Make WordPress Core


Ignore:
Timestamp:
02/14/2010 09:32:23 AM (15 years ago)
Author:
westi
Message:

Introduce new get_generic_template() function for themes to use to bring in pieces of template.
Use in twentyten for loop.php including. See #9015.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/general-template.php

    r13143 r13146  
    9292    if ('' == locate_template($templates, true))
    9393        load_template( get_theme_root() . '/default/sidebar.php');
     94}
     95
     96/**
     97 * Load a generic template.
     98 *
     99 * Includes the named template for a theme or if a name is specified then a
     100 * specialised template will be included. If the theme contains no {slug}.php file
     101 * then no template will be included.
     102 *
     103 * For the parameter, if the file is called "{slug}-special.php" then specify
     104 * "special".
     105 *
     106 * @uses locate_template()
     107 * @since 3.0.0
     108 * @uses do_action() Calls 'get_generic_template_{$slug}' action.
     109 *
     110 * @param string $slug The slug name for the generic template.
     111 * @param string $name The name of the specialised template.
     112 */
     113function get_generic_template( $slug, $name = null ) {
     114    do_action( "get_generic_template_{$slug}", $name );
     115
     116    $templates = array();
     117    if ( isset($name) )
     118        $templates[] = "{$slug}-{$name}.php";
     119
     120    $templates[] = "{$slug}.php";
     121
     122    locate_template($templates, true);
    94123}
    95124
Note: See TracChangeset for help on using the changeset viewer.