Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Theme Hook Alliance

Mike Hansen
September 23, 2013

Theme Hook Alliance

WordCamp SLC 2013

Mike Hansen

September 23, 2013
Tweet

More Decks by Mike Hansen

Other Decks in Technology

Transcript

  1. 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.
  2. 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.
  3. 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
  4. 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….
  5. 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)
  6. A Reasonable Solution • 4 sections ◦ before ◦ top

    ◦ bottom ◦ after • Major sections ◦ html ◦ head ◦ body ◦ content ◦ entry ◦ comments ◦ sidebar ◦ footer
  7. 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' );
  8. Benefits of 3rd Party Management • Core Version Agnostic •

    Knowing you plugin will work with “compatible” themes • Reduce Core bloat • GitHub discussion