I am using jQuery tinyMCE to populate dynamically generated text areas with tiny MCE editors.
When I use the WordPress
wp_editor function before I call the jQuery version, I have no issues. If I do not, I get;
Uncaught ReferenceError: tinymce is not defined
As a dreadful hack, I have used;
wp_editor('hacky', 'hackhack'); wp_register_script('admin_js', get_template_directory_uri() . '/assets/js/admin.min.js', array()); wp_enqueue_script('admin_js');
Which allows the jQuery TinyMCE to work. I wish to eliminate this. Thinking WP wasn't loading the jQuery version (and not knowing a good way to get the path of
WP-includes) I used;
But this doesn't seem to be the issue. It seems that the WP version loads the required files I need - except I do not know what files I need.
With help from a colleague, we dug through
Here are the necessary scripts to initialise jQuery tinyMCE if
wp_editor has not been used beforehand (which calls these scripts).
This will create a dynamic tinyMCE editor without the tabs to switch between visual / text, nor the media upload functionality. I had to create these buttons manually as well as the respective jQuery for each.
Edited in the required css the editor uses as well.
More elegant solution but with less fallback (no versioning)
For what it's worth - I recently ran into this problem with the editor disappearing with wp 4.1 after a site migration. The issue happened to be that "accessibility mode" (The link under screen options in the widget editor) was turned on.
My problem was wordpress was not including the tinymce script tag because
user_can_richedit() was returning false (I did not investigate why. My user is an admin, and it was previously working on a different install, so maybe some setting controls it?). In any case, you can filter the return value of
user_can_richedit() to get wordpress to include the tinymce scripts and then tinymce will be defined.