针对一些垃圾评论,很多人可能没有办法解决,如果你使用插件的话,那么需要注意的就是插件屏蔽垃圾评论的原理,是本地处理还是云服务处理。
这里提供一段代码,可以用来处理相关内容:
1 2 3 4 5 6 7 8 9 10 11 |
function preprocess_comment_remove_url( $commentdata ) { // Always remove the URL from the comment author's comment unset( $commentdata['comment_author_url'] ); // If the user is speaking in all caps, lowercase the comment if( $commentdata['comment_content'] == strtoupper( $commentdata['comment_content'] ) ) { $commentdata['comment_content'] = ucwords( strtolower( $commentdata['comment_content'] ) ); } return $commentdata; } |
代码方面来自官方: https://developer.wordpress.org/reference/hooks/preprocess_comment/