WordPress Download Manager - Version 3.2.16

Version Description

  • 2021.09.27 =
  • Fixed an issue with the pagination function
  • Improved UI class
  • Improved category and packages shortcode
  • Fixed package sorting issue with the category and package shortcode
  • Fixed RTL layout issue with wpdm admin settings page
Download this release

Release Info

Developer codename065
Plugin Icon 128x128 WordPress Download Manager
Version 3.2.16
Comparing to
See all releases

Code changes from version 3.2.14 to 3.2.16

assets/css/admin-styles.css CHANGED
@@ -2190,3 +2190,30 @@ body.wpdm-iframe-modal-open {
2190
  font-size: 12px;
2191
  text-align: center;
2192
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2190
  font-size: 12px;
2191
  text-align: center;
2192
  }
2193
+
2194
+
2195
+ body.rtl #wpdm-admin-page-body {
2196
+ margin-right: 250px !important;
2197
+ }
2198
+ body.rtl.wpdmpro_page_settings #wpcontent{
2199
+ padding-right: 0 !important;
2200
+ }
2201
+ body.rtl #wpdm-admin-main-header {
2202
+ padding-left: 0 !important;
2203
+ margin-left: 0 !important;
2204
+ }
2205
+ body.rtl.wpdmpro_page_settings #wpdm-admin-page-header .pull-right
2206
+ {
2207
+ float: left !important;
2208
+ padding-left: 0 !important;
2209
+ }
2210
+ body.rtl #wpdm-admin-page-container {
2211
+ padding-left: 0 !important;
2212
+ }
2213
+ body.rtl .w3eden .chosen-container .chosen-drop,
2214
+ body.rtl .w3eden .chosen-container-single-nosearch .chosen-search input[type="text"]{
2215
+ display: none;
2216
+ }
2217
+ body.rtl .w3eden .chosen-container.chosen-with-drop .chosen-drop {
2218
+ display: block;
2219
+ }
download-manager.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.wpdownloadmanager.com/purchases/
5
  Description: Manage, Protect and Track file downloads, and sell digital products from your WordPress site. A complete digital asset management solution.
6
  Author: W3 Eden, Inc.
7
  Author URI: https://www.wpdownloadmanager.com/
8
- Version: 3.2.14
9
  Text Domain: download-manager
10
  Domain Path: /languages
11
  */
@@ -39,7 +39,7 @@ use WPDM\Widgets\WidgetController;
39
 
40
  global $WPDM;
41
 
42
- define('WPDM_VERSION','3.2.14');
43
 
44
  define('WPDM_TEXT_DOMAIN','download-manager');
45
 
@@ -47,6 +47,13 @@ $upload_dir = wp_upload_dir();
47
  $upload_base_url = $upload_dir['baseurl'];
48
  $upload_dir = $upload_dir['basedir'];
49
 
 
 
 
 
 
 
 
50
  /**
51
  * Define plugin admin access capability.
52
  */
@@ -173,9 +180,11 @@ final class WordPressDownloadManager{
173
  'ajax' => esc_url_raw(admin_url('/admin-ajax.php'))
174
  );
175
 
 
 
176
  include_once(dirname(__FILE__) . "/src/wpdm-functions.php");
177
  include(dirname(__FILE__)."/src/wpdm-core.php");
178
- $this->session = new Session();
179
  $this->user = UserController::getInstance();
180
  $this->apply = new Apply();
181
  $this->admin = new AdminController();
5
  Description: Manage, Protect and Track file downloads, and sell digital products from your WordPress site. A complete digital asset management solution.
6
  Author: W3 Eden, Inc.
7
  Author URI: https://www.wpdownloadmanager.com/
8
+ Version: 3.2.16
9
  Text Domain: download-manager
10
  Domain Path: /languages
11
  */
39
 
40
  global $WPDM;
41
 
42
+ define('WPDM_VERSION','3.2.16');
43
 
44
  define('WPDM_TEXT_DOMAIN','download-manager');
45
 
47
  $upload_base_url = $upload_dir['baseurl'];
48
  $upload_dir = $upload_dir['basedir'];
49
 
50
+ /**
51
+ * Define cookie domain if it is already not defined
52
+ */
53
+ if (!defined('COOKIE_DOMAIN'))
54
+ define('COOKIE_DOMAIN',false);
55
+
56
+
57
  /**
58
  * Define plugin admin access capability.
59
  */
180
  'ajax' => esc_url_raw(admin_url('/admin-ajax.php'))
181
  );
182
 
183
+ $this->session = new Session();
184
+
185
  include_once(dirname(__FILE__) . "/src/wpdm-functions.php");
186
  include(dirname(__FILE__)."/src/wpdm-core.php");
187
+
188
  $this->user = UserController::getInstance();
189
  $this->apply = new Apply();
190
  $this->admin = new AdminController();
readme.txt CHANGED
@@ -181,6 +181,18 @@ Check download stats and get a push notification when someone downloads, install
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  = 3.2.14 - 2021.08.16 =
185
  * Fixed an issue with template file detection in child theme
186
  * Fixed file delete option with the asset manager
181
 
182
  == Changelog ==
183
 
184
+ = 3.2.16 - 2021.09.27 =
185
+ * Fixed an issue with the pagination function
186
+ * Improved UI class
187
+ * Improved category and packages shortcode
188
+ * Fixed package sorting issue with the category and package shortcode
189
+ * Fixed RTL layout issue with wpdm admin settings page
190
+
191
+ = 3.2.15 - 2021.08.18 =
192
+ * Improved session manager class
193
+ * Fixed an issue with with asset access checking function
194
+ * Fixed an issue with the WidgetController class
195
+
196
  = 3.2.14 - 2021.08.16 =
197
  * Fixed an issue with template file detection in child theme
198
  * Fixed file delete option with the asset manager
src/Admin/views/metaboxes/package-settings.php CHANGED
@@ -91,7 +91,12 @@
91
 
92
  </td>
93
  </tr>
94
-
 
 
 
 
 
95
  <?php do_action("wpdm_package_settings_tr", $post->ID); ?>
96
  </table>
97
  <div class="clear"></div>
91
 
92
  </td>
93
  </tr>
94
+ <?php if(isset($_GET['post'])&&$_GET['post']!=''){ ?>
95
+ <tr>
96
+ <td><?php echo __( "Master Key" , "download-manager" ); ?></td>
97
+ <td><input class="form-control" style="width: 200px;display: inline-block;font-family: monospace;letter-spacing: 1px" type="text" readonly="readonly" value="<?php echo get_post_meta($post->ID, '__wpdm_masterkey', true); ?>"> <label><input type="checkbox" value="1" name="reset_key" /> <?php echo __( "Regenerate Master Key for Download" , "download-manager" ); ?></label> <i class="info fa fa-info" data-placement="top" title="<?php echo __( "This key can be used for direct download" , "download-manager" ); ?>"></i></td>
98
+ </tr>
99
+ <?php } ?>
100
  <?php do_action("wpdm_package_settings_tr", $post->ID); ?>
101
  </table>
102
  <div class="clear"></div>
src/AssetManager/Asset.php CHANGED
@@ -159,8 +159,8 @@ class Asset
159
  $ext = end($ext);
160
  $ext = strtolower($ext);
161
  $url = str_replace(ABSPATH, home_url('/'), $path);
162
- $accessible = __::is_url($url) ? get_headers($url) : [403];
163
- $accessible = strstr($accessible[0], '403') ? false : true;
164
  $relpath = str_replace(AssetManager::root(), "", $path);
165
  if(!$accessible)
166
  $url = home_url("/?wpdmfmdl={$relpath}");
159
  $ext = end($ext);
160
  $ext = strtolower($ext);
161
  $url = str_replace(ABSPATH, home_url('/'), $path);
162
+ $accessible = ini_get('allow_url_fopen') && __::is_url($url) ? get_headers($url) : [403];
163
+ $accessible = substr_count($accessible[0], '403') ? false : true;
164
  $relpath = str_replace(AssetManager::root(), "", $path);
165
  if(!$accessible)
166
  $url = home_url("/?wpdmfmdl={$relpath}");
src/Category/Shortcodes.php CHANGED
@@ -17,153 +17,22 @@ class Shortcodes
17
 
18
  function listPackages($params = array('id' => '', 'operator' => 'IN', 'items_per_page' => 10, 'title' => false, 'desc' => false, 'orderby' => 'create_date', 'order' => 'desc', 'paging' => false, 'toolbar' => 1, 'template' => '', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1, 'morelink' => 1))
19
  {
20
- /*extract($params);
21
- $fnparams = $params;
22
- if (!isset($id)) return '';
23
- if (!isset($items_per_page)) $items_per_page = 10;
24
- if (!isset($template)) $template = 'link-template-calltoaction3.php';
25
- if (!isset($cols)) $cols = 3;
26
- if (!isset($colspad)) $colspad = 2;
27
- if (!isset($colsphone)) $colsphone = 1;
28
- $toolbar = isset($toolbar) ? $toolbar : 0;
29
- $scid = isset($scid) ? $scid : md5($id);
30
- $taxo = 'wpdmcategory';
31
- if (isset($tag) && $tag == 1) $taxo = 'wpdmtag';
32
- $css_class = isset($css_class) ? $css_class : '';
33
- $cwd_class = "col-lg-" . (int)(12 / $cols);
34
- $cwdsm_class = "col-md-" . (int)(12 / $colspad);
35
- $cwdxs_class = "col-" . (int)(12 / $colsphone);
36
-
37
- $id = trim($id, ", ");
38
- $cids = explode(",", $id);
39
-
40
- global $wpdb, $current_user, $post, $wp_query;
41
-
42
- $orderby = isset($orderby) ? $orderby : 'publish_date';
43
- $orderby = in_array(wpdm_query_var('orderby'), array('title', 'publish_date', 'updates', 'download_count', 'view_count')) ? wpdm_query_var('orderby') : $orderby;
44
-
45
- $order = isset($fnparams['order']) ? $fnparams['order'] : 'desc';
46
- $order = wpdm_query_var('order') ? wpdm_query_var('order') : $order;
47
- $operator = isset($operator) ? $operator : 'IN';
48
- //$cpvid = str_replace(",", "_", $id);
49
- //$cpvar = 'cp_'.$cids[0];
50
- $term = get_term_by('slug', $cids[0], 'wpdmcategory');
51
- if(!$term) return apply_filters("wpdm_category_not_found", __( "Category doesn't exist", 'download-manager' ));
52
- $cpvar = 'cp_' . $term->term_id;
53
- $cp = wpdm_query_var($cpvar, 'num');
54
- if (!$cp) $cp = 1;
55
-
56
- $query = new Query();
57
- $query->items_per_page($items_per_page);
58
- $query->paged($cp);
59
- $query->sort($orderby, $order);
60
- $query->categories($cids, 'slug', $operator, wpdm_valueof($params, 'include_children', false));
61
-
62
- if (get_option('_wpdm_hide_all', 0) == 1) {
63
- $query->meta("__wpdm_access", '"guest"');
64
 
65
- if (is_user_logged_in()) {
66
- foreach ($current_user->roles as $role) {
67
- $query->meta("__wpdm_access", $role);
68
- }
69
- $query->meta_relation('OR');
 
70
  }
71
- }
72
-
73
- if (wpdm_query_var('skw', 'txt') != '') {
74
- $query->s(wpdm_query_var('skw', 'txt'));
75
- }
76
-
77
- $query->process();
78
- $total = $query->count;
79
- $packs = $query->packages();
80
- $pages = ceil($total / $items_per_page);
81
- $burl = get_permalink();
82
-
83
- $html = '';
84
- $templates = maybe_unserialize(get_option("_fm_link_templates", true));
85
-
86
- if (isset($templates[$template])) $template = $templates[$template]['content'];
87
-
88
- foreach ($packs as $pack) {
89
- $pack = (array)$pack;
90
- $thtml = WPDM()->package->fetchTemplate($template, $pack);
91
- $repeater = '';
92
- if ($thtml != '')
93
- $repeater = "<div class='{$cwd_class} {$cwdsm_class} {$cwdxs_class}'>" . $thtml . "</div>";
94
- $html .= $repeater;
95
-
96
- }
97
-
98
- wp_reset_postdata();
99
-
100
- $html = "<div class='row'>{$html}</div>";
101
- $cname = array();
102
- foreach ($cids as $cid) {
103
- $cat = get_term_by('slug', $cid, $taxo);
104
- if ($cat)
105
- $cname[] = $cat->name;
106
-
107
- }
108
- $cats = implode(", ", $cname);
109
-
110
- //Added from v4.2.1
111
- $desc = '';
112
- $category = new Category($cids[0]); //get_term_by('slug', $cids[0], 'wpdmcategory');
113
-
114
- if (isset($fnparams['title']) && $fnparams['title'] != false && intval($fnparams['title']) != 1) $cats = $fnparams['title'];
115
- if (isset($fnparams['desc']) && $fnparams['desc'] != false && intval($fnparams['desc']) != 1) $desc = $fnparams['desc'];
116
- if (isset($fnparams['desc']) && (int)$fnparams['desc'] == 1) $desc = $category->description;
117
-
118
- $cimg = '';
119
-
120
-
121
- $subcats = '';
122
- if (function_exists('wpdm_ap_categories') && $subcats == 1) {
123
- $schtml = wpdm_ap_categories(array('parent' => $id));
124
- if ($schtml != '') {
125
- $subcats = "<fieldset class='cat-page-tilte'><legend>" . __("Sub-Categories", "download-manager") . "</legend>" . $schtml . "<div style='clear:both'></div></fieldset>" . "<fieldset class='cat-page-tilte'><legend>" . __("Downloads", "download-manager") . "</legend>";
126
- $efs = '</fieldset>';
127
  }
128
  }
129
- $pagination = "";
130
- if (!isset($paging) || intval($paging) == 1) {
131
- $pag_links = wpdm_paginate_links($total, $items_per_page, $cp, $cpvar, array('container' => '#content_' . $scid, 'async' => (isset($async) && $async == 1 ? 1 : 0), 'next_text' => ' <i style="display: inline-block;width: 8px;height: 8px;border-right: 2px solid;border-top: 2px solid;transform: rotate(45deg);margin-left: -2px;margin-top: -2px;"></i> ', 'prev_text' => ' <i style="display: inline-block;width: 8px;height: 8px;border-right: 2px solid;border-bottom: 2px solid;transform: rotate(135deg);margin-left: 2px;margin-top: -2px;"></i> '));
132
- $pagination = "<div style='clear:both'></div>" . $pag_links . "<div style='clear:both'></div>";
133
- } else
134
- $pgn = "";
135
-
136
- global $post;
137
-
138
- $sap = get_option('permalink_structure') ? '?' : '&';
139
- $burl = $burl . $sap;
140
- if (isset($_GET['p']) && $_GET['p'] != '') $burl .= 'p=' . esc_attr($_GET['p']) . '&';
141
- if (isset($_GET['src']) && $_GET['src'] != '') $burl .= 'src=' . esc_attr($_GET['src']) . '&';
142
- $order = ucfirst($order);
143
- $orderby_label = " " . __(ucwords(str_replace("_", " ", $orderby)), "wpdmpro");
144
- $ttitle = __("Title", "download-manager");
145
- $tdls = __("Downloads", "download-manager");
146
- $tcdate = __("Publish Date", "download-manager");
147
- $tudate = __("Update Date", "download-manager");
148
- $tasc = __("Asc", "download-manager");
149
- $tdsc = __("Desc", "download-manager");
150
- $tsrc = __("Search", "download-manager");
151
- $ord = __("Order", "download-manager");
152
- $order_by_label = __("Order By", "download-manager");
153
- $hasdesc = $desc != '' ? 'has-desc' : '';
154
-
155
- $icon = $category->icon;
156
- if(!isset($iconw)) $iconw = $desc != '' ? 64 : 32;
157
- if ($icon != '') $icon = "<div class='pull-left mr-3'><img class='category-icon m-0 category-{$category->ID}' style='max-width: {$iconw}px' src='{$icon}' alt='{$category->name}' /></div>";
158
-
159
- $title = $cats;
160
-
161
- ob_start();
162
- include Template::locate("category-shortcode.php", __DIR__.'/views');
163
- $content = ob_get_clean();
164
- return $content;*/
165
- $params['categories'] = $params['id'];
166
- unset($params['id']);
167
  return WPDM()->package->shortCodes->packages($params);
168
 
169
  }
17
 
18
  function listPackages($params = array('id' => '', 'operator' => 'IN', 'items_per_page' => 10, 'title' => false, 'desc' => false, 'orderby' => 'create_date', 'order' => 'desc', 'paging' => false, 'toolbar' => 1, 'template' => '', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1, 'morelink' => 1))
