Make WordPress Core

Changeset 62767


Ignore:
Timestamp:
07/17/2026 09:08:42 AM (4 weeks ago)
Author:
0mirka00
Message:

Script Loader: Register wp-theme design tokens stylesheet.

Register the wp-theme stylesheet in the script loader so design tokens
are available to wp-components and the block editor dependency chain.

Developed in: https://github.com/WordPress/wordpress-develop/pull/12560
Reviewed by aduth, ciampo, mukesh27.
Fixes #65646.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r62750 r62767  
    17221722        // Only add CONTENT styles here that should be enqueued in the iframe!
    17231723        $wp_edit_blocks_dependencies = array(
     1724                'wp-theme',
    17241725                'wp-base-styles',
    17251726                'wp-components',
     
    17621763                'block-library'        => array(),
    17631764                'block-directory'      => array(),
     1765                'theme'                => array(),
    17641766                'base-styles'          => array(),
    1765                 'components'           => array(),
     1767                'components'           => array( 'wp-theme' ),
    17661768                'commands'             => array( 'wp-components' ),
    17671769                'edit-post'            => array(
     
    18301832                }
    18311833
     1834                if ( 'theme' === $package ) {
     1835                        $path = "/wp-includes/css/dist/theme/design-tokens$suffix.css";
     1836                }
     1837
    18321838                $styles->add( $handle, $path, $dependencies );
    18331839                $styles->add_data( $handle, 'path', ABSPATH . $path );
     
    18731879                'wp-editor-classic-layout-styles',
    18741880                'wp-block-library-theme',
     1881                'wp-theme',
    18751882                'wp-edit-blocks',
    18761883                'wp-block-editor',
  • trunk/tests/phpunit/tests/dependencies/styles.php

    r61927 r62767  
    556556                        $GLOBALS['wp_styles']->registered['wp-block-library']->src
    557557                );
     558        }
     559
     560        /**
     561         * Tests that the design tokens stylesheet is registered in core.
     562         *
     563         * @ticket 65646
     564         *
     565         * @covers ::wp_default_styles
     566         */
     567        public function test_wp_theme_style_is_registered() {
     568                wp_default_styles( $GLOBALS['wp_styles'] );
     569
     570                $this->assertArrayHasKey( 'wp-theme', $GLOBALS['wp_styles']->registered );
     571                $this->assertSame(
     572                        '/' . WPINC . '/css/dist/theme/design-tokens.css',
     573                        $GLOBALS['wp_styles']->registered['wp-theme']->src
     574                );
     575        }
     576
     577        /**
     578         * Tests that wp-components depends on wp-theme so tokens load before component styles.
     579         *
     580         * @ticket 65646
     581         *
     582         * @covers ::wp_default_styles
     583         */
     584        public function test_wp_components_depends_on_wp_theme() {
     585                wp_default_styles( $GLOBALS['wp_styles'] );
     586
     587                $this->assertContains(
     588                        'wp-theme',
     589                        $GLOBALS['wp_styles']->registered['wp-components']->deps
     590                );
     591        }
     592
     593        /**
     594         * Tests that wp-edit-blocks loads design tokens before other editor styles.
     595         *
     596         * @ticket 65646
     597         *
     598         * @covers ::wp_default_styles
     599         */
     600        public function test_wp_edit_blocks_depends_on_wp_theme_first() {
     601                wp_default_styles( $GLOBALS['wp_styles'] );
     602
     603                $deps = $GLOBALS['wp_styles']->registered['wp-edit-blocks']->deps;
     604
     605                $this->assertContains( 'wp-theme', $deps );
     606                $this->assertSame( 0, array_search( 'wp-theme', $deps, true ) );
    558607        }
    559608
Note: See TracChangeset for help on using the changeset viewer.