Make WordPress Core


Ignore:
Timestamp:
01/12/2026 12:18:12 PM (5 weeks ago)
Author:
youknowriad
Message:

Global Styles: Lift classic block restrictions.

Enable Global Styles functionality in classic WordPress themes, allowing features like the Font Library to work without requiring a theme.json file.

This change:

  • Removes restrictions that prevented classic themes from accessing Global Styles features.
  • Enables font functionality in classic themes through the Font Library.
  • Fixes Fonts menu not appearing in classic themes by changing its submenu index to avoid collision with Widgets.

Props youknowriad, isabel_brison, ramonopoly.
Fixes #64408.

File:
1 edited

Legend:

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

    r60729 r61473  
    735735     * @covers WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles
    736736     */
    737     public function test_get_user_data_from_wp_global_styles_does_not_run_for_theme_without_support() {
    738         // The 'default' theme does not support theme.json.
     737    public function test_get_user_data_from_wp_global_styles_runs_for_classic_themes() {
     738        // The 'default' theme does not support theme.json (classic theme).
    739739        switch_theme( 'default' );
    740740        wp_set_current_user( self::$administrator_id );
    741741        $theme = wp_get_theme();
    742742
    743         $start_queries = get_num_queries();
    744 
    745         // When theme.json is not supported, the method should not run a query and always return an empty result.
    746         $user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme );
    747         $this->assertEmpty( $user_cpt, 'User CPT is expected to be empty.' );
    748         $this->assertSame( 0, get_num_queries() - $start_queries, 'Unexpected SQL query detected for theme without theme.json support.' );
    749 
     743        // Classic themes should now be able to access user global styles data.
     744        // When should_create_post is true, it should create a post.
    750745        $user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme, true );
    751         $this->assertEmpty( $user_cpt, 'User CPT is expected to be empty.' );
    752         $this->assertSame( 0, get_num_queries() - $start_queries, 'Unexpected SQL query detected for theme without theme.json support.' );
     746        $this->assertIsArray( $user_cpt, 'User CPT should be an array for classic themes.' );
     747        $this->assertArrayHasKey( 'ID', $user_cpt, 'User CPT should have an ID for classic themes.' );
     748
     749        // Clean up the created post.
     750        if ( isset( $user_cpt['ID'] ) ) {
     751            wp_delete_post( $user_cpt['ID'], true );
     752        }
    753753    }
    754754
Note: See TracChangeset for help on using the changeset viewer.