Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles: pass only the data the site editor uses #35458

Merged
merged 2 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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