Simple Download Monitor - Version 3.2.5

Version Description

  • Modified the 'sdm_download_shortcode_output' filter to pass the arguments array also (allows greater customization option via this filter).
  • Added a new option to show X number of latest downloads from a specified category.
Download this release

Release Info

Developer mra13
Plugin Icon 128x128 Simple Download Monitor
Version 3.2.5
Comparing to
See all releases

Code changes from version 3.2.3 to 3.2.5

Files changed (4) hide show
  1. includes/sdm-latest-downloads.php +21 -4
  2. main.php +11 -2
  3. readme.txt +10 -2
  4. sdm-shortcodes.php +36 -2
includes/sdm-latest-downloads.php CHANGED
@@ -9,17 +9,34 @@ function sdm_show_latest_downloads($args){
9
  'new_window' => '',
10
  'orderby' => 'post_date',
11
  'order' => 'DESC',
 
12
  ), $args));
13
 
14
-
15
- // Query cpt's based on arguments above
16
- $get_posts = get_posts(array(
17
  'post_type' => 'sdm_downloads',
18
  'show_posts' => -1,
19
  'posts_per_page' => $number,
20
  'orderby' => $orderby,
21
  'order' => $order,
22
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  // If no cpt's are found
25
  if (!$get_posts) {
9
  'new_window' => '',
10
  'orderby' => 'post_date',
11
  'order' => 'DESC',
12
+ 'category_slug' => '',
13
  ), $args));
14
 
15
+ $query_args = array(
 
 
16
  'post_type' => 'sdm_downloads',
17
  'show_posts' => -1,
18
  'posts_per_page' => $number,
19
  'orderby' => $orderby,
20
  'order' => $order,
21
+ );
22
+
23
+ //Check if the query needs to be for a category
24
+ if (!empty($category_slug)) {
25
+ $field = 'slug';
26
+ $terms = $category_slug;
27
+
28
+ //Add the category slug parameters for the query args
29
+ $query_args['tax_query'] = array(
30
+ array(
31
+ 'taxonomy' => 'sdm_categories',
32
+ 'field' => $field,
33
+ 'terms' => $terms
34
+ )
35
+ );
36
+ }
37
+
38
+ // Query cpt's based on arguments above
39
+ $get_posts = get_posts($query_args);
40
 
41
  // If no cpt's are found
42
  if (!$get_posts) {
main.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
- * Version: 3.2.3
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
@@ -13,7 +13,7 @@ if (!defined('ABSPATH')) {
13
  exit;
14
  }
15
 
16
- define('WP_SIMPLE_DL_MONITOR_VERSION', '3.2.3');
17
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
18
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
19
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
@@ -450,6 +450,15 @@ function handle_sdm_download_via_direct_post() {
450
  $download_id = strip_tags($_REQUEST['download_id']);
451
  $download_title = get_the_title($download_id);
452
  $download_link = get_post_meta($download_id, 'sdm_upload', true);
 
 
 
 
 
 
 
 
 
453
  $ipaddress = $_SERVER["REMOTE_ADDR"];
454
  $date_time = current_time('mysql');
455
  $visitor_country = sdm_ip_info('Visitor', 'Country');
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
+ * Version: 3.2.5
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
13
  exit;
14
  }
15
 
16
+ define('WP_SIMPLE_DL_MONITOR_VERSION', '3.2.5');
17
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
18
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
19
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
450
  $download_id = strip_tags($_REQUEST['download_id']);
451
  $download_title = get_the_title($download_id);
452
  $download_link = get_post_meta($download_id, 'sdm_upload', true);
453
+
454
+ //Do some validation checks
455
+ if(empty($download_id)){
456
+ wp_die(__('Error! Incorrect download item id.', 'sdm_lang'));
457
+ }
458
+ if(empty($download_link)){
459
+ wp_die(__('Error! This download item ('.$download_id.') does not have any download link. Edit this item and specify a downloadable file URL for it.', 'sdm_lang'));
460
+ }
461
+
462
  $ipaddress = $_SERVER["REMOTE_ADDR"];
463
  $date_time = current_time('mysql');
464
  $visitor_country = sdm_ip_info('Visitor', 'Country');
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Tips and Tricks HQ, Ruhul Amin, josh401
3
  Donate link: https://www.tipsandtricks-hq.com
4
  Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
5
  Requires at least: 3.0
6
- Tested up to: 4.2
7
- Stable tag: 3.2.3
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -156,6 +156,14 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
156
 
157
  == Changelog ==
158
 
 
 
 
 
 
 
 
 
159
  = 3.2.3 =
160
  - Addressed some warning/notice messages that shows when debug is enabled.
161
 
3
  Donate link: https://www.tipsandtricks-hq.com
4
  Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
5
  Requires at least: 3.0
6
+ Tested up to: 4.3
7
+ Stable tag: 3.2.5
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
156
 
157
  == Changelog ==
158
 
159
+ = 3.2.5 =
160
+ - Modified the 'sdm_download_shortcode_output' filter to pass the arguments array also (allows greater customization option via this filter).
161
+ - Added a new option to show X number of latest downloads from a specified category.
162
+
163
+ = 3.2.4 =
164
+ - Added a new feature to show pagination in the display all downloads from a category shortcode.
165
+ - Added validation checks while processing a download request to make sure the download item ID is valid and the item has a download link.
166
+
167
  = 3.2.3 =
168
  - Addressed some warning/notice messages that shows when debug is enabled.
169
 
sdm-shortcodes.php CHANGED
@@ -82,7 +82,7 @@ function sdm_create_download_shortcode($atts) {
82
  $output = '<div class="sdm_download_link">' . $download_button_code . '</div>';
83
  }
84
 
85
- return apply_filters('sdm_download_shortcode_output', $output);
86
  }
