From fbb9d5277446a264017f9916a3425edcf62d64e8 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Wed, 9 Feb 2022 13:22:03 +0000 Subject: [PATCH] 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 --- wp-includes/block-template.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/block-template.php b/wp-includes/block-template.php index de266c04f2..7bea75dca4 100644 --- a/wp-includes/block-template.php +++ b/wp-includes/block-template.php @@ -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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 0351f05a50..9ea4ae884f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.