Opened 16 years ago
Closed 16 years ago
#8132 closed enhancement (fixed)
calls to default theme should be modular
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Template | Keywords: | |
Focuses: | Cc: |
Description
themes/default/...
is called in several places, and is hard-coded:
function get_header() {
do_action( 'get_header' );
if ( file_exists( TEMPLATEPATH . '/header.php') )
load_template( TEMPLATEPATH . '/header.php');
else
load_template( WP_CONTENT_DIR . '/themes/default/header.php');
}
this ruins any modularity one might desire in temporarily relocating default for one user, one file, etc. additionally, default/ is part of the svn tree and overriding the files is not ideal.
i recommend moving all calls to default theme files through something more akin to the already-existing get_query_template(), which is passed through a filter:
if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
$template = TEMPLATEPATH . "/{$type}.php";
return apply_filters("{$type}_template", $template);
which could possibly be as easy as:
foreach(Array('404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'page', 'paged', 'search', 'single', 'attachment', 'comments_popup') as $k)
{
add_filter($k."_template", create_function('$t', 'return try_default_theme($t,'.$k.');'));
}
function try_default_theme($template, $type){
if ( !$template && file_exists(get_theme_root() . "/default/{$type}.php") )
$template = get_theme_root() . "/default/{$type}.php";
return $template;
}
fixed now. get_header() has two hooks that you can use.