Download Monitor - Version 4.0.7

Version Description

Download this release

Release Info

Developer barrykooij
Plugin Icon 128x128 Download Monitor
Version 4.0.7
Comparing to
See all releases

Code changes from version 4.0.6 to 4.0.7

assets/js/reports/charts-date-range-selector.js CHANGED
@@ -74,8 +74,8 @@ DLM_Reports_Date_Range_Selector.prototype.createElement = function () {
74
  } );
75
  actions.append( applyButton );
76
  el.append( startDate ).append( endDate ).append( actions ).append( this.startDateInput ).append( this.endDateInput );
77
- startDate.datepicker( {inline: true, altField: this.startDateInput, dateFormat: "dd M yy", defaultDate: this.startDate } );
78
- endDate.datepicker( {inline: true, altField: this.endDateInput, dateFormat: "dd M yy", defaultDate: this.endDate } );
79
  el.click( function () {
80
  return false
81
  } );
74
  } );
75
  actions.append( applyButton );
76
  el.append( startDate ).append( endDate ).append( actions ).append( this.startDateInput ).append( this.endDateInput );
77
+ startDate.datepicker( {inline: true, altField: this.startDateInput, dateFormat: "yy-m-dd", defaultDate: this.startDate } );
78
+ endDate.datepicker( {inline: true, altField: this.endDateInput, dateFormat: "yy-m-dd", defaultDate: this.endDate } );
79
  el.click( function () {
80
  return false
81
  } );
assets/js/reports/charts-date-range-selector.min.js CHANGED
@@ -1 +1 @@
1
- jQuery.fn.extend({dlm_reports_date_range:function(a,b,c){return new DLM_Reports_Date_Range_Selector(this,a,b,c),this}});var DLM_Reports_Date_Range_Selector=function(a,b,c,d){this.container=a,this.startDate=new Date(b),this.endDate=new Date(c),this.url=d,this.el=null,this.opened=!1,this.startDateInput=null,this.endDateInput=null,this.setup=function(){var a=this;this.container.click(function(){return a.toggleDisplay(),!1})},this.setup()};DLM_Reports_Date_Range_Selector.prototype.toggleDisplay=function(){this.opened?this.hide():this.display()},DLM_Reports_Date_Range_Selector.prototype.display=function(){this.opened||(this.opened=!0,this.el=this.createElement(),this.container.append(this.el))},DLM_Reports_Date_Range_Selector.prototype.hide=function(){this.opened=!1,this.el.remove()},DLM_Reports_Date_Range_Selector.prototype.apply=function(){var a=new Date(this.startDateInput.val()),b=new Date(this.endDateInput.val()),c=a.getFullYear()+"-"+(a.getMonth()+1)+"-"+a.getDate(),d=b.getFullYear()+"-"+(b.getMonth()+1)+"-"+b.getDate();this.hide(),window.location.replace(this.url+"&date_from="+c+"&date_to="+d)},DLM_Reports_Date_Range_Selector.prototype.createElement=function(){var a=this,b=jQuery("<div>").addClass("dlm_rdrs_overlay"),c=jQuery("<div>").addClass("dlm_rdrs_date").attr("id","dlm_rdrs_date_start"),d=jQuery("<div>").addClass("dlm_rdrs_date").attr("id","dlm_rdrs_date_end");this.startDateInput=jQuery("<input>").attr("type","hidden"),this.endDateInput=jQuery("<input>").attr("type","hidden");var e=jQuery("<div>").addClass("dlm_rdrs_actions"),f=jQuery("<a>").addClass("button").html("Apply").click(function(){return a.apply(),!1});return e.append(f),b.append(c).append(d).append(e).append(this.startDateInput).append(this.endDateInput),c.datepicker({inline:!0,altField:this.startDateInput,dateFormat:"dd M yy",defaultDate:this.startDate}),d.datepicker({inline:!0,altField:this.endDateInput,dateFormat:"dd M yy",defaultDate:this.endDate}),b.click(function(){return!1}),b};
1
+ jQuery.fn.extend({dlm_reports_date_range:function(a,b,c){return new DLM_Reports_Date_Range_Selector(this,a,b,c),this}});var DLM_Reports_Date_Range_Selector=function(a,b,c,d){this.container=a,this.startDate=new Date(b),this.endDate=new Date(c),this.url=d,this.el=null,this.opened=!1,this.startDateInput=null,this.endDateInput=null,this.setup=function(){var a=this;this.container.click(function(){return a.toggleDisplay(),!1})},this.setup()};DLM_Reports_Date_Range_Selector.prototype.toggleDisplay=function(){this.opened?this.hide():this.display()},DLM_Reports_Date_Range_Selector.prototype.display=function(){this.opened||(this.opened=!0,this.el=this.createElement(),this.container.append(this.el))},DLM_Reports_Date_Range_Selector.prototype.hide=function(){this.opened=!1,this.el.remove()},DLM_Reports_Date_Range_Selector.prototype.apply=function(){var a=new Date(this.startDateInput.val()),b=new Date(this.endDateInput.val()),c=a.getFullYear()+"-"+(a.getMonth()+1)+"-"+a.getDate(),d=b.getFullYear()+"-"+(b.getMonth()+1)+"-"+b.getDate();this.hide(),window.location.replace(this.url+"&date_from="+c+"&date_to="+d)},DLM_Reports_Date_Range_Selector.prototype.createElement=function(){var a=this,b=jQuery("<div>").addClass("dlm_rdrs_overlay"),c=jQuery("<div>").addClass("dlm_rdrs_date").attr("id","dlm_rdrs_date_start"),d=jQuery("<div>").addClass("dlm_rdrs_date").attr("id","dlm_rdrs_date_end");this.startDateInput=jQuery("<input>").attr("type","hidden"),this.endDateInput=jQuery("<input>").attr("type","hidden");var e=jQuery("<div>").addClass("dlm_rdrs_actions"),f=jQuery("<a>").addClass("button").html("Apply").click(function(){return a.apply(),!1});return e.append(f),b.append(c).append(d).append(e).append(this.startDateInput).append(this.endDateInput),c.datepicker({inline:!0,altField:this.startDateInput,dateFormat:"yy-m-dd",defaultDate:this.startDate}),d.datepicker({inline:!0,altField:this.endDateInput,dateFormat:"yy-m-dd",defaultDate:this.endDate}),b.click(function(){return!1}),b};
download-monitor.php CHANGED
@@ -3,11 +3,11 @@
3
  Plugin Name: Download Monitor
