Make WordPress Core

Changeset 56357


Ignore:
Timestamp:
08/03/2023 08:29:12 PM (9 months ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/template.php

    r56194 r56357  
    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;
Note: See TracChangeset for help on using the changeset viewer.