mirror of
git://develop.git.wordpress.org/
synced 2025-04-12 08:02:05 +02:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@52697 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
89bcc4843a
commit
96a1687b91
@ -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.
|
||||
|
@ -18,6 +18,7 @@ class Tests_Block_Template extends WP_UnitTestCase {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
switch_theme( 'block-theme' );
|
||||
do_action( 'setup_theme' );
|
||||
}
|
||||
|
||||
public function tear_down() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user