4
  Plugin URI: https://www.download-monitor.com
5
  Description: A full solution for managing downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
- Version: 4.0.6
7
  Author: Never5
8
  Author URI: https://www.never5.com
9
  Requires at least: 3.8
10
- Tested up to: 4.9.4
11
  Text Domain: download-monitor
12
 
13
  License: GPL v3
@@ -33,7 +33,7 @@ if ( ! defined( 'ABSPATH' ) ) {
33
  } // Exit if accessed directly
34
 
35
  // Define DLM Version
36
- define( 'DLM_VERSION', '4.0.6' );
37
 
38
  // Define DLM FILE
39
  define( 'DLM_PLUGIN_FILE', __FILE__ );
3
  Plugin Name: Download Monitor
4
  Plugin URI: https://www.download-monitor.com
5
  Description: A full solution for managing downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
+ Version: 4.0.7
7
  Author: Never5
8
  Author URI: https://www.never5.com
9
  Requires at least: 3.8
10
+ Tested up to: 4.9.5
11
  Text Domain: download-monitor
12
 
13
  License: GPL v3
33
  } // Exit if accessed directly
34
 
35
  // Define DLM Version
36
+ define( 'DLM_VERSION', '4.0.7' );
37
 
38
  // Define DLM FILE
39
  define( 'DLM_PLUGIN_FILE', __FILE__ );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: never5, barrykooij, mikejolley, hchouhan
3
  Donate link: http://www.barrykooij.com/donate/
4
  Tags: download, downloads, monitor, hits, download monitor, tracking, admin, count, counter, files, versions, download count, logging, AJAX, digital, documents, download category, download manager, download template, downloadmanager, file manager, file tree, grid, hits, ip-address, manager, media, monitor, password, protect downloads, tracker
5
  Requires at least: 3.8
6
- Tested up to: 4.9.4
7
- Stable tag: 4.0.6
8
  License: GPLv3
9
  Text Domain: -
10
 
