Writing Your First WordPress Plugin

4,216 views

Published on

How to write a WordPress plugin.

Published in: Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,216
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
80
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

Writing Your First WordPress Plugin

  1. 1. Writing Your First Plugin by Mark Jaquith @markjaquith markjaquith.com Saturday, August 21, 2010
  2. 2. Assumptions • You know PHP syntax • You’re targeting PHP 5 Saturday, August 21, 2010
  3. 3. What I want you to learn • Plugins change what WordPress does • They rely on the concepts of actions and filters • There are numerous internal WordPress APIs for you to use Saturday, August 21, 2010
  4. 4. What is a Plugin? • PHP code that sits in separate files • Integrates tightly with WordPress • Can add, alter, or remove functionality Saturday, August 21, 2010
  5. 5. Where? • wp-content/plugins/name.php • wp-content/plugins/folder/name.php • WordPress only looks one level deep • It looks for .php files with a plugin header Saturday, August 21, 2010
  6. 6. Plugin Header “Plugin Name” is required. Saturday, August 21, 2010
  7. 7. Basic Structure • Build some stuff • Tell WordPress to use that stuff when WordPress does certain stuff Saturday, August 21, 2010
  8. 8. Actions • Triggered when various things happen in WordPress core • “Wakes up” code you’ve registered against that action Saturday, August 21, 2010
  9. 9. Actions Saturday, August 21, 2010
  10. 10. Actions Saturday, August 21, 2010
  11. 11. Filters • WordPress passes data to your code • Your code optionally changes the data, then returns it to WordPress Saturday, August 21, 2010
  12. 12. Filters Saturday, August 21, 2010
  13. 13. Filters Saturday, August 21, 2010
  14. 14. How to organize your plugin Saturday, August 21, 2010
  15. 15. Saturday, August 21, 2010
  16. 16. Saturday, August 21, 2010
  17. 17. Prefix cws_spn_function_name() Saturday, August 21, 2010
  18. 18. Singleton Saturday, August 21, 2010
  19. 19. Singleton variation Saturday, August 21, 2010
  20. 20. Most Important Action in WordPress init Saturday, August 21, 2010
  21. 21. Let’s build a plugin! • Insert mailing address and phone number into a post or a page • Use a shortcode... [address] • Configurable address and phone number • Option to show phone number by default (or not) • Ability to override the phone number default Saturday, August 21, 2010
  22. 22. Saturday, August 21, 2010
  23. 23. Saturday, August 21, 2010
  24. 24. Saturday, August 21, 2010
  25. 25. Saturday, August 21, 2010
  26. 26. Saturday, August 21, 2010
  27. 27. Saturday, August 21, 2010
  28. 28. Saturday, August 21, 2010
  29. 29. Saturday, August 21, 2010
  30. 30. Settings form handle Setting name Saturday, August 21, 2010
  31. 31. Section handle Title Content callback Settings form handle Saturday, August 21, 2010
  32. 32. HTML id Title Content callback Settings form handle Section handle Saturday, August 21, 2010
  33. 33. Saturday, August 21, 2010
  34. 34. Saturday, August 21, 2010
  35. 35. Saturday, August 21, 2010
  36. 36. Saturday, August 21, 2010
  37. 37. Saturday, August 21, 2010
  38. 38. Saturday, August 21, 2010
  39. 39. Saturday, August 21, 2010
  40. 40. Saturday, August 21, 2010
  41. 41. Saturday, August 21, 2010
  42. 42. Saturday, August 21, 2010
  43. 43. Saturday, August 21, 2010
  44. 44. http://txfx.net/s/3q Saturday, August 21, 2010

×