bbPress : 画像を貼り付けられる様にする

には標準で画像を添付する事ができません。
つまり、imgタグなどが使えないって事です。

それを使えるようにする方法が紹介されていました。

方法は、
bb-includes/formatting-functions.php の
58行目あたり、function encode_bad( $text ) 以下に

CODE:
  1. $text = preg_replace('|&lt;(/?img.*?)&gt;|', '<$1>', $text);

を追加します。

PHP:
  1. function encode_bad( $text ) {
  2.     $text = wp_specialchars($text);
  3.     $text = preg_replace('|&lt;(/?strong)&gt;|', '<$1>', $text);
  4.     $text = preg_replace('|&lt;(/?em)&gt;|', '<$1>', $text);
  5.     $text = preg_replace('|&lt;(/?a.*?)&gt;|', '<$1>', $text);
  6.     $text = preg_replace('|&lt;(/?ol)&gt;|', '<$1>', $text);
  7.     $text = preg_replace('|&lt;(/?p)&gt;|', '<$1>', $text);
  8.     $text = preg_replace('|&lt;br /&gt;|', '<br />', $text);
  9.     $text = preg_replace('|&lt;(/?ul)&gt;|', '<$1>', $text);
  10.     $text = preg_replace('|&lt;(/?li)&gt;|', '<$1>', $text);
  11.     $text = preg_replace('|&lt;(/?blockquote.*?)&gt;|', '<$1>', $text);
  12.     $text = preg_replace('|&lt;(/?code)&gt;|', '<$1>', $text);
  13.  
  14.     $text = preg_replace("|`(.*?)`|se", "'<code>' . encodeit('$1') . '</code>'", $text);
  15.     $text = preg_replace('|&lt;(/?img.*?)&gt;|', '<$1>', $text);
  16.     return $text;
  17. }

次に、87行目あたり function bb_allowed_tags() { 以下に

CODE:
  1. 'img' => array(
  2.         'src' => array(),
  3.         'alt' => array(),
  4.         'title' => array()),

を追加します。

PHP:
  1. function bb_allowed_tags() {
  2.     $tags = array(
  3.         'a' => array(
  4.             'href' => array(),
  5.             'title' => array(),
  6.             'rel' => array()),
  7.         'blockquote' => array('cite' => array()),
  8.         'br' => array(),
  9.         'code' => array(),
  10.         'em' => array(),
  11.         'strong' => array(),
  12.         'ul' => array(),
  13.         'ol' => array(),
  14.         'li' => array()
  15.  
  16.         'img' => array(
  17.         'src' => array(),
  18.         'alt' => array(),
  19.         'title' => array()),
  20.  
  21.     );
  22.     return apply_filters( 'bb_allowed_tags', $tags );
  23. }

これで imgタグ が使えるようになるはずです。
ちなみに、0.73で試しました。

動作デモは、

画像テスト « WordPress Plugin DB Japan

ネタ元
bbPress Img Tag Add On « Talkabout Design - Community

Related posts

0 Responses to “bbPress : 画像を貼り付けられる様にする”


  1. No Comments

Leave a Reply





Facebooked
Ranting Daily
Loopy Red
Pink for October
Pigments
T1
Saur
Love