WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to determine if the page/post editor is in Visual or Text mode. I also need to determine when this changes.

Does WordPress provide some kind of functionality for doing this? I am writing some JS that requires this information.

share|improve this question
up vote 1 down vote accepted
  1. To determine what mode the editor is currently in, you can use the getUserSetting('editor') in JavaScript, which returns either "html" or "tinymce".

  2. To determine when the editor mode is switched, you can use the jQuery click event handler on the #content-tmce and #content-html elements, which are the editor type switching buttons:

    jQuery( '#content-tmce' ).click( function() { // Visual editor selected } );

    jQuery( '#content-html' ).click( function() { // Text editor selected } );

Bear in mind that these click events will always be triggered when you click on the buttons; when you click on the "Visual" button for example, the event will be triggered regardless whether the current mode is "Visual" or "Text". If you need to, you could easily tackle that by storing the previous state yourself.

share|improve this answer
Quick and dirty, but it will probably work. I'm going to give it a try. Thank you for your feedback. – user52790 Jun 6 '14 at 22:03
It is a little quick and dirty, but then again, that's how WordPress actually handles the Visual Editor modes itself. It's the prettiest way available, I believe. By the way, if it works, please mark the answer as "Accepted". – engelen Jun 7 '14 at 15:24
Yeah, I intended on accepting the answer. Seems to be what I was looking for. Thanks. – user52790 Jun 8 '14 at 2:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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