Skip to content

Commit

Permalink
Fully disable reusable blocks in Widgets Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Jun 18, 2021
1 parent 7fa877e commit 9daa3a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';
import { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';
import useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';
import { store as editWidgetsStore } from '../../store';
import { ALLOW_REUSABLE_BLOCKS } from '../../constants';

export default function WidgetAreasBlockEditorProvider( {
blockEditorSettings,
Expand All @@ -43,10 +44,9 @@ export default function WidgetAreasBlockEditorProvider( {
),
widgetAreas: select( editWidgetsStore ).getWidgetAreas(),
widgets: select( editWidgetsStore ).getWidgets(),
reusableBlocks: select( coreStore ).getEntityRecords(
'postType',
'wp_block'
),
reusableBlocks: ALLOW_REUSABLE_BLOCKS
? select( coreStore ).getEntityRecords( 'postType', 'wp_block' )
: [],
isFixedToolbarActive: select(
editWidgetsStore
).__unstableIsFeatureActive( 'fixedToolbar' ),
Expand Down
1 change: 1 addition & 0 deletions packages/edit-widgets/src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ALLOW_REUSABLE_BLOCKS = false;
7 changes: 6 additions & 1 deletion packages/edit-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ import './store';
import './filters';
import * as widgetArea from './blocks/widget-area';
import Layout from './components/layout';
import { ALLOW_REUSABLE_BLOCKS } from './constants';

const DISABLED_BLOCKS = [ 'core/more', 'core/block' ];
const DISABLED_BLOCKS = [
'core/more',
...( ! ALLOW_REUSABLE_BLOCKS && [ 'core/block' ] ),
];
const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;

/**
Expand Down Expand Up @@ -55,6 +59,7 @@ export function initialize( id, settings ) {
registerBlock( widgetArea );
settings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>
fetchLinkSuggestions( search, searchOptions, settings );

render(
<Layout blockEditorSettings={ settings } />,
document.getElementById( id )
Expand Down

0 comments on commit 9daa3a1

Please sign in to comment.