Skip to content

Commit

Permalink
WP Block Styles: Only load in the editor if a theme opts in (#29252)
Browse files Browse the repository at this point in the history
* WP Block Styles: Only load in the editor if a theme opts in, or if it doesn't add any editor styles

* Check that the array exists

* Update lib/client-assets.php

Co-authored-by: Jeff Ong <[email protected]>

Co-authored-by: Jeff Ong <[email protected]>
  • Loading branch information
scruffian and jffng authored Mar 5, 2021
1 parent 1b923b0 commit 09bd43c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,24 @@ function gutenberg_register_packages_styles( $styles ) {
);
$styles->add_data( 'wp-format-library', 'rtl', 'replace' );

$wp_edit_blocks_dependencies = array(
'wp-components',
'wp-editor',
'wp-block-library',
'wp-reusable-blocks',
);

global $editor_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.
$wp_edit_blocks_dependencies[] = 'wp-block-library-theme';
}

gutenberg_override_style(
$styles,
'wp-edit-blocks',
gutenberg_url( 'build/block-library/editor.css' ),
array(
'wp-components',
'wp-editor',
'wp-block-library',
'wp-reusable-blocks',
// Always include visual styles so the editor never appears broken.
'wp-block-library-theme',
),
$wp_edit_blocks_dependencies,
filemtime( gutenberg_dir_path() . 'build/block-library/editor.css' )
);
$styles->add_data( 'wp-edit-blocks', 'rtl', 'replace' );
Expand Down

0 comments on commit 09bd43c

Please sign in to comment.