Make WordPress Core


Ignore:
Timestamp:
05/20/2022 12:47:45 AM (2 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpTheme.php

    r53253 r53416  
    310310                'expected'  => true,
    311311            ),
     312            'deprecated block theme'    => array(
     313                'theme_dir' => 'block-theme-deprecated-path',
     314                'expected'  => true,
     315            ),
    312316        );
    313317    }
     
    336340    public function data_get_file_path() {
    337341        return array(
    338             'no theme: no file given'           => array(
     342            'no theme: no file given'              => array(
    339343                'theme_dir' => 'nonexistent',
    340344                'file'      => '',
    341345                'expected'  => '/nonexistent',
    342346            ),
    343             'parent theme: no file given'       => array(
     347            'parent theme: no file given'          => array(
    344348                'theme_dir' => 'block-theme',
    345349                'file'      => '',
    346350                'expected'  => '/block-theme',
    347351            ),
    348             'child theme: no file given'        => array(
     352            'child theme: no file given'           => array(
    349353                'theme_dir' => 'block-theme-child',
    350354                'file'      => '',
    351355                'expected'  => '/block-theme-child',
    352356            ),
    353             'nonexistent theme: file given'     => array(
     357            'nonexistent theme: file given'        => array(
    354358                'theme_dir' => 'nonexistent',
    355359                'file'      => '/templates/page.html',
    356360                'expected'  => '/nonexistent/templates/page.html',
    357361            ),
    358             'parent theme: file exists'         => array(
     362            'parent theme: file exists'            => array(
    359363                'theme_dir' => 'block-theme',
    360364                'file'      => '/templates/page-home.html',
    361365                'expected'  => '/block-theme/templates/page-home.html',
    362366            ),
    363             'parent theme: file does not exist' => array(
     367            'parent theme: deprecated file exists' => array(
     368                'theme_dir' => 'block-theme-deprecated-path',
     369                'file'      => '/block-templates/page-home.html',
     370                'expected'  => '/block-theme-deprecated-path/block-templates/page-home.html',
     371            ),
     372            'parent theme: file does not exist'    => array(
    364373                'theme_dir' => 'block-theme',
    365374                'file'      => '/templates/nonexistent.html',
    366375                'expected'  => '/block-theme/templates/nonexistent.html',
    367376            ),
    368             'child theme: file exists'          => array(
     377            'child theme: file exists'             => array(
    369378                'theme_dir' => 'block-theme-child',
    370379                'file'      => '/templates/page-1.html',
    371380                'expected'  => '/block-theme-child/templates/page-1.html',
    372381            ),
    373             'child theme: file does not exist'  => array(
     382            'child theme: file does not exist'     => array(
    374383                'theme_dir' => 'block-theme-child',
    375384                'file'      => '/templates/nonexistent.html',
Note: See TracChangeset for help on using the changeset viewer.