{"id":117,"date":"2009-07-24T20:50:14","date_gmt":"2009-07-25T00:50:14","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=117"},"modified":"2014-08-09T21:39:07","modified_gmt":"2014-08-10T01:39:07","slug":"disable-wordpress-conversion-of-double-dashes-in-posts","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2009\/07\/24\/disable-wordpress-conversion-of-double-dashes-in-posts\/","title":{"rendered":"Disable WordPress conversion of double-dashes in posts"},"content":{"rendered":"<p><strong>Update (2014-08-09)<\/strong>: Still works for WordPress 3.9.2.<\/p>\n<p><strong>Update (2013-11-16)<\/strong>: Still works for WordPress 3.7.1.<\/p>\n<p><strong>Update (2012-07-26)<\/strong>: Updated for WordPress 3.4.1.<\/p>\n<p><strong>Update (2012-02-03)<\/strong>: Updated for WordPress 3.3.1.<\/p>\n<p><strong>Update (2011-08-21)<\/strong>: Updated for WordPress 3.2.1.<\/p>\n<p><strong>Update (2009-08-16)<\/strong>: Updated for WordPress 2.8.3.<\/p>\n<p>If you use WordPress (like this blog and many hundreds and thousands of blogs) for your blogging engine and you attempt to post code or programming related posts, you may find that <a href=\"http:\/\/www.compdigitec.com\/labs\/2009\/05\/15\/disable-annoying-update-manager-behaviour-in-ubuntu\/comment-page-1\/#comment-4381\">WordPress will mess up your code<\/a>. This was pointed out to us by a commenter on the aforementioned page. Out of the side, the <a href=\"http:\/\/www.tech-recipes.com\/rx\/1865\/wordpress_stop_replacing_double_dash_em_dash\/\" rel=\"nofollow\">guide at Tech-Recepies<\/a> <strong>will <em>not<\/em> work<\/strong> as the mentioned line of code no longer exists in WordPress.<\/p>\n<p>This guide has been tested with WordPress 2.7.1, 2.8.3, 3.3.1, 3.4.1, 3.5, 3.7.1, and 3.9.2 (latest).<\/p>\n<p><b>WordPress 3.9.2, 3.7.1, 3.5, and 3.4.1<\/b><br \/>\nApply this <a href=\"\/labs\/files\/formatting341.diff\">diff<\/a> to wp-includes\/formatting.php like so:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">patch formatting.php formatting.diff<\/pre>\n<p>Manual patching: replace lines 73 and 74 of &#8220;wp-includes\/formatting.php&#8221; with these two lines:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\t\t$static_characters = array_merge( array( \/*'---', ' -- ', '--', ' - ', 'xn&amp;#8211;',*\/ '...', '``', '\\'\\'', ' (tm)' ), $cockney );\r\n\t\t$static_replacements = array_merge( array( \/*$em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', *\/'&amp;#8230;', $opening_quote, $closing_quote, ' &amp;#8482;' ), $cockneyreplace );\r\n<\/pre>\n<p><strong>WordPress 3.3.1<\/strong><br \/>\nApply this <a href=\"\/labs\/files\/formatting331.diff\">diff<\/a> to wp-includes\/formatting.php like so:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">patch formatting.php formatting.diff<\/pre>\n<p>Manual patching: replace lines 56 and 57 of &#8220;wp-includes\/formatting.php&#8221; with these two lines:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\t\t$static_characters = array_merge( array(\/*'---', ' -- ', '--', ' - ', 'xn&amp;#8211;',*\/ '...', '``', '\\'\\'', ' (tm)'), $cockney );\r\n\t\t$static_replacements = array_merge( array(\/*$em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--',*\/ '&amp;#8230;', $opening_quote, $closing_quote, ' &amp;#8482;'), $cockneyreplace );\r\n<\/pre>\n<p><strong>WordPress 3.2.1<\/strong><br \/>\nYou can apply this <a href=\"\/labs\/files\/formatting.diff\">diff<\/a> to wp-includes\/formatting.php like so:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">patch formatting.php formatting.diff<\/pre>\n<p>Or you can patch it manually with the following directions:<\/p>\n<ol>\n<li>Download <strong><em>&lt;blog path here&gt;<\/em><\/strong>\/wp-includes\/formatting.php from your webserver (using something like FTP or SSH). Don&#8217;t navigate to the page and try to use &#8220;Save Page As&#8221;, it won&#8217;t work.<\/li>\n<li>Open formatting.php with a text editor, preferably with the ability to navigate to specific lines (<a href=\"\/labs\/2008\/08\/28\/geany-the-ultimate-ide-for-programming\/\">such as Geany<\/a>, which also displays the line numbers beside each line).<\/li>\n<li>Go to line 52\/53 and find this:<\/li>\n<li>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n$static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn\u2013', '...', '``', '\\'\\'', ' (tm)'), $cockney);\r\n$static_replacements = array_merge(array('\u2014', ' \u2014 ', '\u2013', ' \u2013 ', 'xn--', '\u2026', $opening_quote, $closing_quote, ' \u2122'), $cockneyreplace);\r\n<\/pre>\n<\/li>\n<li>Replace it with this:\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n$static_characters = array_merge(array(\/*'---', ' -- ', '--', ' - ', 'xn\u2013',*\/ '...', '``', '\\'\\'', ' (tm)'), $cockney);\r\n$static_replacements = array_merge(array(\/*'\u2014', ' \u2014 ', '\u2013', ' \u2013 ', 'xn--',*\/ '\u2026', $opening_quote, $closing_quote, ' \u2122'), $cockneyreplace);\r\n<\/pre>\n<\/li>\n<li>Save and re-upload to web server.<\/li>\n<\/ol>\n<p><strong>Instructions (2.x)<\/strong><\/p>\n<ol>\n<li>Download <strong><em>&lt;blog path here&gt;<\/em><\/strong>\/wp-includes\/formatting.php from your webserver (using something like FTP or SSH). Don&#8217;t navigate to the page and try to use &#8220;Save Page As&#8221;, it won&#8217;t work.<\/li>\n<li>Open formatting.php with a text editor, preferably with the ability to navigate to specific lines (<a href=\"\/labs\/2008\/08\/28\/geany-the-ultimate-ide-for-programming\/\">such as Geany<\/a>, which also displays the line numbers beside each line).<\/li>\n<li>(<em>2.7.1 only<\/em>)<\/li>\n<li>Navigate\/browse to line 47\/48 and find the following code:<\/li>\n<li><span style=\"color: #0000bb;\"> $static_characters <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #dd0000;\">&#8216;&#8212;&#8216;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\u00a0&#8212;\u00a0&#8216;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&#8211;&#8216;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;xn&amp;#8211;&#8217;<\/span><span style=\"color: #007700;\">,<\/span><span style=\"color: #dd0000;\">&#8216;&#8230;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&#8220;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\\&#8217;s&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\\&#8217;\\&#8221;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\u00a0(tm)&#8217;<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockney<\/span><span style=\"color: #007700;\">);<\/span><span style=\"color: #007700;\"><br \/>\n<\/span><span style=\"color: #0000bb;\">$static_replacements <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8212;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\u00a0&amp;#8212;\u00a0&#8216;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8211;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;xn--&#8216;<\/span><span style=\"color: #007700;\">,<\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8230;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8220;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8217;s&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8221;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\u00a0&amp;#8482;&#8217;<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockneyreplace<\/span><span style=\"color: #007700;\">);<\/span><\/li>\n<li>(<em>2.8.3 only<\/em>)<\/li>\n<li>Browse to line 55\/56 and find the following code:<\/li>\n<li><code><span style=\"color: #000000;\"><br \/>\n<span style=\"color: #0000bb;\">$static_characters <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #dd0000;\">'---'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0--\u00a0'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'--'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0-\u00a0'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'xn&amp;#8211;'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'...'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'``'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\\'s'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\\'\\''<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0(tm)'<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockney<\/span><span style=\"color: #007700;\">);<br \/>\n<\/span><span style=\"color: #0000bb;\">$static_replacements <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #dd0000;\">'&amp;#8212;'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0&amp;#8212;\u00a0'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'&amp;#8211;'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0&amp;#8211;\u00a0'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'xn--'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'&amp;#8230;'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #0000bb;\">$opening_quote<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'&amp;#8217;s'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #0000bb;\">$closing_quote<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0&amp;#8482;'<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockneyreplace<\/span><span style=\"color: #007700;\">);<br \/>\n<\/span><br \/>\n<\/span><br \/>\n<\/code><\/li>\n<li>(<em>end version specific instructions<\/em>)<\/li>\n<li>Once you have found the aforementioned lines of code, comment out the first four items in each array. In short, replace the above two lines with:<\/li>\n<li>(<em>2.7.1 only<\/em>)<\/li>\n<li><span style=\"color: #0000bb;\"> $static_characters <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #ff8000;\">\/*&#8217;&#8212;&#8216;,\u00a0&#8216;\u00a0&#8212;\u00a0&#8216;,\u00a0&#8216;&#8211;&#8216;,\u00a0&#8216;xn&amp;#8211;&#8217;,*\/<\/span><span style=\"color: #dd0000;\">&#8216;&#8230;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&#8220;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\\&#8217;s&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\\&#8217;\\&#8221;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\u00a0(tm)&#8217;<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockney<\/span><span style=\"color: #007700;\">);<\/span><span style=\"color: #007700;\"><br \/>\n<\/span><span style=\"color: #0000bb;\">$static_replacements <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #ff8000;\">\/*&#8217;&amp;#8212;&#8217;,\u00a0&#8216;\u00a0&amp;#8212;\u00a0&#8216;,\u00a0&#8216;&amp;#8211;&#8217;,\u00a0&#8216;xn--&#8216;,*\/<\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8230;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8220;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8217;s&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;&amp;#8221;&#8217;<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">&#8216;\u00a0&amp;#8482;&#8217;<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockneyreplace<\/span><span style=\"color: #007700;\">);<\/span><\/li>\n<li>\uff08<em>2.8.3 only<\/em>\uff09<\/li>\n<li><code><span style=\"color: #000000;\"><br \/>\n<span style=\"color: #0000bb;\">$static_characters <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #ff8000;\">\/*'---',\u00a0'\u00a0--\u00a0',\u00a0'--',\u00a0'\u00a0-\u00a0',\u00a0'xn&amp;#8211;',*\/ <\/span><span style=\"color: #dd0000;\">'...'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'``'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\\'s'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\\'\\''<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0(tm)'<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockney<\/span><span style=\"color: #007700;\">);<br \/>\n<\/span><span style=\"color: #0000bb;\">$static_replacements <\/span><span style=\"color: #007700;\">= <\/span><span style=\"color: #0000bb;\">array_merge<\/span><span style=\"color: #007700;\">(array(<\/span><span style=\"color: #ff8000;\">\/*'&amp;#8212;',\u00a0'\u00a0&amp;#8212;\u00a0',\u00a0'&amp;#8211;',\u00a0'\u00a0&amp;#8211;\u00a0',\u00a0'xn--',*\/ <\/span><span style=\"color: #dd0000;\">'&amp;#8230;'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #0000bb;\">$opening_quote<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'&amp;#8217;s'<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #0000bb;\">$closing_quote<\/span><span style=\"color: #007700;\">, <\/span><span style=\"color: #dd0000;\">'\u00a0&amp;#8482;'<\/span><span style=\"color: #007700;\">), <\/span><span style=\"color: #0000bb;\">$cockneyreplace<\/span><span style=\"color: #007700;\">);<br \/>\n<\/span><br \/>\n<\/span><br \/>\n<\/code><\/li>\n<li>(<em>end version specific instructions<\/em>)<\/li>\n<li>Save the file and re-upload to take effect.<\/li>\n<\/ol>","protected":false},"excerpt":{"rendered":"<p>Update (2014-08-09): Still works for WordPress 3.9.2. Update (2013-11-16): Still works for WordPress 3.7.1. Update (2012-07-26): Updated for WordPress 3.4.1. Update (2012-02-03): Updated for WordPress 3.3.1. Update (2011-08-21): Updated for WordPress 3.2.1. Update (2009-08-16): Updated for WordPress 2.8.3. If you use WordPress (like this blog and many hundreds and thousands of blogs) for your blogging [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,14],"tags":[93,326,532,158,533,152],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/117"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}