Call TinyMCE in a WordPress plugin

javascript, php, plugins, tinymce, wordpress

Solution

This is much easier to do in WordPress 3.3 using the wp_editor() function.

I'm working on a plugin that will add a TinyMCE instance to a theme options page. Here's what it looks like:

// Add TinyMCE visual editor
wp_editor( $content, $id );

Where $content is the stored content and $id is the name of the field. Options can also be passed to customize the TinyMCE functionality, check out the WordPress Codex for more details.

Problem

Is there a way to add TinyMCE into my own WordPress plugin? I have a textarea in my back end script and want to make this area into a TinyMCE WYSIWYG editable field. Is there a way to do that? This code does not work for me: ``` <?php wp_tiny_mce(false,array("editor_selector" => "test")); ?> <textarea class="test" id="test" name="test"></textarea> ``` It shows the javascript error ``` f is undefined ``` Firebug screenshot: This didn't work either: ``` <textarea class="theEditor" id="videogalerie-add_description" name="videogalerie-add_description"></textarea> ```

Original source