WP_Editor – Remove TinyMCE Toolbars

I’ve created a TinyMCE Editor in a Metabox and I’m trying to remove the toolbars. According to The Codex I should be able to pass it an array of options to override the default TinyMCE. Here’s what I have:

wp_editor( $content, 'my_editor_id', array(
    'textarea_name'     => '_meta_editor',
    'tinymce'           => array(
        'toolbar1'      => '',
        'toolbar2'      => ''
    ),
    'drag_drop_upload'  => true
) );

I’ve also tried replacing the empty string to false but they still show the default parameters. The purpose is I only want to use the editor for Post Galleries and do not want to give the user access to any of the other TinyMCE Options.

If I just give the TinyMCE the following option: 'tinymce' => array() it still puts options in the toolbar and it removes my gallery preview ( which I do not want ).

List of things I’ve tried:

  • 'tinymce' => array() – removes everything, gallery preview – need gallery preview
  • 'tinymce' => array( 'toolbar1' => '' ) – nothing happens
  • 'tinymce' => array( 'toolbar1' => array() ) – nothing happens
  • 'tinymce' => array( 'toolbar1' => array( ',' ) ) – nothing happens
  • 'tinymce' => array( 'toolbar1' => ',' ) – nothing happens
  • 'tinymce' => array( 'toolbar1' => false ) – nothing happens

Did TinyMCE change it’s index names or am I doing something wrong?

1 Answer
1

If I remember correctly, this should remove the toolbars on the tinyMCE:

function my_format_TinyMCE( $in ) {
    $in['toolbar1'] = '';
    $in['toolbar2'] = '';
    $in['toolbar'] = false;
    return $in;
}
add_filter( 'tiny_mce_before_init', 'my_format_TinyMCE' );

References:
https://codex.wordpress.org/TinyMCE
http://www.tinymce.com/wiki.php/Configuration

For the wp_editor, try applying these filter parameters onto your wp_editor() function.

Hope it helps.

** Edit

Also if that ['toolbar'] = false; still prevents you from uploading galleries, you could just try this instead:

$in['toolbar1'] = 'undo,redo'; 
$in['toolbar2'] = ''; 

(Just add a couple of buttons like undo and redo to the top toolbar and remove the second). I’ve just tested this and it works with adding galleries.

Leave a Comment