函数文档

rich_edit_exists()

💡 云策文档标注

概述

rich_edit_exists() 函数用于检查 TinyMCE 编辑器是否可用,通过检测相关文件是否存在来判断。该函数已在 WordPress 3.9.0 版本中被弃用。

关键要点

  • 函数功能:检查 TinyMCE 文件是否存在,以确定富文本编辑器是否可用。
  • 返回值:返回布尔值,表示 TinyMCE 是否存在。
  • 弃用状态:自 WordPress 3.9.0 起被弃用,建议使用替代方法。
  • 实现方式:通过全局变量 $wp_rich_edit_exists 缓存结果,检测文件路径 ABSPATH . WPINC . '/js/tinymce/tinymce.js'。

代码示例

function rich_edit_exists() {
	global $wp_rich_edit_exists;
	_deprecated_function( __FUNCTION__, '3.9.0' );

	if ( ! isset( $wp_rich_edit_exists ) )
		$wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' );

	return $wp_rich_edit_exists;
}

注意事项

  • 此函数已被弃用,开发者应避免在新代码中使用,并考虑替代方案。
  • 相关函数 _deprecated_function() 用于标记弃用并通知使用情况。

📄 原文内容

Determine if TinyMCE is available.

Description

Checks to see if the user has deleted the tinymce files to slim down their WordPress installation.

Return

bool Whether TinyMCE exists.

Source

function rich_edit_exists() {
	global $wp_rich_edit_exists;
	_deprecated_function( __FUNCTION__, '3.9.0' );

	if ( ! isset( $wp_rich_edit_exists ) )
		$wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' );

	return $wp_rich_edit_exists;
}

Changelog

Version Description
3.9.0 Deprecated.
2.1.0 Introduced.