Why & How to Createa WordPressPlugin
Joe Querin – www.joequerin.com
NEO WP West Meetup – June 6, 2017
@joequerin joecue
joecue
{ About: Joe }
• Graphic Design major
• Self taught Web Developer for 19+ years
• Currently work full-time at Lorain County
Community College for 18+ years.
• WordPress experience last 6 years
• Recently completed moving our college
website to WordPress, and working on an additional 6-
8.
www.joequerin.com
{ Overview }
• What is a Plugin?
• Why create a Plugin?
• When should you create a Plugin?
• Ways to write a plugin.
• Demo
• Questions
{ What is a Plugin? }
• Code that adds functionality (Custom Post
Type or Custom Fields, etc)
• Code that alters WordPress Core code
(filters/actions)
• Code to create Widgets
• Many more…
{ Why Create a Plugin? }
• Custom functionality that does not already
exist.
• Want to improve upon an existing plugin idea.
• Need to add functionality that directly impacts
unique content.
• You want to see if you can!
{ Types of Plugins }
• Standard Plugin
/wp-content/plugin/
• MU-Plugin (Must Use Plugin)
/wp-content/mu-plugins/
• Drop-ins
/wp-content/
Don’t have plugin headers, just PHP code.
{ Current List of Dropins }
File Type of Plugin
advanced-cache.php Advanced Caching Plugin (Caching
plugins often use this file)
db.php Custom database class
db-error.php Custom database error message.
install.php Custom install script
maintenance.php Custom maintenance message.
object-cache.php External object cache.
As of WordPress 4.7.5 – June 2017
{ Plugin vs Functions.php }
• On-going debate within the community
• My rule of thumb
(not really mine, since I borrowed the ideas from the community)
– If the functions will create content dependencies, place the
functions in a plugin.
– A content dependency would be a custom post type, custom
fields. Things the site needs to function, without these the site
will break.
– If the functions are more suited for theme needs (custom image
sizes, excerpt length, filter or action that effects content display),
then place those functions in the theme.
– If in doubt, create a plugin
{ Ways to Write a Plugin }
• Site Specific Plugin – WPBeginner
• Very simple and lightweight, good for simple plugins
• WPPB.me – Tom McFarlin and Devin Vinson
• Very robust and developer centric. Great foundation for
a very feature rich and organized plugin.
{ Site Specific Plugin Template }
<?php
/*
Plugin Name: Site Plugin for example.com
Description: Site specific code changes for
example.com
*/
/* Start Adding Functions Below this Line */
/* Stop Adding Functions Below this Line */
?>
Code Demo!!
{ Before we begin }
• What type of plugin are you building?
• What are you building?
• Plan?
• Features?
• Research?
{ Questions? }
Joe Querin
www.joequerin.com
@joequerin
joecue
joecue
{ Links Mentioned }
• WPBeginner Site Specific
http://www.wpbeginner.com/beginners-guide/what-why-and-
how-tos-of-creating-a-site-specific-wordpress-plugin/
• WordPress Plugin Boiler Plate https://wppb.me/
• WordPress Settings API
https://codex.wordpress.org/Settings_API
• Creating Custom Metaboxes
https://www.smashingmagazine.com/2011/10/create-custom-
post-meta-boxes-wordpress
{ Links Mentioned (cont’d) }
• MU-Plugins
https://codex.wordpress.org/Must_Use_Plugins
• Drop-ins
http://wpengineer.com/2500/wordpress-dropins/
https://hakre.wordpress.com/2010/05/01/must-use-
and-drop-ins-plugins/
•

Why & How to Create a WordPress Plugin

  • 1.
    Why & Howto Createa WordPressPlugin Joe Querin – www.joequerin.com NEO WP West Meetup – June 6, 2017 @joequerin joecue joecue
  • 2.
    { About: Joe} • Graphic Design major • Self taught Web Developer for 19+ years • Currently work full-time at Lorain County Community College for 18+ years. • WordPress experience last 6 years • Recently completed moving our college website to WordPress, and working on an additional 6- 8. www.joequerin.com
  • 3.
    { Overview } •What is a Plugin? • Why create a Plugin? • When should you create a Plugin? • Ways to write a plugin. • Demo • Questions
  • 4.
    { What isa Plugin? } • Code that adds functionality (Custom Post Type or Custom Fields, etc) • Code that alters WordPress Core code (filters/actions) • Code to create Widgets • Many more…
  • 5.
    { Why Createa Plugin? } • Custom functionality that does not already exist. • Want to improve upon an existing plugin idea. • Need to add functionality that directly impacts unique content. • You want to see if you can!
  • 6.
    { Types ofPlugins } • Standard Plugin /wp-content/plugin/ • MU-Plugin (Must Use Plugin) /wp-content/mu-plugins/ • Drop-ins /wp-content/ Don’t have plugin headers, just PHP code.
  • 7.
    { Current Listof Dropins } File Type of Plugin advanced-cache.php Advanced Caching Plugin (Caching plugins often use this file) db.php Custom database class db-error.php Custom database error message. install.php Custom install script maintenance.php Custom maintenance message. object-cache.php External object cache. As of WordPress 4.7.5 – June 2017
  • 8.
    { Plugin vsFunctions.php } • On-going debate within the community • My rule of thumb (not really mine, since I borrowed the ideas from the community) – If the functions will create content dependencies, place the functions in a plugin. – A content dependency would be a custom post type, custom fields. Things the site needs to function, without these the site will break. – If the functions are more suited for theme needs (custom image sizes, excerpt length, filter or action that effects content display), then place those functions in the theme. – If in doubt, create a plugin
  • 9.
    { Ways toWrite a Plugin } • Site Specific Plugin – WPBeginner • Very simple and lightweight, good for simple plugins • WPPB.me – Tom McFarlin and Devin Vinson • Very robust and developer centric. Great foundation for a very feature rich and organized plugin.
  • 10.
    { Site SpecificPlugin Template } <?php /* Plugin Name: Site Plugin for example.com Description: Site specific code changes for example.com */ /* Start Adding Functions Below this Line */ /* Stop Adding Functions Below this Line */ ?>
  • 11.
  • 12.
    { Before webegin } • What type of plugin are you building? • What are you building? • Plan? • Features? • Research?
  • 13.
    { Questions? } JoeQuerin www.joequerin.com @joequerin joecue joecue
  • 14.
    { Links Mentioned} • WPBeginner Site Specific http://www.wpbeginner.com/beginners-guide/what-why-and- how-tos-of-creating-a-site-specific-wordpress-plugin/ • WordPress Plugin Boiler Plate https://wppb.me/ • WordPress Settings API https://codex.wordpress.org/Settings_API • Creating Custom Metaboxes https://www.smashingmagazine.com/2011/10/create-custom- post-meta-boxes-wordpress
  • 15.
    { Links Mentioned(cont’d) } • MU-Plugins https://codex.wordpress.org/Must_Use_Plugins • Drop-ins http://wpengineer.com/2500/wordpress-dropins/ https://hakre.wordpress.com/2010/05/01/must-use- and-drop-ins-plugins/ •