Example #1
0
function wpdm_downloadable($content)
{
    global $wpdb;
    preg_match_all("/\\{filelink\\=([^\\}]+)\\}/", $content, $matches);
    $home = home_url('/');
    $sap = count($_GET) > 0 ? '&' : '?';
    for ($i = 0; $i < count($matches[1]); $i++) {
        $id = $matches[1][$i];
        $data = $wpdb->get_row("select * from ahm_files where id='{$id}'", ARRAY_A);
        $data['title'] = stripcslashes($data['title']);
        $wpdm_login_msg = get_option('wpdm_login_msg') ? get_option('wpdm_login_msg') : 'Login Required';
        $link_label = $data['link_label'] ? $data['link_label'] : 'Download';
        if ($data['access'] == 'member' && !is_user_logged_in()) {
            $matches[1][$i] = "<a href='" . get_option('siteurl') . "/wp-login.php?redirect_to=" . $_SERVER['REQUEST_URI'] . "'  style=\"background:url('" . get_option('siteurl') . "/wp-content/plugins/download-manager/l24.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;\">" . $wpdm_login_msg . "</a>";
        } else {
            if ($data['password'] == '') {
                $url = home_url('/?wpdmact=process&did=' . base64_encode($id . '.hotlink'));
                $classrel = "";
            } else {
                $url = home_url('/?download=' . $id);
                $classrel = " class='wpdm-popup' rel='colorbox' ";
            }
            $matches[1][$i] = "<a {$classrel} title='{$data[title]}' href='{$url}' style=\"background:url('" . get_option('siteurl') . "/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;\">{$link_label}</a>";
            if ($data['show_counter'] != 0) {
                $matches[1][$i] .= "<br><small style='margin-left:30px;'>Downloaded {$data['download_count']} times</small>";
            }
        }
    }
    preg_match_all("/\\{wpdm_category\\=([^\\}]+)\\}/", $content, $cmatches);
    for ($i = 0; $i < count($cmatches[1]); $i++) {
        $cmatches[1][$i] = wpdm_embed_category($cmatches[1][$i]);
    }
    $content = str_replace($cmatches[0], $cmatches[1], $content);
    return str_replace($matches[0], $matches[1], $content);
}
 /**
  * @usage Show packages by tag
  * @param $params
  * @return string
  */
 function packagesByTag($params)
 {
     $params['order_field'] = isset($params['order_by']) ? $params['order_by'] : 'publish_date';
     $params['tag'] = 1;
     unset($params['order_by']);
     if (isset($params['item_per_page']) && !isset($params['items_per_page'])) {
         $params['items_per_page'] = $params['item_per_page'];
     }
     unset($params['item_per_page']);
     return wpdm_embed_category($params);
 }
Example #3
0
function misiva_wpdm_category($params)
{
    // muestra solamente cuando esta logeado una categoria.
    $user_ID = get_current_user_id();
    if ($user_ID != 0) {
        $params['order_field'] = isset($params['order_by']) ? $params['order_by'] : 'publish_date';
        unset($params['order_by']);
        if (isset($params['item_per_page']) && !isset($params['items_per_page'])) {
            $params['items_per_page'] = $params['item_per_page'];
        }
        unset($params['item_per_page']);
        return wpdm_embed_category($params);
    }
}