From da46c93af9e116bd1be9111e83f9040d603096dd Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Tue, 12 Aug 2008 20:18:05 +0000 Subject: [PATCH] Refactor template location code to reduce duplication. Also make it easier for theme authors to pull in seperate files into templates while making theme overrideable. See #7492. git-svn-id: https://develop.svn.wordpress.org/trunk@8624 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/general-template.php | 29 +++---- wp-includes/theme.php | 126 ++++++++++++++----------------- 2 files changed, 67 insertions(+), 88 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 3f07381285..8bae11a472 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -4,37 +4,28 @@ function get_header() { do_action( 'get_header' ); - if ( file_exists( STYLESHEETPATH . '/header.php') ) - load_template( STYLESHEETPATH . '/header.php'); - elseif ( file_exists( TEMPLATEPATH . '/header.php') ) - load_template( TEMPLATEPATH . '/header.php'); - else + if ('' == locate_template(array('header.php'), true)) load_template( get_theme_root() . '/default/header.php'); } function get_footer() { do_action( 'get_footer' ); - if ( file_exists( STYLESHEETPATH . '/footer.php') ) - load_template( STYLESHEETPATH . '/footer.php'); - elseif ( file_exists( TEMPLATEPATH . '/footer.php') ) - load_template( TEMPLATEPATH . '/footer.php'); - else + if ('' == locate_template(array('footer.php'), true)) load_template( get_theme_root() . '/default/footer.php'); } function get_sidebar( $name = null ) { do_action( 'get_sidebar' ); - if ( isset($name) && file_exists( STYLESHEETPATH . "/sidebar-{$name}.php") ) - load_template( STYLESHEETPATH . "/sidebar-{$name}.php"); - elseif ( isset($name) && file_exists( TEMPLATEPATH . "/sidebar-{$name}.php") ) - load_template( TEMPLATEPATH . "/sidebar-{$name}.php"); - elseif ( file_exists( STYLESHEETPATH . '/sidebar.php') ) - load_template( STYLESHEETPATH . '/sidebar.php'); - elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') ) - load_template( TEMPLATEPATH . '/sidebar.php'); - else + + $templates = array(); + if ( isset($name) ) + $templates[] = "sidebar-{$name}.php"; + + $templates[] = "sidebar.php"; + + if ('' == locate_template($templates, true)) load_template( get_theme_root() . '/default/sidebar.php'); } diff --git a/wp-includes/theme.php b/wp-includes/theme.php index e6abc00c90..2ba2f3d4ee 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1,8 +1,10 @@