Skip to content

Commit c8d5b0c

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents 9c13fd7 + 81b2b5b commit c8d5b0c

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

src/wp-includes/script-loader.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@ function wp_default_styles( $styles ) {
17211721

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',
17261727
/*
@@ -1761,8 +1762,9 @@ function wp_default_styles( $styles ) {
17611762
'block-editor' => array( 'wp-components', 'wp-preferences' ),
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(
17681770
'wp-components',
@@ -1829,6 +1831,10 @@ function wp_default_styles( $styles ) {
18291831
$path = "/wp-includes/css/dist/base-styles/admin-schemes$suffix.css";
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 );
18341840
}
@@ -1872,6 +1878,7 @@ function wp_default_styles( $styles ) {
18721878
'wp-reset-editor-styles',
18731879
'wp-editor-classic-layout-styles',
18741880
'wp-block-library-theme',
1881+
'wp-theme',
18751882
'wp-edit-blocks',
18761883
'wp-block-editor',
18771884
'wp-block-library',

tests/phpunit/tests/dependencies/styles.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,55 @@ public function test_block_styles_for_viewing_with_split_styles() {
557557
);
558558
}
559559

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 ) );
607+
}
608+
560609
/**
561610
* @ticket 58394
562611
* @ticket 63887

0 commit comments

Comments
 (0)