Advertisements

wp_blacklist_check

Definition:
function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {}

Does comment contain blacklisted characters or words.

Parameters

  • string $author: The author of the comment
  • string $email: The email of the comment
  • string $url: The url used in the comment
  • string $comment: The comment content
  • string $user_ip: The comment author IP address
  • string $user_agent: The author’s browser user agent

Return values

returns:True if comment contains blacklisted content, false if comment does not

Defined actions

  • wp_blacklist_check
    do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);

Source code

function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {

	do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);



	$mod_keys = trim( get_option('blacklist_keys') );

	if ( '' == $mod_keys )

		return false; // If moderation keys are empty

	$words = explode("\n", $mod_keys );



	foreach ( (array) $words as $word ) {

		$word = trim($word);



		// Skip empty lines

		if ( empty($word) ) { continue; }



		// Do some escaping magic so that '#' chars in the

		// spam words don't break things:

		$word = preg_quote($word, '#');



		$pattern = "#$word#i";

		if (

			   preg_match($pattern, $author)

			|| preg_match($pattern, $email)

			|| preg_match($pattern, $url)

			|| preg_match($pattern, $comment)

			|| preg_match($pattern, $user_ip)

			|| preg_match($pattern, $user_agent)

		 )

			return true;

	}

	return false;

}

3433

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: