Skip to content

Commit

Permalink
Global Styles: pass only the data the site editor uses (#35458)
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal authored Oct 14, 2021
1 parent 80112e4 commit b371822
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/class-wp-rest-block-editor-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public function get_item_schema() {
'context' => array( 'site-editor' ),
),

'__experimentalGlobalStylesBaseStyles' => array(
'description' => __( 'Global styles settings.', 'gutenberg' ),
'__experimentalGlobalStylesBaseConfig' => array(
'description' => __( 'Settings and styles consolidated from core and theme origins.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'site-editor' ),
),
Expand Down
5 changes: 3 additions & 2 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ function_exists( 'gutenberg_is_edit_site_page' ) &&
$theme = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data( $settings, 'theme' );
$user_cpt_id = WP_Theme_JSON_Resolver_Gutenberg::get_user_custom_post_type_id();

$settings['__experimentalGlobalStylesUserEntityId'] = $user_cpt_id;
$settings['__experimentalGlobalStylesBaseStyles'] = $theme->get_raw_data();
$settings['__experimentalGlobalStylesUserEntityId'] = $user_cpt_id;
$settings['__experimentalGlobalStylesBaseConfig']['styles'] = $theme->get_raw_data()['styles'];
$settings['__experimentalGlobalStylesBaseConfig']['settings'] = $theme->get_settings();
}

if ( 'other' === $context ) {
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function useGlobalStylesUserConfig() {
function useGlobalStylesBaseConfig() {
const baseConfig = useSelect( ( select ) => {
return select( editSiteStore ).getSettings()
.__experimentalGlobalStylesBaseStyles;
.__experimentalGlobalStylesBaseConfig;
}, [] );

return baseConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
'__experimentalBlockPatternCategories',
'__experimentalBlockPatterns',
'__experimentalFeatures',
'__experimentalGlobalStylesBaseStyles',
'__experimentalGlobalStylesBaseConfig',
'__experimentalGlobalStylesUserEntityId',
'__experimentalPreferredStyleVariations',
'__experimentalSetIsInserterOpened',
Expand Down

0 comments on commit b371822

Please sign in to comment.