Skip to content

Commit

Permalink
Hide "Create template part" menu from block settings dropdown for cla…
Browse files Browse the repository at this point in the history
…ssic themes
  • Loading branch information
t-hamano committed Sep 23, 2024
1 parent 7f87eef commit e3b2eab
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
import { symbolFilled } from '@wordpress/icons';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -20,16 +21,18 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
const { replaceBlocks } = useDispatch( blockEditorStore );
const { createSuccessNotice } = useDispatch( noticesStore );

const { canCreate } = useSelect( ( select ) => {
const { isBlockBasedTheme, canCreate } = useSelect( ( select ) => {
return {
isBlockBasedTheme:
select( coreStore ).getCurrentTheme()?.is_block_theme,
canCreate:
select( blockEditorStore ).canInsertBlockType(
'core/template-part'
),
};
}, [] );

if ( ! canCreate ) {
if ( ! isBlockBasedTheme || ! canCreate ) {
return null;
}

Expand Down

0 comments on commit e3b2eab

Please sign in to comment.