From 067e66c8f620f3a6aa11e180f5d4fe17d6d3a0df Mon Sep 17 00:00:00 2001 From: westi Date: Sun, 14 Feb 2010 09:32:23 +0000 Subject: [PATCH] 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 --- wp-content/themes/twentyten/archive.php | 2 +- wp-content/themes/twentyten/author.php | 2 +- wp-content/themes/twentyten/category.php | 2 +- wp-content/themes/twentyten/index.php | 2 +- wp-content/themes/twentyten/search.php | 2 +- wp-content/themes/twentyten/tag.php | 2 +- wp-includes/general-template.php | 29 ++++++++++++++++++++++++ 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/wp-content/themes/twentyten/archive.php b/wp-content/themes/twentyten/archive.php index d8c1e56a01..cda1c64e88 100644 --- a/wp-content/themes/twentyten/archive.php +++ b/wp-content/themes/twentyten/archive.php @@ -17,7 +17,7 @@ - + diff --git a/wp-content/themes/twentyten/author.php b/wp-content/themes/twentyten/author.php index 6c27b3b914..e1ccd0c7ae 100644 --- a/wp-content/themes/twentyten/author.php +++ b/wp-content/themes/twentyten/author.php @@ -21,7 +21,7 @@ - + diff --git a/wp-content/themes/twentyten/category.php b/wp-content/themes/twentyten/category.php index 4614cd1565..8b72a1ac43 100644 --- a/wp-content/themes/twentyten/category.php +++ b/wp-content/themes/twentyten/category.php @@ -10,7 +10,7 @@ - + diff --git a/wp-content/themes/twentyten/index.php b/wp-content/themes/twentyten/index.php index eb6b9f09a6..e12aa8050f 100644 --- a/wp-content/themes/twentyten/index.php +++ b/wp-content/themes/twentyten/index.php @@ -4,7 +4,7 @@

diff --git a/wp-content/themes/twentyten/search.php b/wp-content/themes/twentyten/search.php index 7fa68a3f06..6e83f1edd1 100644 --- a/wp-content/themes/twentyten/search.php +++ b/wp-content/themes/twentyten/search.php @@ -5,7 +5,7 @@

- +

diff --git a/wp-content/themes/twentyten/tag.php b/wp-content/themes/twentyten/tag.php index e768230c40..081379ec0d 100644 --- a/wp-content/themes/twentyten/tag.php +++ b/wp-content/themes/twentyten/tag.php @@ -9,7 +9,7 @@ - +
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 8f6f70b890..3180f9244e 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -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. *