From 7e812cfe416c48496218a0e7aedebbffe4d2f59a Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 20 Nov 2026 10:29:49 +0530 Subject: [PATCH 1/2] Editor: Restore the default editor styles for classic themes. `get_default_block_editor_settings()` read the default editor styles from `wp-includes/css/dist/block-editor/default-editor-styles.css`. The block editor package no longer ships that file, and [65716] deletes it during upgrades. Because of this, the `defaultEditorStyles` setting is always empty in 7.2. Classic themes without their own editor styles, and users who turn off "Use theme styles", lose the default font, font size, line height, block gap, and post title styles. This moves the CSS from the last shipped version of that file into core, so the setting no longer depends on the file. Follow-up to [65716]. Co-Authored-By: Claude Opus 5.5 --- src/wp-includes/block-editor.php | 27 ++++++++++++--------------- tests/phpunit/tests/blocks/editor.php | 11 +++++++++++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index 24bdd2f6db5db..c7346359d377e 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -194,21 +194,18 @@ function get_default_block_editor_settings() { } } - // These styles are used if the "no theme styles" options is triggered or on - // themes without their own editor styles. - $default_editor_styles_file = ABSPATH . WPINC . '/css/dist/block-editor/default-editor-styles.css'; - - static $default_editor_styles_file_contents = false; - if ( ! $default_editor_styles_file_contents && file_exists( $default_editor_styles_file ) ) { - $default_editor_styles_file_contents = file_get_contents( $default_editor_styles_file ); - } - - $default_editor_styles = array(); - if ( $default_editor_styles_file_contents ) { - $default_editor_styles = array( - array( 'css' => $default_editor_styles_file_contents ), - ); - } + /* + * These styles are used if the "no theme styles" option is triggered or on + * themes without their own editor styles. + * + * They were previously read from `css/dist/block-editor/default-editor-styles.css`, + * which the block editor package no longer ships. + */ + $default_editor_styles = array( + array( + 'css' => 'body{font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:18px;line-height:1.5;--wp--style--block-gap:2em}p{line-height:1.8}.editor-post-title__block{margin-top:2em;margin-bottom:1em;font-size:2.5em;font-weight:800}', + ), + ); $editor_settings = array( 'alignWide' => get_theme_support( 'align-wide' ), diff --git a/tests/phpunit/tests/blocks/editor.php b/tests/phpunit/tests/blocks/editor.php index 5055aab4d999e..4fd0d76c86639 100644 --- a/tests/phpunit/tests/blocks/editor.php +++ b/tests/phpunit/tests/blocks/editor.php @@ -382,6 +382,17 @@ public static function data_get_default_block_editor_settings_auto_attach_media_ ); } + /** + * Tests that the default editor styles are provided without the removed block editor stylesheet. + */ + public function test_get_default_block_editor_settings_default_editor_styles() { + $settings = get_default_block_editor_settings(); + + $this->assertCount( 1, $settings['defaultEditorStyles'], 'There should be one default editor style.' ); + $this->assertStringContainsString( 'font-size:18px', $settings['defaultEditorStyles'][0]['css'], 'The default editor style should set the body font size.' ); + $this->assertStringContainsString( '.editor-post-title__block', $settings['defaultEditorStyles'][0]['css'], 'The default editor style should style the post title.' ); + } + /** * @ticket 56815 */ From e32d3ed168c46b74d6f8cd9d5c4b52178e1a48b7 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Sat, 21 Nov 2026 09:23:25 +0530 Subject: [PATCH 2/2] Editor: Narrow the restored default editor styles to where they apply. Since [61473], the post editor gives classic themes their global styles, so it only uses `defaultEditorStyles` when the "Use theme styles" preference is turned off. The Customizer widgets editor always uses them. This updates the code comment to say so. This also removes the `.editor-post-title__block` rule. Gutenberg removed that class in WordPress 5.9, so the rule has not matched anything since then. The test assertions move into `test_get_default_block_editor_settings()`, which checks each default setting and did not check `defaultEditorStyles`. Props wildworks. See #66762. Co-Authored-By: Claude Opus 5.5 --- src/wp-includes/block-editor.php | 6 +++--- tests/phpunit/tests/blocks/editor.php | 14 +++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index c7346359d377e..8aa19ffe35224 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -195,15 +195,15 @@ function get_default_block_editor_settings() { } /* - * These styles are used if the "no theme styles" option is triggered or on - * themes without their own editor styles. + * These styles are used when the "Use theme styles" preference is turned off + * and in the Customizer widgets editor. * * They were previously read from `css/dist/block-editor/default-editor-styles.css`, * which the block editor package no longer ships. */ $default_editor_styles = array( array( - 'css' => 'body{font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:18px;line-height:1.5;--wp--style--block-gap:2em}p{line-height:1.8}.editor-post-title__block{margin-top:2em;margin-bottom:1em;font-size:2.5em;font-weight:800}', + 'css' => 'body{font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:18px;line-height:1.5;--wp--style--block-gap:2em}p{line-height:1.8}', ), ); diff --git a/tests/phpunit/tests/blocks/editor.php b/tests/phpunit/tests/blocks/editor.php index 4fd0d76c86639..d152e8b8577f6 100644 --- a/tests/phpunit/tests/blocks/editor.php +++ b/tests/phpunit/tests/blocks/editor.php @@ -247,6 +247,7 @@ public function test_get_allowed_block_types_deprecated_filter_post_editor() { /** * @ticket 52920 + * @ticket 66762 */ public function test_get_default_block_editor_settings() { $settings = get_default_block_editor_settings(); @@ -300,6 +301,8 @@ public function test_get_default_block_editor_settings() { $this->assertFalse( $settings['disableCustomFontSizes'] ); $this->assertFalse( $settings['disableCustomGradients'] ); $this->assertFalse( $settings['disableLayoutStyles'] ); + $this->assertCount( 1, $settings['defaultEditorStyles'] ); + $this->assertStringContainsString( 'font-size:18px', $settings['defaultEditorStyles'][0]['css'] ); $this->assertFalse( $settings['enableCustomLineHeight'] ); $this->assertFalse( $settings['enableCustomSpacing'] ); $this->assertFalse( $settings['enableCustomUnits'] ); @@ -382,17 +385,6 @@ public static function data_get_default_block_editor_settings_auto_attach_media_ ); } - /** - * Tests that the default editor styles are provided without the removed block editor stylesheet. - */ - public function test_get_default_block_editor_settings_default_editor_styles() { - $settings = get_default_block_editor_settings(); - - $this->assertCount( 1, $settings['defaultEditorStyles'], 'There should be one default editor style.' ); - $this->assertStringContainsString( 'font-size:18px', $settings['defaultEditorStyles'][0]['css'], 'The default editor style should set the body font size.' ); - $this->assertStringContainsString( '.editor-post-title__block', $settings['defaultEditorStyles'][0]['css'], 'The default editor style should style the post title.' ); - } - /** * @ticket 56815 */