Remove Specific Buttons from WP Editor TinyMCE

php, tinymce, wordpress, wysiwyg

Solution

The `tinymce` parameter allows you to pass configuration options directly to TinyMCE - see the docs for theme_advanced_buttons and theme_advanced_disable, and the button reference.

To show only the bold, italic and underline buttons:

wp_editor($value, "input...", array(
    'tinymce' => array(
        'theme_advanced_buttons1' => 'bold,italic,underline',
        'theme_advanced_buttons2' => '',
        'theme_advanced_buttons3' => ''
    )
));

Or, to show everything except the bold, italic and underline buttons:

wp_editor($value, "input...", array(
    'tinymce' => array(
        'theme_advanced_disable' => 'bold,italic,underline'
    )
));

As requested, your code modified:

add_action( 'gform_field_input', 'gforms_wp_editor', 10, 5 );

function gforms_wp_editor( $input, $field, $value, $lead_id, $form_id ) {
    if( $field["cssClass"] == 'richtext' ) {
        ob_start();
        wp_editor( $value, "input_{$form_id}_{$field['id']}",
            array(
                'media_buttons' => false,
                'quicktags'     => false,
                'textarea_name' => "input_{$field['id']}",
                'tinymce'       => array(
                    'theme_advanced_disable' => 'bold,italic,underline'
                )
            )
        );
        $input = ob_get_clean();
    }
    return $input;
}

Problem

I am trying to figure out how to remove specific buttons from the TinyMCE editor. I have researched the arguments in the codex but for TinyMCE is just says array and not sure if I can include some paramters in my arguments of which buttons to show/hide? I am using the editor in a gravity form and my code is as follows so far ``` add_action( 'gform_field_input', 'gforms_wp_editor', 10, 5 ); function gforms_wp_editor( $input, $field, $value, $lead_id, $form_id ) { if( $field["cssClass"] == 'richtext' ) { ob_start(); wp_editor( $value, "input_{$form_id}_{$field['id']}", array( 'media_buttons' => false, 'quicktags' => false, 'textarea_name' => "input_{$field['id']}" ) ); $input = ob_get_clean(); } return $input; } ``` I have removed the HTML tab using the `quicktags` to false, so hoping I can do something similar to strip out buttons from the editor. buttons shown right now with the code above are as follows Note: 'teeny' editor is now what I need, just in case someone suggests Thanks

Original source