Presentation is loading. Please wait.

Presentation is loading. Please wait.

WordPress from Start to Finish Day 3: Working with plugins (

Similar presentations

Presentation on theme: "WordPress from Start to Finish Day 3: Working with plugins ("— Presentation transcript:

1 WordPress from Start to Finish Day 3: Working with plugins (

2 Required Plugin Files There is technically only one required file – pluginname.php (same as the folder name) However, if you want to host your Plugin on, you also need to create a readme.txt file in a standard format, and include it with your Plugin. See me.txt for a description of the format. me.txt

3 Standard Plugin Information The top of your Plugins main PHP file should contain a standard Plugin information header. This header lets WordPress recognize that your Plugin exists, add it to the Plugin management screen so it can be activated, load it, and run its functions; without the header, your Plugin will never be activated and will never run. Here are the header arguments: – Plugin Name: Name Of The Plugin – Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates – Description: A brief description of the Plugin. – Version: The Plugin's Version Number, e.g.: 1.0 – Author: Name Of The Plugin Author – Author URI: http://URI_Of_The_Plugin_Author – License: A "Slug" license name e.g. GPL2 Example: plugin-header.txt plugin-header.txt

4 Create an Options Page There are several ways to skin this cat, but this is the easiest. Pay attention to these functions: – add_options_page() add_options_page() – settings_fields() settings_fields() – do_settings_sections() do_settings_sections() – register_setting() register_setting() – add_settings_section() add_settings_section() – add_settings_field() add_settings_field() – get_options() get_options() Example: options-page.txt options-page.txt

5 The Cat API Well need to make sure we create and include The Cat API into our plugin. – include_once( plugin_dir_path( __FILE__ ). '/the-cat- api.php' ); – Example: ining-plugin-the-cat-api.txt ining-plugin-the-cat-api.txt

6 Adding Shortcodes To add a shortcode, you simply need to run the function add_shortcode() which takes two arguments, the shortcode name and the function it calls to process the shortcode. add_shortcode() – Example: plugin-shortcodes.txt plugin-shortcodes.txt Include the shortcode file into our main plugin file. – include_once( plugin_dir_path( __FILE__ ). '/catnip- shortcodes.php' ); – $catnip_shortcodes= new catnip_shortcodes();

7 Adding Widgets Widgets are a little more complicated, you need to register your widgets with register_widget() which should be called with the widgets_init action. Then you should extend the WP_Widgets API Class to create your new widget.register_widget() – Example: plugin-widgets.txt plugin-widgets.txt Include the new widget file into our main plugin file. – include_once( plugin_dir_path( __FILE__ ). '/catnip- widgets.php' );

8 The Plugins readme.txt Before submitting our plugin to the WordPress repository, we need to create a readme.txt. – Example: ptraining-plugin-readme.txt ptraining-plugin-readme.txt

9 Submit to the WP Plugin Repository Zip your plugin and upload it to an online resource that will hold the plugin. Be sure to check out the Developer FAQ and the detailed guidelines before submitting your plugin. Visit and fill out the required information. After you submit your plugin, youll need to wait for it to be approved, then you will receive information for accessing Subversion.

10 WordPress SVN Access Upon approval of your plugin, youll get an email like this one: layotte, Your plugin hosting request has been approved. Within one hour, you will have access to your SVN repository at with your username and password (the same one you use on the forums). Here's some handy links to help you get started. Using Subversion with the WordPress Plugins Directory FAQ about the WordPress Plugins Directory WordPress Plugins Directory readme.txt standard readme.txt validator: Enjoy! I prefer to use TortoiseSVN for my Windows SVN Client as well as the plugin for Dreamweaver called SubWeaver.TortoiseSVNSubWeaver

11 MU Plugins You can create a directory in /wp-content/ for plugins that you always want activated, no options for any users to deactivate them. The directory is mu-plugins. E.g. /wp-content/mu- plugins/ – Example: ining-mu-plugin.txt ining-mu-plugin.txt This mostly used in WordPress Multi-Site installations.

12 Dont Forget to Donate wordpress-plugin-developer/ wordpress-plugin-developer/ favorite-wordpress-plugin-developer-on-march-1st/ favorite-wordpress-plugin-developer-on-march-1st/ wordpress-plugin-developers/ wordpress-plugin-developers/ In short, if you dont support the plugin developers who make your life easy, you run the risk of that plugin being abandoned. As much as developers want to make you happy, its currently not legal to feed their families with happy people. Paying work will almost always come before charity work. And most of these developers arent just developing plugins for WordPress, they also have to spend time with support questions about their plugin.

13 Did I mention Donating? Also, you may have noticed WordPress is completely free. If youre making money from WordPress, Id recommend giving back to the WordPress community. You can donate by visiting the WordPress Foundation donation page.WordPress Foundation

14 Next Week… WordPress Multi-Site JavaScript, CSS, and AJAX in Plugins Other Advanced APIs built into WordPress More on i18n – Internationalization Questions

Download ppt "WordPress from Start to Finish Day 3: Working with plugins ("

Similar presentations

Ads by Google