[wp-trac] [WordPress Trac] #22355: Template stack - Beyond parent/child theme relationships
WordPress Trac
noreply at wordpress.org
Sat Nov 3 21:45:26 UTC 2012
#22355: Template stack - Beyond parent/child theme relationships
-----------------------------+-------------------------
Reporter: johnjamesjacoby | Type: enhancement
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Themes
Version: | Severity: normal
Keywords: has-patch |
-----------------------------+-------------------------
'''Problem'''
Robust plugins (!BuddyPress, bbPress, et all) are unable to break out of
the parent/child restrictions that !WordPress imposes on template output.
For these plugins to include their own template parts, elaborate code must
be written to hook into several different execution points, requiring an
intimate knowledge of the inner workings of !WordPress's template loading
system.
----
'''Solution'''
Create a stack of template locations, and allow !WordPress to transverse
an array of template locations, following the same
STYLESHEETPATH/TEMPLATEPATH order it always has, while also enabling
additional paths to be added with a priority.
----
'''Details'''
The attached patch includes two new functions in wp-includes/template.php:
* register_template_stack()
* get_template_stack()
Register template stack is a wrapper for the 'template_stack' filter.
get_template_stack() is a variation of apply_filters() that returns the
array of filtered template locations.
A modifications to wp-settings.php calls register_template_stack(),
passing get_stylesheet_directory() and get_template_directory() as
callbacks, which initialized the core parent/child relationship.
----
'''Result'''
This allows for plugins to register additional paths in the template
loader hierarchy, and enables plugins that may come with their own default
template parts the option of registering a fallback template location.
This works with both locate_template() and get_template_part(), and has
the added benefit removing duplicate items inside of get_template_stack(),
resulting in avoiding an additional file system check should the parent
and child themes be the same.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22355>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list