wp_editor

函数


wp_editor ( $content, $editor_id, $settings = array() )
参数
  • (string)
    $content
    Initial content for the editor.
    Required:
  • (string)
    $editor_id
    HTML ID attribute value for the textarea and TinyMCE. Should not contain square brackets.
    Required:
  • (array)
    $settings
    See _WP_Editors::parse_settings() for description.
    Required:
    Default: array()
相关
  • _WP_Editors::editor()
  • _WP_Editors::parse_settings()
定义位置
  • wp-includes/general-template.php
    , line 3808
引入
3.3.0
弃用

渲染一个编辑器。

使用这个函数是输出TinyMCE和Quicktags所有需要的组件的正确方式。_WP_Editors不应该被直接使用。见https://core.trac.wordpress.org/ticket/17144。

注意:一旦初始化,TinyMCE编辑器就不能在DOM中安全移动。由于这个原因,在meta box里面运行wp_editor()不是一个好主意,除非只使用Quicktags。在帖子编辑界面,有几个动作可以用来包括包含TinyMCE的额外编辑器:’edit_page_form’, ‘edit_form_advanced’ 和 ‘dbx_post_sidebar’。

更多信息见https://core.trac.wordpress.org/ticket/19173。

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 );
}