你一定烦死讨厌的垃圾留言了吧?并且用尽了全力也无法彻底把这些垃圾清除?怎么解决呢,你可以去看看我之前的建议(如何让你的博客远离垃圾评论)或者釜底抽薪彻底去除留言中的链接,这样就不会有人来烦你了,哈哈。。。
有决心的盆友请接着往下看,我们来去除留言中的链接。打开 function.php 文件,将下面一段代码复制上去。
function plc_comment_post( $incoming_comment ) {
$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
$incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] );
return( $incoming_comment );
}
function plc_comment_display( $comment_to_display ) {
$comment_to_display = str_replace( ''', "'", $comment_to_display );
return $comment_to_display;
}
add_filter( 'preprocess_comment', 'plc_comment_post', '', 1);
add_filter( 'comment_text', 'plc_comment_display', '', 1);
add_filter( 'comment_text_rss', 'plc_comment_display', '', 1);
add_filter( 'comment_excerpt', 'plc_comment_display', '', 1);
$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
$incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] );
return( $incoming_comment );
}
function plc_comment_display( $comment_to_display ) {
$comment_to_display = str_replace( ''', "'", $comment_to_display );
return $comment_to_display;
}
add_filter( 'preprocess_comment', 'plc_comment_post', '', 1);
add_filter( 'comment_text', 'plc_comment_display', '', 1);
add_filter( 'comment_text_rss', 'plc_comment_display', '', 1);
add_filter( 'comment_excerpt', 'plc_comment_display', '', 1);
再次提醒,此代码将会去除所有留言中的链接,请慎重考虑后使用。


盘龙 February 13,2009 04:24 PM#
不错啊 。,继续加油
回复
英语作文 February 13,2009 02:59 PM#
恩 写到第九篇了 接着整吧 .
回复
辐射鱼 February 12,2009 07:29 PM#
你这标题很不河蟹啊
回复