Simple Download Monitor - Version 3.6.5

Version Description

  • Added a new feature to allow easy copying/cloning of your existing download item. Useful if you are trying to create a lot of similar downloads.
  • The list downloads from category can now accept multiple category slugs (or IDs).
  • The pagination arrow has been changed to use »
Download this release

Release Info

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

Code changes from version 3.6.4 to 3.6.5

images/addons/sdm-email-on-download-addon-icon.png ADDED
Binary file
includes/admin-side/sdm-admin-add-ons-page.php CHANGED
@@ -33,15 +33,23 @@ echo '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL
33
  "description" => "Allows you to create hidden download buttons for your downloadable items so the actual location of the file is never revealed.",
34
  "page_url" => "https://simple-download-monitor.com/hidden-downloads-for-simple-download-monitor/",
35
  );
36
- array_push($addons_data, $addon_3);
37
-
38
  $addon_4 = array(
 
 
 
 
 
 
 
 
39
  "name" => "All File Type Uploads",
40
  "thumbnail" => WP_SIMPLE_DL_MONITOR_URL . "/images/addons/sdm-allow-uploads-addon-icon.png",
41
  "description" => "WordPress by default doesn't allow you to upload all file types. This addon will remove the limitation and allow you to upload all file types.",
42
  "page_url" => "https://simple-download-monitor.com/allow-more-file-types-to-be-uploaded-via-wordpress/",
43
  );
44
- array_push($addons_data, $addon_4);
45
 
46
  /*** Show the addons list ***/
47
  foreach ($addons_data as $addon) {
33
  "description" => "Allows you to create hidden download buttons for your downloadable items so the actual location of the file is never revealed.",
34
  "page_url" => "https://simple-download-monitor.com/hidden-downloads-for-simple-download-monitor/",
35
  );
36
+ array_push($addons_data, $addon_3);
37
+
38
  $addon_4 = array(
39
+ "name" => "Email on Download",
40
+ "thumbnail" => WP_SIMPLE_DL_MONITOR_URL . "/images/addons/sdm-email-on-download-addon-icon.png",
41
+ "description" => "The Email Notification Addon sends you (the site admin) an email whenever one of your files is downloaded.",
42
+ "page_url" => "https://simple-download-monitor.com/email-notification-on-download-addon-for-the-simple-download-monitor/",
43
+ );
44
+ array_push($addons_data, $addon_4);
45
+
46
+ $addon_5 = array(
47
  "name" => "All File Type Uploads",
48
  "thumbnail" => WP_SIMPLE_DL_MONITOR_URL . "/images/addons/sdm-allow-uploads-addon-icon.png",
49
  "description" => "WordPress by default doesn't allow you to upload all file types. This addon will remove the limitation and allow you to upload all file types.",
50
  "page_url" => "https://simple-download-monitor.com/allow-more-file-types-to-be-uploaded-via-wordpress/",
51
  );
52
+ array_push($addons_data, $addon_5);
53
 
54
  /*** Show the addons list ***/
55
  foreach ($addons_data as $addon) {
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.6.4
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
15
  exit;
16
  }
17
 
18
- define('WP_SIMPLE_DL_MONITOR_VERSION', '3.6.4');
19
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
20
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
21
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
@@ -211,6 +211,11 @@ class simpleDownloadManager {
211
 
212
  add_action('admin_init', array($this, 'sdm_register_options')); // Register admin options
213
  //add_filter('post_row_actions', array($this, 'sdm_remove_view_link_cpt'), 10, 2); // Remove 'View' link in all downloads list view
 
 
 
 
 
214
  }
215
 
216
  }
@@ -755,6 +760,128 @@ class simpleDownloadManager {
755
  echo '<input size="100" name="sdm_advanced_options[termscond_url]" id="termscond_url" type="text" value="'.$value.'" /> ';
756
  echo '<p class="description">' . __('Enter the URL of your terms and conditions page.', 'simple-download-monitor') . '</p>';
757
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
758
  }
759
 
760
  //End of simpleDownloadManager class
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.6.5
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
15
  exit;
16
  }
17
 
18
+ define('WP_SIMPLE_DL_MONITOR_VERSION', '3.6.5');
19
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
20
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
21
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
211
 
212
  add_action('admin_init', array($this, 'sdm_register_options')); // Register admin options
213
  //add_filter('post_row_actions', array($this, 'sdm_remove_view_link_cpt'), 10, 2); // Remove 'View' link in all downloads list view
