WordPress.org

Ready to get started?Download WordPress

Forums

How I can use TinyMCE for my own plugin (8 posts)

  1. Bagira
    Member
    Posted 4 years ago #

    Hi, I must write a plugin with administration panel, somethig like "Write Post". I need for WYSIWYG. I know, that WordPress use TinyMCE. But i can't include it to my Plugin. How can I do it? I'm newbie in WordPress programming. Help me please. Thanks.

  2. noamnativ
    Member
    Posted 4 years ago #

    Hi Bagira
    I guess you can add a new advanced text area by using the 'the_editor' function:

    the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2)

    so,for example, if you want to add a new field with the name 'thoughts_list'
    You can do it this way:

    the_editor($thoughts,'thoughts_list');

    Hope this helps.

  3. Bagira
    Member
    Posted 4 years ago #

    Thanks, but I have problems with your code :

    the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2)

    the buttons of "Add an Image", "Add video" and "Visual" doesn't works, no error and nothing happens.

    The button "HTML" gives me the JavaScript error "switchEditors is not defined".

    The other problem is that when I write, the text appears in white colour, I only can see what I type if I mark the text.

    What should I do?

  4. inlanger
    Member
    Posted 4 years ago #

    I have this problem too... How I can explain it?

  5. Laurent J.V. Dubois
    Member
    Posted 4 years ago #

    You could take a look to this very interesting article :
    http://www.keighl.com/2010/01/tinymce-in-wordpress-plugins/

  6. Adcaelo
    Member
    Posted 3 years ago #

    according to http://blog.zen-dreams.com/en/2009/06/30/integrate-tinymce-into-your-wordpress-plugins/
    you need to enqueue script in wordpress header (for me it's admin header)

    so :

    add_filter('admin_head','ShowTinyMCE');
    function ShowTinyMCE() {
    	// conditions here
    	wp_enqueue_script( 'common' );
    	wp_enqueue_script( 'jquery-color' );
    	wp_print_scripts('editor');
    	if (function_exists('add_thickbox')) add_thickbox();
    	wp_print_scripts('media-upload');
    	if (function_exists('wp_tiny_mce')) wp_tiny_mce();
    	wp_admin_css();
    	wp_enqueue_script('utils');
    	do_action("admin_print_styles-post-php");
    	do_action('admin_print_styles');
    }

    and

    the_editor($content_to_load);

    where you want your tinyMCE text area

    Not perfectly working with WP 3.0 (beta) i'm working on it, but you can use it as a text area and media upload work (upload file / add code into text)

  7. ArkaneArkade
    Member
    Posted 3 years ago #

    I was actually looking to do this myself last week, and got a different answer, which seems easier to me.
    The page I got the info from in the end was http://www.keighl.com/2010/01/tinymce-in-wordpress-plugins/

    Basically, add wp_tiny_mce() into your page with the textarea you want. The override info is all in that link.

    The only thing I found was that many people have had issues using multiple textareas. I have it working quite successfully, as long as you make sure that they have the same class and id, but different names.

  8. Scott Kingsley Clark
    Member
    Posted 3 years ago #

    I've had nothing but issues trying to use the built-in TinyMCE editor with the_editor or wp_tiny_mce when needing multiple editors on one page. The best results would probably to put together the JS separately and link those files to the WP included ones -- but circumvent the use of the default WP functions for TinyMCE. Only in this way do I believe I can make TinyMCE finally work multiple times the way it's expected.

    The default code like the_editor and wp_tiny_mce just aren't built to be used multiple times on a page and have their many limits.

Topic Closed

This topic has been closed to new replies.

About this Topic