現(xiàn)在很多站長(zhǎng)喜歡使用WordPress文章評(píng)論功能,但是經(jīng)常會(huì)遇到刷垃圾廣告,這樣會(huì)對(duì)網(wǎng)站產(chǎn)生一定影響的。
想要解決這個(gè)問(wèn)題,就需要給評(píng)論添加一個(gè)間隔時(shí)間限制就可以了,今天就分享WordPress限制重復(fù)評(píng)論的間隔時(shí)間方法。
下面這段代碼就能解決:
//WordPress純代碼限制重復(fù)評(píng)論的間隔時(shí)間
add_filter('comment_flood_filter', 'suren_comment_flood_filter', 10, 3);
function suren_comment_flood_filter($flood_control, $time_last, $time_new)
{
$seconds = 90;//間隔時(shí)間
if(($time_new - $time_last) < $seconds)
{
$time=$seconds-($time_new - $time_last);
err ('評(píng)論過(guò)快!請(qǐng)'. $time.'秒后再次評(píng)論');
}
else
{
return false;
}
}
將上面代碼添加到正在使用的WordPress主題functions.php文件中即可。







