trying to use the tiny_mce editor within a plugin (7 posts)

  1. MacAddict
    Posted 7 years ago #

    is there a way to access/integrate the tiny_mce editor to a <textarea> when writing a plugin? I have a the plugin attaching to the admin menu properly, but I can't for the life of me figure out how to get it to render the textarea with the tiny_mce editor.

    I am using add_submenu_page(), which attaches my plugin page to users.php via users.php?page=pluginPage.php, which does not allow me access to the header information, or the ability to embed tiny_mce before the page is drawn.

    I can get it to render a basic one with b, i, link, b-quote like it has here, via:

    <?php the_editor($extraDescription,"extraDescription"); ?>

    but I would like the rich editor. The users see the visual editor when making posts, but this is an extended author profile plugin where I am allowing them to provide an avatar and a more extensive writeup about themselves. (beyond the "about" in profile.php) I know there has to be a way... I am just not seeing it...

    Thanks for any guidance...

  2. MacAddict
    Posted 7 years ago #

    so no one has any insight into utilizing the tiny_mce editor outside of the "add post" page?

  3. dlane99
    Posted 7 years ago #

    Ive been trying to do this aswell,
    Im trying to edit the wp-ajax-newsletter plugin (its under gpl) so that it can send html emails.

    I dont know php or anythign about wordpress but i did see that the_editor is what is used in the post-new.php so i was trying to get the newsletter plugin to use it too.

    it only generates the basic text editor with the buttons for html tags instead of the rich editor like it does for me in the post-new.php page.
    There is the "HTML" and "Visual" links above the editor but they dont work when it renders.

    I'm convinced that the_editor will generate the rich text editor correctly and that there is some variable or something in need to set before i call it.

    I know your probable aware of it already but the_editor func is in general-template.php

    If anyone knows how to get the_editor to render properly i'm also eager to know!


  4. Try adding wp_enqueue_script('editor'); to the plugin. This needs to happen early, before your page is fully generated (before admin-header.php gets included, anyway).

    The best way seems to be to enqueue scripts on the admin_print_scripts-$page_hook action. The $page_hook is what you get back from adding your custom menu via add_menu_page or add_submenu_page. So it's something sorta like this:

    $my_hook = add_submenu_page(whatever);
    function my_scripts() {
    if ( user_can_richedit() ) wp_enqueue_script('editor');
  5. DeannaS
    Posted 6 years ago #

    I tried Otto42's suggestion, and I've verified that the user can richedit, and I still get the simplified editor. I'm using wpmu, though - so perhaps it doesn't work quite the same....

  6. Sarah Anderson
    Posted 6 years ago #

    You still need to load the tinymce.js file to get the Visual and HTML tabs to work, however wp_enqueue_script('tiny_mce') doesn't work, hardcoding the link in does, but that's obviously not a great solution.

  7. benlag
    Posted 6 years ago #


    Had to do this myself recently. I've worked it out from the source after a bit of testing.

    I've posted the solution to this thread:


Topic Closed

This topic has been closed to new replies.

About this Topic