diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php
index 9fa101906a..a8c6464260 100644
a
|
b
|
final class WP_Theme implements ArrayAccess { |
739 | 739 | * @since 3.4.0 |
740 | 740 | */ |
741 | 741 | public function cache_delete() { |
742 | | foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) { |
| 742 | $keys = array( |
| 743 | 'theme', |
| 744 | 'screenshot', |
| 745 | 'headers', |
| 746 | 'post_templates', |
| 747 | 'is_block_theme', |
| 748 | ); |
| 749 | |
| 750 | foreach ( $keys as $key ) { |
743 | 751 | wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' ); |
744 | 752 | } |
745 | 753 | $this->template = null; |
… |
… |
final class WP_Theme implements ArrayAccess { |
1476 | 1484 | * @return bool |
1477 | 1485 | */ |
1478 | 1486 | public function is_block_theme() { |
| 1487 | $is_block_theme = $this->cache_get( 'is_block_theme' ); |
| 1488 | |
| 1489 | if ( false !== $is_block_theme ) { |
| 1490 | return (bool) $is_block_theme; |
| 1491 | } |
| 1492 | |
1479 | 1493 | $paths_to_index_block_template = array( |
1480 | 1494 | $this->get_file_path( '/block-templates/index.html' ), |
1481 | 1495 | $this->get_file_path( '/templates/index.html' ), |
… |
… |
final class WP_Theme implements ArrayAccess { |
1483 | 1497 | |
1484 | 1498 | foreach ( $paths_to_index_block_template as $path_to_index_block_template ) { |
1485 | 1499 | if ( is_file( $path_to_index_block_template ) && is_readable( $path_to_index_block_template ) ) { |
1486 | | return true; |
| 1500 | $content = file_get_contents( $path_to_index_block_template ); |
| 1501 | if ( $content && str_contains( $content, '<!-- wp:' ) ) { |
| 1502 | $this->cache_add( 'is_block_theme', 1 ); |
| 1503 | return true; |
| 1504 | } |
1487 | 1505 | } |
1488 | 1506 | } |
1489 | 1507 | |
| 1508 | $this->cache_add( 'is_block_theme', 0 ); |
| 1509 | |
1490 | 1510 | return false; |
1491 | 1511 | } |
1492 | 1512 | |
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. |