[wp-trac] [WordPress Trac] #21506: Standard Theme Hooks

WordPress Trac noreply at wordpress.org
Fri Feb 22 18:03:37 UTC 2013


#21506: Standard Theme Hooks
---------------------------+------------------------------
 Reporter:  mfields        |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Bundled Theme  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:                 |
---------------------------+------------------------------

Comment (by greenshady):

 One way we can cut down on themes implementing these hooks is to add an
 "after" hook to match these:

 * `get_template_part_{$slug}`
 * `get_header`
 * `get_footer`
 * `get_sidebar`
 * `get_searchform`

 These hooks already exist in core.  We could add these hooks at the end of
 those functions:

 * `get_template_part_{$slug}_after`
 * `get_header_after`
 * `get_footer_after`
 * `get_sidebar_after`
 * `get_searchform_after`

 For example, the `get_header()` function would look like this:

 {{{
 function get_header( $name = null ) {
         do_action( 'get_header', $name );

         $templates = array();
         if ( isset($name) )
                 $templates[] = "header-{$name}.php";

         $templates[] = 'header.php';

         // Backward compat code will be removed in a future release
         if ('' == locate_template($templates, true))
                 load_template( ABSPATH . WPINC . '/theme-
 compat/header.php');

         do_action( 'get_header_after', $name );
 }
 }}}

 Using these would be good for several reasons.

 * Themes don't need to alter their code.
 * Most of these hooks are used across nearly all themes.
 * We'd be building something off existing core hooks and functions.
 * We can cut way back on additional functions for outputting hooks.
 * The only hook we'd really need to consider adding to themes is the one
 for post data. See: #18561

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21506#comment:63>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list