Skip to content

Commit c6d0732

Browse files
committed
Handle omission of classic-theme-styles
1 parent 357f746 commit c6d0732

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

src/wp-includes/script-loader.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,13 +3907,14 @@ public function remove() {
39073907
$inserted_after = $printed_core_block_styles;
39083908
$printed_core_block_styles = '';
39093909

3910-
if ( ! $processor->has_bookmark( 'last_style_at_enqueued_block_assets' ) ) {
3911-
// TODO: There is no coverage for this.
3912-
$inserted_after .= $printed_other_block_styles;
3913-
$inserted_after .= $printed_global_styles;
3914-
3910+
if ( ! $processor->has_bookmark( 'classic_theme_styles' ) ) {
3911+
$inserted_after .= "\n" . $printed_other_block_styles;
39153912
$printed_other_block_styles = '';
3916-
$printed_global_styles = '';
3913+
3914+
if ( ! $processor->has_bookmark( 'last_style_at_enqueued_block_assets' ) ) {
3915+
$inserted_after .= "\n" . $printed_global_styles;
3916+
$printed_global_styles = '';
3917+
}
39173918
}
39183919

39193920
if ( '' !== $inserted_after ) {
@@ -3923,8 +3924,14 @@ public function remove() {
39233924

39243925
if ( '' !== $printed_global_styles && $processor->has_bookmark( 'last_style_at_enqueued_block_assets' ) ) {
39253926
$processor->seek( 'last_style_at_enqueued_block_assets' );
3927+
39263928
$processor->insert_after( "\n" . $printed_global_styles );
39273929
$printed_global_styles = '';
3930+
3931+
if ( ! $processor->has_bookmark( 'classic_theme_styles' ) ) {
3932+
$processor->insert_after( "\n" . $printed_other_block_styles );
3933+
$printed_other_block_styles = '';
3934+
}
39283935
}
39293936

39303937
if ( '' !== $printed_other_block_styles && $processor->has_bookmark( 'classic_theme_styles' ) ) {

tests/phpunit/tests/template.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,39 @@ public function data_wp_hoist_late_printed_styles(): array {
15491549
'BODY' => array(),
15501550
),
15511551
),
1552+
'classic_theme_styles_omitted' => array(
1553+
'set_up' => static function () {
1554+
// Note that wp_enqueue_scripts is used instead of enqueue_block_assets because it runs again at the former action.
1555+
add_action(
1556+
'wp_enqueue_scripts',
1557+
static function () {
1558+
wp_dequeue_style( 'classic-theme-styles' );
1559+
},
1560+
100
1561+
);
1562+
},
1563+
'inline_size_limit' => PHP_INT_MAX,
1564+
'expected_styles' => array(
1565+
'HEAD' => array(
1566+
'wp-img-auto-sizes-contain-inline-css',
1567+
'early-css',
1568+
'early-inline-css',
1569+
'wp-emoji-styles-inline-css',
1570+
'wp-block-library-inline-css',
1571+
'wp-block-separator-inline-css',
1572+
'third-party-test-block-css',
1573+
'custom-block-styles-css',
1574+
'global-styles-inline-css',
1575+
'normal-css',
1576+
'normal-inline-css',
1577+
'wp-custom-css',
1578+
'late-css',
1579+
'late-inline-css',
1580+
'core-block-supports-inline-css',
1581+
),
1582+
'BODY' => array(),
1583+
),
1584+
),
15521585
'standard_classic_theme_config_extra_block_library_inline_style' => array(
15531586
'set_up' => static function () {
15541587
add_action(

0 commit comments

Comments
 (0)