Is there a way to remove the default core/buttons block in Gutenberg, or other various blocks? We're creating our own buttons block and don't want the user to get it confused with the default one and would rather just remove it altogether.
I've tried the following but it tells me that $allowed_block_types is a bool and not an array.
function hide_default_button_block($allowed_block_types, $post) {
// Remove the default Gutenberg button block
if ($post->post_type === 'post' || $post->post_type === 'page') {
$allowed_block_types = array_diff($allowed_block_types, ['core/button']);
}
return $allowed_block_types;
}
add_filter('allowed_block_types', 'hide_default_button_block', 10, 2);
I'm trying to do this in just a theme currently, but will need to implement this in a plugin eventually that will replace core blocks with our revised ones.