禁止全英文和日文评论

/**
 * 禁止全英文和日文评论
 */
function BYMT_comment_post($incoming_comment){
    $pattern = '/[一-龥]/u';
    $jpattern = '/[ぁ-ん]+|[ァ-ヴ]+/u';
    if (!preg_match($pattern, $incoming_comment['comment_content'])) {
        err("写点汉字吧,博主英文过了四级,但还是不认识英文!Please write some chinese words!");
    }
    if (preg_match($jpattern, $incoming_comment['comment_content'])) {
        err("日文滚粗!Japanese Get out!日本語出て行け!");
    }
    return $incoming_comment;
}
add_filter('preprocess_comment', 'BYMT_comment_post');

发表回复

后才能评论