Hi chrisdornan,
You want to do something like this (assuming that you are talking about admin pages):
Put the following, or similar, in your plugin somewhere.
function the_editor_enqueu() { // add libraries for editor
wp_enqueue_script('post');
wp_enqueue_script('media-upload');
wp_enqueue_script('word-count');
wp_enqueue_script('schedule');
wp_enqueue_script('editor');
add_thickbox();
wp_admin_css('thickbox');
}
function enqueue_editor_head() {
if (function_exists('wp_tiny_mce')) wp_tiny_mce();
}
Then invoke them like this:
add_action('admin_head',array(&$this, 'enqueue_editor_head'));
add_action('admin_menu',array(&$this, 'the_editor_enqueu'));
You probably want to add a switch so that you are only loading this stuff on the pages you need it on.
Then, invoke the editor where you want it with : the_editor($whateveryouwanttoedit);
The above works for me. I’m using it for several different admin pages. Maybe someone else has a better suggestion, though.
That has certainly got me going–thanks!
See the follow up thread, Which Admin Page amd I on? for the full reolution, where, , as advised by apljdi, I find out how to ‘add a switch so that you are only loading this stuff on the pages you need it on’.
Hi apljdi,
It seems not work in my plugin, when I want to switch the editor from HTML to VISUAL, there is an error. And I’m sure I have invoked the functions as:
add_action('admin_head',array(&$this, 'enqueue_editor_head'));
add_action('admin_menu',array(&$this, 'the_editor_enqueu'));
And my another question is how to invoke the WP editor in a template (or public pages not admin page)