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.

Built from https://develop.svn.wordpress.org/trunk@56357


git-svn-id: http://core.svn.wordpress.org/trunk@55869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2023-08-03 20:31:22 +00:00
parent 65da089d96
commit 7c7f95a8b2
2 changed files with 2 additions and 2 deletions

View File

@ -707,7 +707,7 @@ function locate_template( $template_names, $load = false, $load_once = true, $ar
if ( file_exists( STYLESHEETPATH . '/' . $template_name ) ) {
$located = STYLESHEETPATH . '/' . $template_name;
break;
} elseif ( file_exists( TEMPLATEPATH . '/' . $template_name ) ) {
} elseif ( is_child_theme() && file_exists( TEMPLATEPATH . '/' . $template_name ) ) {
$located = TEMPLATEPATH . '/' . $template_name;
break;
} elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.4-alpha-56356';
$wp_version = '6.4-alpha-56357';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.