LRH Shortcode List – WP Plugin
Have you every tried to remember all the different shortcodes that WordPress offers? Then pile on top of that shortcodes made available by the different plugins, widgets and themes you use. This plugin doesn’t provide any shortcodes, but does provide a metabox for the admin post or page editor that lists all the active shortcodes.
Displayed as a scrollable list, additional information about the shortcode is displayed if available, and clicking on the insert button will insert the shortcode, along with any known parameters, into the memo. The cursor will be right where you should start typing, if parameters are needed, that would be inside the square brackets. Otherwise, the cursor will be after the open shortcode tag.
For an admin that can manage_options, a complete list of all shortcodes is accessable from the settings menu. This options dialog allows each shortcode can be individually deactivated. Deactivating will not only remove it from the metabox list, it also removes the shortcode hook. A side effect is the neat “feature’ that allows you to see what would happen to your posts and pages if a particular shortcode does ‘missing’. You can deactivate the shortcode, view the pages, and reactivate when your investigation is done.
The list is also a nice summary of what information is available about each shortcode. This additional information would include a user-friendly name, description, and the required and optional parameters. The initial release includes some of the information about the WordPress shortcodes, but at a lower than default priority, so if the WP team supplies their own information, it will take precedence.
Developers
If you are a developer, you probably want to know how to supply your shortcode information to the plugin. It’s very simple, and done through the use of filters.
You can provide addition information about your shortcode by responding to a filter ‘sim_XXX’ where XXX is your shortcode tag. The additional information can include description, is it self-closing, the required parameters, and the optional parameters.
Here is an example for the shortcode ‘snapshot’:
add_filter('sim_snapshot','filter_sim_snapshot');
function filter_sim_snapshot($information) {
$information[cSHORTCODE_NAME]='Web Site Snap Shot';
$information[cSHORTCODE_DESC]='Allows you to embed a snapshot of a web site';
$information[cSHORTCODE_SELFCLS]=true;
$information[cSHORTCODE_RPARAMS]=
array('url'=>'url of site');
$information[cSHORTCODE_OPARAMS]=
array('alt'=>'description'
,'w'=>'width'
,'h'=>'height'
);
return $information;
}
A default array is passed as a parameter, and returned with any information you can provide.
Required fields:
- tag – the shortcode tag, informational only
- name – friendly name
and optional fields:
- desc – longer friendly info
- selfcls – true if of form: [[code]], false if of form: [[code][/code]]
- rparams
- – array of required parameter names, and short-descriptions,
- each row is key of the field parameter with the data being a short description about field value
- oparams
- – array of optional parameter names and short-descriptions,
- same format as rparams
The sim_XXX filters should be registered during the ‘admin’ action, or better yet, during the ‘sim_’ action, which is only triggered if the plugin is active in admin mode.
add_action('sim_','register_shortcode_information');
function register_shortcode_information() {
add_filter('sim_caption','filter_sim_caption',5);
}
The plugin has an include file that automatically registers the WordPress ‘built-in’ shortcodes, with a lower than default priority. This allows you to easily override the filter to provide your own information.
New in 1.3.0
A new information parameter was added, to support the enhanced TinyMCE shortcodes:
$information[cSHORTCODE_TMCEENH]=true;
Version 1.3.0 can be downloaded from lrhshortcodelist_1_3_0.