diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php
index 9fa101906a..fd52275dc8 100644
a
|
b
|
final class WP_Theme implements ArrayAccess { |
1476 | 1476 | * @return bool |
1477 | 1477 | */ |
1478 | 1478 | public function is_block_theme() { |
| 1479 | $is_block_theme = wp_cache_get( 'is_block_theme' ); |
| 1480 | |
| 1481 | if ( false !== $is_block_theme ) { |
| 1482 | return (bool) $is_block_theme; |
| 1483 | } |
| 1484 | |
1479 | 1485 | $paths_to_index_block_template = array( |
1480 | 1486 | $this->get_file_path( '/block-templates/index.html' ), |
1481 | 1487 | $this->get_file_path( '/templates/index.html' ), |
… |
… |
final class WP_Theme implements ArrayAccess { |
1483 | 1489 | |
1484 | 1490 | foreach ( $paths_to_index_block_template as $path_to_index_block_template ) { |
1485 | 1491 | if ( is_file( $path_to_index_block_template ) && is_readable( $path_to_index_block_template ) ) { |
1486 | | return true; |
| 1492 | $content = file_get_contents( $path_to_index_block_template ); |
| 1493 | $blocks = parse_blocks( $content ); |
| 1494 | |
| 1495 | if ( $blocks && array_filter( wp_list_pluck( $blocks, 'blockName' ) ) ) { |
| 1496 | wp_cache_set( 'is_block_theme', 1 ); |
| 1497 | return true; |
| 1498 | } |
1487 | 1499 | } |
1488 | 1500 | } |
1489 | 1501 | |
| 1502 | wp_cache_set( 'is_block_theme', 0 ); |
| 1503 | |
1490 | 1504 | return false; |
1491 | 1505 | } |
1492 | 1506 | |
diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php
index 891e77748d..4d43d69237 100644
a
|
b
|
function get_query_template( $type, $templates = array() ) { |
63 | 63 | |
64 | 64 | $template = locate_template( $templates ); |
65 | 65 | |
66 | | $template = locate_block_template( $template, $type, $templates ); |
| 66 | if ( wp_is_block_theme() ) { |
| 67 | $template = locate_block_template( $template, $type, $templates ); |
| 68 | } |
67 | 69 | |
68 | 70 | /** |
69 | 71 | * Filters the path of the queried template by type. |