Skip to content

Commit 4709117

Browse files
committed
Themes: Avoid unnecessary check whether parent template file exists when not using a child theme.
Prior to this change, the `locate_template()` function would unconditionally check whether the relevant template file exists in the parent theme, which for sites not using a child theme is an exact duplicate of the previous check. This is wasteful and has a small impact on performance since `file_exists()` checks have a cost. Props nihar007, thekt12, spacedmonkey, mukesh27. Fixes #58576. git-svn-id: https://develop.svn.wordpress.org/trunk@56357 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9e4188b commit 4709117

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/wp-includes/template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ function locate_template( $template_names, $load = false, $load_once = true, $ar
707707
if ( file_exists( STYLESHEETPATH . '/' . $template_name ) ) {
708708
$located = STYLESHEETPATH . '/' . $template_name;
709709
break;
710-
} elseif ( file_exists( TEMPLATEPATH . '/' . $template_name ) ) {
710+
} elseif ( is_child_theme() && file_exists( TEMPLATEPATH . '/' . $template_name ) ) {
711711
$located = TEMPLATEPATH . '/' . $template_name;
712712
break;
713713
} elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {

0 commit comments

Comments
 (0)