Smart quotes in WP

I didn't like the way WP is adding smart qoutes to my posts. This is especially annoying when you post programming code. So it had to go :-\
I couldn't find an option to disable smart-quoting in the WordPress back-end so I took a look at the code and commented a few lines.

The commented lines were in
/wp-include/functions-formatting.php
in the wptexturize() function
right after the cockney conversions.

/*
$curl = preg_replace("/'s/", '’s', $curl);
$curl = preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl);
$curl = preg_replace('/(\s|\A|")\'/', '$1‘', $curl);
$curl = preg_replace('/(\d+)"/', '$1″', $curl);
$curl = preg_replace("/(\d+)'/", '$1′', $curl);
$curl = preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl);
$curl = preg_replace('/(\s|\A)"(?!\s)/', '$1“$2', $curl);
$curl = preg_replace('/"(\s|\S|\Z)/', '”$1', $curl);
$curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl);
$curl = preg_replace("/ \(tm\)/i", ' ™', $curl);
$curl = str_replace("''", '”', $curl);
*/

In this code snippet, the conversion of (tm) into ™ was also disabled, this is the line before the last one. Feel free to keep it your code, it was just easier to comment out the whole block.

This entry was posted on Monday, March 7th, 2005 and is filed under WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

11 Responses to “Smart quotes in WP”

  1. Matt Fletcher Says:

    That is useful to know, thanks. The approach I took was to write a plugin to do the job. You can download it from http://www.matt-fletcher.co.uk/index.php/2005/02/04/strip-smart-quotes/

  2. Denis de Bernardy Says:

    Neither solution is OK. Leaving quotes in the xml will produce errors. You need to leave at least one filter, to change the quote marks into ".

  3. stuart Says:

    This doesn’t work. Smart Quotes need another solution.

  4. Tickled to Death » Blog Archive » Dumb Quotes Says:

    [...] I don’t see what’s so horrible about Basic ASCII that WordPress had to add “smart quotes” and whatnot.  Under your WordPress installation, in wp-includes/functions-formatting.php, there’s a “wptexturize” method that has several preg_replace’s that change your single- and double-quotes into extended set (unicode even?) characters that perhaps look a bit more professional but also aren’t represented in every font out there.  I hadn’t noticed as Bitstream Vera handles them just fine, but in the interests of globalization, I went ahead and commented out that bit of code. Thanks to a phpied.com post for this information and a commenter for pointing out WP’s folly. [...]

  5. Mashup Guide :: Fixing smart quote problem in WordPress Says:

    [...] phpied.com » Blog Archive » Smart quotes in WP [...]

  6. amanda Says:

    This is the official “right way” to address this stuff, at least in 2.x:

    http://wordpress.org/support/topic/125038

    You want something like:
    remove_filter(‘the_content’, ‘wptexturize’);

    in your “functions.php”

  7. Data Unbound » Changing various annoying aspects of WordPress Says:

    [...] One way to change this behavior is to edit some of the WordPress source code (the first issues could be resolved by edits described in WordPress Editor Fix to Stop Stripping or Changing Code and the second, by changes shown in phpied.com » Blog Archive » Smart quotes in WP). [...]

  8. Svetoslav Says:

    It seems that filter should be removed from the comments as well.

  9. Successfully migrated this blog to a VPS | Svetoslav Marinov's Blog Says:

    [...] http://www.phpied.com/smart-quotes-in-wp/ [...]

  10. Smart quotes in WP phpied com | Paid Surveys Says:

    [...] Smart quotes in WP phpied com Posted by root 1 day 15 hours ago (http://www.phpied.com) Feel free to keep it your code it was just easier to comment out the whole block phpied com is proudly powered by wordpress Discuss  |  Bury |  News | Smart quotes in WP phpied com [...]

  11. rss submission Says:

    I just like the valuable info you supply on your articles. I?ll bookmark your weblog and test once more right here regularly. I am rather certain I will be told many new stuff proper right here! Good luck for the next!

Leave a Reply