• Resolved chrisdornan

    (@chrisdornan)


    I am embedding an application within wordpress and have a need to edit formatted text–i.e., I need an invocation of TinyMCE. I could download TinyMCE and install it and work out where to get and how to add all the plugins that WordPress is using, but WordPress has them all sitting there, ready to go, if only I knew how to invoke them.

    Is there a discussion somewhere of how to invoke TinyMCE within a template, ideally with the exact-same configuration as used to edit posts, including (say) the TinyMCE advanced pugin?

    I hope thids makes sense. I have been searching high and low to get mre information on this, and trying things out without success. Thanks in advance for any help or insights.

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    Thread Starter chrisdornan

    (@chrisdornan)

    That has certainly got me going–thanks!

    Thread Starter chrisdornan

    (@chrisdornan)

    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)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Using TinyMCE inside tmplates’ is closed to new replies.