forked from miracleren/ABCSpam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABCSpam.php
More file actions
26 lines (22 loc) · 985 Bytes
/
ABCSpam.php
File metadata and controls
26 lines (22 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/*
Plugin Name: ABCSpam
Plugin URI: http://www.bbpress.me/forums/topic/me-plug-in/
Version: 0.1
Author: bbpress.me
Author URI: http://www.bbpress.me
Description: Wordpress的垃圾评论中有95%是全英文评论和含有日文字符的评论,该插件用于禁止全英文回复,有效阻止bbpress里的回复垃圾,效率高不写数据库,但有一定局限性。
*/
function bbSpamStopCheck( $comment ) {
$pattern = '/[一-龥]/u';
//禁止全英文评论
$status = preg_match($pattern, $comment);
if(!$status) {
$mess = 'You should type some Chinese word (like 支持 ) in your comment to pass the spam-check, thanks for your patience! 您的评论中必须包含汉字!';
wp_die($mess . '<br /><br /><a href="' . $_SERVER['HTTP_REFERER'] .'#respond">返回</a>');
}
return $comment;
}
add_filter('bbp_new_reply_pre_content', 'bbSpamStopCheck');
add_filter('bbp_new_topic_pre_content', 'bbSpamStopCheck');
?>