Last active
February 11, 2022 09:05
-
-
Save Christian-Roth/a5c3ffe98181bd8671fc10f1dd5fb1bb to your computer and use it in GitHub Desktop.
Remove all blocks from the theme category. Useful if you use the WP Block Editor but not a Full Site Editing Theme.
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 /* Remove all blocks from the theme category */ | |
function custom_allowed_block_types ( $allowed_block_types, $block_editor_context ) { | |
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered(); | |
if (!empty($block_types)) { | |
$allowed_block_types = array(); | |
foreach ($block_types as $key => $value) { | |
if ($value->category != 'theme') { | |
$allowed_block_types[] = $key; | |
} | |
} | |
} | |
return $allowed_block_types; | |
} | |
add_filter( 'allowed_block_types_all', 'custom_allowed_block_types', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment