函数文档

wp_blacklist_check()

💡 云策文档标注

概述

wp_blacklist_check() 是一个已弃用的 WordPress 函数,用于检查评论是否包含不允许的字符或词语。自 WordPress 5.5.0 起,建议使用 wp_check_comment_disallowed_list() 替代。

关键要点

  • 函数 wp_blacklist_check() 已弃用,从 WordPress 5.5.0 开始,应改用 wp_check_comment_disallowed_list()。
  • 该函数接收六个参数:$author(评论作者)、$email(评论邮箱)、$url(评论中使用的 URL)、$comment(评论内容)、$user_ip(评论作者的 IP 地址)和 $user_agent(作者的浏览器用户代理)。
  • 返回布尔值:如果评论包含不允许的内容则返回 true,否则返回 false。
  • 相关函数包括 wp_check_comment_disallowed_list() 和 _deprecated_function()。

注意事项

开发者应更新代码以使用 wp_check_comment_disallowed_list(),避免使用已弃用的函数,并考虑编写更具包容性的代码。


📄 原文内容

Does comment contain disallowed characters or words.

Parameters

$authorstringrequired
The author of the comment
$emailstringrequired
The email of the comment
$urlstringrequired
The url used in the comment
$commentstringrequired
The comment content
$user_ipstringrequired
The comment author’s IP address
$user_agentstringrequired
The author’s browser user agent

Return

bool True if comment contains disallowed content, false if comment does not

Source

function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) {
	_deprecated_function( __FUNCTION__, '5.5.0', 'wp_check_comment_disallowed_list()' );

	return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent );
}

Changelog

Version Description
5.5.0 Deprecated. Use wp_check_comment_disallowed_list() instead.
Please consider writing more inclusive code.
1.5.0 Introduced.