Quantcast
Channel: KWS Blog » Code
Viewing all articles
Browse latest Browse all 10

How I fixed WP-DownloadManager 404 errors

$
0
0

Lester Chan\'s header
I use LesterChan‘s Download Manager plugin, and it’s great. Good interface, simple purpose. 

I recently found out that after upgrading a client’s site to WP 2.5, WP-DownloadManager was no longer working.  I followed the documentation on the plugin website, including resetting the permalink structure, but nothing worked.

For some reason the re-write wasn’t working properly: all the downloads were giving 404 errors.  I couldn’t figure it out, so I dove into the code.  I found the part of the plugin that rewrites the download links, and found the problem.

Here’s the fix I found hack:

The plugin uses a function on line 271 of downloadmanager.php that may not be working because of WP 2.5: download_file_url.

Here’s the original code:

### Function: Download URL
function download_file_url($file_id) {
$file_id = intval($file_id);
if(get_option('permalink_structure')) {
$download_file_url = get_option('siteurl').'/download/'.$file_id.'/';
} else {
$download_file_url = get_option('siteurl').'?dl_id='.$file_id;
}
return $download_file_url;
}

I highlighted the part of the code that was causing me issues, and removed that if/else.

Updated code:

function download_file_url($file_id) {
$file_id = intval($file_id);
/* if(get_option('permalink_structure')) {
$download_file_url = get_option('siteurl').'/download/'.$file_id.'/';
} else {
$download_file_url = get_option('siteurl').'?dl_id='.$file_id;
} */

$download_file_url = get_option('siteurl').'?dl_id='.$file_id;
return $download_file_url;
}

In summary

This may or may not have been a WordPress upgrade issue, but it did solve my problem, and I didn’t need to delve any further into the root cause.

Please post any comments or corrections below.

The post How I fixed WP-DownloadManager 404 errors appeared first on KWS Blog.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images