Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.