The Software People's (TSP) Easy Dev for WordPress is an application programming interface (API) for WordPress plugin development. Easy Dev makes OOD hot again and it's the engine that powers all WordPress plugins created by The Software People!
All the hard work is done for you (see features below) The only thing you have to do is process the information returned to you and display your data to the screen.
If your plugin requires any of the following options to be stored in the database, you will need to create an advanced settings file:
Widget - Fields that will display on every widget for the plugin
Settings - Fields that will display on the settings page
Shortcodes - Fields that will display on the settings page for setting default values for shortcodes
Post Fields - Fields that will display upon editing and creating posts
Category Fields - Fields that will display upon editing and creating post categories
Remember: You can name your config file any name you want and store it in any location, as long as your main plugin file has access to it and requires it.
The recommended name for the config file is '''TSP_Easy_Dev.config.php''' and it should be placed in the save directory level as your plugin file.
If your plugin will uses a settings menu then you are required to define the following settings (fyi Smarty will automatically be required to generate pages):
$easy_dev_settings['parent_name']="my_parent_menu";// The main menu to ID your settings will be placed under, leave BLANK/NULL if the plugin has no menu to be nested under
$easy_dev_settings['parent_title']="Parent Menu";// The title of the menu your settings will appear under, leave BLANK/NULL if the plugin has no menu to be nested under
$easy_dev_settings['menu_pos']="2833.23";// A menu position where your menu will be placed, adding decimals decreases the chances that other plugins will have the same menu position
$easy_dev_settings['option_prefix']=$easy_dev_settings['name']."-option";// The option name, where your settings will be stored in the database
$easy_dev_settings['option_prefix_old']=$easy_dev_settings['TextDomain']."_options";// For cleanup from previous versions, If you have renamed your option name, specify the name here and it will be removed automatically
If your plugin stores data of any kind, you will need to supply the fields that will be displayed to the user based on where they will be displayed. For example, if the user can add a widget to their side menu, then you will need to define the widget fields that the user will need to update.
If you need to save Widget data: widget_fields will need to be added to the array `$easy_dev_settings('plugin_options')`
If you need to save Settings data: settings_fields will need to be added to the array `$easy_dev_settings('plugin_options')`
If you need to save Post data: post_fields will need to be added to the array `$easy_dev_settings('plugin_options')`
If you need to save Category data: category_fields will need to be added to the array `$easy_dev_settings('plugin_options')`
If you need to save Shortcode data: shortcode_fields will need to be added to the array `$easy_dev_settings('plugin_options')`
All data fields have the following options, new types are being added so be sure to update often.
'type' // the field type, available INPUT, TEXT, SELECT, TEXTAREA [Pro Version includes IMAGE]
'label' // the field's label text, not required for TEXT
'value' // the default value of the field
'old_labels' // If this is NOT your first version of your plugin and you have renamed a field in this version, place the old field name value in this array, FOR SHORTCODE USE
'options' // array of values used for SELECT, Label => Value format
'html' // true or false, allow HTML, default false
Below is an example of a plugin that uses a widget to display a title (`title`), description (`desc`) and whether or not to hide the description (`hide_desc`). It also has a settings page that simply displays instructions to the user.
Create Extends File: Extend Easy Dev Classes ⇑ top
The only reason why there is a need to extend Easy Dev is to perform some logic that your plugin requires. We have no way of knowing what that logic is so in order for Easy Dev to work for you, you MAY need to extend classes in order to perform some logic for your plugin.
Extend the `TSP_Easy_Dev_Options` or `TSP_Easy_Dev_Pro_Options`(Pro) class if your plugin needs an options menu.
Extend the TSP_Easy_Dev_Widget class if your plugin requires a widget or shortcode.
If you don't require any of these then you will not need to create an extends file.
Remember: You can name your extends file any name you want and store it in any location, as long as your main plugin file has access to it and requires it ('''config file must be required first before the extends file''').
The recommended name for the extends file is '''TSP_Easy_Dev.extend.php''' and it should be placed in the save directory level as your plugin file.
If your plugin requires options you will need AT LEAST implement the `display_parent_page` and `display_plugin_options_page` methods. Below is sample code that implements these methods. Remember the class names must be unique.
* Extends the TSP_Easy_Dev_Options Class
class TSP_Easy_Dev_Options_MY_PLUGIN extends TSP_Easy_Dev_Options
If your plugin requires a widget you will need to AT LEAST implement the `__construct`, `init`, `display_form` and `display_widget` methods. Below is sample code that implements these methods. Remember the class names must be unique.
Remember: Take note of the REQUIRED comments below
* Extends the TSP_Easy_Dev_Widget Class
class TSP_Easy_Dev_Widget_MY_PLUGIN extends TSP_Easy_Dev_Widget
* Constructor - The following filter is required inside of this constructor. WordPress makes a call to this class statically and in order to
* initialize it we have to add a filter. The filter will be applied inside the main plugin file.
Now that you have created your configuration (TSP_Easy_Dev.config.php) and extends file (TSP_Easy_Dev.extend.php) you can now create your main plugin file. You can always go back to your extends file and add in more logic later.
Below is an actual plugin implementation that uses Easy Dev. As you can see, there is only ONE unavoidable call, the rest is handled by Easy Dev.
To take full advantage of all the features of Easy Dev, please visit Easy Dev API page.
Remember: Take note of the REQUIRED comments below
$message= TSPFC_PLUGIN_TITLE .' <strong>was not installed</strong>, plugin requires the installation of <strong><a href="plugin-install.php?tab=search&type=term&s=TSP+Easy+Dev">TSP Easy Dev</a></strong>.';
$featured_categories=new TSP_Easy_Dev_Pro( TSPFC_PLUGIN_FILE, TSPFC_PLUGIN_REQ_VERSION );// REQUIRED, Pass in the plugin file AND the required version for ALL versions of Easy Dev
// Once the options handler is set your extended TSP_Easy_Dev_Options will have access to the plugin options. See API for functions available to you from the TSP_Easy_Dev_Options class
$featured_categories->set_options_handler(new TSP_Easy_Dev_Options_Featured_Categories($easy_dev_settings),false,true);// The TSP_Easy_Dev_Options class handles settings, See API docs for further param explanations
$featured_categories->set_widget_handler('TSP_Easy_Dev_Widget_Featured_Categories');// We hate doing this but there is no workaround, supply the text name of your extended TSP_Easy_Dev_Widget class here
// Queue User styles
$featured_categories->add_css( TSPFC_PLUGIN_URL . TSPFC_PLUGIN_NAME .'.css');// See API docs for further param explanations
// Queue User Scripts
$featured_categories->add_script( TSPFC_PLUGIN_URL .'js'. DS .'jquery.smoothDivScroll-1.1.js',array('jquery','jquery-ui-widget'));// See API docs for further param explanations