Themes: Accept valid block themes.

Updates theme validation to accept block themes. This replaces the requirement for an `index.php` with a requirement for either an `index.php`, `/templates/index.html` or the deprecated `/block-templates/index.html`.

Validation is updated for theme uploads, within `WP_Theme::__construct` and `validate_current_theme()`. 

A block theme using the deprecated file structure is now included in the unit tests.

Props peterwilsoncc, sergeybiryukov, hellofromtonya, costdev, azaozz, gziolo, FlorianBrinkmann, Boniu91, aristath, poena, audrasjb.
Fixes #55754.


git-svn-id: https://develop.svn.wordpress.org/trunk@53416 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson
2022-05-20 00:47:45 +00:00
parent 96d6eae601
commit 72bc35114b
13 changed files with 166 additions and 19 deletions
+3 -1
View File
@@ -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(