[wp-trac] [WordPress Trac] #16128: WordPress Template System Override
WordPress Trac
wp-trac at lists.automattic.com
Thu Jan 6 19:44:18 UTC 2011
#16128: WordPress Template System Override
--------------------------+-------------------------------
Reporter: pearsonified | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: 3.1
Severity: normal | Keywords: themes, templates
--------------------------+-------------------------------
As it's currently constructed (in version 3.0.4), the WordPress template
loader (wp-includes/template-loader.php) is relatively inflexible. No
matter how a theme operates, it's forced through the series of if-
statements and template "fetches" defined in lines 23–41 of template-
loader.php.
Fortunately, by making very simple modifications to this file, we can
accommodate themes/frameworks/template systems that may have different
(and, ideally, more efficient) ways of determining which template to show
and how to show it.
This is sensible because developers only need the contents of $wp_query in
order to determine which template to show. While the current workings of
the WP template system include a lot of "convenience" functions, these
unnecessary function calls could be skipped entirely by relying upon the
$wp_query->is_[x] variables.
My proposal for a template system override is quite simple, and it
introduces one new constant and one new hook into the core. The constant,
WP_THEME_TEMPLATE, is a boolean value that theme developers should place
in their functions.php file and set to TRUE only if they have defined
their own template system. The hook, theme_template, is the "tie-in" point
for the developer's template system.
The template-loader.php file must be modified to accommodate the constant
and hook described above. Fortunately, this can be done in 4 lines of
code, as evidenced by (new) lines 22–24 and line 48 in the attached
template-loader.php file.
I like this template system solution because it does not affect any
current themes, developers, or development practices. Despite this, it
opens to door to innovation and places the dev community in a position to
come up with mind-blowing new ways to handle template/theme functionality.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16128>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list