Last active
May 19, 2022 03:47
-
-
Save nathan-roberts/39879fda12ae41156f544569cb51e024 to your computer and use it in GitHub Desktop.
Disable 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
add_filter('allowed_block_types', 'ca_allowed_block_types'); | |
function ca_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; | |
} | |
// leave this block in as taking it out removes some editor formatting | |
if ($block_name == 'core/paragraph') { | |
$allowed_blocks[] = $block_name; | |
} | |
} | |
// var_dump($allowed_blocks); | |
// die(); | |
return $allowed_blocks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment