Your SlideShare is downloading. ×
WordPress Plugin Development For Beginners
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

WordPress Plugin Development For Beginners


Published on

My presentation from WordPress DC 11/9/10

My presentation from WordPress DC 11/9/10

Published in: Technology, Business

  • 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. WordPress Plugin Development for Beginners John P. Bloch Senior Web Developer Avendi Media, Inc. @johnpbloch
  • 2. What Are Plugins?  The stupid answer:  Anything you want*  *theoretically, at least  The useful answer:  Non-essential and elective aspects of any given WordPress installation
  • 3. Wait a Minute... Aren't plugins just extensions of WordPress? Don't they just add functionality that isn't there?
  • 4. Plugins are Part of WordPress  Plugins have primacy of place  Plugins interact with WordPress in the same way WordPress interacts with itself
  • 5. An Example Plugin
  • 6. How Do Plugins Work?  Almost all plugin use hooks. There are two kinds of hooks:  Actions  Filters  What's the difference?  Filters expect you to return something, and...  … that's it!  Hooks let you tell WordPress to execute a function when the specified hook fires
  • 7. How To Use Hooks  Filters:  <?php add_filter( 'filter_name', 'function_name' ); ?>  Actions:  <?php add_action( 'action_name', 'func_name' ); ?>  Both functions take two optional arguments:  Priority  Accepted Arguments
  • 8. How To Fire Hooks  To fire an action:  <?php do_action( 'action_name' ); ?>  This fires all functions hooked into that action  To fire a filter:  <?php apply_filters( 'filter_name', 'Filter value' ); ?>  The 'Filter value' will be the first argument of each hooked function  apply_filters will return the filtered input
  • 9. How Does Priority Work? Actions and filters are executed in the order they are added. So this code will echo: First Second Third
  • 10. How Does Priority Work? Priority changes this order. Actions and filters have a default priority of 10. Using a lower number gives it higher priority. This code ouputs: Third First Second
  • 11. Accepted Arguments  Accepted arguments allows you to specify how many arguments to send to a hooked function  Defaults to 1 for both actions and filters  The following would output: Don't mention Joomla Don't mention
  • 12. Some Common Hooks  Actions  init  template_redirect  admin_init  after_setup_theme  wp_loaded  wp_head  wp_footer  admin_menu  Filters  the_content  the_title  wp_title  template_include  body_class  post_class
  • 13. But Wait! There's More!  One more way to hook into WordPress is through shortcodes  Shortcodes are inserted into a post or page from the editor; WordPress replaces the shortcode tags with dynamically generated content  Shortcodes are kind of like HTML:  [foo bar='bar']  [foo bar='bar']Some Content[/foo]
  • 14. How to Add a Shortcode  Shortcodes must be registered:  <?php add_shortcode( 'tag_name', 'function_name' ); ?>  Shortcode handlers take two optional arguments:  Arguments: an array of arguments from the shortcode  Content: the content (if any) of the shortcode  Shortcode handlers should return, not echo, their content
  • 15. An Example of a Shortcode
  • 16. Developer Toolbox  Local development environment  LAMPP Stack (XAMPP –  Subversion  Windows: TortoiseSVN or Cygwin  Everything else: CLI  Text Editor  FTP client  Mac: Transmit  SSH Client  Windows: Putty  Reference  PHPXref (
  • 17. WordPress Developer Toolbox  Official Support Channels  WordPress Codex (  WordPress Forums (  IRC Channel #wordpress (  Mailing Lists (sort of) (  Unofficial Support Channels  WordPress Answers (  WordPress Docs (  Alot of Books
  • 18. Just Because
  • 19. Adding Your Plugin to the Directory   Answer a few questions  Name – Very important! This will determine the name of the directory your plugin creates  Description  Plugin URL (optional)  … And wait!
  • 20. What is SVN? SVN, or Subversion, is a version control program. Others include Git and Mercurial. Subversion is used for core WordPress development/distribution and official plugin development/distribution. Once you have your repository, anybody in the world can check it out. Only you* can check files into it. *Technically, Nacin and some others have global plugin repo commit access. #blamenacin
  • 21. How to Use SVN  If you are on windows and use TortoiseSVN, just follow these next steps substituting ”Click X menu item” for ”Execute X command”  Go to the directory into which you'd like the repo to go:  ~$ cd Documents/svn  Check out your repository for the first time:  ~$ svn co custom-post-permalinks  Edit to your heart's content
  • 22. How to Use SVN  When you're done making changes (or reach a good stopping point), commit your changes:  ~$ svn ci -m 'This is a description of the commit!'  … Tada!
  • 23. Some Other Notes on SVN  Updating your plugin  Tagging vs. Stable Trunk  Branching  Adding committers (and other admin tools)
  • 24. Further Reading  Core.  Core.  Core.  Seriously. Just read core's runtime execution.  Line by line.
  • 25. Now Let's Get Down to Business! Time to switch gears, open VIM, and write a plugin!