函数文档

wp_tiny_mce()

💡 云策文档标注

概述

wp_tiny_mce() 是一个已弃用的 WordPress 函数,用于输出 TinyMCE 编辑器。自 WordPress 3.3.0 起,建议使用 wp_editor() 替代。

关键要点

  • wp_tiny_mce() 函数已被弃用,自 WordPress 3.3.0 版本起,应改用 wp_editor() 函数。
  • 该函数接受两个可选参数:$teeny(布尔值,控制是否使用简化编辑器)和 $settings(数组或布尔值,用于自定义 TinyMCE 设置)。
  • 函数内部依赖 _WP_Editors 类来解析设置并输出编辑器,自动生成唯一的编辑器 ID。
  • 相关函数包括 _WP_Editors::editor_settings()、_WP_Editors::parse_settings() 和 _deprecated_function()。

注意事项

在开发新功能或维护旧代码时,应避免使用 wp_tiny_mce(),转而使用 wp_editor() 以确保兼容性和最佳实践。


📄 原文内容

Outputs the TinyMCE editor.

Description

See also

Source

function wp_tiny_mce( $teeny = false, $settings = false ) {
	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );

	static $num = 1;

	if ( ! class_exists( '_WP_Editors', false ) )
		require_once ABSPATH . WPINC . '/class-wp-editor.php';

	$editor_id = 'content' . $num++;

	$set = array(
		'teeny' => $teeny,
		'tinymce' => $settings ? $settings : true,
		'quicktags' => false
	);

	$set = _WP_Editors::parse_settings($editor_id, $set);
	_WP_Editors::editor_settings($editor_id, $set);
}

Changelog

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