Editor: Fix 'wp-block-library-theme' style enqueue conditions.

Fixes the conditions for when to enqueue the opinionated block styles (i.e. `'wp-block-library-theme'` stylesheet):

* the theme adds `'wp-block-styles'` theme support;
* and no editor styles are declared.

This resolves an issue with themes that do not add the `'wp-block-styles'` theme support while not impacting themes that do.

Follow-up to [53419], [52069], [50761], [44157].

Props mikachan, costdev, glendaviesnz, hellofromTonya, jffng, mamaduka, ndiego, poena, sannevndrmeulen, scruffian.
Fixes #57561.
Built from https://develop.svn.wordpress.org/trunk@55368


git-svn-id: http://core.svn.wordpress.org/trunk@54901 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2023-02-20 21:13:27 +00:00
parent 89a3b0e9f2
commit 5bf74c0433
4 changed files with 15 additions and 6 deletions

View File

@ -120,7 +120,7 @@ wp_enqueue_style( 'wp-format-library' );
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' );

View File

@ -296,7 +296,7 @@ function get_legacy_widget_block_editor_settings() {
* }
*/
function _wp_get_iframed_editor_assets() {
global $pagenow;
global $pagenow, $editor_styles;
$script_handles = array(
'wp-polyfill',
@ -305,7 +305,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';
}

View File

@ -1635,8 +1635,14 @@ function wp_default_styles( $styles ) {
$wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles';
}
if ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) {
// Include opinionated block styles if no $editor_styles are declared, so the editor never appears broken.
if (
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.
*/
$wp_edit_blocks_dependencies[] = 'wp-block-library-theme';
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-beta2-55367';
$wp_version = '6.2-beta2-55368';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.