Make WordPress Core

Ticket #54272: 54272.4.diff

File 54272.4.diff, 2.6 KB (added by SergeyBiryukov, 2 years ago)
  • src/wp-includes/class-wp-theme.php

     
    338338
    339339                if ( ! $this->template ) {
    340340                        $this->template = $this->stylesheet;
    341                         if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
     341                        $theme_path     = $this->theme_root . '/' . $this->stylesheet;
     342
     343                        if ( ! file_exists( $theme_path . '/templates/index.html' )
     344                                && ! file_exists( $theme_path . '/index.php' )
     345                        ) {
    342346                                $error_message = sprintf(
    343                                         /* translators: 1: index.php, 2: Documentation URL, 3: style.css */
    344                                         __( '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.' ),
     347                                        /* translators: 1: templates/index.html, 2: index.php, 3: Documentation URL, 4: style.css */
     348                                        __( 'Template is missing. Standalone themes need to have a %1$s or %2$s template file. <a href="%3$s">Child themes</a> need to have a Template header in the %4$s stylesheet.' ),
     349                                        '<code>templates/index.html</code>',
    345350                                        '<code>index.php</code>',
    346351                                        __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ),
    347352                                        '<code>style.css</code>'
  • src/wp-includes/theme.php

     
    830830}
    831831
    832832/**
    833  * Checks that the active theme has 'index.php' and 'style.css' files.
     833 * Checks that the active theme has the required files.
    834834 *
     835 * Standalone themes need to have a `templates/index.html` or `index.php` template file.
     836 * Child themes need to have a `Template` header in the `style.css` stylesheet.
     837 *
    835838 * Does not initially check the default theme, which is the fallback and should always exist.
    836839 * But if it doesn't exist, it'll fall back to the latest core default theme that does exist.
    837840 * Will switch theme to the fallback theme if active theme does not validate.
     
    840843 * this functionality.
    841844 *
    842845 * @since 1.5.0
     846 * @since 6.0.0 Removed the requirement for block themes to have an `index.php` template.
    843847 *
    844848 * @see WP_DEFAULT_THEME
    845849 *
     
    857861                return true;
    858862        }
    859863
    860         if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
     864        if ( ! file_exists( get_template_directory() . '/templates/index.html' )
     865                && ! file_exists( get_template_directory() . '/index.php' )
     866        ) {
    861867                // Invalid.
    862868        } elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
    863869                // Invalid.