Skip to content

Commit

Permalink
Check for content blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Jun 7, 2024
1 parent 4886740 commit c50b7ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { __ } from '@wordpress/i18n';
*/
import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';
import { CONTENT_ONLY_BLOCKS } from '../provider/disable-non-page-content-blocks';

function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
const { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(
Expand All @@ -26,6 +27,7 @@ function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
getBlockParentsByBlockName,
getSettings,
getBlockAttributes,
getBlockName,
} = select( blockEditorStore );
const contentOnly =
getBlockEditingMode( clientId ) === 'contentOnly';
Expand All @@ -48,7 +50,10 @@ function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
} else {
const { getCurrentTemplateId } = select( editorStore );
const templateId = getCurrentTemplateId();
if ( templateId ) {
if (
CONTENT_ONLY_BLOCKS.includes( getBlockName( clientId ) ) &&
templateId
) {
record = select( coreStore ).getEntityRecord(
'postType',
'wp_template',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
import { useEffect } from '@wordpress/element';
import { applyFilters } from '@wordpress/hooks';

const CONTENT_ONLY_BLOCKS = applyFilters( 'editor.postContentBlockTypes', [
'core/post-title',
'core/post-featured-image',
'core/post-content',
'core/template-part',
] );
export const CONTENT_ONLY_BLOCKS = applyFilters(
'editor.postContentBlockTypes',
[
'core/post-title',
'core/post-featured-image',
'core/post-content',
'core/template-part',
]
);

/**
* Component that when rendered, makes it so that the site editor allows only
Expand Down

0 comments on commit c50b7ba

Please sign in to comment.