Skip to content

Commit

Permalink
Global Styles: Don't show Apply Styles Globally button in non-block b…
Browse files Browse the repository at this point in the history
…ased themes (#56033)
  • Loading branch information
t-hamano authored and cbravobernal committed Nov 14, 2023
1 parent 75c8984 commit 39b0db2
Showing 1 changed file with 13 additions and 6 deletions.
Expand Up @@ -17,8 +17,9 @@ import {
hasBlockSupport,
} from '@wordpress/blocks';
import { useContext, useMemo, useCallback } from '@wordpress/element';
import { useDispatch } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import { store as noticesStore } from '@wordpress/notices';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand Down Expand Up @@ -391,18 +392,24 @@ function PushChangesToGlobalStylesControl( {
const withPushChangesToGlobalStyles = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
const blockEditingMode = useBlockEditingMode();
const isBlockBasedTheme = useSelect(
( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,
[]
);
const supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>
hasBlockSupport( props.name, feature )
);

return (
<>
<BlockEdit { ...props } />
{ blockEditingMode === 'default' && supportsStyles && (
<InspectorAdvancedControls>
<PushChangesToGlobalStylesControl { ...props } />
</InspectorAdvancedControls>
) }
{ blockEditingMode === 'default' &&
supportsStyles &&
isBlockBasedTheme && (
<InspectorAdvancedControls>
<PushChangesToGlobalStylesControl { ...props } />
</InspectorAdvancedControls>
) }
</>
);
}
Expand Down

0 comments on commit 39b0db2

Please sign in to comment.