I’m trying to add a rich text editor to my own plugin.
So I googled it first of course and I found several answers on dev4press and Stack Overflow. This code displays nothing so I tried another solution. This displays a rich text editor like :
This seems to work fine, but as soon I switch to the WYSIWYG tab the text I inserted is deleted, I only see a blank field and I can’t type anything.
Is someone familiar with this problem?
Is this a bug or what can I do to make it work?
These scripts and styles are included in my plugin:
function highlights_style() {
wp_enqueue_style('thickbox');
}
function highlights_script() {
wp_register_script( 'jquery.js', HIGHLIGHTS_PLUGIN_URL . 'jquery.js', array('jquery','media-upload','thickbox'));
wp_enqueue_script( 'jquery.js' );
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_enqueue_script( 'editor' );
wp_enqueue_media();
add_action( 'admin_head', 'wp_tiny_mce' );
}
And I use this to display the editor:
the_editor( '' , 'content' );
4 Answers
wp_editor()
outputs the textarea(html codes),
so, maybe you dont need to use that in functions.php, but use inside the page’s source.
(for example, in your plugin.php:
<div class="blabla>
<form action="" method="POST">
<?php wp_editor( 'Hi,its content' , 'desired_id_of_textarea', $settings = array('textarea_name'=>'your_desired_name_for_$POST') ); ?>
<input type="submit">
</form>
</div>
note: it may wont work for add_option
function..