[wp-trac] [WordPress Trac] #58576: locate_template does not check to see site has parent theme.

WordPress Trac noreply at wordpress.org
Mon Jun 19 17:14:39 UTC 2023


#58576: locate_template does not check to see site has parent theme.
--------------------------+-----------------------------
 Reporter:  spacedmonkey  |      Owner:  (none)
     Type:  enhancement   |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:
 Severity:  normal        |   Keywords:  good-first-bug
  Focuses:  performance   |
--------------------------+-----------------------------
 In locate_template, function checks to exist if a file exists in parent
 and child themes. But if the current theme is not a child theme, this
 check is pointless and checks if the same file exists twice per request.

 So
 {{{#!php
 if ( file_exists( STYLESHEETPATH . '/' . $template_name ) ) {
         $located = STYLESHEETPATH . '/' . $template_name;
         break;
 } elseif ( file_exists( TEMPLATEPATH . '/' . $template_name ) ) {
         $located = TEMPLATEPATH . '/' . $template_name;
         break;
 }
 }}}

 Should become

 {{{#!php
 if ( file_exists( STYLESHEETPATH . '/' . $template_name ) ) {
         $located = STYLESHEETPATH . '/' . $template_name;
         break;
 } elseif ( STYLESHEETPATH !== TEMPLATEPATH && file_exists( TEMPLATEPATH .
 '/' . $template_name ) ) {
         $located = TEMPLATEPATH . '/' . $template_name;
         break;
 }
 }}}

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


More information about the wp-trac mailing list