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.

git-svn-id: http://svn.automattic.com/wordpress/trunk@13146 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi
2010-02-14 09:32:23 +00:00
parent 3284d920c0
commit 067e66c8f6
7 changed files with 35 additions and 6 deletions

View File

@@ -93,6 +93,35 @@ function get_sidebar( $name = null ) {
load_template( get_theme_root() . '/default/sidebar.php');
}
/**
* Load a generic template.
*
* Includes the named template for a theme or if a name is specified then a
* specialised template will be included. If the theme contains no {slug}.php file
* then no template will be included.
*
* For the parameter, if the file is called "{slug}-special.php" then specify
* "special".
*
* @uses locate_template()
* @since 3.0.0
* @uses do_action() Calls 'get_generic_template_{$slug}' action.
*
* @param string $slug The slug name for the generic template.
* @param string $name The name of the specialised template.
*/
function get_generic_template( $slug, $name = null ) {
do_action( "get_generic_template_{$slug}", $name );
$templates = array();
if ( isset($name) )
$templates[] = "{$slug}-{$name}.php";
$templates[] = "{$slug}.php";
locate_template($templates, true);
}
/**
* Display search form.
*