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' );
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:
note: it may wont work for
add_option
function..I suggest you use the built in wp_editor() function. Google “wp_editor wordpress codex” and Check out this tutorial Using the WP Editor Function
You have unnecessary scripts loading.
You are able to see the editor.. but it is not loading it’s javascript. You can tell because there are no buttons present. This is most likely because you have a javascript error.
I would remove the unnecessary scripts you have enqueued.
Then, check your browser console to see what errors or notices are generated.
to properly use the wp_editor use it like this: