Top

Why I Loathe Shortcodes

September 28, 2011

The other day I was reminded of why I absolutely loathe shortcodes. We were working on a pretty big client project involving a bunch of high profile blogs in a network install. The original solutions were less than optimal to say the least, so we’re hitting interesting things all the time. And by interesting I mean bloody stupid nonsense, obviously.

Which brings me back to why I loathe shortcodes. Not the gallery shortcode, of inserting all your images in a fancy thumbnail gallery fame, that one’s ok. My problem is with theme and plugin specific shortcodes.

Why, you might ask?

Man, look at my fancy quote, I’m so clever I get to quote myself!

Think about it. Let’s say you’re using a theme where you insert a fancy pull-quote using a shortcode. You’re happy and everything is dandy, until you find a new theme and make the switch. You’ve got your regular header images, widget areas and whatnot to get up and running, and then everything is dandy again, with a fancy new design, right?

Wrong! Your shortcodes from the previous theme won’t output those fancy blockquotes, because that feature were located in the previous theme. Instead you get the actual shortcode

[pullquote align="right"]Man, look at my fancy quote, I’m so clever I get to quote myself![/pullquote]

in all its glory. Not particularly pretty, is it?

This particular shortcode would be easy to fix however. Just copy the part about the pullquote shortcode from your old theme’s functions.php to your new one. Voila, pretty pull-quotes again, albeit with some extra work. You might want to stick this feature in a plugin instead, to keep your copy-pasting to a minimum every time you change themes. That way you give in to your theme-changing compulsory behavior as much as you like, and as long as your plugin is active and works well everything will be – you guessed it! – dandy.

Back to our client then. They used a plugin for adding photos to an embedded Google Map, which were included in the posts with a shortcode. Problem is, the plugin isn’t really behaving the way it should after the 3.2 update. Also, we don’t want it because it sneaks in everywhere and doesn’t feel reliable. All in all not an excellent scenario, since just removing the plugin isn’t an option when it is used all over the site, and hence the shortcode is everywhere.

I repeat: The shortcodes are everywhere!

In this case we decided to make do with the plugin, but it costs time and money. Had we had more of both we’d do our own solution and hook on to the shortcodes used by the plugin with some brilliant little thing of our own. We could also go through the database (automagically!) and clean out the shortcode, but that’s not an option here either.

Honestly, this shouldn’t have been an issue at all. It’s not like the functionality was crucial in the first place, so relying for a plugin to embed a Google Map here is questionable. Sure, they thought it’d be fun to add photos to the map, and in a way it is, but now it is costing them time and money. Knowing this I doubt they’d have this feature, and had the original developers thought in advance they’d anticipate this scenario and find a more portable solution. Unless they enjoy billing by the hour of course, in which case the more you screw over your client when it comes to future updates the better. Bad form, mates.

So what am I saying, really? Be cautious with shortcode functionality, and if you do rely on it make sure it is portable between themes and installs. Something as simple as the pull-quote feature can easily be managed, but when things get as advanced as our map plugin problem it will be harder to create independent solutions. There is a time for shortcodes I’m sure, but it definitely isn’t the most future-proof solution out there. They’re not even all that user friendly anymore, with the visual editor and its TinyMCE buttons that you should look at instead, which of course can result in the same problem in the future should you include weird code that won’t stand on its own. Your milage may vary and all that.

Just make an informed decision in these matters, that way you’ll only have yourself to blame down the road.

[tdh]out[/out]

The first portable computer photo by Stacy Lynn Baum (CC).

Because this plugin/widget is provided free of charge, I simply ask you to link back to Pressography.com in a post on your blog, or from one of your sites. It doesn't need to be anything fancy - just a note saying that you're using it, and whether or not you like it. However, there is no requirement that you do this, you're free to use the plugin regardless.

This theme is provided free of charge, provided you leave the "Wordpress Theme From Pressography.com" attribution link at the bottom of the theme.

If you want to remove the attribution link, you must pay a small, $10 license fee for each site on which you want to remove the link. Click Here For More Information

Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.