We’ve become accustomed to writing snippets of shortcode – both the good and bad – and publishing here on Internoetics… but we’ve generally refrained from venturing into the WordPress.org plugin realm because of the issues generally associated with the commitment that comes with continued development of anything once you release it as a more formal product. That safe distance that we’ve maintained has come to an end.
We introduced you to some shortcode last week that would render ‘This Day in History’ information on your WordPress website (utilising our little API at Hiztory.org ). The code was flawed for one reason above any other: it would only retrieve a single result. It didn’t take more than a few hours before we had people asking for something that would permit them to add multiple events. What we’ll provide on this post will provide that feature.
Although Hiztory was originally built for one of our aviation websites , and despite aviation content being a clear focus moving forward, it hasn’t detracted us form building upon the data and adding multiple other modules that relate to various interest groups or countries. Despite not having released too many of these other components into the wild (just yet), we though we’d release version 0.1 of a WordPress plugin that eases the techo-burden of displaying this and all future content on your website.
If you’re using the shortcode we’ve previously published, sadly, changing over to the plugin will require you to generate new shortcode in your posts and/or pages; it became apparent quite quickly that the options that we formerly provided weren’t the most appropriate. However, the change is advantageous. The time associated with the API request is now the time associated with your blog; we always expected to provide an option to include a GMT offset… but that isn’t necessary since we now plug into your own WordPress website’s timezone (as defined in
General). We now permit up to 15 results to be rendered on your website and have coded in a few extras that’ll permit you to offer a measure of customisation with how results are displayed.
Like any plugin that you’ve ever installed into WordPress, it can be installed in a number of different ways.
The easiest method of installation is via the ‘Install Plugins’ menu on your own WordPress blog via
Add New in the left hand menu. Search for “
hiztory“. Since it’s essentially a misspelled word, we’re the only result with that keyword. Click
Install Now… then
Of course, you could just download the zip file directly and then either upload it via the
Upload option on the ‘Install Plugin’ administration page referenced above, or you could FTP the contents into your
Once you click on
Activate, you’ll see a
Settings menu. Select it. Alternatively, you will now be able to select the
History Shortcode option from your Settings menu.
The Hiztory shortcode generator is a form that’ll construct shortcode based on the (non-default) options your select.
By clicking on
Get Shortcode at this point we’ll just generate default usage by way of nothing other than the
The default output provides us with one historical aviation event. You’ll likely want to change this!
The first 1000-bomber raid on Germany (Cologne), with four RCAF squadrons participating. One RCAF aircraft was lost in battle. - 30th May 1942
Using the shortcode generator, and as an example, we’ll generate three results that’ll be cached locally for two hours. We’ll also change the formatting of the date so it renders as
Sun 3rd Dec, 1944… and we’ll apply style to the date with html tags.
[hiztory number="3" datetags="em,strong" dateformat="D jS M, Y" cache="7200"]
You should note that the datetags, or the html formatting for the date, doesn’t include the < or > tag; this is automatically applied with the results.
The shortcode will generate the following result:
- One of the last 2 remaining ATL-98 Carvair (N898AT) crashed at Nixon Fork Mine near McGrath, Alaska. - Wed 30th May, 2007
- First flight of the Cessna Citation III - Wed 30th May, 1979
- An McDonnell-Douglas F-15C-26-MC Eagle, 79-0068, c/n 0616/C137, of the 53d Fighter Squadron, 52d Fighter Wing, Spangdahlem Air Base, Germany, crashes on take-off killing pilot Maj. Donald Lowry, Jr., 36, who dies en route to hospital. Cause was cross-connected control rods for the flaps. The U.S. Air Force, despite awareness of poorly coordinated color scheme for keeping the rods from being misconnected (identical cases in 1986 and 1991, which, fortunately, were detected before leading to accidents), subjects two mechanics to courts martial for criminally negligent homicide, punishable by four years in prison, a dishonorable discharge and forfeiture of all pay and allowances. The Air Force also engages in dirty tricks, intercepting the defendants' mail and holding it when they were contacted by a safety expert who wanted to assist them. One defendant committed suicide on 3 October 1995, the date the court martial was due to begin. On 13 November, the service, citing "justice and the interests of the Air Force", dropped its case against the other mechanic, in exchange for his decision to leave the military. Motivation for the scape-goating attempt by the service can be traced to criticism the 52d Fighter Wing received for not bringing up on charges pilots who were responsible for downing two U.S. Army helicopters over Iraq in 1994, killing 26. "The 53rd FS 'Tigers' never fully recovered from the dark blemish on their otherwise exemplary record. The only way the USAF could make the issue and the pain go away was by closing the unit. This was done on March 10, 1999, leaving USAFE with only one Eagle squadron for the next war in its theater." - Tue 30th May, 1995
Of course, you can choose not to display results in a list (as is the default case). In the next example, we’ll retrieve three historical events and format them in a block of text. By default, we’ll add the <br> tags after each event (you can change this in the option titled ‘
After post HTML‘).
[hiztory number="3" type="events" datetags="strong" returnaslist="0" dateformat="l jS M, Y" cache="7200"]
Result:Minn Twin Bert Blyleven is 2nd to win as teenager and 40 year old - Saturday 30th May, 1992
New York Lotto pays $30 million to one winner (#s are 12-15-30-33-40-48) - Saturday 30th May, 1992
69th National Spelling Bee: Wendy Guey wins spelling vivisepulture - Thursday 30th May, 1996
Retrieving Results for Another Date
By default, we’ll select the date associated with your WordPress installation in making our request to the API. At times, however, it might be necessary to render results for another arbitrary date.
By unticking the option that says “Yes, use WordPress blog time of for data requests?”, a date option appears. Keep in mind that this is a static date reference that won’t change over time.
Some other features of the shortcode generation include:
- Events relating to deaths, births, events and aviation.
- Results between 1 and 15.
- Custom separator between the content and date.
- Defined or custom date format (using PHP’s date() function).
Using Shortcode in a Sidebar?
By default, WordPress doesn’t enable the filter that permits you to use shortcode in a sidebar widget. If you plan on using this plugin, a sidebar widget is probably the most appropriate place to display random history. To enable shortcode in widgets, we’ve create a simple form that’ll activate that function globally; it works outside our plugin as well.
If you’re using our custom functions plugin, this filter is enabled by default, so you don’t have to activate it.
There are a number of RSS feeds available that generate random output for each day. They are:
The feeds can be consumed by most blogs and other CMS platforms by way of widgets and other types of integrated functionality. Certainly, in WordPress, there are countless plugins that’ll render feeds in different ways – not to mention shortcode, including our own.
The feeds are based on Australian Eastern Standard Time. If you’re elsewhere in the world, you can access a local feed using the following format:
Format is as follows: http://www.hiztory.org/[month]/[date]/[data-type].rss
We’ll build upon both the API and this plugin based almost exclusively on the feedback we receive. Some of the features that we’ll be including sooner rather than later include the following:
- Ability to render results beyond the 15 limit currently imposed.
- The API will shortly permit multiple events from multiple user defined categories (at the moment we only allow one category per request).
- Geo-specific history queries
- Additional categories (tech, marine, science, space, rail, country specific etc.).
- Keyword filtering.
As a matter of interest, the shortcode we use to build the WordPress download box (with the download count) is scheduled in late January.
Let us know what you think.
Download from WordPress.