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

WordPress Trac noreply at wordpress.org
Wed Feb 12 04:00:09 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 rmccue):

 Replying to [comment:62 MikeSchinkel]:
 > 5. Captured value of expressions that called
 `get_stylesheet_directory()` and `get_template_directory()` into variable
 `$filepath` so those functions need not be called twice ''(and so that
 value is easier to debug within `locate_template()`).''

 I thought you meant something more like:

 {{{
 $stylesheet = get_stylesheet_directory();

 // ...
 } else if ( file_exists( $stylesheet . '/' . $template_name ) ) {
          $located = $stylesheet . '/' . $template_name;
          break;
 }}}

 (Ditto for template directory.)

 The code currently calls `get_stylesheet_directory()` and
 `get_template_directory()` once per iteration.

 (The `else if ( $filepath = file_exists( $filepath =
 get_template_directory() . '/' . $template_name ) )` line also means
 `$filepath` ends up being `true` rather than the path. :) )

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


More information about the wp-trac mailing list