Interesting WordPress Bug – Help Needed

I've encountered a small WP bug in a critical feature on the blog this morning, and since it has me baffled I thought I would post it and ask for help.

Whenever I write a review or long post, I like to add an auto-generated TOC (this one). It's a quick and easy way to add a useful feature without having to code the TOC by hand. The TOC is added by way of a shortcode which looks something like this:

[- - - ATOC - - -] (spaces added so you can see the hyphens)
[- - - TAG:h2 - - -]

Unfortunately, some time in the past week WordPress has decided that when I type in 3 hyphens what I really wanted was an mdash. (This issue may have been caused by the WP 4.0.1 security update on Thursday.)

- - - becomes ---

Yes, that is a common typography trick, but WP didn't used to muck around with shortcodes. Now WP is changing the text inside the shortcode and that broke the TOC.

I have already contacted the developer of the TOC plugin, and I am about to go complain to Automattic, but if anyone knows how I can patch this myself I would really appreciate it.

Update: A developer acquaintance of mine pointed me at a support thread on WordPress.com which explained that the broken shortcode was a known issue with that recent WP update and was the result of the plugin not being programmed correctly.  So I guess I will have to wait for the Plugin's developer to update.

Nate Hoffelder

View posts by Nate Hoffelder
Nate Hoffelder is the founder and editor of The Digital Reader: He's here to chew bubble gum and fix broken websites, and he is all out of bubble gum. He has been blogging about indie authors since 2010 while learning new tech skills at the drop of a hat. He fixes author sites, and shares what he learns on The Digital Reader's blog. In his spare time, he fosters dogs for A Forever Home, a local rescue group.

18 Comments

  1. DaveZ22 November, 2014

    Prior to whatever hit your site, I’ve been using two dashes to make an extra long dash for years… so that was indeed already present. And, as I mentioned on Twitter, I’ve been able to duplicate your results both in text and visual editors. What’s weird, I would think it should only do that if there is space on either side of the three dashes. But should not alter the text if it’s part of a longer string. Weird.

    Reply
    1. DaveZ22 November, 2014

      Of course, they have a long history of tampering with our text. If you type WordPress, it’s auto-corrected to WordPress. So who knows.

      Reply
      1. DaveZ22 November, 2014

        Ha, if you type Word press with a lower case P it goes upper case. See, they took the liberty of editing my comment for me. Matt knows best.

        Reply
        1. Nate Hoffelder22 November, 2014

          LOL. That was funny.

          Reply
    2. DaveZ22 November, 2014

      By the by, your footer ads aren’t showing. It just has in there. Is that your Amazon rollover code? If so, do this instead (without the spaces).

      Reply
      1. DaveZ22 November, 2014

        OK so that didn’t work. Even fake HTML is stripped. Will tweet you.

        Reply
      2. Nate Hoffelder22 November, 2014

        The footer ads have no rollover code. Those symbols are vestigal.

        Reply
    3. Nate Hoffelder22 November, 2014

      Yep. And I have seen the issue elsewhere

      Reply
  2. Felix22 November, 2014

    All I can tell you is that WordPress 4.0.1 breaks all shortcodes that don’t go through the standard parsing mechanism, as explained here: http://wptavern.com/wordpress-4-0-1-exposes-bad-development-practices-used-in-some-plugins — and yours appear to fall into that category. A lot of people are pissed off about it, too. The plugin author can fix it, but at the cost of changing the syntax. Which means you’d have to go back and change all posts using it. A fine mess…

    Sorry for the bad news. Can you wait for a few days and see how the story evolves?

    Reply
    1. Nate Hoffelder22 November, 2014

      Yep. An acquaintance on Twitter pointed me to the thread on wordpress.com.

      It’s interesting that the post you linked to says that this should not have been included in this update.

      Reply
      1. Kevin de Harde22 November, 2014

        The smaller plugin I just sent you does use the standard parsing mechanism Felix mentions. Hope it works out.

        Reply
        1. Nate Hoffelder22 November, 2014

          It works, thanks!

          Reply
    2. DaveZ22 November, 2014

      The issue is larger than plugin syntax. Why is WordPress rewriting what I put in the editor? I don’t have Nate’s plugin, yet three hyphens morphs into something else.

      Reply
      1. Nate Hoffelder23 November, 2014

        That kind of syntax change is not so unusual. When typewriter still ruled, you used to have to make an mdash out of hyphens, so this is kinda a holdover.

        Breaking the plugins without any need to do so, on the other hand, is best described as user-hostile programming.

        Reply
        1. DaveZ24 November, 2014

          I’m fine with concatenating three hyphens into an mdash. But it shouldn’t automatically happen if that text is part of a larger text string – only if surrounded by non breaking spaces. And I still don’t care for capitalizing that P in wordpress. At least they got rid of the smiley face tracker.

          Reply
  3. bainternet12 December, 2014

    Hi,
    as the developer of the plugin in question first let me say that its fixed and no you dont have to go over your old posts and change the syntax , so thanks.

    Now as for “shortcode not being programmed correctly”
    its not a shortcode and it never was so its not something that fall’s into the whole “bad practice shortcode development”.

    The plugin filters the content using the_content filter to add anchor tags in to the content. trust me I know the shortcode API inside out after developing my shortcodes UI plugin.

    And last, an update like that (WordPress 4.0.1) which impacts the content on the front-end of the site shouldn’t be an auto-update nor a change like that shouldn’t go live without notifying plugin and theme developers in advanced .
    The same way that JavaScript libraries updates are being notified in advance.

    Reply
    1. Nate Hoffelder12 December, 2014

      Hi,

      I saw the update a few days ago, thanks. (I also bugged you a bunch of times without a response, thanks for that as well.) I need to update this post.

      “And last, an update like that (WordPress 4.0.1) which impacts the content on the front-end of the site shouldn’t be an auto-update nor a change like that shouldn’t go live without notifying plugin and theme developers in advanced.”

      I agree with you completely. Shit like this is one of the reasons I don’t like Automattic.

      Reply
      1. bainternet12 December, 2014

        Sorry for the response time but I was in a car accident which made me “out of service” for about two weeks, But I’m ok now.

        Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top
%d bloggers like this: