Created
December 5, 2021 13:37
-
-
Save rocket-martue/35a2fb7aa819450d4d828bb6bb50a70d to your computer and use it in GitHub Desktop.
JavaScriptで必要なブロックのみ表示する (ホワイトリスト形式)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wp.domReady( () => { | |
const registerBlocks = [ | |
'core/paragraph', | |
'core/heading', | |
'core/list', | |
'core/embed', | |
]; | |
wp.blocks.getBlockTypes().forEach( block => { | |
if ( ! registerBlocks.includes( block.name ) ) { | |
wp.blocks.unregisterBlockType( block.name ); | |
} | |
} ); | |
const registerEmbedBlocks = [ | |
'twitter', | |
'youtube', | |
'wordpress', | |
]; | |
wp.blocks.getBlockVariations( 'core/embed' ).forEach( block => { | |
if ( ! registerEmbedBlocks.includes( block.name ) ) { | |
wp.blocks.unregisterBlockVariation( 'core/embed', block.name ); | |
} | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
埋め込みブロックは、
registerEmbedBlocks
の方に指定する。