Limit the Embed Providers in the Inserter
Hides the long list of embed blocks (TikTok, Reddit, Kickstarter and dozens more) from the inserter, keeping only the providers you actually use.
Opens WPIDE on
Code
// Embed providers to keep in the inserter.
$wpide_kept_embeds = array( 'youtube', 'vimeo', 'twitter', 'spotify' );
add_action( 'enqueue_block_editor_assets', function () use ( $wpide_kept_embeds ) {
wp_add_inline_script(
'wp-blocks',
'wp.domReady(function(){(window._wpLoadBlockEditor||Promise.resolve()).then(function(){var keep=' . wp_json_encode( array_values( $wpide_kept_embeds ) ) . ';(wp.blocks.getBlockVariations("core/embed")||[]).forEach(function(variation){if(keep.indexOf(variation.name)===-1){wp.blocks.unregisterBlockVariation("core/embed",variation.name);}});});});'
);
} );
Notes
Pasting a URL from a hidden provider still embeds it. Provider names are lowercase, such as youtube, vimeo, twitter, spotify or soundcloud.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.