Upload
pippin-williamson
View
134
Download
1
Tags:
Embed Size (px)
DESCRIPTION
An introduction to writing your first WordPress plugin. These are simple slides that accompanied an in-depth presentation.
Citation preview
Writing Your Own PluginsThe basics and more
Pippin Williamsonpippinsplugins.com
@pippinsplugins
What makes up a plugin?
wp-content/plugins/my-plugin-name/
.php files
.js files
.css files
.mo/po files
image files
What defines a plugin?
The plugin header
wp-content/plugins/my-plugin/my-plugin.php
<?php/** * Plugin Name: My Plugin Name * Description: A simple plugin * Version: 1.0 * Author: Pippin Williamson * Author URI: http://pippinsplugins.com */
The plugin header
plugins/simple-post-expiration/simple-post-expiration.php
<?php/** * Plugin Name: Simple Post Expiration * Description: A simple post expiration plugin * Version: 1.0 * Author: Pippin Williamson * Author URI: http://pippinsplugins.com */
/wp-admin/plugins.php
Quick demo time
The plugin API
Action hooks:
do_action()add_action()remove_action()remove_all_actions()has_action()did_action()doing_action
Quick demo timewp_footer action
https://github.com/WordPress/WordPress/blob/master/wp-includes/general-template.php#L2051
The plugin API
Filter hooks:
apply_filters()add_filter()remove_filter()remove_all_filters()has_filter()current_filter()doing_filter()
Quick demo timethe_title filter
https://github.com/WordPress/WordPress/blob/master/wp-includes/post-template.php#L99
Plugins for InspirationThere are so many possibilities
Inspiring Dashboard
Not sure what to write about for your next blog post?
Maybe this Dashboard Widget can inspire you.
Adds a dashboard widget
Provides quick inspiration on something to write
http://wordpress.org/plugins/inspiring-dashboards/
Multi Site Plugins Add New
Enables the “Add New” menu under Plugins for multisite
The Add New Plugin screen is hard to get to
This plugin adds a shortcut
http://wordpress.org/plugins/multi-site-plugins-add-new/
CodePen oEmbed
Adds oEmbed support for CodePen.io
The Add New Plugin screen is hard to get to
This plugin adds a shortcut
http://wordpress.org/plugins/codepen-oembed/
Remove Comment Notes
Removes the notes section below the comment form
The notes section can create clutter
It isn’t needed in the majority of cases
http://wordpress.org/plugins/remove-comment-notes/
Write First
Blogging is about writing
Sends users directly to the edit screen upon login
http://wordpress.org/plugins/write-first/
Simple Post Expiration
A simple plugin to add an expiration date to posts
adds an “Expires on” field to post editor
prepends “Expired” to post titles once expired
is really simple
https://github.com/pippinsplugins/simple-post-expiration
Items to keep in mind
Overall structure of the plugin
How the data is stored
Features for launch
Features for tomorrow
Updates
Backwards compatibility
How the plugin will be distributed
When will you get started?