Wordpress Simple Shortcodes
Simple Shortcodes provides an easy to use mechanism for creating and using custom shortcodes.
After installing and activating SimpleShortcodes, a Simple Shortcodes configuration item is added to your Settings menu.
From the configuration page you can create new simple shortcodes and edit and delete existing simple shortcodes.
Simple shortcodes are stored in a database table (MB_SimpleShortcodes), which contains several fields (name, value, value2, defaults, description).
Beware 1: Use unique names for your shortcodes. If you use the same shortcode name as that used by another plugin, one of the short code definitions will be overwritten by the other without any warning.
Beware 2: The names of Simple Shortcodes can only consist of letters, digits, "-" and "_".
Simple Shortcodes comes with a pre-installed shortcode - [mb_ack].
If you find Simple Shortcodes to be useful I would appreciate it if you could show your support by including the shortcode [mb_ack] on one or more of your posts or pages.
Install instructions
- Download , extract & upload the zip file content to your WordPress Plugins directory /wp-content/plugins/
- Go to your WordPress Admin Dashboard >> Plugins menu
- Activate "Simple Shortcodes"
If you are upgrading from version 0.2 you will need to deactivate Simple Shortcodes then activate Simple Shortcodes after you upgrade to modify the Simple Shortcodes database table.
Using Simple Shortcodes
After installing Simple Shortcodes go to the Settings >> Configure Simple Shortcodes page and create one or more shortcodes.
As an example enter myshortcode in the Shortcode Name text box, enter "This is boilerplate created using myshortcode." in the Shortcode Value text box (with or without the quotes), and click Save. Your new shortcode will be listed below the text boxes.
To edit an existing shortcode, click on edit, and the shortcode name and value will be placed in the textboxes ready to be edited. When done click on save.
Beware when saving shortcodes, no check is made to see if there is an exising shortcode with the same name.
To delete an existing shortcode, click on delete. Beware when deleting shortcodes as it occurs immediately without confirmation, and there is no undelete facility.
To use a shortcode in a post or page on your blog just enter the shortcode in [ ], such as [myshortcode].
Parameters
Simple Shortcodes can contain substitution parameters. For example if you define the shortcode favourites as "My favourite colour is {colour} and my favourite number is {number}.", then [favourites colour='red' number='23'] will expand to "My favourite colour is red and my favourite number is 23.".
You can define default values for your parameters using the Parameter Defaults field on the Configure Simple Shortcodes page. To define defaults for your favourites shortcode write in the Parameter Defaults field: colour='blue' number='57' :. Then if you miss a parameter the defaults will be used instead. For example [favourites] will expand to "My favourite colour is blue and my favourite number is 57.".
To include the parameter indicator character ("{") in a shortcode value, use the three character sequence {{}.
Options
There are three options which can be changed to alter the behaviour of the Configure Simple Shortcodes page. These can be altered using the form at the foot of the Configure Simple Shortcodes page.
The options are:
- Shortcode Value Input Width: The width of the shortcode value input field. Valid values are 1 to 999, but anything over 100 is probably not sensible. The default value is 45.
- Shortcode Value Input Height: The height of the shortcode value input field. Valid values are 1 to 999, but anything over 20 is probably not sensible. The default value is 1.
- Display HTML Markup on this page: Whether to display HTML Markup in the shortcodes values or not. The default value is no.
- Enable Value 2: Whether to display the Value 2 column on the Configure Simple Shortcodes page and enable Value 2 in Simple Shortcodes or not. The default value is no.
- Enable Defaults: Whether to display the Defaults column on the Configure Simple Shortcodes page and enable Defaults in Simple Shortcodes or not. The default value is no.
- Enable Descriptions: Whether to display the Description column on the Configure Simple Shortcodes page or not. The default value is no.
Before saving, all of the options are checked to ensure that they are valid. Any options which are invalid are silently changed to their default values.
Support
Support for Simple Shortcodes is available from http://michael-baker.com/simple_shortcodes/support/
History
Version 0.3, Released January 2009
Following feedback a check has been added to ensure that the names of Simple Shortcodes can only consist of letters, digits, "-" and "_", and the Configure Simple Shortcodes page has been improved.
Also added:
- A second value for Simple Shortcodes so that enclosing shortcodes can be created.
- Added parameters so substitutions can be made in Simple Shortcodes.
Version 0.2, Released 2 January 2009
Following feedback and my initial experience of using Simple Shortcodes I've made the following changes:
- Removed the 255 character limit on the size of simple shortcode values.
- Added options to change the height and width of the simple shortcode value input field.
- Added an option to display html markup in simple shortcodes on the configuration page. This will be particularly useful if any of your simple shortcodes contain unballanced html markup, such as a single </tr>. Why you'd want to do that I don't know, but you might.
- Added a test to check that the MB_SS_Handler.php can be opened for writing. This file, which contains the simple shortcode handler functions, needs to be re-written each time a simple shortcode is added, deleted or modified.
Version 0.1
For many years I've maintained the website of my friend, the world renowed marine artist, Gordon Frickers . Initially I used ppwizard and wenost to build the site. Among other things I used ppwizard to set up macros for commonly used text like phone numbers and Gordon's address.
When I set up a WordPress Blog for Gordon , I wanted to be able use a similar mechanism for such commonly used text like phone and address.
Simple Shortcodes was originally developed between Christmas and New Year in 2008.
Donate
If you find Simple Shortcodes to be useful please consider making a donation.