214
+
215
+ add_filter('page_row_actions', array($this, 'sdm_add_clone_record_btn'), 10, 2); // Add 'Clone' link in all downloads list view
216
+ add_filter('post_row_actions', array($this, 'sdm_add_clone_record_btn'), 10, 2); // Add 'Clone' link in all downloads list view
217
+
218
+ add_action('admin_action_sdm_clone_post', array($this, 'sdm_action_clone_post'));
219
  }
220
 
221
  }
760
  echo '<input size="100" name="sdm_advanced_options[termscond_url]" id="termscond_url" type="text" value="'.$value.'" /> ';
761
  echo '<p class="description">' . __('Enter the URL of your terms and conditions page.', 'simple-download-monitor') . '</p>';
762
  }
763
+
764
+ public function sdm_add_clone_record_btn($action, $post) {
765
+ // Only execute on SDM CPT posts page
766
+ if ($post->post_type == 'sdm_downloads') {
767
+ $action['clone'] = sprintf(
768
+ '<a href="%2$s" aria-label="%1$s">%1$s</a>',
769
+ esc_html__( 'Clone', 'simple-download-monitor' ),
770
+ $this->get_duplicate_url( $post->ID )
771
+ );
772
+ }
773
+ return $action;
774
+ }
775
+
776
+ /**
777
+ * Returns duplicate post URL
778
+ *
779
+ * @return string
780
+ */
781
+ public function get_duplicate_url($post_id) {
782
+ global $wp;
783
+ return add_query_arg(array(
784
+ 'action' => 'sdm_clone_post',
785
+ 'post' => $post_id,
786
+ 'ref' => urlencode(add_query_arg($wp->query_string, '', home_url($wp->request))),
787
+ '_nonce' => wp_create_nonce('sdm_downloads')
788
+ ), esc_url(admin_url('admin.php'))
789
+ );
790
+ }
791
+
792
+ public function sdm_action_clone_post() {
793
+
794
+ global $wpdb;
795
+ if (!( isset($_GET['post']) || isset($_POST['post']) || ( isset($_REQUEST['action']) && 'sdm_clone_post' == $_REQUEST['action'] ) )) {
796
+ wp_die(__('No post to duplicate has been supplied!', 'simple-download-monitor'));
797
+ }
798
+
799
+ /*
800
+ * Nonce verification
801
+ */
802
+ if (!isset($_GET['_nonce']) || !wp_verify_nonce($_GET['_nonce'], 'sdm_downloads'))
803
+ return;
804
+
805
+ /*
806
+ * get the original post id
807
+ */
808
+ $post_id = (isset($_GET['post']) ? absint($_GET['post']) : absint($_POST['post']) );
809
+ /*
810
+ * and all the original post data then
811
+ */
812
+ $post = get_post($post_id);
813
+
814
+ /*
815
+ * if you don't want current user to be the new post author,
816
+ * then change next couple of lines to this: $new_post_author = $post->post_author;
817
+ */
818
+ $current_user = wp_get_current_user();
819
+ $new_post_author = $current_user->ID;
820
+
821
+ /*
822
+ * if post data exists, create the post duplicate
823
+ */
824
+ if (isset($post) && $post != null) {
825
+
826
+ /*
827
+ * new post data array
828
+ */
829
+ $args = array(
830
+ 'comment_status' => $post->comment_status,
831
+ 'ping_status' => $post->ping_status,
832
+ 'post_author' => $new_post_author,
833
+ 'post_content' => $post->post_content,
834
+ 'post_excerpt' => $post->post_excerpt,
835
+ 'post_name' => $post->post_name,
836
+ 'post_parent' => $post->post_parent,
837
+ 'post_password' => $post->post_password,
838
+ 'post_status' => 'draft',
839
+ 'post_title' => $post->post_title,
840
+ 'post_type' => $post->post_type,
841
+ 'to_ping' => $post->to_ping,
842
+ 'menu_order' => $post->menu_order
843
+ );
844
+
845
+ /*
846
+ * insert the post by wp_insert_post() function
847
+ */
848
+ $new_post_id = wp_insert_post($args);
849
+
850
+ /*
851
+ * get all current post terms ad set them to the new post draft
852
+ */
853
+ $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
854
+ foreach ($taxonomies as $taxonomy) {
855
+ $post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
856
+ wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
857
+ }
858
+
859
+ /*
860
+ * duplicate all post meta just in two SQL queries
861
+ */
862
+ $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
863
+ if (count($post_meta_infos) != 0) {
864
+ $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
865
+ foreach ($post_meta_infos as $meta_info) {
866
+ $meta_key = $meta_info->meta_key;
867
+ if ($meta_key == '_wp_old_slug')
868
+ continue;
869
+ $meta_value = addslashes($meta_info->meta_value);
870
+ $sql_query_sel[] = "SELECT $new_post_id, '$meta_key', '$meta_value'";
871
+ }
872
+ $sql_query .= implode(" UNION ALL ", $sql_query_sel);
873
+ $wpdb->query($sql_query);
874
+ }
875
+
876
+ /*
877
+ * finally, redirect to the edit post screen for the new draft
878
+ */
879
+ wp_redirect(admin_url('post.php?action=edit&post=' . $new_post_id));
880
+ exit;
881
+ } else {
882
+ wp_die(__('Post creation failed, could not find original post: ', 'simple-download-monitor') . $post_id);
883
+ }
884
+ }
885
  }
