Creating Wordpress Plugins
Who is Here?
• PHP GTA Meetup
• Wordpress Toronto Meetup
• East Toronto Web Design Meetup
About Me – Peter Meth
Degree in Computer Science
Full time web application developer
Also do websites, hosting, consulting
PHP, MySQL, HTML, CSS, Javascript
Wordpress, Joomla
What is Wordpress?
• Most popular Blogging System in the
• Most popular Content Management
System in the World
• Used by 13% of the world's top million
• It’s free and Open Source
What is a Plugin?
• Add functionality without changing core
• Use Wordpress API to interact with
• Not overwritten when Wordpress gets
• 13,000+ Free Plugins on
• Commercial Plugins also available
Why Create Plugins for Wordpress?
• Add functionality for existing Wordpress
• Take advantage of Wordpress security,
stability, infrastructure, templates
• Exposure to a huge userbase
• You may have your own reasons
Naming & File Structure
• Give your plugin a unique name
• Create a main php file
• You can create your own directory
• gets installed in plugins directory:
– {pathtowordpress}/wp-content/plugins/
Standard Header
Plugin Name: Name Of The Plugin
Description: A brief description of
the Plugin.
Activating Your Plugin
• Copy all files to
– {pathtowordpress}/wp-content/plugins/
• Load the wordpress admin
• go to the Plugins menu, click Activate
• Let’s have a look...
• Filters change text as it gets written or
• add_filter('hook_name','myfilter')
function myfilter($content) {
return $content;
• Let’s have a look...
• Actions are the steps that Wordpress
takes to create a page
• add_action('hook_name','myaction')
function myaction() {
Creating a Menu
• Create a new function
• call add_menu_page(..) within it
• add your function to the admin_menu
• use if(is_admin()) for safety
• Let’s have a look...
Creating a Settings Page
Create a function that outputs a form
In the form set action=“options.php”
call settings_fields(..) inside your form
register your fields register_setting(..)
use get_option(..) to retrieve values
Let’s have a look...
Other Ways to Manage Data
• Create your own tables and forms
• Use Wordpress built in Options
• Use Custom Fields mechanism to add
fields to Posts
• Beyond Scope of this presentation
Want More Information?
– (paid videos)
– (commercial plugins)
• B2Template plugin by Dan Imbrogno
Questions & Answers

Creating Wordpress Plugins - East Toronto Web Design Meetup