默认的WordPress评论可以包含好几种标记语言,可以添加链接、文本样式(粗体、斜体)、表单等等。这些都是非常实用的,但是垃圾留言要是找上门来就麻烦了。
你可以通过禁用WordPress评论区中的HTML功能来阻止垃圾信息。方法很简单,打开你的functions.php文件并添加下列代码:
// This will occur when the comment is posted
function plc_comment_post( $incoming_comment ) {
// convert everything in a comment to display literally
$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
// the one exception is single quotes, which cannot be #039; because WordPress marks it as spam
$incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] );
return( $incoming_comment );
}
// This will occur before a comment is displayed
function plc_comment_display( $comment_to_display ) {
// Put the single quotes back in
$comment_to_display = str_replace( ''', "'", $comment_to_display );
return $comment_to_display;
或者你也可以从这里下载原始的插件。
* 版权声明:作者WordPress啦! 转载请注明出处。
发表新评论