wp_editor

Renders an editor.

Description

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

Using this function is the proper way to output all needed components for both TinyMCE and Quicktags. _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.

NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason running wp_editor() inside of a meta box is not a good idea unless only Quicktags is used. On the post edit screen several actions can be used to include additional editors containing TinyMCE: edit_page_form,, edit_form_advanced and dbx_post_sidebar.. See https://core.trac.wordpress.org/ticket/19173 for more information.

Parameters (3)

0. $content (string)
Initial content for the editor.
1. $editor_id (string)
HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
2. $settings — Optional. (array) => array()
See _WP_Editors::editor().

Usage

  1. if ( !function_exists( 'wp_editor' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // Initial content for the editor. 
  5. $content = ''; 
  6.  
  7. // HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/. 
  8. $editor_id = ''; 
  9.  
  10. // See _WP_Editors::editor(). 
  11. $settings = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wp_editor($content, $editor_id, $settings); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function wp_editor( $content, $editor_id, $settings = array() ) { 
  2. if ( ! class_exists( '_WP_Editors', false ) ) 
  3. require( ABSPATH . WPINC . '/class-wp-editor.php' ); 
  4. _WP_Editors::editor($content, $editor_id, $settings);