函数文档

wp_check_site_meta_support_prefilter()

💡 云策文档标注

概述

wp_check_site_meta_support_prefilter() 是一个 WordPress 过滤器函数,用于在站点元数据不支持时中止相关调用。它检查站点元数据是否启用,若不支持则返回 false 并触发错误提示。

关键要点

  • 函数作为过滤器使用,参数 $check 为是否执行站点元数据函数的初始值
  • 通过 is_site_meta_supported() 检查站点元数据支持状态,若不支持则调用 _doing_it_wrong() 输出错误信息并返回 false
  • 若站点元数据支持,则直接返回原始 $check 值
  • 此函数在 WordPress 5.1.0 版本中引入

代码示例

function wp_check_site_meta_support_prefilter( $check ) {
	if ( ! is_site_meta_supported() ) {
		/* translators: %s: Database table name. */
		_doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.1.0' );
		return false;
	}

	return $check;
}

注意事项

  • 错误信息提示用户运行网络数据库升级以安装必要的数据库表
  • 函数与 is_site_meta_supported()、__() 和 _doing_it_wrong() 等相关函数配合使用

📄 原文内容

Aborts calls to site meta if it is not supported.

Parameters

$checkmixedrequired
Skip-value for whether to proceed site meta function execution.

Return

mixed Original value of $check, or false if site meta is not supported.

Source

function wp_check_site_meta_support_prefilter( $check ) {
	if ( ! is_site_meta_supported() ) {
		/* translators: %s: Database table name. */
		_doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.1.0' );
		return false;
	}

	return $check;
}

Changelog

Version Description
5.1.0 Introduced.