Posts Tagged ‘hyphens’

WordPress replaces — with –

Thursday, November 5th, 2009

I just recently upgraded my wordpress system, and now it does not show my embedded flash at all. I would be surprised, but this isn’t the first time this happens.
The last time I upgraded I found a blog post on how to fix it, but it’s been a while and I just can’t find that post any more, so I’m writing my own.

So this is the deal: I always embed my flash using the html code that SWFobject recommends:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
  <param name="movie" value="myContent.swf" />
  <!--[if !IE]>-->
  <object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">
  <!--<![endif]-->
    <p>Alternative content</p>
  <!--[if !IE]>-->
  </object>
  <!--<![endif]-->
</object>

After the upgrade, instead of my pretty flash objects I get this funky arrow in my posts:

–>

And if I look at the source, it now looks like this:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
  <param name="movie" value="myContent.swf" />
  <!--[if !IE]>&#8211;>
  <object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">
  <!--<![endif]-->
    <p>Alternative content</p>
  <!--[if !IE]>&#8211;>
  </object>
  <!--<![endif]-->
</object>

Apparently wordpress replaces
<!–[if !IE]>>
with
<!–[if !IE]>&#8211;>, but when I look into my post to edit it, it still looks fine there.

The reason is that wordpress is trying to make your writing prettier, even if you don’t use the wysiwyg editor. To stop wordpress from doing that, go into your wordpress directory and edit the file wp-includes/formatting.php. On lines 55 and 56 (for version 2.8.5) you should see this text:

$static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn&#8211;', '...', '``', ''s', '''', ' (tm)'), $cockney);
$static_replacements = array_merge(array('&#8212;', ' &#8212; ', '&#8211;', ' &#8211; ', 'xn--', '&#8230;', $opening_quote, '&#8217;s', $closing_quote, ' &#8482;'), 

If not, just look for it, it should be in the top page or two.
Now all you have to do is comment out the array elements you don’t want wordpress to replace. My lines look like this:

$static_characters = array_merge(array(/*'---', ' -- ', '--', ' - ', */'xn&#8211;', '...', '``', ''s', '''', ' (tm)'), $cockney);
$static_replacements = array_merge(array(/*'&#8212;', ' &#8212; ', '&#8211;', ' &#8211; ', */'xn--', '&#8230;', $opening_quote, '&#8217;s', $closing_quote, ' &#8482;'), 

Hope this helps.