Simple Download Monitor - Version 3.4.8

Version Description

  • Fixed an issue with the shortcode inserter interface showing the last 5 items only.
  • The "show_size" shortcode parameter will work correctly with the fancy template now.
Download this release

Release Info

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

Code changes from version 3.4.6 to 3.4.8

Files changed (4) hide show
  1. js/sdm_admin_scripts.js +45 -32
  2. main.php +31 -16
  3. readme.txt +14 -3
  4. sdm-shortcodes.php +3 -0
js/sdm_admin_scripts.js CHANGED
@@ -1,52 +1,65 @@
1
- jQuery(document).ready(function($) {
2
-
 
3
  // Run media uploader for file upload
4
- $('#upload_image_button').click(function() {
5
-
6
- tb_show('', 'media-upload.php?type=image&TB_iframe=true');
7
-
8
- window.send_to_editor = function(html) {
 
 
 
 
 
 
 
9
 
10
- imgurl = $(html).attr('href');
11
- $('#sdm_upload').val(imgurl);
12
- tb_remove();
13
- }
14
  });
15
 
16
  // Run media uploader for thumbnail upload
17
- $('#upload_thumbnail_button').click(function() {
18
-
19
- tb_show('', 'media-upload.php?type=image&TB_iframe=true');
20
-
21
- window.send_to_editor = function(html) {
 
 
 
 
 
 
 
 
22
 
23
- imgurl = $(html).attr('href');
24
  $('#sdm_thumbnail_image').remove();
25
- $('#sdm_admin_thumb_preview').html('<img id="sdm_thumbnail_image" src="' + imgurl + '" style="max-width:200px;" />');
26
 
27
- $('#sdm_upload_thumbnail').val(imgurl);
28
- tb_remove();
29
- }
30
  });
31
 
32
  // Remove thumbnail image from CPT
33
- $('#remove_thumbnail_button').click(function() {
34
  $.post(
35
  sdm_admin_ajax_url.sdm_admin_ajax_url,
36
  {
37
  action: 'sdm_remove_thumbnail_image',
38
  post_id_del: sdm_del_thumb_postid
39
  },
40
- function(response) {
41
- if (response) { // ** If response was successful
42
- $('#sdm_thumbnail_image').remove();
43
- $('#sdm_upload_thumbnail').val('');
44
- alert(sdm_translations.image_removed);
45
- }
46
- else { // ** Else response was unsuccessful
47
- alert(sdm_translations.ajax_error);
48
- }
49
- }
50
  );
51
  });
52
 
1
+ jQuery(document).ready(function ($) {
2
+ var selectFileFrame;
3
+ var selectThumbFramel
4
  // Run media uploader for file upload
5
+ $('#upload_image_button').click(function (e) {
6
+ e.preventDefault();
7
+ selectFileFrame = wp.media({
8
+ title: sdm_translations.select_file,
9
+ button: {
10
+ text: sdm_translations.insert,
11
+ },
12
+ multiple: false
13
+ });
14
+ selectFileFrame.open();
15
+ selectFileFrame.on('select', function () {
16
+ var attachment = selectFileFrame.state().get('selection').first().toJSON();
17
 
18
+ $('#sdm_upload').val(attachment.url);
19
+ });
20
+ return false;
 
21
  });
22
 
23
  // Run media uploader for thumbnail upload
24
+ $('#upload_thumbnail_button').click(function (e) {
25
+ e.preventDefault();
26
+ selectFileFrame = wp.media({
27
+ title: sdm_translations.select_thumbnail,
28
+ button: {
29
+ text: sdm_translations.insert,
30
+ },
31
+ multiple: false,
32
+ library: {type: 'image'},
33
+ });
34
+ selectFileFrame.open();
35
+ selectFileFrame.on('select', function () {
36
+ var attachment = selectFileFrame.state().get('selection').first().toJSON();
37
 
 
38
  $('#sdm_thumbnail_image').remove();
39
+ $('#sdm_admin_thumb_preview').html('<img id="sdm_thumbnail_image" src="' + attachment.url + '" style="max-width:200px;" />');
40
 
41
+ $('#sdm_upload_thumbnail').val(attachment.url);
42
+ });
43
+ return false;
44
  });
45
 
46
  // Remove thumbnail image from CPT
47
+ $('#remove_thumbnail_button').click(function () {
48
  $.post(
49
  sdm_admin_ajax_url.sdm_admin_ajax_url,
50
  {
51
  action: 'sdm_remove_thumbnail_image',
52
  post_id_del: sdm_del_thumb_postid
53
  },
54
+ function (response) {
55
+ if (response) { // ** If response was successful
56
+ $('#sdm_thumbnail_image').remove();
57
+ $('#sdm_upload_thumbnail').val('');
58
+ alert(sdm_translations.image_removed);
59
+ } else { // ** Else response was unsuccessful
60
+ alert(sdm_translations.ajax_error);
61
+ }
62
+ }
 
63
  );
64
  });
65
 
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.4.6
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
@@ -12,7 +12,7 @@ if (!defined('ABSPATH')) {
12
  exit;
13
  }
14
 
15
- define('WP_SIMPLE_DL_MONITOR_VERSION', '3.4.6');
16
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
17
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
18
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
@@ -138,10 +138,16 @@ function sdm_delete_data_handler() {
138
  //let's delete options
139
  delete_option('sdm_downloads_options');
140
  delete_option('sdm_db_version');
 
 
 
 
141
  //let's delete sdm_downloads table
142
  $wpdb->query("DROP TABLE " . $wpdb->prefix . "sdm_downloads");
143
  //deactivate plugin
144
  deactivate_plugins(plugin_basename(__FILE__));
 
 
145
  echo '1';
146
  wp_die();
147
  }
@@ -214,7 +220,7 @@ class simpleDownloadManager {
214
  // These scripts are needed for the media upload thickbox
215
  wp_enqueue_script('media-upload');
216
  wp_enqueue_script('thickbox');
217
- wp_register_script('sdm-upload', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_admin_scripts.js', array('jquery', 'media-upload', 'thickbox'));
218
  wp_enqueue_script('sdm-upload');
219
 
220
  // Pass postID for thumbnail deletion
@@ -225,6 +231,9 @@ class simpleDownloadManager {
225
  <?php
226
  // Localize langauge strings used in js file
227
  $sdmTranslations = array(
 
 
 
228
  'image_removed' => __('Image Successfully Removed', 'simple-download-monitor'),
229
  'ajax_error' => __('Error with AJAX', 'simple-download-monitor')
230
  );
@@ -274,7 +283,7 @@ class simpleDownloadManager {
274
 
275
  //***** Create metaboxes for the custom post type
276
  add_meta_box('sdm_description_meta_box', __('Description', 'simple-download-monitor'), array($this, 'display_sdm_description_meta_box'), 'sdm_downloads', 'normal', 'default');
277
- add_meta_box('sdm_upload_meta_box', __('Upload File', 'simple-download-monitor'), array($this, 'display_sdm_upload_meta_box'), 'sdm_downloads', 'normal', 'default');
278
  add_meta_box('sdm_dispatch_meta_box', __('PHP Dispatch or Redirect', 'simple-download-monitor'), array($this, 'display_sdm_dispatch_meta_box'), 'sdm_downloads', 'normal', 'default');
279
  add_meta_box('sdm_thumbnail_meta_box', __('File Thumbnail (Optional)', 'simple-download-monitor'), array($this, 'display_sdm_thumbnail_meta_box'), 'sdm_downloads', 'normal', 'default');
280
  add_meta_box('sdm_stats_meta_box', __('Statistics', 'simple-download-monitor'), array($this, 'display_sdm_stats_meta_box'), 'sdm_downloads', 'normal', 'default');
@@ -310,9 +319,9 @@ class simpleDownloadManager {
310
  echo '<br /><br />';
311
  _e('Steps to upload a file or choose one from your media library:', 'simple-download-monitor');
312
  echo '<ol>';
313
- echo '<li>Hit the "Select File" button</li>';
314
  echo '<li>Upload a new file or choose an existing one from your media library.</li>';
315
- echo '<li>Click the "Insert into Post" button, this will populate the uploaded file URL in the above text field.</li>';
316
  echo '</ol>';
317
 
318
  wp_nonce_field('sdm_upload_box_nonce', 'sdm_upload_box_nonce_check');
@@ -669,15 +678,15 @@ add_action('wp_ajax_nopriv_sdm_tiny_get_post_ids', 'sdm_tiny_get_post_ids_ajax_c
669
  add_action('wp_ajax_sdm_tiny_get_post_ids', 'sdm_tiny_get_post_ids_ajax_call');
670
 
671
  function sdm_tiny_get_post_ids_ajax_call() {
672
-
673
- $args = array(
674
  'post_type' => 'sdm_downloads',
 
 
675
  );
676
- $loop = new WP_Query($args);
677
- $test = '';
678
- foreach ($loop->posts as $loop_post) {
679
- $test[] = array('post_id' => $loop_post->ID, 'post_title' => $loop_post->post_title);
680
- }
681
 
682
  $response = json_encode(array('success' => true, 'test' => $test));
683
 
@@ -699,9 +708,15 @@ function sdm_remove_thumbnail_image_ajax_call() {
699
 
700
  //Go ahead with the thumbnail removal
701
  $post_id = $_POST['post_id_del'];
702
- $success = delete_post_meta($post_id, 'sdm_upload_thumbnail');
703
- if ($success) {
704
- $response = json_encode(array('success' => true));
 
 
 
 
 
 
705
  }
706
 
707
  header('Content-Type: application/json');
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.4.8
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
12
  exit;
13
  }
14
 
15
+ define('WP_SIMPLE_DL_MONITOR_VERSION', '3.4.8');
16
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
17
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
18
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
138
  //let's delete options
139
  delete_option('sdm_downloads_options');
140
  delete_option('sdm_db_version');
141
+ //remove post type and taxonomies
142
+ unregister_post_type('sdm_downloads');
143
+ unregister_taxonomy('sdm_categories');
144
+ unregister_taxonomy('sdm_tags');
145
  //let's delete sdm_downloads table
146
  $wpdb->query("DROP TABLE " . $wpdb->prefix . "sdm_downloads");
147
  //deactivate plugin
148
  deactivate_plugins(plugin_basename(__FILE__));
149
+ //flush rewrite rules
150
+ flush_rewrite_rules(false);
151
  echo '1';
152
  wp_die();
153
  }
220
  // These scripts are needed for the media upload thickbox
221
  wp_enqueue_script('media-upload');
222
  wp_enqueue_script('thickbox');
223
+ wp_register_script('sdm-upload', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_admin_scripts.js', array('jquery', 'media-upload', 'thickbox'), WP_SIMPLE_DL_MONITOR_VERSION);
224
  wp_enqueue_script('sdm-upload');
225
 
226
  // Pass postID for thumbnail deletion
231
  <?php
232
  // Localize langauge strings used in js file
233
  $sdmTranslations = array(
234
+ 'select_file' => __('Select File', 'simple-download-monitor'),
235
+ 'select_thumbnail' => __('Select Thumbnail', 'simple-download-monitor'),
236
+ 'insert' => __('Insert', 'simple-download-monitor'),
237
  'image_removed' => __('Image Successfully Removed', 'simple-download-monitor'),
238
  'ajax_error' => __('Error with AJAX', 'simple-download-monitor')
239
  );
283
 
284
  //***** Create metaboxes for the custom post type
285
  add_meta_box('sdm_description_meta_box', __('Description', 'simple-download-monitor'), array($this, 'display_sdm_description_meta_box'), 'sdm_downloads', 'normal', 'default');
286
+ add_meta_box('sdm_upload_meta_box', __('Downloadable File (Visitors will download this item)', 'simple-download-monitor'), array($this, 'display_sdm_upload_meta_box'), 'sdm_downloads', 'normal', 'default');
287
  add_meta_box('sdm_dispatch_meta_box', __('PHP Dispatch or Redirect', 'simple-download-monitor'), array($this, 'display_sdm_dispatch_meta_box'), 'sdm_downloads', 'normal', 'default');
288
  add_meta_box('sdm_thumbnail_meta_box', __('File Thumbnail (Optional)', 'simple-download-monitor'), array($this, 'display_sdm_thumbnail_meta_box'), 'sdm_downloads', 'normal', 'default');
289
  add_meta_box('sdm_stats_meta_box', __('Statistics', 'simple-download-monitor'), array($this, 'display_sdm_stats_meta_box'), 'sdm_downloads', 'normal', 'default');
319
  echo '<br /><br />';
320
  _e('Steps to upload a file or choose one from your media library:', 'simple-download-monitor');
321
  echo '<ol>';
322
+ echo '<li>Hit the "Select File" button.</li>';
323
  echo '<li>Upload a new file or choose an existing one from your media library.</li>';
324
+ echo '<li>Click the "Insert" button, this will populate the uploaded file\'s URL in the above text field.</li>';
325
  echo '</ol>';
326
 
327
  wp_nonce_field('sdm_upload_box_nonce', 'sdm_upload_box_nonce_check');
678
  add_action('wp_ajax_sdm_tiny_get_post_ids', 'sdm_tiny_get_post_ids_ajax_call');
679
 
680
  function sdm_tiny_get_post_ids_ajax_call() {
681
+
682
+ $posts = get_posts(array(
683
  'post_type' => 'sdm_downloads',
684
+ 'numberposts' => -1,
685
+ )
686
  );
687
+ foreach ($posts as $item) {
688
+ $test[] = array('post_id' => $item->ID, 'post_title' => $item->post_title);
689
+ }
 
 
690
 
691
  $response = json_encode(array('success' => true, 'test' => $test));
692
 
708
 
709
  //Go ahead with the thumbnail removal
710
  $post_id = $_POST['post_id_del'];
711
+ $key_exists = metadata_exists('post', $post_id, 'sdm_upload_thumbnail');
712
+ if ($key_exists) {
713
+ $success = delete_post_meta($post_id, 'sdm_upload_thumbnail');
714
+ if ($success) {
715
+ $response = json_encode(array('success' => true));
716
+ }
717
+ } else {
718
+ // in order for frontend script to not display "Ajax error", let's return some data
719
+ $response = json_encode(array('not_exists' => true));
720
  }
721
 
722
  header('Content-Type: application/json');
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Tips and Tricks HQ, Ruhul Amin, josh401, mbrsolution, chesio
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: 4.1.0
6
- Tested up to: 4.8
7
- Stable tag: 3.4.6
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -25,7 +25,7 @@ The plugin will log the IP addresses of the users who download your digital file
25
 
26
  It has a very user-friendly interface for uploading, managing, monitoring and tracking file downloads.
27
 
28
- https://www.youtube.com/watch?v=L-mXbs7kp0s
29
 
30
  = Simple Download Monitor Features =
31
 
@@ -172,6 +172,17 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
172
 
173
  == Changelog ==
174
 
 
 
 
 
 
 
 
 
 
 
 
175
  = 3.4.6 =
176
  - Added option to delete plugin's settings, data and tables from database.
177
  - Added "Login Page URL" option to optionally specify a login page URL when user is required to be logged in to download.
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: 4.1.0
6
+ Tested up to: 4.9
7
+ Stable tag: 3.4.8
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
25
 
26
  It has a very user-friendly interface for uploading, managing, monitoring and tracking file downloads.
27
 
28
+ https://www.youtube.com/watch?v=utYIH0fILuQ
29
 
30
  = Simple Download Monitor Features =
31
 
172
 
173
  == Changelog ==
174
 
175
+ = TODO 3.4.9 =
176
+ - Updated the settings menu slug to make it unique.
177
+
178
+ = 3.4.8 =
179
+ - Fixed an issue with the shortcode inserter interface showing the last 5 items only.
180
+ - The "show_size" shortcode parameter will work correctly with the fancy template now.
181
+
182
+ = 3.4.7 =
183
+ - Reworked the file upload interface to make it more user-friendly.
184
+ - Delete plugin Data button now also deletes taxonomies and rewrite rules related to plugin.
185
+
186
  = 3.4.6 =
187
  - Added option to delete plugin's settings, data and tables from database.
188
  - Added "Login Page URL" option to optionally specify a login page URL when user is required to be logged in to download.
sdm-shortcodes.php CHANGED
@@ -61,6 +61,9 @@ function sdm_create_download_shortcode($atts) {
61
  'button_text' => __('Download Now!', 'simple-download-monitor'),
62
  'new_window' => '',
63
  'color' => '',
 
 
 
64
  ), $atts)
65
  );
66
 
61
  'button_text' => __('Download Now!', 'simple-download-monitor'),
62
  'new_window' => '',
63
  'color' => '',
64
+ 'css_class' => '',
65
+ 'show_size' => '',
66
+ 'show_version' => '',
67
  ), $atts)
68
  );
69