I'm developing a WordPress plugin that allows sending a short code into the rich text editor. Assuming the short code content is stored inside shortcode
variable, the following code works perfectly:
tinyMCE.execCommand('mceInsertContent', false, shortcode);
...if the user is in "Visual Editor" mode. If they switch to "Plain Text" mode, the code doesn't work anymore - no content appears in the textarea.
Anyone can help? Thanks in advance.
(Ah, if that matters, I have several instance of editors on the same "Add Post" page).
Just got it! Simply do
send_to_editor(shortcode);
this function is located inside media-upload.js, which should be loaded in Edit/Add Post pages.