87
 
88
  function sdm_create_simple_download_link($atts){
@@ -130,6 +130,7 @@ function sdm_handle_category_shortcode($args) {
130
  'new_window' => '',
131
  'orderby' => 'post_date',
132
  'order' => 'DESC',
 
133
  ), $args));
134
 
135
  // Define vars
@@ -157,11 +158,23 @@ function sdm_handle_category_shortcode($args) {
157
  $terms = $category_id;
158
  }
159
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  // Query cpt's based on arguments above
161
  $get_posts = get_posts(array(
162
  'post_type' => 'sdm_downloads',
163
  'show_posts' => -1,
164
- 'posts_per_page' => 9999,
165
  'tax_query' => array(
166
  array(
167
  'taxonomy' => 'sdm_categories',
@@ -171,6 +184,7 @@ function sdm_handle_category_shortcode($args) {
171
  ),
172
  'orderby' => $orderby,
173
  'order' => $order,
 
174
  ));
175
 
176
  // If no cpt's are found
@@ -236,6 +250,26 @@ function sdm_handle_category_shortcode($args) {
236
  $output .= sdm_generate_fancy2_category_display_output($get_posts, $args);
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  // Return results
240
  return apply_filters('sdm_category_download_items_shortcode_output', $output, $args, $get_posts);
241
  } // End else iterate cpt's
82
  $output = '<div class="sdm_download_link">' . $download_button_code . '</div>';
83
  }
84
 
85
+ return apply_filters('sdm_download_shortcode_output', $output, $atts);
86
  }
87
 
88
  function sdm_create_simple_download_link($atts){
130
  'new_window' => '',
131
  'orderby' => 'post_date',
132
  'order' => 'DESC',
133
+ 'pagination' => '',
134
  ), $args));
135
 
136
  // Define vars
158
  $terms = $category_id;
159
  }
160
 
161
+ // For pagination
162
+ $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
163
+ if(isset($args['pagination'])){
164
+ if(!is_numeric($args['pagination'])){
165
+ return '<p style="color: red;">' . __('Error! You must enter a numeric number for the "pagination" parameter of the shortcode. Refer to the usage documentation.', 'sdm_lang') . '</p>';
166
+ }
167
+ $posts_per_page = $args['pagination'];
168
+ } else {
169
+ $posts_per_page = 9999;
170
+ }
171
+
172
+
173
  // Query cpt's based on arguments above
174
  $get_posts = get_posts(array(
175
  'post_type' => 'sdm_downloads',
176
  'show_posts' => -1,
177
+ 'posts_per_page' => $posts_per_page,
178
  'tax_query' => array(
179
  array(
180
  'taxonomy' => 'sdm_categories',
184
  ),
185
  'orderby' => $orderby,
186
  'order' => $order,
187
+ 'paged' => $paged,
188
  ));
189
 
190
  // If no cpt's are found
250
  $output .= sdm_generate_fancy2_category_display_output($get_posts, $args);
251
  }
252
 
253
+ // Pagination related
254
+ if(isset($args['pagination'])){
255
+ $posts_per_page = $args['pagination'];
256
+ $count_sdm_posts = wp_count_posts('sdm_downloads');
257
+ $published_sdm_posts = $count_sdm_posts->publish;
258
+ $total_pages = ceil($published_sdm_posts / $posts_per_page);
259
+
260
+ $big = 999999999; // Need an unlikely integer
261
+ $pagination = paginate_links( array(
262
+ 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
263
+ 'format' => '',
264
+ 'add_args' => '',
265
+ 'current' => max( 1, get_query_var( 'paged' ) ),
266
+ 'total' => $total_pages,
267
+ 'prev_text' => '&larr;',
268
+ 'next_text' => '&rarr;',
269
+ ) );
270
+ $output .= '<div class="sdm_pagination">'.$pagination.'</div>';
271
+ }
272
+
273
  // Return results
274
  return apply_filters('sdm_category_download_items_shortcode_output', $output, $args, $get_posts);
275
  } // End else iterate cpt's