最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

WordPress評論中禁止HTML代碼顯示的方法

  發(fā)布時間:2014-12-24 15:14:25   作者:佚名   我要評論
這篇文章主要為大家介紹了WordPress評論中禁止HTML代碼顯示的方法,通過增加自定義函數(shù)有效防止垃圾評論的產(chǎn)生,是非常實用的技巧,需要的朋友可以參考下

本文實例講述了WordPress評論中禁止HTML代碼顯示的方法。分享給大家供大家參考。具體分析如下:

使用WordPress的朋友會發(fā)現(xiàn)如果我們開戶了博客評論會經(jīng)常看到大量的垃圾廣告,帶連接了,那么我們要如何禁止用戶輸入html標(biāo)簽原樣輸出,而不顯示呢,下面我來給大家介紹.

html標(biāo)題無非就是由“<”、“>”組成了,我們可以反它轉(zhuǎn)換成“&lt;”、“&gt;”,這樣通過HTML編譯,自動變成了“<”、“>” 我們也可以直接替換掉了

找到一國外人的代碼,搞定了,不過不一定他是原作者,在functions.php的PHP代碼里加入如下代碼:

復(fù)制代碼
代碼如下:
//禁用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建站有所幫助。

相關(guān)文章

最新評論

鹿泉市| 广东省| 蒙阴县| 乌拉特前旗| 阿克陶县| 青神县| 湄潭县| 伊川县| 绿春县| 永定县| 资中县| 屏东县| 确山县| 工布江达县| 修文县| 祥云县| 湟源县| 长春市| 盐亭县| 普格县| 平南县| 尼玛县| 乌兰察布市| 景宁| 富锦市| 乳源| 平顶山市| 昔阳县| 金平| 瓮安县| 巢湖市| 万山特区| 泗洪县| 堆龙德庆县| 沁阳市| 荃湾区| 遂平县| 聂拉木县| 兴城市| 会东县| 海兴县|