Make WordPress Core

Ticket #54910: 54910_1.diff

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

Also cover non-block HTML 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..90dfdc2a55 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                                $blocks  = parse_blocks( $content );
     1488
     1489                                if ( $blocks && array_filter( wp_list_pluck( $blocks, 'blockName' ) ) ) {
     1490                                        return true;
     1491                                }
    14871492                        }
    14881493                }
    14891494
  • 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.