Created
March 19, 2023 12:24
-
-
Save csaborio001/03e4a4c024055dccb381853eda02119c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]); | |
| } | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given they're likely to modify the
core/embedvariations -- adding and removing over time -- rather than enumerating all the variations, you can callwp.blocks.getBlockVariations('core/embed')which will return an array of variation objects. Then you can use thenameproperty to unregister each:If you want to allow particular variations then just wrap a conditional around the
unregisterBlockVariationcall using theembed_type.name.