Read the Latest Articles:

While developping ZdMultilang’s new version, I came accross a compatibilty problem with Wordpress 2.7.

In fact, to include the tinyMCE editor you won’t use the same functions between 2.6.3 and 2.7 releases. More interesting is WP2.7 will need one more function to be able to display the editor.

Most of the time you will want to include this editor when working with posts, or when you want to enable your plugin users to enter information with the Wysiwyg editor (newsletter, advanced widgets, etc…)

Wordpress 2.5.x and 2.6.x

Here is how to include the editor in one of your plugin’s admin panel.

  1. Include this code in the admin_head hook
    add_filter('admin_head','zd_multilang_tinymce');
    
    function zd_multilang_tinymce() {
    	wp_admin_css('thickbox');
    	wp_print_scripts('post');
    	wp_print_scripts('editor');
    	add_thickbox();
    	wp_print_scripts('media-upload');
    	wp_print_scripts('jquery');
    	wp_print_scripts('jquery-ui-core');
    	wp_print_scripts('jquery-ui-tabs');
    }
  2. Call the editor anywhere you need it to be displayed
    	the_editor($content_to_load);

Wordpress 2.7

Here is how to include the editor in one of your plugin’s admin panel.

  1. Include this code in the admin_head hook
    add_filter('admin_head','zd_multilang_tinymce');
    
    function zd_multilang_tinymce() {
    	wp_admin_css('thickbox');
    	wp_print_scripts('jquery-ui-core');
    	wp_print_scripts('jquery-ui-tabs');
    	wp_print_scripts('post');
    	wp_print_scripts('editor');
    	add_thickbox();
    	wp_print_scripts('media-upload');
    	if (function_exists('wp_tiny_mce')) wp_tiny_mce();
    // use the if condition because this function doesn't exist in version prior to 2.7
    }
  2. Call the editor anywhere you need it to be displayed
    	the_editor($content_to_load);

Differences between versions.

As you can see, there is only one difference in the code between both version, but this is a major one as if you don’t call the wp_tiny_mce function, the editor will not work at all.

There are some other differences but mostly in the css classes as the design has been totally revamped. Therefore if you want to mimic the interface on both version you will need to add some classes and divs as you will see when I’ll publish ZdMultilang v1.1.2 ;)

By the way, I’m proud to announce that version 1.1.2 of ZdMultilang will be fully compatible with Wordpress 2.7 and the interface will look much better in 2.6.3 and 2.7 than right now.

Wordpress 2.8

