Customising the output of the WordPress Download Manager plugin shortcode

September 18, 2012 | Time Savers, Troubleshooting, Tutorials, Wordpress | 2 comments

I had a request this morning from a client who uses the WordPress Download Manager plugin. I can’t say whether it’s any good or not but the admin interface seems ok to me. It does, however, lack somewhat in the settings department.

When you add the following to your theme functions.php it will override the [wpdm_downloadable_nsc] shortcode with our own function where we can put whatever markup we want. This lot might take a bit of untangling. I can only assume the code is intentionally hideous in some attempt at amateur obfuscation.

My changes in this case were to remove the encapsulating divs around the links… my client wanted the download links inline which is why I did this… Uncommenting the lines with // preceeding will return the function to it’s original state and allow you to make your own changes thereafter.

function sb_wpdm_downloadable_nsc($params){
 global $wpdb; 

 $home = home_url('/');

 $sap = count($_GET)>0?'&':'?';

 $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A); 
 if($title=='true') $title = "<h3>".$data['title']."</h3>";
 else $title = '';
 if($desc=='true') $desc = $data['description']."</br>";
 else $desc = '';
 $desc = stripslashes($desc);
 if($data['show_counter']!=0) $hc= 'has-counter';
 if($template=='') $template = 'wpdm-only-button';
 $wpdm_login_msg = get_option('wpdm_login_msg')?get_option('wpdm_login_msg'):'Login Required';
 $link_label = $data['link_label']?$data['link_label']:'Download';
 $url = get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI'];
 $uuid = uniqid();
 //"<div>Login Required<br/><input placeholder='Username' type=text id='username_{$id}' size=15 class='inf' /> <input placeholder='Password' class='inf' type=password id='password_{$id}' size=15 /><span class='perror'></span></div>"; 
 //$html = "<div id='wpdm_file_{$id}' class='wpdm_file $template'>{$title}<div class='cont'>{$desc}{$loginform}<div class='btn_outer'><div class='btn_outer_c'><a class='btn_left $classrel $hc login-please' rel='{$id}' title='{$data[title]}' href='$url' >$link_label</a>"; 
 $html = "<a class='sb_download_label btn_left $classrel $hc login-please' rel='{$id}' title='{$data[title]}' href='$url' >$link_label</a>"; 
 //$html .= "<span class='btn_right counter'>$data[download_count] downloads</span>"; 
// $html .= "<span class='btn_right counter'>Login Required</span>"; 
 //$html .= "</div></div><div class='clear'></div></div></div>";
 else {
 if($data['password']=='') { $url = home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink')); $classrel = ""; }
 else { $classrel='haspass'; /*$url = home_url('/?download='.$id);*/ $url = home_url('/'); $password_field = "<div>Enter password<br/><input type=password id='pass_{$id}' size=15 /><span class='perror'></span></div>"; }
 $html = "<a class='sb_download_label btn_left $classrel $hc' rel='{$id}' title='{$data[title]}' href='$url' >$link_label</a>";
 //$html .= "<span class='btn_right counter'>$data[download_count] downloads</span>"; 
 //$html .= "<span class='btn_right'>&nbsp;</span>"; 
 //$html .= "</div></div><div class='clear'></div></div></div>";
 return $html; 

A Donate Button!


  1. berrada

    I’ve never seen such a bad plugin i totally agree. And the pro version is not better.

    • Sean

      Thanks for your comment. I have yet to use it a great deal to be honest. I don’t intend to either. I would likely write one myself if good ‘ol Mike Jolley’s Download Monitor plugin didn’t do the trick. I started using that about three years ago when it was shockingly bad but I was too idle to move but these days it’s a pretty good plugin with plenty of settings and configurations. My downloads page uses his simple shortcode to generate. Everything an idle site owner such as myself needs in their life šŸ™‚



Submit a Comment

Your email address will not be published. Required fields are marked *

CommentLuv badge

Stay in touch!

Page Builder Cloud

Page Builder Cloud

A truly universal template library for WordPress Page Builders.

Page Builder Recommendation

Elementor Banner

We are BIG fans of the Elementor page builder. Give it a look!

About this site and Sean Barton

Picture of Sean
Sean Barton is a Freelance PHP Website Developer in Crewe, Cheshire. He is a Wordpress and CMS/Framework specialist and Co-Founder of Page Builder Cloud.
This site was set up in 2008 as a tutorial and scripting resource for the PHP language and Wordpress.
Find out more about Sean on the About Me page or use the Hire Me page to get in touch. For more information about Sean's work take a look at the Portfolio

Our Services

  • Wordpress plugin/theme development
  • Divi specialist
  • Ecommerce (Woocommerce, WPSC, Shopify, Magento)
  • PSD to Wordpress theme conversion (Responsive)
  • Website design work (Banners, Logos, Full Site, etc)
  • Website analysis (security, usability, SEO)
  • API Integrations (InfusionSoft, SalesForce, Ontraport, Customer Thermometer, etc..)
  • Wordpress consultancy & expert advice
  • Crisis support
  • Website hosting

The main services offered are Wordpress based although we do a great deal of technical programming for bespoke systems. From troubleshooting, extending frameworks, finding bugs to writing them from scratch.

Find out more by looking through our past projects or get a quote.

Be the first to hear about new products/updates!

This is a mailing list for those people interested in being toldĀ when we releaseĀ a new product (Divi plugin or Theme).

We shall also use this list to let you know about product updates and releases.

You have Successfully Subscribed!