Created
July 6, 2015 13:44
-
-
Save lmm214/e6584f891b1620899919 to your computer and use it in GitHub Desktop.
禁止全英文评论
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scp_comment_post( $incoming_comment ) { | |
$pattern = '/[一-龥]/u'; | |
if(!preg_match($pattern, $incoming_comment['comment_content'])) { | |
wp_die( "您的评论中必须包含中文!" ); | |
} | |
return( $incoming_comment ); | |
} | |
add_filter('preprocess_comment', 'scp_comment_post'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment