Make WordPress Core

Ticket #54272: 54272.diff

File 54272.diff, 1.7 KB (added by sabbirshouvo, 3 years ago)

Allow block themes without index.php if either index.php or block-templates/index.html is present in a theme folder, theme will activate without any issue. If a theme missing both, a notice will be shown as previous.

  • 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 d0607528b5..506a6c650c 100644
    a b final class WP_Theme implements ArrayAccess { 
    337337
    338338                if ( ! $this->template ) {
    339339                        $this->template = $this->stylesheet;
    340                         if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
     340
     341                        $index_php_path = $this->theme_root . '/' . $this->stylesheet . '/index.php';
     342                        $index_html_path = $this->theme_root . '/' . $this->stylesheet . '/block-templates/index.html';
     343
     344                        if ( ! file_exists( $index_php_path ) &&  ! file_exists( $index_html_path ) ) {
    341345                                $error_message = sprintf(
    342346                                        /* translators: 1: index.php, 2: Documentation URL, 3: style.css */
    343347                                        __( 'Template is missing. Standalone themes need to have a %1$s template file. <a href="%2$s">Child themes</a> need to have a Template header in the %3$s stylesheet.' ),
    344                                         '<code>index.php</code>',
     348                                        '<code>index.php</code> or <code>block-templates/index.html</code>',
    345349                                        __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ),
    346350                                        '<code>style.css</code>'
    347351                                );
  • src/wp-includes/theme.php

    diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
    index 384c056404..35c0ad07a6 100644
    a b function validate_current_theme() { 
    857857                return true;
    858858        }
    859859
    860         if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
     860        if ( ! file_exists( get_template_directory() . '/index.php' ) && ! file_exists( get_template_directory() . '/block-templates/index.html' ) ) {
    861861                // Invalid.
    862862        } elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
    863863                // Invalid.