国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > Wordpress > 正文

WordPress博客評論禁止HTML代碼顯示

2024-09-07 00:50:02
字體:
來源:轉載
供稿:網友

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

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

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

  1. //禁用wordpress評論html代碼 
  2. // This will occur when the comment is posted 
  3. function plc_comment_post( $incoming_comment ) { 
  4.  // convert everything in a comment to display literally 
  5.  $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']); 
  6.  // the one exception is single quotes, which cannot be #039; because WordPress marks it as spam 
  7.  $incoming_comment['comment_content'] = str_replace"'", '&apos;', $incoming_comment['comment_content'] ); 
  8.  return$incoming_comment ); 
  9. // This will occur before a comment is displayed 
  10. function plc_comment_display( $comment_to_display ) { 
  11.  // Put the single quotes back in 
  12.  $comment_to_display = str_replace'&apos;'"'"$comment_to_display ); 
  13.  return $comment_to_display
  14. add_filter( 'preprocess_comment''plc_comment_post''', 1); 
  15. add_filter( 'comment_text''plc_comment_display''', 1); 
  16. add_filter( 'comment_text_rss''plc_comment_display''', 1); 
  17. add_filter( 'comment_excerpt''plc_comment_display''', 1); 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乐陵市| 南京市| 泽州县| 芦溪县| 勐海县| 丽江市| 全椒县| 岳池县| 广东省| 枝江市| 商南县| 南投县| 伊金霍洛旗| 宁蒗| 洛阳市| 海口市| 云浮市| 白河县| 湘西| 米泉市| 宜兰市| 贡觉县| 潜江市| 浦东新区| 历史| 德钦县| 仙游县| 沾益县| 沽源县| 宜昌市| 措美县| 团风县| 潼关县| 汪清县| 开封县| 微博| 兴业县| 诸城市| 双柏县| 鱼台县| 巴林右旗|