1

I am attempting to disable the Text tab in the post editor but not having any luck.

enter image description here

The first thing I want to do is set the Visual editor to be the default but this code does not work (it is being called from a MU plugin):

apply_filters( 'wp_default_editor', 'tinymce' );

Next, I want to be able to completely hide the 'Visual' and 'Text' tabs but I don't see and hooks I could use to accomplish this.I really don't want to resort to CSS/JS to do it.

  • I figured out my first problem with setting the default. It should have been add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') ); – Adam Dec 7 '14 at 3:31
  • Please post that as an answer and accept it as well :-) – Pieter Goosen Dec 7 '14 at 3:38
  • But there is still the second part of my question. I was curious if there is a better way than CSS/JS to get rid of the tabs. – Adam Dec 7 '14 at 3:39
  • AH OK. Then you should add your comment as an edit to your question :-) – Pieter Goosen Dec 7 '14 at 4:05
7

I was hunting for a way to do this, and no-one seems to mention the wp_editor_settings filter. This worked for me:

function my_editor_settings($settings) {
$settings['quicktags'] = false;
return $settings;
}

add_filter('wp_editor_settings', 'my_editor_settings');
  • Thanks. This code seem to work for me. Is it possible the make it work for all users roles except Administrator? – sampaii Nov 12 '17 at 0:33
  • This isn't tested, but I suspect if you modified the above code as follows: if ( !current_user_can( 'manage_options' ) ) { $settings['quicktags'] = false; } return $settings; It might work – Stef Williams Jan 22 '18 at 13:56
6

I was able to resolve both defaulting to the Visual editor and hiding the tabs with the following code.

Dumped the following in plugin file:

add_filter( 'wp_default_editor', array($this, 'default_editor') );

Hide the tabs with this javascript:

$('.wp-editor-tabs').remove();

Or hide it with CSS:

.wp-editor-tabs{display:none;}

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.