wordpress
发布时间:2022-05-06 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了WordPress评论中禁止HTML代码显示的方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了wordpress评论中禁止HTML代码显示的方法。分享给大家供大家参考。具体分析如下:
使用wordpress的朋友会发现如果我们开户了博客评论会经常看到大量的垃圾广告,带连接了,那么我们要如何禁止用户输入html标签原样输出,而不显示呢,下面我来给大家介绍.
html标题无非就是由“<”、“>”组成了,我们可以反它转换成“<”、“>”,这样通过HTML编译,自动变成了“<”、“>” 我们也可以直接替换掉了
找到一国外人的代码,搞定了,不过不一定他是原作者,在functions.PHP的PHP代码里加入如下代码:
phpcode1">//禁用
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 c
Annot 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',1
); add_filter( 'comment_excerpt',1
);
本图文内容来源于网友网络收集整理提供,作为学习参
考使用,版权属于原作者。
@H_
675_33@@H_
675_33@
大佬总结
以上是大佬教程为你收集整理的WordPress评论中禁止HTML代码显示的方法全部内容,希望文章能够帮你解决WordPress评论中禁止HTML代码显示的方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。