Fixed WordPress problem with escaping quotes in <pre> tag
I finally got around to tracking down why wordpress is stubbornly putting a backslash against all my quotes in pre tags, i.e.,
\"text\"
The problem lies in this line of function wpautop,
preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') \. clean_pre('$2') . '</pre>' ", $pee);
The s option in !ise says to treat the input as a single line, somehow this forces " to be preceded by \. We can’t remove s option however, since the line breaks the code inserted previously won’t be removed in pre. There are a couple of ways to fix this, but the easiest would be to replace it back in function clean_pre, i.e.,
function clean_pre($text) {
...
// add
$text = str_replace('\\"', '"', $text);
return $text;
}
Took me long enough.
Leave a Reply
You must be logged in to post a comment.