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.

5
  • I figured out my first problem with setting the default. It should have been add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
    – Adam
    Commented Dec 7, 2014 at 3:31
  • Please post that as an answer and accept it as well :-) Commented Dec 7, 2014 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
    Commented Dec 7, 2014 at 3:39
  • AH OK. Then you should add your comment as an edit to your question :-) Commented Dec 7, 2014 at 4:05
  • please let me know where are the relevant files in wordpress files. i cant locate the right .js , .css and plugin file u mention
    – Ran Ran
    Commented Aug 18, 2021 at 11:03

2 Answers 2

10

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');
2
  • Thanks. This code seem to work for me. Is it possible the make it work for all users roles except Administrator?
    – Samuel
    Commented Nov 12, 2017 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 Commented Jan 22, 2018 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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.