Make WordPress Core


Ignore:
Timestamp:
02/12/2022 07:45:56 AM (5 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.
Merges [52697] to the 5.9 branch.
Fixes #54844.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-includes/block-template.php

    r52596 r52716  
    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.