Created
October 21, 2022 11:56
-
-
Save jstask82/6529655be0410bcb3b433d6333722faf to your computer and use it in GitHub Desktop.
This file contains 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
function ak_disable_blocks($allowed_blocks, $post) | |
{ | |
//get all blocks | |
$registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered(); | |
//list all blocks | |
//var_dump(array_keys($registered_blocks)); | |
//exit(); | |
//disable unwanted blocks | |
unset($registered_blocks['core/archives']); | |
unset($registered_blocks['core/block']); | |
unset($registered_blocks['core/calendar']); | |
unset($registered_blocks['core/categories']); | |
unset($registered_blocks['core/file']); | |
unset($registered_blocks['core/latest-comments']); | |
unset($registered_blocks['core/latest-posts']); | |
unset($registered_blocks['core/legacy-widget']); | |
unset($registered_blocks['core/loginout']); | |
unset($registered_blocks['core/page-list']); | |
unset($registered_blocks['core/post-content']); | |
unset($registered_blocks['core/post-date']); | |
unset($registered_blocks['core/post-excerpt']); | |
unset($registered_blocks['core/post-featured-image']); | |
unset($registered_blocks['core/post-terms']); | |
unset($registered_blocks['core/post-title']); | |
unset($registered_blocks['core/post-template']); | |
unset($registered_blocks['core/query']); | |
unset($registered_blocks['core/query-pagination']); | |
unset($registered_blocks['core/query-pagination-next']); | |
unset($registered_blocks['core/query-pagination-numbers']); | |
unset($registered_blocks['core/query-pagination-previous']); | |
unset($registered_blocks['core/query-title']); | |
unset($registered_blocks['core/rss']); | |
unset($registered_blocks['core/search']); | |
//unset($registered_blocks['core/shortcode']); | |
unset($registered_blocks['core/site-tagline']); | |
unset($registered_blocks['core/site-logo']); | |
unset($registered_blocks['core/site-title']); | |
unset($registered_blocks['core/social-link']); | |
unset($registered_blocks['core/tag-cloud']); | |
unset($registered_blocks['core/audio']); | |
unset($registered_blocks['core/button']); | |
unset($registered_blocks['core/buttons']); | |
unset($registered_blocks['core/code']); | |
unset($registered_blocks['core/column']); | |
unset($registered_blocks['core/columns']); | |
unset($registered_blocks['core/cover']); | |
unset($registered_blocks['core/embed']); | |
unset($registered_blocks['core/freeform']); | |
unset($registered_blocks['core/gallery']); | |
unset($registered_blocks['core/group']); | |
//unset($registered_blocks['core/heading']); | |
//unset($registered_blocks['core/html']); | |
unset($registered_blocks['core/image']); | |
//unset($registered_blocks['core/list']); | |
unset($registered_blocks['core/media-text']); | |
unset($registered_blocks['core/missing']); | |
unset($registered_blocks['core/more']); | |
unset($registered_blocks['core/nextpage']); | |
//unset($registered_blocks['core/paragraph']); | |
//unset($registered_blocks['core/preformatted']); | |
unset($registered_blocks['core/pullquote']); | |
unset($registered_blocks['core/quote']); | |
//unset($registered_blocks['core/separator']); | |
unset($registered_blocks['core/social-links']); | |
//unset($registered_blocks['core/spacer']); | |
//unset($registered_blocks['core/table']); | |
unset($registered_blocks['core/text-columns']); | |
unset($registered_blocks['core/verse']); | |
unset($registered_blocks['core/video']); | |
//conditionaly disable unwanted blocks | |
// switch ($post->post_type) { | |
// case 'my_cpt': | |
// unset($registered_blocks['core/archives']); | |
// return array_keys($registered_blocks); | |
// break; | |
// default: | |
// return true; | |
// } | |
return array_keys($registered_blocks); | |
} | |
add_filter('allowed_block_types_all', 'ak_disable_blocks', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment