diff --git a/wp-admin/includes/class-theme-upgrader.php b/wp-admin/includes/class-theme-upgrader.php index 0a73f4b86c..4e874cd636 100644 --- a/wp-admin/includes/class-theme-upgrader.php +++ b/wp-admin/includes/class-theme-upgrader.php @@ -566,15 +566,28 @@ class Theme_Upgrader extends WP_Upgrader { ); } - // If it's not a child theme, it must have at least an index.php to be legit. - if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) { + /* + * Parent themes must contain an index file: + * - classic themes require /index.php + * - block themes require /templates/index.html or block-templates/index.html (deprecated 5.9.0). + */ + if ( + empty( $info['Template'] ) && + ! file_exists( $working_directory . 'index.php' ) && + ! file_exists( $working_directory . 'templates/index.html' ) && + ! file_exists( $working_directory . 'block-templates/index.html' ) + ) { return new WP_Error( 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'], sprintf( - /* translators: %s: index.php */ - __( 'The theme is missing the %s file.' ), - 'index.php' + /* translators: 1: templates/index.html, 2: index.php, 3: Documentation URL, 4: Template, 5: style.css */ + __( 'Template is missing. Standalone themes need to have a %1$s or %2$s template file. Child themes need to have a %4$s header in the %5$s stylesheet.' ), + 'templates/index.html', + 'index.php', + __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), + 'Template', + 'style.css' ) ); } diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index cef5b034c6..c2398fb4eb 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -341,7 +341,9 @@ final class WP_Theme implements ArrayAccess { $this->template = $this->stylesheet; $theme_path = $this->theme_root . '/' . $this->stylesheet; - if ( ! file_exists( $theme_path . '/templates/index.html' ) + if ( + ! file_exists( $theme_path . '/templates/index.html' ) + && ! file_exists( $theme_path . '/block-templates/index.html' ) // Deprecated path support since 5.9.0. && ! file_exists( $theme_path . '/index.php' ) ) { $error_message = sprintf( diff --git a/wp-includes/theme.php b/wp-includes/theme.php index d511ab1a8d..55e2d13789 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -861,7 +861,9 @@ function validate_current_theme() { return true; } - if ( ! file_exists( get_template_directory() . '/templates/index.html' ) + if ( + ! file_exists( get_template_directory() . '/templates/index.html' ) + && ! file_exists( get_template_directory() . '/block-templates/index.html' ) // Deprecated path support since 5.9.0. && ! file_exists( get_template_directory() . '/index.php' ) ) { // Invalid. diff --git a/wp-includes/version.php b/wp-includes/version.php index a3355b8c66..7c94a7faa9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53414'; +$wp_version = '6.1-alpha-53416'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.