As a general rule, I hate WordPress shortcodes. I understand their value to the end-user and have even enjoyed developing them on some recent projects; however, they’ve become a sort of mutated flu vaccine.
Created for good, they have now become a disgusting virus mimicking basic HTML and infiltrating areas they do not belong – themes.
I cringe every time I see a theme that boasts “100’s of shortcodes” or, God forbid, uses [h1][/h1] as a replacement for traditional HTML headings.
But how do we make everyone happy? How do we satisfy the developers that need their themes to be competitive in marketplaces?
How do we satisfy end-users that want to abuse shortcodes without having hundreds of pages or thousands of posts break when switching themes? How do we make shortcodes future-proof?
The answer? A Plugin! I have seen a very pleasant trend within the ThemeForest marketplace of developers creating plugins – ZillaShortcodes or Symple Shortcodes – to house the shortcode functionalities for their themes. Love that approach; however, I would like to take this one step further.
A Vision For The Mad Revolution
I have a dream, theme developers and end-users can live in shortcode harmony with the use of a single plugin. This plugin would contain hundreds – nay, thousands – of shortcodes! Every possible shortcode an end-user could demand!
For Developers
To integrate shortcodes into themes using this plugin, a theme developer would only have to:
- require the plugin
- add support for the shortcodes they desired
- style their outputs.
[php]
// Check to see if the plugin is installed. If it is, adds support for the desired shortcodes. If not, it prompts the user to download from repository
if ( function_exists( ‘plugin_specific_function’ ) ) {
add_shortcodes_to_theme(‘toggles’, ‘columns’, ‘buttons’, ‘dialog box that jumps in from the top-right corner and exits through your screen, that’s right, through your screen’)
} else {
add_thickbox(); // Required for the plugin install dialog.
function plugin_install_notice() { ?>
<div class="updated">
<p><?php _e("This theme uses a shortcode plugin to generate shortcodes.", ‘cudathemes’); ?><a href="<?php echo admin_url(‘plugin-install.php?tab=plugin-information&plugin=our-cool-plugin&TB_iframe=true&width=640&height=517’); ?>" class="thickbox onclick"><?php _e("Install Now", ‘cudathemes’); ?></a></p>;
</div>
<?php
}
add_action(‘admin_notices’, ‘plugin_install_notice’);
}
[/php]
For End-Users
When an end-user activates their theme and downloads the plugin, the shortcodes defined by the developer will be accessible within a shortcode generator.
Future-Proofing
When switching themes, what if the developer of the new theme doesn’t add support for a shortcode that has been previously used?
Easy! Have an admin settings page that lets the user manually activate any of the shortcodes available within the plugin. This would allow the functionality to be output with very generic styling that can be overridden with style changes to the new child theme.
Thoughts?
Like the title suggests, this is just my “mad” solution for something I see as an annoying problem. I would love to hear some different ideas or ways others are working with the shortcodes madness.
13 Comments