本文实例讲述了WordPress评论中制止HTML代码显示的办法。分享给大家供大家参考。详细剖析如下:
应用WordPress的冤家会发现假如咱们开户了博客评论会常常看到大量的渣滓广告,带衔接了,那么咱们要如何制止用户输出html标签原样输入,而不显示呢,上面我来给大家引见.
html题目无非就是由“<”、“>”组成了,咱们能够反它转换成“<”、“>”,这样经过HTML编译,主动变成了“<”、“>” 咱们也能够间接交换掉了
找到一国外人的代码,搞定了,不过不肯定他是原作者,在functions.php的PHP代码里退出如下代码:
//禁用wordpress评论html代码
// 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;
}
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);
心愿本文所述对大家的WordPress建站有所协助。
以上就是安达网络工作室关于《WordPress评论中禁止HTML代码显示的方法》的一些看法。更多内容请查看本栏目更多内容!
本文实例讲述了WordPress完成回复文章评论后发送邮件告诉的性能。分享给大家供大家参考,详细如下: 很多时...
随着 WordPress 一版一版的晋级,性能越来越多,代码量也越来越宏大,对 WordPress 速度慢的埋怨声也越来越...
本文实例讲述了WordPress站点呈现404谬误时邮件告诉治理员的办法。分享给大家供大家参考。详细剖析如下: 这...
露兜博客首页的访客可自行抉择文章排序形式的成果是怎样做的,明天就来给大家分享这个文章排序成果的完成进...
关于伪动态的成绩,置信用 WordPress 的冤家都会很相熟 WP-Cache 这款插件了,不只由于它出众的功能使其简直...
很多冤家都在应用Wordpress写集体博客,然而又想把写的博客文章同步到其余的社交网站上,比方人人网,那怎样...