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>
Log in to your WordPress Dashboard, click Plugins, then Add New. Search for the Advanced TinyMCE Configuration plugin, then click Install Now. Once the plugin is installed, click Activate.
To do so, log into your site's admin area (http://yoursite.com/wp-login.php) and then navigate to Plugins > Add New using the sidebar menu. From the Add Plugins screen, enter 'tinymce advanced' in the search field and then install the first item listed in the results.
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.
Camden already answered this, but in case somebody needs the full code... Be sure to hook in admin_head, hooking into admin_enqueue_scripts will cause it to load before other scripts, such as jQuery, so it will not work.
add_action("admin_head","load_custom_wp_tiny_mce"); function load_custom_wp_tiny_mce() { if (function_exists('wp_tiny_mce')) { add_filter('teeny_mce_before_init', create_function('$a', ' $a["theme"] = "advanced"; $a["skin"] = "wp_theme"; $a["height"] = "200"; $a["width"] = "800"; $a["onpageload"] = ""; $a["mode"] = "exact"; $a["elements"] = "intro"; $a["editor_selector"] = "mceEditor"; $a["plugins"] = "safari,inlinepopups,spellchecker"; $a["forced_root_block"] = false; $a["force_br_newlines"] = true; $a["force_p_newlines"] = false; $a["convert_newlines_to_brs"] = true; return $a;')); wp_tiny_mce(true); } }
Then somewhere in your template insert a regular textarea:
<textarea id="intro"></textarea>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With