Simple Download Monitor - Version 3.4.0

Version Description

  • Added a new hook to allow plugin extensions to hook into download request handling.
  • Added empty index file to the plugin folder.
  • Fixed potential XSS vulnerability. Thanks to Neven Biruski (Defensecode) for pointing it out.
  • Minor typo fix.
Download this release

Release Info

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

Code changes from version 3.3.4 to 3.4.0

css/index.html ADDED
File without changes
css/sdm_admin_styles.css CHANGED
@@ -19,4 +19,13 @@ body.loading {
19
  }
20
  body.loading .modal {
21
  display: block;
22
- }
 
 
 
 
 
 
 
 
 
19
  }
20
  body.loading .modal {
21
  display: block;
22
+ }
23
+
24
+
25
+ /* Download button TinyMCE icon */
26
+ i.mce-i-sdm-download::before {
27
+ content: "";
28
+
29
+ font: 400 20px/1 dashicons;
30
+ vertical-align: top;
31
+ }
css/sdm_wp_styles.css CHANGED
@@ -40,6 +40,11 @@
40
  .sdm_download_link{
41
  display: block;
42
  }
 
 
 
 
 
43
  .sdm_download_button{
44
  display: inline-block;
45
  }
@@ -116,7 +121,7 @@
116
  background: -webkit-gradient(linear, left top, left bottom, from(#cae285), to(#9fcb57)); /* WebKit */
117
  background: -moz-linear-gradient(top, #cae285, #9fcb57);
118
  border-color: #adc671 #98b65b #87aa4a;
119
- color: #5d7731;
120
  text-shadow: 0 1px 0 #cfe5a4;
121
  -webkit-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #d7e9a4;
122
  -moz-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #d7e9a4;
@@ -140,7 +145,7 @@
140
  background: -webkit-gradient(linear, left top, left bottom, from(#abe4f8), to(#6fcef3)); /* WebKit */
141
  background: -moz-linear-gradient(top, #abe4f8, #6fcef3);
142
  border-color: #8dc5da #76b7cf #63abc7;
143
- color: #42788e;
144
  text-shadow: 0 1px 0 #b6e6f9;
145
  -webkit-box-shadow: 0 1px 1px #d6d6d6, inset 0 1px 0 #c0ebfa;
146
  -moz-box-shadow: 0 1px 1px #d6d6d6, inset 0 1px 0 #c0ebfa;
@@ -161,7 +166,7 @@
161
  background: -webkit-gradient(linear, left top, left bottom, from(#e8c4e4), to(#d494ce)); /* WebKit */
162
  background: -moz-linear-gradient(top, #e8c4e4, #d494ce);
163
  border-color: #bc9db9 #ad89aa #a1799d;
164
- color: #7b5777;
165
  text-shadow: 0 1px 0 #eacae6;
166
  -webkit-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #eed3eb;
167
  -moz-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #eed3eb;
@@ -185,7 +190,7 @@
185
  background: -webkit-gradient(linear, left top, left bottom, from(#b7f2f4), to(#7ce7ea)); /* WebKit */
186
  background: -moz-linear-gradient(top, #b7f2f4, #7ce7ea);
187
  border-color: #90c6c8 #78bdc0 #65b6ba;
188
- color: #437b7d;
189
  text-shadow: 0 1px 0 #bef3f5;
190
  -webkit-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #c9f5f7;
191
  -moz-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #c9f5f7;
@@ -206,7 +211,7 @@
206
  background: -webkit-gradient(linear, left top, left bottom, from(#becbd6), to(#88a1b4)); /* WebKit */
207
  background: -moz-linear-gradient(top, #becbd6, #88a1b4);
208
  border-color: #a2afb8 #8696a1 #6f818f;
209
- color: #515f6a;
210
  text-shadow: 0 1px 0 #c4d0d9;
211
  -webkit-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #ced8e0;
212
  -moz-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #ced8e0;
@@ -227,7 +232,7 @@
227
  background: -webkit-gradient(linear, left top, left bottom, from(#5e5e5e), to(#434343)); /* WebKit */
228
  background: -moz-linear-gradient(top, #5e5e5e, #434343);
229
  border-color: #4c4c4c #313131 #1f1f1f;
230
- color: #fff;
231
  text-shadow: 0 1px 0 #2e2e2e;
232
  -webkit-box-shadow: 0 1px 1px #afafaf, inset 0 1px 0 #868686;
233
  -moz-box-shadow: 0 1px 1px #afafaf, inset 0 1px 0 #868686;
@@ -247,7 +252,7 @@
247
  background: -webkit-gradient(linear, left top, left bottom, from(#cacaca), to(#aeaeae)); /* WebKit */
248
  background: -moz-linear-gradient(top, #cacaca, #aeaeae);
249
  border-color: #b5b5b5 #a1a1a1 #8f8f8f;
250
- color: #555;
251
  text-shadow: 0 1px 0 #d4d4d4;
252
  -webkit-box-shadow: 0 1px 1px #c9c9c9, inset 0 1px 0 #d7d7d7;
253
  -moz-box-shadow: 0 1px 1px #c9c9c9, inset 0 1px 0 #d7d7d7;
@@ -271,7 +276,7 @@
271
  background: -webkit-gradient(linear, left top, left bottom, from(#f78297), to(#f56778)); /* WebKit */
272
  background: -moz-linear-gradient(top, #f78297, #f56778);
273
  border-color: #df6f8b #da5f75 #d55061;
274
- color: #913944;
275
  text-shadow: 0 1px 0 #f89ca9;
276
  -webkit-box-shadow: 0 1px 1px #c1c1c1, inset 0 1px 0 #f9a1b1;
277
  -moz-box-shadow: 0 1px 1px #c1c1c1, inset 0 1px 0 #f9a1b1;
@@ -295,7 +300,7 @@
295
  background: -webkit-gradient(linear, left top, left bottom, from(#feda71), to(#febb4a)); /* WebKit */
296
  background: -moz-linear-gradient(top, #feda71, #febb4a);
297
  border-color: #f5b74e #e5a73e #d6982f;
298
- color: #996633;
299
  text-shadow: 0 1px 0 #fedd9b;
300
  -webkit-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #fee395;
301
  -moz-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #fee395;
@@ -318,7 +323,7 @@
318
  background: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f0f0f0)); /* WebKit */
319
  background: -moz-linear-gradient(top, #f9f9f9, #f0f0f0);
320
  border-color: #dedede #d8d8d8 #d3d3d3;
321
- color: #555;
322
  text-shadow: 0 1px 0 #fff;
323
  -webkit-box-shadow: 0 1px 1px #eaeaea, inset 0 1px 0 #fbfbfb;
324
  -moz-box-shadow: 0 1px 1px #eaeaea, inset 0 1px 0 #fbfbfb;
40
  .sdm_download_link{
41
  display: block;
42
  }
43
+ .sdm_download_link:after {
44
+ content: "";
45
+ display: table;
46
+ clear: both;
47
+ }
48
  .sdm_download_button{
49
  display: inline-block;
50
  }
121
  background: -webkit-gradient(linear, left top, left bottom, from(#cae285), to(#9fcb57)); /* WebKit */
122
  background: -moz-linear-gradient(top, #cae285, #9fcb57);
123
  border-color: #adc671 #98b65b #87aa4a;
124
+ color: #2F4014 !important;
125
  text-shadow: 0 1px 0 #cfe5a4;
126
  -webkit-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #d7e9a4;
127
  -moz-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #d7e9a4;
145
  background: -webkit-gradient(linear, left top, left bottom, from(#abe4f8), to(#6fcef3)); /* WebKit */
146
  background: -moz-linear-gradient(top, #abe4f8, #6fcef3);
147
  border-color: #8dc5da #76b7cf #63abc7;
148
+ color: #1E4657 !important;
149
  text-shadow: 0 1px 0 #b6e6f9;
150
  -webkit-box-shadow: 0 1px 1px #d6d6d6, inset 0 1px 0 #c0ebfa;
151
  -moz-box-shadow: 0 1px 1px #d6d6d6, inset 0 1px 0 #c0ebfa;
166
  background: -webkit-gradient(linear, left top, left bottom, from(#e8c4e4), to(#d494ce)); /* WebKit */
167
  background: -moz-linear-gradient(top, #e8c4e4, #d494ce);
168
  border-color: #bc9db9 #ad89aa #a1799d;
169
+ color: #4D334A !important;
170
  text-shadow: 0 1px 0 #eacae6;
171
  -webkit-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #eed3eb;
172
  -moz-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #eed3eb;
190
  background: -webkit-gradient(linear, left top, left bottom, from(#b7f2f4), to(#7ce7ea)); /* WebKit */
191
  background: -moz-linear-gradient(top, #b7f2f4, #7ce7ea);
192
  border-color: #90c6c8 #78bdc0 #65b6ba;
193
+ color: #2B5052 !important;
194
  text-shadow: 0 1px 0 #bef3f5;
195
  -webkit-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #c9f5f7;
196
  -moz-box-shadow: 0 1px 1px #d5d5d5, inset 0 1px 0 #c9f5f7;
211
  background: -webkit-gradient(linear, left top, left bottom, from(#becbd6), to(#88a1b4)); /* WebKit */
212
  background: -moz-linear-gradient(top, #becbd6, #88a1b4);
213
  border-color: #a2afb8 #8696a1 #6f818f;
214
+ color: #26313B !important;
215
  text-shadow: 0 1px 0 #c4d0d9;
216
  -webkit-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #ced8e0;
217
  -moz-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #ced8e0;
232
  background: -webkit-gradient(linear, left top, left bottom, from(#5e5e5e), to(#434343)); /* WebKit */
233
  background: -moz-linear-gradient(top, #5e5e5e, #434343);
234
  border-color: #4c4c4c #313131 #1f1f1f;
235
+ color: #FFFFFF !important;
236
  text-shadow: 0 1px 0 #2e2e2e;
237
  -webkit-box-shadow: 0 1px 1px #afafaf, inset 0 1px 0 #868686;
238
  -moz-box-shadow: 0 1px 1px #afafaf, inset 0 1px 0 #868686;
252
  background: -webkit-gradient(linear, left top, left bottom, from(#cacaca), to(#aeaeae)); /* WebKit */
253
  background: -moz-linear-gradient(top, #cacaca, #aeaeae);
254
  border-color: #b5b5b5 #a1a1a1 #8f8f8f;
255
+ color: #555555 !important;
256
  text-shadow: 0 1px 0 #d4d4d4;
257
  -webkit-box-shadow: 0 1px 1px #c9c9c9, inset 0 1px 0 #d7d7d7;
258
  -moz-box-shadow: 0 1px 1px #c9c9c9, inset 0 1px 0 #d7d7d7;
276
  background: -webkit-gradient(linear, left top, left bottom, from(#f78297), to(#f56778)); /* WebKit */
277
  background: -moz-linear-gradient(top, #f78297, #f56778);
278
  border-color: #df6f8b #da5f75 #d55061;
279
+ color: #4F272C !important;
280
  text-shadow: 0 1px 0 #f89ca9;
281
  -webkit-box-shadow: 0 1px 1px #c1c1c1, inset 0 1px 0 #f9a1b1;
282
  -moz-box-shadow: 0 1px 1px #c1c1c1, inset 0 1px 0 #f9a1b1;
300
  background: -webkit-gradient(linear, left top, left bottom, from(#feda71), to(#febb4a)); /* WebKit */
301
  background: -moz-linear-gradient(top, #feda71, #febb4a);
302
  border-color: #f5b74e #e5a73e #d6982f;
303
+ color: #4D3217 !important;
304
  text-shadow: 0 1px 0 #fedd9b;
305
  -webkit-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #fee395;
306
  -moz-box-shadow: 0 1px 1px #d3d3d3, inset 0 1px 0 #fee395;
323
  background: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f0f0f0)); /* WebKit */
324
  background: -moz-linear-gradient(top, #f9f9f9, #f0f0f0);
325
  border-color: #dedede #d8d8d8 #d3d3d3;
326
+ color: #555555 !important;
327
  text-shadow: 0 1px 0 #fff;
328
  -webkit-box-shadow: 0 1px 1px #eaeaea, inset 0 1px 0 #fbfbfb;
329
  -moz-box-shadow: 0 1px 1px #eaeaea, inset 0 1px 0 #fbfbfb;
includes/index.html ADDED
File without changes
includes/sdm-admin-menu-handler.php CHANGED
@@ -115,7 +115,7 @@ function sdm_create_logs_page() {
115
  <div class="postbox">
116
  <h3 class="hndle"><label for="title"><?php _e('Export Download Log Entries', 'simple-download-monitor'); ?></label></h3>
117
  <div class="inside">
118
- <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" onSubmit="return confirm('Are you sure you want to export all the log entries?');" >
119
  <div class="submit">
120
  <input type="submit" class="button" name="sdm_export_log_entries" value="<?php _e('Export Log Entries to CSV File', 'simple-download-monitor'); ?>" />
121
  </div>
@@ -126,7 +126,7 @@ function sdm_create_logs_page() {
126
  <div class="postbox">
127
  <h3 class="hndle"><label for="title"><?php _e('Reset Download Log Entries', 'simple-download-monitor'); ?></label></h3>
128
  <div class="inside">
129
- <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" onSubmit="return confirm('Are you sure you want to reset all the log entries to a CSV file?');" >
130
  <div class="submit">
131
  <input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e('Reset Log Entries', 'simple-download-monitor'); ?>" />
132
  </div>
115
  <div class="postbox">
116
  <h3 class="hndle"><label for="title"><?php _e('Export Download Log Entries', 'simple-download-monitor'); ?></label></h3>
117
  <div class="inside">
118
+ <form method="post" action="" onSubmit="return confirm('Are you sure you want to export all the log entries?');" >
119
  <div class="submit">
120
  <input type="submit" class="button" name="sdm_export_log_entries" value="<?php _e('Export Log Entries to CSV File', 'simple-download-monitor'); ?>" />
121
  </div>
126
  <div class="postbox">
127
  <h3 class="hndle"><label for="title"><?php _e('Reset Download Log Entries', 'simple-download-monitor'); ?></label></h3>
128
  <div class="inside">
129
+ <form method="post" action="" onSubmit="return confirm('Are you sure you want to reset all the log entries to a CSV file?');" >
130
  <div class="submit">
131
  <input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e('Reset Log Entries', 'simple-download-monitor'); ?>" />
132
  </div>
includes/sdm-download-request-handler.php CHANGED
@@ -22,7 +22,13 @@ function handle_sdm_download_via_direct_post() {
22
  if(!empty($post_pass)){//This download item has a password. So validate the password.
23
  $pass_val = $_REQUEST['pass_text'];
24
  if(empty($pass_val)){//No password was submitted with the downoad request.
25
- wp_die(__('Error! This download requires a password.', 'simple-download-monitor'));
 
 
 
 
 
 
26
  }
27
  if ($post_pass != $pass_val) {
28
  //Incorrect password submitted.
@@ -96,6 +102,9 @@ function handle_sdm_download_via_direct_post() {
96
  }
97
  }
98
 
 
 
 
99
  // Should the item be dispatched?
100
  $dispatch = apply_filters('sdm_dispatch_downloads', get_post_meta($download_id, 'sdm_item_dispatch', true));
101
 
22
  if(!empty($post_pass)){//This download item has a password. So validate the password.
23
  $pass_val = $_REQUEST['pass_text'];
24
  if(empty($pass_val)){//No password was submitted with the downoad request.
25
+ $dl_post_url = get_permalink($download_id);
26
+ $error_msg = __('Error! This download requires a password.', 'simple-download-monitor');
27
+ $error_msg .= '<p>';
28
+ $error_msg .= '<a href="'.$dl_post_url.'">'.__('Click here', 'simple-download-monitor').'</a>';
29
+ $error_msg .= __(' and enter a valid password for this item', 'simple-download-monitor');
30
+ $error_msg .= '</p>';
31
+ wp_die($error_msg);
32
  }
33
  if ($post_pass != $pass_val) {
34
  //Incorrect password submitted.
102
  }
103
  }
104
 
105
+ // Allow plugin extensions to hook into download request.
106
+ do_action('sdm_process_download_request', $download_id, $download_link);
107
+
108
  // Should the item be dispatched?
109
  $dispatch = apply_filters('sdm_dispatch_downloads', get_post_meta($download_id, 'sdm_item_dispatch', true));
110
 
includes/sdm-utility-functions.php CHANGED
@@ -1,5 +1,26 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function sdm_get_download_count_for_post($id){
4
  // Get number of downloads by counting db columns matching postID
5
  global $wpdb;
@@ -135,4 +156,4 @@ function sdm_sanitize_value_by_array($to_check, $valid_values)
135
  return $to_check;
136
  }
137
  return reset($keys);//Return the first element from the valid values
138
- }
1
  <?php
2
 
3
+
4
+ /**
5
+ * Get (filtered) list of all download button colors.
6
+ * @return array Array of colors: color key => color name.
7
+ */
8
+ function sdm_get_download_button_colors() {
9
+ return apply_filters('sdm_download_button_color_options', array(
10
+ 'green' => __('Green', 'simple-download-monitor'),
11
+ 'blue' => __('Blue', 'simple-download-monitor'),
12
+ 'purple' => __('Purple', 'simple-download-monitor'),
13
+ 'teal' => __('Teal', 'simple-download-monitor'),
14
+ 'darkblue' => __('Dark Blue', 'simple-download-monitor'),
15
+ 'black' => __('Black', 'simple-download-monitor'),
16
+ 'grey' => __('Grey', 'simple-download-monitor'),
17
+ 'pink' => __('Pink', 'simple-download-monitor'),
18
+ 'orange' => __('Orange', 'simple-download-monitor'),
19
+ 'white' => __('White', 'simple-download-monitor')
20
+ ));
21
+ }
22
+
23
+
24
  function sdm_get_download_count_for_post($id){
25
  // Get number of downloads by counting db columns matching postID
26
  global $wpdb;
156
  return $to_check;
157
  }
158
  return reset($keys);//Return the first element from the valid values
159
+ }
includes/templates/fancy1/sdm-fancy-1.php CHANGED
@@ -3,23 +3,11 @@
3
  function sdm_generate_fancy1_latest_downloads_display_output($get_posts, $args) {
4
 
5
  $output = "";
6
- isset($args['button_text']) ? $button_text = $args['button_text'] : $button_text = '';
7
- isset($args['new_window']) ? $new_window = $args['new_window'] : $new_window = '';
8
- isset($args['show_size']) ? $show_size = $args['show_size'] : $show_size = '';
9
- isset($args['show_version']) ? $show_version = $args['show_version'] : $show_version = '';
10
 
11
  foreach ($get_posts as $item) {
12
- $id = $item->ID; //Get the post ID
13
- //Create a args array
14
- $args = array(
15
- 'id' => $id,
16
- 'fancy' => '1',
17
- 'button_text' => $button_text,
18
- 'new_window' => $new_window,
19
- 'show_size' => $show_size,
20
- 'show_version' => $show_version,
21
  );
22
- $output .= sdm_generate_fancy1_display_output($args);
23
  }
24
  $output .= '<div class="sdm_clear_float"></div>';
25
  return $output;
@@ -32,23 +20,10 @@ function sdm_generate_fancy1_category_display_output($get_posts, $args) {
32
  //TODO - when the CSS file is moved to the fancy1 folder, change it here
33
  //$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 . '" />';
34
 
35
- isset($args['button_text']) ? $button_text = $args['button_text'] : $button_text = '';
36
- isset($args['new_window']) ? $new_window = $args['new_window'] : $new_window = '';
37
- isset($args['show_size']) ? $show_size = $args['show_size'] : $show_size = '';
38
- isset($args['show_version']) ? $show_version = $args['show_version'] : $show_version = '';
39
-
40
  foreach ($get_posts as $item) {
41
- $id = $item->ID; //Get the post ID
42
- //Create a args array
43
- $args = array(
44
- 'id' => $id,
45
- 'fancy' => '1',
46
- 'button_text' => $button_text,
47
- 'new_window' => $new_window,
48
- 'show_size' => $show_size,
49
- 'show_version' => $show_version,
50
  );
51
- $output .= sdm_generate_fancy1_display_output($args);
52
  }
53
  $output .= '<div class="sdm_clear_float"></div>';
54
  return $output;
@@ -60,35 +35,33 @@ function sdm_generate_fancy1_category_display_output($get_posts, $args) {
60
  * id, fancy, button_text, new_window
61
  */
62
 
63
- function sdm_generate_fancy1_display_output($args) {
64
-
65
- //Get the download ID
66
- $id = $args['id'];
67
- if (!is_numeric($id)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  return '<div class="sdm_error_msg">Error! The shortcode is missing the ID parameter. Please refer to the documentation to learn the shortcode usage.</div>';
69
  }
70
 
71
- // See if user color option is selected
72
  $main_opts = get_option('sdm_downloads_options');
73
- $color_opt = $main_opts['download_button_color'];
74
- $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : __('green', 'simple-download-monitor');
75
 
76
- //See if new window parameter is seet
77
- $window_target = '';
78
- if (isset($args['new_window']) && $args['new_window'] == '1') {
79
- $window_target = 'target="_blank"';
80
- }
81
-
82
- //Get the download button text
83
- $button_text = isset($args['button_text']) ? $args['button_text'] : '';
84
- if (empty($button_text)) {//Use the default text for the button
85
- $button_text_string = __('Download Now!', 'simple-download-monitor');
86
- } else {//Use the custom text
87
- $button_text_string = $button_text;
88
- }
89
-
90
- // Get permalink
91
- $permalink = get_permalink($id);
92
 
93
  // Get CPT thumbnail
94
  $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
@@ -96,7 +69,6 @@ function sdm_generate_fancy1_display_output($args) {
96
 
97
  // Get CPT title
98
  $item_title = get_the_title($id);
99
- $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
100
 
101
  // Get CPT description
102
  $isset_item_description = sdm_get_item_description_output($id);
@@ -104,15 +76,15 @@ function sdm_generate_fancy1_display_output($args) {
104
  // Get download button
105
  $homepage = get_bloginfo('url');
106
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
107
- $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" ' . $window_target . '>' . $button_text_string . '</a>';
108
 
109
  //Get item file size
110
  $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
111
- $isset_item_file_size = (isset($args['show_size']) && isset($item_file_size)) ? $item_file_size : '';//check if show_size is enabled and if there is a size value
112
 
113
  //Get item version
114
  $item_version = get_post_meta($id, 'sdm_item_version', true);
115
- $isset_item_version = (isset($args['show_version']) && isset($item_version)) ? $item_version : '';//check if show_version is enabled and if there is a version value
116
 
117
  // Check to see if the download link cpt is password protected
118
  $get_cpt_object = get_post($id);
@@ -125,14 +97,12 @@ function sdm_generate_fancy1_display_output($args) {
125
  $string = ($db_count == '1') ? __('Download', 'simple-download-monitor') : __('Downloads', 'simple-download-monitor');
126
  $download_count_string = '<span class="sdm_item_count_number">' . $db_count . '</span><span class="sdm_item_count_string"> ' . $string . '</span>';
127
 
128
- $css_class = isset($args['css_class']) ? $args['css_class'] : '';
129
-
130
  $output = '';
131
 
132
  $output .= '<div class="sdm_download_item ' . $css_class . '">';
133
  $output .= '<div class="sdm_download_item_top">';
134
  $output .= '<div class="sdm_download_thumbnail">' . $isset_download_thumbnail . '</div>';
135
- $output .= '<div class="sdm_download_title">' . $isset_item_title . '</div>';
136
  $output .= '</div>'; //End of .sdm_download_item_top
137
  $output .= '<div style="clear:both;"></div>';
138
 
3
  function sdm_generate_fancy1_latest_downloads_display_output($get_posts, $args) {
4
 
5
  $output = "";
 
 
 
 
6
 
7
  foreach ($get_posts as $item) {
8
+ $output .= sdm_generate_fancy1_display_output(
9
+ array_merge($args, array('id' => $item->ID))
 
 
 
 
 
 
 
10
  );
 
11
  }
12
  $output .= '<div class="sdm_clear_float"></div>';
13
  return $output;
20
  //TODO - when the CSS file is moved to the fancy1 folder, change it here
21
  //$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 . '" />';
22
 
 
 
 
 
 
23
  foreach ($get_posts as $item) {
24
+ $output .= sdm_generate_fancy1_display_output(
25
+ array_merge($args, array('id' => $item->ID))
 
 
 
 
 
 
 
26
  );
 
27
  }
28
  $output .= '<div class="sdm_clear_float"></div>';
29
  return $output;
35
  * id, fancy, button_text, new_window
36
  */
37
 
38
+ function sdm_generate_fancy1_display_output($atts) {
39
+
40
+ $shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
41
+ shortcode_atts(array(
42
+ 'id' => '',
43
+ 'button_text' => __('Download Now!', 'simple-download-monitor'),
44
+ 'new_window' => '',
45
+ 'color' => '',
46
+ 'css_class' => '',
47
+ 'show_size' => '',
48
+ 'show_version' => '',
49
+ ), $atts)
50
+ );
51
+
52
+ // Make shortcode attributes available in function local scope.
53
+ extract($shortcode_atts);
54
+
55
+ // Check the download ID
56
+ if ( empty($id) ) {
57
  return '<div class="sdm_error_msg">Error! The shortcode is missing the ID parameter. Please refer to the documentation to learn the shortcode usage.</div>';
58
  }
59
 
60
+ // Read plugin settings
61
  $main_opts = get_option('sdm_downloads_options');
 
 
62
 
63
+ // See if new window parameter is set
64
+ $window_target = empty($new_window) ? '_self' : '_blank';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  // Get CPT thumbnail
67
  $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
69
 
70
  // Get CPT title
71
  $item_title = get_the_title($id);
 
72
 
73
  // Get CPT description
74
  $isset_item_description = sdm_get_item_description_output($id);
76
  // Get download button
77
  $homepage = get_bloginfo('url');
78
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
79
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
80
 
81
  //Get item file size
82
  $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
83
+ $isset_item_file_size = ($show_size && isset($item_file_size)) ? $item_file_size : '';//check if show_size is enabled and if there is a size value
84
 
85
  //Get item version
86
  $item_version = get_post_meta($id, 'sdm_item_version', true);
87
+ $isset_item_version = ($show_version && isset($item_version)) ? $item_version : '';//check if show_version is enabled and if there is a version value
88
 
89
  // Check to see if the download link cpt is password protected
90
  $get_cpt_object = get_post($id);
97
  $string = ($db_count == '1') ? __('Download', 'simple-download-monitor') : __('Downloads', 'simple-download-monitor');
98
  $download_count_string = '<span class="sdm_item_count_number">' . $db_count . '</span><span class="sdm_item_count_string"> ' . $string . '</span>';
99
 
 
 
100
  $output = '';
101
 
102
  $output .= '<div class="sdm_download_item ' . $css_class . '">';
103
  $output .= '<div class="sdm_download_item_top">';
104
  $output .= '<div class="sdm_download_thumbnail">' . $isset_download_thumbnail . '</div>';
105
+ $output .= '<div class="sdm_download_title">' . $item_title . '</div>';
106
  $output .= '</div>'; //End of .sdm_download_item_top
107
  $output .= '<div style="clear:both;"></div>';
108
 
includes/templates/fancy2/sdm-fancy-2.php CHANGED
@@ -10,23 +10,9 @@ function sdm_generate_fancy2_latest_downloads_display_output($get_posts, $args)
10
  $count = 1;
11
  //$output .= '<ul class="sdm_fancy2_category_items">';
12
  foreach ($get_posts as $item) {
13
- $id = $item->ID; //Get the post ID
14
- $button_text = isset($args['button_text'])? $args['button_text'] : '';
15
- $new_window = isset($args['new_window'])? $args['new_window'] : '';
16
- $show_size = isset($args['show_size'])? $args['show_size'] : '';
17
- $show_version = isset($args['show_version'])? $args['show_version'] : '';
18
-
19
- //Create a args array
20
- $args = array(
21
- 'id' => $id,
22
- 'fancy' => '2',
23
- 'button_text' => $button_text,
24
- 'new_window' => $new_window,
25
- 'css_class' => 'sdm_fancy2_grid',
26
- 'show_size' => $show_size,
27
- 'show_version' => $show_version,
28
  );
29
- $output .= sdm_generate_fancy2_display_output($args);
30
 
31
  if ($count % 3 == 0) {//Clear after every 3 items in the grid
32
  $output .= '<div class="sdm_clear_float"></div>';
@@ -46,23 +32,9 @@ function sdm_generate_fancy2_category_display_output($get_posts, $args) {
46
  $count = 1;
47
  //$output .= '<ul class="sdm_fancy2_category_items">';
48
  foreach ($get_posts as $item) {
49
- $id = $item->ID; //Get the post ID
50
- $button_text = isset($args['button_text'])? $args['button_text'] : '';
51
- $new_window = isset($args['new_window'])? $args['new_window'] : '';
52
- $show_size = isset($args['show_size'])? $args['show_size'] : '';
53
- $show_version = isset($args['show_version'])? $args['show_version'] : '';
54
-
55
- //Create a args array
56
- $args = array(
57
- 'id' => $id,
58
- 'fancy' => '2',
59
- 'button_text' => $button_text,
60
- 'new_window' => $new_window,
61
- 'css_class' => 'sdm_fancy2_grid',
62
- 'show_size' => $show_size,
63
- 'show_version' => $show_version,
64
  );
65
- $output .= sdm_generate_fancy2_display_output($args);
66
 
67
  if ($count % 3 == 0) {//Clear after every 3 items in the grid
68
  $output .= '<div class="sdm_clear_float"></div>';
@@ -80,30 +52,34 @@ function sdm_generate_fancy2_category_display_output($get_posts, $args) {
80
  * id, fancy, button_text, new_window
81
  */
82
 
83
- function sdm_generate_fancy2_display_output($args) {
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
- //Get the download ID
86
- $id = $args['id'];
87
- if (!is_numeric($id)) {
 
 
88
  return '<div class="sdm_error_msg">Error! The shortcode is missing the ID parameter. Please refer to the documentation to learn the shortcode usage.</div>';
89
  }
90
 
91
- //See if new window parameter is seet
92
- $window_target = '';
93
- if (isset($args['new_window']) && $args['new_window'] == '1') {
94
- $window_target = 'target="_blank"';
95
- }
96
 
97
- //Get the download button text
98
- $button_text = isset($args['button_text']) ? $args['button_text'] : '';
99
- if (empty($button_text)) {//Use the default text for the button
100
- $button_text_string = __('Download Now!', 'simple-download-monitor');
101
- } else {//Use the custom text
102
- $button_text_string = $button_text;
103
- }
104
  $homepage = get_bloginfo('url');
105
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
106
- $download_button_code = '<a href="' . $download_url . '" class="sdm_fancy2_download" ' . $window_target . '>' . $button_text_string . '</a>';
107
 
108
  // Check to see if the download link cpt is password protected
109
  $get_cpt_object = get_post($id);
@@ -112,30 +88,25 @@ function sdm_generate_fancy2_display_output($args) {
112
  $download_button_code = sdm_get_password_entry_form($id);
113
  }
114
 
115
- // Get item permalink
116
- $permalink = get_permalink($id);
117
-
118
  // Get item thumbnail
119
  $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
120
  $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_fancy2_thumb_image" src="' . $item_download_thumbnail . '" />' : '';
121
 
122
  // Get item title
123
  $item_title = get_the_title($id);
124
- $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
125
 
126
  // Get item description
127
  $isset_item_description = sdm_get_item_description_output($id);
128
 
129
  //Get item file size
130
  $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
131
- $isset_item_file_size = (isset($args['show_size']) && isset($item_file_size)) ? $item_file_size : '';//check if show_size is enabled and if there is a size value
132
 
133
  //Get item version
134
  $item_version = get_post_meta($id, 'sdm_item_version', true);
135
- $isset_item_version = (isset($args['show_version']) && isset($item_version)) ? $item_version : '';//check if show_version is enabled and if there is a version value
136
 
137
 
138
- $css_class = isset($args['css_class']) ? $args['css_class'] : '';
139
  $output = '';
140
  $output .= '<div class="sdm_fancy2_item ' . $css_class . '">';
141
  $output .= '<div class="sdm_fancy2_wrapper">';
@@ -144,7 +115,7 @@ function sdm_generate_fancy2_display_output($args) {
144
  $output .= '<div class="sdm_fancy2_download_thumbnail">' . $isset_download_thumbnail . '</div>';
145
  $output .= '</div>'; //End of .sdm_download_item_top
146
 
147
- $output .= '<div class="sdm_fancy2_download_title">' . $isset_item_title . '</div>';
148
 
149
  if (!empty($isset_item_file_size)) {//Show file size info if specified in the shortcode
150
  $output .= '<div class="sdm_fancy2_download_size">';
10
  $count = 1;
11
  //$output .= '<ul class="sdm_fancy2_category_items">';
12
  foreach ($get_posts as $item) {
13
+ $output .= sdm_generate_fancy2_display_output(
14
+ array_merge($args, array('id' => $item->ID))
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  );
 
16
 
17
  if ($count % 3 == 0) {//Clear after every 3 items in the grid
18
  $output .= '<div class="sdm_clear_float"></div>';
32
  $count = 1;
33
  //$output .= '<ul class="sdm_fancy2_category_items">';
34
  foreach ($get_posts as $item) {
35
+ $output .= sdm_generate_fancy2_display_output(
36
+ array_merge($args, array('id' => $item->ID))
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  );
 
38
 
39
  if ($count % 3 == 0) {//Clear after every 3 items in the grid
40
  $output .= '<div class="sdm_clear_float"></div>';
52
  * id, fancy, button_text, new_window
53
  */
54
 
55
+ function sdm_generate_fancy2_display_output($atts) {
56
+
57
+ $shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
58
+ shortcode_atts(array(
59
+ 'id' => '',
60
+ 'button_text' => __('Download Now!', 'simple-download-monitor'),
61
+ 'new_window' => '',
62
+ 'color' => '',
63
+ 'css_class' => 'sdm_fancy2_grid',
64
+ 'show_size' => '',
65
+ 'show_version' => '',
66
+ ), $atts)
67
+ );
68
 
69
+ // Make shortcode attributes available in function local scope.
70
+ extract($shortcode_atts);
71
+
72
+ // Check the download ID
73
+ if ( empty($id) ) {
74
  return '<div class="sdm_error_msg">Error! The shortcode is missing the ID parameter. Please refer to the documentation to learn the shortcode usage.</div>';
75
  }
76
 
77
+ // See if new window parameter is set
78
+ $window_target = empty($new_window) ? '_self' : '_blank';
 
 
 
79
 
 
 
 
 
 
 
 
80
  $homepage = get_bloginfo('url');
81
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
82
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_fancy2_download" target="' . $window_target . '">' . $button_text . '</a>';
83
 
84
  // Check to see if the download link cpt is password protected
85
  $get_cpt_object = get_post($id);
88
  $download_button_code = sdm_get_password_entry_form($id);
89
  }
90
 
 
 
 
91
  // Get item thumbnail
92
  $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
93
  $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_fancy2_thumb_image" src="' . $item_download_thumbnail . '" />' : '';
94
 
95
  // Get item title
96
  $item_title = get_the_title($id);
 
97
 
98
  // Get item description
99
  $isset_item_description = sdm_get_item_description_output($id);
100
 
101
  //Get item file size
102
  $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
103
+ $isset_item_file_size = ($show_size && isset($item_file_size)) ? $item_file_size : '';//check if show_size is enabled and if there is a size value
104
 
105
  //Get item version
106
  $item_version = get_post_meta($id, 'sdm_item_version', true);
107
+ $isset_item_version = ($show_version && isset($item_version)) ? $item_version : '';//check if show_version is enabled and if there is a version value
108
 
109
 
 
110
  $output = '';
111
  $output .= '<div class="sdm_fancy2_item ' . $css_class . '">';
112
  $output .= '<div class="sdm_fancy2_wrapper">';
115
  $output .= '<div class="sdm_fancy2_download_thumbnail">' . $isset_download_thumbnail . '</div>';
116
  $output .= '</div>'; //End of .sdm_download_item_top
117
 
118
+ $output .= '<div class="sdm_fancy2_download_title">' . $item_title . '</div>';
119
 
120
  if (!empty($isset_item_file_size)) {//Show file size info if specified in the shortcode
121
  $output .= '<div class="sdm_fancy2_download_size">';
index.html ADDED
File without changes
js/index.html ADDED
File without changes
main.php CHANGED
@@ -3,16 +3,17 @@
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.3.4
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
10
  */
 
11
  if (!defined('ABSPATH')) {
12
  exit;
13
  }
14
 
15
- define('WP_SIMPLE_DL_MONITOR_VERSION', '3.3.4');
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__));
@@ -180,8 +181,10 @@ class simpleDownloadManager {
180
  download_title: '<?php _e('Download Title', 'simple-download-monitor') ?>',
181
  include_fancy: '<?php _e('Include Fancy Box', 'simple-download-monitor') ?>',
182
  open_new_window: '<?php _e('Open New Window', 'simple-download-monitor') ?>',
 
183
  insert_shortcode: '<?php _e('Insert SDM Shortcode', 'simple-download-monitor') ?>'
184
  };
 
185
  </script>
186
  <?php
187
  }
@@ -199,7 +202,7 @@ class simpleDownloadManager {
199
  public function sdm_admin_styles() {
200
 
201
  wp_enqueue_style('thickbox'); // Needed for media upload thickbox
202
- wp_enqueue_style('sdm_admin_styles', WP_SIMPLE_DL_MONITOR_URL . '/css/sdm_admin_styles.css'); // Needed for media upload thickbox
203
  }
204
 
205
  public function sdm_create_menu_pages() {
@@ -353,14 +356,14 @@ class simpleDownloadManager {
353
  _e('File Size: ', 'simple-download-monitor');
354
  echo '<br />';
355
  echo ' <input type="text" name="sdm_item_file_size" value="' . $file_size . '" size="20" />';
356
- echo '<p class="description">'.__('Enter the size of this file (example value: 2.15 MB). You can show shis value in the fancy display by using a shortcode parameter.', 'simple-download-monitor').'</p>';
357
  echo '</div>';
358
 
359
  echo '<div class="sdm-download-edit-version">';
360
  _e('Version: ', 'simple-download-monitor');
361
  echo '<br />';
362
  echo ' <input type="text" name="sdm_item_version" value="' . $version . '" size="20" />';
363
- echo '<p class="description">'.__('Enter the version number for this item if any (example value: v2.5.10). You can show shis value in the fancy display by using a shortcode parameter.', 'simple-download-monitor').'</p>';
364
  echo '</div>';
365
 
366
  wp_nonce_field('sdm_other_details_nonce', 'sdm_other_details_nonce_check');
@@ -542,17 +545,16 @@ class simpleDownloadManager {
542
 
543
  public function download_button_color_cb() {
544
  $main_opts = get_option('sdm_downloads_options');
545
- $color_opt = $main_opts['download_button_color'];
546
- $color_opts = array(__('Green', 'simple-download-monitor'), __('Blue', 'simple-download-monitor'), __('Purple', 'simple-download-monitor'), __('Teal', 'simple-download-monitor'), __('Dark Blue', 'simple-download-monitor'), __('Black', 'simple-download-monitor'), __('Grey', 'simple-download-monitor'), __('Pink', 'simple-download-monitor'), __('Orange', 'simple-download-monitor'), __('White', 'simple-download-monitor'));
 
 
547
  echo '<select name="sdm_downloads_options[download_button_color]" id="download_button_color" class="sdm_opts_ajax_dropdowns">';
548
- if (isset($color_opt)) {
549
- echo '<option value="' . $color_opt . '" selected="selected">' . $color_opt . ' (' . __('current', 'simple-download-monitor') . ')</option>';
550
- }
551
- foreach ($color_opts as $color) {
552
- echo '<option value="' . $color . '">' . $color . '</option>';
553
  }
554
  echo '</select> ';
555
- _e('Adjusts the color of the "Download Now" button.', 'simple-download-monitor');
556
  }
557
 
558
  }//End of simpleDownloadManager class
@@ -742,7 +744,6 @@ if ($tiny_button_option != true) {
742
 
743
  function sdm_downloads_register_button($buttons) {
744
 
745
- //array_push( $buttons, 'sdm_downloads' );
746
  $buttons[] = 'sdm_downloads';
747
  return $buttons;
748
  }
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.0
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
10
  */
11
+
12
  if (!defined('ABSPATH')) {
13
  exit;
14
  }
15
 
16
+ define('WP_SIMPLE_DL_MONITOR_VERSION', '3.4.0');
17
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
18
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
19
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
181
  download_title: '<?php _e('Download Title', 'simple-download-monitor') ?>',
182
  include_fancy: '<?php _e('Include Fancy Box', 'simple-download-monitor') ?>',
183
  open_new_window: '<?php _e('Open New Window', 'simple-download-monitor') ?>',
184
+ button_color: '<?php _e('Button Color', 'simple-download-monitor'); ?>',
185
  insert_shortcode: '<?php _e('Insert SDM Shortcode', 'simple-download-monitor') ?>'
186
  };
187
+ var sdm_button_colors = <?php echo wp_json_encode(sdm_get_download_button_colors()); ?>;
188
  </script>
189
  <?php
190
  }
202
  public function sdm_admin_styles() {
203
 
204
  wp_enqueue_style('thickbox'); // Needed for media upload thickbox
205
+ wp_enqueue_style('sdm_admin_styles', WP_SIMPLE_DL_MONITOR_URL . '/css/sdm_admin_styles.css', array(), WP_SIMPLE_DL_MONITOR_VERSION); // Needed for media upload thickbox
206
  }
207
 
208
  public function sdm_create_menu_pages() {
356
  _e('File Size: ', 'simple-download-monitor');
357
  echo '<br />';
358
  echo ' <input type="text" name="sdm_item_file_size" value="' . $file_size . '" size="20" />';
359
+ echo '<p class="description">'.__('Enter the size of this file (example value: 2.15 MB). You can show this value in the fancy display by using a shortcode parameter.', 'simple-download-monitor').'</p>';
360
  echo '</div>';
361
 
362
  echo '<div class="sdm-download-edit-version">';
363
  _e('Version: ', 'simple-download-monitor');
364
  echo '<br />';
365
  echo ' <input type="text" name="sdm_item_version" value="' . $version . '" size="20" />';
366
+ echo '<p class="description">'.__('Enter the version number for this item if any (example value: v2.5.10). You can show this value in the fancy display by using a shortcode parameter.', 'simple-download-monitor').'</p>';
367
  echo '</div>';
368
 
369
  wp_nonce_field('sdm_other_details_nonce', 'sdm_other_details_nonce_check');
545
 
546
  public function download_button_color_cb() {
547
  $main_opts = get_option('sdm_downloads_options');
548
+ // Read current color class.
549
+ $color_opt = isset($main_opts['download_button_color']) ? $main_opts['download_button_color'] : null;
550
+ $color_opts = sdm_get_download_button_colors();
551
+
552
  echo '<select name="sdm_downloads_options[download_button_color]" id="download_button_color" class="sdm_opts_ajax_dropdowns">';
553
+ foreach ($color_opts as $color_class => $color_name) {
554
+ echo '<option value="' . $color_class . '"' . selected($color_class, $color_opt, false) . '>' . $color_name . '</option>';
 
 
 
555
  }
556
  echo '</select> ';
557
+ esc_html_e('Adjusts the color of the "Download Now" button.', 'simple-download-monitor');
558
  }
559
 
560
  }//End of simpleDownloadManager class
744
 
745
  function sdm_downloads_register_button($buttons) {
746
 
 
747
  $buttons[] = 'sdm_downloads';
748
  return $buttons;
749
  }
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  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: 3.3.0
6
- Tested up to: 4.6
7
- Stable tag: 3.3.4
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -112,6 +112,8 @@ Example Shortcode Usage:
112
 
113
  `[sdm_download id="271" fancy="0"]` (embed a plain download button/link for a file)
114
 
 
 
115
  **D) Download logs**
116
 
117
  You can check the download stats from the "Downloads->Logs" interface. It shows the number of downloads for each files, IP address of the user who downloaded it, date and time of the download.
@@ -168,6 +170,26 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
168
 
169
  == Changelog ==
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  = 3.3.4 =
172
  - Replace deprecated get_currentuserinfo() with wp_get_current_user()
173
  - Improve remote IP and location detection
2
  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.7
7
+ Stable tag: 3.4.0
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
112
 
113
  `[sdm_download id="271" fancy="0"]` (embed a plain download button/link for a file)
114
 
115
+ `[sdm_download id="271" fancy="0" color="blue"]` (embed a plain download button/link for a file with a blue color)
116
+
117
  **D) Download logs**
118
 
119
  You can check the download stats from the "Downloads->Logs" interface. It shows the number of downloads for each files, IP address of the user who downloaded it, date and time of the download.
170
 
171
  == Changelog ==
172
 
173
+ = 3.4.0 =
174
+ - Added a new hook to allow plugin extensions to hook into download request handling.
175
+ - Added empty index file to the plugin folder.
176
+ - Fixed potential XSS vulnerability. Thanks to Neven Biruski (Defensecode) for pointing it out.
177
+ - Minor typo fix.
178
+
179
+ = 3.3.7 =
180
+ - Added an improvement for the password protected download. If a user goes directly to the download link without entering a password, it will point the users to go to a page where they can enter a password for the download item.
181
+
182
+ = 3.3.6 =
183
+ - Fix fancy template shortcode attributes: some shortcode attributes were ignored in the previous release.
184
+
185
+ = 3.3.5 =
186
+ - Download button color can now be specified in the shortcode for fancy 1 and the standard download button.
187
+ - Added clearfix to .sdm_download_link container for better rendering in mobile devices.
188
+ - The button text color CSS has been sharpened a little to make it look nicer.
189
+ - Fixed an undefined variable notice.
190
+ - Updated TinyMCE button icon to a better one.
191
+ - Minimum WordPress version requirement changed to WP4.1
192
+
193
  = 3.3.4 =
194
  - Replace deprecated get_currentuserinfo() with wp_get_current_user()
195
  - Improve remote IP and location detection
sdm-shortcodes.php CHANGED
@@ -22,15 +22,53 @@ function sdm_register_shortcodes() {
22
  add_shortcode('sdm_download_categories_list', 'sdm_download_categories_list_shortcode');
23
  }
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  // Create Download Shortcode
26
  function sdm_create_download_shortcode($atts) {
27
 
28
- extract(shortcode_atts(array(
29
- 'id' => 'id',
30
- 'fancy' => '0',
31
- 'button_text' => '',
32
- 'new_window' => '',
33
- ), $atts));
 
 
 
 
 
 
34
 
35
  if (empty($id)) {
36
  return '<p style="color: red;">' . __('Error! Please enter an ID value with this shortcode.', 'simple-download-monitor') . '</p>';
@@ -41,26 +79,13 @@ function sdm_create_download_shortcode($atts) {
41
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
42
  // Get CPT title
43
  $item_title = get_the_title($id);
44
- $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
45
-
46
- // See if user color option is selected
47
- $main_opts = get_option('sdm_downloads_options');
48
- $color_opt = $main_opts['download_button_color'];
49
- $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : __('green', 'simple-download-monitor');
50
 
51
  //*** Generate the download now button code ***
52
- $window_target = '';
53
- if (!empty($new_window)) {
54
- $window_target = 'target="_blank"';
55
- }
56
- if (empty($button_text)) {//Use the default text for the button
57
- $button_text_string = __('Download Now!', 'simple-download-monitor');
58
- } else {//Use the custom text
59
- $button_text_string = $button_text;
60
- }
61
  $homepage = get_bloginfo('url');
62
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
63
- $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" ' . $window_target . '>' . $button_text_string . '</a>';
64
 
65
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
66
  $download_button_code = sdm_get_password_entry_form($id);
@@ -68,19 +93,20 @@ function sdm_create_download_shortcode($atts) {
68
  //End of download now button code generation
69
 
70
  $output = '';
71
- if ($fancy == '0') {
72
- $output = '<div class="sdm_download_link">' . $download_button_code . '</div>';
73
- } else if ($fancy == '1') {
74
- include_once('includes/templates/fancy1/sdm-fancy-1.php');
75
- $output .= sdm_generate_fancy1_display_output($atts);
76
- $output .= '<div class="sdm_clear_float"></div>';
77
- } else if ($fancy == '2') {
78
- include_once('includes/templates/fancy2/sdm-fancy-2.php');
79
- $output .= '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL . '/includes/templates/fancy2/sdm-fancy-2-styles.css?ver=' . WP_SIMPLE_DL_MONITOR_VERSION . '" />';
80
- $output .= sdm_generate_fancy2_display_output($atts);
81
- $output .= '<div class="sdm_clear_float"></div>';
82
- } else {//Default output is the standard download now button (fancy 0)
83
- $output = '<div class="sdm_download_link">' . $download_button_code . '</div>';
 
84
  }
85
 
86
  return apply_filters('sdm_download_shortcode_output', $output, $atts);
@@ -88,15 +114,14 @@ function sdm_create_download_shortcode($atts) {
88
 
89
  function sdm_create_simple_download_link($atts){
90
  extract(shortcode_atts(array(
91
- 'id' => 'id',
92
  ), $atts));
93
 
94
  if (empty($id)) {
95
  return '<p style="color: red;">' . __('Error! Please enter an ID value with this shortcode.', 'simple-download-monitor') . '</p>';
96
  }
97
 
98
- $download_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
99
- return $download_url;
100
  }
101
 
102
  // Create Counter Shortcode
@@ -127,7 +152,7 @@ function sdm_handle_category_shortcode($args) {
127
  'category_slug' => '',
128
  'category_id' => '',
129
  'fancy' => '0',
130
- 'button_text' => '',
131
  'new_window' => '',
132
  'orderby' => 'post_date',
133
  'order' => 'DESC',
@@ -142,12 +167,14 @@ function sdm_handle_category_shortcode($args) {
142
  if (empty($category_slug) && empty($category_id)) {
143
  return '<p style="color: red;">' . __('Error! You must enter a category slug OR a category id with this shortcode. Refer to the documentation for usage instructions.', 'simple-download-monitor') . '</p>';
144
  }
145
- // Else if both category slug AND category id are defined... return error
146
- else if (!empty($category_slug) && !empty($category_id)) {
 
147
  return '<p style="color: red;">' . __('Error! Please enter a category slug OR id; not both.', 'simple-download-monitor') . '</p>';
148
  }
 
149
  // Else setup query arguments for category_slug
150
- else if (!empty($category_slug) && empty($category_id)) {
151
 
152
  $field = 'slug';
153
  $terms = $category_slug;
@@ -197,53 +224,37 @@ function sdm_handle_category_shortcode($args) {
197
 
198
  $output = '';
199
 
200
- // Setup download location
201
- $homepage = get_bloginfo('url');
202
-
203
  // See if user color option is selected
204
  $main_opts = get_option('sdm_downloads_options');
205
  $color_opt = $main_opts['download_button_color'];
206
- $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : __('green', 'simple-download-monitor');
207
 
208
- $window_target = '';
209
- if (!empty($new_window)) {
210
- $window_target = 'target="_blank"';
211
- }
212
 
213
- if (empty($button_text)) {//Use the default text for the button
214
- $button_text_string = __('Download Now!', 'simple-download-monitor');
215
- } else {//Use the custom text
216
- $button_text_string = $button_text;
217
- }
218
-
219
- // Iterate cpt's
220
- foreach ($get_posts as $item) {
221
 
222
- // Set download location
223
- $id = $item->ID; // get each cpt ID
224
- $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
225
 
226
- // Get each cpt title
227
- $item_title = get_the_title($id);
228
- $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
229
 
230
- // Get CPT thumbnail (for fancy option)
231
- $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
232
- $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_download_thumbnail_image" src="' . $item_download_thumbnail . '" />' : '';
233
 
234
- // Get item description (for fancy option)
235
- $isset_item_description = sdm_get_item_description_output($id);
236
 
237
- // Setup download button code
238
- $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" ' . $window_target . '>' . $button_text_string . '</a>';
239
 
240
- // Generate download buttons
241
- if ($fancy == '0') {
242
  $output .= '<div class="sdm_download_link">' . $download_button_code . '</div><br />';
243
- }
244
- } // End foreach
245
- //Fancy 1 and onwards handles the loop inside the template function
246
- if ($fancy == '1') {
247
  include_once('includes/templates/fancy1/sdm-fancy-1.php');
248
  $output .= sdm_generate_fancy1_category_display_output($get_posts, $args);
249
  } else if ($fancy == '2') {
@@ -329,7 +340,7 @@ function sdm_download_categories_list_walker($atts, $parent = 0) {
329
  if ( empty($terms) ) { return ''; }
330
 
331
  // Produce list of download categories under $parent.
332
- $out .= '<' . $list_tag . '>';
333
 
334
  foreach ( $terms as $term ) {
335
  $out .= '<li>'
22
  add_shortcode('sdm_download_categories_list', 'sdm_download_categories_list_shortcode');
23
  }
24
 
25
+
26
+ /**
27
+ * Process (sanitize) download button shortcode attributes:
28
+ * - convert "id" to absolute integer
29
+ * - set "color" to color from settings or default color, if empty
30
+ * @param array $atts
31
+ * @return array
32
+ */
33
+ function sanitize_sdm_create_download_shortcode_atts($atts) {
34
+
35
+ // Sanitize download item ID
36
+ $atts['id'] = absint($atts['id']);
37
+
38
+ // See if user color option is selected
39
+ $main_opts = get_option('sdm_downloads_options');
40
+
41
+ if ( empty($atts['color']) ) {
42
+ // No color provided by shortcode, read color from plugin settings.
43
+ $atts['color']
44
+ = isset($main_opts['download_button_color'])
45
+ ? strtolower($main_opts['download_button_color']) // default values needs to be lowercased
46
+ : 'green'
47
+ ;
48
+ }
49
+
50
+ // Remove spaces from color key to make a proper CSS class name.
51
+ $atts['color'] = str_replace(' ', '', $atts['color']);
52
+
53
+ return $atts;
54
+ }
55
+
56
+
57
  // Create Download Shortcode
58
  function sdm_create_download_shortcode($atts) {
59
 
60
+ $shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
61
+ shortcode_atts(array(
62
+ 'id' => '',
63
+ 'fancy' => '0',
64
+ 'button_text' => __('Download Now!', 'simple-download-monitor'),
65
+ 'new_window' => '',
66
+ 'color' => '',
67
+ ), $atts)
68
+ );
69
+
70
+ // Make shortcode attributes available in function local scope.
71
+ extract($shortcode_atts);
72
 
73
  if (empty($id)) {
74
  return '<p style="color: red;">' . __('Error! Please enter an ID value with this shortcode.', 'simple-download-monitor') . '</p>';
79
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
80
  // Get CPT title
81
  $item_title = get_the_title($id);
 
 
 
 
 
 
82
 
83
  //*** Generate the download now button code ***
84
+ $window_target = empty($new_window) ? '_self' : '_blank';
85
+
 
 
 
 
 
 
 
86
  $homepage = get_bloginfo('url');
87
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
88
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
89
 
90
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
91
  $download_button_code = sdm_get_password_entry_form($id);
93
  //End of download now button code generation
94
 
95
  $output = '';
96
+ switch ( $fancy ) {
97
+ case '1':
98
+ include_once('includes/templates/fancy1/sdm-fancy-1.php');
99
+ $output .= sdm_generate_fancy1_display_output($shortcode_atts);
100
+ $output .= '<div class="sdm_clear_float"></div>';
101
+ break;
102
+ case '2':
103
+ include_once('includes/templates/fancy2/sdm-fancy-2.php');
104
+ $output .= '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL . '/includes/templates/fancy2/sdm-fancy-2-styles.css?ver=' . WP_SIMPLE_DL_MONITOR_VERSION . '" />';
105
+ $output .= sdm_generate_fancy2_display_output($shortcode_atts);
106
+ $output .= '<div class="sdm_clear_float"></div>';
107
+ break;
108
+ default: // Default output is the standard download now button (fancy 0)
109
+ $output = '<div class="sdm_download_link">' . $download_button_code . '</div>';
110
  }
111
 
112
  return apply_filters('sdm_download_shortcode_output', $output, $atts);
114
 
115
  function sdm_create_simple_download_link($atts){
116
  extract(shortcode_atts(array(
117
+ 'id' => '',
118
  ), $atts));
119
 
120
  if (empty($id)) {
121
  return '<p style="color: red;">' . __('Error! Please enter an ID value with this shortcode.', 'simple-download-monitor') . '</p>';
122
  }
123
 
124
+ return WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
 
125
  }
126
 
127
  // Create Counter Shortcode
152
  'category_slug' => '',
153
  'category_id' => '',
154
  'fancy' => '0',
155
+ 'button_text' => __('Download Now!', 'simple-download-monitor'),
156
  'new_window' => '',
157
  'orderby' => 'post_date',
158
  'order' => 'DESC',
167
  if (empty($category_slug) && empty($category_id)) {
168
  return '<p style="color: red;">' . __('Error! You must enter a category slug OR a category id with this shortcode. Refer to the documentation for usage instructions.', 'simple-download-monitor') . '</p>';
169
  }
170
+
171
+ // If both category slug AND category id are defined... return error
172
+ if (!empty($category_slug) && !empty($category_id)) {
173
  return '<p style="color: red;">' . __('Error! Please enter a category slug OR id; not both.', 'simple-download-monitor') . '</p>';
174
  }
175
+
176
  // Else setup query arguments for category_slug
177
+ if (!empty($category_slug) && empty($category_id)) {
178
 
179
  $field = 'slug';
180
  $terms = $category_slug;
224
 
225
  $output = '';
226
 
 
 
 
227
  // See if user color option is selected
228
  $main_opts = get_option('sdm_downloads_options');
229
  $color_opt = $main_opts['download_button_color'];
230
+ $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : 'green';
231
 
232
+ if ($fancy == '0') {
 
 
 
233
 
234
+ // Setup download location
235
+ $homepage = get_bloginfo('url');
 
 
 
 
 
 
236
 
237
+ $window_target = empty($new_window) ? '_self' : '_blank';
 
 
238
 
239
+ // Iterate cpt's
240
+ foreach ($get_posts as $item) {
 
241
 
242
+ // Set download location
243
+ $id = $item->ID; // get each cpt ID
244
+ $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
245
 
246
+ // Get each cpt title
247
+ $item_title = get_the_title($id);
248
 
249
+ // Setup download button code
250
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
251
 
252
+ // Generate download buttons
 
253
  $output .= '<div class="sdm_download_link">' . $download_button_code . '</div><br />';
254
+ } // End foreach
255
+ }
256
+ // Fancy 1 and onwards handles the loop inside the template function
257
+ else if ($fancy == '1') {
258
  include_once('includes/templates/fancy1/sdm-fancy-1.php');
259
  $output .= sdm_generate_fancy1_category_display_output($get_posts, $args);
260
  } else if ($fancy == '2') {
340
  if ( empty($terms) ) { return ''; }
341
 
342
  // Produce list of download categories under $parent.
343
+ $out = '<' . $list_tag . '>';
344
 
345
  foreach ( $terms as $term ) {
346
  $out .= '<li>'
tinymce/index.html ADDED
File without changes
tinymce/sdm_editor_plugin.js CHANGED
@@ -10,9 +10,9 @@
10
  */
11
  init : function(ed, url) {
12
  ed.addButton('sdm_downloads', {
13
- title : 'SDM Downloads',
14
- cmd : 'sdm_downloads',
15
- image : url + '/img/sdm_downloads.png'
16
  });
17
 
18
  ed.addCommand('sdm_downloads', function() {
@@ -91,31 +91,36 @@ jQuery(function(){
91
  }
92
  }
93
  );
 
 
 
 
 
94
 
95
  // Instantiate a form in the wp thickbox window (hidden at start)
96
  var form = jQuery('<div id="highlight-form"><div id="sdm_tinymce_postids" style="display:none;"></div>\
97
  <div id="sdm_select_title" style="margin-top:20px;">'+tinymce_langs.select_download_item+'</div>\
98
  <table id="highlight-table" class="form-table" style="text-align: left">\
99
- \
100
- \
101
  <tr>\
102
- <th><label class="title" for="highlight-bg">'+tinymce_langs.download_title+'</label></th>\
103
- <td><select name="sdm_select" id="sdm_select">\
104
- </select><br />\
 
 
 
105
  </tr>\
106
  <tr>\
107
- <th><label class="sdm_fancy" for "sdm_fancy_option">'+tinymce_langs.include_fancy+'</th>\
108
- <td><input type="checkbox" name="sdm_fancy_cb" id="sdm_fancy_cb" />\
109
  </tr>\
110
  <tr>\
111
- <th><label class="sdm_new_window" for "sdm_open_new_window">'+tinymce_langs.open_new_window+'</th>\
112
- <td><input type="checkbox" name="sdm_open_new_window_cb" id="sdm_open_new_window_cb" />\
113
  </tr>\
114
  </table>\
115
  <p class="submit">\
116
  <input type="button" id="sdm-tinymce-submit" class="button-primary" value="'+tinymce_langs.insert_shortcode+'" name="submit" style=""/>\
117
  </p>\
118
- <p></p>\
119
  </div>');
120
 
121
  var table = form.find('table');
@@ -124,25 +129,30 @@ jQuery(function(){
124
  // handles the click event of the submit button
125
  form.find('#sdm-tinymce-submit').click(function(){
126
 
127
- fancy_cb = jQuery('#sdm_fancy_cb').is(':checked');
128
- new_window_cb = jQuery('#sdm_open_new_window_cb').is(':checked');
129
- post_id = jQuery('#sdm_select').find(":selected").val(); // Get selected CPT item title value (item id)
 
130
 
131
  //Build the shortcode with parameters according to the options
132
- shortcode = '[sdm_download id="'+post_id+'"';
133
 
134
  //Add the fancy parameter to the shortcode (if needed
135
- if (jQuery('#sdm_fancy_cb').is(':checked')) {
136
  shortcode = shortcode + ' fancy="1"';
137
  } else {
138
  shortcode = shortcode + ' fancy="0"';
139
  }
140
 
141
  //Add the new_window parameter to the shortcode (if needed)
142
- if (jQuery('#sdm_open_new_window_cb').is(':checked')) {
143
  shortcode = shortcode + ' new_window="1"';
144
  }
145
 
 
 
 
 
146
  shortcode = shortcode + ']';//End the shortcode
147
 
148
  // inserts the shortcode into the active editor
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() {
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');
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