Disabling some buttons from wp_editor

2019-09-16 05:57发布

问题:

I use tinyMce editor in meta boxes of Wordpress by the following line of code, I want to remove some buttons when I use there. I don't want to affect the main editor. I know how to remove some buttons, which is told here.

My question is, is it possible to disable some buttons (e.g. more) when I call editor with wp_editor. I checked its manual, arguments doesn't seem to support this.

wp_editor( $careers_settings["description"], "editor", array("media_buttons"=>FALSE,  "textarea_name"=>"description", "textarea_rows"=>5) );

Thank you.

回答1:

You should check the referenced manual again - it's possible to have tinymce as parameter and pass an array of configuration options, e.g. like

wp_editor($value, "input...", array(
    'tinymce' => array( .. //tinymce configuration options here )
     ))

Haven't tried it out, but it should work like that.



回答2:

I guess it's a bit late to answer but in case it might be useful for someone. Since Tinymce 4, "toolbar1" must be used and "teeny" must be set as false to modify buttons :

wp_editor(
'id',
'value',
array(
  'teeny'=>false,
  'media_buttons'=>false,
  'tinymce' => array(
    'toolbar1' => 'bold, italic, underline,|,fontsizeselect',
    'toolbar2'=>false
  ),
)
);

Also I added "toolbar2" to the array. I realized that although I only set toolbar1, additional buttons still appear in some cases. Setting toolbar2 as false will remove default buttons on the second buttons row.