19
  {
20
+ $params['categories'] = $params['id'];
21
+ $params['catsc'] = 1;
22
+ unset($params['id']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ if(!in_array(wpdm_valueof($params, 'cat_field'), ['id', 'term_id'])) {
25
+ $ids = [];
26
+ foreach (explode(",", $params['categories']) as $slug) {
27
+ $term = get_term_by('slug', $slug, 'wpdmcategory');
28
+ if($term)
29
+ $ids[] = $term->term_id;
30
  }
31
+ if(count($ids) > 0) {
32
+ $params['categories'] = implode(",", $ids);
33
+ $params['cat_field'] = 'id';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  return WPDM()->package->shortCodes->packages($params);
37
 
38
  }
src/MediaLibrary/MediaAccessControl.php CHANGED
@@ -8,6 +8,7 @@ namespace WPDM\MediaLibrary;
8
 
9
 
10
  use WPDM\__\Crypt;
 
11
  use WPDM\__\Template;
12
  use WPDM\__\TempStorage;
13
  use WPDM\__\FileSystem;
@@ -79,9 +80,12 @@ class MediaAccessControl
79
 
80
  function protectMediaLibrary(){
81
  if(isset($_REQUEST['wpdmmediaid'])){
82
- global $wpdb, $current_user;
83
- $media = get_post($_REQUEST['wpdmmediaid']);
84
- $media_meta = wp_get_attachment_metadata($_REQUEST['wpdmmediaid']);
 
 
 
85
  //wpdmdd($media_meta);
86
  //wpdmdd($media);
87
  $media->path = str_replace(home_url('/'), ABSPATH.'/', $media->guid);
@@ -119,18 +123,18 @@ class MediaAccessControl
119
  $upload_dir = $upload_dir['basedir'];
120
  $htaccess_rules = "<IfModule mod_rewrite.c>\nRewriteEngine On\n";
121
  foreach ($protected as $id => $path){
122
- $path = str_replace($upload_dir.'/', "", $path);
123
- $file_dir = preg_replace("/\/([^\/]+)$/i", "/", $path);
124
- $htaccess_rules .= "RewriteRule ^({$path})$ ../../index.php?wpdmmediaid={$id}&wpdmmedia=$1\n";
125
- if(wp_attachment_is_image($id))
126
- {
127
- $meta = wp_get_attachment_metadata($id);
128
- $thumbs = $meta['sizes'];
129
- foreach ($thumbs as $size => $thumb) {
130
- $_path = $file_dir.$thumb['file'];
131
- $htaccess_rules .= "RewriteRule ^({$_path})$ ../../index.php?wpdmmediaid={$id}&wpdmmedia=$1&thumb={$size}\n";
132
- }
133
- }
134
 
135
  }
136
  $htaccess_rules .= "</IfModule>";
8
 
9
 
10
  use WPDM\__\Crypt;
11
+ use WPDM\__\Messages;
12
  use WPDM\__\Template;
13
  use WPDM\__\TempStorage;
14
  use WPDM\__\FileSystem;
80
 
81
  function protectMediaLibrary(){
82
  if(isset($_REQUEST['wpdmmediaid'])){
83
+ global $wpdb;
84
+ $current_user = wp_get_current_user();
85
+ $ID = wpdm_query_var('wpdmmediaid', 'int');
86
+ $media = get_post($ID);
87
+ if(!$media) Messages::fullPage('404', esc_attr__( 'Media not found!', WPDM_TEXT_DOMAIN ));
88
+ $media_meta = wp_get_attachment_metadata($ID);
89
  //wpdmdd($media_meta);
90
  //wpdmdd($media);
91
  $media->path = str_replace(home_url('/'), ABSPATH.'/', $media->guid);
123
  $upload_dir = $upload_dir['basedir'];
124
  $htaccess_rules = "<IfModule mod_rewrite.c>\nRewriteEngine On\n";
125
  foreach ($protected as $id => $path){
126
+ $path = str_replace($upload_dir.'/', "", $path);
127
+ $file_dir = preg_replace("/\/([^\/]+)$/i", "/", $path);
128
+ $htaccess_rules .= "RewriteRule ^({$path})$ ../../index.php?wpdmmediaid={$id}&wpdmmedia=$1\n";
129
+ if(wp_attachment_is_image($id))
130
+ {
131
+ $meta = wp_get_attachment_metadata($id);
132
+ $thumbs = $meta['sizes'];
133
+ foreach ($thumbs as $size => $thumb) {
134
+ $_path = $file_dir.$thumb['file'];
135
+ $htaccess_rules .= "RewriteRule ^({$_path})$ ../../index.php?wpdmmediaid={$id}&wpdmmedia=$1&thumb={$size}\n";
136
+ }
137
+ }
138
 
139
  }
140
  $htaccess_rules .= "</IfModule>";
src/Package/PackageController.php CHANGED
@@ -128,7 +128,7 @@ class PackageController extends PackageTemplate
128
  $post_vars['play_button'] = self::audioPlayer($post_vars);
129
 
130
 
131
- $post_vars['link_label'] = isset($post_vars['link_label']) ? $post_vars['link_label'] : __("Download", "download-manager");
132
  $post_vars['page_url'] = get_permalink($post_vars['ID']);
133
  $post_vars['page_link'] = "<a href='" . $post_vars['page_url'] . "'>{$post_vars['title']}</a>";
134
  $post_vars['page_url_qr'] = "<img class='wpdm-qr-code wpdm-qr-code{$post_vars['ID']}' style='max-width: 250px' src='http://chart.googleapis.com/chart?cht=qr&chs=450x450&choe=UTF-8&chld=H|0&chl={$post_vars['page_url']}' alt='{$post_vars['title']}' />";
@@ -666,8 +666,7 @@ class PackageController extends PackageTemplate
666
  if ($audio != null) {
667
  $song = FileSystem::mediaURL($package['ID'], $audx, basename($audio)); //home_url("/?wpdmdl={$package['ID']}&ind=".$audx."&play=".basename($audio));
668
  $audiohtml = "<button data-player='wpdm-audio-player' data-song='{$song}' class='btn btn-{$style} wpdm-btn-play'><i class='fa fa-play'></i></button>";
669
-
670
-
671
  }
672
 
673
  if ($return)
@@ -799,7 +798,7 @@ class PackageController extends PackageTemplate
799
  //if($metaValidate[$metaDataRow->meta_key] === 'array' && !is_array($metaDataRow->meta_value)) $metaDataRow->meta_value = unserialize($metaDataRow->meta_value);
800
  //else
801
  // $metaDataRow->meta_value = __::sanitize_var($metaDataRow->meta_value, $metaValidate[$metaDataRow->meta_key]);
802
- $data[$key] = maybe_unserialize($metaDataRow->meta_value);
803
  }
804
  }
805
  unset($metaData);
@@ -1239,7 +1238,7 @@ class PackageController extends PackageTemplate
1239
  }
1240
 
1241
  if ($data != "") {
1242
- $data = apply_filters('wpdm_download_link', $data, array('ID' => $ID, 'id' => $ID));
1243
  return $data;
1244
  }
1245
 
@@ -1251,7 +1250,7 @@ class PackageController extends PackageTemplate
1251
  $data = "<button class='btn btn-danger btn-block' type='button' disabled='disabled' data-title='DOWNLOAD ERROR:'>" . __("Limit Over!", "download-manager") . "</button>";
1252
  }
1253
  if ($data == 'loginform') return WPDM()->user->login->form();
1254
- $data = apply_filters('wpdm_download_link', $data, array('ID' => $ID, 'id' => $ID));
1255
  return $data;
1256
 
1257
  }
@@ -1782,6 +1781,7 @@ class PackageController extends PackageTemplate
1782
  public function linkLabel($ID)
1783
  {
1784
  $link_label = get_post_meta($ID, '__wpdm_link_label', true);
 
1785
  $link_label = $link_label ? $link_label : __("Download", "download-manager");
1786
  return $link_label;
1787
  }
128
  $post_vars['play_button'] = self::audioPlayer($post_vars);
129
 
130
 
131
+ $post_vars['link_label'] = isset($post_vars['link_label']) ? esc_attr($post_vars['link_label']) : esc_attr__("Download", "download-manager");
132
  $post_vars['page_url'] = get_permalink($post_vars['ID']);
133
  $post_vars['page_link'] = "<a href='" . $post_vars['page_url'] . "'>{$post_vars['title']}</a>";
134
  $post_vars['page_url_qr'] = "<img class='wpdm-qr-code wpdm-qr-code{$post_vars['ID']}' style='max-width: 250px' src='http://chart.googleapis.com/chart?cht=qr&chs=450x450&choe=UTF-8&chld=H|0&chl={$post_vars['page_url']}' alt='{$post_vars['title']}' />";
666
  if ($audio != null) {
667
  $song = FileSystem::mediaURL($package['ID'], $audx, basename($audio)); //home_url("/?wpdmdl={$package['ID']}&ind=".$audx."&play=".basename($audio));
668
  $audiohtml = "<button data-player='wpdm-audio-player' data-song='{$song}' class='btn btn-{$style} wpdm-btn-play'><i class='fa fa-play'></i></button>";
669
+ $audiohtml = apply_filters("wpdm_audio_play_button", $audiohtml, $song, $package, 0);
 
670
  }
671
 
672
  if ($return)
798
  //if($metaValidate[$metaDataRow->meta_key] === 'array' && !is_array($metaDataRow->meta_value)) $metaDataRow->meta_value = unserialize($metaDataRow->meta_value);
799
  //else
800
  // $metaDataRow->meta_value = __::sanitize_var($metaDataRow->meta_value, $metaValidate[$metaDataRow->meta_key]);
801
+ $data[$key] = wpdm_sanitize_var(maybe_unserialize($metaDataRow->meta_value), $metaValidate[$metaDataRow->meta_key]);
802
  }
803
  }
804
  unset($metaData);
1238
  }
1239
 
1240
  if ($data != "") {
1241
+ $data = apply_filters('wpdm_download_link', $data, $extras + array('ID' => $ID, 'id' => $ID));
1242
  return $data;
1243
  }
1244
 
1250
  $data = "<button class='btn btn-danger btn-block' type='button' disabled='disabled' data-title='DOWNLOAD ERROR:'>" . __("Limit Over!", "download-manager") . "</button>";
1251
  }
1252
  if ($data == 'loginform') return WPDM()->user->login->form();
1253
+ $data = apply_filters('wpdm_download_link', $data, $extras + array('ID' => $ID, 'id' => $ID));
1254
  return $data;
1255
 
1256
  }
1781
  public function linkLabel($ID)
1782
  {
1783
  $link_label = get_post_meta($ID, '__wpdm_link_label', true);
1784
+ $link_label = esc_attr($link_label);
1785
  $link_label = $link_label ? $link_label : __("Download", "download-manager");
1786
  return $link_label;
1787
  }
