Roblog

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:

Usage

  1. First you need to download and install the plugin. Extract and upload the files from the above zip, upload them to your wp-content/plugins directory, and activate Downloads in the WordPress admin panel.
  2. Now you’ll need to edit downloads.php and edit the $path variable to reflect your local storage. I store my files in wp-content/projects, so that’s what my $path variable is set to.
  3. 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.zip
    

    Hopefully 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
    
  4. Now you’ll probably want to insert a link into a post or a page. Check the syntax section below for more details.
  5. Done!

Syntax

Downloads adds a template tag, <--download-->, that displays download links. It takes a number of variables that determine what file to display.

  1. name – Required

    The name of the project, corresponding to project_name in the above directory structure.

  2. version – Optional

    The specific version to link to. If omitted, Downloads will link to the newest version available.

  3. 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 $path variable, the version and the project name.

Confusing? Try some examples:

Code:

<!--download name="now-reading"-->

Output:

Code:

<!--download name="now-reading" version="1.0"-->

Output:

Code:

<!--download file="now-reading/files/1.0/now-reading.zip" name="now-reading" version="1.0"-->

Output:

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!