Disable Gutenberg blocks in WordPress

In order to provide a better user experience in WordPress Gutenberg editor, you can disable unnecessary or unused block types. Using the allowed_block_types filter you can return an array of allowed blocks. You may also specify allowed blocks by the current post using the $post variable provided in the callback function.

add_filter('allowed_block_types', function ($allow_block_type, $post) {
    return [
        'core-embed/vimeo',
        'core-embed/youtube',
        'core/block',
        'core/embed',
        'core/heading',
        'core/image',
        'core/list',
        'core/paragraph',
        'core/subhead',
        'core/template',
        'acf/instagram',
    ];
}, 10, 2);

If you want to list all registered block types, visit the WordPress dashboard, open up the developer tools in your browser and run the JavaScript snippet below.

wp.blocks.getBlockTypes();

This will list all available blocks in your WordPress application. If you find a better way to list all block types, please let me know on Twitter!