From f19a0ac5cee027b8ced2e0793aeec7af3d49b6f3 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 26 Jan 2023 14:06:53 +0000 Subject: [PATCH 1/6] Update site-editor.php --- src/wp-admin/site-editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php index deb556a695768..68940e77bc4f5 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -146,7 +146,7 @@ static function( $classes ) { wp_enqueue_media(); if ( - current_theme_supports( 'wp-block-styles' ) || + current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { wp_enqueue_style( 'wp-block-library-theme' ); From 2bdf0f6e576dc3bbbcc31d3df901fe473e785431 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 26 Jan 2023 14:08:38 +0000 Subject: [PATCH 2/6] Update script-loader.php --- src/wp-includes/script-loader.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index de52578936989..7ac503553a34e 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1624,7 +1624,10 @@ function wp_default_styles( $styles ) { $wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles'; } - if ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) { + if ( + current_theme_supports( 'wp-block-styles' ) && + ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) + ) { // Include opinionated block styles if no $editor_styles are declared, so the editor never appears broken. $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; } From 436ef90556c924617c8835648018285e7533477d Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 26 Jan 2023 14:22:05 +0000 Subject: [PATCH 3/6] Update comment --- src/wp-includes/script-loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 7ac503553a34e..c52b3a9e8fecc 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1628,7 +1628,7 @@ function wp_default_styles( $styles ) { current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { - // Include opinionated block styles if no $editor_styles are declared, so the editor never appears broken. + // Include opinionated block styles if the theme supports block styles and no $editor_styles are declared, so the editor never appears broken. $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; } From dfc34928cd3c18c035b1d9e70d3a5afd40bb53fe Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 26 Jan 2023 14:28:38 +0000 Subject: [PATCH 4/6] Update block-editor.php --- src/wp-includes/block-editor.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index 4227c674c02ff..7e4058f3b9c49 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -314,7 +314,7 @@ function get_legacy_widget_block_editor_settings() { * } */ function _wp_get_iframed_editor_assets() { - global $pagenow; + global $pagenow, $editor_styles; $script_handles = array(); $style_handles = array( @@ -323,7 +323,10 @@ function _wp_get_iframed_editor_assets() { 'wp-edit-blocks', ); - if ( current_theme_supports( 'wp-block-styles' ) ) { + if ( + current_theme_supports( 'wp-block-styles' ) && + ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) + ) { $style_handles[] = 'wp-block-library-theme'; } From 4b652e5cdb8ccb36495c3f37900639a1be517603 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 20 Feb 2023 08:54:28 -0600 Subject: [PATCH 5/6] Updates the test --- tests/phpunit/tests/dependencies/styles.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 34a9847f2f4d8..0d2f8e664bf33 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -405,9 +405,9 @@ public function data_styles_with_media() { } /** - * Tests that visual block styles are enqueued in the editor even when there is not theme support for 'wp-block-styles'. + * Tests that visual block styles are not be enqueued in the editor when there is not theme support for 'wp-block-styles'. * - * Visual block styles should always be enqueued when editing to avoid the appearance of a broken editor. + * @ticket 57561 * * @covers ::wp_enqueue_style */ @@ -419,7 +419,7 @@ public function test_block_styles_for_editing_without_theme_support() { $this->assertFalse( wp_style_is( 'wp-block-library-theme' ) ); wp_enqueue_style( 'wp-edit-blocks' ); - $this->assertTrue( wp_style_is( 'wp-block-library-theme' ) ); + $this->assertFalse( wp_style_is( 'wp-block-library-theme' ), "The 'wp-block-library-theme' style should not be in the queue after enqueuing 'wp-edit-blocks'" ); } /** From 2e0e055a8c3c35f1e9496163e1424583df438af6 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Mon, 20 Feb 2023 14:59:49 -0600 Subject: [PATCH 6/6] Splits long comment into multiline --- src/wp-includes/script-loader.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index c52b3a9e8fecc..ecde8a4952381 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1628,7 +1628,10 @@ function wp_default_styles( $styles ) { current_theme_supports( 'wp-block-styles' ) && ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) ) { - // Include opinionated block styles if the theme supports block styles and no $editor_styles are declared, so the editor never appears broken. + /* + * Include opinionated block styles if the theme supports block styles and + * no $editor_styles are declared, so the editor never appears broken. + */ $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; }