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):
“The only time you have too much fuel is when you're on fire.”
The p=1
is used to wrap the quote in paragraph <p> tags. If not used the quote will display inline (as follows): “The only time you have too much fuel is when you're on fire.”
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
sep
is the separator between the text and the attribution. Defaults to em-dash (--).tags
tags="strong, em"
.p
p="1"
. We only built this in because of issues with WordPress that often prevents paragraph tags being applied.offline
offline="your text in here"
.cache_temp
cache_temp
before making another request.cache
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.
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
Title: Display Aviation Quotes on Your Website (Shortcode)
Description: Display Aviation Quotes on Your Website With WordPress or PHP.
Download • Version 0.2, 1.0K, zip, Category: WordPress Shortcodes
PHP Code & Snippets, (989.0B)