Thursday, September 22, 2022
The Great Tit
Updated: 22. 9. 2022, Added: 22. 9. 2022

Disable Gutenberg Blocks and Pattern library

When I use Oxygen Builder to create website for customer, I want them to edit the content in Gutenberg editor, but I don't want to give them a "FULL POWER" of Gutenberg editor. What I do every time? Disable bunch of unused blocks and completely disable the patterns library. I also disable block styles and create my Own.

I use the code in Advanced Scripts plugin. It needs to run on INIT.

add_filter( 'allowed_block_types_all', 'great_tit_enable_blocks', 25, 2 );
 
function great_tit_enable_blocks( $allowed_blocks, $editor_context ) {
 
return array(
    'core/paragraph',
    'core/image',
    'core/heading',
    'core/gallery',
    'core/list',
    'core/quote',
    'core/shortcode',
    'core/audio',
    'core/button',
    'core/buttons',
    'core/code',
    'core/columns',
    'core/column',
    'core/code',
    'core/columns',
    'core/column',
    'core/freeform',
    'core/html',
    'core/table',
    'core/video'
	);
}


/*Disable patterns*/
function disable_remote_patterns_filter() {
	return false;
}
add_filter( 'should_load_remote_block_patterns', 'disable_remote_patterns_filter' );
remove_theme_support( 'core-block-patterns' );

Blocks list

For the more blocks visit official resource Blocks – WordPress.org Forums.

Gutenberg Blocks and patterns before applying the code:

Blocks and Patterns after activating the code:

Patterns not available at all and blocks display only the ones specified within the code.
Did I help you? Support me on Patreon!
Beep this article to your friends!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram