I have installed https://github.com/godaddy-wordpress/coblocks and want to provide only OpenStreetMap based blocks (which I installed additionally) and remove the coblocks/map
block.
add_filter( 'allowed_block_types_all', 'myplugin_allowed_block_types', 0 );
function myplugin_allowed_block_types( $allowed_blocks )
{
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();
if (!isset($block_types['coblocks/map'])) {
wp_die('Block not found to unset');
}
unset($block_types['coblocks/map']);
return array_keys($block_types);
}
This dies with Block not found to unset
Actually the code works without that check, but I am wondering if there are other blocks which are not in the registry but still work and would be disabled with my code.
So essentially I am asking why get_all_registered
does not have some blocks which are still there and how I can remove only specific blocks if I can not reliably fetch a list of all blocks.
inserter
is set tofalse
in its supports sectionwp_die
, this might kill other block based areas or post types e.g. the widget block areas