On this page
wp_editor( string $content, string $editor_id, array $settings = array() )
Renders an editor.
Description
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.
See also
Parameters
$contentstring Required-
Initial content for the editor.
$editor_idstring Required-
HTML ID attribute value for the textarea and TinyMCE.
Should not contain square brackets. $settingsarray Optional-
See _WP_Editors::parse_settings() for description.
More Arguments from _WP_Editors::parse_settings( ... $settings )
Array of editor arguments.
wpautopboolWhether to use wpautop() . Default true.media_buttonsboolWhether to show the Add Media/other media buttons.default_editorstringWhen both TinyMCE and Quicktags are used, set which editor is shown on page load. Default empty.drag_drop_uploadboolWhether to enable drag & drop on the editor uploading. Default false.
Requires the media modal.textarea_namestringGive the textarea a unique name here. Square brackets can be used here. Default $editor_id.textarea_rowsintNumber rows in the editor textarea. Default 20.tabindexstring|intTabindex value to use. Default empty.tabfocus_elementsstringThe previous and next element ID to move the focus to when pressing the Tab key in TinyMCE. Default':prev,:next'.editor_cssstringIntended for extra styles for both Visual and Text editors.
Should include<style>tags, and can use "scoped". Default empty.editor_classstringExtra classes to add to the editor textarea element. Default empty.teenyboolWhether to output the minimal editor config. Examples include Press This and the Comment editor. Default false.dfwboolDeprecated in 4.1. Unused.tinymcebool|arrayWhether to load TinyMCE. Can be used to pass settings directly to TinyMCE using an array. Default true.quicktagsbool|arrayWhether to load Quicktags. Can be used to pass settings directly to Quicktags using an array. Default true.
Default:
array()
Source
File: wp-includes/general-template.php. View all references
function wp_editor( $content, $editor_id, $settings = array() ) {
if ( ! class_exists( '_WP_Editors', false ) ) {
require ABSPATH . WPINC . '/class-wp-editor.php';
}
_WP_Editors::editor( $content, $editor_id, $settings );
}
Related
Uses
| Uses | Description |
|---|---|
| _WP_Editors::editor() wp-includes/class-wp-editor.php | Outputs the HTML for a single instance of the editor. |
Used By
| Used By | Description |
|---|---|
| wp_comment_reply() wp-admin/includes/template.php | Outputs the in-line comment reply-to form in the Comments list table. |
| edit_form_image_editor() wp-admin/includes/media.php | Displays the image and editor in the post editor |
| the_editor() wp-includes/deprecated.php | Displays an editor: TinyMCE, HTML, or both. |
Changelog
| Version | Description |
|---|---|
| 3.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_editor