From e407a97a836473e3a49a43e27b87d5edca1eea83 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Fri, 17 Jul 2026 00:30:46 +0900 Subject: [PATCH 1/3] Register wp-theme stylesheet in script loader --- src/wp-includes/script-loader.php | 11 +++- tests/phpunit/tests/dependencies/styles.php | 57 +++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 01ef8a348e5bc..bb8b6392c3450 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1721,6 +1721,7 @@ function wp_default_styles( $styles ) { // Only add CONTENT styles here that should be enqueued in the iframe! $wp_edit_blocks_dependencies = array( + 'wp-theme', 'wp-base-styles', 'wp-components', /* @@ -1760,9 +1761,10 @@ function wp_default_styles( $styles ) { $package_styles = array( 'block-editor' => array( 'wp-components', 'wp-preferences' ), 'block-library' => array(), - 'block-directory' => array(), + 'block-directory' => array( 'wp-theme' ), + 'theme' => array(), 'base-styles' => array(), - 'components' => array(), + 'components' => array( 'wp-theme' ), 'commands' => array( 'wp-components' ), 'edit-post' => array( 'wp-components', @@ -1829,6 +1831,10 @@ function wp_default_styles( $styles ) { $path = "/wp-includes/css/dist/base-styles/admin-schemes$suffix.css"; } + if ( 'theme' === $package ) { + $path = "/wp-includes/css/dist/theme/design-tokens$suffix.css"; + } + $styles->add( $handle, $path, $dependencies ); $styles->add_data( $handle, 'path', ABSPATH . $path ); } @@ -1872,6 +1878,7 @@ function wp_default_styles( $styles ) { 'wp-reset-editor-styles', 'wp-editor-classic-layout-styles', 'wp-block-library-theme', + 'wp-theme', 'wp-edit-blocks', 'wp-block-editor', 'wp-block-library', diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index de6fefb94b5bb..b2a3d9e293861 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -557,6 +557,63 @@ public function test_block_styles_for_viewing_with_split_styles() { ); } + /** + * Tests that the design tokens stylesheet is registered in core. + * + * @covers ::wp_default_styles + */ + public function test_wp_theme_style_is_registered() { + wp_default_styles( $GLOBALS['wp_styles'] ); + + $this->assertArrayHasKey( 'wp-theme', $GLOBALS['wp_styles']->registered ); + $this->assertSame( + '/' . WPINC . '/css/dist/theme/design-tokens.css', + $GLOBALS['wp_styles']->registered['wp-theme']->src + ); + } + + /** + * Tests that wp-components depends on wp-theme so tokens load before component styles. + * + * @covers ::wp_default_styles + */ + public function test_wp_components_depends_on_wp_theme() { + wp_default_styles( $GLOBALS['wp_styles'] ); + + $this->assertContains( + 'wp-theme', + $GLOBALS['wp_styles']->registered['wp-components']->deps + ); + } + + /** + * Tests that wp-block-directory depends on wp-theme for design token CSS. + * + * @covers ::wp_default_styles + */ + public function test_wp_block_directory_depends_on_wp_theme() { + wp_default_styles( $GLOBALS['wp_styles'] ); + + $this->assertContains( + 'wp-theme', + $GLOBALS['wp_styles']->registered['wp-block-directory']->deps + ); + } + + /** + * Tests that wp-edit-blocks loads design tokens before other editor styles. + * + * @covers ::wp_default_styles + */ + public function test_wp_edit_blocks_depends_on_wp_theme_first() { + wp_default_styles( $GLOBALS['wp_styles'] ); + + $deps = $GLOBALS['wp_styles']->registered['wp-edit-blocks']->deps; + + $this->assertContains( 'wp-theme', $deps ); + $this->assertSame( 0, array_search( 'wp-theme', $deps, true ) ); + } + /** * @ticket 58394 * @ticket 63887 From 0f3608e3e7a000ee4a9729100c9606d4919f794c Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Fri, 17 Jul 2026 00:41:28 +0900 Subject: [PATCH 2/3] Remove wp-theme dependency from block-directory --- src/wp-includes/script-loader.php | 2 +- tests/phpunit/tests/dependencies/styles.php | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index bb8b6392c3450..d777ecccc4373 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1761,7 +1761,7 @@ function wp_default_styles( $styles ) { $package_styles = array( 'block-editor' => array( 'wp-components', 'wp-preferences' ), 'block-library' => array(), - 'block-directory' => array( 'wp-theme' ), + 'block-directory' => array(), 'theme' => array(), 'base-styles' => array(), 'components' => array( 'wp-theme' ), diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index b2a3d9e293861..a39efa2fafa7f 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -586,20 +586,6 @@ public function test_wp_components_depends_on_wp_theme() { ); } - /** - * Tests that wp-block-directory depends on wp-theme for design token CSS. - * - * @covers ::wp_default_styles - */ - public function test_wp_block_directory_depends_on_wp_theme() { - wp_default_styles( $GLOBALS['wp_styles'] ); - - $this->assertContains( - 'wp-theme', - $GLOBALS['wp_styles']->registered['wp-block-directory']->deps - ); - } - /** * Tests that wp-edit-blocks loads design tokens before other editor styles. * From 8b4e0655815b956f7c3e742d9100b34f85b4f479 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Fri, 17 Jul 2026 17:24:46 +0900 Subject: [PATCH 3/3] Add @ticket annotations to wp-theme style tests. --- tests/phpunit/tests/dependencies/styles.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index a39efa2fafa7f..90c4e59fccdee 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -560,6 +560,8 @@ public function test_block_styles_for_viewing_with_split_styles() { /** * Tests that the design tokens stylesheet is registered in core. * + * @ticket 65646 + * * @covers ::wp_default_styles */ public function test_wp_theme_style_is_registered() { @@ -575,6 +577,8 @@ public function test_wp_theme_style_is_registered() { /** * Tests that wp-components depends on wp-theme so tokens load before component styles. * + * @ticket 65646 + * * @covers ::wp_default_styles */ public function test_wp_components_depends_on_wp_theme() { @@ -589,6 +593,8 @@ public function test_wp_components_depends_on_wp_theme() { /** * Tests that wp-edit-blocks loads design tokens before other editor styles. * + * @ticket 65646 + * * @covers ::wp_default_styles */ public function test_wp_edit_blocks_depends_on_wp_theme_first() {