Make WordPress Core


Ignore:
Timestamp:
12/14/2021 03:31:14 PM (22 months ago)
Author:
hellofromTonya
Message:

Customize: Overlay incompatible banner for block themes.

Starting in 5.9, block themes are not compatible with (do not support) Customizer; rather, they use the Site Editor. Viewing installed themes in Customizer, this commit adds an overlay message to alert users and give them a way to activate the block theme. Clicking on the "Activate" button activates the block theme and redirects back to the Appearance > Themes interface, where the user can then enter the Site Editor for customization.

Non-block themes are not affected by this change and continue to work in Customizer.

Follow-up to [41648], [41893], [52279].

Props antonvlasenko, costdev, hellofromTonya, jffng, joyously, noisysocks, poena, shaunandrews.
Fixes #54549.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/CustomizeManager.php

    r52010 r52371  
    715715        $this->assertSame( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] );
    716716    }
     717
     718    /**
     719     * Test request for retrieving installed themes.
     720     *
     721     * @ticket 54549
     722     * @covers WP_Customize_Manager::handle_load_themes_request
     723     */
     724    public function test_wp_ajax_customize_load_themes_action() {
     725        $arguments = array(
     726            'changeset_uuid'     => false,
     727            'settings_previewed' => true,
     728            'branching'          => false,
     729        );
     730        new WP_Customize_Manager( $arguments );
     731        wp_set_current_user( self::$admin_user_id );
     732        $nonce                 = wp_create_nonce( 'switch_themes' );
     733        $_POST['nonce']        = $nonce;
     734        $_GET['nonce']         = $nonce;
     735        $_REQUEST['nonce']     = $nonce;
     736        $_POST['theme_action'] = 'installed';
     737        $this->make_ajax_call( 'customize_load_themes' );
     738        $response = $this->_last_response_parsed;
     739        $this->assertIsArray( $response, 'Response is not an array' );
     740
     741        $this->assertArrayHasKey( 'success', $response, 'Response must have a "success" key' );
     742        $this->assertTrue( $response['success'], 'Response was not "success"' );
     743
     744        $this->assertArrayHasKey( 'data', $response, 'Response must have a "data" key' );
     745        $this->assertIsArray( $response['data'], 'The response "data" is not an array' );
     746        $this->assertArrayHasKey( 'themes', $response['data'], 'The response data must have a "themes" key' );
     747        $this->assertIsArray( $response['data']['themes'], 'Themes data is not an array' );
     748        $this->assertNotEmpty( $response['data']['themes'], 'Themes data must not be empty' );
     749
     750        foreach ( $response['data']['themes'] as $theme ) {
     751            $this->assertIsArray( $theme, 'Theme is not an array' );
     752            $this->assertNotEmpty( $theme, 'Theme data must not be empty' );
     753            $this->assertArrayHasKey( 'id', $theme, 'Theme data must have an "id" key' );
     754            $this->assertNotEmpty( $theme['id'], 'Theme id cannot be empty' );
     755
     756            $this->assertArrayHasKey( 'name', $theme, 'Theme data must have a "name" key' );
     757            $this->assertNotEmpty( $theme['name'], 'Theme name cannot be empty' );
     758
     759            $this->assertArrayHasKey( 'blockTheme', $theme, 'Themes data must include information about blocks support' );
     760        }
     761    }
    717762}
Note: See TracChangeset for help on using the changeset viewer.