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.

Built from https://develop.svn.wordpress.org/trunk@52697


git-svn-id: http://core.svn.wordpress.org/trunk@52286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-02-09 13:22:03 +00:00
parent 4f856dfae0
commit fbb9d52774
2 changed files with 5 additions and 1 deletions

View File

@ -48,6 +48,10 @@ function _add_template_loader_filters() {
function locate_block_template( $template, $type, array $templates ) {
global $_wp_current_template_content;
if ( ! current_theme_supports( 'block-templates' ) ) {
return $template;
}
if ( $template ) {
/*
* locate_template() has found a PHP template at the path specified by $template.

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-52696';
$wp_version = '6.0-alpha-52697';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.