WordPress评论中制止HTML代码显示的办法

本文实例讲述了WordPress评论中制止HTML代码显示的办法。分享给大家供大家参考。详细剖析如下:

应用WordPress的冤家会发现假如咱们开户了博客评论会常常看到大量的渣滓广告,带衔接了,那么咱们要如何制止用户输出html标签原样输入,而不显示呢,上面我来给大家引见.

html题目无非就是由“<”、“>”组成了,咱们能够反它转换成“&lt;”、“&gt;”,这样经过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( "'", '&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', 'plc_comment_display', '', 1);
add_filter( 'comment_excerpt', 'plc_comment_display', '', 1);

心愿本文所述对大家的WordPress建站有所协助。

以上就是安达网络工作室关于《WordPress评论中禁止HTML代码显示的方法》的一些看法。更多内容请查看本栏目更多内容!

本文相关话题: WordPress 评论 禁止 HTML代码 显示 方法
版权声明:本文为 安达网络工作室 转载文章,如有侵权请联系我们及时删除。
相关文章
制止wordpress主动将半角转换为全角 制止全角和半角的转换

找到wp-includes/formatting.php文件中复制代码代码如下:// This is not a tag, nor is the texturization ...

wordpress首页文章限度显示字数的办法

办法一:应用<!--more-->标签来自在的截取字数 在模板中应用the_content()函数来打印内容,在文章中经过点击...

修正PHP脚本使WordPress阻拦渣滓评论的办法示例

阻拦英文渣滓评论 因为绝大少数的渣滓评论都是英文的,所以国际不少冤家在应用 Some Chinese Please 插件,...

WordPress伪动态和中文标签支持配置办法

WORDPRESS博客站曾经运转快一年了,在伪动态上不断很纠结,空间默许不支持伪动态,网上找了很多办法,用404...

给WordPress的编辑后盾增加提醒框的代码实例分享

WordPress 3.5 新增加了一个提醒框性能,能够创立一个提醒框,而后指向任何元素,比方下边的例子: 本文就...

处理WordPress应用CDN后博文无奈评论的谬误

comments-ajax.js在cdn缓存后,很多人遇到无奈(应用ajax)回复的成绩。对此,我之前的做法只是制止cdn缓存...

需求提交

客服服务

亿鸽在线客服系统