Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Creating Your First WordPress Plugin

2,922 views

Published on

Reno-Tahoe WordCamp 2009 - I went over the basics of plugin development. The example code and other files are available at www.colinloretz.com

Published in: Technology, Business

Creating Your First WordPress Plugin

  1. 1. Creating Your First WordPress Plugin Colin Loretz
  2. 2. Why?
  3. 3. codex.wordpress.org Know it Breathe it Live it
  4. 4. Anatomy of a Plugin Plugin Folder Name • main php file • js folder • css folder • php folder
  5. 5. Anatomy of a Plugin reno-wordcamp • reno-wordcamp.php • js • css • php
  6. 6. Main PHP File <?php /* Plugin Name: Your Plugin Name Here Plugin URI: Your Plugin URI Version: Current Plugin Version Author: You Description: What does this do? */
  7. 7. reno-wordcamp.php <?php /* Plugin Name: Reno WordCamp Plugin URI: http://renotahoewordcamp.com Version: v1.0 Author: <a href = “http://colinloretz.com”>Colin Loretz</a> Description: A plugin for Reno WordCamp */
  8. 8. Adding an Action function addHeaderCode() { echo ʻHello from the clouds!ʼ; }
  9. 9. Actions & Filters //Actions add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1); ?>
  10. 10. Adding a Filter function addContent($content=ʼʼ) { $content .= ʻ<p>Colin is at WordCamp.</p>ʼ; return $content; }
  11. 11. Actions & Filters //Actions add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1); //Filters add_filter(ʻthe_contentʼ, ʻaddContentʼ); ?>
  12. 12. Adding a Shortcode [renowordcamp]
  13. 13. Adding a Shortcode function renoShortcode($att) { extract(shortcode_atts(array( 'foo' => 'no foo', 'bar' => 'default bar', ), $atts)); return quot;foo = {$foo}quot;; }
  14. 14. Add the Shortcode //Actions add_action(ʻwp_headʼ, ʻaddHeaderCodeʼ, 1); //Filters add_filter(ʻthe_contentʼ, ʻaddContentʼ); //Shortcodes add_shortcode('renowordcamp', 'renoShortcode');
  15. 15. Going Further Saving & Storing Explore Plugins Learn from others Options Post Metadata Database
  16. 16. Want More? • Wordpress.org (and codex) • WP-Hacker email list (google it) • WordPress Planet
  17. 17. Find Me @colinloretz www.colinloretz.com

×