How To Disable HTML Editor In WordPress

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 functionwp_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 valuetinymce.

  • 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";') );

 

4 Responses to “How To Disable HTML Editor In WordPress”

  1. This stylesheet must be loaded in the admin, while we can go several ways.

  2. sureshpeters says:

    html editors are very important when we need any inner style sheet or embed code added means we need html editor . If you web design stuff you can really play with that html