WordPress 3.3: Stop replacing double dashes and single quotes

Mattias Geniar, Tuesday, January 3, 2012 - last modified: Wednesday, January 4, 2012

Oh boy, another update to WordPress, another set of changes to the WordPress core to prevent WordPress from changing the default double dash and single quote characters to the "pretty" HTML versions &#8217, &#8216, &#8211, &#8212, ...

When posting snippets of source code or command line arguments, having the quotes and dashes replaced makes copy/pasting the commands a pain, as your terminal won't recognise them.

So, if you want to fix that in WordPress 3.3, edit the /wp-includes/formatting.php file and go to around line 61. You'll see something like this.

function wptexturize($text) {
....
$static_characters = array_merge(...
$static_replacements = array_merge(...
$dynamic_characters = array(...
$dynamic_replacements = array(...
...
}

Right below those 4 PHP variables, add the following lines.

// Just ignore everything from above
$static_characters = array();
$static_replacements = array();
$dynamic_characters = array();
$dynamic_replacements = array();

That simply overwrites whatever WordPress had defined to be replaced, to leave it at the default HTML characters.

If you've done that above, the file should look similar to the screenshot below.

And afterwards, the dashes shouldn't be replaced anymore!



Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear!. Follow me on Twitter as @mattiasgeniar.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Inbound links