欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WordPress評(píng)論禁止針對(duì)指定內(nèi)容全英文的方法

  發(fā)布時(shí)間:2014-12-26 12:02:08   作者:佚名   我要評(píng)論
這篇文章主要為大家介紹了WordPress評(píng)論禁止針對(duì)指定內(nèi)容全英文的方法,可實(shí)現(xiàn)過(guò)濾英文垃圾內(nèi)容的功能,非常實(shí)用的技巧,需要的朋友可以參考下

本文實(shí)例講述了WordPress評(píng)論禁止針對(duì)指定內(nèi)容全英文的方法。分享給大家供大家參考。具體分析如下:

WordPress評(píng)論中第一要過(guò)濾的是全英文的垃圾內(nèi)容了,這個(gè)簡(jiǎn)單我們只要檢查包括漢字就可以了,還有時(shí)我們希望有些敏感字不讓提交,只要一個(gè)簡(jiǎn)單的過(guò)濾函數(shù)即可.

有很多朋友可能會(huì)發(fā)現(xiàn)有大量的英文垃圾論內(nèi)容,下面給個(gè)函數(shù),代碼如下:

復(fù)制代碼
代碼如下:
<?php
function scp_comment_post( $incoming_comment ) {
$pattern = '/[一-?]/u';
// 禁止全英文評(píng)論
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! 您的評(píng)論中必須包含漢字!" );
}
return( $incoming_comment );
}
?>

以下代碼禁止許評(píng)論中包含 <a 隨便 href=" 或者rel="nofollow"或者h(yuǎn)ttp://,你也可以根據(jù)自己的需要修改,代碼如下:

復(fù)制代碼
代碼如下:
function lianyue_comment_post( $incoming_comment ) {
$http = '/[href="|rel="nofollow"|http://|</a>]/u';
if(preg_match($http, $incoming_comment['comment_content'])) {
wp_die( "萬(wàn)惡的發(fā)貼機(jī)!" );
}
return( $incoming_comment );
}
add_filter('preprocess_comment', 'lianyue_comment_post');

希望本文所述對(duì)大家的WordPress建站有所幫助。

相關(guān)文章

最新評(píng)論