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

WordPress Trac wp-trac at lists.automattic.com
Sun Jul 10 21:13:13 UTC 2011


#13239: Filter locate_template template_names variable
---------------------------------+-----------------------
 Reporter:  chrisbliss18         |       Owner:
     Type:  enhancement          |      Status:  reopened
 Priority:  normal               |   Milestone:
Component:  Themes               |     Version:  3.0
 Severity:  normal               |  Resolution:
 Keywords:  has-patch 3.3-early  |
---------------------------------+-----------------------
Changes (by coffee2code):

 * status:  closed => reopened
 * resolution:  duplicate =>


Comment:

 There may be some overlap, but I still think this has merit on its own.  I
 acknowledged #14310 in my
 [http://core.trac.wordpress.org/ticket/13239#comment:3 initial comment
 here].  I still contend this solution is more robust.

 One drawback in what appears to be the most current patch for #14310 is
 that it requires that the template type be specified to hook the filter..
 i.e. `add_filter( 'author_template_hierarchy', ... )`.  If I'm interested
 in processing all template location requests, I'd have to register hooks
 against all possible types.

 That aside, #14310 operates at a higher level.  I want lower level access
 via `locate_template()`.  Not all template requests go through
 `get_query_template()`, but if you care about templates in the child OR
 parent theme, then `locate_template()` will be called.  For instance,
 `get_search_form()` uses `locate_template()` to find searchform.php.
 Being able to short-circuit that is part of the impetus for my patch.
 #14310 won't let me intercept location of that template file.

 I also think themes and plugins are more likely to call
 `locate_template()` to find specialized templates than to call
 `get_query_template()`.  Even if they aren't, if the hook is in
 `locate_template()` you'll be able to intercede regardless of which of two
 functions are used.

 I won't go so far as to close #14310 as a dup of this.  I think what it
 hopes to accomplish could be done with my patch for this ticket, but its
 specificity might make things slightly easier in certain situations (i.e.
 you want to modify the template search order for just the 'author'
 templates).  However, I'd like for my proposed patch for this to continue
 on for further consideration.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13239#comment:23>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list