Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#19551 closed feature request (duplicate)

Please provide option to match whole words for comment moderation

Reported by: jwz's profile jwz Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3
Component: Comments Keywords:
Focuses: Cc:


The "Comment Moderation" and "Comment Blacklist" fields are documented to match inside words. However, I find that less useful than the alternative, of matching whole words.

With each WP release, I have to modify the source to add \b to the regexp. It would be better if there was a preference option to say whether you want to match whole words or not. Alternately, there could be an option to just let me type real regexps into the field directly.

--- wp-includes/comment.php	14 Dec 2011 19:42:49 -0000	1.5
+++ wp-includes/comment.php	14 Dec 2011 19:43:31 -0000
@@ -69,9 +69,7 @@
 			// spam words don't break things:
 			$word = preg_quote($word, '#');
-			// jwz: match whole words only.
-			$pattern = "#\\b$word\\b#i";
+			$pattern = "#$word#i";
 			if ( preg_match($pattern, $author) ) return false;
 			if ( preg_match($pattern, $email) ) return false;
 			if ( preg_match($pattern, $url) ) return false;

Change History (1)

#1 @scribu
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Funny, this was just brought up a few days ago: #19495

Feel free to make your case there.

Note: See TracTickets for help on using tickets.