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
This commit is contained in:
Peter Westwood
2008-08-12 20:18:05 +00:00
parent 3d1b545642
commit da46c93af9
2 changed files with 67 additions and 88 deletions
+10 -19
View File
@@ -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');
}