Checks if a comment contains disallowed characters or words.
Parameters
$author
stringrequired- The author of the comment
$email
stringrequired- The email of the comment
$url
stringrequired- The url used in the comment
$comment
stringrequired- The comment content
$user_ip
stringrequired- The comment author’s IP address
$user_agent
stringrequired- The author’s browser user agent
Source
$approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
}
}
/**
* Filters a comment's approval status before it is set.
*
* @since 2.1.0
* @since 4.9.0 Returning a WP_Error value from the filter will short-circuit comment insertion
* and allow skipping further processing.
*
* @param int|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam', 'trash',
* or WP_Error.
* @param array $commentdata Comment data.
*/
return apply_filters( 'pre_comment_approved', $approved, $comment_data );
}
/**
* Checks if a comment contains disallowed characters or words.
*
* @since 5.5.0
*
* @param string $author The author of the comment.
* @param string $email The email of the comment.
* @param string $url The url used in the comment.
* @param string $comment The comment content.
* @param string $user_ip The comment author's IP address.
* @param string $user_agent The author's browser user agent.
* @return bool True if the comment contains disallowed content, false otherwise.
*/
function wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent ) {
/**
* Fires before the comment is tested for disallowed characters or words.
*
* @since 1.5.0
* @deprecated 5.5.0 Use 'wp_check_comment_disallowed_list' instead.
*
* @param string $author Comment author.
* @param string $email Comment author's email.
* @param string $url Comment author's URL.
* @param string $comment Comment content.
* @param string $user_ip Comment author's IP address.
* @param string $user_agent Comment author's browser user agent.
*/
do_action_deprecated(
'wp_blacklist_check',
array( $author, $email, $url, $comment, $user_ip, $user_agent ),
'5.5.0',
'wp_check_comment_disallowed_list',
__( 'Please consider writing more inclusive code.' )
);
/**
* Fires before the comment is tested for disallowed characters or words.
*
* @since 5.5.0
*
* @param string $author Comment author.
* @param string $email Comment author's email.
* @param string $url Comment author's URL.
* @param string $comment Comment content.
* @param string $user_ip Comment author's IP address.
* @param string $user_agent Comment author's browser user agent.
*/
do_action( 'wp_check_comment_disallowed_list', $author, $email, $url, $comment, $user_ip, $user_agent );
$mod_keys = trim( get_option( 'disallowed_keys' ) );
if ( '' === $mod_keys ) {
return false; // If moderation keys are empty.
Changelog
Version | Description |
---|---|
5.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.