WordPress plugins

Uploaded on

A WordPress presentation from WordCampDev Toronto 2012

A WordPress presentation from WordCampDev Toronto 2012

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. How to create aWordPress plugin.WordCamp Toronto Dev 2012@thisismyurl
  • 2. What is a Plugin?A WordPress plugin is a PHP based addition to theWordPress blogging platform.• Plugins are functions which interact with WordPress Core code;• A Plugin changes what WordPress does;• Plugins are stored external of the theme;
  • 3. What can they do?Since Plugins are executed as part of the WordPress platform,they’re almost limitless.• Plugins can interact with WordPress via Hooks and Actions;• They can create, or interact with API’s in the WordPress system;• Plugins can affect Posts, Pages, Users, or any part of the WordPress tool;
  • 4. When should you use aPlugin?Plugin functions can be stored as a plugin, or in a themefunction.php file, why choose?• Functions are specifically part of the theme;• Plugins allow you to share code outside a theme, across multiple designs;• Plugins can be activated in multisite environments;
  • 5. Theme functions arerestricted to a singletheme. Plugins deliver the same code to multiple blogs, on the same server or across multiple hosting accounts.
  • 6. How WordPress finds aPluginWordPress will automatically locate plugins on a standardinstall, adding them to the admin• /wp-content/plugins/filename.php• /wp-content/plugins/folder-name/filename.php• WordPress will search one level deep in the plugins folder;• Searches for .php files with a valid plugin header;
  • 7. Plugin header
  • 8. Plugin header
  • 9. Complete Plugin
  • 10. Play nice with otherfunctionsRemember WordPress shares your plugin functions across theentire site, be unique• Your plugins should use a unique name for all functions;• function demo_plugin_function_name() for example;• Plugin file load order is determined by WordPress;
  • 11. What are Actions?Actions are triggered by WordPress, causing your plugin tospring to life.• There’s an action for almost everything WordPress does• http://codex.wordpress.org/Plugin_API/Action_Reference
  • 12. What are Filters?Filters allow you to change content WordPresshas created.• There’s an filter for almost everything WordPress does• http://codex.wordpress.org/Plugin_API
  • 13. Building a PluginLet’s get started with something basic.
  • 14. A standard WordPress function
  • 15. A standard WordPress plugin
  • 16. Adding a link items to the Plugins page list
  • 17. Adding an item to the Settings menu
  • 18. Creating a settings page
  • 19. Adding items to the settings page
  • 20. Defining the settings page
  • 21. Defining the default values
  • 22. Showing the values
  • 23. A standard WordPress function
  • 24. A standard WordPress function, calling settings
  • 25. Adding a Shortcode
  • 26. The entire pluginhttp://wordpress.org/extend/plugins/fetch-twitter-count-for-wordpress/
  • 27. How to uninstall the data from your plugin• Stored separately in an uninstall.php file.
  • 28. Plugin Best PractisesSome ideas on how to do it right.
  • 29. Be unique.Remember Plugins interact will all the code on yourWordPress website, make sure you’re unique.• Classes and Functions should use unique names;• thisismyurl_plugin_name_function_name() for example;
  • 30. Be descriptive.Your Plugin is part of something else, make sure people caneasily understand your code.• Elements should use verbose naming conventions, easy to understand;• $i is bad;• $loop_resume_posts is good;
  • 31. Be consistent.There are standards in the WordPress community, followingthem makes it easy.• The WordPress coding standards make coding easier in the long run;• If you’re following your own coding standards, stick to them;• http://codex.wordpress.org/WordPress_Coding_Standards
  • 32. Be lazy, but smart.In my experience, somebody else has already done a lot of theheavy lifting so look before you code.
  • 33. Contributing a Plugin.How to help.
  • 34. Be respectful.Some authors like to work on their plugins alone. If you’dlike to help, ask.
  • 35. Fork it.All plugins on WordPress.org are released under the GNUlicensing terms, if you can’t collaborate, innovate.
  • 36. Give Back.If you’ve written a WordPress Plugin that you think thecommunity will benefit from, submit it to WordPress.org forreview and consideration.
  • 37. @thisismyurlChristopher Ross (info@thisismyurl.com)