For an updated version of this tutorial using Wordpress 2.8, check this post.



  1. Markus (Reply) on Thursday 6, 2008

    Hi Anthony,

    I’m excited to hear this. If you like you can Email the new Beta version to me and I’ll start some testing for you.

    I forgot to ask, where in Canada are you moving? (my guess would be Montreal, Quebec. I lived for over 30 years in Canada myself and have been all over this beautiful country.

    Cheers, Markus

  2. Anthony (Reply) on Thursday 6, 2008

    Markus, I’ll send you a Beta version during the week, I expect to release next version next week :)

    No, I’m not moving to Montréal, I’m moving to Vancouver :) But your guess was legitimate as I’m french ;)

  3. [...] How-To include tinyMCE in your WP plugin | Zen-Dreams This post about adding TinyMCE to your WordPress plugin includes instructions for WordPress 2.7. (tags: wordpress programming plugins) SHARETHIS.addEntry({ title: “links for 2008-12-02″, url: “http://michaelwender.com/2008/12/02/links-for-2008-12-02/” }); This entry was written by Michael Wender, posted on December 2, 2008 at 2:00 pm, filed under Links. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL. « Oldest Ever Lolcat Found – I Can Has Cheezburger? [...]

  4. Chris Respeto (Reply) on Thursday 6, 2008

    I have been looking all over for this information, thank you so much, this was very, very helpful.

  5. Jack Lenox (Reply) on Thursday 6, 2008

    Hi Anthony,

    I’m afraid I don’t quite understand the part about the admin_head hook. Whereabouts do I find this and where do I place the code that you have suggested? Is it in admin-header.php in wp-admin? Can you show what code should be either side of the new bit?

    Thanks,

    Jack

  6. Peter (Reply) on Thursday 6, 2008

    First of all – brilliant post – this is the only place I can find working instructions on using the_editor to its fullest.

    I have run into one problem though – After 3 hours of debugging this morning (after months of using this piece of code in client work.. whoops), I found that you need to make sure that when you include the zd_multilang_tinymce() function, there really needs to be a conditional statment to make sure it’s only run on the page you want it to run on. In my case, I used this:

    if(get_admin_page_title() == ‘Theme Options’){
    //enqueue stuff here
    }

    The problem comes when this function is run on the edit-post page – the tinymce editor goes wonky, but you don’t notice it until you hit the “kitchen sink” button, and apparently it only happens in firefox (and I only tested FF3). I haven’t taken the time to figure out why it happens, because figuring this out was one of the most infuriating things I’ve ever done, and I’m not sure I can look at another line of code today – but perhaps using wp_enqueue_script instead of print_script would solve the problem?

    Regardless, a million thanks for figuring this out the first place – it has been a lifesaver.

  7. Guillaume (Reply) on Thursday 6, 2008

    hi! thanks for this usefull tip…
    Do you have any update with Wordpress 2.8, I tried and the upload part isn’t working anymore.
    Thanks a lot

    • Anthony (Reply) on Thursday 6, 2008

      Yes I do have the answer to your question, and I will update the post soon :D

  8. guigouz (Reply) on Thursday 6, 2008

    I do have the same question…. any way to make this work with 2.8 ?

    • Anthony (Reply) on Thursday 6, 2008

      The post has been updated and there is also a post about 2.8 on my homepage.

  9. [...] the RSS feed for updates on this topic.You might remember that I wrote a previous article about the integration of tinyMCE into your wordpress plugins for version 2.5 to [...]

  10. php trivandrum (Reply) on Thursday 6, 2008

    hey all, actually

    wp_admin_css(‘thickbox’) is not needed in any case if add_thickbox() works, and the fact is that it will not work if it is called from the trigger urged me to pull out the wp_admin_css(‘thickbox’), and add_thickbox() from the function, and just added add_thickbox() to the body of the main plugin file, such that the wp_enque-blah will run well ahead, and the thickbox js as well as the css is outputted by the wordpress.
    php trivandrum´s last blog ..First taste of bbpress – was sweet but getting sour My ComLuv Profile

  11. php trivandrum (Reply) on Thursday 6, 2008

    also I did change the add_filter to add_action
    php trivandrum´s last blog ..First taste of bbpress – was sweet but getting sour My ComLuv Profile

  12. Mike (Reply) on Thursday 6, 2008

    I am also wanting to find out how to make this work with WordPress 2.8
    Mike´s last blog ..Google Voice CallMe Widget for WordPress My ComLuv Profile

    • Anthony (Reply) on Thursday 6, 2008

      There is a newer post explaining how to do that.

  13. Scott (Reply) on Thursday 6, 2008

    I was just wondering if you could add WP 2.8 to this how to, the method listed doesn’t seem to work any more. The editor comes up but you cannot resize it, cannot load content into it through JS, and the media buttons (images,files,etc) do not work.

  14. zquest (Reply) on Thursday 6, 2008

    Hi Anthony, thankyou for your help. But I think I did not understand it very clearly. Does that mean we could only call the editor in the admin panel? What should I do, if I want to call the tinyMCE in a public page?

  15. Amit (Reply) on Thursday 6, 2008

    Hi Anthony,

    I followed your post and tinyMCE shows up well in my plugin for wordpress 2.8. I was earlier using the following statement to save content of my textarea to my DB but now I have no clue how to save tinyMCE’s content to DB…

    $settings["template"] = stripslashes($_POST["textareaContent"]);
    ajaxNewsletter::saveSettings($settings);

    I’ll really appreciate if you may kindly guide me on this…

    Thanks a lot,
    ak