and like us on FB

In the continued spirit of sharing ordinary plugins to the WordPress repository, we posted Aviation Quotes a few years ago. It’s purpose is to simply return a random aviation quote on your website. We have a growing database of quotes and the plugin was designed primarily to service a few of our own aviation websites. It’s one of a few plugins we submitted only because we used them ourselves… and WordPress provided an easy means to maintain and update them.

One of the most limiting aspects of the current setup is that we’ll indiscriminately deliver a quote – comedic, serious, or otherwise. The ability to specifically request quotes of a specific nature hasn’t yet been implemented. The same applies for quotes that might be considered NSFW.

While there’s a WordPress plugin hosted in the WP repository, we’ve also provided shortcode and a PHP function.

The Result

The shortcode of [aviationquote p="1"] in your text editor will render the following on your WordPress website (blockquote is my own formatting):

“A Pilot and a Normal Person Live Here (sign on a pilot's house).”

The p=1 is used to wrap the quote in paragraph <p> tags. If not used the quote will display inline (as follows): “If God had intended women to be pilots, he would have called the cockpit the box office.”

Display Aviation Quotes on Your Website With WordPress or PHP

WordPress shortcodes are easy to use. Even pilots can use them.

The individual receiving attribution for the quote can be formatted with standard HTML tags (if attribution exists). For example, to render the attribution text as bold and in italics, use the following: [aviationquote p="1" tags="em,strong"]. Note that the opening and closing tags aren’t used, and each html formatting instruction is separated by a comma.

“The important achievement of Apollo was demonstrating that humanity is not forever chained to this planet and our visions go rather further than that and our opportunities are unlimited.” – Neil Armstrong

We use an m-dash between the quote and attribution by default. You can alter this as follows: [aviationquote p="1" sep="~"]. The result:

“Nobody who gets too damned relaxed builds up much flying time.” ~ Ernest K. Gann, advice from the ‘old pelican’, The Black Watch, 1989

Again, the attribution will only be formatted if it is returned in the API response.

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Shortcode Attributes

The following attributes can be used.

sep

The sep is the separator between the text and the attribution. Defaults to em-dash (–).

tags

The tags applies to the attribution. Usage: tags="strong, em".

p

To wrap the text in paragraph tags, use p="1". We only built this in because of issues with WordPress that often prevents paragraph tags being applied.

offline

To display a custom message if the API is offline, use offline="your text in here".

cache_temp

If the API is offline, wait the cache_temp before making another request.

cache

The quote will be cached for the period defined by cache. We cache on our end for (usually) 20 minutes.

PHP Function

Used outside of WordPress, the following function can be used. The function requires Simple Cache.

To mimic the features of the shortcode, pass an array with ‘attributes’.

Considerations

  • The feature to submit new quotes from within your dashboard is now being tested by a few colleagues. Quotes are held for moderation and later make their way into the database.

Download

Plugin Title: Aviation Quotes Author: beliefmedia
Description: Aviation Quotes is a very simple plugin that’ll generate a random aviation quote on your website…
Download (downloaded 565 times) | Plugin Page

Title: Display Aviation Quotes on Your Website
Description: Display Aviation Quotes on Your Website With WordPress or PHP.
Download: Shortcode (V0.2) | PHP Code (V0.2) | Plugin Page

Shortt URL for this post: http://shor.tt/105q