Skip to content

Instantly share code, notes, and snippets.

@rocket-martue
Last active December 5, 2021 14:44
Show Gist options
  • Save rocket-martue/ecc512c8537e5ea3819350e966fcdc1d to your computer and use it in GitHub Desktop.
Save rocket-martue/ecc512c8537e5ea3819350e966fcdc1d to your computer and use it in GitHub Desktop.
<?php
/**
* 不要なブロックを非表示にする (ブラックリスト形式)
* $unregister_blocks に非表示にするブロックを指定する。
*/
add_filter(
'allowed_block_types_all',
function( $allowed_block_types, $block_editor_context ) {
$default_blocks = [];
$blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
foreach ( $blocks as $block ) {
$default_blocks[] = $block->name;
}
$unregister_blocks = [
'core/freeform', // クラシック
'core/pullquote', // プルクオート
'core/verse', // 詩
];
$allowed_block_types = array_values( array_diff( $default_blocks, $unregister_blocks ) );
return $allowed_block_types;
},
10,
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment