I would just use the WordPress JavaScript API for TinyMCE — wp.editor
.
The steps in brief:
-
PHP: Enqueue the editor scripts (and styles) via
wp_enqueue_editor()
. -
JS: Call
wp.editor.initialize()
from your script.
And do take note of this: (the “this function” refers to wp.editor.initialize
)
If this function does nothing, please make sure that
wp.editor.getDefaultSettings
is a function.
Which means, if it’s not a function, then while there are no errors thrown in the browser/console, the textarea
will not be converted to a TinyMCE editor.