国产探花免费观看_亚洲丰满少妇自慰呻吟_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); 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安塞县| 车致| 高青县| 泾川县| 巴青县| 鄱阳县| 信阳市| 民丰县| 夹江县| 闽侯县| 稷山县| 东乡| 大兴区| 夏津县| 高雄市| 湖北省| 新宁县| 延津县| 柘城县| 闸北区| 泗水县| 淳化县| 安乡县| 潞西市| 新化县| 吴忠市| 仲巴县| 泰宁县| 荣昌县| 平原县| 南乐县| 巴南区| 桓仁| 博湖县| 平凉市| 玛纳斯县| 庆云县| 六盘水市| 湖南省| 昭通市| 西乌珠穆沁旗|