Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: img tags


AphelionZ
Participant

@aphelionz

function outlet_encode_bad( $text ) {

$text = wp_specialchars($text);

$text = preg_replace('|<(/?strong)>|', '<$1>', $text);

$text = preg_replace('|<(/?em)>|', '<$1>', $text);

$text = preg_replace('|<(/?a.*?)>|', '<$1>', $text);

$text = preg_replace('|<(/?ol)>|', '<$1>', $text);

$text = preg_replace('|<(/?p)>|', '<$1>', $text);

$text = preg_replace('|<(/?img.*?)>|', '<$1>', $text);

$text = preg_replace('|
|', '
', $text);

$text = preg_replace('|<(/?ul)>|', '<$1>', $text);

$text = preg_replace('|<(/?li)>|', '<$1>', $text);

$text = preg_replace('|<(/?blockquote.*?)>|', '<$1>', $text);

$text = preg_replace('|<(/?code)>|', '<$1>', $text);

$text = preg_replace(“|(.*?)|se”, “‘' . encodeit('$1') . '‘”, $text);

return $text;

}

..should work, but doesn’t.

Ok, how bbPress does it is that it takes every < and > and replaces them with the &lt; and &gt; characters.

Then, it goes through the above list (the exceptions) and turns the lt’s and the gt’s back to actual <‘s and >’s. I can’t get it to recognize the img tag though, because regular expressions confuse the hell out of me. If anybody can get it to recognize the img tags, you’d be making a lot of people happy. For now I am going to take a break…

Skip to toolbar