Remove Unwanted Block Style Variations
Hides block styles you do not want editors to use, such as the outline button or rounded image, from the block editor.
Opens WPIDE on
Code
// Block name => style names to remove.
$wpide_remove_block_styles = array(
'core/button' => array( 'outline' ),
'core/image' => array( 'rounded' ),
'core/quote' => array( 'plain' ),
'core/separator' => array( 'dots', 'wide' ),
);
add_action( 'enqueue_block_editor_assets', function () use ( $wpide_remove_block_styles ) {
wp_register_script( 'wpide-remove-block-styles', false, array( 'wp-blocks', 'wp-dom-ready' ), '1.0', true );
wp_enqueue_script( 'wpide-remove-block-styles' );
wp_add_inline_script(
'wpide-remove-block-styles',
sprintf(
'wp.domReady(function(){var map=%s;Object.keys(map).forEach(function(block){map[block].forEach(function(style){wp.blocks.unregisterBlockStyle(block,style);});});});',
wp_json_encode( $wpide_remove_block_styles )
)
);
} );
Notes
Blocks already using a removed style keep it until edited.
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.