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.

Bookmark and Share

Somewhat related posts

7 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). [...]

Leave a Reply