Downloads
Downloads is a rather simple plugin that lets you easily offer downloads of files from WordPress posts and pages. Written for this site out of necessity, you can see examples on all my project pages and right here:
Download Downloads (Version 1.5)
Downloads has been downloaded 1,383 times.
Usage
- First you need to download and install the plugin. Extract and upload the files from the above
zip, upload them to yourwp-content/pluginsdirectory, and activate Downloads in the WordPress admin panel. - Now you’ll need to edit
downloads.phpand edit the$pathvariable to reflect your local storage. I store my files inwp-content/projects, so that’s what my$pathvariable is set to. Next, you’ll need to set up that particular directory, which is where you’re going to store your files. It’s pretty simple:
wordpress_directory + path_directory + project_name + files + version + project_name.zipHopefully that doesn’t look too complex! Here’s an example of what mine looks like:
wordpress + wp-content + projects + now-reading + files + 3.3 + now-reading.zip- Now you’ll probably want to insert a link into a post or a page. Check the syntax section below for more details.
- Done!
Syntax
Downloads adds a template tag, <--download-->, that displays download links. It takes a number of variables that determine what file to display.
name – Required
The name of the project, corresponding to
project_namein the above directory structure.version – Optional
The specific version to link to. If omitted, Downloads will link to the newest version available.
filename – Optional
The full filename of the file to download. In almost every case you can simply omit this, and Downloads will work out the filename based on the
$pathvariable, the version and the project name.
Confusing? Try some examples:
Code:
<!--download name="now-reading"-->
Output:
Download Now Reading (Version 4.4.3)
Now Reading has been downloaded 35,496 times.
Code:
<!--download name="now-reading" version="1.0"-->
Output:
Download Now Reading (Version 1.0)
Now Reading has been downloaded 35,496 times.
Caution: this is an old version of Now Reading. The newest version is 4.4.3.
Code:
<!--download file="now-reading/files/1.0/now-reading.zip" name="now-reading" version="1.0"-->
Output:
Download Now Reading (Version 1.0)
Now Reading has been downloaded 35,496 times.
Caution: this is an old version of Now Reading. The newest version is 4.4.3.
Advanced
Downloads also supports a couple of nifty API functions that might be useful.
MD5
By passing downloads.php a filename and an action of md5, Downloads will display the MD5 hash of that particular file. Try it!
Version Checking
By passing downloads.php a project name and an action of getlatest, Downloads will display the latest version of that project. Try it!