[wp-trac] [WordPress Trac] #11242: Add "template_include" action to be run just before templates are included

WordPress Trac wp-trac at lists.automattic.com
Tue Jan 5 14:58:29 UTC 2010


#11242: Add "template_include" action to be run just before templates are included
------------------------------------+---------------------------------------
 Reporter:  holizz                  |        Owner:  westi   
     Type:  enhancement             |       Status:  reopened
 Priority:  normal                  |    Milestone:  3.0     
Component:  Plugins                 |      Version:  2.9     
 Severity:  normal                  |   Resolution:          
 Keywords:  has-patch dev-feedback  |  
------------------------------------+---------------------------------------

Comment(by hakre):

 I reviewed the patch and like it. This will add some filters that are
 often needed. I found some places which actually benefit from a touchup:

  1.) the template-loader can be made configure-able. That does not only
 clean up the code, it also offers the possibility to add an additional
 filter: ''template_include_config''.
  2.) the default (non-existant) template is not NULL but an empty string
 (''). that is what all the get_''for_whatever_query''_template() is
 returning in case of error. the patch should be aligned to those.
  3.) an action after the actual include does make sense in my eyes. you
 smell what this well open? I named it ''template_included'' in my patch.
  4.) load_template() did contain a require_once statement. I do not see
 that this makes sense. It will prevent to load a sub-template twice. I
 changed it to include (as we do in the template loader as well).
  5.) since that function is not named include_template() but
 load_template() I suggest to change the filter to ''template_load'' in
 there. In accordance to 3.) I introduced the ''template_loaded'' action
 into there as well.

 My patch is based on the last one provided (r12294.diff).

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


More information about the wp-trac mailing list