函数文档

the_editor()

💡 云策文档标注

概述

the_editor() 是一个已弃用的 WordPress 函数,用于显示 TinyMCE、HTML 或两者结合的编辑器。自 3.3.0 版本起,建议使用 wp_editor() 替代。

关键要点

  • the_editor() 函数已被弃用,自 WordPress 3.3.0 起应改用 wp_editor()。
  • 该函数用于显示编辑器,支持 TinyMCE、HTML 或两者结合,并可控制媒体按钮的显示。
  • 参数包括 $content(必需)、$id(可选,默认 'content')、$media_buttons(可选,默认 true)等,但 $prev_id、$tab_index 和 $extended 参数已不再使用。
  • 函数内部调用 wp_editor() 并传递相关参数,同时通过 _deprecated_function() 标记为弃用。

代码示例

function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
    _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
    wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
}

注意事项

  • 在开发新代码时,应避免使用 the_editor(),转而使用 wp_editor() 以确保兼容性和最佳实践。
  • 如果维护旧代码,需注意 the_editor() 的弃用状态,并计划迁移到 wp_editor()。

📄 原文内容

Displays an editor: TinyMCE, HTML, or both.

Description

See also

Parameters

$contentstringrequired
Textarea content.
$idstringoptional
HTML ID attribute value. Default 'content'.
$prev_idstringoptional
Unused.
$media_buttonsbooloptional
Whether to display media buttons.

Default:true

$tab_indexintoptional
Unused.

Default:2

$extendedbooloptional
Unused.

Default:true

Source

function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );

	wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
}

Changelog

Version Description
3.3.0 Deprecated. Use wp_editor()
2.1.0 Introduced.