本文实例讲述了WordPress评论制止针对指定内容全英文的办法。分享给大家供大家参考。详细剖析如下:
WordPress评论中**要过滤的是全英文的渣滓内容了,这个简略咱们只需反省包括汉字就能够了,还有时咱们心愿有些敏感字不让提交,只需一个简略的过滤函数即可.
有很多冤家可能会发现有大量的英文渣滓论内容,上面给个函数,代码如下:
<?php
function scp_comment_post( $incoming_comment ) {
$pattern = '/[一-?]/u';
// 制止全英文评论
if(!preg_match($pattern, $incoming_comment['comment_content'])) {
wp_die( "You should type some Chinese word (like "你好") in your comment to pass the spam-check, thanks for your patience! 您的评论中必需蕴含汉字!" );
}
return( $incoming_comment );
}
?>function lianyue_comment_post( $incoming_comment ) {
$http = '/[href="|rel="nofollow"|http://|</a>]/u';
if(preg_match($http, $incoming_comment['comment_content'])) {
wp_die( "万恶的发贴机!" );
}
return( $incoming_comment );
}
add_filter('preprocess_comment', 'lianyue_comment_post');
心愿本文所述对大家的WordPress建站有所协助。
以上就是安达网络工作室关于《WordPress评论禁止针对指定内容全英文的方法》的一些看法。更多内容请查看本栏目更多内容!
在 PHP 中发送 Http 申请(GET / POST)有很多的办法,比方 file_get_contents() 函数、fopen() 函数或许 c...
通常咱们喜爱应用Wordpress Thread Comment 或 Mail To Commenter这两款插件前者久未更新,已测支持WordPre...
flush_rewrite_rules() 函数用来删除而后依据现有的条件重写伪动态规定,也就是刷新一次伪动态规定了。 先来...
最近做一个wordpress的企业模板,关注了一下查问次数这个货色! 在 footer.php 里增加了如下代码,以显示wo...
现在,WordPress CMS 主题越来越多,WordPress 作为 CMS 终究有那些共同的劣势,吸援用户去一直的延长扩大呢...
在WordPress中,咱们发如今写文章时,可视化模式下会对html代码进行清算,例如对<>等符号转化为html实体,对...