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 避免歹意评论的办法

即便你的博客治理后盾的治理员身份被人破解了,普通他也不会同时破解你的网站空间ftp账号,所以他也更改不了...

wordpress更改用户列表排序(按注册工夫排序)教程

在 WordPress 后盾,用户是依照用户名排序的,并且没有显示注册工夫,假如咱们心愿可以在后盾看到用户的注册...

wordpress获取以后文章的评论数完成代码

有时分,为了需求,是要获取wordpress以后文章的评论数,要想获取文章的评论数必需要晓得以后文章的id,怎样...

WordPress中访客登陆完成邮件提示的PHP脚本实例分享

登陆邮件提示完成办法 前提是空间有邮件性能,测试有无邮件性能的办法:登录界面点击“遗记明码”,有邮件...

wordpress自定义上传文件类型的办法

前言 家喻户晓WordPress默许支持大局部图片等文件格局的上传,但也有一些文件格局是不支持的,依据集体需求...

WordPress主题制造之模板文件的引入办法

get_template_part() 用来援用模板文件,相似于 get_header()、get_sidebar() 和 get_footer(),只不过这个...

需求提交

客服服务

亿鸽在线客服系统