Skip to content

Commit 3d3aa3c

Browse files
Block Editor: Add Global Styles support using theme.json file.
This is the second piece of landing the theme.json processing in WordPress core. It includes the mechanism that outputs the CSS styles of a theme.json file. Props nosolosw, youknowriad. See #53175. git-svn-id: https://develop.svn.wordpress.org/trunk@50973 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3236645 commit 3d3aa3c

File tree

5 files changed

+1065
-40
lines changed

5 files changed

+1065
-40
lines changed

src/wp-includes/block-editor.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,17 @@ function get_block_editor_settings( $editor_name, $custom_settings = array() ) {
243243
$custom_settings
244244
);
245245

246-
$editor_settings['__experimentalFeatures'] = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings )->get_settings();
246+
$theme_json = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings );
247247

248+
if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
249+
$editor_settings['styles'][] = array( 'css' => $theme_json->get_stylesheet( 'block_styles' ) );
250+
$editor_settings['styles'][] = array(
251+
'css' => $theme_json->get_stylesheet( 'css_variables' ),
252+
'__experimentalNoWrapper' => true,
253+
);
254+
}
255+
256+
$editor_settings['__experimentalFeatures'] = $theme_json->get_settings();
248257
// These settings may need to be updated based on data coming from theme.json sources.
249258
if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
250259
$editor_settings['colors'] = $editor_settings['__experimentalFeatures']['color']['palette'];

0 commit comments

Comments
 (0)