-
Notifications
You must be signed in to change notification settings - Fork 0
/
block-editor.js
39 lines (29 loc) · 865 Bytes
/
block-editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Hide Blocks
*/
wp.hooks.addFilter( 'blocks.registerBlockType', 'hideBlocks', ( blockSettings, blockName ) => {
if ( -1 < mrwEditorOptions.hiddenBlocks.indexOf( blockName ) ) {
return Object.assign({}, blockSettings, {
supports: Object.assign( {}, blockSettings.supports, {inserter: false} )
});
}
return blockSettings;
});
wp.domReady( function() {
/*
* Hide Embed Variations
*/
wp.blocks.getBlockVariations('core/embed').forEach(function (embed) {
if ( -1 !== mrwEditorOptions.hiddenEmbeds.indexOf(embed.name) ) {
wp.blocks.unregisterBlockVariation('core/embed', embed.name );
}
});
/*
* Hide Block Styles
*/
Object.keys( mrwEditorOptions.hiddenStyles ).forEach( function( block ) {
mrwEditorOptions.hiddenStyles[block].forEach( function( style ) {
wp.blocks.unregisterBlockStyle( block, style );
});
});
});