WordPress评论中禁止HTML代码显示的方法

本文实例讲述了wordpress评论禁止HTML代码显示方法分享给大家供大家参考。具体分析如下:

使用wordpress的朋友会发现如果我们开户了博客评论会经常看到大量的垃圾广告,带连接了,那么我们要如何禁止用户输入html标签原样输出,而不显示呢,下面我来给大家介绍.

html标题无非就是由“<”、“>”组成了,我们可以反它转换成“&lt;”、“&gt;”,这样通过HTML编译,自动变成了“<”、“>” 我们也可以直接替换掉了

找到一国外人的代码,搞定了,不过不一定他是原作者,在functions.PHPPHP代码里加入如下代码:

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 cannot be #039; because wordpress marks it as spam $incoming_comment['comment_content'] = str_replace( "'",'&apos;',$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( '&apos;',"'",$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);

相关文章

我们有时候在定制WORDPRESS主题的时候,由于菜单样式的要求我...
很多朋友在做wordpree主题制作的时候会经常遇到一个问题,那...
wordpress后台的模块很多,但并不是每个都经常用到。介绍几段...
从WordPress4.2版本开始,如果我们在MYSQL5.1版本数据中导出...
很多网友会遇到这样一个问题,就是WordPress网站上传图片、附...
对于经常要在文章中出现代码的IT相关博客,安装一个代码高亮...