Including WYSIWYG Editor in Plugin Admin Settings Page?

How would I include a WYSIWYG editor on the admin settings page as opposed to a standard text area?

Thanks.

Related posts

Leave a Reply

2 comments

  1. the_editor($content, $id, $prev_id, $media_buttons, $tab_index, $extended);
    

    is deprecated.

    Use instead:

    wp_editor( $content, $editor_id, $settings = array() );
    

    More info here.

    To include this in your Admin Settings page all you need to do is replace the input or textarea with the wp_editor() code. Example:

    If you are using a class to output a custom Admin Settings page. The form field would be output like this:

    public function content_callback()
    {
        printf(
            '<textarea type="text" id="title" name="my_option_name[content]" value="%s" />',
            esc_attr( $this->options['content'])
        );
    }
    

    Replace the function above with the following:

    public function content_callback()
    {
        printf(
            wp_editor(
               my_option_name[section_one_content], 
               $this->options['section_one_content'])
        );
    }
    

    You can find info on using a class to create options pages here: http://codex.wordpress.org/Creating_Options_Pages

  2. This is super old and possibly this function did not exist when this was posted. That said, just use this:

    <?php the_editor($content, $id, $prev_id, $media_buttons, $tab_index); ?>