用了WordPress做博客,各位站长肯定会遇到恶意评论,可能是有些插件带的,或者一些发帖机干的,这里给大家提出解决方法,
将下面的代码添加到你的WordPress主题中的function.php文件中即可,
//评论禁止纯英文、日语 function refused_spam_comments($comment_data) { $pattern = '/[一-龥]/u'; $jpattern = '/[ぁ-ん]+|[ァ-ヴ]+/u'; if (!preg_match($pattern, $comment_data['comment_content'])) { err(__('禁止纯英文评论!You should type some Chinese word!')); } if (preg_match($jpattern, $comment_data['comment_content'])) { err(__('关于日语,站长勉强听懂雅蠛蝶 Japanese Get out!日本语出て行け! You should type some Chinese word!')); } return ($comment_data); } add_filter('preprocess_comment', 'refused_spam_comments');
评论抢沙发