Insults has to be one of the most pointless plugins in the WordPress repository. It was the first plugin we ever submitted to WP and was done so - like a few others - just to test the WordPress waters and get a feel for how their approval process worked. The plugin will retrieve an 'insult' from a database of thousands and return it. Simple. Like all plugins, it'll find its place somewhere.
This post will show you how to access a random insult via our API with shortcode, PHP, or with our WordPress plugin.
The Results
The result of this function will render something like this on your website:
"Some day you will find yourself -- and wish that you hadn't."
Cheesy, we know.
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.
Usage
Insert the shortcode of [insult]
wherever it is you want your insult to be rendered. The default code will cache the text for 1 hours (3600 seconds) but you can get them as often as every 6 minutes. We cache the text locally on our end for 5 minutes.
PHP Function
Used outside of WordPress, the following PHP function may be used. It requires the use of Simple Cache.
Download
The plugin version is hosted in the WordPress plugin repository.
Title: Display a Random Insult (Shortcode)
Description: Display a Random Insult on Your Website with PHP or WordPress Shortcode.
Download • Version 0.2, 923.0B, zip, Category: WordPress Shortcodes
PHP Code & Snippets, (664.0B)