From 7c7f95a8b22c1c9cb1fb70c69057175255c6a84c Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 3 Aug 2023 20:31:22 +0000 Subject: [PATCH] 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 --- wp-includes/template.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/template.php b/wp-includes/template.php index b9ac37d235..afc2ca6edf 100644 --- a/wp-includes/template.php +++ b/wp-includes/template.php @@ -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 ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index ada65c247e..8eaf37976c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.