Lisez les derniers articles:

Pendant le developpement de la nouvelle version de ZdMultilang, je suis tombé sur un problème majeur de compatibilité entre Wordpress 2.7 et le plugin.

En fait, c’est due au fait que Wordpress 2.7 nécéssite une fonction de plus que la 2.6.3 pour afficher l’editeur tinyMCE

Wordpress 2.5.x et 2.6.x

Voici comment inclure l’éditeur dans le panneau d’administration de votre plugin.

  1. Inclure ces appels dans le 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. Apeller l’editeur la ou vous le désirez via cet appel
    	the_editor($content_to_load);

Wordpress 2.7

Et voila comment inclure l’editeur avec une version 2.7.

  1. Toujours pareil, inclure ceci dans l’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();
    // Il faut utiliser la condition if si vous voulez rester compatible avec les anciennes version
    // car cette fonction n'as été inclue que depuis la version 2.7
    }
  2. Et enfin apeller l’editeur de la ou vous le voulez
    	the_editor($content_to_load);

Différences entre les versions.

Comme vous pouvez le constater, il n’y à qu’une différence au niveau du code entre des deux version. Mais cette différence est très importante car sans la fonction wp_tiny_mce, l’éditeur ne fonctionnera pas du tout.

Il y a aussi des différences importantes au niveau du design de la page, et il faudra donc utiliser pas mal de ruses pour garder une interface ressemblant a l’originale et compatible avec les deux versions (a base de nouvelles div et de nouvelles classes)

Par la même occasion, j’en profites pour vous annoncer que ZdMultilang sera parfaitement compatible avec Wordpress 2.7 et que l’interface sera grandement améliorée par rapport a maintenant (WP 2.6.3 et 2.7).



  1. Markus (Reply) on Jeudi 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 Jeudi 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 Jeudi 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 Jeudi 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 Jeudi 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 Jeudi 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 Jeudi 6, 2008

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

  8. guigouz (Reply) on Jeudi 6, 2008

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

    • Anthony (Reply) on Jeudi 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 Jeudi 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 Jeudi 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 Jeudi 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 Jeudi 6, 2008

      There is a newer post explaining how to do that.

  13. Scott (Reply) on Jeudi 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 Jeudi 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?