@@ -114,6 +114,20 @@ More documentation can be found in our [Knowledge Base](https://www.download-mon
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  = 4.0.6: March 8, 2018 =
118
  * Tweak: Fixed a bug in the version-list template, correct version links are now displayed.
119
 
3
  Donate link: http://www.barrykooij.com/donate/
4
  Tags: download, downloads, monitor, hits, download monitor, tracking, admin, count, counter, files, versions, download count, logging, AJAX, digital, documents, download category, download manager, download template, downloadmanager, file manager, file tree, grid, hits, ip-address, manager, media, monitor, password, protect downloads, tracker
5
  Requires at least: 3.8
6
+ Tested up to: 4.9.5
7
+ Stable tag: 4.0.7
8
  License: GPLv3
9
  Text Domain: -
10
 
114
 
115
  == Changelog ==
116
 
117
+ = 4.0.7: April 13, 2018 =
118
+ * Tweak: Fixed a bug that caused certain months in the reports filter to crash for non English languages.
119
+ * Tweak: Fixed a bug that caused the 10 download limit on the Dashboard Widget to be ignored.
120
+ * Tweak: Added "dlm_remove_dashboard_popular_downloads" filter that allows for not loading of dashboard widget.
121
+ * Tweak: Moved 'dlm_log_item' filter to within the WordPressLogItemRepository::persist() method. This way the filter will always be called upon a log persist.
122
+ * Tweak: Filter 'dlm_log_item' 2nd and 3rd argument changed from DLM_Download & DLM_Download_Version type to int (ID's of both download and version).
123
+ * Tweak: Moved 'dlm_downloading_log_item_added' filter to within the WordPressLogItemRepository::persist() method. This way the filter will always be called upon a log persist.
124
+ * Tweak: Filter 'dlm_downloading_log_item_added' 2nd and 3rd argument changed from DLM_Download & DLM_Download_Version type to int (ID's of both download and version).
125
+ * Tweak: Added filter 'dlm_reports_page_start' to add content on top of admin reports page.
126
+ * Tweak: Added filter 'dlm_reports_page_end' to add content on bottom of admin reports page.
127
+ * Tweak: Added download id and download object to 'dlm_placeholder_image_src' filter, props [James Golovich](https://github.com/jamesgol).
128
+ * Tweak: Added filter 'dlm_download_get_versions' on return of DLM_Download::get_versions(), props [James Golovich](https://github.com/jamesgol).
129
+ * Tweak: Added $atts to various shortcode filters, props [James Golovich](https://github.com/jamesgol).
130
+
131
  = 4.0.6: March 8, 2018 =
132
  * Tweak: Fixed a bug in the version-list template, correct version links are now displayed.
133
 
src/Admin/Dashboard.php CHANGED
@@ -16,7 +16,7 @@ class DLM_Admin_Dashboard {
16
  */
17
  public function __construct() {
18
 
19
- if ( ! current_user_can( 'manage_downloads' ) ) {
20
  return;
21
  }
22
 
@@ -36,7 +36,6 @@ class DLM_Admin_Dashboard {
36
 
37
  $filters = array(
38
  'no_found_rows' => 1,
39
- 'posts_per_page' => 10,
40
  'orderby' => 'meta_value_num',
41
  'order' => 'desc',
42
  'meta_query' => array(
@@ -48,7 +47,7 @@ class DLM_Admin_Dashboard {
48
  ),
49
  'meta_key' => '_download_count'
50
  );
51
- $downloads = download_monitor()->service('download_repository')->retrieve($filters);
52
 
53
  if ( empty( $downloads ) ) {
54
  echo '<p>' . __( 'There are no stats available yet!', 'download-monitor' ) . '</p>';
16
  */
17
  public function __construct() {
18
 
19
+ if ( ! current_user_can( 'manage_downloads' ) || apply_filters( 'dlm_remove_dashboard_popular_downloads', false ) ) {
20
  return;
21
  }
22
 
36
 
37
  $filters = array(
38
  'no_found_rows' => 1,
 
39
  'orderby' => 'meta_value_num',
40
  'order' => 'desc',
41
  'meta_query' => array(
47
  ),
48
  'meta_key' => '_download_count'
49
  );
50
+ $downloads = download_monitor()->service( 'download_repository' )->retrieve( $filters, 10 );
51
 
52
  if ( empty( $downloads ) ) {
53
  echo '<p>' . __( 'There are no stats available yet!', 'download-monitor' ) . '</p>';
src/Admin/Reports/Page.php CHANGED
@@ -200,6 +200,8 @@ class DLM_Reports_Page {
200
  */
201
  ?>
202
 
 
 
203
  <div class="dlm-reports-block dlm-reports-block-chart"
204
  id="total_downloads_chart"<?php echo $this->generate_js_data(); ?>></div>
205
 
@@ -222,6 +224,8 @@ class DLM_Reports_Page {
222
  <span class="dlm-reports-placeholder-no-data">NO DATA</span>
223
  </div>
224
 
 
 
225
  <script type="text/javascript">
226
  jQuery( document ).ready( function ( $ ) {
227
  $( '#dlm-date-range-picker' ).dlm_reports_date_range( '<?php echo $date_range['from']; ?>', '<?php echo $date_range['to']; ?>', '<?php echo $js_url; ?>' );
200
  */
201
  ?>
202
 
203
+ <?php do_action( 'dlm_reports_page_start' ); ?>
204
+
205
  <div class="dlm-reports-block dlm-reports-block-chart"
206
  id="total_downloads_chart"<?php echo $this->generate_js_data(); ?>></div>
207
 
224
  <span class="dlm-reports-placeholder-no-data">NO DATA</span>
225
  </div>
226
 
227
+ <?php do_action( 'dlm_reports_page_end' ); ?>
228
+
229
  <script type="text/javascript">
230
  jQuery( document ).ready( function ( $ ) {
231
  $( '#dlm-date-range-picker' ).dlm_reports_date_range( '<?php echo $date_range['from']; ?>', '<?php echo $date_range['to']; ?>', '<?php echo $js_url; ?>' );
src/Download/Download.php CHANGED
@@ -296,7 +296,7 @@ class DLM_Download {
296
  if ( has_post_thumbnail( $this->id ) ) {
297
  return get_the_post_thumbnail( $this->id, $size );
298
  } else {
299
- return '<img alt="Placeholder" class="wp-post-image" src="' . apply_filters( 'dlm_placeholder_image_src', download_monitor()->get_plugin_url() . '/assets/images/placeholder.png' ) . '" />';
300
  }
301
  }
302
 
@@ -372,7 +372,7 @@ class DLM_Download {
372
  * @return bool
373
  */
374
  public function has_version() {
375
- return ( null !== $this->get_version() );
376
  }
377
 
378
  /**
@@ -500,7 +500,7 @@ class DLM_Download {
500
  }
501
  }
502
 
503
- return $this->versions;
504
  }
505
 
506
  /**
296
  if ( has_post_thumbnail( $this->id ) ) {
297
  return get_the_post_thumbnail( $this->id, $size );
298
  } else {
299
+ return '<img alt="Placeholder" class="wp-post-image" src="' . apply_filters( 'dlm_placeholder_image_src', download_monitor()->get_plugin_url() . '/assets/images/placeholder.png', $this->id, $this ) . '" />';
300
  }
301
  }
302
 
372
  * @return bool
373
  */
374
  public function has_version() {
375
+ return ( null !== $this->get_version() && $this->get_version()->get_id() > 0 );
376
  }
377
 
378
  /**
500
  }
501
  }
502
 
503
+ return apply_filters( 'dlm_download_get_versions', $this->versions, $this );
504
  }
505
 
506
  /**
src/DownloadHandler.php CHANGED
@@ -364,14 +364,8 @@ class DLM_Download_Handler {
364
  $log_item->set_download_status( $status );
365
  $log_item->set_download_status_message( $message );
366
 
367
- // allow filtering of log item
368
- $log_item = apply_filters( 'dlm_log_item', $log_item, $download, $version );
369
-
370
  // persist log item
371
  download_monitor()->service( 'log_item_repository' )->persist( $log_item );
372
-
373
- // trigger action when new log item was added for a download request
374
- do_action( 'dlm_downloading_log_item_added', $log_item, $download, $version );
375
  }
376
 
377
  }
364
  $log_item->set_download_status( $status );
365
  $log_item->set_download_status_message( $message );
366
 
 
 
 
367
  // persist log item
368
  download_monitor()->service( 'log_item_repository' )->persist( $log_item );
 
 
 
369
  }
370
 
371
  }
src/Logs/WordPressLogItemRepository.php CHANGED
@@ -180,6 +180,9 @@ class DLM_WordPress_Log_Item_Repository implements DLM_Log_Item_Repository {
180
  public function persist( $log_item ) {
181
  global $wpdb;
182
 
 
 
 
183
  // hide wpdb errors to prevent errors in download request
184
  $wpdb->hide_errors();
185
 
@@ -276,6 +279,9 @@ class DLM_WordPress_Log_Item_Repository implements DLM_Log_Item_Repository {
276
 
277
  }
278
 
 
 
 
279
  return true;
280
  }
281
 
180
  public function persist( $log_item ) {
181
  global $wpdb;
182
 
183
+ // allow filtering of log item
184
+ $log_item = apply_filters( 'dlm_log_item', $log_item, $log_item->get_download_id(), $log_item->get_version_id() );
185
+
186
  // hide wpdb errors to prevent errors in download request
187
  $wpdb->hide_errors();
188
 
279
 
280
  }
281
 
282
+ // trigger action when new log item was added for a download request
283
+ do_action( 'dlm_downloading_log_item_added', $log_item, $log_item->get_download_id(), $log_item->get_version_id() );
284
+
285
  return true;
286
  }
287
 
src/Shortcodes.php CHANGED
@@ -64,6 +64,7 @@ class DLM_Shortcodes {
64
  * @access public
65
  *
66
  * @param array $atts
 
67
  *
68
  * @return string
69
  */
@@ -79,7 +80,7 @@ class DLM_Shortcodes {
79
  ), $atts ) );
80
 
81
  // Make id filterable
82
- $id = apply_filters( 'dlm_shortcode_download_id', $id );
83
 
84
  // Check id
85
  if ( empty( $id ) ) {
@@ -87,7 +88,7 @@ class DLM_Shortcodes {
87
  }
88
 
89
  // Allow third party extensions to hijack shortcode
90
- $hijacked_content = apply_filters( 'dlm_shortcode_download_content', '', $id, $atts );
91
 
92
  // If there's hijacked content, return it and be done with it
93
  if ( '' !== $hijacked_content ) {
@@ -162,7 +163,7 @@ class DLM_Shortcodes {
162
  'version' => ''
163
  ), $atts ) );
164
 
165
- $id = apply_filters( 'dlm_shortcode_download_id', $id );
166
 
167
  if ( empty( $id ) || empty( $data ) ) {
168
  return "";
@@ -427,7 +428,7 @@ class DLM_Shortcodes {
427
  ob_start();
428
 
429
  // Allow filtering of arguments
430
- $args = apply_filters( 'dlm_shortcode_downloads_args', $args );
431
 
432
  $offset = $paginate ? ( max( 1, get_query_var( 'paged' ) ) - 1 ) * $per_page : $offset;
433
 
64
  * @access public
65
  *
66
  * @param array $atts
67
+ * @param string $content
68
  *
69
  * @return string
70
  */
80
  ), $atts ) );
81
 
82
  // Make id filterable
83
+ $id = apply_filters( 'dlm_shortcode_download_id', $id, $atts );
84
 
85
  // Check id
86
  if ( empty( $id ) ) {
88
  }
89
 
90
  // Allow third party extensions to hijack shortcode
91
+ $hijacked_content = apply_filters( 'dlm_shortcode_download_content', '', $id, $atts, $content );
92
 
93
  // If there's hijacked content, return it and be done with it
94
  if ( '' !== $hijacked_content ) {
163
  'version' => ''
164
  ), $atts ) );
165
 
166
+ $id = apply_filters( 'dlm_shortcode_download_id', $id, $atts );
167
 
168
  if ( empty( $id ) || empty( $data ) ) {
169
  return "";
428
  ob_start();
429
 
430
  // Allow filtering of arguments
431
+ $args = apply_filters( 'dlm_shortcode_downloads_args', $args, $atts );
432
 
433
  $offset = $paginate ? ( max( 1, get_query_var( 'paged' ) ) - 1 ) * $per_page : $offset;
434