写了一年多WordPress,除了感受到它的强大,还有spam…
虽然Akismet阻挡了四五K的spam,但是一条一条审核还是太过麻烦,写个方法来处理一下
function spamCheck( $in
coming_
comment ) {
$pattern = '/[一-龥]/u';
if(!preg_match($pattern, $incoming_comment['comment_content'])) {
wp_die( 'You should type some Chinese word!' );
}
if(substr_count($incoming_comment['comment_content'],'http') > 3) {
wp_die( '请勿在您的评论中包含过多链接!' );
}
return( $incoming_comment );
}
add_filter('preprocess_comment', 'spamCheck');