Remove Built-In Block Style Options
Removes block style choices you do not want editors to use, such as the outline button, rounded image or dotted separator, keeping the design consistent.
Opens WPIDE on
Code
// Block name => style names to remove.
$wpide_removed_block_styles = array(
'core/button' => array( 'outline' ),
'core/image' => array( 'rounded' ),
'core/separator' => array( 'dots', 'wide' ),
'core/quote' => array( 'plain' ),
);
add_action( 'enqueue_block_editor_assets', function () use ( $wpide_removed_block_styles ) {
wp_add_inline_script(
'wp-blocks',
'wp.domReady(function(){(window._wpLoadBlockEditor||Promise.resolve()).then(function(){var map=' . wp_json_encode( $wpide_removed_block_styles ) . ';Object.keys(map).forEach(function(block){map[block].forEach(function(style){wp.blocks.unregisterBlockStyle(block,style);});});});});'
);
} );
Notes
Edit the list of block names and style names. Content that already uses a removed style keeps its look.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.