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

Editor: Optimize global styles permission check #65177

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
18 changes: 11 additions & 7 deletions packages/editor/src/components/global-styles-provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ function useGlobalStylesUserConfig() {

function useGlobalStylesBaseConfig() {
const baseConfig = useSelect( ( select ) => {
const { __experimentalGetCurrentThemeBaseGlobalStyles, canUser } =
select( coreStore );

return (
canUser( 'read', { kind: 'root', name: 'theme' } ) &&
__experimentalGetCurrentThemeBaseGlobalStyles()
);
const {
__experimentalGetCurrentThemeBaseGlobalStyles,
getCurrentTheme,
canUser,
} = select( coreStore );
const currentTheme = getCurrentTheme();

return currentTheme &&
canUser( 'read', 'global-styles/themes', currentTheme.stylesheet )
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would match the request made by __experimentalGetCurrentThemeBaseGlobalStyles.

path: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }`,

? __experimentalGetCurrentThemeBaseGlobalStyles()
: undefined;
}, [] );

return [ !! baseConfig, baseConfig ];
Expand Down
Loading