From 990eba65ba8ba54ee46b159c0b13e0b7da99794c Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Thu, 11 Jul 2024 15:16:59 +0100 Subject: [PATCH] add comments --- .../src/components/global-styles-provider/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/editor/src/components/global-styles-provider/index.js b/packages/editor/src/components/global-styles-provider/index.js index 7b89b413d4aa2f..4b80c9082d3b87 100644 --- a/packages/editor/src/components/global-styles-provider/index.js +++ b/packages/editor/src/components/global-styles-provider/index.js @@ -41,9 +41,14 @@ function useGlobalStylesUserConfig() { } = select( coreStore ); const _globalStylesId = select( coreStore ).__experimentalGetCurrentGlobalStylesId(); + + // Doing canUser( 'read', 'global_styles' ) returns false even for users with the capability. + // See: https://github.com/WordPress/gutenberg/issues/63438 + // So we need to check the user capabilities directly. const userId = getCurrentUser()?.id; const canEditThemeOptions = userId && getUser( userId )?.capabilities?.edit_theme_options; + const record = _globalStylesId && canEditThemeOptions ? getEditedEntityRecord( @@ -139,6 +144,11 @@ function useGlobalStylesBaseConfig() { getUser, __experimentalGetCurrentThemeBaseGlobalStyles, } = select( coreStore ); + + + // Doing canUser( 'read', 'global_styles' ) returns false even for users with the capability. + // See: https://github.com/WordPress/gutenberg/issues/63438 + // So we need to check the user capabilities directly. const userId = getCurrentUser()?.id; const canEditThemeOptions = userId && getUser( userId )?.capabilities?.edit_theme_options;