Last active
May 19, 2022 03:40
-
-
Save nathan-roberts/145cf4f47f5faffb6bab6044875e3c70 to your computer and use it in GitHub Desktop.
Remove Core Gutenberg Blocks
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 | |
// Disable core WordPress Gutenberg Blocks | |
add_filter('allowed_block_types', 'misha_allowed_block_types'); | |
function misha_allowed_block_types($allowed_blocks) | |
{ | |
$allowed_blocks = []; | |
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered(); | |
$blocks = array_keys($block_types); | |
foreach ($blocks as $block => $block_name) { | |
if (strpos($block_name, 'core') !== 0) { | |
$allowed_blocks[] = $block_name; | |
} | |
} | |
return $allowed_blocks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment