Make WordPress Core

Changeset 52697 for trunk


Ignore:
Timestamp:
02/09/2022 01:20:49 PM (4 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.

Location:
trunk
Files:
2 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 ) {
  • trunk/tests/phpunit/tests/block-template.php

    r52308 r52697  
    1919                parent::set_up();
    2020                switch_theme( 'block-theme' );
     21                do_action( 'setup_theme' );
    2122        }
    2223
Note: See TracChangeset for help on using the changeset viewer.