diff -r be944660c56a -r 3d72ae0968f4 wp/wp-admin/includes/class-theme-upgrader.php --- a/wp/wp-admin/includes/class-theme-upgrader.php Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-admin/includes/class-theme-upgrader.php Tue Sep 27 16:37:53 2022 +0200 @@ -92,7 +92,7 @@ /* translators: %s: Theme name. */ $this->strings['parent_theme_not_found'] = sprintf( __( 'The parent theme could not be found. You will need to install the parent theme, %s, before you can use this child theme.' ), '%s' ); /* translators: %s: Theme error. */ - $this->strings['current_theme_has_errors'] = __( 'The current theme has the following error: "%s".' ); + $this->strings['current_theme_has_errors'] = __( 'The active theme has the following error: "%s".' ); if ( ! empty( $this->skin->overwrite ) ) { if ( 'update-theme' === $this->skin->overwrite ) { @@ -448,7 +448,7 @@ ) ); - $results[ $theme ] = $this->result; + $results[ $theme ] = $result; // Prevent credentials auth screen from displaying multiple times. if ( false === $result ) { @@ -560,21 +560,34 @@ $this->strings['incompatible_archive'], sprintf( /* translators: %s: style.css */ - __( 'The %s stylesheet doesn’t contain a valid theme header.' ), + __( 'The %s stylesheet does not contain a valid theme header.' ), 'style.css' ) ); } - // 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' ) ); } @@ -609,27 +622,27 @@ } /** - * Turn on maintenance mode before attempting to upgrade the current theme. + * Turn on maintenance mode before attempting to upgrade the active theme. * * Hooked to the {@see 'upgrader_pre_install'} filter by Theme_Upgrader::upgrade() and * Theme_Upgrader::bulk_upgrade(). * * @since 2.8.0 * - * @param bool|WP_Error $return Upgrade offer return. - * @param array $theme Theme arguments. - * @return bool|WP_Error The passed in $return param or WP_Error. + * @param bool|WP_Error $response The installation response before the installation has started. + * @param array $theme Theme arguments. + * @return bool|WP_Error The original `$response` parameter or WP_Error. */ - public function current_before( $return, $theme ) { - if ( is_wp_error( $return ) ) { - return $return; + public function current_before( $response, $theme ) { + if ( is_wp_error( $response ) ) { + return $response; } $theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; - // Only run if current theme + // Only run if active theme. if ( get_stylesheet() !== $theme ) { - return $return; + return $response; } // Change to maintenance mode. Bulk edit handles this separately. @@ -637,31 +650,31 @@ $this->maintenance_mode( true ); } - return $return; + return $response; } /** - * Turn off maintenance mode after upgrading the current theme. + * Turn off maintenance mode after upgrading the active theme. * * Hooked to the {@see 'upgrader_post_install'} filter by Theme_Upgrader::upgrade() * and Theme_Upgrader::bulk_upgrade(). * * @since 2.8.0 * - * @param bool|WP_Error $return Upgrade offer return. - * @param array $theme Theme arguments. - * @return bool|WP_Error The passed in $return param or WP_Error. + * @param bool|WP_Error $response The installation response after the installation has finished. + * @param array $theme Theme arguments. + * @return bool|WP_Error The original `$response` parameter or WP_Error. */ - public function current_after( $return, $theme ) { - if ( is_wp_error( $return ) ) { - return $return; + public function current_after( $response, $theme ) { + if ( is_wp_error( $response ) ) { + return $response; } $theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; - // Only run if current theme. + // Only run if active theme. if ( get_stylesheet() !== $theme ) { - return $return; + return $response; } // Ensure stylesheet name hasn't changed after the upgrade: @@ -675,7 +688,7 @@ if ( ! $this->bulk ) { $this->maintenance_mode( false ); } - return $return; + return $response; } /**