diff --git a/lib/class-wp-rest-global-styles-controller-gutenberg.php b/lib/class-wp-rest-global-styles-controller-gutenberg.php index 421408e6f20b4a..cfcec0c8f956fb 100644 --- a/lib/class-wp-rest-global-styles-controller-gutenberg.php +++ b/lib/class-wp-rest-global-styles-controller-gutenberg.php @@ -586,12 +586,11 @@ public function get_item_schema() { * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise. */ public function get_theme_item_permissions_check( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - /* - * Verify if the current user has edit_theme_options capability. - * This capability is required to edit/view/delete templates. + * Verify if the current user has edit_posts capability. + * This capability is required to view global styles. */ - if ( ! current_user_can( 'edit_theme_options' ) ) { + if ( ! current_user_can( 'edit_posts' ) ) { return new WP_Error( 'rest_cannot_manage_global_styles', __( 'Sorry, you are not allowed to access the global styles on this site.', 'gutenberg' ), diff --git a/lib/compat/wordpress-6.6/rest-api.php b/lib/compat/wordpress-6.6/rest-api.php index fee9c71b86c070..aaef8c77c4f578 100644 --- a/lib/compat/wordpress-6.6/rest-api.php +++ b/lib/compat/wordpress-6.6/rest-api.php @@ -170,6 +170,7 @@ function gutenberg_block_editor_preload_paths_6_6( $paths, $context ) { $paths[] = '/wp/v2/global-styles/themes/' . get_stylesheet(); $paths[] = '/wp/v2/themes?context=edit&status=active'; $paths[] = '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver_Gutenberg::get_user_global_styles_post_id() . '?context=edit'; + $paths[] = '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver_Gutenberg::get_user_global_styles_post_id(); } return $paths; } diff --git a/packages/core-data/src/entities.js b/packages/core-data/src/entities.js index 8d09402087cf90..c8af0dc94348d4 100644 --- a/packages/core-data/src/entities.js +++ b/packages/core-data/src/entities.js @@ -182,7 +182,7 @@ export const rootEntitiesConfig = [ name: 'globalStyles', kind: 'root', baseURL: '/wp/v2/global-styles', - baseURLParams: { context: 'edit' }, + baseURLParams: {}, plural: 'globalStylesVariations', // Should be different from name. getTitle: ( record ) => record?.title?.rendered || record?.title, getRevisionsUrl: ( parentId, revisionId ) => diff --git a/packages/editor/src/components/global-styles-provider/index.js b/packages/editor/src/components/global-styles-provider/index.js index 8426593d8f5f51..93dd4dbe1eda49 100644 --- a/packages/editor/src/components/global-styles-provider/index.js +++ b/packages/editor/src/components/global-styles-provider/index.js @@ -146,13 +146,10 @@ function useGlobalStylesUserConfig() { function useGlobalStylesBaseConfig() { const baseConfig = useSelect( ( select ) => { - const { __experimentalGetCurrentThemeBaseGlobalStyles, canUser } = + const { __experimentalGetCurrentThemeBaseGlobalStyles } = select( coreStore ); - return ( - canUser( 'read', { kind: 'root', name: 'theme' } ) && - __experimentalGetCurrentThemeBaseGlobalStyles() - ); + return __experimentalGetCurrentThemeBaseGlobalStyles(); }, [] ); return [ !! baseConfig, baseConfig ];