Make WordPress Core


Ignore:
Timestamp:
12/07/2021 12:00:45 AM (4 years ago)
Author:
hellofromTonya
Message:

Themes: Better names for WP_Theme::is_block_theme() and wp_is_block_theme() and make wp_is_block_theme() a wrapper.

This commit renames the following method and function to better represent block theme terminology:

  • WP_Theme::is_block_based() to WP_Theme::is_block_theme()
  • wp_is_block_template_theme() to wp_is_block_theme()

It also changes wp_is_block_theme() to be a helper wrapper (sugar syntax) for wp_get_theme()->is_block_theme();. Why? To ensure both the method and function behave the same, to help Gutenberg maintain WordPress cross-version compatibility, and to make it less cumbersome to port changes from Gutenberg to Core.

Follow-up to [52069], [52247], [52279].

Props antonvlasenko, costdev, hellofromTonya, noisysocks.
Fixes #54550.

File:
1 edited

Legend:

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

    r52279 r52330  
    249249
    250250    /**
    251      * @dataProvider data_is_block_based
     251     * @dataProvider data_is_block_theme
    252252     * @ticket 54460
    253253     *
    254      * @covers WP_Theme::is_block_based
     254     * @covers WP_Theme::is_block_theme
    255255     *
    256256     * @param string $theme_dir Directory of the theme to test.
    257257     * @param bool   $expected  Expected result.
    258258     */
    259     public function test_is_block_based( $theme_dir, $expected ) {
    260         $theme  = new WP_Theme( $theme_dir, $this->theme_root );
    261         $actual = $theme->is_block_based();
    262 
    263         if ( $expected ) {
    264             $this->assertTrue( $actual );
    265         } else {
    266             $this->assertFalse( $actual );
    267         }
     259    public function test_is_block_theme( $theme_dir, $expected ) {
     260        $theme = new WP_Theme( $theme_dir, $this->theme_root );
     261        $this->assertSame( $expected, $theme->is_block_theme() );
    268262    }
    269263
     
    273267     * @return array
    274268     */
    275     public function data_is_block_based() {
     269    public function data_is_block_theme() {
    276270        return array(
    277271            'default - non-block theme' => array(
Note: See TracChangeset for help on using the changeset viewer.