Support » Plugins » HACK: Top 10 and per-item reporting for Download Manager

  • I’ve had a number of requests for my hack of Download Manager. DM is great, but only reports in the admin panel, and the author seems to have stopped development on it. This hack allows for a top 10 list and per-post reporting. You can see it in action at my site Automator World.

    This hack is very customized to the way my site handles files; the download file names are identical to the post-slug of the post it’s attached to (e.g. if a post is titled “My Cool Download”, the filename is “”). Ergo, the reporting here depends on the filename being identical to the post-slug (post_id). If you don’t need this dependency, you can (and should) modify as need be.

    Please note: I didn’t write this hack myself, a friend did. So if you have any problems, my ability to help will be somewhat limited (but I will try to rope in my friend to assist if need be).

    Here we go:

    1) If you don’t already have it running, get Download Manager from the above URL, and get it running properly per that site’s instructions.

    2) Download dls.php (remove the “.txt”) and place it into your WordPress directory (index root is default, but you can put it anywhere).

    3) To make a “Top 10” list, insert the following code into your sidebar (make sure to replace “YOUR DOWNLOAD URL” with the same path used in Download Manager):

    $theDLs = getTopDLs(10); // modify number of items here
    foreach($theDLs as $currFile) {
    print("<a href='[YOUR DOWNLOAD URL]/?p=" . $currFile['post_id'] . "' title='" . $currFile['count'] . " downloads'>" . $currFile['title'] . "</a>");

    4) Per-post counts: Insert the following at the top of your “index.php” theme template, after <? php get_header(); ?> :

    require_once("dls.php"); // this assumes this file is in same spot as dls.php
    // if not, put the path to dls.php here

    function printDLcount($postID,$before,$after) {
    $dls = getDLbyID($postID);
    if ($dls['count'] < 1) {
    print($before . "No" . $after);
    } else {
    print($before . $dls['count'] . $after);

    5) At the location within the loop where you want to display the download count, insert:
    <?php printDLcount($post->ID, $before="", $after=" downloads"); ?>

    That’s it! Yes, the code is very verbose and full of extra junk, but it does work 🙂
    If anyone has ideas of how to simplify/improve this, I would love to see it.

    Good Luck,

  • The topic ‘HACK: Top 10 and per-item reporting for Download Manager’ is closed to new replies.