Simple Download Monitor - Version 3.9.2

Version Description

  • The sorting option on the "Downloads" column has been removed.
  • Added a new filter that can be used to override the "slug" of the download single post. The name of the filter hook is "sdm_downloads_post_type_before_register".
  • Addressed an issue whereby the single post of the download can show a warning if the download button color is not set in the settings.
  • WordPress 5.8 compatibility.
Download this release

Release Info

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

Code changes from version 3.8.7 to 3.9.2

includes/sdm-admin-menu-handler.php CHANGED
@@ -12,21 +12,21 @@ function sdm_handle_admin_menu() {
12
  $sdm_addons_page = add_submenu_page( 'edit.php?post_type=sdm_downloads', __( 'Add-ons', 'simple-download-monitor' ), __( 'Add-ons', 'simple-download-monitor' ), 'manage_options', 'sdm-addons', 'sdm_create_addons_page' );
13
  }
14
 
15
- add_filter( 'whitelist_options', 'sdm_admin_menu_function_hook' );
16
 
17
  /**
18
  * sdm_admin_menu_function_hook
19
- * Its hook for add advanced testings tab, and working on saving options to db, if not used, you receive error "options page not found"
20
- * @param array $whitelist_options
21
  * @return string
22
  */
23
- function sdm_admin_menu_function_hook( $whitelist_options = array() ) {
24
- $whitelist_options[ 'recaptcha_options_section' ] = array( 'sdm_advanced_options' );
25
- $whitelist_options[ 'termscond_options_section' ] = array( 'sdm_advanced_options' );
26
- $whitelist_options[ 'adsense_options_section' ] = array( 'sdm_advanced_options' );
27
- $whitelist_options[ 'maps_api_options_section' ] = array( 'sdm_advanced_options' );
28
 
29
- return $whitelist_options;
30
  }
31
 
32
  /*
@@ -163,7 +163,11 @@ function sdm_create_settings_page() {
163
  </div>
164
 
165
  <div style="background: none repeat scroll 0 0 #FFF6D5;border: 1px solid #D1B655;color: #3F2502;margin: 10px 0;padding: 5px 5px 5px 10px;text-shadow: 1px 1px #FFFFFF;">
166
- <p><?php _e( 'If you need a feature rich and supported plugin for selling your digital items then checkout our', 'simple-download-monitor' ); ?> <a href="https://www.tipsandtricks-hq.com/wordpress-estore-plugin-complete-solution-to-sell-digital-products-from-your-wordpress-blog-securely-1059" target="_blank"><?php _e( 'WP eStore Plugin', 'simple-download-monitor' ); ?></a>
 
 
 
 
167
  </p>
168
  </div>
169
 
12
  $sdm_addons_page = add_submenu_page( 'edit.php?post_type=sdm_downloads', __( 'Add-ons', 'simple-download-monitor' ), __( 'Add-ons', 'simple-download-monitor' ), 'manage_options', 'sdm-addons', 'sdm_create_addons_page' );
13
  }
14
 
15
+ add_filter( 'allowed_options', 'sdm_admin_menu_function_hook' );
16
 
17
  /**
18
  * sdm_admin_menu_function_hook
19
+ * Its hook for add advanced tab, and working on saving options to db, if not used, you receive error "options page not found"
20
+ * @param array $allowed_options
21
  * @return string
22
  */
23
+ function sdm_admin_menu_function_hook( $allowed_options = array() ) {
24
+ $allowed_options[ 'recaptcha_options_section' ] = array( 'sdm_advanced_options' );
25
+ $allowed_options[ 'termscond_options_section' ] = array( 'sdm_advanced_options' );
26
+ $allowed_options[ 'adsense_options_section' ] = array( 'sdm_advanced_options' );
27
+ $allowed_options[ 'maps_api_options_section' ] = array( 'sdm_advanced_options' );
28
 
29
+ return $allowed_options;
30
  }
31
 
