Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to add the embedded TinyMCE editor to content area using the code:

add_action( 'comment_form_after', 'tinyMCE_comment_form' );

function tinyMCE_comment_form() {

    wp_tiny_mce(false, array(
        'mode' => 'exact',
        'elements' => 'comment',
        'height' => 200,
        'plugins' => 'inlinepopups,wpdialogs,wplink,media,wpeditimage,wpgallery,paste,tabfocus',
        'forced_root_block' => false,
        'force_br_newlines' => true,
        'force_p_newlines' => false,
        'convert_newlines_to_brs' => true
    ));

}

defined in functions.php of my theme. For some reason if I load a page with comments there it returns the error wp_tiny_mce is not found. Do you know how to fix it? Maybe I chosen the wrong action?

share|improve this question
add comment

3 Answers

I'm not sure if this meets your specific requirements, but I've used this to get a "condensed" version of the TinyMce editor on my comments form:

    <?php
        add_action( 'comment_form_after', 'tinyMCE_comment_form' );
    function tinyMCE_comment_form() {
    ?>
        <script type="text/javascript" src="<?php echo includes_url( 'js/tinymce/tiny_mce.js' ); ?>"></script>;
        <script type="text/javascript">
            tinyMCE.init({
                theme : "advanced",
                mode: "specific_textareas",
                language: "",
                skin: "default",
                theme_advanced_buttons1: 'bold, italic, underline, blockquote, strikethrough, bullist, numlist, undo, redo, link, unlink',
                theme_advanced_buttons2: '',
                theme_advanced_buttons3: '',
                theme_advanced_buttons4: '',
                elements: 'comment',
                theme_advanced_toolbar_location : "top",
            });
        </script>
    <?php
    }

If you need more specific functionality not included in the sample I've provided, post your specific need and I'll try to help you out.

share|improve this answer
    
Thank you, but do you know how could I change the script initialization to let TinyMCE use plugins like wplink, for example? –  Drake Jul 7 '11 at 11:02
    
Sorry, that's the extent of my tinymce "hacking" ability. I've tried a few things, but none have worked. If I figure it out I'll let you know. –  Jeremy Jared Jul 8 '11 at 1:24
add comment

You're trying to use an admin function... outside of the admin!

wp_tiny_mce is defined in wp-admin/includes/post.php - you'll need to include the file manually, or use an alternative as @Jeremy suggests.

share|improve this answer
add comment

If you're using WP 3.3+ I would recommend giving the new "wp_editor()" function a shot. I've used it in several plugins and even on the front end of sites and it's pretty handy.

More detail on how to use it can be found here http://soderlind.no/archives/2011/09/25/front-end-editor-in-wordpress-3-3/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.