As a theme developer I often want the embed blocks restricted to youtube and vimeo, just as Sven. So, following Sven's answer:
In my php code:
function my_theme_deny_list_blocks() {
wp_enqueue_script(
'deny-list-blocks',
get_template_directory_uri() . '/assets/js/deny-list-blocks.js',
array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' )
);
}
add_action( 'enqueue_block_editor_assets', 'my_theme_deny_list_blocks' );
In my new javascript file deny-list-blocks.js:
wp.domReady( function() {
var embed_variations = [
'amazon-kindle',
'animoto',
'cloudup',
'collegehumor',
'crowdsignal',
'dailymotion',
'facebook',
'flickr',
'imgur',
'instagram',
'issuu',
'kickstarter',
'meetup-com',
'mixcloud',
'reddit',
'reverbnation',
'screencast',
'scribd',
'slideshare',
'smugmug',
'soundcloud',
'speaker-deck',
'spotify',
'ted',
'tiktok',
'tumblr',
'twitter',
'videopress',
//'vimeo'
'wordpress',
'wordpress-tv',
//'youtube'
];
for (var i = embed_variations.length - 1; i >= 0; i--) {
wp.blocks.unregisterBlockVariation('core/embed', embed_variations[i]);
}
} );
Notice that vimeo and youtube are commented. Nevertheless, it should be a better way to do this, for instance disabling all variations in one line, then enabling only the desired ones.
Also worth noticing that all themes using the allowed_block_types filter to disable embeds will have to be modified when updating wordpress to 5.6.