Wordpress - How to remove the core embed blocks in WordPress 5.6?
With WordPress 5.6 (Gutenberg v8.8.0), the implementation of the core-embed/*
blocks changed (see pull request #24090: Refactor embed block to single block with block variations). There are now 43 blocks with block variations of the core/embed
block.
Available core blocks are:
core/paragraph
core/image
core/heading
core/gallery
core/list
core/quote
core/shortcode
core/archives
core/audio
core/button
core/buttons
core/calendar
core/categories
core/code
core/columns
core/column
core/cover
core/embed
core/file
core/group
core/freeform
core/html
core/media-text
core/latest-comments
core/latest-posts
core/missing
core/more
core/nextpage
core/preformatted
core/pullquote
core/rss
core/search
core/separator
core/block
core/social-links
core/social-link
core/spacer
core/subhead
core/table
core/tag-cloud
core/text-columns
core/verse
core/video
Unregister embeds altogether (including variations):
wp.domReady(function () {
wp.blocks.unregisterBlockType('core/embed');
});
The blocks previously listed as core-embed/*
are now available as a variation of core/embed
:
console.table(wp.blocks.getBlockVariations('core/embed'));
Available block variations of core/embed
are:
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
You can unregister a single variation like this:
wp.domReady(function () {
wp.blocks.unregisterBlockVariation('core/embed', 'twitter');
});
Or unregister all variations and only allow individual variations:
wp.domReady(function () {
const allowedEmbedBlocks = [
'vimeo',
'youtube',
];
wp.blocks.getBlockVariations('core/embed').forEach(function (blockVariation) {
if (-1 === allowedEmbedBlocks.indexOf(blockVariation.name)) {
wp.blocks.unregisterBlockVariation('core/embed', blockVariation.name);
}
});
});