Use get_template_part() in get_header(), get_sidebar(), get_footer(). props scribu, see #18331.

git-svn-id: https://develop.svn.wordpress.org/trunk@18665 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2011-09-13 16:17:14 +00:00
parent bcb073c403
commit 486670f072

View File

@ -24,14 +24,8 @@
function get_header( $name = null ) { function get_header( $name = null ) {
do_action( 'get_header', $name ); do_action( 'get_header', $name );
$templates = array();
if ( isset($name) )
$templates[] = "header-{$name}.php";
$templates[] = 'header.php';
// Backward compat code will be removed in a future release // Backward compat code will be removed in a future release
if ('' == locate_template($templates, true)) if ( '' == get_template_part( 'header', $name ) )
load_template( ABSPATH . WPINC . '/theme-compat/header.php' ); load_template( ABSPATH . WPINC . '/theme-compat/header.php' );
} }
@ -53,14 +47,8 @@ function get_header( $name = null ) {
function get_footer( $name = null ) { function get_footer( $name = null ) {
do_action( 'get_footer', $name ); do_action( 'get_footer', $name );
$templates = array();
if ( isset($name) )
$templates[] = "footer-{$name}.php";
$templates[] = 'footer.php';
// Backward compat code will be removed in a future release // Backward compat code will be removed in a future release
if ('' == locate_template($templates, true)) if ( '' == get_template_part( 'footer', $name ) )
load_template( ABSPATH . WPINC . '/theme-compat/footer.php' ); load_template( ABSPATH . WPINC . '/theme-compat/footer.php' );
} }
@ -82,14 +70,8 @@ function get_footer( $name = null ) {
function get_sidebar( $name = null ) { function get_sidebar( $name = null ) {
do_action( 'get_sidebar', $name ); do_action( 'get_sidebar', $name );
$templates = array();
if ( isset($name) )
$templates[] = "sidebar-{$name}.php";
$templates[] = 'sidebar.php';
// Backward compat code will be removed in a future release // Backward compat code will be removed in a future release
if ('' == locate_template($templates, true)) if ( '' == get_template_part( 'sidebar', $name ) )
load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php' ); load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php' );
} }
@ -125,7 +107,7 @@ function get_template_part( $slug, $name = null ) {
$templates[] = "{$slug}.php"; $templates[] = "{$slug}.php";
locate_template($templates, true, false); return locate_template($templates, true, false);
} }
/** /**