11. What’s a plugin?
• The WordPress Codex* defines
a plugin as:
“[...]a program, or a set of one or more
functions, written in the PHP scripting
language, that adds a specific set of features
or services to the WordPress weblog, which
can be seamlessly integrated with the weblog
using access points and methods provided
by the WordPress Plugin Application Program
Interface (API).”**
12. What’s a plugin?
• The WordPress Codex* defines
a plugin as:
“[...]a program, or a set of one or more
functions, written in the PHP scripting
language, that adds a specific set of features
or services to the WordPress weblog, which
can be seamlessly integrated with the weblog
using access points and methods provided
by the WordPress Plugin Application Program
Interface (API).”**
* You do know what the Codex is, right?
** http://codex.wordpress.org/Writing_a_Plugin
16. A plugin...
• Is a piece of software
• Is usually written in a mix of PHP and JavaScript
17. A plugin...
• Is a piece of software
• Is usually written in a mix of PHP and JavaScript
• Supplements or substantially alters the way WordPress functions
18. A plugin...
• Is a piece of software
• Is usually written in a mix of PHP and JavaScript
• Supplements or substantially alters the way WordPress functions
• Uses the WordPress Plugin API* to accomplish the above in a way that
integrates with WordPress
19. A plugin...
• Is a piece of software
• Is usually written in a mix of PHP and JavaScript
• Supplements or substantially alters the way WordPress functions
• Uses the WordPress Plugin API* to accomplish the above in a way that
integrates with WordPress
* http://codex.wordpress.org/Plugin_API
42. Getting started
• This sounds simple, but pick a name for your plugin
• Now pick a “slug” for your plugin
43. Getting started
• This sounds simple, but pick a name for your plugin
• Now pick a “slug” for your plugin
• Check your slug against existing plugins
44. Getting started
• This sounds simple, but pick a name for your plugin
• Now pick a “slug” for your plugin
• Check your slug against existing plugins
• Slugs are universally used by WordPress to identify plugins
45. Getting started
• This sounds simple, but pick a name for your plugin
• Now pick a “slug” for your plugin
• Check your slug against existing plugins
• Slugs are universally used by WordPress to identify plugins
• If you somehow end up with a slug that matches another plugin’s,
there will be trouble
46. Getting started
• This sounds simple, but pick a name for your plugin
• Now pick a “slug” for your plugin
• Check your slug against existing plugins
• Slugs are universally used by WordPress to identify plugins
• If you somehow end up with a slug that matches another plugin’s,
there will be trouble
• Easy solution: unique slug prefix
49. Getting started (cont.)
• Read about the plugin submission process at http://wordpress.org/extend/plugins/about/
50. Getting started (cont.)
• Read about the plugin submission process at http://wordpress.org/extend/plugins/about/
• Go to http://wordpress.org/extend/plugins/add/
51. Getting started (cont.)
• Read about the plugin submission process at http://wordpress.org/extend/plugins/about/
• Go to http://wordpress.org/extend/plugins/add/
• Log in with your WordPress.org account
52. Getting started (cont.)
• Read about the plugin submission process at http://wordpress.org/extend/plugins/about/
• Go to http://wordpress.org/extend/plugins/add/
• Log in with your WordPress.org account
• Register your new plugin
53. Getting started (cont.)
• Read about the plugin submission process at http://wordpress.org/extend/plugins/about/
• Go to http://wordpress.org/extend/plugins/add/
• Log in with your WordPress.org account
• Register your new plugin
• Name and description are required
54. Getting started (cont.)
• Read about the plugin submission process at http://wordpress.org/extend/plugins/about/
• Go to http://wordpress.org/extend/plugins/add/
• Log in with your WordPress.org account
• Register your new plugin
• Name and description are required
• Wait for The Powers That Be to approve your plugin submission
55. Getting started (cont.)
• Read about the plugin submission process at http://wordpress.org/extend/plugins/about/
• Go to http://wordpress.org/extend/plugins/add/
• Log in with your WordPress.org account
• Register your new plugin
• Name and description are required
• Wait for The Powers That Be to approve your plugin submission
• While you wait...
58. Set up your development environment
• You’ll need a development environment
59. Set up your development environment
• You’ll need a development environment
• Local?
60. Set up your development environment
• You’ll need a development environment
• Local?
• Remote?
61. Set up your development environment
• You’ll need a development environment
• Local?
• Remote?
• Local development environment is preferable
62. Set up your development environment
• You’ll need a development environment
• Local?
• Remote?
• Local development environment is preferable
• Disconnected development
63. Set up your development environment
• You’ll need a development environment
• Local?
• Remote?
• Local development environment is preferable
• Disconnected development
• No waiting for uploads
64. Set up your development environment
• You’ll need a development environment
• Local?
• Remote?
• Local development environment is preferable
• Disconnected development
• No waiting for uploads
• Master of your own domain
66. Set up your development environment (cont.)
• Windows
67. Set up your development environment (cont.)
• Windows
• WAMP (http://www.wampserver.com/en/)
68. Set up your development environment (cont.)
• Windows
• WAMP (http://www.wampserver.com/en/)
• XAMPP (http://www.apachefriends.org/en/xampp-windows.html)
69. Set up your development environment (cont.)
• Windows
• WAMP (http://www.wampserver.com/en/)
• XAMPP (http://www.apachefriends.org/en/xampp-windows.html)
• OS X
70. Set up your development environment (cont.)
• Windows
• WAMP (http://www.wampserver.com/en/)
• XAMPP (http://www.apachefriends.org/en/xampp-windows.html)
• OS X
• MAMP (http://www.mamp.info/en/index.html)
71. Set up your development environment (cont.)
• Windows
• WAMP (http://www.wampserver.com/en/)
• XAMPP (http://www.apachefriends.org/en/xampp-windows.html)
• OS X
• MAMP (http://www.mamp.info/en/index.html)
• XAMPP (http://www.apachefriends.org/en/xampp-macosx.html)
72. Set up your development environment (cont.)
• Windows
• WAMP (http://www.wampserver.com/en/)
• XAMPP (http://www.apachefriends.org/en/xampp-windows.html)
• OS X
• MAMP (http://www.mamp.info/en/index.html)
• XAMPP (http://www.apachefriends.org/en/xampp-macosx.html)
• NMPP (http://getmnpp.org/)
74. Set up your development
environment (cont.)
• Install WordPress
75. Set up your development
environment (cont.)
• Install WordPress
• Create a new directory under
[WordPress install directory]/
wp-content/plugins
76. Set up your development
environment (cont.)
• Install WordPress
• Create a new directory under
[WordPress install directory]/
wp-content/plugins
• Make sure it matches your
slug!
87. readme.txt
• Full example here: http://wordpress.org/extend/plugins/about/readme.txt
• The important bits are at the top
88. readme.txt
• Full example here: http://wordpress.org/extend/plugins/about/readme.txt
• The important bits are at the top
• Uses a modified Markdown syntax
89. readme.txt
• Full example here: http://wordpress.org/extend/plugins/about/readme.txt
• The important bits are at the top
• Uses a modified Markdown syntax
• Contains important information about your theme
90. readme.txt
• Full example here: http://wordpress.org/extend/plugins/about/readme.txt
• The important bits are at the top
• Uses a modified Markdown syntax
• Contains important information about your theme
• Explicitly controls how your plugin’s WordPress.org directory page looks
105. Meat (cont.)
• Topics for advanced study
• Settings API -- http://codex.wordpress.org/Settings_API
• Options API -- http://codex.wordpress.org/Options_API
• Transients API -- http://codex.wordpress.org/Transients_API
• Widgets API -- http://codex.wordpress.org/Widgets_API
106. Meathooks
• From the Codex:
“Hooks are provided by WordPress to allow your plugin to 'hook into' the rest
of WordPress; that is, to call functions in your plugin at specific times, and
thereby set your plugin in motion.”
109. Meathooks (cont.)
• There are two kinds of hooks (again, from the Codex):
• “Actions: Actions are the hooks that the WordPress core launches at
specific points during execution, or when specific events occur. Your plugin
can specify that one or more of its PHP functions are executed at these
points, using the Action API.”
110. Meathooks (cont.)
• There are two kinds of hooks (again, from the Codex):
• “Actions: Actions are the hooks that the WordPress core launches at
specific points during execution, or when specific events occur. Your plugin
can specify that one or more of its PHP functions are executed at these
points, using the Action API.”
• “Filters: Filters are the hooks that WordPress launches to modify text of
various types before adding it to the database or sending it to the browser
screen. Your plugin can specify that one or more of its PHP functions is
executed to modify specific types of text at these times, using the Filter
API.”