Site icon Hip-Hop Website Design and Development

Disable just one Gutenberg block programatically / coblock/maps not listed in blocks

I’ve put in https://github.com/godaddy-wordpress/coblocks and wish to present solely OpenStreetMap primarily based blocks (which I put in moreover) and take away the coblocks/map block.

add_filter( 'allowed_block_types_all', 'myplugin_allowed_block_types', 0 );

operate 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 discovered to unset');
    }
    unset($block_types['coblocks/map']);
    return array_keys($block_types);
}

This dies with Block not discovered to unset

Truly the code works with out that verify, however I’m questioning if there are different blocks which aren’t within the registry however nonetheless work and could be disabled with my code.

So primarily I’m asking why get_all_registered doesn’t have some blocks that are nonetheless there and the way I can take away solely particular blocks if I cannot reliably fetch a listing of all blocks.