[wp-trac] [WordPress Trac] #13239: Filter locate_template template_names variable
WordPress Trac
noreply at wordpress.org
Thu Feb 6 01:21:29 UTC 2014
#13239: Filter locate_template template_names variable
----------------------------------------+-----------------------
Reporter: chrisbliss18 | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone: 3.9
Component: Themes | Version: 3.0
Severity: normal | Resolution:
Keywords: has-patch 3.3-early commit | Focuses:
----------------------------------------+-----------------------
Comment (by MikeSchinkel):
Replying to [comment:57 coffee2code]:
> I still prefer @DrewAPicture's [comment:44 update] in
[attachment:13239.2.diff] of my most recent patch.
> I'm not a fan of bailing on everything `locate_template()` does if the
filter as proposed by @georgestephanis returns a specific template to
load. You lose all the locating functionality of the function, forcing any
hooking code to likely duplicate that to ensure the template exists. More
than anything, though, I have concerns …
Very much agree.
BTW, we use our own version of `locate_template()` so that we can
implement ''"skins"'' which is similar in concept to child themes but for
specific sections of a site and all contained within the same theme. For
example, the `/about/` section could have a red-ish skin, the `/products/`
section a green-ish skin and so on ''(it's more complex than that, but
hopefully you get the idea.)''
It would be nice to be able to implement things like skins without having
to bypass standard WordPress API functions, in this case
`locate_template()`.
> adds the use of `get_stylesheet_directory()` and
`get_template_directory()` rather than constants.
I would suggest not calling those functions twice but instead capturing
the return value the first time called. Is there a good reason not to
capture to a variable instead of calling at least one of them twice?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/13239#comment:58>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list