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
This commit is contained in:
Jorge Costa
2021-05-24 17:38:59 +00:00
parent 3236645ae7
commit 3d3aa3cd09
5 changed files with 1067 additions and 42 deletions

View File

@@ -243,8 +243,17 @@ function get_block_editor_settings( $editor_name, $custom_settings = array() ) {
$custom_settings
);
$editor_settings['__experimentalFeatures'] = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings )->get_settings();
$theme_json = WP_Theme_JSON_Resolver::get_merged_data( $editor_settings );
if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
$editor_settings['styles'][] = array( 'css' => $theme_json->get_stylesheet( 'block_styles' ) );
$editor_settings['styles'][] = array(
'css' => $theme_json->get_stylesheet( 'css_variables' ),
'__experimentalNoWrapper' => true,
);
}
$editor_settings['__experimentalFeatures'] = $theme_json->get_settings();
// These settings may need to be updated based on data coming from theme.json sources.
if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
$editor_settings['colors'] = $editor_settings['__experimentalFeatures']['color']['palette'];