[wp-trac] [WordPress Trac] #14310: Make template hierarchy filterable
WordPress Trac
noreply at wordpress.org
Wed Oct 21 19:23:55 UTC 2015
#14310: Make template hierarchy filterable
------------------------------+--------------------------
Reporter: scribu | Owner: johnbillion
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 4.4
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses: template
------------------------------+--------------------------
Comment (by johnbillion):
Example use case of a multilingual plugin that wants to allow template
files to be overridden on a per-locale basis:
{{{
$types = array(
'404', 'archive', 'attachment', 'author', 'category', 'date',
'front_page', 'home',
'index', 'page', 'paged', 'search', 'single', 'singular', 'tag',
'taxonomy',
);
foreach ( $types as $type ) {
add_filter( "{$type}_template_hierarchy", function( array
$templates ) {
$new = array();
foreach ( $templates as $template ) {
$new[] = get_locale() . '/' . $template;
$new[] = $template;
}
return $new;
} );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/14310#comment:57>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list