I need to disable the Gutenberg text-settings tab in all Blocks. Is this possible with a funtion in funtions.php?

I could disable the colors tab, but found no solution for the text-settings:

function disable_tabs() {
    add_theme_support( 'editor-color-palette' );
    add_theme_support( 'disable-custom-colors' );
add_action( 'after_setup_theme', 'disable_tabs' );

The text-settings tab

  • 1
    Do you mean in all paragraph blocks ? – birgire Jan 24 '19 at 14:20

The closest I can find in the documentation is disabling custom font size (the text input) and forcing the dropdown font size to only contain "Normal".

add_action('after_setup_theme', 'wpse_remove_custom_colors');
function wpse_remove_custom_colors() {
    // removes the text box where users can enter custom pixel sizes
    // forces the dropdown for font sizes to only contain "normal"
    add_theme_support('editor-font-sizes', array(
            'name' => 'Normal',
            'size' => 16,
            'slug' => 'normal'
    ) );

Note this may not work for non-Core blocks - they may have their own way of registering font size etc. that isn't affected by theme_support. Hoping someone else from the community knows how to disable the drop caps as well.

Update: a way to remove Drop Caps

This wouldn't be my preferred method, because you can still add a Drop Cap in the editor and it just doesn't render in the front end, but it's all I have been able to achieve so far:

There is a render_block() hook where you can change what renders on the front end without changing what shows in the editor or gets saved to the database.

add_filter('render_block', function($block_content, $block) {
    // only affect the Core Paragraph block
    if('core/paragraph' === $block['blockName']) {
        // remove the class that creates the drop cap
        $block_content = str_replace('class="has-drop-cap"', '', $block_content);
    // always return the content, whether we changed it or not
    return $block_content;
}, 10, 2);

This method changes the outer appearance rather than the actual content, so that if you ever wanted to allow drop caps, you could just remove the filter and all the ones that people had added in the editor would suddenly appear.

|improve this answer|||||
  • 2
    There's now a proposal to add a block_editor_features hook to take care of font sizes, drop caps, and a whole bunch of other settings. It's not rolled into Core yet but it's on the way. github.com/WordPress/gutenberg/issues/20588 – WebElaine Mar 30 at 14:14
  • 2
    I can't wait... this is so frustrating. We don't need Drop Caps ! (not always) – Max Mar 30 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.