wp_editor()调用编辑器

目录

描述

This function renders an editor in a page in the typical fashion used in Posts and Pages.

wp_editor() 描述

用法

 <?php wp_editor$content$editor_id$settings = array() ); ?> 

wp_editor() 用法

参数

$content

(string) (必填) Initial content for the editor.

默认值: None

$editor_id

(string) (必填) HTML id attribute value for the textarea and TinyMCE. (may only contain lowercase letters and underscores...hyphens will cause editor to not display properly)

默认值: None

$settings

(array) (可选) An array of arguments.

默认值: array()

Arguments

wpautop

(boolean) (可选) Whether to use wpautop for adding in paragraphs. Note that the paragraphs are added automatically when wpautop is false.

默认值: true

media_buttons

(boolean) (可选) Whether to display media insert/upload buttons

默认值: true

textarea_name

(string) (可选) The name assigned to the generated textarea and passed parameter when the form is submitted. (may include [] to pass data as array)

默认值: $editor_id

textarea_rows

(integer) (可选) The number of rows to display for the textarea

默认值: get_option('default_post_edit_rows', 10)

tabindex

(integer) (可选) The tabindex value used for the form field

默认值: None

editor_css

(string) (可选) Additional CSS styling applied for both visual and HTML editors buttons, needs to include <style> tags, can use "scoped"

默认值: None

editor_class

(string) (可选) Any extra CSS Classes to append to the Editor textarea

默认值: Empty string

editor_height

(integer) (可选) The height to set the editor in pixels. If set, will be used instead of textarea_rows. (since WordPress 3.5)

默认值: None

teeny

(boolean) (可选) Whether to output the minimal editor configuration used in PressThis

默认值: false

dfw

(boolean) (可选) Whether to replace the default fullscreen editor with DFW (needs specific DOM elements and CSS)

默认值: false

tinymce

(array) (可选) Load TinyMCE, can be used to pass settings directly to TinyMCE using an array

默认值: true

quicktags

(array) (可选) Load Quicktags, can be used to pass settings directly to Quicktags using an array. Set to false to remove your editor's Visual and Text tabs.

默认值: true

drag_drop_upload

(boolean) (可选) Enable Drag & Drop Upload Support (since WordPress 3.9)

默认值: false

wp_editor() 参数

返回值

This function does not return a value.

wp_editor() 返回值

示例

Display an empty editor using the default settings:

Fill an editor with the content for a particular post:

We can also pass an array of one or more settings if the defaults don't suit our needs. For example, if we wanted to hide the insert media buttons, we would do this:

wp_editor() 示例

注意

  • Note that the ID that is passed to the wp_editor() function can only be composed of lower-case letters. No underscores, no hyphens. Anything else will cause the WYSIWYG editor to malfunction. (As of 3.6.1 you can use underscores in the ID.)
  • Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page. Instead use 'edit_page_form' (for pages) or 'edit_form_advanced' (for other post types):

wp_editor() 注意

历史

  • 添加于 版本 3.3

wp_editor() 历史