WordPress plugins

8,396 views

Published on

A WordPress presentation from WordCampDev Toronto 2012

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
  • The ways to create wordpress plugins have been narrated here very easily . Thanks a lot for doing such a good job
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
8,396
On SlideShare
0
From Embeds
0
Number of Embeds
895
Actions
Shares
0
Downloads
75
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

WordPress plugins

  1. 1. How to create aWordPress plugin.WordCamp Toronto Dev 2012@thisismyurl
  2. 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. 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. 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. 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. 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. 7. Plugin header
  8. 8. Plugin header
  9. 9. Complete Plugin
  10. 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. 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. 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. 13. Building a PluginLet’s get started with something basic.
  14. 14. A standard WordPress function
  15. 15. A standard WordPress plugin
  16. 16. Adding a link items to the Plugins page list
  17. 17. Adding an item to the Settings menu
  18. 18. Creating a settings page
  19. 19. Adding items to the settings page
  20. 20. Defining the settings page
  21. 21. Defining the default values
  22. 22. Showing the values
  23. 23. A standard WordPress function
  24. 24. A standard WordPress function, calling settings
  25. 25. Adding a Shortcode
  26. 26. The entire pluginhttp://wordpress.org/extend/plugins/fetch-twitter-count-for-wordpress/
  27. 27. How to uninstall the data from your plugin• Stored separately in an uninstall.php file.
  28. 28. Plugin Best PractisesSome ideas on how to do it right.
  29. 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. 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. 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. 32. Be lazy, but smart.In my experience, somebody else has already done a lot of theheavy lifting so look before you code.
  33. 33. Contributing a Plugin.How to help.
  34. 34. Be respectful.Some authors like to work on their plugins alone. If you’dlike to help, ask.
  35. 35. Fork it.All plugins on WordPress.org are released under the GNUlicensing terms, if you can’t collaborate, innovate.
  36. 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. 37. @thisismyurlChristopher Ross (info@thisismyurl.com)

×