Make WordPress Core

Ticket #54910: 54910.diff

File 54910.diff, 1.2 KB (added by costdev, 2 years ago)

Check for block markup in templates/index.html or block-templates/index.html.

  • src/wp-includes/class-wp-theme.php

    diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php
    index 9fa101906a..8721abd143 100644
    a b final class WP_Theme implements ArrayAccess { 
    14831483
    14841484                foreach ( $paths_to_index_block_template as $path_to_index_block_template ) {
    14851485                        if ( is_file( $path_to_index_block_template ) && is_readable( $path_to_index_block_template ) ) {
    1486                                 return true;
     1486                                $content = file_get_contents( $path_to_index_block_template );
     1487                                if ( $content && ! empty( parse_blocks( $content ) ) ) {
     1488                                        return true;
     1489                                }
    14871490                        }
    14881491                }
    14891492
  • src/wp-includes/template.php

    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() ) { 
    6363
    6464        $template = locate_template( $templates );
    6565
    66         $template = locate_block_template( $template, $type, $templates );
     66        if ( wp_is_block_theme() ) {
     67                $template = locate_block_template( $template, $type, $templates );
     68        }
    6769
    6870        /**
    6971         * Filters the path of the queried template by type.