当前位置:网站首页 > WordPress教程 > 正文
怎么禁用 WordPress 评论里的HTML标记
作者:xlnxin发布时间:2021-04-15分类:WordPress教程浏览:340
导读:相信大部分WP博主都知道,WordPress默认的评论可以包括各种HTML标记语言,如超链接、加粗加斜、表单等等,这是一个不错的支持功能,但又是一个很坏的支持功能,因为...
相信大部分WP博主都知道,WordPress 默认的评论可以包括各种HTML标记语言,如超链接、加粗加斜、表单等等,这是一个不错的支持功能,但又是一个很坏的支持功能,因为这个功能在评论友好的同时也把垃圾评论留言招引来了,受过垃圾评论迫害的博主都知道垃圾留言的麻烦。所以有时候禁用 wordpress 评论里的HTML标记是非常有必要的。
禁用 wordpress 评论的HTML标记:
在博客当前使用的主题模板中的functions.php文件(如果没有就自己创建一个)中的<?php和?>之间添加以下代码:
// 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; |
保存文件后,WP评论里的HTML标记就会失效。
相关推荐
- 微信小程序function函数arguments 是什么意思呢?
- 小程序和H5中canvas卡顿的性能优化方向和实践
- 微信小程序反编译报SyntaxError: Unexpected token ‘}‘ 不完美的解决方法
- 解决小程序反编译出现 app-service.js
- PHP把textarea中的回车换行替换为br
- zblogphp使用GetArticleList、GetList函数调用热门文章列表
- expose_php = On/Off,是干什么的?底层原理是什么?
- 淘宝给大家发6.5元新年购物红包啦,不要嫌少还有很多优惠,快来领取吧!
- Windows10 DVDRW识别为CD驱动解决方法,windows无法读取驱动器E:\中的光盘解决方法
- windows无法读取驱动器中的光盘(windows10)
- WordPress教程排行
- 最近发表