Disable double hyphen to dash wordpress replacements

wordpress logoAs we know latest wordpress.org blog publishing system includes feature that allows to replace double hyphens into single dash: — into — or –. It’s rather trivial issue but Linux Screw blog contains a lot of shell code examples like sudo apt-get remove mc --purge and I was wondering how to disable it for a long time 🙂

To disable this you should edit /wp-includes/formatting.php:

  • to disable only replacement — into —, just remove ‘–‘ and ‘ — ‘ from the following line:
    $static_characters = array_merge(array('---', ' -- ', '--', 'xn–', '...', '``', '\'s', '\'\'', ' (tm)'), $cockney);
    and remove second and third elements from:
    $static_replacements = array_merge(... line.
  • to disable any characters replacements made by wordpress you can comment the following lines:
    $curl = str_replace($static_characters, $static_replacements, $curl);
    $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
    In other words, after commenting they should look like:
    //$curl = str_replace($static_characters, $static_replacements, $curl);
    //$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

Hope it helps!

SHARE:
nv-author-image

Stefan Durand

My name is Stefan, I'm the admin of LinuxScrew. I am a full-time Linux/Unix sysadmin, a hobby Python programmer, and a part-time blogger. I post useful guides, tips, and tutorials on common Linux and Programming issues. Feel free to reach out in the comment section.

Leave a Reply

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