and like us on FB

When we first started to submit the odd plugin to the WordPress plugin repository, we needed a means of providing an enhanced download link from our website. The answer came by way of a little download box with information sourced via the WordPress API. We wanted to include a title, basic description, download link, version details, and download count – and WP’s API provides this. This article will provide you with the necessary WordPress shortcode that’ll render an information download box in your WordPress page or post.

The result of our code is as follows:

Plugin Title: Simple Audio Player Author: beliefmedia
Description: Simple Audio Player is a highly configurable and lightweight audio player. Numerous options can very easily…
Download (downloaded 36,206 times) | Plugin Page

The shortcode I used to generate this specific information was as follows: [bmplugin name="simple-audio-player"].

There’s a large amount of data returned via the WP API. To avoid hogging realestate we’ve added the update time and tested version text to the Download and Plugin Page links as link titles.

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.

The image I’ve used can be downloaded from here. Alter it in your shortcode along with the background color and border style.

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

name

The name of your plugin is the only attribute that is required. While the plugin name is generally accepted, the plugin slug is preferred to avoid errors.

title

The title is optional. By default, the plugin title as used in the WordPress repository will be used. To use your own use title="my title in here".

description

The description is optional. By default, the plugin title as used in the WordPress repository will be used. To use your own use description="my description in here".

author

The author name and link will be rendered alongside your plugin title. To remove, use author="0" or alter your shortcode function.

n

By default we’ll return your download count using PHP’s number_format() function. If you choose not return the count in this manner, use n="0" or alter the shortcode function.

trim

We trim the description to 16 words. To change, alter the shortcode function, or use in your shortcode as trim="25". It’s used so long descriptions don’t run longer than is aesthetically pleasing.

image

Your own image should be used. Hard-code it into the shortcode function.

bgcolor

Alter the bgcolor with bgcolor="#ffffff" or code a permanent change into the shortcode function.

border

Alter the border with border="#000000" or code a permanent change into the shortcode function.

cache & cache_error

The cache time refers to the time the result is cached. The cache_error time refers to the time you’ll cache an error message before trying again.

PHP Function

The following PHP function may be used outside of WordPress. The primary differences are detailed below. Usage requires Simple Cache With PHP.

The primary difference between this and the WP version is that we truncate the description text to a character length – not a word count. If our means of truncation doesn’t agree with you, select an alternative function here.

Considerations

  • You don’t need to have anything to do with any of the plugins to be able to retrieve and display the data, making it an effective way of displaying information on review sites and blogs.
  • For inactive plugins, consider using a longer cache period to avoid repeated requests to the WordPress API.
  • A collection of the APIs used on the WordPress website are available here .

Download

Title: Display a WordPress Plugin Download Box
Description: Display a WordPress Plugin Download Box with Links and Download Count.
Download: Shortcode (V0.2) | WP Plugin (V0.2) | PHP Code (V0.2)

Shortt URL for this post: http://shor.tt/1Q18