Remove Formatting Buttons From the Block Toolbar
Removes rarely needed formatting options, such as text color highlight, inline image, keyboard input and language, from the rich text toolbar.
Opens WPIDE on
Code
// Formats to remove from the toolbar.
$wpide_removed_formats = array( 'core/text-color', 'core/image', 'core/keyboard', 'core/language' );
add_action( 'enqueue_block_editor_assets', function () use ( $wpide_removed_formats ) {
wp_add_inline_script(
'wp-rich-text',
'wp.domReady(function(){(window._wpLoadBlockEditor||Promise.resolve()).then(function(){' . wp_json_encode( array_values( $wpide_removed_formats ) ) . '.forEach(function(name){if(wp.data.select("core/rich-text").getFormatType(name)){wp.richText.unregisterFormatType(name);}});});});'
);
} );
Notes
Format names include core/text-color, core/image, core/keyboard, core/language, core/subscript, core/superscript, core/code and core/strikethrough.
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.