32
  /*
163
  </div>
164
 
165
  <div style="background: none repeat scroll 0 0 #FFF6D5;border: 1px solid #D1B655;color: #3F2502;margin: 10px 0;padding: 5px 5px 5px 10px;text-shadow: 1px 1px #FFFFFF;">
166
+ <p>
167
+ <?php _e( 'If you need an easy to use and supported plugin for selling your digital items then check out our ', 'simple-download-monitor' ); ?>
168
+ <a href="https://wordpress.org/plugins/wp-express-checkout/" target="_blank"><?php _e( 'WP Express Checkout', 'simple-download-monitor' ); ?></a>
169
+ or <a href="https://wordpress.org/plugins/stripe-payments/" target="_blank"><?php _e( 'Stripe Payments', 'simple-download-monitor' ); ?></a>
170
+ or <a href="https://www.tipsandtricks-hq.com/wordpress-estore-plugin-complete-solution-to-sell-digital-products-from-your-wordpress-blog-securely-1059" target="_blank"><?php _e( 'WP eStore', 'simple-download-monitor' ); ?></a> Plugin.
171
  </p>
172
  </div>
173
 
includes/sdm-download-request-handler.php CHANGED
@@ -58,7 +58,16 @@ function handle_sdm_download_via_direct_post() {
58
  if ( ! isset( $main_option['admin_do_not_capture_user_agent'] ) ) {
59
  //Get the user agent data. The get_browser() function doesn't work on many servers. So use the HTTP var.
60
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
61
- $user_agent = $_SERVER['HTTP_USER_AGENT'];
 
 
 
 
 
 
 
 
 
62
  }
63
  }
64
 
@@ -144,9 +153,10 @@ function handle_sdm_download_via_direct_post() {
144
  'visitor_country' => $visitor_country,
145
  'visitor_name' => $visitor_name,
146
  'user_agent' => $user_agent,
 
147
  );
148
 
149
- $data = array_filter( $data ); //Remove any null values.
150
  $insert_table = $wpdb->insert( $table, $data );
151
 
152
  if ( $insert_table ) {
58
  if ( ! isset( $main_option['admin_do_not_capture_user_agent'] ) ) {
59
  //Get the user agent data. The get_browser() function doesn't work on many servers. So use the HTTP var.
60
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
61
+ $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
62
+ }
63
+ }
64
+
65
+ $referrer_url = '';
66
+ //Check if do not capture Referer URL is enabled.
67
+ if ( ! isset( $main_option['admin_do_not_capture_referrer_url'] ) ) {
68
+ //Get the user agent data. The get_browser() function doesn't work on many servers. So use the HTTP var.
69
+ if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
70
+ $referrer_url = sanitize_text_field( $_SERVER['HTTP_REFERER'] );
71
  }
72
  }
73
 
153
  'visitor_country' => $visitor_country,
154
  'visitor_name' => $visitor_name,
155
  'user_agent' => $user_agent,
156
+ 'referrer_url' => $referrer_url,
157
  );
158
 
159
+ $data = array_filter( $data ); //Remove any null values.
160
  $insert_table = $wpdb->insert( $table, $data );
161
 
162
  if ( $insert_table ) {
includes/sdm-logs-list-table.php CHANGED
@@ -35,6 +35,8 @@ class sdm_List_Table extends WP_List_Table {
35
  return $item[$column_name];
36
  case 'user_agent':
37
  return $item[$column_name];
 
 
38
  default:
39
  return print_r($item, true); //Show the whole array for troubleshooting purposes
40
  }
@@ -75,7 +77,8 @@ class sdm_List_Table extends WP_List_Table {
75
  'date' => __('Date', 'simple-download-monitor'),
76
  'visitor_country' => __('Country', 'simple-download-monitor'),
77
  'visitor_name' => __('Username', 'simple-download-monitor'),
78
- 'user_agent' => __('User Agent', 'simple-download-monitor')
 
79
  );
80
  return $columns;
81
  }
@@ -178,7 +181,7 @@ class sdm_List_Table extends WP_List_Table {
178
  $orderby_column = "date_time";
179
  $sort_order = "DESC";
180
  }
181
- $orderby_column = sdm_sanitize_value_by_array($orderby_column, array('post_title'=>'1', 'file_url'=>'1', 'visitor_ip'=>'1', 'date_time'=>'1', 'visitor_country'=>'1', 'visitor_name'=>'1', 'user_agent'=>'1'));
182
  $sort_order = sdm_sanitize_value_by_array($sort_order, array('DESC' => '1', 'ASC' => '1'));
183
 
184
  //Do a query to find the total number of rows then calculate the query limit
@@ -208,7 +211,7 @@ class sdm_List_Table extends WP_List_Table {
208
  //Prepare the array with the correct index names that the table is expecting.
209
  $data = array();
210
  foreach ($data_results as $data_result) {
211
- $data[] = array('row_id' => $data_result->id, 'ID' => $data_result->post_id, 'title' => $data_result->post_title, 'URL' => $data_result->file_url, 'visitor_ip' => $data_result->visitor_ip, 'date' => $data_result->date_time, 'visitor_country' => $data_result->visitor_country, 'visitor_name' => $data_result->visitor_name, 'user_agent' => $data_result->user_agent);
212
  }
213
 
214
  // Now we add our *sorted* data to the items property, where it can be used by the rest of the class.
35
  return $item[$column_name];
36
  case 'user_agent':
37
  return $item[$column_name];
38
+ case 'referrer_url':
39
+ return $item[$column_name];
40
  default:
41
  return print_r($item, true); //Show the whole array for troubleshooting purposes
42
  }
77
  'date' => __('Date', 'simple-download-monitor'),
78
  'visitor_country' => __('Country', 'simple-download-monitor'),
79
  'visitor_name' => __('Username', 'simple-download-monitor'),
80
+ 'user_agent' => __('User Agent', 'simple-download-monitor'),
81
+ 'referrer_url' => __('Referrer URL', 'simple-download-monitor')
82
  );
83
  return $columns;
84
  }
181
  $orderby_column = "date_time";
182
  $sort_order = "DESC";
183
  }
184
+ $orderby_column = sdm_sanitize_value_by_array($orderby_column, array('post_title'=>'1', 'file_url'=>'1', 'visitor_ip'=>'1', 'date_time'=>'1', 'visitor_country'=>'1', 'visitor_name'=>'1', 'user_agent'=>'1', 'referrer_url'=>'1'));
185
  $sort_order = sdm_sanitize_value_by_array($sort_order, array('DESC' => '1', 'ASC' => '1'));
186
 
187
  //Do a query to find the total number of rows then calculate the query limit
211
  //Prepare the array with the correct index names that the table is expecting.
212
  $data = array();
213
  foreach ($data_results as $data_result) {
214
+ $data[] = array('row_id' => $data_result->id, 'ID' => $data_result->post_id, 'title' => $data_result->post_title, 'URL' => $data_result->file_url, 'visitor_ip' => $data_result->visitor_ip, 'date' => $data_result->date_time, 'visitor_country' => $data_result->visitor_country, 'visitor_name' => $data_result->visitor_name, 'user_agent' => $data_result->user_agent, 'referrer_url' => $data_result->referrer_url);
215
  }
216
 
217
  // Now we add our *sorted* data to the items property, where it can be used by the rest of the class.
includes/sdm-utility-functions.php CHANGED
@@ -350,3 +350,113 @@ function sdm_redirect_to_url( $url, $delay = '0', $exit = '1' ) {
350
  exit;
351
  }
352
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  exit;
351
  }
352
  }
353
+
354
+ /*
355
+ * Utility function to insert a download record into the logs DB table. Used by addons sometimes.
356
+ */
357
+ function sdm_insert_download_to_logs_table( $download_id ){
358
+ global $wpdb;
359
+
360
+ if ( ! $download_id ) {
361
+ SDM_Debug::log('Error! insert to logs function called with incorrect download item id.', false);
362
+ return;
363
+ }
364
+
365
+ $main_option = get_option( 'sdm_downloads_options' );
366
+
367
+ $download_title = get_the_title( $download_id );
368
+ $download_link = get_post_meta( $download_id, 'sdm_upload', true );
369
+
370
+ $ipaddress = '';
371
+ //Check if do not capture IP is enabled.
372
+ if ( ! isset( $main_option['admin_do_not_capture_ip'] ) ) {
373
+ $ipaddress = sdm_get_ip_address();
374
+ }
375
+
376
+ $user_agent = '';
377
+ //Check if do not capture User Agent is enabled.
378
+ if ( ! isset( $main_option['admin_do_not_capture_user_agent'] ) ) {
379
+ //Get the user agent data. The get_browser() function doesn't work on many servers. So use the HTTP var.
380
+ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
381
+ $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
382
+ }
383
+ }
384
+
385
+ $referrer_url = '';
386
+ //Check if do not capture Referer URL is enabled.
387
+ if ( ! isset( $main_option['admin_do_not_capture_referrer_url'] ) ) {
388
+ //Get the user agent data. The get_browser() function doesn't work on many servers. So use the HTTP var.
389
+ if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
390
+ $referrer_url = sanitize_text_field( $_SERVER['HTTP_REFERER'] );
391
+ }
392
+ }
393
+
394
+ $date_time = current_time( 'mysql' );
395
+ $visitor_country = ! empty( $ipaddress ) ? sdm_ip_info( $ipaddress, 'country' ) : '';
396
+
397
+ $visitor_name = sdm_get_logged_in_user();
398
+ $visitor_name = ( $visitor_name === false ) ? __( 'Not Logged In', 'simple-download-monitor' ) : $visitor_name;
399
+
400
+ // Get option for global disabling of download logging
401
+ $no_logs = isset( $main_option['admin_no_logs'] );
402
+
403
+ // Get optoin for logging only unique IPs
404
+ $unique_ips = isset( $main_option['admin_log_unique'] );
405
+
406
+ // Get post meta for individual disabling of download logging
407
+ $get_meta = get_post_meta( $download_id, 'sdm_item_no_log', true );
408
+ $item_logging_checked = isset( $get_meta ) && $get_meta === 'on' ? 'on' : 'off';
409
+
410
+ $dl_logging_needed = true;
411
+
412
+ // Check if download logs have been disabled (globally or per download item)
413
+ if ( $no_logs === true || $item_logging_checked === 'on' ) {
414
+ $dl_logging_needed = false;
415
+ }
416
+
417
+ // Check if we are only logging unique ips
418
+ if ( $unique_ips === true ) {
419
+ $check_ip = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id="' . $download_id . '" AND visitor_ip = "' . $ipaddress . '"' );
420
+
421
+ //This IP is already logged for this download item. No need to log it again.
422
+ if ( $check_ip ) {
423
+ $dl_logging_needed = false;
424
+ }
425
+ }
426
+
427
+ // Check if "Do Not Count Downloads from Bots" setting is enabled
428
+ if ( isset( $main_option['admin_dont_log_bots'] ) ) {
429
+ //it is. Now let's check if visitor is a bot
430
+ if ( sdm_visitor_is_bot() ) {
431
+ //visitor is a bot. We neither log nor count this download
432
+ $dl_logging_needed = false;
433
+ }
434
+ }
435
+
436
+ if ( $dl_logging_needed ) {
437
+ // We need to log this download.
438
+ $table = $wpdb->prefix . 'sdm_downloads';
439
+ $data = array(
440
+ 'post_id' => $download_id,
441
+ 'post_title' => $download_title,
442
+ 'file_url' => $download_link,
443
+ 'visitor_ip' => $ipaddress,
444
+ 'date_time' => $date_time,
445
+ 'visitor_country' => $visitor_country,
446
+ 'visitor_name' => $visitor_name,
447
+ 'user_agent' => $user_agent,
448
+ 'referrer_url' => $referrer_url,
449
+ );
450
+
451
+ $data = array_filter( $data ); //Remove any null values.
452
+ $insert_table = $wpdb->insert( $table, $data );
453
+
454
+ if ( $insert_table ) {
455
+ //Download request was logged successfully
456
+ SDM_Debug::log('Download has been logged in the logs table for download ID: '. $download_id);
457
+ } else {
458
+ //Failed to log the download request
459
+ SDM_Debug::log('Error! Failed to log the download request in the database table.', false);
460
+ }
461
+ }
462
+ }
includes/templates/fancy0/sdm-fancy-0.php CHANGED
@@ -48,7 +48,7 @@ function sdm_generate_fancy0_latest_downloads_display_output( $get_posts, $args
48
  //
49
  // //TODO - when the CSS file is moved to the fancy1 folder, change it here
50
  // //$output .= '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL . '/includes/templates/fancy1/sdm-fancy-1-styles.css?ver=' . WP_SIMPLE_DL_MONITOR_VERSION . '" />';
51
- //
52
  // foreach ($get_posts as $item) {
53
  // $id = $item->ID; //Get the post ID
54
  // //Create a args array
@@ -65,7 +65,7 @@ function sdm_generate_fancy0_latest_downloads_display_output( $get_posts, $args
65
  //}
66
 
67
  /*
68
- * Generates the output of a single item using fancy2 sytle
69
  * $args array can have the following parameters
70
  * id, fancy, button_text, new_window
71
  */
@@ -80,7 +80,7 @@ function sdm_generate_fancy0_display_output( $args ) {
80
 
81
  // See if user color option is selected
82
  $main_opts = get_option( 'sdm_downloads_options' );
83
- $color_opt = $main_opts[ 'download_button_color' ];
84
  $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : __( 'green', 'simple-download-monitor' );
85
 
86
  $def_color = empty( $args[ 'color' ] ) ? $def_color : $args[ 'color' ];
@@ -110,7 +110,7 @@ function sdm_generate_fancy0_display_output( $args ) {
110
 
111
  // Check to see if the download link cpt is password protected
112
  $get_cpt_object = get_post( $id );
113
- $cpt_is_password = ! empty( $get_cpt_object->post_password ) ? 'yes' : 'no'; // yes = download is password protected;
114
 
115
 
116
  $main_advanced_opts = get_option( 'sdm_advanced_options' );
48
  //
49
  // //TODO - when the CSS file is moved to the fancy1 folder, change it here
50
  // //$output .= '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL . '/includes/templates/fancy1/sdm-fancy-1-styles.css?ver=' . WP_SIMPLE_DL_MONITOR_VERSION . '" />';
51
+ //
52
  // foreach ($get_posts as $item) {
53
  // $id = $item->ID; //Get the post ID
54
  // //Create a args array
65
  //}
66
 
67
  /*
68
+ * Generates the output of a single item using fancy2 sytle
69
  * $args array can have the following parameters
70
  * id, fancy, button_text, new_window
71
  */
80
 
81
  // See if user color option is selected
82
  $main_opts = get_option( 'sdm_downloads_options' );
83
+ $color_opt = isset( $main_opts[ 'download_button_color' ] ) ? $main_opts[ 'download_button_color' ] : null;
84
  $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : __( 'green', 'simple-download-monitor' );
85
 
86
  $def_color = empty( $args[ 'color' ] ) ? $def_color : $args[ 'color' ];
110
 
111
  // Check to see if the download link cpt is password protected
112
  $get_cpt_object = get_post( $id );
113
+ $cpt_is_password = ! empty( $get_cpt_object->post_password ) ? 'yes' : 'no'; // yes = download is password protected;
114
 
115
 
116
  $main_advanced_opts = get_option( 'sdm_advanced_options' );
languages/simple-download-monitor-es_ES.mo CHANGED
Binary file
languages/simple-download-monitor-es_ES.po CHANGED
@@ -2,14 +2,14 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: SDM 3.1\n"
4
  "POT-Creation-Date: 2019-10-25 18:15+1100\n"
5
- "PO-Revision-Date: 2019-10-26 09:00+1000\n"
6
  "Last-Translator: Manuel <mbruiz1967@mbrsolution.com>\n"
7
  "Language-Team: \n"
8
  "Language: es\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 2.2.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: .\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
@@ -864,13 +864,13 @@ msgstr ""
864
 
865
  #: main.php:547
866
  msgid ""
867
- "Read the full shortcode usage documentation <a href=\"https://www."
868
- "tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin\" target="
869
- "\"_blank\">here</a>."
870
  msgstr ""
871
- "Lee la documentación completa del uso del shortcode <a href=\"https://www."
872
- "tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin\" target="
873
- "\"_blank\">aquí</a>."
874
 
875
  #: main.php:684
876
  msgid "General Options"
2
  msgstr ""
3
  "Project-Id-Version: SDM 3.1\n"
4
  "POT-Creation-Date: 2019-10-25 18:15+1100\n"
5
+ "PO-Revision-Date: 2020-11-11 16:19+1000\n"
6
  "Last-Translator: Manuel <mbruiz1967@mbrsolution.com>\n"
7
  "Language-Team: \n"
8
  "Language: es\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.4.2\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: .\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
864
 
865
  #: main.php:547
866
  msgid ""
867
+ "Read the full shortcode usage documentation <a href=\"https://simple-"
868
+ "download-monitor.com/miscellaneous-shortcodes-and-shortcode-parameters/\" "
869
+ "target=\"_blank\">here</a>."
870
  msgstr ""
871
+ "Lee la documentación completa del uso del shortcode <a href=\"https://simple-"
872
+ "download-monitor.com/miscellaneous-shortcodes-and-shortcode-parameters/\" "
873
+ "target=\"_blank\">aquí</a>."
874
 
875
  #: main.php:684
876
  msgid "General Options"
main.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://simple-download-monitor.com/
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
- * Version: 3.8.7
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- define( 'WP_SIMPLE_DL_MONITOR_VERSION', '3.8.7' );
18
  define( 'WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname( plugin_basename( __FILE__ ) ) );
19
  define( 'WP_SIMPLE_DL_MONITOR_URL', plugins_url( '', __FILE__ ) );
20
  define( 'WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path( __FILE__ ) );
@@ -22,7 +22,7 @@ define( 'WP_SIMPLE_DL_MONITOR_SITE_HOME_URL', home_url() );
22
  define( 'WP_SDM_LOG_FILE', WP_SIMPLE_DL_MONITOR_PATH . 'sdm-debug-log.txt' );
23
 
24
  global $sdm_db_version;
25
- $sdm_db_version = '1.3';
26
 
27
  //File includes
28
  require_once 'includes/sdm-debug.php';
@@ -62,6 +62,7 @@ function sdm_install_db_table() {
62
  visitor_country mediumtext NOT NULL,
63
  visitor_name mediumtext NOT NULL,
64
  user_agent mediumtext NOT NULL,
 
65
  UNIQUE KEY id (id)
66
  );';
67
 
@@ -712,10 +713,10 @@ class simpleDownloadManager {
712
  add_settings_field( 'general_login_page_url', __( 'Login Page URL', 'simple-download-monitor' ), array( $this, 'general_login_page_url_cb' ), 'user_login_options_section', 'user_login_options' );
713
  add_settings_field( 'redirect_user_back_to_download_page', __( 'Redirect Users to Download Page', 'simple-download-monitor' ), array( $this, 'redirect_user_back_to_download_page_cb' ), 'user_login_options_section', 'user_login_options' );
714
 
715
- add_settings_field( 'admin_tinymce_button', __( 'Remove Tinymce Button', 'simple-download-monitor' ), array( $this, 'admin_tinymce_button_cb' ), 'admin_options_section', 'admin_options' );
716
  add_settings_field( 'admin_log_unique', __( 'Log Unique IP', 'simple-download-monitor' ), array( $this, 'admin_log_unique' ), 'admin_options_section', 'admin_options' );
717
  add_settings_field( 'admin_do_not_capture_ip', __( 'Do Not Capture IP Address', 'simple-download-monitor' ), array( $this, 'admin_do_not_capture_ip' ), 'admin_options_section', 'admin_options' );
718
  add_settings_field( 'admin_do_not_capture_user_agent', __( 'Do Not Capture User Agent', 'simple-download-monitor' ), array( $this, 'admin_do_not_capture_user_agent' ), 'admin_options_section', 'admin_options' );
 
719
  add_settings_field( 'admin_dont_log_bots', __( 'Do Not Count Downloads from Bots', 'simple-download-monitor' ), array( $this, 'admin_dont_log_bots' ), 'admin_options_section', 'admin_options' );
720
  add_settings_field( 'admin_no_logs', __( 'Disable Download Logs', 'simple-download-monitor' ), array( $this, 'admin_no_logs_cb' ), 'admin_options_section', 'admin_options' );
721
 
@@ -854,12 +855,6 @@ class simpleDownloadManager {
854
  echo '<p class="description">' . __( '(Optional) Specify a login page URL where users can login. This is useful if you only allow logged in users to be able to download. This link will be added to the message that is shown to anonymous users.', 'simple-download-monitor' ) . '</p>';
855
  }
856
 
857
- public function admin_tinymce_button_cb() {
858
- $main_opts = get_option( 'sdm_downloads_options' );
859
- echo '<input name="sdm_downloads_options[admin_tinymce_button]" id="admin_tinymce_button" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked( 1, isset( $main_opts['admin_tinymce_button'] ), false ) . ' /> ';
860
- echo '<label for="admin_tinymce_button">' . __( 'Removes the SDM Downloads button from the WP content editor.', 'simple-download-monitor' ) . '</label>';
861
- }
862
-
863
  public function admin_log_unique() {
864
  $main_opts = get_option( 'sdm_downloads_options' );
865
  echo '<input name="sdm_downloads_options[admin_log_unique]" id="admin_log_unique" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked( 1, isset( $main_opts['admin_log_unique'] ), false ) . ' /> ';
@@ -878,6 +873,12 @@ class simpleDownloadManager {
878
  echo '<label for="admin_do_not_capture_user_agent">' . __( 'Use this if you do not want to capture the User Agent value of the browser when they download an item.', 'simple-download-monitor' ) . '</label>';
879
  }
880
 
 
 
 
 
 
 
881
  public function admin_dont_log_bots() {
882
  $main_opts = get_option( 'sdm_downloads_options' );
883
  echo '<input name="sdm_downloads_options[admin_dont_log_bots]" id="admin_dont_log_bots" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked( 1, isset( $main_opts['admin_dont_log_bots'] ), false ) . ' /> ';
@@ -1209,7 +1210,6 @@ function sdm_downloads_sortable( $cols ) {
1209
 
1210
  $cols['sdm_downloads_id'] = 'sdm_downloads_id';
1211
  $cols['sdm_downloads_file'] = 'sdm_downloads_file';
1212
- $cols['sdm_downloads_count'] = 'sdm_downloads_count';
1213
  $cols['taxonomy-sdm_categories'] = 'taxonomy-sdm_categories';
1214
  $cols['taxonomy-sdm_tags'] = 'taxonomy-sdm_tags';
1215
  return $cols;
@@ -1238,59 +1238,3 @@ function sdm_downloads_columns_content( $column_name, $post_ID ) {
1238
  echo '<p class="sdm_downloads_count">' . $wpdb->num_rows . '</p>';
1239
  }
1240
  }
1241
-
1242
- /*
1243
- * * Register Tinymce Button
1244
- */
1245
-
1246
- // First check if option is checked to disable tinymce button
1247
- $main_option = get_option( 'sdm_downloads_options' );
1248
- $tiny_button_option = isset( $main_option['admin_tinymce_button'] );
1249
- if ( $tiny_button_option != true && is_admin() ) {
1250
-
1251
- // Okay.. we're good. Add the button.
1252
- add_action( 'init', 'sdm_downloads_tinymce_button' );
1253
-
1254
- foreach ( array( 'post.php', 'post-new.php' ) as $hook ) {
1255
- add_action( "admin_head-$hook", 'sdm_downloads_tinymce_admin_head' );
1256
- }
1257
-
1258
- function sdm_downloads_tinymce_button() {
1259
-
1260
- add_filter( 'mce_external_plugins', 'sdm_downloads_add_button' );
1261
- add_filter( 'mce_buttons', 'sdm_downloads_register_button' );
1262
- }
1263
-
1264
- function sdm_downloads_add_button( $plugin_array ) {
1265
-
1266
- $plugin_array['sdm_downloads'] = WP_SIMPLE_DL_MONITOR_URL . '/tinymce/sdm_editor_plugin.js';
1267
- return $plugin_array;
1268
- }
1269
-
1270
- function sdm_downloads_register_button( $buttons ) {
1271
-
1272
- $buttons[] = 'sdm_downloads';
1273
- return $buttons;
1274
- }
1275
-
1276
- function sdm_downloads_tinymce_admin_head() {
1277
- global $post;
1278
- //Pass some JS variables
1279
- ?>
1280
- <script type="text/javascript">
1281
- var sdm_del_thumb_postid = '<?php echo $post->ID; ?>';
1282
- var sdm_admin_ajax_url = {sdm_admin_ajax_url: '<?php echo admin_url( 'admin-ajax.php?action=ajax' ); ?>'};
1283
- var sdm_plugin_url = '<?php echo plugins_url(); ?>';
1284
- var tinymce_langs = {
1285
- select_download_item: '<?php _e( 'Please select a Download Item:', 'simple-download-monitor' ); ?>',
1286
- download_title: '<?php esc_js( __( 'Download Title', 'simple-download-monitor' ) ); ?>',
1287
- include_fancy: '<?php _e( 'Include Fancy Box', 'simple-download-monitor' ); ?>',
1288
- open_new_window: '<?php _e( 'Open New Window', 'simple-download-monitor' ); ?>',
1289
- button_color: '<?php _e( 'Button Color', 'simple-download-monitor' ); ?>',
1290
- insert_shortcode: '<?php _e( 'Insert SDM Shortcode', 'simple-download-monitor' ); ?>'
1291
- };
1292
- var sdm_button_colors = <?php echo wp_json_encode( sdm_get_download_button_colors() ); ?>;
1293
- </script>
1294
- <?php
1295
- }
1296
- }
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://simple-download-monitor.com/
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
+ * Version: 3.9.2
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
14
  exit;
15
  }
16
 
17
+ define( 'WP_SIMPLE_DL_MONITOR_VERSION', '3.9.2' );
18
  define( 'WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname( plugin_basename( __FILE__ ) ) );
19
  define( 'WP_SIMPLE_DL_MONITOR_URL', plugins_url( '', __FILE__ ) );
20
  define( 'WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path( __FILE__ ) );
22
  define( 'WP_SDM_LOG_FILE', WP_SIMPLE_DL_MONITOR_PATH . 'sdm-debug-log.txt' );
23
 
24
  global $sdm_db_version;
25
+ $sdm_db_version = '1.4';
26
 
27
  //File includes
28
  require_once 'includes/sdm-debug.php';
62
  visitor_country mediumtext NOT NULL,
63
  visitor_name mediumtext NOT NULL,
64
  user_agent mediumtext NOT NULL,
65
+ referrer_url mediumtext NOT NULL,
66
  UNIQUE KEY id (id)
67
  );';
68
 
713
  add_settings_field( 'general_login_page_url', __( 'Login Page URL', 'simple-download-monitor' ), array( $this, 'general_login_page_url_cb' ), 'user_login_options_section', 'user_login_options' );
714
  add_settings_field( 'redirect_user_back_to_download_page', __( 'Redirect Users to Download Page', 'simple-download-monitor' ), array( $this, 'redirect_user_back_to_download_page_cb' ), 'user_login_options_section', 'user_login_options' );
715
 
 
716
  add_settings_field( 'admin_log_unique', __( 'Log Unique IP', 'simple-download-monitor' ), array( $this, 'admin_log_unique' ), 'admin_options_section', 'admin_options' );
717
  add_settings_field( 'admin_do_not_capture_ip', __( 'Do Not Capture IP Address', 'simple-download-monitor' ), array( $this, 'admin_do_not_capture_ip' ), 'admin_options_section', 'admin_options' );
718
  add_settings_field( 'admin_do_not_capture_user_agent', __( 'Do Not Capture User Agent', 'simple-download-monitor' ), array( $this, 'admin_do_not_capture_user_agent' ), 'admin_options_section', 'admin_options' );
719
+ add_settings_field( 'admin_do_not_capture_referrer_url', __( 'Do Not Capture Referrer URL', 'simple-download-monitor' ), array( $this, 'admin_do_not_capture_referrer_url' ), 'admin_options_section', 'admin_options' );
720
  add_settings_field( 'admin_dont_log_bots', __( 'Do Not Count Downloads from Bots', 'simple-download-monitor' ), array( $this, 'admin_dont_log_bots' ), 'admin_options_section', 'admin_options' );
721
  add_settings_field( 'admin_no_logs', __( 'Disable Download Logs', 'simple-download-monitor' ), array( $this, 'admin_no_logs_cb' ), 'admin_options_section', 'admin_options' );
722
 
855
  echo '<p class="description">' . __( '(Optional) Specify a login page URL where users can login. This is useful if you only allow logged in users to be able to download. This link will be added to the message that is shown to anonymous users.', 'simple-download-monitor' ) . '</p>';
856
  }
857
 
 
 
 
 
 
 
858
  public function admin_log_unique() {
859
  $main_opts = get_option( 'sdm_downloads_options' );
860
  echo '<input name="sdm_downloads_options[admin_log_unique]" id="admin_log_unique" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked( 1, isset( $main_opts['admin_log_unique'] ), false ) . ' /> ';
873
  echo '<label for="admin_do_not_capture_user_agent">' . __( 'Use this if you do not want to capture the User Agent value of the browser when they download an item.', 'simple-download-monitor' ) . '</label>';
874
  }
875
 
876
+ public function admin_do_not_capture_referrer_url() {
877
+ $main_opts = get_option( 'sdm_downloads_options' );
878
+ echo '<input name="sdm_downloads_options[admin_do_not_capture_referrer_url]" id="admin_do_not_capture_referrer_url" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked( 1, isset( $main_opts['admin_do_not_capture_referrer_url'] ), false ) . ' /> ';
879
+ echo '<label for="admin_do_not_capture_referrer_url">' . __( 'Use this if you do not want to capture the Referrer URL value when they download an item. The plugin only tries to capture this value if it is available.', 'simple-download-monitor' ) . '</label>';
880
+ }
881
+
882
  public function admin_dont_log_bots() {
883
  $main_opts = get_option( 'sdm_downloads_options' );
884
  echo '<input name="sdm_downloads_options[admin_dont_log_bots]" id="admin_dont_log_bots" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked( 1, isset( $main_opts['admin_dont_log_bots'] ), false ) . ' /> ';
1210
 
1211
  $cols['sdm_downloads_id'] = 'sdm_downloads_id';
1212
  $cols['sdm_downloads_file'] = 'sdm_downloads_file';
 
1213
  $cols['taxonomy-sdm_categories'] = 'taxonomy-sdm_categories';
1214
  $cols['taxonomy-sdm_tags'] = 'taxonomy-sdm_tags';
1215
  return $cols;
1238
  echo '<p class="sdm_downloads_count">' . $wpdb->num_rows . '</p>';
1239
  }
1240
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: Tips and Tricks HQ, Ruhul Amin, josh401, mbrsolution, alexanderfoxc
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: 5.5
7
- Stable tag: 3.8.7
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -42,6 +42,7 @@ https://www.youtube.com/watch?v=SjVaanbulRU
42
  * Track date and time of each file downloads.
43
  * Track the usernames of the users downloading the files.
44
  * Track the User Agent of the visitors downloading the files.
 
45
  * Option to setup secure downloads for your files (the URL of the downloadable file will be hidden).
46
  * Option to upload a thumbnail image for each of your downloadable files.
47
  * Option to use a nice looking template to show your download now buttons.
@@ -188,6 +189,29 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
188
 
189
  == Changelog ==
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  = 3.8.7 =
192
  - Added a new filter for the visitor name tracking.
193
  - Added two new bot strings that will be filtered out from the log (when using the "Do Not Count Downloads from Bots" option).
2
  Contributors: Tips and Tricks HQ, Ruhul Amin, josh401, mbrsolution, alexanderfoxc
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: 5.0
6
+ Tested up to: 5.8
7
+ Stable tag: 3.9.2
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
42
  * Track date and time of each file downloads.
43
  * Track the usernames of the users downloading the files.
44
  * Track the User Agent of the visitors downloading the files.
45
+ * Track the Referrer URL to see which page the downloads are coming from.
46
  * Option to setup secure downloads for your files (the URL of the downloadable file will be hidden).
47
  * Option to upload a thumbnail image for each of your downloadable files.
48
  * Option to use a nice looking template to show your download now buttons.
189
 
190
  == Changelog ==
191
 
192
+ = 3.9.2 =
193
+ - The sorting option on the "Downloads" column has been removed.
194
+ - Added a new filter that can be used to override the "slug" of the download single post. The name of the filter hook is "sdm_downloads_post_type_before_register".
195
+ - Addressed an issue whereby the single post of the download can show a warning if the download button color is not set in the settings.
196
+ - WordPress 5.8 compatibility.
197
+
198
+ = 3.9.1 =
199
+ - Replaced the deprecated "whitelist_options" filter (using the "allowed_options" filter instead).
200
+
201
+ = 3.9.0 =
202
+ - Added a new utility function to record downloads in the logs table.
203
+ - Updated the Spanish language translation file.
204
+ - WordPress 5.7 compatibility.
205
+
206
+ = 3.8.9 =
207
+ - WordPress 5.5 compatiblity.
208
+ - Added sanitization to the "User Agent" field.
209
+ - Removed the "TinyMCE" button option. It is no longer needed in current WordPress version.
210
+
211
+ = 3.8.8 =
212
+ - Added a new option to capture the Referrer URL of the downloads in the "Logs" menu.
213
+ - The "Do Not Capture Referrer URL" option can be used to disable the "Referrer URL" capture.
214
+
215
  = 3.8.7 =
216
  - Added a new filter for the visitor name tracking.
217
  - Added two new bot strings that will be filtered out from the log (when using the "Do Not Count Downloads from Bots" option).
sdm-post-type-and-taxonomy.php CHANGED
@@ -36,6 +36,10 @@ function sdm_register_post_type() {
36
  'menu_icon' => 'dashicons-download',
37
  'supports' => array( 'title' )
38
  );
 
 
 
 
39
  register_post_type( 'sdm_downloads', $args );
40
  }
41
 
36
  'menu_icon' => 'dashicons-download',
37
  'supports' => array( 'title' )
38
  );
39
+
40
+ //Trigger filter before registering the post type. Can be used to override the slug of the downloads
41
+ $args = apply_filters( 'sdm_downloads_post_type_before_register', $args );
42
+
43
  register_post_type( 'sdm_downloads', $args );
44
  }
45
 
sdm-post-type-content-handler.php CHANGED
@@ -52,7 +52,7 @@ function filter_sdm_post_type_content( $content ) {
52
 
53
  // See if user color option is selected
54
  $main_opts = get_option( 'sdm_downloads_options' );
55
- $color_opt = $main_opts[ 'download_button_color' ];
56
  $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : __( 'green', 'simple-download-monitor' );
57
 
58
  //Download counter
52
 
53
  // See if user color option is selected
54
  $main_opts = get_option( 'sdm_downloads_options' );
55
+ $color_opt = isset( $main_opts[ 'download_button_color' ] ) ? $main_opts[ 'download_button_color' ] : null;
56
  $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : __( 'green', 'simple-download-monitor' );
57
 
58
  //Download counter
sdm-shortcodes.php CHANGED
@@ -295,7 +295,7 @@ function sdm_handle_category_shortcode( $args ) {
295
 
296
  // See if user color option is selected
297
  $main_opts = get_option( 'sdm_downloads_options' );
298
- $color_opt = $main_opts['download_button_color'];
299
  $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : 'green';
300
 
301
  if ( $fancy == '0' ) {
295
 
296
  // See if user color option is selected
297
  $main_opts = get_option( 'sdm_downloads_options' );
298
+ $color_opt = isset( $main_opts[ 'download_button_color' ] ) ? $main_opts[ 'download_button_color' ] : null;
299
  $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : 'green';
300
 
301
  if ( $fancy == '0' ) {
tinymce/index.html DELETED
File without changes
tinymce/sdm_editor_plugin.js DELETED
@@ -1,164 +0,0 @@
1
- (function() {
2
- tinymce.create('tinymce.plugins.sdmDownloads', {
3
- /**
4
- * Initializes the plugin, this will be executed after the plugin has been created.
5
- * This call is done before the editor instance has finished it's initialization so use the onInit event
6
- * of the editor instance to intercept that event.
7
- *
8
- * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
9
- * @param {string} url Absolute URL to where the plugin is located.
10
- */
11
- init : function(ed, url) {
12
- ed.addButton('sdm_downloads', {
13
- icon: 'sdm-download',
14
- tooltip : 'SDM Downloads Button',
15
- cmd : 'sdm_downloads'
16
- });
17
-
18
- ed.addCommand('sdm_downloads', function() {
19
- /*
20
- ed.windowManager.open({
21
- file : url + '/sdm_downloads.php',
22
- width : 400,
23
- height : 400,
24
- inline : 1
25
- });
26
- */
27
- var width = jQuery(window).width(),
28
- H = jQuery(window).height(),
29
- W = ( 720 < width ) ? 720 : width;
30
- W = W - 80;
31
- H = H - 84;
32
- tb_show( 'SDM Downloads Insert Shortcode', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=highlight-form' );
33
- });
34
- },
35
-
36
- /**
37
- * Creates control instances based in the incomming name. This method is normally not
38
- * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
39
- * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
40
- * method can be used to create those.
41
- *
42
- * @param {String} n Name of the control to create.
43
- * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
44
- * @return {tinymce.ui.Control} New control instance or null if no control was created.
45
- */
46
- createControl : function(n, cm) {
47
- return null;
48
- },
49
-
50
- /**
51
- * Returns information about the plugin as a name/value array.
52
- * The current keys are longname, author, authorurl, infourl and version.
53
- *
54
- * @return {Object} Name/value array containing information about the plugin.
55
- */
56
- getInfo : function() {
57
- return {
58
- longname : 'Simple Download Monitor Button',
59
- author : 'Tips and Tricks HQ',
60
- authorurl : 'http://www.tipsandtricks-hq.com/development-center',
61
- infourl : 'http://www.tipsandtricks-hq.com/development-center',
62
- version : "1.0"
63
- };
64
- }
65
- });
66
-
67
- // Register plugin
68
- tinymce.PluginManager.add( 'sdm_downloads', tinymce.plugins.sdmDownloads );
69
- })();
70
-
71
- jQuery(function(){
72
-
73
-
74
- // Run an ajax call to the main.php to get all current CPT items
75
- jQuery.post(
76
- sdm_admin_ajax_url.sdm_admin_ajax_url,
77
- {
78
- action: 'sdm_tiny_get_post_ids'
79
- },
80
- function(response) {
81
- if(response) { // ** If response was successful
82
-
83
- //console.log(response.test);
84
-
85
- jQuery.each(response.test, function (index, value) {
86
- jQuery('#sdm_select').append('<option value="'+value.post_id+'">'+value.post_title+'</option>'); // Populate dropdown list with CPT item titles
87
- });
88
- }
89
- else { // ** Else response was unsuccessful
90
- alert('SDM Downloads AJAX Error! Please deactivate the plugin to permanently dismiss this alert.');
91
- }
92
- }
93
- );
94
-
95
- var button_color_options = '';
96
- for ( var color in sdm_button_colors ) {
97
- button_color_options += '<option value="' + color + '">' + sdm_button_colors[color] + '</option>';
98
- }
99
-
100
- // Instantiate a form in the wp thickbox window (hidden at start)
101
- var form = jQuery('<div id="highlight-form"><div id="sdm_tinymce_postids" style="display:none;"></div>\
102
- <div id="sdm_select_title" style="margin-top:20px;">'+tinymce_langs.select_download_item+'</div>\
103
- <table id="highlight-table" class="form-table" style="text-align: left">\
104
- <tr>\
105
- <th><label class="title" for="sdm_select">'+tinymce_langs.download_title+'</label></th>\
106
- <td><select name="sdm_select" id="sdm_select"></select></td>\
107
- </tr>\
108
- <tr>\
109
- <th><label class="sdm_fancy" for="sdm_fancy_cb">'+tinymce_langs.include_fancy+'</th>\
110
- <td><input type="checkbox" name="sdm_fancy_cb" id="sdm_fancy_cb" /></td>\
111
- </tr>\
112
- <tr>\
113
- <th><label class="color" for="sdm_button_color">'+tinymce_langs.button_color+'</label></th>\
114
- <td><select name="sdm_button_color" id="sdm_button_color">' + button_color_options + '</select></td>\
115
- </tr>\
116
- <tr>\
117
- <th><label class="sdm_new_window" for="sdm_open_new_window_cb">'+tinymce_langs.open_new_window+'</th>\
118
- <td><input type="checkbox" name="sdm_open_new_window_cb" id="sdm_open_new_window_cb" /></td>\
119
- </tr>\
120
- </table>\
121
- <p class="submit">\
122
- <input type="button" id="sdm-tinymce-submit" class="button-primary" value="'+tinymce_langs.insert_shortcode+'" name="submit" style=""/>\
123
- </p>\
124
- </div>');
125
-
126
- var table = form.find('table');
127
- form.appendTo('body').hide(); // Hide form
128
-
129
- // handles the click event of the submit button
130
- form.find('#sdm-tinymce-submit').click(function(){
131
-
132
- var fancy_cb = jQuery('#sdm_fancy_cb').is(':checked');
133
- var new_window_cb = jQuery('#sdm_open_new_window_cb').is(':checked');
134
- var post_id = jQuery('#sdm_select').find(":selected").val(); // Get selected CPT item title value (item id)
135
- var color = jQuery('#sdm_button_color').find(":selected").val(); // Get selected CPT item title value (item id)
136
-
137
- //Build the shortcode with parameters according to the options
138
- var shortcode = '[sdm_download id="'+post_id+'"';
139
-
140
- //Add the fancy parameter to the shortcode (if needed
141
- if ( fancy_cb ) {
142
- shortcode = shortcode + ' fancy="1"';
143
- } else {
144
- shortcode = shortcode + ' fancy="0"';
145
- }
146
-
147
- //Add the new_window parameter to the shortcode (if needed)
148
- if ( new_window_cb ) {
149
- shortcode = shortcode + ' new_window="1"';
150
- }
151
-
152
- if ( color ) {
153
- shortcode += ' color="' + color + '"';
154
- }
155
-
156
- shortcode = shortcode + ']';//End the shortcode
157
-
158
- // inserts the shortcode into the active editor
159
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode); // Send processed shortcode to editor
160
-
161
- // close WP thickbox window
162
- tb_remove();
163
- });
164
- });