3

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?

  • Did you try the comma string 'toolbar1' => array( ',' ) ? It might be related to the answer + discussion in comments here. – birgire Jun 26 '15 at 18:03
  • @birgire I've tried that and ',' – Howdy_McGee Jun 26 '15 at 18:08
  • 1
    ps: yes I meant to write 'toolbar1' => ',' ;-) – birgire Jun 26 '15 at 18:13
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.

  • While, what you're referring to is the Default tinyMCE, I'm using the wp_editor() function to generate a separate tinyMCE ( so your filter wouldn't apply ). I did apply your filter parameters onto my function and it worked :D ! Thanks for your suggestion, if you could edit your answer and apply it onto the wp_editor() instead I'll accept your answer! – Howdy_McGee Jun 30 '15 at 13:54
  • 1
    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. – user3438958 Jun 30 '15 at 21:00

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.