Make WordPress Core


Ignore:
Timestamp:
02/09/2022 01:20:49 PM (3 years ago)
Author:
audrasjb
Message:

Query: Check if the theme supports block-templates before calling locate_block_template() in get_query_template().

This change improves performance for classic themes by removing an unnecessary query and fixes an issue where a classic theme would show "Empty template: Index" on the frontend when an empty (block-)templates/index.html file exists.

Props johnbillion, ianatkins, Mamaduka, costdev, manfcarlo, dolphingg, audrasjb, madeinua, kapilpaul, rafiahmedd, SergeyBiryukov.
Fixes #54844.

File:
1 edited

Legend:

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

    r52610 r52697  
    4848function locate_block_template( $template, $type, array $templates ) {
    4949    global $_wp_current_template_content;
     50
     51    if ( ! current_theme_supports( 'block-templates' ) ) {
     52        return $template;
     53    }
    5054
    5155    if ( $template ) {
Note: See TracChangeset for help on using the changeset viewer.