Last active
December 5, 2021 14:44
-
-
Save rocket-martue/ecc512c8537e5ea3819350e966fcdc1d to your computer and use it in GitHub Desktop.
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
<?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