886
 
887
  //End of simpleDownloadManager class
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.6.4
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -70,8 +70,9 @@ https://www.youtube.com/watch?v=utYIH0fILuQ
70
  * Option to ignore download count from bots.
71
  * Option to add Google reCAPTCHA to your download buttons.
72
  * Option to add Terms and Condtions to your download buttons.
 
73
 
74
- View more details on the [download monitor plugin](https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin) page.
75
 
76
  = Language Translations =
77
 
@@ -181,10 +182,15 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
184
  = 3.6.4 =
185
  - Switched the column location of "Title" and "Image" in the downloads admin interface. This helps with the downloads admin interface working better in all devices.
186
  - Fixed a CSS class name in the "Image" column.
187
- - French langauge file updated.
188
 
189
  = 3.6.3 =
190
  - German translation file updated. Thanks to Thorsten.
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.6.5
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
70
  * Option to ignore download count from bots.
71
  * Option to add Google reCAPTCHA to your download buttons.
72
  * Option to add Terms and Condtions to your download buttons.
73
+ * Ability to easily clone/copy your existing download items.
74
 
75
+ View more details on the [download monitor plugin](https://simple-download-monitor.com/) page.
76
 
77
  = Language Translations =
78
 
182
 
183
  == Changelog ==
184
 
185
+ = 3.6.5 =
186
+ - Added a new feature to allow easy copying/cloning of your existing download item. Useful if you are trying to create a lot of similar downloads.
187
+ - The list downloads from category can now accept multiple category slugs (or IDs).
188
+ - The pagination arrow has been changed to use &raquo;
189
+
190
  = 3.6.4 =
191
  - Switched the column location of "Title" and "Image" in the downloads admin interface. This helps with the downloads admin interface working better in all devices.
192
  - Fixed a CSS class name in the "Image" column.
193
+ - French language file updated.
194
 
195
  = 3.6.3 =
196
  - German translation file updated. Thanks to Thorsten.
sdm-shortcodes.php CHANGED
@@ -198,13 +198,19 @@ function sdm_handle_category_shortcode( $args ) {
198
  if ( ! empty( $category_slug ) && empty( $category_id ) ) {
199
 
200
  $field = 'slug';
201
- $terms = $category_slug;
 
 
 
202
  }
203
  // Else setup query arguments for category_id
204
  else if ( ! empty( $category_id ) && empty( $category_slug ) ) {
205
 
206
  $field = 'term_id';
207
- $terms = $category_id;
 
 
 
208
  }
209
 
210
  if ( isset( $args[ 'show_all' ] ) ) {
@@ -320,8 +326,8 @@ function sdm_handle_category_shortcode( $args ) {
320
  'add_args' => '',
321
  'current' => max( 1, get_query_var( 'paged' ) ),
322
  'total' => $total_pages,
323
- 'prev_text' => '&larr;',
324
- 'next_text' => '&rarr;',
325
  ) );
326
  $output .= '<div class="sdm_pagination">' . $pagination . '</div>';
327
  }
198
  if ( ! empty( $category_slug ) && empty( $category_id ) ) {
199
 
200
  $field = 'slug';
201
+
202
+ $terms = array_filter(explode(',', $category_slug), function($value) {
203
+ return !empty($value) ? trim($value) : false;
204
+ });
205
  }
206
  // Else setup query arguments for category_id
207
  else if ( ! empty( $category_id ) && empty( $category_slug ) ) {
208
 
209
  $field = 'term_id';
210
+ //$terms = $category_id;
211
+ $terms = array_filter(explode(',', $category_id), function($value) {
212
+ return !empty($value) ? trim($value) : false;
213
+ });
214
  }
215
 
216
  if ( isset( $args[ 'show_all' ] ) ) {
326
  'add_args' => '',
327
  'current' => max( 1, get_query_var( 'paged' ) ),
328
  'total' => $total_pages,
329
+ 'prev_text' => '&laquo;',
330
+ 'next_text' => '&raquo;',
331
  ) );
332
  $output .= '<div class="sdm_pagination">' . $pagination . '</div>';
333
  }