From 7e141e4192d502a98ee82e52afd408b825b7a010 Mon Sep 17 00:00:00 2001 From: westi 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: http://svn.automattic.com/wordpress/trunk@8624 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 3f0738128..8bae11a47 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 e6abc00c9..2ba2f3d4e 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1,8 +1,10 @@