From 98212da6c9a04df1a2d9eb94d9f4034f29d3848a Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Fri, 14 Feb 2025 11:52:39 +0100 Subject: [PATCH] Limit access to the global styles options --- .../sidebar-global-styles-wrapper/index.js | 11 +++++++++++ .../index.js | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js b/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js index de12bbe466bf3..1fd79179648b3 100644 --- a/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js +++ b/packages/edit-site/src/components/sidebar-global-styles-wrapper/index.js @@ -8,6 +8,8 @@ import { useViewportMatch } from '@wordpress/compose'; import { Button } from '@wordpress/components'; import { addQueryArgs, removeQueryArgs } from '@wordpress/url'; import { seen } from '@wordpress/icons'; +import { useSelect } from '@wordpress/data'; +import { store as coreStore } from '@wordpress/core-data'; /** * Internal dependencies @@ -73,6 +75,15 @@ export default function GlobalStylesUIWrapper() { const isMobileViewport = useViewportMatch( 'medium', '<' ); const [ section, onChangeSection ] = useSection(); + const isBlockBasedTheme = useSelect( + ( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme, + [] + ); + + if ( ! isBlockBasedTheme ) { + return null; + } + return ( <> select( coreStore ).getCurrentTheme()?.is_block_theme, + [] + ); + const openGlobalStyles = useCallback( async () => { history.navigate( addQueryArgs( path, { canvas: 'edit' } ), { transition: 'canvas-mode-edit-transition', @@ -68,6 +74,16 @@ export default function SidebarNavigationScreenGlobalStyles() { const shouldShowGlobalStylesFooter = !! revisionsCount && ! isLoadingRevisions; + if ( ! isBlockBasedTheme ) { + return ( +

+ { __( + 'The theme you are currently using is not compatible with the Site Editor.' + ) } +

+ ); + } + return ( <>