垃圾评论是一件让人非常苦恼的事情,如果你没有使用任何防范措施,有你受的!倡萌之前分享的《WordPress 如何有效拦截和过滤垃圾评论》就介绍了好几种防范垃圾评论的方法,今天再补充下,自动将包含长链接的评论标记为垃圾评论。
将下面的代码添加到主题的 functions.php 文件即可:
function rkv_url_spamcheck( $approved , $commentdata ) {
return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
}
add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 ); |
function rkv_url_spamcheck( $approved , $commentdata ) {
return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
}
add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 );
注意看第二行的 50 ,根据自己的需要修改这个数值。如果你希望将所有带有链接(不管是否是长链接)的评论内容都自动标记为垃圾评论,将 50 改为 1 即可。
参考资料:http://www.wprecipes.com/automatically-spam-comments-with-a-very-long-url
来源:
https://www.wpdaxue.com/automatically-spam-comments-with-a-long-url.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33207.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57