src/Package/Shortcodes.php CHANGED
@@ -386,12 +386,17 @@ class Shortcodes
386
  {
387
  global $wpdb, $current_user, $wp_query;
388
  $items = isset($params['items_per_page']) && $params['items_per_page'] > 0 ? $params['items_per_page'] : 20;
389
- if (isset($params['jstable']) && $params['jstable'] == 1) $items = 2000;
390
- $cp = isset($wp_query->query_vars['paged']) && $wp_query->query_vars['paged'] > 0 ? $wp_query->query_vars['paged'] : 1;
 
 
 
 
 
 
391
  $terms = isset($params['categories']) ? explode(",", $params['categories']) : array();
392
  $tag = isset($params['tag']) ? $params['tag'] : '';
393
  if (isset($_GET['wpdmc'])) $terms = array(esc_attr($_GET['wpdmc']));
394
- $offset = ($cp - 1) * $items;
395
  $total_files = wp_count_posts('wpdmpro')->publish;
396
  if (count($terms) > 0) {
397
  $tax_query = array(array(
386
  {
387
  global $wpdb, $current_user, $wp_query;
388
  $items = isset($params['items_per_page']) && $params['items_per_page'] > 0 ? $params['items_per_page'] : 20;
389
+ $offset = $cp = 0;
390
+ if (isset($params['jstable']) && $params['jstable'] == 1) {
391
+ $items = 2000;
392
+ } else {
393
+ $cp = wpdm_query_var('cp', ['validate' => 'int', 'default' => 1]);
394
+ $offset = ($cp - 1) * $items;
395
+
396
+ }
397
  $terms = isset($params['categories']) ? explode(",", $params['categories']) : array();
398
  $tag = isset($params['tag']) ? $params['tag'] : '';
399
  if (isset($_GET['wpdmc'])) $terms = array(esc_attr($_GET['wpdmc']));
 
400
  $total_files = wp_count_posts('wpdmpro')->publish;
401
  if (count($terms) > 0) {
402
  $tax_query = array(array(
src/Package/views/all-packages-shortcode.php CHANGED
@@ -212,7 +212,6 @@ if(isset($params['jstable']) && $params['jstable']==1):
212
 
213
 
214
  $cfurl = get_permalink();
215
-
216
  $query_params = array("post_type"=>"wpdmpro","posts_per_page"=>$items,"offset"=>$offset);
217
  if(isset($tax_query)) $query_params['tax_query'] = $tax_query;
218
  $query_params['orderby'] = (isset($params['order_by']))?$params['order_by']:'date';
@@ -290,7 +289,7 @@ if(isset($params['jstable']) && $params['jstable']==1):
290
  $data['download_link'] = WPDM()->package->downloadLink($data['ID'], 0, array('template_type' => 'link'));
291
  $data = apply_filters("wpdm_after_prepare_package_data", $data);
292
  $download_link = htmlspecialchars_decode($data['download_link']);
293
- if(((isset($data['base_price']) && $data['base_price'] > 0) || (isset($data['pay_as_you_want']) && (int)$data['pay_as_you_want'] === 1)) && function_exists('wpdmpp_currency_sign'))
294
  $download_link = wpdmpp_waytocart($data, 'btn-primary');
295
 
296
  if(WPDM()->package->userCanAccess($data['ID']) || !get_option("_wpdm_hide_all", 0)){
@@ -396,26 +395,7 @@ if(isset($params['jstable']) && $params['jstable']==1):
396
 
397
  isset($wp_query->query_vars['paged']) && $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
398
 
399
- $pagination = array(
400
- 'base' => @add_query_arg('paged','%#%'),
401
- 'format' => '',
402
- 'total' => ceil($total_files/$items),
403
- 'current' => $cp,
404
- 'show_all' => false,
405
- 'type' => 'list',
406
- 'prev_next' => True,
407
- 'prev_text' => '<i class="fa fa-long-arrow-left"></i> '.__('Previous', 'download-manager'),
408
- 'next_text' => __('Next', 'download-manager').' <i class="fa fa-long-arrow-right"></i>',
409
- );
410
-
411
- if( $wp_rewrite->using_permalinks() )
412
- $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s',get_pagenum_link(1) ) ) . 'page/%#%/', 'paged');
413
-
414
- if( !empty($wp_query->query_vars['s']) )
415
- $pagination['add_args'] = array('s'=>get_query_var('s'));
416
-
417
- echo "<div class='text-center'>".str_replace("<ul class='page-numbers'>","<ul class='page-numbers pagination pagination-centered'>",paginate_links($pagination))."</div>";
418
-
419
  wp_reset_query();
420
  ?>
421
 
212
 
213
 
214
  $cfurl = get_permalink();
 
215
  $query_params = array("post_type"=>"wpdmpro","posts_per_page"=>$items,"offset"=>$offset);
216
  if(isset($tax_query)) $query_params['tax_query'] = $tax_query;
217
  $query_params['orderby'] = (isset($params['order_by']))?$params['order_by']:'date';
289
  $data['download_link'] = WPDM()->package->downloadLink($data['ID'], 0, array('template_type' => 'link'));
290
  $data = apply_filters("wpdm_after_prepare_package_data", $data);
291
  $download_link = htmlspecialchars_decode($data['download_link']);
292
+ if (function_exists('wpdmpp_effective_price') && wpdmpp_effective_price($data['ID']) > 0)
293
  $download_link = wpdmpp_waytocart($data, 'btn-primary');
294
 
295
  if(WPDM()->package->userCanAccess($data['ID']) || !get_option("_wpdm_hide_all", 0)){
395
 
396
  isset($wp_query->query_vars['paged']) && $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
397
 
398
+ echo wpdm_paginate_links($total_files, $items, $cp);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  wp_reset_query();
400
  ?>
401
 
src/Package/views/category-shortcode-toolbar.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base: wpdmpro
4
+ * Developer: shahjada
5
+ * Team: W3 Eden
6
+ * Date: 6/6/20 09:48
7
+ */
8
+
9
+ if(!defined("ABSPATH")) die();
10
+
11
+ //Show toolbar on post type archive
12
+ if(is_post_type_archive()) $toolbar = 1;
13
+ if ($toolbar) {
14
+ $title = wpdm_valueof($scparams, 'title');
15
+ $desc = wpdm_valueof($scparams, 'desc');
16
+ $icon_width = wpdm_valueof($scparams, 'icon_width', ['default' => 64]);
17
+ $icon = wpdm_valueof($scparams, 'icon');
18
+ $titles = $descs = [];
19
+ if((int)$title === 1) {
20
+ $categories = explode(",", $scparams['categories']);
21
+ $title = "";
22
+ foreach ($categories as $slug) {
23
+ $field = wpdm_valueof($scparams, 'cat_field', ['default' => 'slug']);
24
+ $category = get_term_by($field, $slug, "wpdmcategory");
25
+ if($category) {
26
+ $titles[] = $category->name;
27
+ if (trim($category->description) !== '')
28
+ $descs[] = $category->description;
29
+ $icon_url = WPDM()->categories->icon($category->term_id);
30
+ $icon = !$icon && $icon_url ? $icon_url : $icon;
31
+ }
32
+ }
33
+ $title = implode(", ", $titles);
34
+ $desc = (int)$desc === 1 ? implode("<hr/>", $descs) : $desc;
35
+ }
36
+ $icon = $icon ? \WPDM\__\UI::img($icon, "Icon", ['style' => "width: {$icon_width}px;"]) : '';
37
+ ?>
38
+ <form method="get" class="<?php if(isset($async) && (int)$async === 1) echo '__wpdm_submit_async'; ?>" data-container="#content_<?php echo $scid; ?>" id="sc_form_<?php echo $scid; ?>" style="margin-bottom: 15px">
39
+ <?php
40
+ if ($toolbar !== 'skinny' && $title !== '') {
41
+
42
+
43
+ ?>
44
+ <div class="panel panel-default card category-panel wpdm-shortcode-toolbar">
45
+ <div class="panel-body card-body">
46
+ <div class="media">
47
+ <div class="mr-3">
48
+ <?php echo isset($icon) ? $icon : ''; ?>
49
+ </div>
50
+ <div class="media-body">
51
+ <h3 style="margin: 0"><?php echo $title; ?></h3>
52
+ <?php echo $desc; ?>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ <div class="panel-footer card-footer">
57
+ <div class="row">
58
+ <div class="col-lg-<?php echo $sr; ?> col-md-12">
59
+ <input type="text" name="skw" value="<?php echo stripslashes_deep(wpdm_query_var('skw', 'txt')) ?>" placeholder="<?php echo __( "Search Keyword...", "download-manager" ); ?>" class="form-control" />
60
+ </div>
61
+ <div class="col-lg-<?php echo $ob; ?> col-md-4">
62
+ <select name="orderby" class="wpdm-custom-select custom-select">
63
+ <option value="date" disabled="disabled"><?php echo __( "Order By:", "download-manager" ) ?></option>
64
+ <option value="date" <?php selected('date', wpdm_query_var('orderby')) ?>><?php echo __( "Publish Date", "download-manager" ) ?></option>
65
+ <option value="title" <?php selected('title', wpdm_query_var('orderby')) ?>><?php echo __( "Title", "download-manager" ) ?></option>
66
+ <option value="update_date" <?php selected('update_date', wpdm_query_var('orderby')) ?>><?php echo __( "Update Date", "download-manager" ) ?></option>
67
+ <option value="download_count" <?php selected('downloads', wpdm_query_var('orderby')) ?>><?php echo __( "Downloads", "download-manager" ) ?></option>
68
+ <option value="view_count" <?php selected('views', wpdm_query_var('orderby')) ?>><?php echo __( "Views", "download-manager" ) ?></option>
69
+ </select>
70
+ </div>
71
+ <div class="col-lg-<?php echo $od; ?> col-md-4">
72
+ <select name="order" class="wpdm-custom-select custom-select">
73
+ <option value="desc" disabled="disabled"><?php echo __( "Order:", "download-manager" ) ?></option>
74
+ <option value="desc" <?php selected('desc', wpdm_query_var('order')) ?>><?php echo __( "Descending", "download-manager" ) ?></option>
75
+ <option value="asc" <?php selected('asc', wpdm_query_var('order')) ?>><?php echo __( "Ascending", "download-manager" ) ?></option>
76
+ </select>
77
+ </div>
78
+ <div class="col-lg-<?php echo $bt; ?> col-md-4">
79
+ <button type="submit" class="btn btn-secondary btn-block"><?php echo __( "Apply Filter", "download-manager" ) ?></button>
80
+ </div>
81
+ </div>
82
+
83
+ </div>
84
+ </div>
85
+ <?php
86
+ } else {
87
+ ?>
88
+
89
+ <div class="card panel panel-default wpdm-shortcode-toolbar">
90
+ <div class="card-body panel-body">
91
+ <div class="row">
92
+ <div class="col-lg-<?php echo $sr; ?> col-md-12">
93
+ <input type="search" name="skw" value="<?php echo stripslashes_deep(wpdm_query_var('skw', 'txt')) ?>" placeholder="<?php echo __( "Search Keyword...", "download-manager" ); ?>" class="form-control" />
94
+ </div>
95
+ <div class="col-lg-<?php echo $ob; ?> col-md-4">
96
+ <select name="orderby" class="wpdm-custom-select custom-select">
97
+ <option value="date" disabled="disabled"><?php echo __( "Order By:", "download-manager" ) ?></option>
98
+ <option value="date" <?php selected('date', wpdm_query_var('orderby')) ?>><?php echo __( "Publish Date", "download-manager" ) ?></option>
99
+ <option value="title" <?php selected('title', wpdm_query_var('orderby')) ?>><?php echo __( "Title", "download-manager" ) ?></option>
100
+ <option value="update_date" <?php selected('update_date', wpdm_query_var('orderby')) ?>><?php echo __( "Update Date", "download-manager" ) ?></option>
101
+ <option value="downloads" <?php selected('downloads', wpdm_query_var('orderby')) ?>><?php echo __( "Downloads", "download-manager" ) ?></option>
102
+ <option value="views" <?php selected('views', wpdm_query_var('orderby')) ?>><?php echo __( "Views", "download-manager" ) ?></option>
103
+ </select>
104
+ </div>
105
+ <div class="col-lg-<?php echo $od; ?> col-md-4">
106
+ <select name="order" class="wpdm-custom-select custom-select">
107
+ <option value="desc" disabled="disabled"><?php echo __( "Order:", "download-manager" ) ?></option>
108
+ <option value="desc" <?php selected('desc', wpdm_query_var('order')) ?>><?php echo __( "Descending", "download-manager" ) ?></option>
109
+ <option value="asc" <?php selected('asc', wpdm_query_var('order')) ?>><?php echo __( "Ascending", "download-manager" ) ?></option>
110
+ </select>
111
+ </div>
112
+ <div class="col-lg-<?php echo $bt; ?> col-md-4">
113
+ <button type="submit" class="btn btn-secondary btn-block"><?php echo __( "Apply Filter", "download-manager" ) ?></button>
114
+ </div>
115
+ </div>
116
+ </div>
117
+ </div>
118
+
119
+ <?php
120
+ }
121
+ ?>
122
+ </form>
123
+ <div class="spacer mb-3 d-block clearfix"></div>
124
+ <?php }
src/Package/views/packages-shortcode-toolbar.php CHANGED
@@ -47,8 +47,8 @@ if ($toolbar) {
47
  <option value="date" <?php selected('date', wpdm_query_var('orderby')) ?>><?php echo __( "Publish Date", "download-manager" ) ?></option>
48
  <option value="title" <?php selected('title', wpdm_query_var('orderby')) ?>><?php echo __( "Title", "download-manager" ) ?></option>
49
  <option value="update_date" <?php selected('update_date', wpdm_query_var('orderby')) ?>><?php echo __( "Update Date", "download-manager" ) ?></option>
50
- <option value="downloads" <?php selected('downloads', wpdm_query_var('orderby')) ?>><?php echo __( "Downloads", "download-manager" ) ?></option>
51
- <option value="views" <?php selected('views', wpdm_query_var('orderby')) ?>><?php echo __( "Views", "download-manager" ) ?></option>
52
  </select>
53
  </div>
54
  <div class="col-lg-<?php echo $od; ?> col-md-4">
47
  <option value="date" <?php selected('date', wpdm_query_var('orderby')) ?>><?php echo __( "Publish Date", "download-manager" ) ?></option>
48
  <option value="title" <?php selected('title', wpdm_query_var('orderby')) ?>><?php echo __( "Title", "download-manager" ) ?></option>
49
  <option value="update_date" <?php selected('update_date', wpdm_query_var('orderby')) ?>><?php echo __( "Update Date", "download-manager" ) ?></option>
50
+ <option value="download_count" <?php selected('downloads', wpdm_query_var('orderby')) ?>><?php echo __( "Downloads", "download-manager" ) ?></option>
51
+ <option value="view_count" <?php selected('views', wpdm_query_var('orderby')) ?>><?php echo __( "Views", "download-manager" ) ?></option>
52
  </select>
53
  </div>
54
  <div class="col-lg-<?php echo $od; ?> col-md-4">
src/Package/views/packages-shortcode.php CHANGED
@@ -6,10 +6,27 @@
6
  * Date: 6/6/20 06:35
7
  */
8
  if (!defined("ABSPATH")) die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ?>
10
  <div class='w3eden'>
11
  <div class='<?php echo $css_class; ?>'>
12
- <?php include \WPDM\__\Template::locate("packages-shortcode-toolbar.php", __DIR__); ?>
 
 
13
  <div id="content_<?php echo $scid; ?>">
14
  <?php echo $html ?>
15
  <?php echo $pagination ?>
6
  * Date: 6/6/20 06:35
7
  */
8
  if (!defined("ABSPATH")) die();
9
+ $category_shortcode = wpdm_valueof($scparams, 'catsc', ['validate' => 'int']);
10
+ $toolbar_file = $category_shortcode === 1 ? "category-shortcode-toolbar.php" : "packages-shortcode-toolbar.php";
11
+
12
+ /*
13
+ tbgrid - Toolbar grid layout setting variable, 12 grid layout distribute amonng search bar, order by dropdown, order dropdown, and filter button
14
+ $sr - Search bar width
15
+ $ob - Orderby dropdown width
16
+ $od - Order dropdown width
17
+ $bt - Button area width
18
+ */
19
+ list($sr, $ob, $od, $bt) = [6,2,2,2];
20
+ if(isset($scparams['tbgrid'])){
21
+ list($sr, $ob, $od, $bt) = explode(",", $scparams['tbgrid']);
22
+ }
23
+
24
  ?>
25
  <div class='w3eden'>
26
  <div class='<?php echo $css_class; ?>'>
27
+
28
+ <?php include \WPDM\__\Template::locate($toolbar_file, __DIR__); ?>
29
+
30
  <div id="content_<?php echo $scid; ?>">
31
  <?php echo $html ?>
32
  <?php echo $pagination ?>
src/Widgets/Affiliate.php CHANGED
@@ -1,45 +1,54 @@
1
  <?php
2
- if(!defined("ABSPATH")) die("Shit happens!");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- class WPDM_Affiliate extends WP_Widget {
5
- /** constructor */
6
- function __construct() {
7
- $widget_options = array( 'classname' => 'wpdm_affiliate', 'description' => 'WPDM Pro Affiliate Widget' );
8
- parent::__construct(false, 'WPDM Pro Affiliate', $widget_options);
9
- }
10
-
11
- /** @see WP_Widget::widget */
12
- function widget($args, $instance) {
13
- extract( $args );
14
- $title = apply_filters('widget_title', wpdm_valueof($instance, 'title'));
15
-
16
- echo $before_widget;
17
-
18
- echo "<div class='w3eden'><div class='panel panel-primary'>";
19
- echo "<div class='panel-heading' style='font-size: 10pt'>Best File & Document Management Plugin</div><div class='panel-body' style='padding-bottom:0;background:#F2F2F2;'><a href='https://www.wpdownloadmanager.com/?affid={$title}'><img src='https://cdn.wpdownloadmanager.com/wp-content/uploads/2017/09/WordPress-Download-Manager-Intro-4.png' alt='WordPress Download Manager' /></a></div>";
20
- echo "<div class='panel-footer' style='line-height: 30px'><a class='pull-right btn btn-sm btn-danger' href='https://www.wpdownloadmanager.com/?affid={$title}'>Buy Now <i class='fa fa-angle-right'></i></a><span class='label label-success' style='font-size: 12pt;border-radius: 2px'>$59.00</span></div></div></div>";
21
- echo $after_widget;
22
- }
23
-
24
- /** @see WP_Widget::update */
25
- function update($new_instance, $old_instance) {
26
- $instance = $old_instance;
27
- $instance['title'] = strip_tags($new_instance['title']);
28
- return $instance;
29
- }
30
-
31
- /** @see WP_Widget::form */
32
- function form($instance) {
33
- $title = isset($instance['title'])?esc_attr($instance['title']):"";
34
- ?>
35
- <p>
36
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('WPDM Affiliate ID:'); ?></label>
37
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
38
- <em>It is your account <b>username</b> at www.wpdownloadmanager.com. You will get up to 20% from each sale referred by you</em>
39
- </p>
40
- <?php
41
  }
42
 
 
43
  }
44
-
45
- register_widget('WPDM_Affiliate');
1
  <?php
2
+ if (!defined("ABSPATH")) die("Shit happens!");
3
+
4
+ if (!class_exists('WPDM_Affiliate')) {
5
+ class WPDM_Affiliate extends WP_Widget
6
+ {
7
+ /** constructor */
8
+ function __construct()
9
+ {
10
+ $widget_options = array('classname' => 'wpdm_affiliate', 'description' => 'WPDM Pro Affiliate Widget');
11
+ parent::__construct(false, 'WPDM Pro Affiliate', $widget_options);
12
+ }
13
+
14
+ /** @see WP_Widget::widget */
15
+ function widget($args, $instance)
16
+ {
17
+ extract($args);
18
+ $title = apply_filters('widget_title', wpdm_valueof($instance, 'title'));
19
+
20
+ echo $before_widget;
21
+
22
+ echo "<div class='w3eden'><div class='panel panel-primary'>";
23
+ echo "<div class='panel-heading' style='font-size: 10pt'>Best File & Document Management Plugin</div><div class='panel-body' style='padding-bottom:0;background:#F2F2F2;'><a href='https://www.wpdownloadmanager.com/?affid={$title}'><img src='https://cdn.wpdownloadmanager.com/wp-content/uploads/2017/09/WordPress-Download-Manager-Intro-4.png' alt='WordPress Download Manager' /></a></div>";
24
+ echo "<div class='panel-footer' style='line-height: 30px'><a class='pull-right btn btn-sm btn-danger' href='https://www.wpdownloadmanager.com/?affid={$title}'>Buy Now <i class='fa fa-angle-right'></i></a><span class='label label-success' style='font-size: 12pt;border-radius: 2px'>$59.00</span></div></div></div>";
25
+ echo $after_widget;
26
+ }
27
+
28
+ /** @see WP_Widget::update */
29
+ function update($new_instance, $old_instance)
30
+ {
31
+ $instance = $old_instance;
32
+ $instance['title'] = strip_tags($new_instance['title']);
33
+ return $instance;
34
+ }
35
+
36
+ /** @see WP_Widget::form */
37
+ function form($instance)
38
+ {
39
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : "";
40
+ ?>
41
+ <p>
42
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('WPDM Affiliate ID:'); ?></label>
43
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
44
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
45
+ <em>It is your account <b>username</b> at www.wpdownloadmanager.com. You will get up to 20% from each
46
+ sale referred by you</em>
47
+ </p>
48
+ <?php
49
+ }
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
 
53
+ register_widget('WPDM_Affiliate');
54
  }
 
 
src/Widgets/CatPackages.php CHANGED
@@ -1,101 +1,108 @@
1
  <?php
2
- if(!defined("ABSPATH")) die("Shit happens!");
3
-
4
- class CatPackages extends WP_Widget {
5
- /** constructor */
6
- function __construct() {
7
- parent::__construct(false, 'WPDM Packages by Category');
8
- }
 
 
9
 
10
- /** @see WP_Widget::widget */
11
- function widget($args, $instance) {
12
- global $post;
13
- extract( $args );
14
- $title = apply_filters('widget_title', $instance['title']);
15
- $sdc3 = $instance['sdc3'];
16
- $cat = $instance['scat'];
17
- $nop = $instance['nop1']<=0?5:$instance['nop1'];
18
- $html = "";
19
- $newp = new \WP_Query(array('post_type'=>'wpdmpro','posts_per_page'=>$nop, 'order_by'=>'publish_date','order'=>'desc',
20
- 'tax_query'=>array(array('taxonomy'=>'wpdmcategory','terms'=>array($cat),'field'=>'id'))));
 
21
 
22
- ?>
23
- <?php echo $before_widget; ?>
24
- <?php if ( $title )
25
  echo $before_title . $title . $after_title;
26
- echo "<div class='w3eden'>";
27
- while($newp->have_posts()){
28
- $newp->the_post();
29
 
30
- $pack = (array)$post;
31
- echo wpdm_fetch_template($sdc3, $pack);
 
 
 
 
32
  }
33
- echo "</div>";
34
- echo $after_widget;
35
- wp_reset_query();
36
- }
37
 
38
- /** @see WP_Widget::update */
39
- function update($new_instance, $old_instance) {
40
- $instance = $old_instance;
41
- $instance['title'] = strip_tags($new_instance['title']);
42
- $instance['sdc3'] = strip_tags($new_instance['sdc3']);
43
- $instance['scat'] = strip_tags($new_instance['scat']);
44
- $instance['nop1'] = strip_tags($new_instance['nop1']);
45
- return $instance;
46
- }
 
47
 
48
- /** @see WP_Widget::form */
49
- function form($instance) {
50
- $title = isset($instance['title']) ? esc_attr($instance['title']):'';
51
- $sdc3 = isset($instance['sdc3'])?$instance['sdc3']:0;
52
- $scat = isset($instance['scat'])?esc_attr($instance['scat']):0;
53
- $nop = isset($instance['nop1']) ?esc_attr($instance['nop1']):5;
54
- $args = array(
55
- 'show_option_all' => '',
56
- 'show_option_none' => '',
57
- 'orderby' => 'ID',
58
- 'order' => 'ASC',
59
- 'show_count' => 0,
60
- 'hide_empty' => 1,
61
- 'child_of' => 0,
62
- 'exclude' => '',
63
- 'echo' => true,
64
- 'selected' => $scat,
65
- 'hierarchical' => 0,
66
- 'name' => $this->get_field_name('scat'),
67
- 'id' => '',
68
- 'class' => 'postform widefat',
69
- 'depth' => 0,
70
- 'tab_index' => 0,
71
- 'taxonomy' => 'wpdmcategory',
72
- 'hide_if_empty' => false,
73
- 'walker' => ''
74
- );
75
- ?>
76
- <p>
77
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
78
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
79
- </p>
80
- <p>
81
- <label for="<?php echo $this->get_field_id('scat'); ?>"><?php _e( "Select Category:" , "download-manager" ); ?></label>
82
- <?php wp_dropdown_categories($args); ?>
 
 
83
 
84
- </p>
85
- <p>
86
- <label for="<?php echo $this->get_field_id('nop1'); ?>"><?php _e( "Number of packages to show:" , "download-manager" ); ?></label>
87
- <input class="widefat" id="<?php echo $this->get_field_id('nop1'); ?>" name="<?php echo $this->get_field_name('nop1'); ?>" type="text" value="<?php echo $nop; ?>" />
88
- </p>
89
- <p>
 
90
 
91
- <label for="<?php echo $this->get_field_id('sdc3'); ?>"><?php _e( "Link Template:" , "download-manager" ); ?></label>
92
- <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc3'), 'id' => $this->get_field_id('sdc3'), 'selected' => $sdc3], true); ?>
93
 
94
 
95
- </p>
96
- <?php
97
- }
98
 
 
99
  }
100
-
101
  register_widget('CatPackages');
1
  <?php
2
+ if (!defined("ABSPATH")) die("Shit happens!");
3
+ if (!class_exists('CatPackages')) {
4
+ class CatPackages extends WP_Widget
5
+ {
6
+ /** constructor */
7
+ function __construct()
8
+ {
9
+ parent::__construct(false, 'WPDM Packages by Category');
10
+ }
11
 
12
+ /** @see WP_Widget::widget */
13
+ function widget($args, $instance)
14
+ {
15
+ global $post;
16
+ extract($args);
17
+ $title = apply_filters('widget_title', $instance['title']);
18
+ $sdc3 = $instance['sdc3'];
19
+ $cat = $instance['scat'];
20
+ $nop = $instance['nop1'] <= 0 ? 5 : $instance['nop1'];
21
+ $html = "";
22
+ $newp = new \WP_Query(array('post_type' => 'wpdmpro', 'posts_per_page' => $nop, 'order_by' => 'publish_date', 'order' => 'desc',
23
+ 'tax_query' => array(array('taxonomy' => 'wpdmcategory', 'terms' => array($cat), 'field' => 'id'))));
24
 
25
+ ?>
26
+ <?php echo $before_widget; ?>
27
+ <?php if ($title)
28
  echo $before_title . $title . $after_title;
29
+ echo "<div class='w3eden'>";
30
+ while ($newp->have_posts()) {
31
+ $newp->the_post();
32
 
33
+ $pack = (array)$post;
34
+ echo wpdm_fetch_template($sdc3, $pack);
35
+ }
36
+ echo "</div>";
37
+ echo $after_widget;
38
+ wp_reset_query();
39
  }
 
 
 
 
40
 
41
+ /** @see WP_Widget::update */
42
+ function update($new_instance, $old_instance)
43
+ {
44
+ $instance = $old_instance;
45
+ $instance['title'] = strip_tags($new_instance['title']);
46
+ $instance['sdc3'] = strip_tags($new_instance['sdc3']);
47
+ $instance['scat'] = strip_tags($new_instance['scat']);
48
+ $instance['nop1'] = strip_tags($new_instance['nop1']);
49
+ return $instance;
50
+ }
51
 
52
+ /** @see WP_Widget::form */
53
+ function form($instance)
54
+ {
55
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
56
+ $sdc3 = isset($instance['sdc3']) ? $instance['sdc3'] : 0;
57
+ $scat = isset($instance['scat']) ? esc_attr($instance['scat']) : 0;
58
+ $nop = isset($instance['nop1']) ? esc_attr($instance['nop1']) : 5;
59
+ $args = array(
60
+ 'show_option_all' => '',
61
+ 'show_option_none' => '',
62
+ 'orderby' => 'ID',
63
+ 'order' => 'ASC',
64
+ 'show_count' => 0,
65
+ 'hide_empty' => 1,
66
+ 'child_of' => 0,
67
+ 'exclude' => '',
68
+ 'echo' => true,
69
+ 'selected' => $scat,
70
+ 'hierarchical' => 0,
71
+ 'name' => $this->get_field_name('scat'),
72
+ 'id' => '',
73
+ 'class' => 'postform widefat',
74
+ 'depth' => 0,
75
+ 'tab_index' => 0,
76
+ 'taxonomy' => 'wpdmcategory',
77
+ 'hide_if_empty' => false,
78
+ 'walker' => ''
79
+ );
80
+ ?>
81
+ <p>
82
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
83
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
84
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
85
+ </p>
86
+ <p>
87
+ <label for="<?php echo $this->get_field_id('scat'); ?>"><?php _e("Select Category:", "download-manager"); ?></label>
88
+ <?php wp_dropdown_categories($args); ?>
89
 
90
+ </p>
91
+ <p>
92
+ <label for="<?php echo $this->get_field_id('nop1'); ?>"><?php _e("Number of packages to show:", "download-manager"); ?></label>
93
+ <input class="widefat" id="<?php echo $this->get_field_id('nop1'); ?>"
94
+ name="<?php echo $this->get_field_name('nop1'); ?>" type="text" value="<?php echo $nop; ?>"/>
95
+ </p>
96
+ <p>
97
 
98
+ <label for="<?php echo $this->get_field_id('sdc3'); ?>"><?php _e("Link Template:", "download-manager"); ?></label>
99
+ <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc3'), 'id' => $this->get_field_id('sdc3'), 'selected' => $sdc3], true); ?>
100
 
101
 
102
+ </p>
103
+ <?php
104
+ }
105
 
106
+ }
107
  }
 
108
  register_widget('CatPackages');
src/Widgets/Categories.php CHANGED
@@ -1,163 +1,188 @@
1
  <?php
2
- use WPDM\Category\CategoryController;
3
-
4
- if(!defined("ABSPATH")) die("Shit happens!");
5
 
6
- class WPDM_Categories extends \WP_Widget {
7
- /** constructor */
8
- function __construct() {
9
- parent::__construct(false, 'WPDM Categories');
10
- }
11
 
12
- /** @see WP_Widget::widget */
13
- function widget($args, $instance) {
14
- extract( $args );
15
- $instance['title'] = isset($instance['title'])?$instance['title']:'';
16
- $title = apply_filters('widget_title', $instance['title']);
17
- $parent = isset($instance['parent']) && $instance['parent'] >0 ?intval($instance['parent']):0;
18
- $style = isset($instance['style'])?esc_attr($instance['style']):'flat';
19
- $toplevel = isset($instance['toplevel'])?esc_attr($instance['toplevel']):0;
20
- $category_page = isset($instance['category_page'])?esc_attr($instance['category_page']):'showall';
21
- $hideon0 = isset($instance['hideon0'])?esc_attr($instance['hideon0']):0;
22
-
23
-
24
- $args = array(
25
- 'orderby' => 'name',
26
- 'order' => 'ASC',
27
- 'hide_empty' => false,
28
- 'exclude' => array(),
29
- 'exclude_tree' => array(),
30
- 'include' => array(),
31
- 'number' => '',
32
- 'fields' => 'all',
33
- 'slug' => '',
34
- 'parent' => '',
35
- 'hierarchical' => ($style == 'flat'?false:true),
36
- 'child_of' => $parent,
37
- 'childless' => false,
38
- 'get' => '',
39
- 'name__like' => '',
40
- 'description__like' => '',
41
- 'pad_counts' => false,
42
- 'offset' => '',
43
- 'search' => '',
44
- 'cache_domain' => 'core'
45
- );
46
-
47
- $object = get_queried_object();
48
- if($category_page == 'subs' && !isset($object->post_type))
49
- $args['parent'] = get_queried_object_id();
50
-
51
- $terms = get_terms("wpdmcategory", $args);
52
-
53
- if($hideon0 == 1 && count($terms) == 0){
54
- return;
55
  }
56
 
57
- echo $before_widget;
58
- if ( $title )
59
- echo $before_title . $title . $after_title;
60
-
61
- if($style == 'flat') {
62
- echo "<div class='w3eden'><div class='list-group'>";
63
- foreach ($terms as $term) {
64
- if(($toplevel == 1 && ($term->parent == 0 || $term->parent === $parent)) || $toplevel == 0)
65
- echo "<a href='" . get_term_link($term) . "' class='list-group-item d-flex justify-content-between align-items-center'>{$term->name}<span class='badge'>{$term->count}</span></a>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
- echo "</div></div>\n";
69
- } else if($style == 'icon' ) {
 
70
 
 
 
 
 
 
 
71
 
72
- echo "<div class='wpdm-categories icon-list'>";
73
- foreach ($terms as $term) {
74
- $icon = CategoryController::icon($term->term_id);
75
- if($icon == '') $icon = "https://cdn1.iconfinder.com/data/icons/gradient-android-apps/64/1-05-512.png";
76
- if(($toplevel == 1 && ($term->parent == 0 || $term->parent === $parent)) || $toplevel == 0)
77
- echo "<div class='icon-cat'><a href='" . get_term_link($term) . "'><img src='{$icon}' class='cat-icon' /> {$term->name}</a></div>\n";
78
- }
79
- echo "</div>";
80
- }
81
- else {
82
-
83
- function wpdm_categories_tree($parent = 0, $selected = array()){
84
- $categories = get_terms( 'wpdmcategory' , array('hide_empty'=>0,'parent'=>$parent));
85
- $checked = "";
86
- foreach($categories as $category){
87
- if($selected){
88
- foreach($selected as $ptype){
89
- if($ptype->term_id==$category->term_id){$checked="checked='checked'";break;}else $checked="";
 
 
 
 
 
 
 
 
90
  }
 
 
 
 
 
 
 
 
91
  }
92
- echo '<li><a href="'.get_term_link($category).'"> '.$category->name.' </a>';
93
- $termchildren = get_term_children( $category->term_id, 'wpdmcategory' );
94
- if($termchildren) {
95
- echo "<ul>";
96
- wpdm_categories_tree($category->term_id, $selected);
97
- echo "</ul>";
98
- }
99
- echo "</li>";
100
  }
101
- }
102
 
103
- echo "<ul class='wpdm-categories'>";
104
- $cparent = $parent;
105
- if($cparent!==0){
106
- $cparent = get_term_by('slug', $cparent, 'wpdmcategory');
107
- $cparent = $cparent->term_id;
 
 
 
108
  }
109
- wpdm_categories_tree($cparent, $terms);
110
- echo "</ul>";
111
  }
112
- echo $after_widget; ?>
113
- <?php
114
- }
115
 
116
- /** @see WP_Widget::update */
117
- function update($new_instance, $old_instance) {
118
- return $new_instance;
119
- }
 
120
 
121
- /** @see WP_Widget::form */
122
- function form($instance) {
123
- $title = isset($instance['title'])?esc_attr($instance['title']):"";
124
- $parent = isset($instance['parent'])?intval($instance['parent']):0;
125
- $style = isset($instance['style'])?esc_attr($instance['style']):'flat';
126
- $toplevel = isset($instance['toplevel'])?esc_attr($instance['toplevel']):0;
127
- $category_page = isset($instance['category_page'])?esc_attr($instance['category_page']):0;
128
- $hideon0 = isset($instance['hideon0'])?esc_attr($instance['hideon0']):0;
129
- ?>
130
- <p>
131
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
132
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
133
- </p>
134
- <p>
135
- <label for="<?php echo $this->get_field_id('parent'); ?>"><?php _e('Parent:'); ?></label><br/>
136
- <?php wpdm_dropdown_categories($this->get_field_name('parent'), $parent, $this->get_field_id('parent')); ?>
137
- </p>
138
- <p>
139
- <label for="<?php echo $this->get_field_id('category_page'); ?>"><?php _e('On Category Page:', 'download-manger'); ?></label><br/>
140
- <select id="<?php echo $this->get_field_id('category_page'); ?>" name="<?php echo $this->get_field_name('category_page'); ?>">
141
- <option value="showall" <?php selected('showall', $category_page ); ?>><?php echo __( "Show all", "download-manager" ) ?></option>
142
- <option value="subs" <?php selected('subs', $category_page ); ?>><?php echo __( "Show subcategories only", "download-manager" ) ?></option>
143
- </select>
144
- </p>
145
- <p>
146
- <label><?php _e('Style:'); ?></label><br/>
147
- <label><input type="radio" name="<?php echo $this->get_field_name('style'); ?>" <?php checked('flat', $style); ?> value="flat"> Flat List</label><br/>
148
- <label><input type="radio" name="<?php echo $this->get_field_name('style'); ?>" <?php checked('tree', $style); ?> value="tree"> Hierarchy List</label><br/>
149
- <label><input type="radio" name="<?php echo $this->get_field_name('style'); ?>" <?php checked('icon', $style); ?> value="icon"> Icon List ( Flat )</label><br/>
150
- <!-- label><input type="radio" name="<?php echo $this->get_field_name('style'); ?>" <?php checked('dropdown', $style); ?> value="dropdown"> Dropdown List</label></br -->
151
- </p>
152
- <p>
153
- <label for="<?php echo $this->get_field_id('toplevel'); ?>"><input type="checkbox" name="<?php echo $this->get_field_name('toplevel'); ?>" <?php checked('1', $toplevel); ?> value="1"> <?php _e('Top Level Only', 'download-manager'); ?></label><br/>
154
- </p>
155
- <p>
156
- <label for="<?php echo $this->get_field_id('hideon0'); ?>"><input type="checkbox" name="<?php echo $this->get_field_name('hideon0'); ?>" <?php checked('1', $hideon0); ?> value="1"> <?php _e('Hide widget when no category', 'download-manager'); ?></label><br/>
157
- </p>
158
- <?php
159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
 
161
  }
162
 
163
  register_widget('WPDM_Categories');
 
1
  <?php
 
 
 
2
 
3
+ use WPDM\Category\CategoryController;
 
 
 
 
4
 
5
+ if (!defined("ABSPATH")) die("Shit happens!");
6
+ if (!class_exists('WPDM_Categories')) {
7
+ class WPDM_Categories extends \WP_Widget
8
+ {
9
+ /** constructor */
10
+ function __construct()
11
+ {
12
+ parent::__construct(false, 'WPDM Categories');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
+ /** @see WP_Widget::widget */
16
+ function widget($args, $instance)
17
+ {
18
+ extract($args);
19
+ $instance['title'] = isset($instance['title']) ? $instance['title'] : '';
20
+ $title = apply_filters('widget_title', $instance['title']);
21
+ $parent = isset($instance['parent']) && $instance['parent'] > 0 ? intval($instance['parent']) : 0;
22
+ $style = isset($instance['style']) ? esc_attr($instance['style']) : 'flat';
23
+ $toplevel = isset($instance['toplevel']) ? esc_attr($instance['toplevel']) : 0;
24
+ $category_page = isset($instance['category_page']) ? esc_attr($instance['category_page']) : 'showall';
25
+ $hideon0 = isset($instance['hideon0']) ? esc_attr($instance['hideon0']) : 0;
26
+
27
+
28
+ $args = array(
29
+ 'orderby' => 'name',
30
+ 'order' => 'ASC',
31
+ 'hide_empty' => false,
32
+ 'exclude' => array(),
33
+ 'exclude_tree' => array(),
34
+ 'include' => array(),
35
+ 'number' => '',
36
+ 'fields' => 'all',
37
+ 'slug' => '',
38
+ 'parent' => '',
39
+ 'hierarchical' => ($style == 'flat' ? false : true),
40
+ 'child_of' => $parent,
41
+ 'childless' => false,
42
+ 'get' => '',
43
+ 'name__like' => '',
44
+ 'description__like' => '',
45
+ 'pad_counts' => false,
46
+ 'offset' => '',
47
+ 'search' => '',
48
+ 'cache_domain' => 'core'
49
+ );
50
+
51
+ $object = get_queried_object();
52
+ if ($category_page == 'subs' && !isset($object->post_type))
53
+ $args['parent'] = get_queried_object_id();
54
+
55
+ $terms = get_terms("wpdmcategory", $args);
56
+
57
+ if ($hideon0 == 1 && count($terms) == 0) {
58
+ return;
59
  }
60
 
61
+ echo $before_widget;
62
+ if ($title)
63
+ echo $before_title . $title . $after_title;
64
 
65
+ if ($style == 'flat') {
66
+ echo "<div class='w3eden'><div class='list-group'>";
67
+ foreach ($terms as $term) {
68
+ if (($toplevel == 1 && ($term->parent == 0 || $term->parent === $parent)) || $toplevel == 0)
69
+ echo "<a href='" . get_term_link($term) . "' class='list-group-item d-flex justify-content-between align-items-center'>{$term->name}<span class='badge'>{$term->count}</span></a>\n";
70
+ }
71
 
72
+ echo "</div></div>\n";
73
+ } else if ($style == 'icon') {
74
+
75
+
76
+ echo "<div class='wpdm-categories icon-list'>";
77
+ foreach ($terms as $term) {
78
+ $icon = CategoryController::icon($term->term_id);
79
+ if ($icon == '') $icon = "https://cdn1.iconfinder.com/data/icons/gradient-android-apps/64/1-05-512.png";
80
+ if (($toplevel == 1 && ($term->parent == 0 || $term->parent === $parent)) || $toplevel == 0)
81
+ echo "<div class='icon-cat'><a href='" . get_term_link($term) . "'><img src='{$icon}' class='cat-icon' /> {$term->name}</a></div>\n";
82
+ }
83
+ echo "</div>";
84
+ } else {
85
+
86
+ function wpdm_categories_tree($parent = 0, $selected = array())
87
+ {
88
+ $categories = get_terms('wpdmcategory', array('hide_empty' => 0, 'parent' => $parent));
89
+ $checked = "";
90
+ foreach ($categories as $category) {
91
+ if ($selected) {
92
+ foreach ($selected as $ptype) {
93
+ if ($ptype->term_id == $category->term_id) {
94
+ $checked = "checked='checked'";
95
+ break;
96
+ } else $checked = "";
97
+ }
98
  }
99
+ echo '<li><a href="' . get_term_link($category) . '"> ' . $category->name . ' </a>';
100
+ $termchildren = get_term_children($category->term_id, 'wpdmcategory');
101
+ if ($termchildren) {
102
+ echo "<ul>";
103
+ wpdm_categories_tree($category->term_id, $selected);
104
+ echo "</ul>";
105
+ }
106
+ echo "</li>";
107
  }
 
 
 
 
 
 
 
 
108
  }
 
109
 
110
+ echo "<ul class='wpdm-categories'>";
111
+ $cparent = $parent;
112
+ if ($cparent !== 0) {
113
+ $cparent = get_term_by('slug', $cparent, 'wpdmcategory');
114
+ $cparent = $cparent->term_id;
115
+ }
116
+ wpdm_categories_tree($cparent, $terms);
117
+ echo "</ul>";
118
  }
119
+ echo $after_widget; ?>
120
+ <?php
121
  }
 
 
 
122
 
123
+ /** @see WP_Widget::update */
124
+ function update($new_instance, $old_instance)
125
+ {
126
+ return $new_instance;
127
+ }
128
 
129
+ /** @see WP_Widget::form */
130
+ function form($instance)
131
+ {
132
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : "";
133
+ $parent = isset($instance['parent']) ? intval($instance['parent']) : 0;
134
+ $style = isset($instance['style']) ? esc_attr($instance['style']) : 'flat';
135
+ $toplevel = isset($instance['toplevel']) ? esc_attr($instance['toplevel']) : 0;
136
+ $category_page = isset($instance['category_page']) ? esc_attr($instance['category_page']) : 0;
137
+ $hideon0 = isset($instance['hideon0']) ? esc_attr($instance['hideon0']) : 0;
138
+ ?>
139
+ <p>
140
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
141
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
142
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
143
+ </p>
144
+ <p>
145
+ <label for="<?php echo $this->get_field_id('parent'); ?>"><?php _e('Parent:'); ?></label><br/>
146
+ <?php wpdm_dropdown_categories($this->get_field_name('parent'), $parent, $this->get_field_id('parent')); ?>
147
+ </p>
148
+ <p>
149
+ <label for="<?php echo $this->get_field_id('category_page'); ?>"><?php _e('On Category Page:', 'download-manger'); ?></label><br/>
150
+ <select id="<?php echo $this->get_field_id('category_page'); ?>"
151
+ name="<?php echo $this->get_field_name('category_page'); ?>">
152
+ <option value="showall" <?php selected('showall', $category_page); ?>><?php echo __("Show all", "download-manager") ?></option>
153
+ <option value="subs" <?php selected('subs', $category_page); ?>><?php echo __("Show subcategories only", "download-manager") ?></option>
154
+ </select>
155
+ </p>
156
+ <p>
157
+ <label><?php _e('Style:'); ?></label><br/>
158
+ <label><input type="radio"
159
+ name="<?php echo $this->get_field_name('style'); ?>" <?php checked('flat', $style); ?>
160
+ value="flat"> Flat List</label><br/>
161
+ <label><input type="radio"
162
+ name="<?php echo $this->get_field_name('style'); ?>" <?php checked('tree', $style); ?>
163
+ value="tree"> Hierarchy List</label><br/>
164
+ <label><input type="radio"
165
+ name="<?php echo $this->get_field_name('style'); ?>" <?php checked('icon', $style); ?>
166
+ value="icon"> Icon List ( Flat )</label><br/>
167
+ <!-- label><input type="radio" name="<?php echo $this->get_field_name('style'); ?>" <?php checked('dropdown', $style); ?> value="dropdown"> Dropdown List</label></br -->
168
+ </p>
169
+ <p>
170
+ <label for="<?php echo $this->get_field_id('toplevel'); ?>"><input type="checkbox"
171
+ name="<?php echo $this->get_field_name('toplevel'); ?>" <?php checked('1', $toplevel); ?>
172
+ value="1"> <?php _e('Top Level Only', 'download-manager'); ?>
173
+ </label><br/>
174
+ </p>
175
+ <p>
176
+ <label for="<?php echo $this->get_field_id('hideon0'); ?>"><input type="checkbox"
177
+ name="<?php echo $this->get_field_name('hideon0'); ?>" <?php checked('1', $hideon0); ?>
178
+ value="1"> <?php _e('Hide widget when no category', 'download-manager'); ?>
179
+ </label><br/>
180
+ </p>
181
+ <?php
182
+ }
183
 
184
+ }
185
  }
186
 
187
  register_widget('WPDM_Categories');
188
+
src/Widgets/ListPackages.php CHANGED
@@ -1,137 +1,153 @@
1
  <?php
2
- if(!defined("ABSPATH")) die("Shit happens!");
 
 
 
 
 
 
 
 
3
 
4
- class ListPackages extends WP_Widget {
5
- /** constructor */
6
- function __construct() {
7
- parent::__construct(false, 'WPDM Packages');
8
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- /** @see WP_Widget::widget */
11
- function widget($args, $instance) {
12
- global $post;
13
- extract( $args );
14
- $title = apply_filters('widget_title', (isset($instance['title'])?$instance['title']:''));
15
- $sdc3 = isset($instance['sdc3'])?$instance['sdc3']:'';
16
- $cat = isset($instance['scat'])?$instance['scat']:'';
17
- $nop = !isset($instance['nop1']) || $instance['nop1'] <= 0 ? 5 : $instance['nop1'];
18
- $html = "";
19
- $order_by = isset($instance['order_by'])?$instance['order_by']:'publish_date';
20
- $order = isset($instance['order'])?$instance['order']:'desc';
21
- $params = array('post_type'=>'wpdmpro','posts_per_page'=>$nop, 'orderby'=>$order_by,'order'=>$order);
22
- if($cat > 0)
23
- $params['tax_query'] = array(array('taxonomy'=>'wpdmcategory','terms'=>array($cat),'field'=>'id'));
24
- if(strstr($order_by, "_wpdm_")) {
25
- $params['orderby'] = 'meta_value_num';
26
- $params['meta_key'] = $order_by;
27
  }
28
- $newp = new \WP_Query($params);
29
- //$params['orderby'] = 'meta_value_num';
30
- ?>
31
- <?php echo $before_widget; ?>
32
- <?php if ( $title )
33
- echo $before_title . $title . $after_title;
34
- echo "<div class='w3eden'>";
35
- while($newp->have_posts()){
36
- $newp->the_post();
37
 
38
- $pack = (array)$post;
39
- echo wpdm_fetch_template($sdc3, $pack);
 
 
 
 
 
 
 
 
 
40
  }
41
- echo "</div>";
42
- echo $after_widget;
43
- wp_reset_query();
44
- }
45
 
46
- /** @see WP_Widget::update */
47
- function update($new_instance, $old_instance) {
48
- $instance = $old_instance;
49
- $instance['title'] = strip_tags($new_instance['title']);
50
- $instance['sdc3'] = strip_tags($new_instance['sdc3']);
51
- $instance['scat'] = strip_tags($new_instance['scat']);
52
- $instance['nop1'] = strip_tags($new_instance['nop1']);
53
- $instance['order_by'] = strip_tags($new_instance['order_by']);
54
- $instance['order'] = strip_tags($new_instance['order']);
55
- return $instance;
56
- }
57
 
58
- /** @see WP_Widget::form */
59
- function form($instance) {
60
- $title = isset($instance['title']) ? esc_attr($instance['title']):'';
61
- $sdc3 = isset($instance['sdc3'])?$instance['sdc3']:0;
62
- $scat = isset($instance['scat'])?esc_attr($instance['scat']):0;
63
- $nop = isset($instance['nop1']) ?esc_attr($instance['nop1']):5;
64
- $order_by = isset($instance['order_by'])?$instance['order_by']:'';
65
- $order = isset($instance['order'])?$instance['order']:'';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
- $args = array(
68
- 'show_option_all' => 'All Categories',
69
- 'show_option_none' => '',
70
- 'orderby' => 'ID',
71
- 'order' => 'ASC',
72
- 'show_count' => 0,
73
- 'hide_empty' => 1,
74
- 'child_of' => 0,
75
- 'exclude' => '',
76
- 'echo' => true,
77
- 'selected' => $scat,
78
- 'hierarchical' => 0,
79
- 'name' => $this->get_field_name('scat'),
80
- 'id' => '',
81
- 'class' => 'postform widefat',
82
- 'depth' => 0,
83
- 'tab_index' => 0,
84
- 'taxonomy' => 'wpdmcategory',
85
- 'hide_if_empty' => false,
86
- 'walker' => ''
87
- );
88
- ?>
89
- <p>
90
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
91
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
92
- </p>
93
- <p>
94
- <label for="<?php echo $this->get_field_id('scat'); ?>"><?php _e( "Select Category:" , "download-manager" ); ?></label>
95
 
96
- <?php wp_dropdown_categories($args); ?>
97
 
 
 
 
 
 
 
98
 
99
- </p>
100
- <p>
101
- <strong><label><?php echo __( "On Single Download Page", "download-manager" ); ?>:</label></strong><br/>
102
- <label><input type="checkbox" value="1" name="<?php echo $this->get_field_name('cpc'); ?>" id="<?php echo $this->get_field_id('cpc'); ?>"> <?php _e( "Show packages from current package category", "download-manager" ) ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- </p>
105
- <p>
106
- <strong>Order:</strong><br/>
107
- <select id="plob" style="margin-right: 5px" name="<?php echo $this->get_field_name('order_by'); ?>">
108
- <option value="date" >Order By:</option>
109
- <option value="date" <?php selected('date', $order_by); ?>>Publish Date</option>
110
- <option value="post_title" <?php selected('post_title', $order_by); ?>>Title</option>
111
- <option value="__wpdm_download_count" <?php selected('__wpdm_download_count', $order_by); ?>>Downloads</option>
112
- <option value="__wpdm_package_size_b" <?php selected('__wpdm_package_size_b', $order_by); ?>>Package Size</option>
113
- <option value="__wpdm_view_count" <?php selected('__wpdm_view_count', $order_by); ?>>Views</option>
114
- <option value="modified" <?php selected('modified', $order_by); ?>>Update Date</option>
115
- </select><select id="plobs" style="margin-right: 5px" name="<?php echo $this->get_field_name('order'); ?>">
116
- <option value="asc">Order:</option>
117
- <option value="asc" <?php selected('asc', $order); ?>>Asc</option>
118
- <option value="desc" <?php selected('desc', $order); ?>>Desc</option>
119
- </select>
120
- </p>
121
- <p>
122
- <strong><label for="<?php echo $this->get_field_id('nop1'); ?>"><?php _e( "Number of packages to show:" , "download-manager" ); ?></label></strong>
123
- <input class="widefat form-control" id="<?php echo $this->get_field_id('nop1'); ?>" name="<?php echo $this->get_field_name('nop1'); ?>" type="text" value="<?php echo $nop; ?>" />
124
- </p>
125
- <p>
126
 
127
- <strong><label for="<?php echo $this->get_field_id('sdc3'); ?>"><?php _e( "Link Template:" , "download-manager" ); ?></label></strong>
128
- <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc3'), 'id' => $this->get_field_id('sdc3'), 'selected' => $sdc3], true); ?>
129
 
 
 
 
130
 
131
- </p>
132
- <?php
133
  }
134
-
135
  }
136
-
137
  register_widget('ListPackages');
1
  <?php
2
+ if (!defined("ABSPATH")) die("Shit happens!");
3
+ if (!class_exists('ListPackages')) {
4
+ class ListPackages extends WP_Widget
5
+ {
6
+ /** constructor */
7
+ function __construct()
8
+ {
9
+ parent::__construct(false, 'WPDM Packages');
10
+ }
11
 
12
+ /** @see WP_Widget::widget */
13
+ function widget($args, $instance)
14
+ {
15
+ global $post;
16
+ extract($args);
17
+ $title = apply_filters('widget_title', (isset($instance['title']) ? $instance['title'] : ''));
18
+ $sdc3 = isset($instance['sdc3']) ? $instance['sdc3'] : '';
19
+ $cat = isset($instance['scat']) ? $instance['scat'] : '';
20
+ $nop = !isset($instance['nop1']) || $instance['nop1'] <= 0 ? 5 : $instance['nop1'];
21
+ $html = "";
22
+ $order_by = isset($instance['order_by']) ? $instance['order_by'] : 'publish_date';
23
+ $order = isset($instance['order']) ? $instance['order'] : 'desc';
24
+ $params = array('post_type' => 'wpdmpro', 'posts_per_page' => $nop, 'orderby' => $order_by, 'order' => $order);
25
+ if ($cat > 0)
26
+ $params['tax_query'] = array(array('taxonomy' => 'wpdmcategory', 'terms' => array($cat), 'field' => 'id'));
27
+ if (strstr($order_by, "_wpdm_")) {
28
+ $params['orderby'] = 'meta_value_num';
29
+ $params['meta_key'] = $order_by;
30
+ }
31
+ $newp = new \WP_Query($params);
32
+ //$params['orderby'] = 'meta_value_num';
33
+ ?>
34
+ <?php echo $before_widget; ?>
35
+ <?php if ($title)
36
+ echo $before_title . $title . $after_title;
37
+ echo "<div class='w3eden'>";
38
+ while ($newp->have_posts()) {
39
+ $newp->the_post();
40
 
41
+ $pack = (array)$post;
42
+ echo wpdm_fetch_template($sdc3, $pack);
43
+ }
44
+ echo "</div>";
45
+ echo $after_widget;
46
+ wp_reset_query();
 
 
 
 
 
 
 
 
 
 
 
47
  }
 
 
 
 
 
 
 
 
 
48
 
49
+ /** @see WP_Widget::update */
50
+ function update($new_instance, $old_instance)
51
+ {
52
+ $instance = $old_instance;
53
+ $instance['title'] = strip_tags($new_instance['title']);
54
+ $instance['sdc3'] = strip_tags($new_instance['sdc3']);
55
+ $instance['scat'] = strip_tags($new_instance['scat']);
56
+ $instance['nop1'] = strip_tags($new_instance['nop1']);
57
+ $instance['order_by'] = strip_tags($new_instance['order_by']);
58
+ $instance['order'] = strip_tags($new_instance['order']);
59
+ return $instance;
60
  }
 
 
 
 
61
 
62
+ /** @see WP_Widget::form */
63
+ function form($instance)
64
+ {
65
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
66
+ $sdc3 = isset($instance['sdc3']) ? $instance['sdc3'] : 0;
67
+ $scat = isset($instance['scat']) ? esc_attr($instance['scat']) : 0;
68
+ $nop = isset($instance['nop1']) ? esc_attr($instance['nop1']) : 5;
69
+ $order_by = isset($instance['order_by']) ? $instance['order_by'] : '';
70
+ $order = isset($instance['order']) ? $instance['order'] : '';
 
 
71
 
72
+ $args = array(
73
+ 'show_option_all' => 'All Categories',
74
+ 'show_option_none' => '',
75
+ 'orderby' => 'ID',
76
+ 'order' => 'ASC',
77
+ 'show_count' => 0,
78
+ 'hide_empty' => 1,
79
+ 'child_of' => 0,
80
+ 'exclude' => '',
81
+ 'echo' => true,
82
+ 'selected' => $scat,
83
+ 'hierarchical' => 0,
84
+ 'name' => $this->get_field_name('scat'),
85
+ 'id' => '',
86
+ 'class' => 'postform widefat',
87
+ 'depth' => 0,
88
+ 'tab_index' => 0,
89
+ 'taxonomy' => 'wpdmcategory',
90
+ 'hide_if_empty' => false,
91
+ 'walker' => ''
92
+ );
93
+ ?>
94
+ <p>
95
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
96
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
97
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
98
+ </p>
99
+ <p>
100
+ <label for="<?php echo $this->get_field_id('scat'); ?>"><?php _e("Select Category:", "download-manager"); ?></label>
101
 
102
+ <?php wp_dropdown_categories($args); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
 
104
 
105
+ </p>
106
+ <p>
107
+ <strong><label><?php echo __("On Single Download Page", "download-manager"); ?>:</label></strong><br/>
108
+ <label><input type="checkbox" value="1" name="<?php echo $this->get_field_name('cpc'); ?>"
109
+ id="<?php echo $this->get_field_id('cpc'); ?>"> <?php _e("Show packages from current package category", "download-manager") ?>
110
+ </label>
111
 
112
+ </p>
113
+ <p>
114
+ <strong>Order:</strong><br/>
115
+ <select id="plob" style="margin-right: 5px" name="<?php echo $this->get_field_name('order_by'); ?>">
116
+ <option value="date">Order By:</option>
117
+ <option value="date" <?php selected('date', $order_by); ?>>Publish Date</option>
118
+ <option value="post_title" <?php selected('post_title', $order_by); ?>>Title</option>
119
+ <option value="__wpdm_download_count" <?php selected('__wpdm_download_count', $order_by); ?>>
120
+ Downloads
121
+ </option>
122
+ <option value="__wpdm_package_size_b" <?php selected('__wpdm_package_size_b', $order_by); ?>>Package
123
+ Size
124
+ </option>
125
+ <option value="__wpdm_view_count" <?php selected('__wpdm_view_count', $order_by); ?>>Views</option>
126
+ <option value="modified" <?php selected('modified', $order_by); ?>>Update Date</option>
127
+ </select><select id="plobs" style="margin-right: 5px"
128
+ name="<?php echo $this->get_field_name('order'); ?>">
129
+ <option value="asc">Order:</option>
130
+ <option value="asc" <?php selected('asc', $order); ?>>Asc</option>
131
+ <option value="desc" <?php selected('desc', $order); ?>>Desc</option>
132
+ </select>
133
+ </p>
134
+ <p>
135
+ <strong><label
136
+ for="<?php echo $this->get_field_id('nop1'); ?>"><?php _e("Number of packages to show:", "download-manager"); ?></label></strong>
137
+ <input class="widefat form-control" id="<?php echo $this->get_field_id('nop1'); ?>"
138
+ name="<?php echo $this->get_field_name('nop1'); ?>" type="text" value="<?php echo $nop; ?>"/>
139
+ </p>
140
+ <p>
141
 
142
+ <strong><label
143
+ for="<?php echo $this->get_field_id('sdc3'); ?>"><?php _e("Link Template:", "download-manager"); ?></label></strong>
144
+ <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc3'), 'id' => $this->get_field_id('sdc3'), 'selected' => $sdc3], true); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
 
 
146
 
147
+ </p>
148
+ <?php
149
+ }
150
 
 
 
151
  }
 
152
  }
 
153
  register_widget('ListPackages');
src/Widgets/NewDownloads.php CHANGED
@@ -1,68 +1,75 @@
1
  <?php
2
- if(!defined("ABSPATH")) die("Shit happens!");
3
-
4
- class WPDM_NewDownloads extends WP_Widget {
5
- /** constructor */
6
- function __construct() {
7
- parent::__construct(false, 'WPDM New Packages');
8
- }
 
 
9
 
10
- /** @see WP_Widget::widget */
11
- function widget($args, $instance) {
12
- global $post;
13
- extract( $args );
14
- $title = isset($instance['title'])?apply_filters('widget_title', $instance['title']):"";
15
- $sdc = isset($instance['sdc'])?$instance['sdc']:'';
16
- $nop = isset($instance['nop1'])?$instance['nop1']:5;
 
17
 
18
- $newp = new \WP_Query(array('post_type'=>'wpdmpro','posts_per_page'=>$nop, 'orderby'=>'date','order'=>'desc'));
19
- ?>
20
- <?php echo $before_widget; ?>
21
- <?php if ( $title )
22
  echo $before_title . $title . $after_title;
23
- echo "<div class='w3eden'>";
24
- while($newp->have_posts()){
25
- $newp->the_post();
26
 
27
- $pack = (array)$post;
28
- echo wpdm_fetch_template($sdc, $pack);
 
 
 
 
29
  }
30
- echo "</div>";
31
- echo $after_widget;
32
- wp_reset_query();
33
- }
34
 
35
- /** @see WP_Widget::update */
36
- function update($new_instance, $old_instance) {
37
- $instance = $old_instance;
38
- $instance['title'] = strip_tags($new_instance['title']);
39
- $instance['sdc'] = strip_tags($new_instance['sdc']);
40
- $instance['nop1'] = strip_tags($new_instance['nop1']);
41
- return $instance;
42
- }
 
43
 
44
- /** @see WP_Widget::form */
45
- function form($instance) {
46
- $title = isset($instance['title'])?esc_attr($instance['title']):"";
47
- $sdc = isset($instance['sdc'])?esc_attr($instance['sdc']):'link-template-default.php';
48
- $nop = isset($instance['nop1'])?esc_attr($instance['nop1']):5;
49
- ?>
50
- <p>
51
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
52
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
53
- </p>
54
- <p>
55
- <label for="<?php echo $this->get_field_id('nop1'); ?>"><?php _e('Number of packages to show:'); ?></label>
56
- <input class="widefat" id="<?php echo $this->get_field_id('nop1'); ?>" name="<?php echo $this->get_field_name('nop1'); ?>" type="text" value="<?php echo $nop; ?>" />
57
- </p>
58
- <p>
 
 
 
59
 
60
- <label for="<?php echo $this->get_field_id('sdc'); ?>"><?php _e('Link Template:'); ?></label>
61
- <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc'), 'id' => $this->get_field_id('sdc'), 'selected' => $sdc], true); ?>
62
- </p>
63
- <?php
64
- }
65
 
 
66
  }
67
-
68
  register_widget('WPDM_NewDownloads');
1
  <?php
2
+ if (!defined("ABSPATH")) die("Shit happens!");
3
+ if (!class_exists('WPDM_NewDownloads')) {
4
+ class WPDM_NewDownloads extends WP_Widget
5
+ {
6
+ /** constructor */
7
+ function __construct()
8
+ {
9
+ parent::__construct(false, 'WPDM New Packages');
10
+ }
11
 
12
+ /** @see WP_Widget::widget */
13
+ function widget($args, $instance)
14
+ {
15
+ global $post;
16
+ extract($args);
17
+ $title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : "";
18
+ $sdc = isset($instance['sdc']) ? $instance['sdc'] : '';
19
+ $nop = isset($instance['nop1']) ? $instance['nop1'] : 5;
20
 
21
+ $newp = new \WP_Query(array('post_type' => 'wpdmpro', 'posts_per_page' => $nop, 'orderby' => 'date', 'order' => 'desc'));
22
+ ?>
23
+ <?php echo $before_widget; ?>
24
+ <?php if ($title)
25
  echo $before_title . $title . $after_title;
26
+ echo "<div class='w3eden'>";
27
+ while ($newp->have_posts()) {
28
+ $newp->the_post();
29
 
30
+ $pack = (array)$post;
31
+ echo wpdm_fetch_template($sdc, $pack);
32
+ }
33
+ echo "</div>";
34
+ echo $after_widget;
35
+ wp_reset_query();
36
  }
 
 
 
 
37
 
38
+ /** @see WP_Widget::update */
39
+ function update($new_instance, $old_instance)
40
+ {
41
+ $instance = $old_instance;
42
+ $instance['title'] = strip_tags($new_instance['title']);
43
+ $instance['sdc'] = strip_tags($new_instance['sdc']);
44
+ $instance['nop1'] = strip_tags($new_instance['nop1']);
45
+ return $instance;
46
+ }
47
 
48
+ /** @see WP_Widget::form */
49
+ function form($instance)
50
+ {
51
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : "";
52
+ $sdc = isset($instance['sdc']) ? esc_attr($instance['sdc']) : 'link-template-default.php';
53
+ $nop = isset($instance['nop1']) ? esc_attr($instance['nop1']) : 5;
54
+ ?>
55
+ <p>
56
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
57
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
58
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
59
+ </p>
60
+ <p>
61
+ <label for="<?php echo $this->get_field_id('nop1'); ?>"><?php _e('Number of packages to show:'); ?></label>
62
+ <input class="widefat" id="<?php echo $this->get_field_id('nop1'); ?>"
63
+ name="<?php echo $this->get_field_name('nop1'); ?>" type="text" value="<?php echo $nop; ?>"/>
64
+ </p>
65
+ <p>
66
 
67
+ <label for="<?php echo $this->get_field_id('sdc'); ?>"><?php _e('Link Template:'); ?></label>
68
+ <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc'), 'id' => $this->get_field_id('sdc'), 'selected' => $sdc], true); ?>
69
+ </p>
70
+ <?php
71
+ }
72
 
73
+ }
74
  }
 
75
  register_widget('WPDM_NewDownloads');
src/Widgets/PackageInfo.php CHANGED
@@ -1,139 +1,176 @@
1
  <?php
2
- if(!defined("ABSPATH")) die("Shit happens!");
3
-
4
- class PackageInfo extends WP_Widget {
5
- /** constructor */
6
- function __construct() {
7
-
8
- parent::__construct(false, 'WPDM Packages Info');
9
- }
10
-
11
- /** @see WP_Widget::widget */
12
- function widget($args, $instance) {
13
-
14
- if(!is_singular('wpdmpro')) return;
15
-
16
- global $post;
17
- extract( $args );
18
- $title = apply_filters('widget_title', $instance['title']);
19
- $package_info = isset($instance['pinfo'])?$instance['pinfo']:array();
20
- $package_info_labels = array(
21
- 'download_count' => __( "Total Downloads" , "download-manager" ),
22
- 'view_count' => __( "Total Views" , "download-manager" ),
23
- 'create_date' => __( "Publish Date" , "download-manager" ),
24
- 'update_date' => __( "Last Updated" , "download-manager" ),
25
- 'package_size' => __( "Size" , "download-manager" ),
26
- 'version' => __( "Version" , "download-manager" ),
27
- );
28
-
29
- $package_info_icons = array(
30
- 'download_count' => 'arrow-alt-circle-down',
31
- 'view_count' => 'eye',
32
- 'package_size' => 'hdd',
33
- 'version' => 'layer-group',
34
- );
35
- $download_link = "";
36
- if(isset($package_info['download_link'])){
37
- unset($package_info['download_link']);
38
- if(isset($package_info['download_link_ext']))
39
- $download_link = WPDM()->package->downloadLink(get_the_ID(), 1, array('popstyle' => 'popup'));
40
- else
41
- $download_link = WPDM()->package->downloadLink(get_the_ID(), 0, array('popstyle' => 'popup'));
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- ?>
46
- <?php echo $before_widget; ?>
47
- <?php if ( isset($title) & $title != '')
48
  echo $before_title . $title . $after_title;
49
- if(isset($instance['table']) && $instance['table'] == 1) {
50
- echo "<div class='w3eden'><table class='table table-striped table-bordered' style='font-size: 9pt'>";
51
-
52
- if (is_array($package_info)) {
53
- foreach ($package_info as $index => $v) {
54
- if ($index == 'create_date')
55
- echo "<tr><td>{$package_info_labels[$index]}</td><td>" . get_the_date() . "</td></tr>";
56
- else if ($index == 'update_date')
57
- echo "<tr><td>{$package_info_labels[$index]}</td><td>" . get_the_modified_date() . "</td></tr>";
58
- else if($index != 'download_link_ext')
59
- echo "<tr><td>{$package_info_labels[$index]}</td><td>" . get_post_meta(get_the_ID(), '__wpdm_' . $index, true) . "</td></tr>";
 
60
  }
61
- }
62
- if($download_link != '')
63
- $download_link = "<tr><td colspan='2' class='text-center'>" . $download_link . "</td>";
64
- echo "{$download_link}</table></div>";
65
- } else {
66
- echo "<div class='w3eden'><div class='list-group package-info-list'>";
67
-
68
- if(is_array($package_info)){
69
- foreach($package_info as $index => $v){
70
- if($index=='create_date')
71
- echo "<div class='list-group-item'><div class='media'><div class='pull-left mr-3'><i class='fa fa-calendar'></i></div><div class='media-body'><strong>{$package_info_labels[$index]}</strong><br/>".get_the_date()."</div></div></div>";
72
- else if($index=='update_date')
73
- echo "<div class='list-group-item'><div class='media'><div class='pull-left mr-3'><i class='fa fa-calendar-check'></i></div><div class='media-body'><strong>{$package_info_labels[$index]}</strong><br/>".get_the_modified_date()."</div></div></div>";
74
- else if($index != 'download_link_ext' && isset($package_info_labels[$index]))
75
- echo "<div class='list-group-item'><div class='media'><div class='pull-left mr-3'><i class='fa fa-{$package_info_icons[$index]}'></i></div><div class='media-body'><strong>{$package_info_labels[$index]}</strong><br/>".get_post_meta(get_the_ID(), '__wpdm_'.$index, true)."</div></div></div>";
76
  }
77
- }
78
-
79
- echo "<div class='list-group-item'>{$download_link}</div></div></div>";
80
- }
81
 
 
 
82
 
83
- echo $after_widget;
84
 
85
- if(is_array($package_info) && isset($package_info['qrcode'])) {
86
- echo $before_widget;
87
- echo "<img class='wpdm-qr-code wpdm-qr-code-widget' style='max-width: 100%' src='https://chart.googleapis.com/chart?cht=qr&chs=450x450&choe=UTF-8&chld=H|0&chl=".get_permalink(get_the_ID())."' alt='".get_the_title()."' />";
88
  echo $after_widget;
89
- }
90
- wp_reset_query();
91
- }
92
-
93
- /** @see WP_Widget::update */
94
- function update($new_instance, $old_instance) {
95
- $instance = $new_instance;
96
- return $instance;
97
- }
98
-
99
- /** @see WP_Widget::form */
100
- function form($instance) {
101
- if(isset($instance['title']))
102
- $title = esc_attr($instance['title']);
103
- else $title = '';
104
- if(isset($instance['pinfo']))
105
- $package_info = $instance['pinfo'];
106
-
107
-
108
-
109
- ?>
110
- <p>
111
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
112
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
113
- </p>
114
- <p>
115
- <label for="<?php echo $this->get_field_id('scat'); ?>"><?php _e( "Fields to Show:" , "download-manager" ); ?></label>
116
-
117
- <ul>
118
- <li><label><input type="checkbox" value="download_count" <?php checked(isset($package_info['download_count']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[download_count]"> <?php _e( "Download Count" , "download-manager" ); ?></label></li>
119
- <li><label><input type="checkbox" value="view_count" <?php checked(isset($package_info['view_count']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[view_count]"> <?php _e( "View Count" , "download-manager" ); ?></label></li>
120
- <li><label><input type="checkbox" value="create_date" <?php checked(isset($package_info['create_date']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[create_date]"> <?php _e( "Publish Date" , "download-manager" ); ?></label></li>
121
- <li><label><input type="checkbox" value="update_date" <?php checked(isset($package_info['update_date']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[update_date]"> <?php _e( "Update Date" , "download-manager" ); ?></label></li>
122
- <li><label><input type="checkbox" value="version" <?php checked(isset($package_info['version']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[version]"> <?php _e( "Version" , "download-manager" ); ?></label></li>
123
- <li><label><input type="checkbox" value="download_link" <?php checked(isset($package_info['package_size']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[package_size]"> <?php _e( "Package Size" , "download-manager" ); ?></label></li>
124
- <li><label><input type="checkbox" value="download_link" <?php checked(isset($package_info['download_link']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[download_link]"> <?php _e( "Download Link" , "download-manager" ); ?></label></li>
125
- <li><label><input type="checkbox" value="download_link_ext" <?php checked(isset($package_info['download_link_ext']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[download_link_ext]"> <?php _e( "Embed Download Options" , "download-manager" ); ?></label></li>
126
- <li><hr/><?php _e( "Style" , "download-manager" ); ?>:<br/><label style="font-weight: 900"><input type="checkbox" value="1" <?php checked(isset($instance['table']), 1) ?> name="<?php echo $this->get_field_name('table'); ?>"> <?php _e( "Tabular View" , "download-manager" ); ?></label></li>
127
- <li><hr/><label style="font-weight: 900"><input type="checkbox" value="1" <?php checked(isset($package_info['qrcode']), 1) ?> name="<?php echo $this->get_field_name('pinfo'); ?>[qrcode]"> <?php _e( "Show QR Code" , "download-manager" ); ?></label></li>
128
- </ul>
129
 
 
 
 
 
 
 
 
130
 
131
- </p>
 
 
 
 
 
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
- <?php
135
  }
136
-
137
  }
138
-
139
  register_widget('PackageInfo');
1
  <?php
2
+ if (!defined("ABSPATH")) die("Shit happens!");
3
+ if (!class_exists('PackageInfo')) {
4
+ class PackageInfo extends WP_Widget
5
+ {
6
+ /** constructor */
7
+ function __construct()
8
+ {
9
+
10
+ parent::__construct(false, 'WPDM Packages Info');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
 
13
+ /** @see WP_Widget::widget */
14
+ function widget($args, $instance)
15
+ {
16
+
17
+ if (!is_singular('wpdmpro')) return;
18
+
19
+ global $post;
20
+ extract($args);
21
+ $title = apply_filters('widget_title', $instance['title']);
22
+ $package_info = isset($instance['pinfo']) ? $instance['pinfo'] : array();
23
+ $package_info_labels = array(
24
+ 'download_count' => __("Total Downloads", "download-manager"),
25
+ 'view_count' => __("Total Views", "download-manager"),
26
+ 'create_date' => __("Publish Date", "download-manager"),
27
+ 'update_date' => __("Last Updated", "download-manager"),
28
+ 'package_size' => __("Size", "download-manager"),
29
+ 'version' => __("Version", "download-manager"),
30
+ );
31
+
32
+ $package_info_icons = array(
33
+ 'download_count' => 'arrow-alt-circle-down',
34
+ 'view_count' => 'eye',
35
+ 'package_size' => 'hdd',
36
+ 'version' => 'layer-group',
37
+ );
38
+ $download_link = "";
39
+ if (isset($package_info['download_link'])) {
40
+ unset($package_info['download_link']);
41
+ if (isset($package_info['download_link_ext']))
42
+ $download_link = WPDM()->package->downloadLink(get_the_ID(), 1, array('popstyle' => 'popup'));
43
+ else
44
+ $download_link = WPDM()->package->downloadLink(get_the_ID(), 0, array('popstyle' => 'popup'));
45
+ }
46
+
47
 
48
+ ?>
49
+ <?php echo $before_widget; ?>
50
+ <?php if (isset($title) & $title != '')
51
  echo $before_title . $title . $after_title;
52
+ if (isset($instance['table']) && $instance['table'] == 1) {
53
+ echo "<div class='w3eden'><table class='table table-striped table-bordered' style='font-size: 9pt'>";
54
+
55
+ if (is_array($package_info)) {
56
+ foreach ($package_info as $index => $v) {
57
+ if ($index == 'create_date')
58
+ echo "<tr><td>{$package_info_labels[$index]}</td><td>" . get_the_date() . "</td></tr>";
59
+ else if ($index == 'update_date')
60
+ echo "<tr><td>{$package_info_labels[$index]}</td><td>" . get_the_modified_date() . "</td></tr>";
61
+ else if ($index != 'download_link_ext')
62
+ echo "<tr><td>{$package_info_labels[$index]}</td><td>" . get_post_meta(get_the_ID(), '__wpdm_' . $index, true) . "</td></tr>";
63
+ }
64
  }
65
+ if ($download_link != '')
66
+ $download_link = "<tr><td colspan='2' class='text-center'>" . $download_link . "</td>";
67
+ echo "{$download_link}</table></div>";
68
+ } else {
69
+ echo "<div class='w3eden'><div class='list-group package-info-list'>";
70
+
71
+ if (is_array($package_info)) {
72
+ foreach ($package_info as $index => $v) {
73
+ if ($index == 'create_date')
74
+ echo "<div class='list-group-item'><div class='media'><div class='pull-left mr-3'><i class='fa fa-calendar'></i></div><div class='media-body'><strong>{$package_info_labels[$index]}</strong><br/>" . get_the_date() . "</div></div></div>";
75
+ else if ($index == 'update_date')
76
+ echo "<div class='list-group-item'><div class='media'><div class='pull-left mr-3'><i class='fa fa-calendar-check'></i></div><div class='media-body'><strong>{$package_info_labels[$index]}</strong><br/>" . get_the_modified_date() . "</div></div></div>";
77
+ else if ($index != 'download_link_ext' && isset($package_info_labels[$index]))
78
+ echo "<div class='list-group-item'><div class='media'><div class='pull-left mr-3'><i class='fa fa-{$package_info_icons[$index]}'></i></div><div class='media-body'><strong>{$package_info_labels[$index]}</strong><br/>" . get_post_meta(get_the_ID(), '__wpdm_' . $index, true) . "</div></div></div>";
79
+ }
80
  }
 
 
 
 
81
 
82
+ echo "<div class='list-group-item'>{$download_link}</div></div></div>";
83
+ }
84
 
 
85
 
 
 
 
86
  echo $after_widget;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
+ if (is_array($package_info) && isset($package_info['qrcode'])) {
89
+ echo $before_widget;
90
+ echo "<img class='wpdm-qr-code wpdm-qr-code-widget' style='max-width: 100%' src='https://chart.googleapis.com/chart?cht=qr&chs=450x450&choe=UTF-8&chld=H|0&chl=" . get_permalink(get_the_ID()) . "' alt='" . get_the_title() . "' />";
91
+ echo $after_widget;
92
+ }
93
+ wp_reset_query();
94
+ }
95
 
96
+ /** @see WP_Widget::update */
97
+ function update($new_instance, $old_instance)
98
+ {
99
+ $instance = $new_instance;
100
+ return $instance;
101
+ }
102
 
103
+ /** @see WP_Widget::form */
104
+ function form($instance)
105
+ {
106
+ if (isset($instance['title']))
107
+ $title = esc_attr($instance['title']);
108
+ else $title = '';
109
+ if (isset($instance['pinfo']))
110
+ $package_info = $instance['pinfo'];
111
+
112
+
113
+ ?>
114
+ <p>
115
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
116
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
117
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
118
+ </p>
119
+ <p>
120
+ <label for="<?php echo $this->get_field_id('scat'); ?>"><?php _e("Fields to Show:", "download-manager"); ?></label>
121
+
122
+ <ul>
123
+ <li><label><input type="checkbox"
124
+ value="download_count" <?php checked(isset($package_info['download_count']), 1) ?>
125
+ name="<?php echo $this->get_field_name('pinfo'); ?>[download_count]"> <?php _e("Download Count", "download-manager"); ?>
126
+ </label></li>
127
+ <li><label><input type="checkbox"
128
+ value="view_count" <?php checked(isset($package_info['view_count']), 1) ?>
129
+ name="<?php echo $this->get_field_name('pinfo'); ?>[view_count]"> <?php _e("View Count", "download-manager"); ?>
130
+ </label></li>
131
+ <li><label><input type="checkbox"
132
+ value="create_date" <?php checked(isset($package_info['create_date']), 1) ?>
133
+ name="<?php echo $this->get_field_name('pinfo'); ?>[create_date]"> <?php _e("Publish Date", "download-manager"); ?>
134
+ </label></li>
135
+ <li><label><input type="checkbox"
136
+ value="update_date" <?php checked(isset($package_info['update_date']), 1) ?>
137
+ name="<?php echo $this->get_field_name('pinfo'); ?>[update_date]"> <?php _e("Update Date", "download-manager"); ?>
138
+ </label></li>
139
+ <li><label><input type="checkbox" value="version" <?php checked(isset($package_info['version']), 1) ?>
140
+ name="<?php echo $this->get_field_name('pinfo'); ?>[version]"> <?php _e("Version", "download-manager"); ?>
141
+ </label></li>
142
+ <li><label><input type="checkbox"
143
+ value="download_link" <?php checked(isset($package_info['package_size']), 1) ?>
144
+ name="<?php echo $this->get_field_name('pinfo'); ?>[package_size]"> <?php _e("Package Size", "download-manager"); ?>
145
+ </label></li>
146
+ <li><label><input type="checkbox"
147
+ value="download_link" <?php checked(isset($package_info['download_link']), 1) ?>
148
+ name="<?php echo $this->get_field_name('pinfo'); ?>[download_link]"> <?php _e("Download Link", "download-manager"); ?>
149
+ </label></li>
150
+ <li><label><input type="checkbox"
151
+ value="download_link_ext" <?php checked(isset($package_info['download_link_ext']), 1) ?>
152
+ name="<?php echo $this->get_field_name('pinfo'); ?>[download_link_ext]"> <?php _e("Embed Download Options", "download-manager"); ?>
153
+ </label></li>
154
+ <li>
155
+ <hr/><?php _e("Style", "download-manager"); ?>:<br/><label style="font-weight: 900"><input
156
+ type="checkbox" value="1" <?php checked(isset($instance['table']), 1) ?>
157
+ name="<?php echo $this->get_field_name('table'); ?>"> <?php _e("Tabular View", "download-manager"); ?>
158
+ </label></li>
159
+ <li>
160
+ <hr/>
161
+ <label style="font-weight: 900"><input type="checkbox"
162
+ value="1" <?php checked(isset($package_info['qrcode']), 1) ?>
163
+ name="<?php echo $this->get_field_name('pinfo'); ?>[qrcode]"> <?php _e("Show QR Code", "download-manager"); ?>
164
+ </label></li>
165
+ </ul>
166
+
167
+
168
+ </p>
169
+
170
+
171
+ <?php
172
+ }
173
 
 
174
  }
 
175
  }
 
176
  register_widget('PackageInfo');
src/Widgets/Search.php CHANGED
@@ -1,56 +1,63 @@
1
  <?php
2
- use WPDM\__\Messages;
3
 
4
- if(!defined("ABSPATH")) die("Shit happens!");
5
 
6
- class WPDM_Search extends WP_Widget {
 
 
 
7
 
8
- function __construct() {
9
- parent::__construct(false, 'WPDM Search');
10
- }
11
-
12
- function widget($args, $instance) {
13
- extract( $args );
14
- if(wpdm_valueof($instance, 'result_page') > 0) {
15
- $title = apply_filters('widget_title', wpdm_valueof($instance, 'title'));
16
- $url = get_permalink(wpdm_valueof($instance, 'result_page'));
17
- echo isset($before_widget) ? $before_widget : "";
18
- if ($title) echo (isset($before_title) ? $before_title : "") . $title . (isset($after_title) ? $after_title : "");
19
- echo "<div class='w3eden'><form action='" . $url . "' class='wpdm-pro'>";
20
- echo "<div class='input-group input-group-lg'><input placeholder='".__( "Search...", "download-manager" )."' type=text class='form-control' name='search' /><span class='input-group-btn input-group-append'><button class='btn btn-secondary'><i class='fas fa-search'></i></button></span></div><div class='clear'></div>";
21
- echo "</form></div>";
22
- echo isset($after_widget) ? $after_widget : "";
23
- } else {
24
- Messages::warning(__( "Search result page was not configured properly. Please create a page with shortcode [wpdm_search_result] and select thee page from widget settings", "download-manager" ), 0);
25
  }
26
- }
27
 
28
- function update($new_instance, $old_instance) {
29
- $instance = $old_instance;
30
- $instance['title'] = strip_tags($new_instance['title']);
31
- $instance['result_page'] = (int)$new_instance['result_page'];
32
- $instance['cv'] = $new_instance['cv'];
33
- return $instance;
34
- }
 
 
 
 
 
 
 
 
 
35
 
36
- function form($instance) {
37
- $title = isset($instance['title']) ? esc_attr($instance['title']) : "";
38
- $result_page = isset($instance['result_page']) ? esc_attr($instance['result_page']) : "";
39
- ?>
40
- <p>
41
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
42
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
43
- </p>
44
- <p>
45
- <?php echo __("Search Result Page","wpdmap").":<br/>"; ?>
46
- <?php wp_dropdown_pages(['selected'=> $result_page, 'name' => $this->get_field_name('result_page'), 'id' => $this->get_field_id('result_page'), 'class' => 'widefat' ] ) ?>
47
- </p>
48
 
49
- <div style="border:1px solid #ccc;padding:15px;margin-bottom: 15px;font-size:8pt">
50
- <?php _e("Note: Create a page with short-code <code>[wpdm_search_result]</code> and select that page as search redult page", "wpdmap");?>
51
- </div>
52
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
  }
55
-
56
  register_widget('WPDM_Search');
1
  <?php
 
2
 
3
+ use WPDM\__\Messages;
4
 
5
+ if (!defined("ABSPATH")) die("Shit happens!");
6
+ if (!class_exists('WPDM_Search')) {
7
+ class WPDM_Search extends WP_Widget
8
+ {
9
 
10
+ function __construct()
11
+ {
12
+ parent::__construct(false, 'WPDM Search');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
 
14
 
15
+ function widget($args, $instance)
16
+ {
17
+ extract($args);
18
+ if (wpdm_valueof($instance, 'result_page') > 0) {
19
+ $title = apply_filters('widget_title', wpdm_valueof($instance, 'title'));
20
+ $url = get_permalink(wpdm_valueof($instance, 'result_page'));
21
+ echo isset($before_widget) ? $before_widget : "";
22
+ if ($title) echo (isset($before_title) ? $before_title : "") . $title . (isset($after_title) ? $after_title : "");
23
+ echo "<div class='w3eden'><form action='" . $url . "' class='wpdm-pro'>";
24
+ echo "<div class='input-group input-group-lg'><input placeholder='" . __("Search...", "download-manager") . "' type=text class='form-control' name='search' /><span class='input-group-btn input-group-append'><button class='btn btn-secondary'><i class='fas fa-search'></i></button></span></div><div class='clear'></div>";
25
+ echo "</form></div>";
26
+ echo isset($after_widget) ? $after_widget : "";
27
+ } else {
28
+ Messages::warning(__("Search result page was not configured properly. Please create a page with shortcode [wpdm_search_result] and select thee page from widget settings", "download-manager"), 0);
29
+ }
30
+ }
31
 
32
+ function update($new_instance, $old_instance)
33
+ {
34
+ $instance = $old_instance;
35
+ $instance['title'] = strip_tags($new_instance['title']);
36
+ $instance['result_page'] = (int)$new_instance['result_page'];
37
+ $instance['cv'] = $new_instance['cv'];
38
+ return $instance;
39
+ }
 
 
 
 
40
 
41
+ function form($instance)
42
+ {
43
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : "";
44
+ $result_page = isset($instance['result_page']) ? esc_attr($instance['result_page']) : "";
45
+ ?>
46
+ <p>
47
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
48
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
49
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
50
+ </p>
51
+ <p>
52
+ <?php echo __("Search Result Page", "wpdmap") . ":<br/>"; ?>
53
+ <?php wp_dropdown_pages(['selected' => $result_page, 'name' => $this->get_field_name('result_page'), 'id' => $this->get_field_id('result_page'), 'class' => 'widefat']) ?>
54
+ </p>
55
+
56
+ <div style="border:1px solid #ccc;padding:15px;margin-bottom: 15px;font-size:8pt">
57
+ <?php _e("Note: Create a page with short-code <code>[wpdm_search_result]</code> and select that page as search redult page", "wpdmap"); ?>
58
+ </div>
59
+ <?php
60
+ }
61
  }
62
  }
 
63
  register_widget('WPDM_Search');
src/Widgets/Tags.php CHANGED
@@ -1,89 +1,97 @@
1
  <?php
2
- if(!defined("ABSPATH")) die("Shit happens!");
3
-
4
- class WPDM_Tags extends \WP_Widget {
5
- /** constructor */
6
- function __construct() {
7
- parent::__construct(false, 'WPDM Tags');
8
- }
9
-
10
- /** @see WP_Widget::widget */
11
- function widget($args, $instance) {
12
- extract( $args );
13
- $instance['title'] = isset($instance['title'])?$instance['title']:'';
14
- $title = apply_filters('widget_title', $instance['title']);
15
- $subt = isset($instance['subt'])?$instance['subt']:'about '.get_the_title();
16
- if(!is_singular('wpdmpro')) $subt = 'about '.get_the_title();
17
- $parent = isset($instance['parent']) && $instance['parent'] >0 ?intval($instance['parent']):0;
18
- $style = isset($instance['style'])?esc_attr($instance['style']):'flat';
19
- $toplevel = isset($instance['toplevel'])?esc_attr($instance['toplevel']):0;
20
- $category_page = isset($instance['category_page'])?esc_attr($instance['category_page']):'showall';
21
- $notags = isset($instance['notags'])?esc_attr($instance['notags']):-1;
22
-
23
-
24
- $args = array(
25
- 'orderby' => 'name',
26
- 'order' => 'ASC',
27
- 'hide_empty' => true
28
- );
29
-
30
- $object = get_queried_object();
31
- if(is_singular())
32
- $terms = wp_get_post_terms(get_the_ID(), 'wpdmtag');
33
- else
34
- $terms = get_terms("wpdmtag", $args);
35
-
36
-
37
- if(is_array($terms)) {
38
- echo $before_widget;
39
- if ($title)
40
- echo $before_title . $title . $after_title;
41
- if($subt)
42
- echo "<div class='subt'>{$subt}</div>";
43
- echo "<div class='w3eden'><div class='list-group_'>";
44
- $n = 0;
45
 
46
- foreach ($terms as $term) {
47
- $n++;
48
- if ($notags > 0 && $n > $notags) break;
49
- echo "<a href='" . get_term_link($term) . "' class='btn btn-outline-secondary btn-sm _list-group-item'>{$term->name}</a>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
- do_action("wpdm_tag_widget");
53
-
54
- echo "</div></div>\n";
55
-
56
- echo $after_widget;
57
  }
58
 
59
- }
 
 
 
 
60
 
61
- /** @see WP_Widget::update */
62
- function update($new_instance, $old_instance) {
63
- return $new_instance;
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- /** @see WP_Widget::form */
67
- function form($instance) {
68
- $title = isset($instance['title'])?esc_attr($instance['title']):"";
69
- $subt = isset($instance['subt'])?esc_attr($instance['subt']):"";
70
- $notags = isset($instance['notags'])?esc_attr($instance['notags']):-1;
71
- ?>
72
- <p>
73
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
74
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
75
- </p>
76
- <p>
77
- <label for="<?php echo $this->get_field_id('subt'); ?>"><?php _e('Sub Title:'); ?></label>
78
- <input class="widefat" id="<?php echo $this->get_field_id('subt'); ?>" name="<?php echo $this->get_field_name('subt'); ?>" type="text" value="<?php echo $subt; ?>" />
79
- </p>
80
- <p>
81
- <label for="<?php echo $this->get_field_id('notags'); ?>"><?php _e('Number of tags to show:', 'download-manager'); ?></label><br/>
82
- <input type="number" name="<?php echo $this->get_field_name('notags'); ?>" value="<?php echo $notags; ?>">
83
- </p>
84
- <?php
85
  }
86
-
87
  }
88
-
89
  register_widget('WPDM_Tags');
1
  <?php
2
+ if (!defined("ABSPATH")) die("Shit happens!");
3
+ if (!class_exists('WPDM_Tags')) {
4
+ class WPDM_Tags extends \WP_Widget
5
+ {
6
+ /** constructor */
7
+ function __construct()
8
+ {
9
+ parent::__construct(false, 'WPDM Tags');
10
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ /** @see WP_Widget::widget */
13
+ function widget($args, $instance)
14
+ {
15
+ extract($args);
16
+ $instance['title'] = isset($instance['title']) ? $instance['title'] : '';
17
+ $title = apply_filters('widget_title', $instance['title']);
18
+ $subt = isset($instance['subt']) ? $instance['subt'] : 'about ' . get_the_title();
19
+ if (!is_singular('wpdmpro')) $subt = 'about ' . get_the_title();
20
+ $parent = isset($instance['parent']) && $instance['parent'] > 0 ? intval($instance['parent']) : 0;
21
+ $style = isset($instance['style']) ? esc_attr($instance['style']) : 'flat';
22
+ $toplevel = isset($instance['toplevel']) ? esc_attr($instance['toplevel']) : 0;
23
+ $category_page = isset($instance['category_page']) ? esc_attr($instance['category_page']) : 'showall';
24
+ $notags = isset($instance['notags']) ? esc_attr($instance['notags']) : -1;
25
+
26
+
27
+ $args = array(
28
+ 'orderby' => 'name',
29
+ 'order' => 'ASC',
30
+ 'hide_empty' => true
31
+ );
32
+
33
+ $object = get_queried_object();
34
+ if (is_singular())
35
+ $terms = wp_get_post_terms(get_the_ID(), 'wpdmtag');
36
+ else
37
+ $terms = get_terms("wpdmtag", $args);
38
+
39
+
40
+ if (is_array($terms)) {
41
+ echo $before_widget;
42
+ if ($title)
43
+ echo $before_title . $title . $after_title;
44
+ if ($subt)
45
+ echo "<div class='subt'>{$subt}</div>";
46
+ echo "<div class='w3eden'><div class='list-group_'>";
47
+ $n = 0;
48
+
49
+ foreach ($terms as $term) {
50
+ $n++;
51
+ if ($notags > 0 && $n > $notags) break;
52
+ echo "<a href='" . get_term_link($term) . "' class='btn btn-outline-secondary btn-sm _list-group-item'>{$term->name}</a>\n";
53
+ }
54
+
55
+ do_action("wpdm_tag_widget");
56
+
57
+ echo "</div></div>\n";
58
+
59
+ echo $after_widget;
60
  }
61
 
 
 
 
 
 
62
  }
63
 
64
+ /** @see WP_Widget::update */
65
+ function update($new_instance, $old_instance)
66
+ {
67
+ return $new_instance;
68
+ }
69
 
70
+ /** @see WP_Widget::form */
71
+ function form($instance)
72
+ {
73
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : "";
74
+ $subt = isset($instance['subt']) ? esc_attr($instance['subt']) : "";
75
+ $notags = isset($instance['notags']) ? esc_attr($instance['notags']) : -1;
76
+ ?>
77
+ <p>
78
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
79
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
80
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
81
+ </p>
82
+ <p>
83
+ <label for="<?php echo $this->get_field_id('subt'); ?>"><?php _e('Sub Title:'); ?></label>
84
+ <input class="widefat" id="<?php echo $this->get_field_id('subt'); ?>"
85
+ name="<?php echo $this->get_field_name('subt'); ?>" type="text" value="<?php echo $subt; ?>"/>
86
+ </p>
87
+ <p>
88
+ <label for="<?php echo $this->get_field_id('notags'); ?>"><?php _e('Number of tags to show:', 'download-manager'); ?></label><br/>
89
+ <input type="number" name="<?php echo $this->get_field_name('notags'); ?>"
90
+ value="<?php echo $notags; ?>">
91
+ </p>
92
+ <?php
93
+ }
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
 
96
  }
 
97
  register_widget('WPDM_Tags');
src/Widgets/TopDownloads.php CHANGED
@@ -1,70 +1,77 @@
1
  <?php
2
- if(!defined("ABSPATH")) die("Shit happens!");
3
-
4
- class WPDM_TopDownloads extends WP_Widget {
5
- /** constructor */
6
- function __construct() {
7
- parent::__construct(false, 'WPDM Top Downloads');
8
- }
 
 
9
 
10
- /** @see WP_Widget::widget */
11
- function widget($args, $instance) {
12
- global $post;
13
- extract( $args );
14
- $title = apply_filters('widget_title', $instance['title']);
15
- $sdc = $instance['sdc'];
16
- $nop = $instance['nop'];
 
17
 
18
- $newp = new \WP_Query(array('post_type'=>'wpdmpro','posts_per_page'=>$nop, 'order_by'=>'publish_date', 'orderby' => 'meta_value_num','meta_key'=>'__wpdm_download_count','order'=>'desc'));
19
 
20
- ?>
21
- <?php echo $before_widget; ?>
22
- <?php if ( $title )
23
  echo $before_title . $title . $after_title;
24
- echo "<div class='w3eden'>";
25
- while($newp->have_posts()){
26
- $newp->the_post();
27
 
28
- $pack = (array)$post;
29
- echo wpdm_fetch_template($sdc, $pack);
 
 
 
 
30
  }
31
- echo "</div>";
32
- echo $after_widget;
33
- wp_reset_query();
34
- }
35
 
36
- /** @see WP_Widget::update */
37
- function update($new_instance, $old_instance) {
38
- $instance = $old_instance;
39
- $instance['title'] = strip_tags($new_instance['title']);
40
- $instance['sdc'] = strip_tags($new_instance['sdc']);
41
- $instance['nop'] = strip_tags($new_instance['nop']);
42
- return $instance;
43
- }
 
44
 
45
- /** @see WP_Widget::form */
46
- function form($instance) {
47
- $title = isset($instance['title'])?esc_attr($instance['title']):"";
48
- $sdc = isset($instance['sdc'])?esc_attr($instance['sdc']):"link-template-default.php";
49
- $nop = isset($instance['nop'])?esc_attr($instance['nop']):5;
50
- ?>
51
- <p>
52
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
53
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
54
- </p>
55
- <p>
56
- <label for="<?php echo $this->get_field_id('nop'); ?>"><?php _e('Number of packages to show:'); ?></label>
57
- <input class="widefat" id="<?php echo $this->get_field_id('nop'); ?>" name="<?php echo $this->get_field_name('nop'); ?>" type="text" value="<?php echo $nop; ?>" />
58
- </p>
59
- <p>
60
- <label for="<?php echo $this->get_field_id('sdc'); ?>"><?php _e('Link Template:'); ?></label>
 
 
 
61
 
62
- <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc'), 'id' => $this->get_field_id('sdc'), 'selected' => $sdc], true); ?>
63
 
64
- </p>
65
- <?php
66
- }
67
 
 
68
  }
69
-
70
  register_widget('WPDM_TopDownloads');
1
  <?php
2
+ if (!defined("ABSPATH")) die("Shit happens!");
3
+ if (!class_exists('WPDM_TopDownloads')) {
4
+ class WPDM_TopDownloads extends WP_Widget
5
+ {
6
+ /** constructor */
7
+ function __construct()
8
+ {
9
+ parent::__construct(false, 'WPDM Top Downloads');
10
+ }
11
 
12
+ /** @see WP_Widget::widget */
13
+ function widget($args, $instance)
14
+ {
15
+ global $post;
16
+ extract($args);
17
+ $title = apply_filters('widget_title', $instance['title']);
18
+ $sdc = $instance['sdc'];
19
+ $nop = $instance['nop'];
20
 
21
+ $newp = new \WP_Query(array('post_type' => 'wpdmpro', 'posts_per_page' => $nop, 'order_by' => 'publish_date', 'orderby' => 'meta_value_num', 'meta_key' => '__wpdm_download_count', 'order' => 'desc'));
22
 
23
+ ?>
24
+ <?php echo $before_widget; ?>
25
+ <?php if ($title)
26
  echo $before_title . $title . $after_title;
27
+ echo "<div class='w3eden'>";
28
+ while ($newp->have_posts()) {
29
+ $newp->the_post();
30
 
31
+ $pack = (array)$post;
32
+ echo wpdm_fetch_template($sdc, $pack);
33
+ }
34
+ echo "</div>";
35
+ echo $after_widget;
36
+ wp_reset_query();
37
  }
 
 
 
 
38
 
39
+ /** @see WP_Widget::update */
40
+ function update($new_instance, $old_instance)
41
+ {
42
+ $instance = $old_instance;
43
+ $instance['title'] = strip_tags($new_instance['title']);
44
+ $instance['sdc'] = strip_tags($new_instance['sdc']);
45
+ $instance['nop'] = strip_tags($new_instance['nop']);
46
+ return $instance;
47
+ }
48
 
49
+ /** @see WP_Widget::form */
50
+ function form($instance)
51
+ {
52
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : "";
53
+ $sdc = isset($instance['sdc']) ? esc_attr($instance['sdc']) : "link-template-default.php";
54
+ $nop = isset($instance['nop']) ? esc_attr($instance['nop']) : 5;
55
+ ?>
56
+ <p>
57
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
58
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
59
+ name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>"/>
60
+ </p>
61
+ <p>
62
+ <label for="<?php echo $this->get_field_id('nop'); ?>"><?php _e('Number of packages to show:'); ?></label>
63
+ <input class="widefat" id="<?php echo $this->get_field_id('nop'); ?>"
64
+ name="<?php echo $this->get_field_name('nop'); ?>" type="text" value="<?php echo $nop; ?>"/>
65
+ </p>
66
+ <p>
67
+ <label for="<?php echo $this->get_field_id('sdc'); ?>"><?php _e('Link Template:'); ?></label>
68
 
69
+ <?php echo WPDM()->packageTemplate->dropdown(['name' => $this->get_field_name('sdc'), 'id' => $this->get_field_id('sdc'), 'selected' => $sdc], true); ?>
70
 
71
+ </p>
72
+ <?php
73
+ }
74
 
75
+ }
76
  }
 
77
  register_widget('WPDM_TopDownloads');
src/Widgets/WidgetController.php CHANGED
@@ -18,15 +18,15 @@ class WidgetController
18
  private function __construct()
19
  {
20
  add_action('widgets_init', function(){
21
- include __DIR__.'/Affiliate.php';
22
- include __DIR__.'/Categories.php';
23
- include __DIR__.'/CatPackages.php';
24
- include __DIR__.'/ListPackages.php';
25
- include __DIR__.'/NewDownloads.php';
26
- include __DIR__.'/PackageInfo.php';
27
- include __DIR__.'/Tags.php';
28
- include __DIR__.'/Search.php';
29
- include __DIR__.'/TopDownloads.php';
30
  });
31
 
32
  }
18
  private function __construct()
19
  {
20
  add_action('widgets_init', function(){
21
+ include_once __DIR__.'/Affiliate.php';
22
+ include_once __DIR__.'/Categories.php';
23
+ include_once __DIR__.'/CatPackages.php';
24
+ include_once __DIR__.'/ListPackages.php';
25
+ include_once __DIR__.'/NewDownloads.php';
26
+ include_once __DIR__.'/PackageInfo.php';
27
+ include_once __DIR__.'/Tags.php';
28
+ include_once __DIR__.'/Search.php';
29
+ include_once __DIR__.'/TopDownloads.php';
30
  });
31
 
32
  }
src/__/Query.php CHANGED
@@ -368,7 +368,7 @@ class Query
368
  global $wpdb;
369
 
370
  if($this->tax_relation && isset($this->params['tax_query']) && is_array($this->params['tax_query']))
371
- array_unshift($this->params['tax_query'], ['relation' => $this->tax_relation]);
372
 
373
  $this->params = apply_filters('wpdm_packages_query_params', $this->params);
374
  $this->params['post_type'] = $this->post_type;
368
  global $wpdb;
369
 
370
  if($this->tax_relation && isset($this->params['tax_query']) && is_array($this->params['tax_query']))
371
+ $this->params['tax_query'] = ['relation' => $this->tax_relation] + $this->params['tax_query'];
372
 
373
  $this->params = apply_filters('wpdm_packages_query_params', $this->params);
374
  $this->params['post_type'] = $this->post_type;
src/__/Session.php CHANGED
@@ -24,13 +24,8 @@ class Session
24
  $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
25
  $deviceID = md5(__::get_client_ip() . $agent);
26
  if(!defined('WPDM_ACCEPT_COOKIE') || WPDM_ACCEPT_COOKIE !== false) {
27
- if(!headers_sent($filename, $linenumber)) {
28
- setcookie('__wpdm_client', $deviceID, 0, "", COOKIE_DOMAIN, is_ssl(), true);
29
- $_COOKIE['__wpdm_client'] = $deviceID;
30
- }
31
- else {
32
- error_log("WPDM Session may not work properly! Cannot modify header information – headers already sent in {$filename}, line number {$linenumber}");
33
- }
34
  }
35
  }
36
  self::$deviceID = $deviceID;
@@ -52,16 +47,21 @@ class Session
52
  }
53
  }
54
 
55
- static function deviceID($deviceID)
56
  {
 
 
 
 
57
  self::$deviceID = $deviceID;
 
58
  }
59
 
60
  static function set($name, $value, $expire = 1800)
61
  {
62
  global $wpdb;
63
  if(!$name) return;
64
- if(!self::$deviceID) new Session();
65
  if (self::$store === 'file') self::$data[$name] = array('value' => $value, 'expire' => time() + $expire);
66
  else {
67
  self::clear($name);
24
  $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
25
  $deviceID = md5(__::get_client_ip() . $agent);
26
  if(!defined('WPDM_ACCEPT_COOKIE') || WPDM_ACCEPT_COOKIE !== false) {
27
+ @setcookie('__wpdm_client', $deviceID, 0, "", COOKIE_DOMAIN, is_ssl(), true);
28
+ $_COOKIE['__wpdm_client'] = $deviceID;
 
 
 
 
 
29
  }
30
  }
31
  self::$deviceID = $deviceID;
47
  }
48
  }
49
 
50
+ static function deviceID($deviceID = null)
51
  {
52
+ if(!$deviceID) {
53
+ $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
54
+ $deviceID = md5(__::get_client_ip() . $agent);
55
+ }
56
  self::$deviceID = $deviceID;
57
+ return self::$deviceID;
58
  }
59
 
60
  static function set($name, $value, $expire = 1800)
61
  {
62
  global $wpdb;
63
  if(!$name) return;
64
+ if(!self::$deviceID) Session::deviceID();
65
  if (self::$store === 'file') self::$data[$name] = array('value' => $value, 'expire' => time() + $expire);
66
  else {
67
  self::clear($name);
src/__/UI.php CHANGED
@@ -23,6 +23,25 @@ class UI
23
  return "<div{$class} $_attrs>{$content}</div>";
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  static function button($label, $attrs = []){
27
  $button = "<button";
28
  foreach ($attrs as $name => $val){
23
  return "<div{$class} $_attrs>{$content}</div>";
24
  }
25
 
26
+ static function html($tag, $attrs = [], $content = '')
27
+ {
28
+ $_attrs = "";
29
+ foreach ($attrs as $name => $val){
30
+ $_attrs .= " {$name}='$val'";
31
+ }
32
+ return "<$tag $_attrs>{$content}</$tag>";
33
+ }
34
+
35
+ static function a($link, $label = '', $attrs = [])
36
+ {
37
+ $label = $label ? $label : $link;
38
+ $_attrs = "";
39
+ foreach ($attrs as $name => $val){
40
+ $_attrs .= " {$name}='$val'";
41
+ }
42
+ return "<a href='{$link}' $_attrs>{$label}</a>";
43
+ }
44
+
45
  static function button($label, $attrs = []){
46
  $button = "<button";
47
  foreach ($attrs as $name => $val){
src/wpdm-functions.php CHANGED
@@ -1279,9 +1279,9 @@ function wpdm_sanitize_var($value, $sanitize = 'kses')
1279
  */
1280
  function wpdm_paginate_links($total, $items_per_page, $current_page = 1, $var = 'cp', $params = array())
1281
  {
1282
-
1283
  $items_per_page = $items_per_page > 0 ? $items_per_page : 10;
1284
  $pages = ceil($total / $items_per_page);
 
1285
  $format = isset($params['format']) ? $params['format'] : "?{$var}=%#%";
1286
  $args = array(
1287
  //'base' => '%_%',
@@ -1289,9 +1289,9 @@ function wpdm_paginate_links($total, $items_per_page, $current_page = 1, $var =
1289
  'total' => $pages,
1290
  'current' => $current_page,
1291
  //'show_all' => false,
1292
- //'end_size' => 2,
1293
  //'mid_size' => 1,
1294
- //'prev_next' => true,
1295
  'prev_text' => isset($params['prev_text']) ? $params['prev_text'] : __('Previous'),
1296
  'next_text' => isset($params['prev_text']) ? $params['next_text'] : __('Next'),
1297
  'type' => 'array',
@@ -1300,7 +1300,7 @@ function wpdm_paginate_links($total, $items_per_page, $current_page = 1, $var =
1300
  //'before_page_number' => '',
1301
  //'after_page_number' => ''
1302
  );
1303
- if(isset($params['base'])) {
1304
  $args['base'] = $params['base'];
1305
  }
1306
  //wpdmprecho($args);
1279
  */
1280
  function wpdm_paginate_links($total, $items_per_page, $current_page = 1, $var = 'cp', $params = array())
1281
  {
 
1282
  $items_per_page = $items_per_page > 0 ? $items_per_page : 10;
1283
  $pages = ceil($total / $items_per_page);
1284
+ if($current_page < 1) $current_page = 1;
1285
  $format = isset($params['format']) ? $params['format'] : "?{$var}=%#%";
1286
  $args = array(
1287
  //'base' => '%_%',
1289
  'total' => $pages,
1290
  'current' => $current_page,
1291
  //'show_all' => false,
1292
+ 'end_size' => 2,
1293
  //'mid_size' => 1,
1294
+ 'prev_next' => true,
1295
  'prev_text' => isset($params['prev_text']) ? $params['prev_text'] : __('Previous'),
1296
  'next_text' => isset($params['prev_text']) ? $params['next_text'] : __('Next'),
1297
  'type' => 'array',
1300
  //'before_page_number' => '',
1301
  //'after_page_number' => ''
1302
  );
1303
+ if (isset($params['base'])) {
1304
  $args['base'] = $params['base'];
1305
  }
1306
  //wpdmprecho($args);
src/wpdm-start-download.php CHANGED
@@ -46,8 +46,8 @@ $limit_msg = Messages::download_limit_exceeded($package['ID']);
46
  if (wpdm_is_download_limit_exceed($package['ID'])) Messages::fullPage("Error!", $limit_msg, 'error');
47
  //$files = WPDM()->package->getFiles($package['ID']);
48
  $files = $package['files'];
49
-
50
- $fileCount = count($files) + (isset($package['package_dir']) && $package['package_dir'] !== '' ? 1 : 0);
51
 
52
  if($fileCount === 0){
53
  Messages::fullPage(__( "No Files", "download-manager" ), __( "No file is attached with this package!", "download-manager" ));
46
  if (wpdm_is_download_limit_exceed($package['ID'])) Messages::fullPage("Error!", $limit_msg, 'error');
47
  //$files = WPDM()->package->getFiles($package['ID']);
48
  $files = $package['files'];
49
+ $files = array_values($files);
50
+ $fileCount = count($files) && $files[0] !== '' ? 1 : 0;
51
 
52
  if($fileCount === 0){
53
  Messages::fullPage(__( "No Files", "download-manager" ), __( "No file is attached with this package!", "download-manager" ));