Disable HTML Editor In WordPress
January 19th, 2010 by Frank • WordPress Hacks • 6 Comments
In contrast to the visual editor in WordPress, you can not disable the HTML editor. WordPress does not provide a user setting or a global option. Also, there is no hook, to disable the HTML tab above the editor when writing posts or pages.

But there are users who do not need this tab and like to deactivate it globally. Therefore, I have a solution, how you can disable it in your editor.
Alternatively, you can use the Plugin Adminimize, which offers such a possibility per role, just put it in the settings.
Since there is no hook or an option, you have to hide the area via CSS. This has the disadvantage that, while the tab is no longer visible, but if the cookie or a Plugin says to enable HTML, the editor has a problem showing us either the two editor tabs simultaneously, or no buttons. You need to explicitly set the editor.
In our first step we hide via CSS the tab and the buttons of the HTML editor. This stylesheet must be loaded in the admin, while you can go several ways: either you write it in the header (Hook admin_head) or load an external css via function wp_enqueue_style().
#editor-toolbar #edButtonHTML, #quicktags {
display: none;
}
The better way is you hide the tab via JavaScript and load this on the Hook admin_footer.
jQuery(document).ready(function($) {
$("#edButtonHTML").remove();
});
In a further step you must set the default editor, therefore you can use a hook and function, which sets the default to the value tinymce.
function my_default_editor() {
$r = 'tinymce'; // html or tinymce
return $r;
}
add_filter( 'wp_default_editor', 'my_default_editor' );
Alternatively, a snippet for the implementation in Plugins or Themes.
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
Info
- Published in WordPress Hacks
- Tags: backend, Code, disable, HTML Editor, PHP, WordPress, WordPress Tutorials, WP
- Comment feed | Trackback URL
- read: 6709 | today: 22
- leave a Comment



Great tip, but who wouldn't want the HTML editor, you can do so much more with it. You can't embed iFrames in the Visual Editor, and in fact the tags break if you switch from HTML to visual editor when you have iframe code in your post.
YOU ARE AMAZING. For some reason, my WP install had this odd habit of always defaulting to the HTML view AND hiding all of the buttons. They'd come back if you switched to Visual and back, but it was super annoying.
You've just put an end to an annoying 2 day search for a solution to this problem. Thank you much!
I'm trying to turn my on. It seems to be disabled, and I can't figure out why?
I just did this using the Adminimize plugin - http://wordpress.org/extend/plugins/adminimize/