[wp-trac] [WordPress Trac] #13239: Filter locate_template template_names variable

WordPress Trac noreply at wordpress.org
Wed Feb 5 19:46: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 coffee2code):

 I still prefer @DrewAPicture's [comment:44 update] in
 [attachment:13239.2.diff] of my most recent patch. It permits
 customization of the template search stack (via the filter) and allows for
 templates to be located outside of the theme or its parent theme
 directories while still retaining the benefit of WP's file existence
 checks, its hierarchical template search, and adds the use of
 `get_stylesheet_directory()` and `get_template_directory()` rather than
 constants.

 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 it makes it harder to play well
 with others; it'll become a problem if multiple functions hook the filter
 since the first invoked callback may have chosen a template to load,
 leaving subsequent callbacks unable to determine how the template was
 chosen and unable to influence the template selection process (short of
 ignoring any previous filtered selection and hoping a later callback
 doesn't override its own selection).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/13239#comment:57>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list