mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Look for template files in the stylesheet folder as well as the template folder for inheriting themes. Fixes #7086 props ionfish.
git-svn-id: http://svn.automattic.com/wordpress/trunk@8497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ca07515463
commit
508dfde88a
@ -664,11 +664,14 @@ function comments_template( $file = '/comments.php' ) {
|
||||
update_comment_cache($comments);
|
||||
|
||||
define('COMMENTS_TEMPLATE', true);
|
||||
$include = apply_filters('comments_template', TEMPLATEPATH . $file );
|
||||
|
||||
$include = apply_filters('comments_template', STYLESHEETPATH . $file );
|
||||
if ( file_exists( $include ) )
|
||||
require( $include );
|
||||
elseif ( file_exists( TEMPLATEPATH . $file ) )
|
||||
require( TEMPLATEPATH . $file );
|
||||
else
|
||||
require( WP_CONTENT_DIR . '/themes/default/comments.php');
|
||||
require( get_theme_root() . '/default/comments.php');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
function get_header() {
|
||||
do_action( 'get_header' );
|
||||
if ( file_exists( TEMPLATEPATH . '/header.php') )
|
||||
if ( file_exists( STYLESHEETPATH . '/header.php') )
|
||||
load_template( STYLESHEETPATH . '/header.php');
|
||||
elseif ( file_exists( TEMPLATEPATH . '/header.php') )
|
||||
load_template( TEMPLATEPATH . '/header.php');
|
||||
else
|
||||
load_template( WP_CONTENT_DIR . '/themes/default/header.php');
|
||||
@ -13,7 +15,9 @@ function get_header() {
|
||||
|
||||
function get_footer() {
|
||||
do_action( 'get_footer' );
|
||||
if ( file_exists( TEMPLATEPATH . '/footer.php') )
|
||||
if ( file_exists( STYLESHEETPATH . '/footer.php') )
|
||||
load_template( STYLESHEETPATH . '/footer.php');
|
||||
elseif ( file_exists( TEMPLATEPATH . '/footer.php') )
|
||||
load_template( TEMPLATEPATH . '/footer.php');
|
||||
else
|
||||
load_template( WP_CONTENT_DIR . '/themes/default/footer.php');
|
||||
@ -22,8 +26,12 @@ function get_footer() {
|
||||
|
||||
function get_sidebar( $name = null ) {
|
||||
do_action( 'get_sidebar' );
|
||||
if ( isset($name) && file_exists( TEMPLATEPATH . "/sidebar-{$name}.php") )
|
||||
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
|
||||
|
@ -232,15 +232,20 @@ function get_themes() {
|
||||
}
|
||||
|
||||
$stylesheet_files = array();
|
||||
$template_files = array();
|
||||
|
||||
$stylesheet_dir = @ dir("$theme_root/$stylesheet");
|
||||
if ( $stylesheet_dir ) {
|
||||
while ( ($file = $stylesheet_dir->read()) !== false ) {
|
||||
if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
|
||||
$stylesheet_files[] = "$theme_loc/$stylesheet/$file";
|
||||
if ( !preg_match('|^\.+$|', $file) ) {
|
||||
if ( preg_match('|\.css$|', $file) )
|
||||
$stylesheet_files[] = "$theme_loc/$stylesheet/$file";
|
||||
elseif ( preg_match('|\.php$|', $file) )
|
||||
$template_files[] = "$theme_loc/$stylesheet/$file";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$template_files = array();
|
||||
$template_dir = @ dir("$theme_root/$template");
|
||||
if ( $template_dir ) {
|
||||
while(($file = $template_dir->read()) !== false) {
|
||||
@ -343,7 +348,9 @@ function get_theme_root_uri() {
|
||||
function get_query_template($type) {
|
||||
$template = '';
|
||||
$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
|
||||
if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
|
||||
if ( file_exists(STYLESHEETPATH . "/{$type}.php") )
|
||||
$template = STYLESHEETPATH . "/{$type}.php";
|
||||
elseif ( file_exists(TEMPLATEPATH . "/{$type}.php") )
|
||||
$template = TEMPLATEPATH . "/{$type}.php";
|
||||
|
||||
return apply_filters("{$type}_template", $template);
|
||||
@ -363,8 +370,12 @@ function get_author_template() {
|
||||
|
||||
function get_category_template() {
|
||||
$template = '';
|
||||
if ( file_exists(TEMPLATEPATH . "/category-" . absint( get_query_var('cat') ) . '.php') )
|
||||
if ( file_exists(STYLESHEETPATH . "/category-" . absint( get_query_var('cat') ) . '.php') )
|
||||
$template = STYLESHEETPATH . "/category-" . absint( get_query_var('cat') ) . '.php';
|
||||
elseif ( file_exists(TEMPLATEPATH . "/category-" . absint( get_query_var('cat') ) . '.php') )
|
||||
$template = TEMPLATEPATH . "/category-" . absint( get_query_var('cat') ) . '.php';
|
||||
elseif ( file_exists(STYLESHEETPATH . "/category.php") )
|
||||
$template = STYLESHEETPATH . "/category.php";
|
||||
elseif ( file_exists(TEMPLATEPATH . "/category.php") )
|
||||
$template = TEMPLATEPATH . "/category.php";
|
||||
|
||||
@ -373,8 +384,12 @@ function get_category_template() {
|
||||
|
||||
function get_tag_template() {
|
||||
$template = '';
|
||||
if ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') )
|
||||
if ( file_exists(STYLESHEETPATH . "/tag-" . get_query_var('tag') . '.php') )
|
||||
$template = STYLESHEETPATH . "/tag-" . get_query_var('tag') . '.php';
|
||||
elseif ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') )
|
||||
$template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php';
|
||||
elseif ( file_exists(STYLESHEETPATH . "/tag.php") )
|
||||
$template = STYLESHEETPATH . "/tag.php";
|
||||
elseif ( file_exists(TEMPLATEPATH . "/tag.php") )
|
||||
$template = TEMPLATEPATH . "/tag.php";
|
||||
|
||||
@ -385,10 +400,16 @@ function get_taxonomy_template() {
|
||||
$template = '';
|
||||
$taxonomy = get_query_var('taxonomy');
|
||||
$term = get_query_var('term');
|
||||
if ( $taxonomy && $term && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php") )
|
||||
if ( $taxonomy && $term && file_exists(STYLESHEETPATH . "/taxonomy-$taxonomy-$term.php") )
|
||||
$template = STYLESHEETPATH . "/taxonomy-$taxonomy-$term.php";
|
||||
elseif ( $taxonomy && $term && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php") )
|
||||
$template = TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php";
|
||||
elseif ( $taxonomy && file_exists(STYLESHEETPATH . "/taxonomy-$taxonomy.php") )
|
||||
$template = STYLESHEETPATH . "/taxonomy-$taxonomy.php";
|
||||
elseif ( $taxonomy && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy.php") )
|
||||
$template = TEMPLATEPATH . "/taxonomy-$taxonomy.php";
|
||||
elseif ( file_exists(STYLESHEETPATH . "/taxonomy.php") )
|
||||
$template = STYLESHEETPATH . "/taxonomy.php";
|
||||
elseif ( file_exists(TEMPLATEPATH . "/taxonomy.php") )
|
||||
$template = TEMPLATEPATH . "/taxonomy.php";
|
||||
|
||||
@ -402,8 +423,12 @@ function get_date_template() {
|
||||
function get_home_template() {
|
||||
$template = '';
|
||||
|
||||
if ( file_exists(TEMPLATEPATH . "/home.php") )
|
||||
if ( file_exists(STYLESHEETPATH . "/home.php") )
|
||||
$template = STYLESHEETPATH . "/home.php";
|
||||
elseif ( file_exists(TEMPLATEPATH . "/home.php") )
|
||||
$template = TEMPLATEPATH . "/home.php";
|
||||
elseif ( file_exists(STYLESHEETPATH . "/index.php") )
|
||||
$template = STYLESHEETPATH . "/index.php";
|
||||
elseif ( file_exists(TEMPLATEPATH . "/index.php") )
|
||||
$template = TEMPLATEPATH . "/index.php";
|
||||
|
||||
@ -419,8 +444,12 @@ function get_page_template() {
|
||||
if ( 'default' == $template )
|
||||
$template = '';
|
||||
|
||||
if ( !empty($template) && !validate_file($template) && file_exists(TEMPLATEPATH . "/$template") )
|
||||
if ( !empty($template) && !validate_file($template) && file_exists(STYLESHEETPATH . "/$template") )
|
||||
$template = STYLESHEETPATH . "/$template";
|
||||
elseif ( !empty($template) && !validate_file($template) && file_exists(TEMPLATEPATH . "/$template") )
|
||||
$template = TEMPLATEPATH . "/$template";
|
||||
elseif ( file_exists(STYLESHEETPATH . "/page.php") )
|
||||
$template = STYLESHEETPATH . "/page.php";
|
||||
elseif ( file_exists(TEMPLATEPATH . "/page.php") )
|
||||
$template = TEMPLATEPATH . "/page.php";
|
||||
else
|
||||
@ -455,7 +484,9 @@ function get_attachment_template() {
|
||||
}
|
||||
|
||||
function get_comments_popup_template() {
|
||||
if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
|
||||
if ( file_exists( STYLESHEETPATH . '/comments-popup.php') )
|
||||
$template = STYLESHEETPATH . '/comments-popup.php';
|
||||
elseif ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
|
||||
$template = TEMPLATEPATH . '/comments-popup.php';
|
||||
else
|
||||
$template = get_theme_root() . '/default/comments-popup.php';
|
||||
|
Loading…
Reference in New Issue
Block a user