Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Theme Hook Alliance

72aa943f41c23b6695dfc47cc6faba2e?s=47 Mike Hansen
September 23, 2013

Theme Hook Alliance

WordCamp SLC 2013


Mike Hansen

September 23, 2013


  1. Theme Hook Alliance for Users and Developers @MikeHansenMe

  2. Definition of a Hook 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.
  3. Definition of an Alliance An alliance is a pact, coalition

    or friendship between two or more parties, made in order to advance common goals and to secure common interests.
  4. A Pain Point for Users Quotes from plugins in the

    wp.org repo “Paste the following code to your Wordpress Theme file” “and you can copy one (and paste it to a theme file)” “paste this php code < ? php do_shortcode("[XX_123_123]"); ? > in any template” “Yes, you needed to edit your theme file for adding this function” WHY? Because the plugin author had no hook to count on in the theme
  5. Pain Point for Plugin Developers How do I get this

    into the theme? Is there a core hook? Ask the user to paste php into a theme….
  6. Pain Points for Theme Developers Plugin not working with a

    theme Users losing content because they edit the theme then update Supporting multiple plugins(general)
  7. A Reasonable Solution • 4 sections ◦ before ◦ top

    ◦ bottom ◦ after • Major sections ◦ html ◦ head ◦ body ◦ content ◦ entry ◦ comments ◦ sidebar ◦ footer
  8. Implementation In the theme: <div id="main" class="wrapper"> <?php tha_content_top(); ?>

    In the theme’s function.php function tha_content_top(){ do_action( 'tha_content_top' ); } Plugin usage add_action( 'tha_content_top', 'plugin_function' );
  9. Switching Themes

  10. Writing Better Plugins

  11. Benefits of 3rd Party Management • Core Version Agnostic •

    Knowing you plugin will work with “compatible” themes • Reduce Core bloat • GitHub discussion
  12. Mike Hansen Twitter @MikeHansenMe

  13. Credits and Additional Resources https://github.com/zamoose/themehookalliance http://yoast.com/standard-wordpress-theme-hooks/ http://www.wptavern.com/the-theme-hook-alliance http://literalbarrage.org/blog/2012/06/29/wordpress-theme-hook-alliance/ http://literalbarrage.org/blog/2012/07/02/theme-hook-alliance-first-pass-1-0-draft/ http://dougal.gunters.org/blog/2012/07/13/theme-hook-alliance-sidebar-edition/

    https://coderwall.com/p/lr0k8q @MikeHansenMe