This is due to the last line of wpautop():
$pee = preg_replace(‘!(<pre.*?>)(.*?)</pre>!ise’, ” stripslashes(‘$1’) . clean_pre(‘$2’) . ‘</pre>’ “, $pee);
you can fix this by:
$pee = preg_replace(‘!(<pre.*?>)(.*?)</pre>!ise’, ” stripslashes(‘$1’) . stripslahes(clean_pre(‘$2’)) . ‘</pre>’ “, $pee);
hope this helps.
Thread Starter
daath
(@daath)
It worked like a charm, thanks! Do you know if they are fixing this in coming releases?
At the risk of being pedantic, the code should read:
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
The second stripslashes was originally stripslahes. Easy typo to make. This works well for me.
Sorry chaps,
may you tell me which file to apply these changes?
If PHP had namespaces that matched the filenames, it wouldn’t be such a pain to find out what functions were in which files.
For the benefit for anyone else that finds this thread, I found the wpautop function in functions-formatting.php.
And the fix worked.
I just moved to wordpress. This is immediately the problem I encountered. The solution provided by above works for the problem of appearing backslashes. But then another problem comes: backslashes that I specifically written were removed.
It seems that the wpautop function is used for auto-formatting p tags. Since I’m hand-coding my posts’ HTML and know how to close my p’s, the best solution for me is to disable wpautop on my posts by disabling the following line in wp-includes/default-filters.php:
add_filter(‘the_content’, ‘wpautop’);