Skip to content

Instantly share code, notes, and snippets.

@csaborio001
Created March 19, 2023 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csaborio001/03e4a4c024055dccb381853eda02119c to your computer and use it in GitHub Desktop.
Save csaborio001/03e4a4c024055dccb381853eda02119c to your computer and use it in GitHub Desktop.
wp.domReady( function() {
//wp.blocks.getBlockTypes().forEach( function( blockType ){ console.log( blockType.name ); });
var core_variations = [
'core/archives',
'core/audio',
'core/avatar',
'core/block',
'core/block',
'core/button',
'core/buttons',
'core/calendar',
'core/categories',
'core/code',
'core/column',
'core/columns',
'core/comments',
'core/cover',
'core/file',
'core/freeform',
'core/gallery',
'core/group',
'core/heading',
'core/html',
'core/image',
'core/latest-comments',
'core/latest-posts',
'core/list',
'core/loginout',
'core/media-text',
'core/missing',
'core/more',
'core/navigation',
'core/navigation',
'core/nextpage',
'core/nextpage',
'core/page-list',
'core/page-list',
'core/paragraph',
'core/post-author',
'core/post-author-biography',
'core/post-comments-form',
'core/post-content',
'core/post-date',
'core/post-excerpt',
'core/post-featured-image',
'core/post-title',
'core/preformatted',
'core/pullquote',
'core/query',
'core/query-no-results',
'core/query-pagination',
'core/query-pagination-next',
'core/query-pagination-numbers',
'core/query-pagination-previous',
'core/query-title',
'core/quote',
'core/read-more',
'core/rss',
'core/search',
'core/separator',
'core/shortcode',
'core/site-logo',
'core/site-tagline',
'core/site-title',
'core/social-link',
'core/social-links',
'core/spacer',
'core/table',
'core/tag-cloud',
'core/term-description',
'core/text-columns',
'core/verse',
'core/video',
'happyfiles/gallery',
];
var embed_variations = [
'amazon-kindle',
'animoto',
'cloudup',
'collegehumor',
'crowdsignal',
'dailymotion',
'facebook',
'flickr',
'imgur',
'instagram',
'issuu',
'kickstarter',
'meetup-com',
'mixcloud',
'pocketcasts',
'reddit',
'reverbnation',
'screencast',
'scribd',
'slideshare',
'smugmug',
'soundcloud',
'speaker-deck',
'spotify',
'ted',
'tiktok',
'tumblr',
'twitter',
'videopress',
'vimeo',
'wordpress',
'wordpress-tv',
'youtube',
];
for (var i = core_variations.length - 1; i >= 0; i--) {
wp.blocks.unregisterBlockType(core_variations[i]);
}
for (var i = embed_variations.length - 1; i >= 0; i--) {
wp.blocks.unregisterBlockVariation('core/embed', embed_variations[i]);
}
} );
@permanyer
Copy link

I just discovered that 'core/list' needs 'core/list-item' to work properly, although 'core/list-item' is not printed in the list

@RickMeasham
Copy link

Given they're likely to modify the core/embed variations -- adding and removing over time -- rather than enumerating all the variations, you can call wp.blocks.getBlockVariations('core/embed') which will return an array of variation objects. Then you can use the name property to unregister each:

  wp.blocks.getBlockVariations('core/embed').forEach(function (embed_type) {
      wp.blocks.unregisterBlockVariation('core/embed', embed_type.name);
  });

If you want to allow particular variations then just wrap a conditional around the unregisterBlockVariation call using the embed_type.name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment