[wp-trac] [WordPress Trac] #37443: locate_template() fails when called in API context

WordPress Trac noreply at wordpress.org
Fri Jul 22 15:14:12 UTC 2016


#37443: locate_template() fails when called in API context
---------------------------+-----------------------------
 Reporter:  paulschreiber  |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:  trunk
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 On WordPress.com, locate_template() fails when called in the API context.

 For example:
 {{{#!php
 include( locate_template( 'template-parts/podcasts/promo.php' ) );
 }}}

 becomes:
 {{{#!php
 include( '' );
 }}}

 which fails.

 Suggestion:
 Add filters to locate_template() to override STYLESHEETPATH and
 TEMPLATEPATH.

 Change this:
 {{{#!php
 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
   $located = STYLESHEETPATH . '/' . $template_name;
 }}}


 to this:
 {{{#!php
 $stylesheet_path = apply_filters( 'stylesheet_path', STYLESHEETPATH );
 if ( file_exists( $stylesheet_path . '/' . $template_name ) ) {
   $located = $stylesheet_path . '/' . $template_name;
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37443>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list