Theme Hook Alliance
for Users and Developers
@MikeHansenMe
Slide 2
Slide 2 text
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.
Slide 3
Slide 3 text
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.
Slide 4
Slide 4 text
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
Slide 5
Slide 5 text
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….
Slide 6
Slide 6 text
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)
Slide 7
Slide 7 text
A Reasonable Solution
● 4 sections
○ before
○ top
○ bottom
○ after
● Major sections
○ html
○ head
○ body
○ content
○ entry
○ comments
○ sidebar
○ footer
Slide 8
Slide 8 text
Implementation
In the theme:
In the theme’s function.php
function tha_content_top(){
do_action( 'tha_content_top' );
}
Plugin usage
add_action( 'tha_content_top', 'plugin_function' );
Slide 9
Slide 9 text
Switching Themes
Slide 10
Slide 10 text
Writing Better Plugins
Slide 11
Slide 11 text
Benefits of 3rd Party Management
● Core Version Agnostic
● Knowing you plugin will work with
“compatible” themes
● Reduce Core bloat
● GitHub discussion