Simple Download Monitor - Version 3.5.9

Version Description

  • Added a new option in the settings that allows you to disable capturing of visitor's IP address in the download logs menu. Helpful for GDPR
Download this release

Release Info

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

Code changes from version 3.4.8 to 3.5.9

Files changed (31) hide show
  1. css/images/Thumbs.db +0 -0
  2. css/sdm_wp_styles.css +4 -0
  3. includes/sdm-admin-menu-handler.php +30 -30
  4. includes/sdm-download-request-handler.php +151 -137
  5. includes/sdm-search-shortcode-handler.php +53 -18
  6. includes/sdm-utility-functions.php +100 -72
  7. includes/templates/fancy0/sdm-fancy-0.php +6 -5
  8. includes/templates/fancy1/sdm-fancy-1.php +24 -26
  9. includes/templates/fancy2/sdm-fancy-2.php +19 -20
  10. langs/simple-download-monitor.pot +0 -511
  11. {langs → languages}/simple-download-monitor-de_DE.mo +0 -0
  12. {langs → languages}/simple-download-monitor-de_DE.po +0 -0
  13. {langs → languages}/simple-download-monitor-es_ES.mo +0 -0
  14. {langs → languages}/simple-download-monitor-es_ES.po +0 -0
  15. {langs → languages}/simple-download-monitor-fr_FR.mo +0 -0
  16. {langs → languages}/simple-download-monitor-fr_FR.po +0 -0
  17. {langs → languages}/simple-download-monitor-it_IT.mo +0 -0
  18. {langs → languages}/simple-download-monitor-it_IT.po +0 -0
  19. {langs → languages}/simple-download-monitor-nl_NL.mo +0 -0
  20. {langs → languages}/simple-download-monitor-nl_NL.po +0 -0
  21. {langs → languages}/simple-download-monitor-pt_BR.mo +0 -0
  22. {langs → languages}/simple-download-monitor-pt_BR.po +0 -0
  23. {langs → languages}/simple-download-monitor-ru_RU.mo +0 -0
  24. {langs → languages}/simple-download-monitor-ru_RU.po +0 -0
  25. languages/simple-download-monitor.pot +843 -0
  26. main.php +436 -415
  27. readme.txt +52 -8
  28. sdm-post-type-content-handler.php +2 -2
  29. sdm-shortcodes.php +320 -235
  30. tinymce/img/Thumbs.db +0 -0
  31. tinymce/img/sdm_downloads.png +0 -0
css/images/Thumbs.db DELETED
Binary file
css/sdm_wp_styles.css CHANGED
@@ -2,6 +2,10 @@
2
  clear: both;
3
  }
4
 
 
 
 
 
5
  .sdm_download_item {
6
  display: block;
7
  border:1px solid #E7E9EB;
2
  clear: both;
3
  }
4
 
5
+ .sdm_pass_text {
6
+ margin-bottom: 10px;
7
+ }
8
+
9
  .sdm_download_item {
10
  display: block;
11
  border:1px solid #E7E9EB;
includes/sdm-admin-menu-handler.php CHANGED
@@ -8,7 +8,7 @@ function sdm_handle_admin_menu() {
8
  //***** Create the 'logs' and 'settings' submenu pages
9
  $sdm_logs_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Logs', 'simple-download-monitor'), __('Logs', 'simple-download-monitor'), 'manage_options', 'logs', 'sdm_create_logs_page');
10
  $sdm_logs_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Stats', 'simple-download-monitor'), __('Stats', 'simple-download-monitor'), 'manage_options', 'sdm-stats', 'sdm_create_stats_page');
11
- $sdm_settings_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Settings', 'simple-download-monitor'), __('Settings', 'simple-download-monitor'), 'manage_options', 'settings', 'sdm_create_settings_page');
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
 
@@ -18,7 +18,7 @@ function sdm_handle_admin_menu() {
18
 
19
  function sdm_create_settings_page() {
20
  echo '<div class="wrap">';
21
- //echo '<div id="poststuff"><div id="post-body">';
22
  ?>
23
  <h1><?php _e('Simple Download Monitor Settings Page', 'simple-download-monitor') ?></h1>
24
 
@@ -114,7 +114,7 @@ function sdm_create_settings_page() {
114
  <!-- End of settings page form -->
115
  </form>
116
 
117
- <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;">
118
  <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>
119
  </p>
120
  </div>
@@ -131,7 +131,7 @@ function sdm_create_logs_page() {
131
  global $wpdb;
132
 
133
  if (isset($_POST['sdm_export_log_entries'])) {
134
- //Export log entries
135
  $log_file_url = sdm_export_download_logs_to_csv();
136
  echo '<div id="message" class="updated"><p>';
137
  _e('Log entries exported! Click on the following link to download the file.', 'simple-download-monitor');
@@ -140,7 +140,7 @@ function sdm_create_logs_page() {
140
  }
141
 
142
  if (isset($_POST['sdm_reset_log_entries'])) {
143
- //reset log entries
144
  $table_name = $wpdb->prefix . 'sdm_downloads';
145
  $query = "TRUNCATE $table_name";
146
  $result = $wpdb->query($query);
@@ -149,10 +149,10 @@ function sdm_create_logs_page() {
149
  echo '</p></div>';
150
  }
151
 
152
- /* * * Display the logs table ** */
153
- //Create an instance of our package class...
154
  $sdmListTable = new sdm_List_Table();
155
- //Fetch, prepare, sort, and filter our data...
156
  $sdmListTable->prepare_items();
157
  ?>
158
  <div class="wrap">
@@ -169,22 +169,22 @@ function sdm_create_logs_page() {
169
  <div class="postbox">
170
  <h3 class="hndle"><label for="title"><?php _e('Export Download Log Entries', 'simple-download-monitor'); ?></label></h3>
171
  <div class="inside">
172
- <form method="post" action="" onSubmit="return confirm('Are you sure you want to export all the log entries?');" >
173
  <div class="submit">
174
  <input type="submit" class="button" name="sdm_export_log_entries" value="<?php _e('Export Log Entries to CSV File', 'simple-download-monitor'); ?>" />
175
- </div>
176
- </form>
177
  </div></div>
178
 
179
  <!-- Log reset button -->
180
  <div class="postbox">
181
  <h3 class="hndle"><label for="title"><?php _e('Reset Download Log Entries', 'simple-download-monitor'); ?></label></h3>
182
  <div class="inside">
183
- <form method="post" action="" onSubmit="return confirm('Are you sure you want to reset all the log entries to a CSV file?');" >
184
  <div class="submit">
185
  <input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e('Reset Log Entries', 'simple-download-monitor'); ?>" />
186
- </div>
187
- </form>
188
  </div></div>
189
 
190
  </div></div><!-- end of .poststuff and .post-body -->
@@ -221,19 +221,19 @@ function sdm_create_stats_page() {
221
  wp_enqueue_style('sdm_jquery_ui_style');
222
 
223
  if (isset($_POST['sdm_stats_start_date'])) {
224
- $start_date = $_POST['sdm_stats_start_date'];
225
  } else {
226
- // default start date is 30 days back
227
  $start_date = date('Y-m-d', time() - 60 * 60 * 24 * 30);
228
  }
229
 
230
  if (isset($_POST['sdm_stats_end_date'])) {
231
- $end_date = $_POST['sdm_stats_end_date'];
232
  } else {
233
  $end_date = date('Y-m-d', time());
234
  }
235
  if (isset($_REQUEST['sdm_active_tab']) && !empty($_REQUEST['sdm_active_tab'])) {
236
- $active_tab = $_REQUEST['sdm_active_tab'];
237
  } else {
238
  $active_tab = 'datechart';
239
  }
@@ -242,32 +242,32 @@ function sdm_create_stats_page() {
242
  $downloads_by_country = sdm_get_downloads_by_country($start_date, $end_date);
243
  ?>
244
  <div class="wrap">
245
- <h2>Stats</h2>
246
  <div id="poststuff"><div id="post-body">
247
 
248
  <div class="postbox">
249
- <h3 class="hndle"><label for="title">Choose Date Range (yyyy-mm-dd)</label></h3>
250
  <div class="inside">
251
  <form id="sdm_choose_date" method="post">
252
  <input type="hidden" name="sdm_active_tab" value="<?php echo $active_tab; ?>">
253
- Start Date: <input type="text" class="datepicker" name="sdm_stats_start_date" value="<?php echo $start_date; ?>">
254
- End Date: <input type="text" class="datepicker" name="sdm_stats_end_date" value="<?php echo $end_date; ?>">
255
  <p id="sdm_date_buttons">
256
- <button type="button" data-start-date="<?php echo date('Y-m-01'); ?>" data-end-date="<?php echo date('Y-m-d'); ?>">This Month</button>
257
- <button type="button" data-start-date="<?php echo date('Y-m-d', strtotime('first day of last month')); ?>" data-end-date="<?php echo date('Y-m-d', strtotime('last day of last month')); ?>">Last Month</button>
258
- <button button type="button" data-start-date="<?php echo date('Y-01-01'); ?>" data-end-date="<?php echo date('Y-m-d'); ?>">This Year</button>
259
- <button button type="button" data-start-date="<?php echo date("Y-01-01", strtotime("-1 year")); ?>" data-end-date="<?php echo date("Y-12-31", strtotime('last year')); ?>">Last Year</button>
260
- <button button type="button" data-start-date="<?php echo "1970-01-01"; ?>" data-end-date="<?php echo date('Y-m-d'); ?>">All Time</button>
261
  </p>
262
  <div class="submit">
263
- <input type="submit" class="button-primary" value="View Stats »">
264
  </div>
265
  </form>
266
  </div>
267
  </div>
268
  <div class="nav-tab-wrapper sdm-tabs">
269
- <a href="edit.php?post_type=sdm_downloads&page=stats&sdm_active_tab=datechart" class="nav-tab<?php echo ($active_tab == 'datechart' ? ' nav-tab-active' : ''); ?>" data-tab-name="datechart">Downloads by date</a>
270
- <a href="edit.php?post_type=sdm_downloads&page=stats&sdm_active_tab=geochart" href="" class="nav-tab<?php echo ($active_tab == 'geochart' ? ' nav-tab-active' : ''); ?>" data-tab-name="geochart">Downloads by country</a>
271
  </div>
272
  <div class="sdm-tabs-content-wrapper" style="height: 500px;margin-top: 10px;">
273
  <div data-tab-name="datechart" class="sdm-tab"<?php echo ($active_tab == 'datechart' ? '' : ' style="display:none;"'); ?>>
8
  //***** Create the 'logs' and 'settings' submenu pages
9
  $sdm_logs_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Logs', 'simple-download-monitor'), __('Logs', 'simple-download-monitor'), 'manage_options', 'logs', 'sdm_create_logs_page');
10
  $sdm_logs_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Stats', 'simple-download-monitor'), __('Stats', 'simple-download-monitor'), 'manage_options', 'sdm-stats', 'sdm_create_stats_page');
11
+ $sdm_settings_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Settings', 'simple-download-monitor'), __('Settings', 'simple-download-monitor'), 'manage_options', 'sdm-settings', 'sdm_create_settings_page');
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
 
18
 
19
  function sdm_create_settings_page() {
20
  echo '<div class="wrap">';
21
+ //echo '<div id="poststuff"><div id="post-body">';
22
  ?>
23
  <h1><?php _e('Simple Download Monitor Settings Page', 'simple-download-monitor') ?></h1>
24
 
114
  <!-- End of settings page form -->
115
  </form>
116
 
117
+ <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;">
118
  <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>
119
  </p>
120
  </div>
131
  global $wpdb;
132
 
133
  if (isset($_POST['sdm_export_log_entries'])) {
134
+ //Export log entries
135
  $log_file_url = sdm_export_download_logs_to_csv();
136
  echo '<div id="message" class="updated"><p>';
137
  _e('Log entries exported! Click on the following link to download the file.', 'simple-download-monitor');
140
  }
141
 
142
  if (isset($_POST['sdm_reset_log_entries'])) {
143
+ //Reset log entries
144
  $table_name = $wpdb->prefix . 'sdm_downloads';
145
  $query = "TRUNCATE $table_name";
146
  $result = $wpdb->query($query);
149
  echo '</p></div>';
150
  }
151
 
152
+ /* Display the logs table */
153
+ //Create an instance of our package class...
154
  $sdmListTable = new sdm_List_Table();
155
+ //Fetch, prepare, sort, and filter our data...
156
  $sdmListTable->prepare_items();
157
  ?>
158
  <div class="wrap">
169
  <div class="postbox">
170
  <h3 class="hndle"><label for="title"><?php _e('Export Download Log Entries', 'simple-download-monitor'); ?></label></h3>
171
  <div class="inside">
172
+ <form method="post" action="" onSubmit="return confirm('Are you sure you want to export all the log entries?');" >
173
  <div class="submit">
174
  <input type="submit" class="button" name="sdm_export_log_entries" value="<?php _e('Export Log Entries to CSV File', 'simple-download-monitor'); ?>" />
175
+ </div>
176
+ </form>
177
  </div></div>
178
 
179
  <!-- Log reset button -->
180
  <div class="postbox">
181
  <h3 class="hndle"><label for="title"><?php _e('Reset Download Log Entries', 'simple-download-monitor'); ?></label></h3>
182
  <div class="inside">
183
+ <form method="post" action="" onSubmit="return confirm('Are you sure you want to reset all the log entries to a CSV file?');" >
184
  <div class="submit">
185
  <input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e('Reset Log Entries', 'simple-download-monitor'); ?>" />
186
+ </div>
187
+ </form>
188
  </div></div>
189
 
190
  </div></div><!-- end of .poststuff and .post-body -->
221
  wp_enqueue_style('sdm_jquery_ui_style');
222
 
223
  if (isset($_POST['sdm_stats_start_date'])) {
224
+ $start_date = sanitize_text_field($_POST['sdm_stats_start_date']);
225
  } else {
226
+ // default start date is 30 days back
227
  $start_date = date('Y-m-d', time() - 60 * 60 * 24 * 30);
228
  }
229
 
230
  if (isset($_POST['sdm_stats_end_date'])) {
231
+ $end_date = sanitize_text_field($_POST['sdm_stats_end_date']);
232
  } else {
233
  $end_date = date('Y-m-d', time());
234
  }
235
  if (isset($_REQUEST['sdm_active_tab']) && !empty($_REQUEST['sdm_active_tab'])) {
236
+ $active_tab = sanitize_text_field($_REQUEST['sdm_active_tab']);
237
  } else {
238
  $active_tab = 'datechart';
239
  }
242
  $downloads_by_country = sdm_get_downloads_by_country($start_date, $end_date);
243
  ?>
244
  <div class="wrap">
245
+ <h2><?php _e('Stats', 'simple-download-monitor'); ?></h2>
246
  <div id="poststuff"><div id="post-body">
247
 
248
  <div class="postbox">
249
+ <h3 class="hndle"><label for="title"><?php _e('Choose Date Range (yyyy-mm-dd)', 'simple-download-monitor'); ?></label></h3>
250
  <div class="inside">
251
  <form id="sdm_choose_date" method="post">
252
  <input type="hidden" name="sdm_active_tab" value="<?php echo $active_tab; ?>">
253
+ <?php _e('Start Date: ', 'simple-download-monitor'); ?><input type="text" class="datepicker" name="sdm_stats_start_date" value="<?php echo $start_date; ?>">
254
+ <?php _e('End Date: ', 'simple-download-monitor'); ?><input type="text" class="datepicker" name="sdm_stats_end_date" value="<?php echo $end_date; ?>">
255
  <p id="sdm_date_buttons">
256
+ <button type="button" data-start-date="<?php echo date('Y-m-01'); ?>" data-end-date="<?php echo date('Y-m-d'); ?>"><?php _e('This Month', 'simple-download-monitor'); ?></button>
257
+ <button type="button" data-start-date="<?php echo date('Y-m-d', strtotime('first day of last month')); ?>" data-end-date="<?php echo date('Y-m-d', strtotime('last day of last month')); ?>"><?php _e('Last Month', 'simple-download-monitor'); ?></button>
258
+ <button button type="button" data-start-date="<?php echo date('Y-01-01'); ?>" data-end-date="<?php echo date('Y-m-d'); ?>"><?php _e('This Year', 'simple-download-monitor'); ?></button>
259
+ <button button type="button" data-start-date="<?php echo date("Y-01-01", strtotime("-1 year")); ?>" data-end-date="<?php echo date("Y-12-31", strtotime('last year')); ?>"><?php _e('Last Year', 'simple-download-monitor'); ?></button>
260
+ <button button type="button" data-start-date="<?php echo "1970-01-01"; ?>" data-end-date="<?php echo date('Y-m-d'); ?>"><?php _e('All Time', 'simple-download-monitor'); ?></button>
261
  </p>
262
  <div class="submit">
263
+ <input type="submit" class="button-primary" value="<?php _e('View Stats', 'simple-download-monitor'); ?>">
264
  </div>
265
  </form>
266
  </div>
267
  </div>
268
  <div class="nav-tab-wrapper sdm-tabs">
269
+ <a href="edit.php?post_type=sdm_downloads&page=stats&sdm_active_tab=datechart" class="nav-tab<?php echo ($active_tab == 'datechart' ? ' nav-tab-active' : ''); ?>" data-tab-name="datechart"><?php _e('Downloads by date', 'simple-download-monitor'); ?></a>
270
+ <a href="edit.php?post_type=sdm_downloads&page=stats&sdm_active_tab=geochart" href="" class="nav-tab<?php echo ($active_tab == 'geochart' ? ' nav-tab-active' : ''); ?>" data-tab-name="geochart"><?php _e('Downloads by country', 'simple-download-monitor'); ?></a>
271
  </div>
272
  <div class="sdm-tabs-content-wrapper" style="height: 500px;margin-top: 10px;">
273
  <div data-tab-name="datechart" class="sdm-tab"<?php echo ($active_tab == 'datechart' ? '' : ' style="display:none;"'); ?>>
includes/sdm-download-request-handler.php CHANGED
@@ -3,135 +3,149 @@
3
  //Handles the download request
4
  function handle_sdm_download_via_direct_post() {
5
  if (isset($_REQUEST['smd_process_download']) && $_REQUEST['smd_process_download'] == '1') {
6
- global $wpdb;
7
- $download_id = absint($_REQUEST['download_id']);
8
- $download_title = get_the_title($download_id);
9
- $download_link = get_post_meta($download_id, 'sdm_upload', true);
10
-
11
- //Do some validation checks
12
- if (!$download_id) {
13
- wp_die(__('Error! Incorrect download item id.', 'simple-download-monitor'));
14
- }
15
- if (empty($download_link)) {
16
- wp_die(__('Error! This download item (' . $download_id . ') does not have any download link. Edit this item and specify a downloadable file URL for it.', 'simple-download-monitor'));
17
- }
18
-
19
- //Check download password (if applicable for this download)
20
- $post_object = get_post($download_id); // Get post object
21
- $post_pass = $post_object->post_password; // Get post password
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.
35
- wp_die(__('Error! Incorrect password. This download requires a valid password.', 'simple-download-monitor'));
36
- } else {
37
- //Password is valid. Go ahead with the download
38
- }
39
- }
40
- //End of password check
41
-
42
- $ipaddress = sdm_get_ip_address();
43
- $date_time = current_time('mysql');
44
- $visitor_country = $ipaddress ? sdm_ip_info($ipaddress, 'country') : '';
45
 
46
  $main_option = get_option('sdm_downloads_options');
47
-
48
- $visitor_name = sdm_get_logged_in_user();
49
-
50
- // Check if we only allow the download for logged-in users
51
- if (isset($main_option['only_logged_in_can_download'])) {
52
- if ($main_option['only_logged_in_can_download'] && $visitor_name === false) {
53
- //User not logged in, let's display the error message.
54
- //But first let's see if we have login page URL set so we can display it as well
55
- $loginMsg = '';
56
- if (isset($main_option['general_login_page_url']) && !empty($main_option['general_login_page_url'])) {
57
- //We have a login page URL set. Lets use it.
58
- $tpl = __("__Click here__ to go to login page.", 'simple-download-monitor');
59
- $loginMsg = preg_replace('/__(.*)__/', ' <a href="' . $main_option['general_login_page_url'] . '">$1</a> $2', $tpl);
60
- }
61
- wp_die(__('You need to be logged in to download this file.', 'simple-download-monitor') . $loginMsg);
62
- }
63
  }
64
-
65
- $visitor_name = ($visitor_name === false) ? __('Not Logged In', 'simple-download-monitor') : $visitor_name;
66
-
67
- // Get option for global disabling of download logging
68
- $no_logs = isset($main_option['admin_no_logs']);
69
-
70
- // Get optoin for logging only unique IPs
71
- $unique_ips = isset($main_option['admin_log_unique']);
72
-
73
- // Get post meta for individual disabling of download logging
74
- $get_meta = get_post_meta($download_id, 'sdm_item_no_log', true);
75
- $item_logging_checked = isset($get_meta) && $get_meta === 'on' ? 'on' : 'off';
76
-
77
- $dl_logging_needed = true;
78
-
79
- // Check if download logs have been disabled (globally or per download item)
80
- if ($no_logs === true || $item_logging_checked === 'on') {
81
- $dl_logging_needed = false;
82
- }
83
-
84
- // Check if we are only logging unique ips
85
- if ($unique_ips === true) {
86
- $check_ip = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id="' . $download_id . '" AND visitor_ip = "' . $ipaddress . '"');
87
-
88
- //This IP is already logged for this download item. No need to log it again.
89
- if ($check_ip) {
90
- $dl_logging_needed = false;
91
- }
92
- }
93
-
94
- if ($dl_logging_needed) {
95
- // We need to log this download.
96
- $table = $wpdb->prefix . 'sdm_downloads';
97
- $data = array(
98
- 'post_id' => $download_id,
99
- 'post_title' => $download_title,
100
- 'file_url' => $download_link,
101
- 'visitor_ip' => $ipaddress,
102
- 'date_time' => $date_time,
103
- 'visitor_country' => $visitor_country,
104
- 'visitor_name' => $visitor_name
105
- );
106
-
107
- $data = array_filter($data); //Remove any null values.
108
- $insert_table = $wpdb->insert($table, $data);
109
-
110
- if ($insert_table) {
111
- //Download request was logged successfully
112
- } else {
113
- //Failed to log the download request
114
- wp_die(__('Error! Failed to log the download request in the database table', 'simple-download-monitor'));
115
- }
116
- }
117
-
118
- // Allow plugin extensions to hook into download request.
119
- do_action('sdm_process_download_request', $download_id, $download_link);
120
-
121
- // Should the item be dispatched?
122
- $dispatch = apply_filters('sdm_dispatch_downloads', get_post_meta($download_id, 'sdm_item_dispatch', true));
123
-
124
- // Only local file can be dispatched.
125
- if ($dispatch && (stripos($download_link, WP_CONTENT_URL) === 0)) {
126
- // Get file path
127
- $file = path_join(WP_CONTENT_DIR, ltrim(substr($download_link, strlen(WP_CONTENT_URL)), '/'));
128
- // Try to dispatch file (terminates script execution on success)
129
- sdm_dispatch_file($file);
130
- }
131
-
132
- // As a fallback or when dispatching is disabled, redirect to the file
133
- // (and terminate script execution).
134
- sdm_redirect_to_url($download_link);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
  }
137
 
@@ -142,18 +156,18 @@ function handle_sdm_download_via_direct_post() {
142
  function sdm_redirect_to_url($url, $delay = '0', $exit = '1') {
143
  $url = apply_filters('sdm_before_redirect_to_url', $url);
144
  if (empty($url)) {
145
- echo '<strong>';
146
- _e('Error! The URL value is empty. Please specify a correct URL value to redirect to!', 'simple-download-monitor');
147
- echo '</strong>';
148
- exit;
149
  }
150
  if (!headers_sent()) {
151
- header('Location: ' . $url);
152
  } else {
153
- echo '<meta http-equiv="refresh" content="' . $delay . ';url=' . $url . '" />';
154
  }
155
  if ($exit == '1') {//exit
156
- exit;
157
  }
158
  }
159
 
@@ -166,13 +180,13 @@ function sdm_redirect_to_url($url, $delay = '0', $exit = '1') {
166
  function sdm_dispatch_file($filename) {
167
 
168
  if (headers_sent()) {
169
- trigger_error(__FUNCTION__ . ": Cannot dispatch file $filename, headers already sent.");
170
- return;
171
  }
172
 
173
  if (!is_readable($filename)) {
174
- trigger_error(__FUNCTION__ . ": Cannot dispatch file $filename, file is not readable.");
175
- return;
176
  }
177
 
178
  header('Content-Description: File Transfer');
3
  //Handles the download request
4
  function handle_sdm_download_via_direct_post() {
5
  if (isset($_REQUEST['smd_process_download']) && $_REQUEST['smd_process_download'] == '1') {
6
+ global $wpdb;
7
+ $download_id = absint($_REQUEST['download_id']);
8
+ $download_title = get_the_title($download_id);
9
+ $download_link = get_post_meta($download_id, 'sdm_upload', true);
10
+
11
+ //Do some validation checks
12
+ if (!$download_id) {
13
+ wp_die(__('Error! Incorrect download item id.', 'simple-download-monitor'));
14
+ }
15
+ if (empty($download_link)) {
16
+ wp_die(__('Error! This download item (' . $download_id . ') does not have any download link. Edit this item and specify a downloadable file URL for it.', 'simple-download-monitor'));
17
+ }
18
+
19
+ //Check download password (if applicable for this download)
20
+ $post_object = get_post($download_id); // Get post object
21
+ $post_pass = $post_object->post_password; // Get post password
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.
35
+ wp_die(__('Error! Incorrect password. This download requires a valid password.', 'simple-download-monitor'));
36
+ } else {
37
+ //Password is valid. Go ahead with the download
38
+ }
39
+ }
40
+ //End of password check
 
 
 
 
41
 
42
  $main_option = get_option('sdm_downloads_options');
43
+
44
+ $ipaddress = '';
45
+ //Check if do not capture IP is enabled.
46
+ if (!isset($main_option['admin_do_not_capture_ip'])) {
47
+ $ipaddress = sdm_get_ip_address();
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
+
50
+ $date_time = current_time('mysql');
51
+ $visitor_country = !empty($ipaddress) ? sdm_ip_info($ipaddress, 'country') : '';
52
+
53
+ $visitor_name = sdm_get_logged_in_user();
54
+
55
+ // Check if we only allow the download for logged-in users
56
+ if (isset($main_option['only_logged_in_can_download'])) {
57
+ if ($main_option['only_logged_in_can_download'] && $visitor_name === false) {
58
+ //User not logged in, let's display the error message.
59
+ //But first let's see if we have login page URL set so we can display it as well
60
+ $loginMsg = '';
61
+ if (isset($main_option['general_login_page_url']) && !empty($main_option['general_login_page_url'])) {
62
+ //We have a login page URL set. Lets use it.
63
+ $tpl = __("__Click here__ to go to login page.", 'simple-download-monitor');
64
+ $loginMsg = preg_replace('/__(.*)__/', ' <a href="' . $main_option['general_login_page_url'] . '">$1</a> $2', $tpl);
65
+ }
66
+ wp_die(__('You need to be logged in to download this file.', 'simple-download-monitor') . $loginMsg);
67
+ }
68
+ }
69
+
70
+ $visitor_name = ($visitor_name === false) ? __('Not Logged In', 'simple-download-monitor') : $visitor_name;
71
+
72
+ // Get option for global disabling of download logging
73
+ $no_logs = isset($main_option['admin_no_logs']);
74
+
75
+ // Get optoin for logging only unique IPs
76
+ $unique_ips = isset($main_option['admin_log_unique']);
77
+
78
+ // Get post meta for individual disabling of download logging
79
+ $get_meta = get_post_meta($download_id, 'sdm_item_no_log', true);
80
+ $item_logging_checked = isset($get_meta) && $get_meta === 'on' ? 'on' : 'off';
81
+
82
+ $dl_logging_needed = true;
83
+
84
+ // Check if download logs have been disabled (globally or per download item)
85
+ if ($no_logs === true || $item_logging_checked === 'on') {
86
+ $dl_logging_needed = false;
87
+ }
88
+
89
+ // Check if we are only logging unique ips
90
+ if ($unique_ips === true) {
91
+ $check_ip = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id="' . $download_id . '" AND visitor_ip = "' . $ipaddress . '"');
92
+
93
+ //This IP is already logged for this download item. No need to log it again.
94
+ if ($check_ip) {
95
+ $dl_logging_needed = false;
96
+ }
97
+ }
98
+
99
+ // Check if "Do Not Count Downloads from Bots" setting is enabled
100
+ if (isset($main_option['admin_dont_log_bots'])) {
101
+ //it is. Now let's check if visitor is a bot
102
+ if (sdm_visitor_is_bot()) {
103
+ //visitor is a bot. We neither log nor count this download
104
+ $dl_logging_needed = false;
105
+ }
106
+ }
107
+
108
+ if ($dl_logging_needed) {
109
+ // We need to log this download.
110
+ $table = $wpdb->prefix . 'sdm_downloads';
111
+ $data = array(
112
+ 'post_id' => $download_id,
113
+ 'post_title' => $download_title,
114
+ 'file_url' => $download_link,
115
+ 'visitor_ip' => $ipaddress,
116
+ 'date_time' => $date_time,
117
+ 'visitor_country' => $visitor_country,
118
+ 'visitor_name' => $visitor_name
119
+ );
120
+
121
+ $data = array_filter($data); //Remove any null values.
122
+ $insert_table = $wpdb->insert($table, $data);
123
+
124
+ if ($insert_table) {
125
+ //Download request was logged successfully
126
+ } else {
127
+ //Failed to log the download request
128
+ wp_die(__('Error! Failed to log the download request in the database table', 'simple-download-monitor'));
129
+ }
130
+ }
131
+
132
+ // Allow plugin extensions to hook into download request.
133
+ do_action('sdm_process_download_request', $download_id, $download_link);
134
+
135
+ // Should the item be dispatched?
136
+ $dispatch = apply_filters('sdm_dispatch_downloads', get_post_meta($download_id, 'sdm_item_dispatch', true));
137
+
138
+ // Only local file can be dispatched.
139
+ if ($dispatch && (stripos($download_link, WP_CONTENT_URL) === 0)) {
140
+ // Get file path
141
+ $file = path_join(WP_CONTENT_DIR, ltrim(substr($download_link, strlen(WP_CONTENT_URL)), '/'));
142
+ // Try to dispatch file (terminates script execution on success)
143
+ sdm_dispatch_file($file);
144
+ }
145
+
146
+ // As a fallback or when dispatching is disabled, redirect to the file
147
+ // (and terminate script execution).
148
+ sdm_redirect_to_url($download_link);
149
  }
150
  }
151
 
156
  function sdm_redirect_to_url($url, $delay = '0', $exit = '1') {
157
  $url = apply_filters('sdm_before_redirect_to_url', $url);
158
  if (empty($url)) {
159
+ echo '<strong>';
160
+ _e('Error! The URL value is empty. Please specify a correct URL value to redirect to!', 'simple-download-monitor');
161
+ echo '</strong>';
162
+ exit;
163
  }
164
  if (!headers_sent()) {
165
+ header('Location: ' . $url);
166
  } else {
167
+ echo '<meta http-equiv="refresh" content="' . $delay . ';url=' . $url . '" />';
168
  }
169
  if ($exit == '1') {//exit
170
+ exit;
171
  }
172
  }
173
 
180
  function sdm_dispatch_file($filename) {
181
 
182
  if (headers_sent()) {
183
+ trigger_error(__FUNCTION__ . ": Cannot dispatch file $filename, headers already sent.");
184
+ return;
185
  }
186
 
187
  if (!is_readable($filename)) {
188
+ trigger_error(__FUNCTION__ . ": Cannot dispatch file $filename, file is not readable.");
189
+ return;
190
  }
191
 
192
  header('Content-Description: File Transfer');
includes/sdm-search-shortcode-handler.php CHANGED
@@ -2,37 +2,72 @@
2
 
3
  function sdm_search_form_shortcode($args) {
4
  $atts = shortcode_atts(
5
- array(
6
  'fancy' => '',
7
  'class' => '', // wrapper class
8
  'placeholder' => 'Search...', // placeholder for search input
9
  'description_max_length' => 50, // short description symbols count
10
- ), $args
11
  );
12
 
 
 
13
  // Check if we have a search value posted
14
  $s_term = isset($_POST['sdm_search_term']) ? stripslashes(sanitize_text_field(esc_html($_POST['sdm_search_term']))) : '';
15
-
16
  if (!empty($s_term)) {
17
  // we got search term posted
18
- global $wpdb;
19
- $querystr = "
20
- SELECT $wpdb->posts.*, $wpdb->postmeta.meta_value as description
21
- FROM $wpdb->posts, $wpdb->postmeta
22
- WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
23
- AND $wpdb->posts.post_status = 'publish'
24
- AND $wpdb->posts.post_type = 'sdm_downloads'
25
- AND ($wpdb->posts.post_title LIKE '%$s_term%'
26
- OR ($wpdb->postmeta.meta_key='sdm_description' AND $wpdb->postmeta.meta_value LIKE '%$s_term%') )
27
- GROUP BY $wpdb->posts.ID
28
- ";
29
- $posts_collection = $wpdb->get_results($querystr, OBJECT);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  $s_results = sdm_generate_search_result_using_template($posts_collection, $atts);
31
 
 
32
  if (!empty($s_results)) {
33
- $s_results = '<h2>Search results for "' . $s_term . '":</h2>' . $s_results;
 
 
 
34
  } else {
35
- $s_results = '<h2>Nothing found for "' . $s_term . '".</h2>';
36
  }
37
  }
38
 
@@ -41,7 +76,7 @@ function sdm_search_form_shortcode($args) {
41
  $out .= '<input type="search" class="search-field" name="sdm_search_term" value="' . $s_term . '" placeholder="' . $atts['placeholder'] . '">';
42
  $out .= '<input type="submit" class="sdm_search_submit" name="sdm_search_submit" value="Search">';
43
  $out .= '</form>';
44
- $out .= isset($s_results) ? $s_results : '';
45
 
46
  return $out;
47
  }
2
 
3
  function sdm_search_form_shortcode($args) {
4
  $atts = shortcode_atts(
5
+ array(
6
  'fancy' => '',
7
  'class' => '', // wrapper class
8
  'placeholder' => 'Search...', // placeholder for search input
9
  'description_max_length' => 50, // short description symbols count
10
+ ), $args
11
  );
12
 
13
+ global $wpdb;
14
+
15
  // Check if we have a search value posted
16
  $s_term = isset($_POST['sdm_search_term']) ? stripslashes(sanitize_text_field(esc_html($_POST['sdm_search_term']))) : '';
17
+
18
  if (!empty($s_term)) {
19
  // we got search term posted
20
+ $keywords_searched = array();
21
+ $posts_collection = array();
22
+ $parts = explode(' ', $s_term);
23
+ foreach($parts as $keyword){
24
+ if(strlen($keyword) < 3){
25
+ //Ignore keywords less than 3 characters long
26
+ continue;
27
+ }
28
+
29
+ $keywords_searched[] = $keyword;
30
+
31
+ $querystr = "
32
+ SELECT $wpdb->posts.*, $wpdb->postmeta.meta_value as description
33
+ FROM $wpdb->posts, $wpdb->postmeta
34
+ WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
35
+ AND $wpdb->posts.post_status = 'publish'
36
+ AND $wpdb->posts.post_type = 'sdm_downloads'
37
+ AND ($wpdb->posts.post_title LIKE '%$keyword%'
38
+ OR ($wpdb->postmeta.meta_key='sdm_description' AND $wpdb->postmeta.meta_value LIKE '%$keyword%') )
39
+ GROUP BY $wpdb->posts.ID
40
+ ";
41
+ $query_result = $wpdb->get_results($querystr, OBJECT);
42
+
43
+ //Merge the results of this keyword with the collection array. Also remove any duplicate.
44
+ $posts_collection = array_merge($posts_collection, $query_result);
45
+ //$posts_collection = array_unique(array_merge($posts_collection, $query_result), SORT_REGULAR);
46
+ }
47
+
48
+ //Lets get rid of any duplicates
49
+ $unique_posts_collection_id = array();
50
+ foreach($posts_collection as $key => $post){
51
+ if(in_array($post->ID, $unique_posts_collection_id)){
52
+ //This is a duplicate.
53
+ unset($posts_collection[$key]);//Delete this entry from the collection.
54
+ } else {
55
+ //This post ID is not in the collection yet. Add it.
56
+ $unique_posts_collection_id[] = $post->ID;
57
+ }
58
+ }
59
+
60
+ //Create the result entries output using a template.
61
  $s_results = sdm_generate_search_result_using_template($posts_collection, $atts);
62
 
63
+ //Show the search result
64
  if (!empty($s_results)) {
65
+ $result_output = '<h2 class="sdm_search_result_heading">'.__('Showing search results for ', 'simple-download-monitor').'"' . $s_term . '"</h2>';
66
+ $result_output .= '<div class="sdm_search_result_number_of_items">' . __('Number of items found: ', 'simple-download-monitor') . count($posts_collection) . '</div>';
67
+ $result_output .= '<div class="sdm_search_result_keywords">' . __('Keywords searched: ', 'simple-download-monitor') . implode(", ", $keywords_searched) . '</div>';
68
+ $result_output .= '<div class="sdm_search_result_listing">' . $s_results . '</div>';
69
  } else {
70
+ $result_output = '<h2 class="sdm_search_result_heading">'.__('Nothing found for ', 'simple-download-monitor').'"' . $s_term . '".</h2>';
71
  }
72
  }
73
 
76
  $out .= '<input type="search" class="search-field" name="sdm_search_term" value="' . $s_term . '" placeholder="' . $atts['placeholder'] . '">';
77
  $out .= '<input type="submit" class="sdm_search_submit" name="sdm_search_submit" value="Search">';
78
  $out .= '</form>';
79
+ $out .= isset($result_output) ? $result_output : '';
80
 
81
  return $out;
82
  }
includes/sdm-utility-functions.php CHANGED
@@ -6,17 +6,17 @@
6
  */
7
  function sdm_get_download_button_colors() {
8
  return apply_filters('sdm_download_button_color_options', array(
9
- 'green' => __('Green', 'simple-download-monitor'),
10
- 'blue' => __('Blue', 'simple-download-monitor'),
11
- 'purple' => __('Purple', 'simple-download-monitor'),
12
- 'teal' => __('Teal', 'simple-download-monitor'),
13
- 'darkblue' => __('Dark Blue', 'simple-download-monitor'),
14
- 'black' => __('Black', 'simple-download-monitor'),
15
- 'grey' => __('Grey', 'simple-download-monitor'),
16
- 'pink' => __('Pink', 'simple-download-monitor'),
17
- 'orange' => __('Orange', 'simple-download-monitor'),
18
- 'white' => __('White', 'simple-download-monitor')
19
- ));
20
  }
21
 
22
  function sdm_get_download_count_for_post($id) {
@@ -32,7 +32,7 @@ function sdm_get_download_count_for_post($id) {
32
 
33
  if ($get_offset && $get_offset != '') {
34
 
35
- $db_count = $db_count + $get_offset;
36
  }
37
 
38
  return $db_count;
@@ -41,7 +41,7 @@ function sdm_get_download_count_for_post($id) {
41
  function sdm_get_item_description_output($id) {
42
  $item_description = get_post_meta($id, 'sdm_description', true);
43
  $isset_item_description = isset($item_description) && !empty($item_description) ? $item_description : '';
44
- //$isset_item_description = apply_filters('the_content', $isset_item_description);
45
 
46
  $isset_item_description = do_shortcode($isset_item_description);
47
  $isset_item_description = wptexturize($isset_item_description);
@@ -53,21 +53,25 @@ function sdm_get_item_description_output($id) {
53
  return $isset_item_description;
54
  }
55
 
56
- function sdm_get_password_entry_form($id, $args = array()) {
57
  $action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
58
 
59
- //Get the download button text
60
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
61
  if (empty($button_text)) {//Use the default text for the button
62
- $button_text_string = __('Download Now!', 'simple-download-monitor');
63
  } else {//Use the custom text
64
- $button_text_string = $button_text;
65
  }
66
 
 
 
67
  $data = __('Enter Password to Download:', 'simple-download-monitor');
68
- $data .= '<form action="' . $action_url . '" method="post" >';
69
  $data .= '<input type="password" name="pass_text" class="sdm_pass_text" value="" /> ';
70
- $data .= '<input type="submit" name="sdm_dl_pass_submit" class="pass_sumbit sdm_pass_protected_download" value="' . $button_text_string . '" />';
 
 
71
  $data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
72
  $data .= '</form>';
73
  return $data;
@@ -83,15 +87,15 @@ function sdm_get_password_entry_form($id, $args = array()) {
83
  function sdm_get_ip_address($ignore_private_and_reserved = false) {
84
  $flags = $ignore_private_and_reserved ? (FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) : 0;
85
  foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
86
- if (array_key_exists($key, $_SERVER) === true) {
87
- foreach (explode(',', $_SERVER[$key]) as $ip) {
88
- $ip = trim($ip); // just to be safe
89
-
90
- if (filter_var($ip, FILTER_VALIDATE_IP, $flags) !== false) {
91
- return $ip;
92
- }
93
- }
94
- }
95
  }
96
  return null;
97
  }
@@ -105,46 +109,46 @@ function sdm_get_ip_address($ignore_private_and_reserved = false) {
105
  function sdm_ip_info($ip, $purpose = "location") {
106
 
107
  $continents = array(
108
- "AF" => "Africa",
109
- "AN" => "Antarctica",
110
- "AS" => "Asia",
111
- "EU" => "Europe",
112
- "OC" => "Australia (Oceania)",
113
- "NA" => "North America",
114
- "SA" => "South America"
115
  );
116
 
117
  $ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
118
 
119
  if (@strlen(trim($ipdat->geoplugin_countryCode)) === 2) {
120
- switch ($purpose) {
121
- case "location":
122
- return array(
123
- "city" => @$ipdat->geoplugin_city,
124
- "state" => @$ipdat->geoplugin_regionName,
125
- "country" => @$ipdat->geoplugin_countryName,
126
- "country_code" => @$ipdat->geoplugin_countryCode,
127
- "continent" => @$continents[strtoupper($ipdat->geoplugin_continentCode)],
128
- "continent_code" => @$ipdat->geoplugin_continentCode
129
- );
130
- case "address":
131
- $address = array($ipdat->geoplugin_countryName);
132
- if (@strlen($ipdat->geoplugin_regionName) >= 1)
133
- $address[] = $ipdat->geoplugin_regionName;
134
- if (@strlen($ipdat->geoplugin_city) >= 1)
135
- $address[] = $ipdat->geoplugin_city;
136
- return implode(", ", array_reverse($address));
137
- case "city":
138
- return @$ipdat->geoplugin_city;
139
- case "state":
140
- return @$ipdat->geoplugin_regionName;
141
- case "region":
142
- return @$ipdat->geoplugin_regionName;
143
- case "country":
144
- return @$ipdat->geoplugin_countryName;
145
- case "countrycode":
146
- return @$ipdat->geoplugin_countryCode;
147
- }
148
  }
149
 
150
  // Either no info found or invalid $purpose.
@@ -159,7 +163,7 @@ function sdm_sanitize_value_by_array($to_check, $valid_values) {
159
  $keys = array_keys($valid_values);
160
  $keys = array_map('strtolower', $keys);
161
  if (in_array($to_check, $keys)) {
162
- return $to_check;
163
  }
164
  return reset($keys); //Return the first element from the valid values
165
  }
@@ -168,19 +172,43 @@ function sdm_get_logged_in_user() {
168
  $visitor_name = false;
169
 
170
  if (is_user_logged_in()) { // Get WP user name (if logged in)
171
- $current_user = wp_get_current_user();
172
- $visitor_name = $current_user->user_login;
173
  }
174
 
175
  //WP eMember plugin integration
176
  if (class_exists('Emember_Auth')) {
177
- //WP eMember plugin is installed.
178
- $emember_auth = Emember_Auth::getInstance();
179
- $username = $emember_auth->getUserInfo('user_name');
180
- if (!empty($username)) {//Member is logged in.
181
- $visitor_name = $username; //Override the visitor name to emember username.
182
- }
183
  }
184
 
185
  return $visitor_name;
186
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  */
7
  function sdm_get_download_button_colors() {
8
  return apply_filters('sdm_download_button_color_options', array(
9
+ 'green' => __('Green', 'simple-download-monitor'),
10
+ 'blue' => __('Blue', 'simple-download-monitor'),
11
+ 'purple' => __('Purple', 'simple-download-monitor'),
12
+ 'teal' => __('Teal', 'simple-download-monitor'),
13
+ 'darkblue' => __('Dark Blue', 'simple-download-monitor'),
14
+ 'black' => __('Black', 'simple-download-monitor'),
15
+ 'grey' => __('Grey', 'simple-download-monitor'),
16
+ 'pink' => __('Pink', 'simple-download-monitor'),
17
+ 'orange' => __('Orange', 'simple-download-monitor'),
18
+ 'white' => __('White', 'simple-download-monitor')
19
+ ));
20
  }
21
 
22
  function sdm_get_download_count_for_post($id) {
32
 
33
  if ($get_offset && $get_offset != '') {
34
 
35
+ $db_count = $db_count + $get_offset;
36
  }
37
 
38
  return $db_count;
41
  function sdm_get_item_description_output($id) {
42
  $item_description = get_post_meta($id, 'sdm_description', true);
43
  $isset_item_description = isset($item_description) && !empty($item_description) ? $item_description : '';
44
+ //$isset_item_description = apply_filters('the_content', $isset_item_description);
45
 
46
  $isset_item_description = do_shortcode($isset_item_description);
47
  $isset_item_description = wptexturize($isset_item_description);
53
  return $isset_item_description;
54
  }
55
 
56
+ function sdm_get_password_entry_form($id, $args = array(), $class = '') {
57
  $action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
58
 
59
+ //Get the download button text
60
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
61
  if (empty($button_text)) {//Use the default text for the button
62
+ $button_text_string = __('Download Now!', 'simple-download-monitor');
63
  } else {//Use the custom text
64
+ $button_text_string = $button_text;
65
  }
66
 
67
+ $uuid = uniqid('sdm-pass-');
68
+
69
  $data = __('Enter Password to Download:', 'simple-download-monitor');
70
+ $data .= '<form action="' . $action_url . '" method="post" id="' . $uuid . '">';
71
  $data .= '<input type="password" name="pass_text" class="sdm_pass_text" value="" /> ';
72
+ $data .= '<span class="sdm-download-button">';
73
+ $data .= '<a href="javascript:document.getElementById(\'' . $uuid . '\').submit();" name="sdm_dl_pass_submit" class="pass_sumbit sdm_pass_protected_download ' . $class . '">' . $button_text_string . '</a>';
74
+ $data .= '</span>';
75
  $data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
76
  $data .= '</form>';
77
  return $data;
87
  function sdm_get_ip_address($ignore_private_and_reserved = false) {
88
  $flags = $ignore_private_and_reserved ? (FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) : 0;
89
  foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
90
+ if (array_key_exists($key, $_SERVER) === true) {
91
+ foreach (explode(',', $_SERVER[$key]) as $ip) {
92
+ $ip = trim($ip); // just to be safe
93
+
94
+ if (filter_var($ip, FILTER_VALIDATE_IP, $flags) !== false) {
95
+ return $ip;
96
+ }
97
+ }
98
+ }
99
  }
100
  return null;
101
  }
109
  function sdm_ip_info($ip, $purpose = "location") {
110
 
111
  $continents = array(
112
+ "AF" => "Africa",
113
+ "AN" => "Antarctica",
114
+ "AS" => "Asia",
115
+ "EU" => "Europe",
116
+ "OC" => "Australia (Oceania)",
117
+ "NA" => "North America",
118
+ "SA" => "South America"
119
  );
120
 
121
  $ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
122
 
123
  if (@strlen(trim($ipdat->geoplugin_countryCode)) === 2) {
124
+ switch ($purpose) {
125
+ case "location":
126
+ return array(
127
+ "city" => @$ipdat->geoplugin_city,
128
+ "state" => @$ipdat->geoplugin_regionName,
129
+ "country" => @$ipdat->geoplugin_countryName,
130
+ "country_code" => @$ipdat->geoplugin_countryCode,
131
+ "continent" => @$continents[strtoupper($ipdat->geoplugin_continentCode)],
132
+ "continent_code" => @$ipdat->geoplugin_continentCode
133
+ );
134
+ case "address":
135
+ $address = array($ipdat->geoplugin_countryName);
136
+ if (@strlen($ipdat->geoplugin_regionName) >= 1)
137
+ $address[] = $ipdat->geoplugin_regionName;
138
+ if (@strlen($ipdat->geoplugin_city) >= 1)
139
+ $address[] = $ipdat->geoplugin_city;
140
+ return implode(", ", array_reverse($address));
141
+ case "city":
142
+ return @$ipdat->geoplugin_city;
143
+ case "state":
144
+ return @$ipdat->geoplugin_regionName;
145
+ case "region":
146
+ return @$ipdat->geoplugin_regionName;
147
+ case "country":
148
+ return @$ipdat->geoplugin_countryName;
149
+ case "countrycode":
150
+ return @$ipdat->geoplugin_countryCode;
151
+ }
152
  }
153
 
154
  // Either no info found or invalid $purpose.
163
  $keys = array_keys($valid_values);
164
  $keys = array_map('strtolower', $keys);
165
  if (in_array($to_check, $keys)) {
166
+ return $to_check;
167
  }
168
  return reset($keys); //Return the first element from the valid values
169
  }
172
  $visitor_name = false;
173
 
174
  if (is_user_logged_in()) { // Get WP user name (if logged in)
175
+ $current_user = wp_get_current_user();
176
+ $visitor_name = $current_user->user_login;
177
  }
178
 
179
  //WP eMember plugin integration
180
  if (class_exists('Emember_Auth')) {
181
+ //WP eMember plugin is installed.
182
+ $emember_auth = Emember_Auth::getInstance();
183
+ $username = $emember_auth->getUserInfo('user_name');
184
+ if (!empty($username)) {//Member is logged in.
185
+ $visitor_name = $username; //Override the visitor name to emember username.
186
+ }
187
  }
188
 
189
  return $visitor_name;
190
  }
191
+
192
+ // Checks if current visitor is a bot
193
+ function sdm_visitor_is_bot() {
194
+ $bots = array('archiver', 'baiduspider', 'bingbot', 'binlar', 'casper', 'checkprivacy', 'clshttp', 'cmsworldmap', 'comodo', 'curl', 'diavol', 'dotbot', 'DuckDuckBot', 'Exabot', 'email', 'extract', 'facebookexternalhit', 'feedfinder', 'flicky', 'googlebot','grab', 'harvest', 'httrack', 'ia_archiver', 'jakarta', 'kmccrew', 'libwww', 'loader', 'MJ12bot', 'miner', 'msnbot', 'nikto', 'nutch', 'planetwork', 'purebot', 'pycurl', 'python', 'scan', 'skygrid', 'slurp', 'sucker', 'turnit', 'vikspider', 'wget', 'winhttp', 'yandex', 'yandexbot', 'yahoo', 'youda', 'zmeu', 'zune');
195
+
196
+ $isBot = false;
197
+
198
+ $user_agent = wp_kses_data($_SERVER['HTTP_USER_AGENT']);
199
+
200
+ foreach ($bots as $bot) {
201
+ if (stripos($user_agent, $bot) !== false) {
202
+ $isBot = true;
203
+ }
204
+ }
205
+
206
+ if (empty($user_agent) || $user_agent == ' ') {
207
+ $isBot = true;
208
+ }
209
+
210
+ //This filter can be used to override what you consider bot via your own custom function. You can read the user-agent value from the server var.
211
+ $isBot = apply_filters('sdm_visitor_is_bot', $isBot);
212
+
213
+ return $isBot;
214
+ }
includes/templates/fancy0/sdm-fancy-0.php CHANGED
@@ -4,7 +4,7 @@ function sdm_generate_fancy0_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
  foreach ($get_posts as $item) {
9
  $id = $item->ID; //Get the post ID
10
  //Create a args array
@@ -20,7 +20,8 @@ function sdm_generate_fancy0_latest_downloads_display_output($get_posts, $args)
20
  return $output;
21
  }
22
 
23
- /*** TODO - Use this function in the category shortcode handler function ***/
 
24
  //function sdm_generate_fancy0_category_display_output($get_posts, $args) {
25
  //
26
  // $output = "";
@@ -76,7 +77,7 @@ function sdm_generate_fancy0_display_output($args) {
76
  $button_text_string = $button_text;
77
  }
78
 
79
- // Get CPT title
80
  $item_title = get_the_title($id);
81
  $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
82
 
@@ -89,11 +90,11 @@ function sdm_generate_fancy0_display_output($args) {
89
  $get_cpt_object = get_post($id);
90
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
91
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
92
- $download_button_code = sdm_get_password_entry_form($id, $args);
93
  }
94
 
95
  $output = "";
96
  $output .= '<div class="sdm_download_button_box_default"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
97
 
98
  return $output;
99
- }
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
  foreach ($get_posts as $item) {
9
  $id = $item->ID; //Get the post ID
10
  //Create a args array
20
  return $output;
21
  }
22
 
23
+ /* * * TODO - Use this function in the category shortcode handler function ** */
24
+
25
  //function sdm_generate_fancy0_category_display_output($get_posts, $args) {
26
  //
27
  // $output = "";
77
  $button_text_string = $button_text;
78
  }
79
 
80
+ // Get CPT title
81
  $item_title = get_the_title($id);
82
  $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
83
 
90
  $get_cpt_object = get_post($id);
91
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
92
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
93
+ $download_button_code = sdm_get_password_entry_form($id, $args, 'sdm_download ' . $def_color);
94
  }
95
 
96
  $output = "";
97
  $output .= '<div class="sdm_download_button_box_default"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
98
 
99
  return $output;
100
+ }
includes/templates/fancy1/sdm-fancy-1.php CHANGED
@@ -3,10 +3,10 @@
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>';
@@ -19,10 +19,10 @@ function sdm_generate_fancy1_category_display_output($get_posts, $args) {
19
 
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>';
@@ -38,22 +38,22 @@ function sdm_generate_fancy1_category_display_output($get_posts, $args) {
38
  function sdm_generate_fancy1_display_output($args) {
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
- ), $args)
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
 
@@ -64,7 +64,7 @@ function sdm_generate_fancy1_display_output($args) {
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);
68
  $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_download_thumbnail_image" src="' . $item_download_thumbnail . '" />' : '';
69
 
70
  // Get CPT title
@@ -72,7 +72,7 @@ function sdm_generate_fancy1_display_output($args) {
72
 
73
  // Get CPT description
74
  $isset_item_description = sdm_get_item_description_output($id);
75
-
76
  // Get download button
77
  $homepage = get_bloginfo('url');
78
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
@@ -80,19 +80,17 @@ function sdm_generate_fancy1_display_output($args) {
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);
91
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
92
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
93
- $download_button_code = sdm_get_password_entry_form($id, $args);
94
  }
95
-
96
  $db_count = sdm_get_download_count_for_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>';
@@ -105,7 +103,7 @@ function sdm_generate_fancy1_display_output($args) {
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
-
109
  $output .= '<div class="sdm_download_description">' . $isset_item_description . '</div>';
110
 
111
  if (!empty($isset_item_file_size)) {//Show file size info
@@ -121,14 +119,14 @@ function sdm_generate_fancy1_display_output($args) {
121
  $output .= '<span class="sdm_download_version_value">' . $isset_item_version . '</span>';
122
  $output .= '</div>';
123
  }
124
-
125
  $output .= '<div class="sdm_download_link">';
126
  $output .= '<span class="sdm_download_button">' . $download_button_code . '</span>';
127
- if(!isset($main_opts['general_hide_donwload_count'])) {//The hide download count is enabled.
128
  $output .= '<span class="sdm_download_item_count">' . $download_count_string . '</span>';
129
  }
130
  $output .= '</div>'; //end .sdm_download_link
131
  $output .= '</div>'; //end .sdm_download_item
132
 
133
  return $output;
134
- }
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>';
19
 
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>';
38
  function sdm_generate_fancy1_display_output($args) {
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
+ ), $args)
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
 
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);
68
  $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_download_thumbnail_image" src="' . $item_download_thumbnail . '" />' : '';
69
 
70
  // Get CPT title
72
 
73
  // Get CPT description
74
  $isset_item_description = sdm_get_item_description_output($id);
75
+
76
  // Get download button
77
  $homepage = get_bloginfo('url');
78
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
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
  //Get item version
85
  $item_version = get_post_meta($id, 'sdm_item_version', true);
86
+ $isset_item_version = ($show_version && isset($item_version)) ? $item_version : ''; //check if show_version is enabled and if there is a version value
 
87
  // Check to see if the download link cpt is password protected
88
  $get_cpt_object = get_post($id);
89
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
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, $shortcode_atts, 'sdm_download ' . $color);
92
  }
93
+
94
  $db_count = sdm_get_download_count_for_post($id);
95
  $string = ($db_count == '1') ? __('Download', 'simple-download-monitor') : __('Downloads', 'simple-download-monitor');
96
  $download_count_string = '<span class="sdm_item_count_number">' . $db_count . '</span><span class="sdm_item_count_string"> ' . $string . '</span>';
103
  $output .= '<div class="sdm_download_title">' . $item_title . '</div>';
104
  $output .= '</div>'; //End of .sdm_download_item_top
105
  $output .= '<div style="clear:both;"></div>';
106
+
107
  $output .= '<div class="sdm_download_description">' . $isset_item_description . '</div>';
108
 
109
  if (!empty($isset_item_file_size)) {//Show file size info
119
  $output .= '<span class="sdm_download_version_value">' . $isset_item_version . '</span>';
120
  $output .= '</div>';
121
  }
122
+
123
  $output .= '<div class="sdm_download_link">';
124
  $output .= '<span class="sdm_download_button">' . $download_button_code . '</span>';
125
+ if (!isset($main_opts['general_hide_donwload_count'])) {//The hide download count is enabled.
126
  $output .= '<span class="sdm_download_item_count">' . $download_count_string . '</span>';
127
  }
128
  $output .= '</div>'; //end .sdm_download_link
129
  $output .= '</div>'; //end .sdm_download_item
130
 
131
  return $output;
132
+ }
includes/templates/fancy2/sdm-fancy-2.php CHANGED
@@ -11,7 +11,7 @@ function sdm_generate_fancy2_latest_downloads_display_output($get_posts, $args)
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
@@ -33,7 +33,7 @@ function sdm_generate_fancy2_category_display_output($get_posts, $args) {
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
@@ -55,22 +55,22 @@ function sdm_generate_fancy2_category_display_output($get_posts, $args) {
55
  function sdm_generate_fancy2_display_output($args) {
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
- ), $args)
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
 
@@ -85,7 +85,7 @@ function sdm_generate_fancy2_display_output($args) {
85
  $get_cpt_object = get_post($id);
86
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
87
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
88
- $download_button_code = sdm_get_password_entry_form($id, $args);
89
  }
90
 
91
  // Get item thumbnail
@@ -100,13 +100,12 @@ function sdm_generate_fancy2_display_output($args) {
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">';
@@ -116,7 +115,7 @@ function sdm_generate_fancy2_display_output($args) {
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">';
122
  $output .= '<span class="sdm_fancy2_download_size_label">' . __('Size: ', 'simple-download-monitor') . '</span>';
@@ -130,11 +129,11 @@ function sdm_generate_fancy2_display_output($args) {
130
  $output .= '<span class="sdm_fancy2_download_version_value">' . $isset_item_version . '</span>';
131
  $output .= '</div>';
132
  }
133
-
134
  $output .= '<div class="sdm_fancy2_download_link">' . $download_button_code . '</div>';
135
 
136
  $output .= '</div>'; //end .sdm_fancy2_item
137
  $output .= '</div>'; //end .sdm_fancy2_wrapper
138
 
139
  return $output;
140
- }
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
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
55
  function sdm_generate_fancy2_display_output($args) {
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
+ ), $args)
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
 
85
  $get_cpt_object = get_post($id);
86
  $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
87
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
88
+ $download_button_code = sdm_get_password_entry_form($id, $shortcode_atts, 'sdm_fancy2_download');
89
  }
90
 
91
  // Get item thumbnail
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
  //Get item version
105
  $item_version = get_post_meta($id, 'sdm_item_version', true);
106
+ $isset_item_version = ($show_version && isset($item_version)) ? $item_version : ''; //check if show_version is enabled and if there is a version value
107
+
108
 
 
109
  $output = '';
110
  $output .= '<div class="sdm_fancy2_item ' . $css_class . '">';
111
  $output .= '<div class="sdm_fancy2_wrapper">';
115
  $output .= '</div>'; //End of .sdm_download_item_top
116
 
117
  $output .= '<div class="sdm_fancy2_download_title">' . $item_title . '</div>';
118
+
119
  if (!empty($isset_item_file_size)) {//Show file size info if specified in the shortcode
120
  $output .= '<div class="sdm_fancy2_download_size">';
121
  $output .= '<span class="sdm_fancy2_download_size_label">' . __('Size: ', 'simple-download-monitor') . '</span>';
129
  $output .= '<span class="sdm_fancy2_download_version_value">' . $isset_item_version . '</span>';
130
  $output .= '</div>';
131
  }
132
+
133
  $output .= '<div class="sdm_fancy2_download_link">' . $download_button_code . '</div>';
134
 
135
  $output .= '</div>'; //end .sdm_fancy2_item
136
  $output .= '</div>'; //end .sdm_fancy2_wrapper
137
 
138
  return $output;
139
+ }
langs/simple-download-monitor.pot DELETED
@@ -1,511 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: SDM 3.1\n"
4
- "POT-Creation-Date: 2014-07-29 12:06+1000\n"
5
- "PO-Revision-Date: 2014-07-29 12:06+1000\n"
6
- "Last-Translator: \n"
7
- "Language-Team: \n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "X-Generator: Poedit 1.5.7\n"
12
- "X-Poedit-KeywordsList: __;_e\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: C:\\Users\\amin\\Desktop\\simple-download-monitor\n"
15
-
16
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:91
17
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:310
18
- msgid "Settings"
19
- msgstr ""
20
-
21
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:145
22
- msgid "Image Successfully Removed"
23
- msgstr ""
24
-
25
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:146
26
- msgid "Error with AJAX"
27
- msgstr ""
28
-
29
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
30
- msgid "Please select a Download Item:"
31
- msgstr ""
32
-
33
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
34
- msgid "Download Title"
35
- msgstr ""
36
-
37
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
38
- msgid "Include Fancy Box"
39
- msgstr ""
40
-
41
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:156
42
- msgid "Insert SDM Shortcode"
43
- msgstr ""
44
-
45
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:166
46
- msgid "Incorrect Password"
47
- msgstr ""
48
-
49
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:182
50
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:183
51
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:188
52
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:194
53
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:590
54
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1034
55
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:48
56
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:94
57
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:87
58
- msgid "Downloads"
59
- msgstr ""
60
-
61
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:184
62
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:185
63
- msgid "Add New"
64
- msgstr ""
65
-
66
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:186
67
- msgid "Edit Download"
68
- msgstr ""
69
-
70
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:187
71
- msgid "New Download"
72
- msgstr ""
73
-
74
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:189
75
- msgid "View Download"
76
- msgstr ""
77
-
78
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:190
79
- msgid "Search Downloads"
80
- msgstr ""
81
-
82
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:191
83
- msgid "No Downloads found"
84
- msgstr ""
85
-
86
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:192
87
- msgid "No Downloads found in Trash"
88
- msgstr ""
89
-
90
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:193
91
- msgid "Parent Download"
92
- msgstr ""
93
-
94
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:221
95
- msgid "Search Categories"
96
- msgstr ""
97
-
98
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:222
99
- msgid "All Categories"
100
- msgstr ""
101
-
102
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:223
103
- msgid "Categories Genre"
104
- msgstr ""
105
-
106
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:224
107
- msgid "Categories Genre:"
108
- msgstr ""
109
-
110
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:225
111
- msgid "Edit Category"
112
- msgstr ""
113
-
114
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:226
115
- msgid "Update Category"
116
- msgstr ""
117
-
118
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:227
119
- msgid "Add New Category"
120
- msgstr ""
121
-
122
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:228
123
- msgid "New Category"
124
- msgstr ""
125
-
126
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:229
127
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1032
128
- msgid "Categories"
129
- msgstr ""
130
-
131
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:246
132
- msgid "Search Tags"
133
- msgstr ""
134
-
135
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:247
136
- msgid "All Tags"
137
- msgstr ""
138
-
139
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:248
140
- msgid "Tags Genre"
141
- msgstr ""
142
-
143
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:249
144
- msgid "Tags Genre:"
145
- msgstr ""
146
-
147
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:250
148
- msgid "Edit Tag"
149
- msgstr ""
150
-
151
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:251
152
- msgid "Update Tag"
153
- msgstr ""
154
-
155
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:252
156
- msgid "Add New Tag"
157
- msgstr ""
158
-
159
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:253
160
- msgid "New Tag"
161
- msgstr ""
162
-
163
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:254
164
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1033
165
- msgid "Tags"
166
- msgstr ""
167
-
168
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:309
169
- msgid "Logs"
170
- msgstr ""
171
-
172
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:317
173
- msgid "Simple Download Monitor Settings Page"
174
- msgstr ""
175
-
176
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:320
177
- msgid "Follow us"
178
- msgstr ""
179
-
180
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:320
181
- msgid ""
182
- "on Twitter, Google+ or via Email to stay upto date about the new features of "
183
- "this plugin."
184
- msgstr ""
185
-
186
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:329
187
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:528
188
- msgid "Admin Options"
189
- msgstr ""
190
-
191
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:332
192
- msgid "Control various plugin features."
193
- msgstr ""
194
-
195
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:349
196
- msgid "Color Options"
197
- msgstr ""
198
-
199
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:352
200
- msgid "Adjust color options"
201
- msgstr ""
202
-
203
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:370
204
- msgid ""
205
- "If you need a feature rich and supported plugin for selling your digital "
206
- "items then checkout our"
207
- msgstr ""
208
-
209
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:370
210
- msgid "WP eStore Plugin"
211
- msgstr ""
212
-
213
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:383
214
- msgid "Description"
215
- msgstr ""
216
-
217
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:385
218
- msgid "Upload File"
219
- msgstr ""
220
-
221
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:387
222
- msgid "File Thumbnail (Optional)"
223
- msgstr ""
224
-
225
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:389
226
- msgid "Shortcodes"
227
- msgstr ""
228
-
229
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:391
230
- msgid "Statistics"
231
- msgstr ""
232
-
233
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:396
234
- msgid "Add a description for this download item."
235
- msgstr ""
236
-
237
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:409
238
- msgid "Click \"Select File\" to upload (or choose) the file."
239
- msgstr ""
240
-
241
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:412
242
- msgid "Select File"
243
- msgstr ""
244
-
245
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:414
246
- msgid "File URL:"
247
- msgstr ""
248
-
249
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:422
250
- msgid ""
251
- "Click \"Select Image\" to upload (or choose) the file thumbnail image. This "
252
- "thumbnail image will be used to create a fancy file download box if you want "
253
- "to use it."
254
- msgstr ""
255
-
256
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:427
257
- msgid "Select Image"
258
- msgstr ""
259
-
260
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:428
261
- msgid "Remove Image"
262
- msgstr ""
263
-
264
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:442
265
- msgid ""
266
- "This is the shortcode which can used on posts or pages to embed a download "
267
- "now button for this file. You can also use the shortcode inserter to add "
268
- "this shortcode to a post or page."
269
- msgstr ""
270
-
271
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:447
272
- msgid "This shortcode may be used as a download counter."
273
- msgstr ""
274
-
275
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:456
276
- msgid "These are the statistics for this download item."
277
- msgstr ""
278
-
279
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:461
280
- msgid "Number of Downloads:"
281
- msgstr ""
282
-
283
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:464
284
- msgid "Offset Count"
285
- msgstr ""
286
-
287
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:529
288
- msgid "Colors"
289
- msgstr ""
290
-
291
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:531
292
- msgid "Remove Tinymce Button"
293
- msgstr ""
294
-
295
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:532
296
- msgid "Download Button Color"
297
- msgstr ""
298
-
299
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:536
300
- msgid "Admin options settings"
301
- msgstr ""
302
-
303
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:540
304
- msgid "Front End colors settings"
305
- msgstr ""
306
-
307
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:546
308
- msgid "Removes the SDM Downloads button from the WP content editor."
309
- msgstr ""
310
-
311
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
312
- msgid "Green"
313
- msgstr ""
314
-
315
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
316
- msgid "Blue"
317
- msgstr ""
318
-
319
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
320
- msgid "Purple"
321
- msgstr ""
322
-
323
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
324
- msgid "Teal"
325
- msgstr ""
326
-
327
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
328
- msgid "Dark Blue"
329
- msgstr ""
330
-
331
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
332
- msgid "Black"
333
- msgstr ""
334
-
335
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
336
- msgid "Grey"
337
- msgstr ""
338
-
339
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
340
- msgid "Pink"
341
- msgstr ""
342
-
343
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
344
- msgid "Orange"
345
- msgstr ""
346
-
347
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:552
348
- msgid "White"
349
- msgstr ""
350
-
351
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:555
352
- msgid "current"
353
- msgstr ""
354
-
355
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:561
356
- msgid "Adjusts the color of the \"Download Now\" button."
357
- msgstr ""
358
-
359
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:589
360
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:48
361
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:94
362
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:87
363
- msgid "Download"
364
- msgstr ""
365
-
366
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:613
367
- msgid "Edit"
368
- msgstr ""
369
-
370
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:614
371
- msgid "Delete"
372
- msgstr ""
373
-
374
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:638
375
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1029
376
- msgid "Title"
377
- msgstr ""
378
-
379
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:639
380
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1031
381
- msgid "File"
382
- msgstr ""
383
-
384
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:640
385
- msgid "Visitor IP"
386
- msgstr ""
387
-
388
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:641
389
- msgid "Date"
390
- msgstr ""
391
-
392
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:642
393
- msgid "Country"
394
- msgstr ""
395
-
396
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:662
397
- msgid "Delete Permanently"
398
- msgstr ""
399
-
400
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:663
401
- msgid "Export All as Excel"
402
- msgstr ""
403
-
404
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:678
405
- msgid "Nope! Security check failed!"
406
- msgstr ""
407
-
408
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:686
409
- msgid "Download Export File"
410
- msgstr ""
411
-
412
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:693
413
- msgid "No entries were selected."
414
- msgstr ""
415
-
416
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:693
417
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:709
418
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:711
419
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:728
420
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:730
421
- msgid "Click to Dismiss"
422
- msgstr ""
423
-
424
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:709
425
- msgid "Entries Deleted!"
426
- msgstr ""
427
-
428
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:711
429
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:730
430
- msgid "Error"
431
- msgstr ""
432
-
433
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:728
434
- msgid "Entry Deleted!"
435
- msgstr ""
436
-
437
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:788
438
- msgid "Download Logs"
439
- msgstr ""
440
-
441
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:791
442
- msgid "This page lists all tracked downloads."
443
- msgstr ""
444
-
445
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:813
446
- msgid "Enter Password to Download:"
447
- msgstr ""
448
-
449
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:816
450
- msgid "Submit"
451
- msgstr ""
452
-
453
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:862
454
- msgid "Error! Failed to log the download request in the database table"
455
- msgstr ""
456
-
457
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:871
458
- msgid ""
459
- "Error! The URL value is empty. Please specify a correct URL value to "
460
- "redirect to!"
461
- msgstr ""
462
-
463
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1028
464
- msgid "Image"
465
- msgstr ""
466
-
467
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1030
468
- msgid "ID"
469
- msgstr ""
470
-
471
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1035
472
- msgid "Date Posted"
473
- msgstr ""
474
-
475
- #: C:\Users\amin\Desktop\simple-download-monitor/main.php:1036
476
- msgid "Visitor Country"
477
- msgstr ""
478
-
479
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:32
480
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:40
481
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:166
482
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:42
483
- msgid "green"
484
- msgstr ""
485
-
486
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-post-type-content-handler.php:37
487
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:48
488
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:174
489
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:53
490
- #: C:\Users\amin\Desktop\simple-download-monitor/includes/templates/fancy2/sdm-fancy-2.php:57
491
- msgid "Download Now!"
492
- msgstr ""
493
-
494
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:27
495
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:88
496
- msgid "Error! Please enter an ID value with this shortcode."
497
- msgstr ""
498
-
499
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:118
500
- msgid ""
501
- "Error! You must enter a category slug OR a category id with this shortcode. "
502
- "Refer to the documentation for usage instructions."
503
- msgstr ""
504
-
505
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:122
506
- msgid "Error! Please enter a category slug OR id; not both."
507
- msgstr ""
508
-
509
- #: C:\Users\amin\Desktop\simple-download-monitor/sdm-shortcodes.php:153
510
- msgid "There are no download items matching this category criteria."
511
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{langs → languages}/simple-download-monitor-de_DE.mo RENAMED
File without changes
{langs → languages}/simple-download-monitor-de_DE.po RENAMED
File without changes
{langs → languages}/simple-download-monitor-es_ES.mo RENAMED
File without changes
{langs → languages}/simple-download-monitor-es_ES.po RENAMED
File without changes
{langs → languages}/simple-download-monitor-fr_FR.mo RENAMED
File without changes
{langs → languages}/simple-download-monitor-fr_FR.po RENAMED
File without changes
{langs → languages}/simple-download-monitor-it_IT.mo RENAMED
File without changes
{langs → languages}/simple-download-monitor-it_IT.po RENAMED
File without changes
{langs → languages}/simple-download-monitor-nl_NL.mo RENAMED
File without changes
{langs → languages}/simple-download-monitor-nl_NL.po RENAMED
File without changes
{langs → languages}/simple-download-monitor-pt_BR.mo RENAMED
File without changes
{langs → languages}/simple-download-monitor-pt_BR.po RENAMED
File without changes
{langs → languages}/simple-download-monitor-ru_RU.mo RENAMED
File without changes
{langs → languages}/simple-download-monitor-ru_RU.po RENAMED
File without changes
languages/simple-download-monitor.pot ADDED
@@ -0,0 +1,843 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Simple Download Monitor\n"
4
+ "POT-Creation-Date: 2017-12-26 16:36+1000\n"
5
+ "PO-Revision-Date: 2017-12-26 16:36+1000\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.7\n"
12
+ "X-Poedit-KeywordsList: __;_e\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "X-Poedit-SearchPath-0: .\n"
15
+
16
+ #: simple-download-monitor/main.php:179
17
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:11
18
+ msgid "Settings"
19
+ msgstr ""
20
+
21
+ #: simple-download-monitor/main.php:234 simple-download-monitor/main.php:317
22
+ msgid "Select File"
23
+ msgstr ""
24
+
25
+ #: simple-download-monitor/main.php:235
26
+ msgid "Select Thumbnail"
27
+ msgstr ""
28
+
29
+ #: simple-download-monitor/main.php:236
30
+ msgid "Insert"
31
+ msgstr ""
32
+
33
+ #: simple-download-monitor/main.php:237
34
+ msgid "Image Successfully Removed"
35
+ msgstr ""
36
+
37
+ #: simple-download-monitor/main.php:238
38
+ msgid "Error with AJAX"
39
+ msgstr ""
40
+
41
+ #: simple-download-monitor/main.php:249
42
+ msgid "Please select a Download Item:"
43
+ msgstr ""
44
+
45
+ #: simple-download-monitor/main.php:250
46
+ msgid "Download Title"
47
+ msgstr ""
48
+
49
+ #: simple-download-monitor/main.php:251
50
+ msgid "Include Fancy Box"
51
+ msgstr ""
52
+
53
+ #: simple-download-monitor/main.php:252
54
+ msgid "Open New Window"
55
+ msgstr ""
56
+
57
+ #: simple-download-monitor/main.php:253
58
+ msgid "Button Color"
59
+ msgstr ""
60
+
61
+ #: simple-download-monitor/main.php:254
62
+ msgid "Insert SDM Shortcode"
63
+ msgstr ""
64
+
65
+ #: simple-download-monitor/main.php:285
66
+ msgid "Description"
67
+ msgstr ""
68
+
69
+ #: simple-download-monitor/main.php:286
70
+ msgid "Downloadable File (Visitors will download this item)"
71
+ msgstr ""
72
+
73
+ #: simple-download-monitor/main.php:287
74
+ msgid "PHP Dispatch or Redirect"
75
+ msgstr ""
76
+
77
+ #: simple-download-monitor/main.php:288
78
+ msgid "File Thumbnail (Optional)"
79
+ msgstr ""
80
+
81
+ #: simple-download-monitor/main.php:289
82
+ msgid "Statistics"
83
+ msgstr ""
84
+
85
+ #: simple-download-monitor/main.php:290
86
+ msgid "Other Details (Optional)"
87
+ msgstr ""
88
+
89
+ #: simple-download-monitor/main.php:291
90
+ msgid "Shortcodes"
91
+ msgstr ""
92
+
93
+ #: simple-download-monitor/main.php:295
94
+ msgid "Add a description for this download item."
95
+ msgstr ""
96
+
97
+ #: simple-download-monitor/main.php:309
98
+ msgid ""
99
+ "Manually enter a valid URL of the file in the text box below, or click "
100
+ "\"Select File\" button to upload (or choose) the downloadable file."
101
+ msgstr ""
102
+
103
+ #: simple-download-monitor/main.php:320
104
+ msgid "Steps to upload a file or choose one from your media library:"
105
+ msgstr ""
106
+
107
+ #: simple-download-monitor/main.php:345
108
+ msgid ""
109
+ "Dispatch the file via PHP directly instead of redirecting to it. PHP "
110
+ "Dispatching keeps the download URL hidden. Dispatching works only for local "
111
+ "files (files that you uploaded to this site via this plugin or media "
112
+ "library)."
113
+ msgstr ""
114
+
115
+ #: simple-download-monitor/main.php:353
116
+ msgid ""
117
+ "Manually enter a valid URL, or click \"Select Image\" to upload (or choose) "
118
+ "the file thumbnail image."
119
+ msgstr ""
120
+
121
+ #: simple-download-monitor/main.php:358
122
+ msgid "Select Image"
123
+ msgstr ""
124
+
125
+ #: simple-download-monitor/main.php:359
126
+ msgid "Remove Image"
127
+ msgstr ""
128
+
129
+ #: simple-download-monitor/main.php:373
130
+ msgid ""
131
+ "This thumbnail image will be used to create a fancy file download box if you "
132
+ "want to use it."
133
+ msgstr ""
134
+
135
+ #: simple-download-monitor/main.php:387
136
+ msgid "These are the statistics for this download item."
137
+ msgstr ""
138
+
139
+ #: simple-download-monitor/main.php:394
140
+ msgid "Number of Downloads:"
141
+ msgstr ""
142
+
143
+ #: simple-download-monitor/main.php:399
144
+ msgid "Offset Count: "
145
+ msgstr ""
146
+
147
+ #: simple-download-monitor/main.php:402
148
+ msgid ""
149
+ "Enter any positive or negative numerical value; to offset the download count "
150
+ "shown to the visitors (when using the download counter shortcode)."
151
+ msgstr ""
152
+
153
+ #: simple-download-monitor/main.php:409
154
+ msgid "Disable download logging for this item."
155
+ msgstr ""
156
+
157
+ #: simple-download-monitor/main.php:423
158
+ msgid "File Size: "
159
+ msgstr ""
160
+
161
+ #: simple-download-monitor/main.php:426
162
+ msgid ""
163
+ "Enter the size of this file (example value: 2.15 MB). You can show this "
164
+ "value in the fancy display by using a shortcode parameter."
165
+ msgstr ""
166
+
167
+ #: simple-download-monitor/main.php:430
168
+ #: simple-download-monitor/sdm-post-type-content-handler.php:94
169
+ #: simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:118
170
+ #: simple-download-monitor/includes/templates/fancy2/sdm-fancy-2.php:128
171
+ msgid "Version: "
172
+ msgstr ""
173
+
174
+ #: simple-download-monitor/main.php:433
175
+ msgid ""
176
+ "Enter the version number for this item if any (example value: v2.5.10). You "
177
+ "can show this value in the fancy display by using a shortcode parameter."
178
+ msgstr ""
179
+
180
+ #: simple-download-monitor/main.php:440
181
+ msgid ""
182
+ "The following shortcode can be used on posts or pages to embed a download "
183
+ "now button for this file. You can also use the shortcode inserter (in the "
184
+ "post editor) to add this shortcode to a post or page."
185
+ msgstr ""
186
+
187
+ #: simple-download-monitor/main.php:446
188
+ msgid ""
189
+ "The following shortcode can be used to show a download counter for this item."
190
+ msgstr ""
191
+
192
+ #: simple-download-monitor/main.php:552
193
+ msgid "General Options"
194
+ msgstr ""
195
+
196
+ #: simple-download-monitor/main.php:553
197
+ msgid "Admin Options"
198
+ msgstr ""
199
+
200
+ #: simple-download-monitor/main.php:554
201
+ msgid "Colors"
202
+ msgstr ""
203
+
204
+ #: simple-download-monitor/main.php:555
205
+ msgid "Debug"
206
+ msgstr ""
207
+
208
+ #: simple-download-monitor/main.php:556
209
+ msgid "Delete Plugin Data"
210
+ msgstr ""
211
+
212
+ #: simple-download-monitor/main.php:559
213
+ msgid "Hide Download Count"
214
+ msgstr ""
215
+
216
+ #: simple-download-monitor/main.php:560
217
+ msgid "PHP Dispatching"
218
+ msgstr ""
219
+
220
+ #: simple-download-monitor/main.php:561
221
+ msgid "Only Allow Logged-in Users to Download"
222
+ msgstr ""
223
+
224
+ #: simple-download-monitor/main.php:562
225
+ msgid "Login Page URL"
226
+ msgstr ""
227
+
228
+ #: simple-download-monitor/main.php:564
229
+ msgid "Remove Tinymce Button"
230
+ msgstr ""
231
+
232
+ #: simple-download-monitor/main.php:565
233
+ msgid "Log Unique IP"
234
+ msgstr ""
235
+
236
+ #: simple-download-monitor/main.php:566
237
+ msgid "Do Not Count Downloads from Bots"
238
+ msgstr ""
239
+
240
+ #: simple-download-monitor/main.php:567
241
+ msgid "Disable Download Logs"
242
+ msgstr ""
243
+
244
+ #: simple-download-monitor/main.php:569
245
+ msgid "Download Button Color"
246
+ msgstr ""
247
+
248
+ #: simple-download-monitor/main.php:571
249
+ msgid "Enable Debug"
250
+ msgstr ""
251
+
252
+ #: simple-download-monitor/main.php:576
253
+ msgid "General options settings"
254
+ msgstr ""
255
+
256
+ #: simple-download-monitor/main.php:581
257
+ msgid "Admin options settings"
258
+ msgstr ""
259
+
260
+ #: simple-download-monitor/main.php:586
261
+ msgid "Front End colors settings"
262
+ msgstr ""
263
+
264
+ #: simple-download-monitor/main.php:591
265
+ msgid "Debug settings"
266
+ msgstr ""
267
+
268
+ #: simple-download-monitor/main.php:596
269
+ msgid ""
270
+ "You can delete all the data related to this plugin from database using the "
271
+ "button below. Useful when you're uninstalling the plugin and don't want any "
272
+ "leftovers remaining."
273
+ msgstr ""
274
+
275
+ #: simple-download-monitor/main.php:597
276
+ msgid "Warning"
277
+ msgstr ""
278
+
279
+ #: simple-download-monitor/main.php:597
280
+ msgid ""
281
+ "this can't be undone. All settings, download items, download logs will be "
282
+ "deleted."
283
+ msgstr ""
284
+
285
+ #: simple-download-monitor/main.php:598
286
+ msgid "Delete all data and deactivate plugin"
287
+ msgstr ""
288
+
289
+ #: simple-download-monitor/main.php:604
290
+ msgid "Hide the download count that is shown in some of the fancy templates."
291
+ msgstr ""
292
+
293
+ #: simple-download-monitor/main.php:611
294
+ msgid ""
295
+ "When you create a new download item, The PHP Dispatching option should be "
296
+ "enabled by default. PHP Dispatching keeps the URL of the downloadable files "
297
+ "hidden."
298
+ msgstr ""
299
+
300
+ #: simple-download-monitor/main.php:618
301
+ msgid ""
302
+ "Enable this option if you want to allow downloads only for logged-in users. "
303
+ "When enabled, anonymous users clicking on the download button will receive "
304
+ "an error message."
305
+ msgstr ""
306
+
307
+ #: simple-download-monitor/main.php:625
308
+ msgid ""
309
+ "(Optional) Specify a login page URL where users can login. This is useful if "
310
+ "you only allow logged in users to be able to download. This link will be "
311
+ "added to the message that is shown to anonymous users."
312
+ msgstr ""
313
+
314
+ #: simple-download-monitor/main.php:631
315
+ msgid "Removes the SDM Downloads button from the WP content editor."
316
+ msgstr ""
317
+
318
+ #: simple-download-monitor/main.php:637
319
+ msgid "Only logs downloads from unique IP addresses."
320
+ msgstr ""
321
+
322
+ #: simple-download-monitor/main.php:643
323
+ msgid "When enabled, the plugin won't count and log downloads from bots."
324
+ msgstr ""
325
+
326
+ #: simple-download-monitor/main.php:649
327
+ msgid ""
328
+ "Disables all download logs. (This global option overrides the individual "
329
+ "download item option.)"
330
+ msgstr ""
331
+
332
+ #: simple-download-monitor/main.php:669
333
+ msgid "Check this option to enable debug logging."
334
+ msgstr ""
335
+
336
+ #: simple-download-monitor/main.php:671 simple-download-monitor/main.php:673
337
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:28
338
+ msgid "Click here"
339
+ msgstr ""
340
+
341
+ #: simple-download-monitor/main.php:672
342
+ msgid " to view log file."
343
+ msgstr ""
344
+
345
+ #: simple-download-monitor/main.php:674
346
+ msgid " to reset log file."
347
+ msgstr ""
348
+
349
+ #: simple-download-monitor/main.php:712
350
+ msgid "Permission denied!"
351
+ msgstr ""
352
+
353
+ #: simple-download-monitor/main.php:787
354
+ msgid "Image"
355
+ msgstr ""
356
+
357
+ #: simple-download-monitor/main.php:788
358
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:70
359
+ msgid "Title"
360
+ msgstr ""
361
+
362
+ #: simple-download-monitor/main.php:789
363
+ msgid "ID"
364
+ msgstr ""
365
+
366
+ #: simple-download-monitor/main.php:790
367
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:71
368
+ msgid "File"
369
+ msgstr ""
370
+
371
+ #: simple-download-monitor/main.php:791
372
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:56
373
+ msgid "Categories"
374
+ msgstr ""
375
+
376
+ #: simple-download-monitor/main.php:792
377
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:80
378
+ msgid "Tags"
379
+ msgstr ""
380
+
381
+ #: simple-download-monitor/main.php:793
382
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:7
383
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:8
384
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:13
385
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:19
386
+ #: simple-download-monitor/sdm-post-type-content-handler.php:63
387
+ #: simple-download-monitor/sdm-shortcodes.php:141
388
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:20
389
+ #: simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:95
390
+ msgid "Downloads"
391
+ msgstr ""
392
+
393
+ #: simple-download-monitor/main.php:794
394
+ msgid "Date Posted"
395
+ msgstr ""
396
+
397
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:9
398
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:10
399
+ msgid "Add New"
400
+ msgstr ""
401
+
402
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:11
403
+ msgid "Edit Download"
404
+ msgstr ""
405
+
406
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:12
407
+ msgid "New Download"
408
+ msgstr ""
409
+
410
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:14
411
+ msgid "View Download"
412
+ msgstr ""
413
+
414
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:15
415
+ msgid "Search Downloads"
416
+ msgstr ""
417
+
418
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:16
419
+ msgid "No Downloads found"
420
+ msgstr ""
421
+
422
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:17
423
+ msgid "No Downloads found in Trash"
424
+ msgstr ""
425
+
426
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:18
427
+ msgid "Parent Download"
428
+ msgstr ""
429
+
430
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:48
431
+ msgid "Search Categories"
432
+ msgstr ""
433
+
434
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:49
435
+ msgid "All Categories"
436
+ msgstr ""
437
+
438
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:50
439
+ msgid "Categories Genre"
440
+ msgstr ""
441
+
442
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:51
443
+ msgid "Categories Genre:"
444
+ msgstr ""
445
+
446
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:52
447
+ msgid "Edit Category"
448
+ msgstr ""
449
+
450
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:53
451
+ msgid "Update Category"
452
+ msgstr ""
453
+
454
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:54
455
+ msgid "Add New Category"
456
+ msgstr ""
457
+
458
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:55
459
+ msgid "New Category"
460
+ msgstr ""
461
+
462
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:72
463
+ msgid "Search Tags"
464
+ msgstr ""
465
+
466
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:73
467
+ msgid "All Tags"
468
+ msgstr ""
469
+
470
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:74
471
+ msgid "Tags Genre"
472
+ msgstr ""
473
+
474
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:75
475
+ msgid "Tags Genre:"
476
+ msgstr ""
477
+
478
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:76
479
+ msgid "Edit Tag"
480
+ msgstr ""
481
+
482
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:77
483
+ msgid "Update Tag"
484
+ msgstr ""
485
+
486
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:78
487
+ msgid "Add New Tag"
488
+ msgstr ""
489
+
490
+ #: simple-download-monitor/sdm-post-type-and-taxonomy.php:79
491
+ msgid "New Tag"
492
+ msgstr ""
493
+
494
+ #: simple-download-monitor/sdm-post-type-content-handler.php:39
495
+ #: simple-download-monitor/includes/templates/fancy0/sdm-fancy-0.php:64
496
+ msgid "green"
497
+ msgstr ""
498
+
499
+ #: simple-download-monitor/sdm-post-type-content-handler.php:44
500
+ #: simple-download-monitor/sdm-shortcodes.php:61
501
+ #: simple-download-monitor/sdm-shortcodes.php:155
502
+ #: simple-download-monitor/includes/sdm-utility-functions.php:62
503
+ #: simple-download-monitor/includes/templates/fancy0/sdm-fancy-0.php:75
504
+ #: simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:43
505
+ #: simple-download-monitor/includes/templates/fancy2/sdm-fancy-2.php:60
506
+ msgid "Download Now!"
507
+ msgstr ""
508
+
509
+ #: simple-download-monitor/sdm-post-type-content-handler.php:63
510
+ #: simple-download-monitor/sdm-shortcodes.php:141
511
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:19
512
+ #: simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:95
513
+ msgid "Download"
514
+ msgstr ""
515
+
516
+ #: simple-download-monitor/sdm-post-type-content-handler.php:87
517
+ #: simple-download-monitor/includes/templates/fancy1/sdm-fancy-1.php:111
518
+ #: simple-download-monitor/includes/templates/fancy2/sdm-fancy-2.php:121
519
+ msgid "Size: "
520
+ msgstr ""
521
+
522
+ #: simple-download-monitor/sdm-shortcodes.php:74
523
+ #: simple-download-monitor/sdm-shortcodes.php:121
524
+ #: simple-download-monitor/sdm-shortcodes.php:135
525
+ msgid "Error! Please enter an ID value with this shortcode."
526
+ msgstr ""
527
+
528
+ #: simple-download-monitor/sdm-shortcodes.php:168
529
+ msgid ""
530
+ "Error! You must enter a category slug OR a category id with this shortcode. "
531
+ "Refer to the documentation for usage instructions."
532
+ msgstr ""
533
+
534
+ #: simple-download-monitor/sdm-shortcodes.php:173
535
+ msgid "Error! Please enter a category slug OR id; not both."
536
+ msgstr ""
537
+
538
+ #: simple-download-monitor/sdm-shortcodes.php:193
539
+ msgid ""
540
+ "Error! You must enter a numeric number for the \"pagination\" parameter of "
541
+ "the shortcode. Refer to the usage documentation."
542
+ msgstr ""
543
+
544
+ #: simple-download-monitor/sdm-shortcodes.php:220
545
+ msgid "There are no download items matching this category criteria."
546
+ msgstr ""
547
+
548
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:9
549
+ msgid "Logs"
550
+ msgstr ""
551
+
552
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:10
553
+ msgid "Stats"
554
+ msgstr ""
555
+
556
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:12
557
+ msgid "Add-ons"
558
+ msgstr ""
559
+
560
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:23
561
+ msgid "Simple Download Monitor Settings Page"
562
+ msgstr ""
563
+
564
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:27
565
+ msgid "follow us"
566
+ msgstr ""
567
+
568
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:27
569
+ msgid ""
570
+ "on Twitter, Google+ or via Email to stay upto date about the new features of "
571
+ "this plugin."
572
+ msgstr ""
573
+
574
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:86
575
+ msgid "Are you sure want to delete all plugin's data and deactivate plugin?"
576
+ msgstr ""
577
+
578
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:91
579
+ msgid ""
580
+ "Data has been deleted and plugin deactivated. Click OK to go to Plugins page."
581
+ msgstr ""
582
+
583
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:95
584
+ msgid "Error occured."
585
+ msgstr ""
586
+
587
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:118
588
+ msgid ""
589
+ "If you need a feature rich and supported plugin for selling your digital "
590
+ "items then checkout our"
591
+ msgstr ""
592
+
593
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:118
594
+ msgid "WP eStore Plugin"
595
+ msgstr ""
596
+
597
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:137
598
+ msgid "Log entries exported! Click on the following link to download the file."
599
+ msgstr ""
600
+
601
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:138
602
+ msgid "Download Logs CSV File"
603
+ msgstr ""
604
+
605
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:148
606
+ msgid "Download log entries deleted!"
607
+ msgstr ""
608
+
609
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:160
610
+ msgid "Download Logs"
611
+ msgstr ""
612
+
613
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:163
614
+ msgid "This page lists all tracked downloads."
615
+ msgstr ""
616
+
617
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:170
618
+ msgid "Export Download Log Entries"
619
+ msgstr ""
620
+
621
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:174
622
+ msgid "Export Log Entries to CSV File"
623
+ msgstr ""
624
+
625
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:181
626
+ msgid "Reset Download Log Entries"
627
+ msgstr ""
628
+
629
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:185
630
+ msgid "Reset Log Entries"
631
+ msgstr ""
632
+
633
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:249
634
+ msgid "Choose Date Range (yyyy-mm-dd)"
635
+ msgstr ""
636
+
637
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:253
638
+ msgid "Start Date: "
639
+ msgstr ""
640
+
641
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:254
642
+ msgid "End Date: "
643
+ msgstr ""
644
+
645
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:256
646
+ msgid "This Month"
647
+ msgstr ""
648
+
649
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:257
650
+ msgid "Last Month"
651
+ msgstr ""
652
+
653
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:258
654
+ msgid "This Year"
655
+ msgstr ""
656
+
657
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:259
658
+ msgid "Last Year"
659
+ msgstr ""
660
+
661
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:260
662
+ msgid "All Time"
663
+ msgstr ""
664
+
665
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:263
666
+ msgid "View Stats"
667
+ msgstr ""
668
+
669
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:269
670
+ msgid "Downloads by date"
671
+ msgstr ""
672
+
673
+ #: simple-download-monitor/includes/sdm-admin-menu-handler.php:270
674
+ msgid "Downloads by country"
675
+ msgstr ""
676
+
677
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:13
678
+ msgid "Error! Incorrect download item id."
679
+ msgstr ""
680
+
681
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:16
682
+ msgid "Error! This download item ("
683
+ msgstr ""
684
+
685
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:26
686
+ msgid "Error! This download requires a password."
687
+ msgstr ""
688
+
689
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:29
690
+ msgid " and enter a valid password for this item"
691
+ msgstr ""
692
+
693
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:35
694
+ msgid "Error! Incorrect password. This download requires a valid password."
695
+ msgstr ""
696
+
697
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:58
698
+ msgid "__Click here__ to go to login page."
699
+ msgstr ""
700
+
701
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:61
702
+ msgid "You need to be logged in to download this file."
703
+ msgstr ""
704
+
705
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:65
706
+ msgid "Not Logged In"
707
+ msgstr ""
708
+
709
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:123
710
+ msgid "Error! Failed to log the download request in the database table"
711
+ msgstr ""
712
+
713
+ #: simple-download-monitor/includes/sdm-download-request-handler.php:155
714
+ msgid ""
715
+ "Error! The URL value is empty. Please specify a correct URL value to "
716
+ "redirect to!"
717
+ msgstr ""
718
+
719
+ #: simple-download-monitor/includes/sdm-latest-downloads.php:43
720
+ msgid "There are no download items matching this shortcode criteria."
721
+ msgstr ""
722
+
723
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:45
724
+ msgid "Edit"
725
+ msgstr ""
726
+
727
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:46
728
+ msgid "Delete"
729
+ msgstr ""
730
+
731
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:72
732
+ msgid "Visitor IP"
733
+ msgstr ""
734
+
735
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:73
736
+ msgid "Date"
737
+ msgstr ""
738
+
739
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:74
740
+ msgid "Country"
741
+ msgstr ""
742
+
743
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:75
744
+ msgid "Username"
745
+ msgstr ""
746
+
747
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:96
748
+ msgid "Delete Permanently"
749
+ msgstr ""
750
+
751
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:111
752
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:142
753
+ msgid "Nope! Security check failed!"
754
+ msgstr ""
755
+
756
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:115
757
+ msgid "No entries were selected."
758
+ msgstr ""
759
+
760
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:115
761
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:129
762
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:131
763
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:151
764
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:153
765
+ msgid "Click to Dismiss"
766
+ msgstr ""
767
+
768
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:122
769
+ msgid "Error! The row id value of a log entry must be numeric."
770
+ msgstr ""
771
+
772
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:129
773
+ msgid "Entries Deleted!"
774
+ msgstr ""
775
+
776
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:131
777
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:153
778
+ msgid "Error"
779
+ msgstr ""
780
+
781
+ #: simple-download-monitor/includes/sdm-logs-list-table.php:151
782
+ msgid "Entry Deleted!"
783
+ msgstr ""
784
+
785
+ #: simple-download-monitor/includes/sdm-search-shortcode-handler.php:65
786
+ msgid "Showing search results for "
787
+ msgstr ""
788
+
789
+ #: simple-download-monitor/includes/sdm-search-shortcode-handler.php:66
790
+ msgid "Number of items found: "
791
+ msgstr ""
792
+
793
+ #: simple-download-monitor/includes/sdm-search-shortcode-handler.php:67
794
+ msgid "Keywords searched: "
795
+ msgstr ""
796
+
797
+ #: simple-download-monitor/includes/sdm-search-shortcode-handler.php:70
798
+ msgid "Nothing found for "
799
+ msgstr ""
800
+
801
+ #: simple-download-monitor/includes/sdm-utility-functions.php:9
802
+ msgid "Green"
803
+ msgstr ""
804
+
805
+ #: simple-download-monitor/includes/sdm-utility-functions.php:10
806
+ msgid "Blue"
807
+ msgstr ""
808
+
809
+ #: simple-download-monitor/includes/sdm-utility-functions.php:11
810
+ msgid "Purple"
811
+ msgstr ""
812
+
813
+ #: simple-download-monitor/includes/sdm-utility-functions.php:12
814
+ msgid "Teal"
815
+ msgstr ""
816
+
817
+ #: simple-download-monitor/includes/sdm-utility-functions.php:13
818
+ msgid "Dark Blue"
819
+ msgstr ""
820
+
821
+ #: simple-download-monitor/includes/sdm-utility-functions.php:14
822
+ msgid "Black"
823
+ msgstr ""
824
+
825
+ #: simple-download-monitor/includes/sdm-utility-functions.php:15
826
+ msgid "Grey"
827
+ msgstr ""
828
+
829
+ #: simple-download-monitor/includes/sdm-utility-functions.php:16
830
+ msgid "Pink"
831
+ msgstr ""
832
+
833
+ #: simple-download-monitor/includes/sdm-utility-functions.php:17
834
+ msgid "Orange"
835
+ msgstr ""
836
+
837
+ #: simple-download-monitor/includes/sdm-utility-functions.php:18
838
+ msgid "White"
839
+ msgstr ""
840
+
841
+ #: simple-download-monitor/includes/sdm-utility-functions.php:69
842
+ msgid "Enter Password to Download:"
843
+ msgstr ""
main.php CHANGED
@@ -3,16 +3,19 @@
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
- * Version: 3.4.8
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
 
 
10
  */
 
11
  if (!defined('ABSPATH')) {
12
  exit;
13
  }
14
 
15
- define('WP_SIMPLE_DL_MONITOR_VERSION', '3.4.8');
16
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
17
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
18
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
@@ -90,9 +93,9 @@ function sdm_init_time_tasks() {
90
  //Handle download request if any
91
  handle_sdm_download_via_direct_post();
92
  if (is_admin()) {
93
- //Register Google Charts library
94
- wp_register_script('sdm_google_charts', 'https://www.gstatic.com/charts/loader.js', array(), null, true);
95
- wp_register_style('sdm_jquery_ui_style', WP_SIMPLE_DL_MONITOR_URL . '/css/jquery.ui.min.css', array(), null, 'all');
96
  }
97
  }
98
 
@@ -102,17 +105,17 @@ function sdm_admin_init_time_tasks() {
102
  add_action('wp_ajax_sdm_delete_data', 'sdm_delete_data_handler');
103
 
104
  if (is_admin()) {
105
- if (user_can(wp_get_current_user(), 'administrator')) {
106
- // user is an admin
107
- if (isset($_GET['sdm-action'])) {
108
- if ($_GET['sdm-action'] === 'view_log') {
109
- $logfile = fopen(WP_SDM_LOG_FILE, 'rb');
110
- header('Content-Type: text/plain');
111
- fpassthru($logfile);
112
- die;
113
- }
114
- }
115
- }
116
  }
117
  }
118
 
@@ -124,16 +127,16 @@ function sdm_reset_log_handler() {
124
 
125
  function sdm_delete_data_handler() {
126
  if (!check_ajax_referer('sdm_delete_data', 'nonce', false)) {
127
- //nonce check failed
128
- wp_die(0);
129
  }
130
  global $wpdb;
131
  //let's find and delete smd_download posts and meta
132
  $posts = $wpdb->get_results('SELECT id FROM ' . $wpdb->prefix . 'posts WHERE post_type="sdm_downloads"', ARRAY_A);
133
  if (!is_null($posts)) {
134
- foreach ($posts as $post) {
135
- wp_delete_post($post['id'], true);
136
- }
137
  }
138
  //let's delete options
139
  delete_option('sdm_downloads_options');
@@ -158,11 +161,11 @@ function sdm_delete_data_handler() {
158
 
159
  function sdm_db_update_check() {
160
  if (is_admin()) {//Check if DB needs to be upgraded
161
- global $sdm_db_version;
162
- $inst_db_version = get_option('sdm_db_version');
163
- if ($inst_db_version != $sdm_db_version) {
164
- sdm_install_db_table();
165
- }
166
  }
167
  }
168
 
@@ -174,10 +177,10 @@ add_filter('plugin_action_links', 'sdm_settings_link', 10, 2);
174
  function sdm_settings_link($links, $file) {
175
  static $this_plugin;
176
  if (!$this_plugin)
177
- $this_plugin = plugin_basename(__FILE__);
178
  if ($file == $this_plugin) {
179
- $settings_link = '<a href="edit.php?post_type=sdm_downloads&page=settings" title="SDM Settings Page">' . __("Settings", 'simple-download-monitor') . '</a>';
180
- array_unshift($links, $settings_link);
181
  }
182
  return $links;
183
  }
@@ -187,484 +190,501 @@ class simpleDownloadManager {
187
 
188
  public function __construct() {
189
 
190
- add_action('init', 'sdm_register_post_type'); // Create 'sdm_downloads' custom post type
191
- add_action('init', 'sdm_create_taxonomies'); // Register 'tags' and 'categories' taxonomies
192
- add_action('init', 'sdm_register_shortcodes'); //Register the shortcodes
193
- add_action('wp_enqueue_scripts', array($this, 'sdm_frontend_scripts')); // Register frontend scripts
194
 
195
- if (is_admin()) {
196
- add_action('admin_menu', array($this, 'sdm_create_menu_pages')); // Create admin pages
197
- add_action('add_meta_boxes', array($this, 'sdm_create_upload_metabox')); // Create metaboxes
198
 
199
- add_action('save_post', array($this, 'sdm_save_description_meta_data')); // Save 'description' metabox
200
- add_action('save_post', array($this, 'sdm_save_upload_meta_data')); // Save 'upload file' metabox
201
- add_action('save_post', array($this, 'sdm_save_dispatch_meta_data')); // Save 'dispatch' metabox
202
- add_action('save_post', array($this, 'sdm_save_thumbnail_meta_data')); // Save 'thumbnail' metabox
203
- add_action('save_post', array($this, 'sdm_save_statistics_meta_data')); // Save 'statistics' metabox
204
- add_action('save_post', array($this, 'sdm_save_other_details_meta_data')); // Save 'other details' metabox
205
 
206
- add_action('admin_enqueue_scripts', array($this, 'sdm_admin_scripts')); // Register admin scripts
207
- add_action('admin_print_styles', array($this, 'sdm_admin_styles')); // Register admin styles
208
 
209
- add_action('admin_init', array($this, 'sdm_register_options')); // Register admin options
210
- //add_filter('post_row_actions', array($this, 'sdm_remove_view_link_cpt'), 10, 2); // Remove 'View' link in all downloads list view
211
- }
212
  }
213
 
214
  public function sdm_admin_scripts() {
215
 
216
- global $current_screen, $post;
217
-
218
- if (is_admin() && $current_screen->post_type == 'sdm_downloads' && $current_screen->base == 'post') {
219
-
220
- // These scripts are needed for the media upload thickbox
221
- wp_enqueue_script('media-upload');
222
- wp_enqueue_script('thickbox');
223
- wp_register_script('sdm-upload', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_admin_scripts.js', array('jquery', 'media-upload', 'thickbox'), WP_SIMPLE_DL_MONITOR_VERSION);
224
- wp_enqueue_script('sdm-upload');
225
-
226
- // Pass postID for thumbnail deletion
227
- ?>
228
- <script type="text/javascript">
229
- var sdm_del_thumb_postid = '<?php echo $post->ID; ?>';
230
- </script>
231
- <?php
232
- // Localize langauge strings used in js file
233
- $sdmTranslations = array(
234
- 'select_file' => __('Select File', 'simple-download-monitor'),
235
- 'select_thumbnail' => __('Select Thumbnail', 'simple-download-monitor'),
236
- 'insert' => __('Insert', 'simple-download-monitor'),
237
- 'image_removed' => __('Image Successfully Removed', 'simple-download-monitor'),
238
- 'ajax_error' => __('Error with AJAX', 'simple-download-monitor')
239
- );
240
- wp_localize_script('sdm-upload', 'sdm_translations', $sdmTranslations);
241
- }
242
-
243
- // Pass admin ajax url
244
- ?>
245
- <script type="text/javascript">
246
- var sdm_admin_ajax_url = {sdm_admin_ajax_url: '<?php echo admin_url('admin-ajax.php?action=ajax'); ?>'};
247
- var sdm_plugin_url = '<?php echo plugins_url(); ?>';
248
- var tinymce_langs = {
249
- select_download_item: '<?php _e('Please select a Download Item:', 'simple-download-monitor') ?>',
250
- download_title: '<?php _e('Download Title', 'simple-download-monitor') ?>',
251
- include_fancy: '<?php _e('Include Fancy Box', 'simple-download-monitor') ?>',
252
- open_new_window: '<?php _e('Open New Window', 'simple-download-monitor') ?>',
253
- button_color: '<?php _e('Button Color', 'simple-download-monitor'); ?>',
254
- insert_shortcode: '<?php _e('Insert SDM Shortcode', 'simple-download-monitor') ?>'
255
- };
256
- var sdm_button_colors = <?php echo wp_json_encode(sdm_get_download_button_colors()); ?>;
257
- </script>
258
- <?php
259
  }
260
 
261
  public function sdm_frontend_scripts() {
262
- //Use this function to enqueue fron-end js scripts.
263
- wp_enqueue_style('sdm-styles', WP_SIMPLE_DL_MONITOR_URL . '/css/sdm_wp_styles.css');
264
- wp_register_script('sdm-scripts', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_wp_scripts.js', array('jquery'));
265
- wp_enqueue_script('sdm-scripts');
266
 
267
- // Localize ajax script for frontend
268
- wp_localize_script('sdm-scripts', 'sdm_ajax_script', array('ajaxurl' => admin_url('admin-ajax.php')));
269
  }
270
 
271
  public function sdm_admin_styles() {
272
 
273
- wp_enqueue_style('thickbox'); // Needed for media upload thickbox
274
- 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
275
  }
276
 
277
  public function sdm_create_menu_pages() {
278
- include_once('includes/sdm-admin-menu-handler.php');
279
- sdm_handle_admin_menu();
280
  }
281
 
282
  public function sdm_create_upload_metabox() {
283
 
284
- //***** Create metaboxes for the custom post type
285
- add_meta_box('sdm_description_meta_box', __('Description', 'simple-download-monitor'), array($this, 'display_sdm_description_meta_box'), 'sdm_downloads', 'normal', 'default');
286
- add_meta_box('sdm_upload_meta_box', __('Downloadable File (Visitors will download this item)', 'simple-download-monitor'), array($this, 'display_sdm_upload_meta_box'), 'sdm_downloads', 'normal', 'default');
287
- add_meta_box('sdm_dispatch_meta_box', __('PHP Dispatch or Redirect', 'simple-download-monitor'), array($this, 'display_sdm_dispatch_meta_box'), 'sdm_downloads', 'normal', 'default');
288
- add_meta_box('sdm_thumbnail_meta_box', __('File Thumbnail (Optional)', 'simple-download-monitor'), array($this, 'display_sdm_thumbnail_meta_box'), 'sdm_downloads', 'normal', 'default');
289
- add_meta_box('sdm_stats_meta_box', __('Statistics', 'simple-download-monitor'), array($this, 'display_sdm_stats_meta_box'), 'sdm_downloads', 'normal', 'default');
290
- add_meta_box('sdm_other_details_meta_box', __('Other Details (Optional)', 'simple-download-monitor'), array($this, 'display_sdm_other_details_meta_box'), 'sdm_downloads', 'normal', 'default');
291
- add_meta_box('sdm_shortcode_meta_box', __('Shortcodes', 'simple-download-monitor'), array($this, 'display_sdm_shortcode_meta_box'), 'sdm_downloads', 'normal', 'default');
292
  }
293
 
294
  public function display_sdm_description_meta_box($post) { // Description metabox
295
- _e('Add a description for this download item.', 'simple-download-monitor');
296
- echo '<br /><br />';
297
 
298
- $old_description = get_post_meta($post->ID, 'sdm_description', true);
299
- $sdm_description_field = array('textarea_name' => 'sdm_description');
300
- wp_editor($old_description, "sdm_description_editor_content", $sdm_description_field);
301
 
302
- wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');
303
  }
304
 
305
  public function display_sdm_upload_meta_box($post) { // File Upload metabox
306
- $old_upload = get_post_meta($post->ID, 'sdm_upload', true);
307
- $old_value = isset($old_upload) ? $old_upload : '';
308
 
309
- _e('Manually enter a valid URL of the file in the text box below, or click "Select File" button to upload (or choose) the downloadable file.', 'simple-download-monitor');
310
- echo '<br /><br />';
311
 
312
- echo '<div class="sdm-download-edit-file-url-section">';
313
- echo '<input id="sdm_upload" type="text" size="100" name="sdm_upload" value="' . $old_value . '" placeholder="http://..." />';
314
- echo '</div>';
315
 
316
- echo '<br />';
317
- echo '<input id="upload_image_button" type="button" class="button-primary" value="' . __('Select File', 'simple-download-monitor') . '" />';
318
 
319
- echo '<br /><br />';
320
- _e('Steps to upload a file or choose one from your media library:', 'simple-download-monitor');
321
- echo '<ol>';
322
- echo '<li>Hit the "Select File" button.</li>';
323
- echo '<li>Upload a new file or choose an existing one from your media library.</li>';
324
- echo '<li>Click the "Insert" button, this will populate the uploaded file\'s URL in the above text field.</li>';
325
- echo '</ol>';
326
 
327
- wp_nonce_field('sdm_upload_box_nonce', 'sdm_upload_box_nonce_check');
328
  }
329
 
330
  public function display_sdm_dispatch_meta_box($post) {
331
- $dispatch = get_post_meta($post->ID, 'sdm_item_dispatch', true);
332
 
333
- if ($dispatch === '') {
334
- // No value yet (either new item or saved with older version of plugin)
335
- $screen = get_current_screen();
336
 
337
- if ($screen->action === 'add') {
338
- // New item: set default value as per plugin settings.
339
- $main_opts = get_option('sdm_downloads_options');
340
- $dispatch = isset($main_opts['general_default_dispatch_value']) && $main_opts['general_default_dispatch_value'];
341
- }
342
- }
343
 
344
- echo '<input id="sdm_item_dispatch" type="checkbox" name="sdm_item_dispatch" value="yes"' . checked(true, $dispatch, false) . ' />';
345
- echo '<label for="sdm_item_dispatch">' . __('Dispatch the file via PHP directly instead of redirecting to it. PHP Dispatching keeps the download URL hidden. Dispatching works only for local files (files that you uploaded to this site via this plugin or media library).', 'simple-download-monitor') . '</label>';
346
 
347
- wp_nonce_field('sdm_dispatch_box_nonce', 'sdm_dispatch_box_nonce_check');
348
  }
349
 
350
  public function display_sdm_thumbnail_meta_box($post) { // Thumbnail upload metabox
351
- $old_thumbnail = get_post_meta($post->ID, 'sdm_upload_thumbnail', true);
352
- $old_value = isset($old_thumbnail) ? $old_thumbnail : '';
353
- _e('Manually enter a valid URL, or click "Select Image" to upload (or choose) the file thumbnail image.', 'simple-download-monitor');
354
- ?>
355
- <br /><br />
356
- <input id="sdm_upload_thumbnail" type="text" size="100" name="sdm_upload_thumbnail" value="<?php echo $old_value; ?>" placeholder="http://..." />
357
- <br /><br />
358
- <input id="upload_thumbnail_button" type="button" class="button-primary" value="<?php _e('Select Image', 'simple-download-monitor'); ?>" />
359
- <input id="remove_thumbnail_button" type="button" class="button" value="<?php _e('Remove Image', 'simple-download-monitor'); ?>" />
360
- <br /><br />
361
-
362
- <span id="sdm_admin_thumb_preview">
363
- <?php
364
- if (!empty($old_value)) {
365
- ?><img id="sdm_thumbnail_image" src="<?php echo $old_value; ?>" style="max-width:200px;" />
366
- <?php
367
- }
368
- ?>
369
- </span>
370
-
371
- <?php
372
- echo '<p class="description">';
373
- _e('This thumbnail image will be used to create a fancy file download box if you want to use it.', 'simple-download-monitor');
374
- echo '</p>';
375
-
376
- wp_nonce_field('sdm_thumbnail_box_nonce', 'sdm_thumbnail_box_nonce_check');
377
  }
378
 
379
  public function display_sdm_stats_meta_box($post) { //Stats metabox
380
- $old_count = get_post_meta($post->ID, 'sdm_count_offset', true);
381
- $value = isset($old_count) && $old_count != '' ? $old_count : '0';
382
 
383
- // Get checkbox for "disable download logging"
384
- $no_logs = get_post_meta($post->ID, 'sdm_item_no_log', true);
385
- $checked = isset($no_logs) && $no_logs === 'on' ? 'checked="checked"' : '';
386
 
387
- _e('These are the statistics for this download item.', 'simple-download-monitor');
388
- echo '<br /><br />';
389
 
390
- global $wpdb;
391
- $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id=%s', $post->ID));
392
 
393
- echo '<div class="sdm-download-edit-dl-count">';
394
- _e('Number of Downloads:', 'simple-download-monitor');
395
- echo ' <strong>' . $wpdb->num_rows . '</strong>';
396
- echo '</div>';
397
 
398
- echo '<div class="sdm-download-edit-offset-count">';
399
- _e('Offset Count: ', 'simple-download-monitor');
400
- echo '<br />';
401
- echo ' <input type="text" size="10" name="sdm_count_offset" value="' . $value . '" />';
402
- echo '<p class="description">' . __('Enter any positive or negative numerical value; to offset the download count shown to the visitors (when using the download counter shortcode).', 'simple-download-monitor') . '</p>';
403
- echo '</div>';
404
 
405
- echo '<br />';
406
- echo '<div class="sdm-download-edit-disable-logging">';
407
- echo '<input type="checkbox" name="sdm_item_no_log" ' . $checked . ' />';
408
- echo '<span style="margin-left: 5px;"></span>';
409
- _e('Disable download logging for this item.', 'simple-download-monitor');
410
- echo '</div>';
411
 
412
- wp_nonce_field('sdm_count_offset_nonce', 'sdm_count_offset_nonce_check');
413
  }
414
 
415
  public function display_sdm_other_details_meta_box($post) { //Other details metabox
416
- $file_size = get_post_meta($post->ID, 'sdm_item_file_size', true);
417
- $file_size = isset($file_size) ? $file_size : '';
418
 
419
- $version = get_post_meta($post->ID, 'sdm_item_version', true);
420
- $version = isset($version) ? $version : '';
421
 
422
- echo '<div class="sdm-download-edit-filesize">';
423
- _e('File Size: ', 'simple-download-monitor');
424
- echo '<br />';
425
- echo ' <input type="text" name="sdm_item_file_size" value="' . $file_size . '" size="20" />';
426
- 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>';
427
- echo '</div>';
428
 
429
- echo '<div class="sdm-download-edit-version">';
430
- _e('Version: ', 'simple-download-monitor');
431
- echo '<br />';
432
- echo ' <input type="text" name="sdm_item_version" value="' . $version . '" size="20" />';
433
- 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>';
434
- echo '</div>';
435
 
436
- wp_nonce_field('sdm_other_details_nonce', 'sdm_other_details_nonce_check');
437
  }
438
 
439
  public function display_sdm_shortcode_meta_box($post) { //Shortcode metabox
440
- _e('The following shortcode can be used on posts or pages to embed a download now button for this file. You can also use the shortcode inserter (in the post editor) to add this shortcode to a post or page.', 'simple-download-monitor');
441
- echo '<br />';
442
- $shortcode_text = '[sdm_download id="' . $post->ID . '" fancy="0"]';
443
- echo "<input type='text' class='code' onfocus='this.select();' readonly='readonly' value='" . $shortcode_text . "' size='40'>";
444
- echo "<br /><br />";
445
 
446
- _e('The following shortcode can be used to show a download counter for this item.', 'simple-download-monitor');
447
- echo '<br />';
448
- $shortcode_text = '[sdm_download_counter id="' . $post->ID . '"]';
449
- echo "<input type='text' class='code' onfocus='this.select();' readonly='readonly' value='" . $shortcode_text . "' size='40'>";
450
 
451
- echo '<br /><br />';
452
- echo 'Read the full shortcode usage documentation <a href="https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin" target="_blank">here</a>.';
453
  }
454
 
455
  public function sdm_save_description_meta_data($post_id) { // Save Description metabox
456
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
457
- return;
458
- if (!isset($_POST['sdm_description_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_description_box_nonce_check'], 'sdm_description_box_nonce'))
459
- return;
460
-
461
- if (isset($_POST['sdm_description'])) {
462
- update_post_meta($post_id, 'sdm_description', $_POST['sdm_description']);
463
- }
 
464
  }
465
 
466
  public function sdm_save_upload_meta_data($post_id) { // Save File Upload metabox
467
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
468
- return;
469
- if (!isset($_POST['sdm_upload_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_upload_box_nonce_check'], 'sdm_upload_box_nonce'))
470
- return;
471
 
472
- if (isset($_POST['sdm_upload'])) {
473
- update_post_meta($post_id, 'sdm_upload', $_POST['sdm_upload']);
474
- }
475
  }
476
 
477
  public function sdm_save_dispatch_meta_data($post_id) { // Save "Dispatch or Redirect" metabox
478
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
479
- return;
480
- }
481
- if (!isset($_POST['sdm_dispatch_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_dispatch_box_nonce_check'], 'sdm_dispatch_box_nonce')) {
482
- return;
483
- }
484
- // Get POST-ed data as boolean value
485
- $value = filter_input(INPUT_POST, 'sdm_item_dispatch', FILTER_VALIDATE_BOOLEAN);
486
- update_post_meta($post_id, 'sdm_item_dispatch', $value);
487
  }
488
 
489
  public function sdm_save_thumbnail_meta_data($post_id) { // Save Thumbnail Upload metabox
490
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
491
- return;
492
- if (!isset($_POST['sdm_thumbnail_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_thumbnail_box_nonce_check'], 'sdm_thumbnail_box_nonce'))
493
- return;
494
-
495
- if (isset($_POST['sdm_upload_thumbnail'])) {
496
- update_post_meta($post_id, 'sdm_upload_thumbnail', $_POST['sdm_upload_thumbnail']);
497
- }
 
498
  }
499
 
500
  public function sdm_save_statistics_meta_data($post_id) { // Save Statistics Upload metabox
501
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
502
- return;
503
- if (!isset($_POST['sdm_count_offset_nonce_check']) || !wp_verify_nonce($_POST['sdm_count_offset_nonce_check'], 'sdm_count_offset_nonce'))
504
- return;
505
-
506
- if (isset($_POST['sdm_count_offset']) && is_numeric($_POST['sdm_count_offset'])) {
507
-
508
- update_post_meta($post_id, 'sdm_count_offset', $_POST['sdm_count_offset']);
509
- }
510
-
511
- // Checkbox for disabling download logging for this item
512
- if (isset($_POST['sdm_item_no_log'])) {
513
- update_post_meta($post_id, 'sdm_item_no_log', $_POST['sdm_item_no_log']);
514
- } else {
515
- delete_post_meta($post_id, 'sdm_item_no_log');
516
- }
517
  }
518
 
519
  public function sdm_save_other_details_meta_data($post_id) { // Save Statistics Upload metabox
520
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
521
- return;
522
- }
523
- if (!isset($_POST['sdm_other_details_nonce_check']) || !wp_verify_nonce($_POST['sdm_other_details_nonce_check'], 'sdm_other_details_nonce')) {
524
- return;
525
- }
526
 
527
- if (isset($_POST['sdm_item_file_size'])) {
528
- update_post_meta($post_id, 'sdm_item_file_size', $_POST['sdm_item_file_size']);
529
- }
530
 
531
- if (isset($_POST['sdm_item_version'])) {
532
- update_post_meta($post_id, 'sdm_item_version', $_POST['sdm_item_version']);
533
- }
534
  }
535
 
536
  public function sdm_remove_view_link_cpt($action, $post) {
537
 
538
- // Only execute on SDM CPT posts page
539
- if ($post->post_type == 'sdm_downloads') {
540
- unset($action['view']);
541
- }
542
 
543
- return $action;
544
  }
545
 
546
  public function sdm_register_options() {
547
 
548
- //Register the main setting
549
- register_setting('sdm_downloads_options', 'sdm_downloads_options');
550
 
551
- //Add all the settings section that will go under the main settings
552
- add_settings_section('general_options', __('General Options', 'simple-download-monitor'), array($this, 'general_options_cb'), 'general_options_section');
553
- add_settings_section('admin_options', __('Admin Options', 'simple-download-monitor'), array($this, 'admin_options_cb'), 'admin_options_section');
554
- add_settings_section('sdm_colors', __('Colors', 'simple-download-monitor'), array($this, 'sdm_colors_cb'), 'sdm_colors_section');
555
- add_settings_section('sdm_debug', __('Debug', 'simple-download-monitor'), array($this, 'sdm_debug_cb'), 'sdm_debug_section');
556
- add_settings_section('sdm_deldata', __('Delete Plugin Data', 'simple-download-monitor'), array($this, 'sdm_deldata_cb'), 'sdm_deldata_section');
557
 
558
- //Add all the individual settings fields that goes under the sections
559
- add_settings_field('general_hide_donwload_count', __('Hide Download Count', 'simple-download-monitor'), array($this, 'hide_download_count_cb'), 'general_options_section', 'general_options');
560
- add_settings_field('general_default_dispatch_value', __('PHP Dispatching', 'simple-download-monitor'), array($this, 'general_default_dispatch_value_cb'), 'general_options_section', 'general_options');
561
- add_settings_field('only_logged_in_can_download', __('Only Allow Logged-in Users to Download', 'simple-download-monitor'), array($this, 'general_only_logged_in_can_download_cb'), 'general_options_section', 'general_options');
562
- add_settings_field('general_login_page_url', __('Login Page URL', 'simple-download-monitor'), array($this, 'general_login_page_url_cb'), 'general_options_section', 'general_options');
563
 
564
- add_settings_field('admin_tinymce_button', __('Remove Tinymce Button', 'simple-download-monitor'), array($this, 'admin_tinymce_button_cb'), 'admin_options_section', 'admin_options');
565
- add_settings_field('admin_log_unique', __('Log Unique IP', 'simple-download-monitor'), array($this, 'admin_log_unique'), 'admin_options_section', 'admin_options');
566
- add_settings_field('admin_no_logs', __('Disable Download Logs', 'simple-download-monitor'), array($this, 'admin_no_logs_cb'), 'admin_options_section', 'admin_options');
 
 
567
 
568
- add_settings_field('download_button_color', __('Download Button Color', 'simple-download-monitor'), array($this, 'download_button_color_cb'), 'sdm_colors_section', 'sdm_colors');
569
 
570
- add_settings_field('enable_debug', __('Enable Debug', 'simple-download-monitor'), array($this, 'enable_debug_cb'), 'sdm_debug_section', 'sdm_debug');
571
  }
572
 
573
  public function general_options_cb() {
574
- //Set the message that will be shown below the general options settings heading
575
- _e('General options settings', 'simple-download-monitor');
576
  }
577
 
578
  public function admin_options_cb() {
579
- //Set the message that will be shown below the admin options settings heading
580
- _e('Admin options settings', 'simple-download-monitor');
581
  }
582
 
583
  public function sdm_colors_cb() {
584
- //Set the message that will be shown below the color options settings heading
585
- _e('Front End colors settings', 'simple-download-monitor');
586
  }
587
 
588
  public function sdm_debug_cb() {
589
- //Set the message that will be shown below the debug options settings heading
590
- _e('Debug settings', 'simple-download-monitor');
591
  }
592
 
593
  public function sdm_deldata_cb() {
594
- //Set the message that will be shown below the debug options settings heading
595
- _e('You can delete all the data related to this plugin from database using the button below. Useful when you\'re uninstalling the plugin and don\'t want any leftovers remaining.', 'simple-download-monitor');
596
- echo '<p><b>' . __('Warning', 'simple-download-monitor') . ': </b> ' . __('this can\'t be undone. All settings, download items, download logs will be deleted.', 'simple-download-monitor') . '</p>';
597
- echo '<p><button id="sdmDeleteData" class="button" style="color:red;">' . __('Delete all data and deactivate plugin', 'simple-download-monitor') . '</button></p>';
 
598
  }
599
 
600
  public function hide_download_count_cb() {
601
- $main_opts = get_option('sdm_downloads_options');
602
- echo '<input name="sdm_downloads_options[general_hide_donwload_count]" id="general_hide_download_count" type="checkbox" ' . checked(1, isset($main_opts['general_hide_donwload_count']), false) . ' /> ';
603
- echo '<label for="general_hide_download_count">' . __('Hide the download count that is shown in some of the fancy templates.', 'simple-download-monitor') . '</label>';
604
  }
605
 
606
  public function general_default_dispatch_value_cb() {
607
- $main_opts = get_option('sdm_downloads_options');
608
- $value = isset($main_opts['general_default_dispatch_value']) && $main_opts['general_default_dispatch_value'];
609
- echo '<input name="sdm_downloads_options[general_default_dispatch_value]" id="general_default_dispatch_value" type="checkbox" value="1"' . checked(true, $value, false) . ' />';
610
- echo '<label for="general_default_dispatch_value">' . __('When you create a new download item, The PHP Dispatching option should be enabled by default. PHP Dispatching keeps the URL of the downloadable files hidden.', 'simple-download-monitor') . '</label>';
611
  }
612
 
613
  public function general_only_logged_in_can_download_cb() {
614
- $main_opts = get_option('sdm_downloads_options');
615
- $value = isset($main_opts['only_logged_in_can_download']) && $main_opts['only_logged_in_can_download'];
616
- echo '<input name="sdm_downloads_options[only_logged_in_can_download]" id="only_logged_in_can_download" type="checkbox" value="1"' . checked(true, $value, false) . ' />';
617
- echo '<label for="only_logged_in_can_download">' . __('Enable this option if you want to allow downloads only for logged-in users. When enabled, anonymous users clicking on the download button will receive an error message.', 'simple-download-monitor') . '</label>';
618
  }
619
 
620
  public function general_login_page_url_cb() {
621
- $main_opts = get_option('sdm_downloads_options');
622
- $value = isset($main_opts['general_login_page_url']) ? $main_opts['general_login_page_url'] : '';
623
- echo '<input size="100" name="sdm_downloads_options[general_login_page_url]" id="general_login_page_url" type="text" value="' . $value . '" />';
624
- 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>';
625
  }
626
 
627
  public function admin_tinymce_button_cb() {
628
- $main_opts = get_option('sdm_downloads_options');
629
- 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) . ' /> ';
630
- echo '<label for="admin_tinymce_button">' . __('Removes the SDM Downloads button from the WP content editor.', 'simple-download-monitor') . '</label>';
631
  }
632
 
633
  public function admin_log_unique() {
634
- $main_opts = get_option('sdm_downloads_options');
635
- 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) . ' /> ';
636
- echo '<label for="admin_log_unique">' . __('Only logs downloads from unique IP addresses.', 'simple-download-monitor') . '</label>';
 
 
 
 
 
 
 
 
 
 
 
 
637
  }
638
 
639
  public function admin_no_logs_cb() {
640
- $main_opts = get_option('sdm_downloads_options');
641
- echo '<input name="sdm_downloads_options[admin_no_logs]" id="admin_no_logs" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_no_logs']), false) . ' /> ';
642
- echo '<label for="admin_no_logs">' . __('Disables all download logs. (This global option overrides the individual download item option.)', 'simple-download-monitor') . '</label>';
643
  }
644
 
645
  public function download_button_color_cb() {
646
- $main_opts = get_option('sdm_downloads_options');
647
- // Read current color class.
648
- $color_opt = isset($main_opts['download_button_color']) ? $main_opts['download_button_color'] : null;
649
- $color_opts = sdm_get_download_button_colors();
650
 
651
- echo '<select name="sdm_downloads_options[download_button_color]" id="download_button_color" class="sdm_opts_ajax_dropdowns">';
652
- foreach ($color_opts as $color_class => $color_name) {
653
- echo '<option value="' . $color_class . '"' . selected($color_class, $color_opt, false) . '>' . $color_name . '</option>';
654
- }
655
- echo '</select> ';
656
- esc_html_e('Adjusts the color of the "Download Now" button.', 'simple-download-monitor');
657
  }
658
 
659
  public function enable_debug_cb() {
660
- $main_opts = get_option('sdm_downloads_options');
661
- echo '<input name="sdm_downloads_options[enable_debug]" id="enable_debug" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['enable_debug']), false) . ' /> ';
662
- echo '<label for="enable_debug">' . __('Check this option to enable debug logging.', 'simple-download-monitor') .
663
- '<p class="description"><a href="' . get_admin_url() . '?sdm-action=view_log" target="_blank">' .
664
- __('Click here', 'simple-download-monitor') . '</a>' .
665
- __(' to view log file.', 'simple-download-monitor') . '<br>' .
666
- '<a id="sdm-reset-log" href="#0" style="color: red">' . __('Click here', 'simple-download-monitor') . '</a>' .
667
- __(' to reset log file.', 'simple-download-monitor') . '</p></label>';
668
  }
669
 
670
  }
@@ -678,15 +698,15 @@ add_action('wp_ajax_nopriv_sdm_tiny_get_post_ids', 'sdm_tiny_get_post_ids_ajax_c
678
  add_action('wp_ajax_sdm_tiny_get_post_ids', 'sdm_tiny_get_post_ids_ajax_call');
679
 
680
  function sdm_tiny_get_post_ids_ajax_call() {
681
-
682
  $posts = get_posts(array(
683
- 'post_type' => 'sdm_downloads',
684
- 'numberposts' => -1,
685
- )
686
  );
687
  foreach ($posts as $item) {
688
- $test[] = array('post_id' => $item->ID, 'post_title' => $item->post_title);
689
- }
690
 
691
  $response = json_encode(array('success' => true, 'test' => $test));
692
 
@@ -701,22 +721,22 @@ add_action('wp_ajax_sdm_remove_thumbnail_image', 'sdm_remove_thumbnail_image_aja
701
 
702
  function sdm_remove_thumbnail_image_ajax_call() {
703
  if (!current_user_can('edit_posts')) {
704
- //Permission denied
705
- wp_die(__('Permission denied!', 'simple-download-monitor'));
706
- exit;
707
  }
708
 
709
- //Go ahead with the thumbnail removal
710
- $post_id = $_POST['post_id_del'];
711
  $key_exists = metadata_exists('post', $post_id, 'sdm_upload_thumbnail');
712
  if ($key_exists) {
713
- $success = delete_post_meta($post_id, 'sdm_upload_thumbnail');
714
- if ($success) {
715
- $response = json_encode(array('success' => true));
716
- }
717
  } else {
718
- // in order for frontend script to not display "Ajax error", let's return some data
719
- $response = json_encode(array('not_exists' => true));
720
  }
721
 
722
  header('Content-Type: application/json');
@@ -730,33 +750,34 @@ add_action('wp_ajax_sdm_pop_cats', 'sdm_pop_cats_ajax_call');
730
 
731
  function sdm_pop_cats_ajax_call() {
732
 
733
- $cat_slug = $_POST['cat_slug']; // Get button cpt slug
734
- $parent_id = $_POST['parent_id']; // Get button cpt id
735
- // Query custom posts based on taxonomy slug
 
736
  $posts = get_posts(array(
737
- 'post_type' => 'sdm_downloads',
738
- 'numberposts' => -1,
739
- 'tax_query' => array(
740
- array(
741
- 'taxonomy' => 'sdm_categories',
742
- 'field' => 'slug',
743
- 'terms' => $cat_slug,
744
- 'include_children' => 0
745
- )
746
- ),
747
- 'orderby' => 'title',
748
- 'order' => 'ASC')
749
  );
750
 
751
  $final_array = array();
752
 
753
- // Loop results
754
  foreach ($posts as $post) {
755
- // Create array of variables to pass to js
756
- $final_array[] = array('id' => $post->ID, 'permalink' => get_permalink($post->ID), 'title' => $post->post_title);
757
  }
758
 
759
- // Generate ajax response
760
  $response = json_encode(array('final_array' => $final_array));
761
  header('Content-Type: application/json');
762
  echo $response;
@@ -801,24 +822,24 @@ function sdm_downloads_sortable($cols) {
801
  function sdm_downloads_columns_content($column_name, $post_ID) {
802
 
803
  if ($column_name == 'sdm_downloads_thumbnail') {
804
- $old_thumbnail = get_post_meta($post_ID, 'sdm_upload_thumbnail', true);
805
- //$old_value = isset($old_thumbnail) ? $old_thumbnail : '';
806
- if ($old_thumbnail) {
807
- echo '<p class="sdm_downloads_count"><img src="' . $old_thumbnail . '" style="width:50px;height:50px;" /></p>';
808
- }
809
  }
810
  if ($column_name == 'sdm_downloads_id') {
811
- echo '<p class="sdm_downloads_postid">' . $post_ID . '</p>';
812
  }
813
  if ($column_name == 'sdm_downloads_file') {
814
- $old_file = get_post_meta($post_ID, 'sdm_upload', true);
815
- $file = isset($old_file) ? $old_file : '--';
816
- echo '<p class="sdm_downloads_file">' . $file . '</p>';
817
  }
818
  if ($column_name == 'sdm_downloads_count') {
819
- global $wpdb;
820
- $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id=%s', $post_ID));
821
- echo '<p class="sdm_downloads_count">' . $wpdb->num_rows . '</p>';
822
  }
823
  }
824
 
@@ -849,20 +870,20 @@ if ($tiny_button_option != true) {
849
 
850
  function sdm_downloads_tinymce_button() {
851
 
852
- add_filter('mce_external_plugins', 'sdm_downloads_add_button');
853
- add_filter('mce_buttons', 'sdm_downloads_register_button');
854
  }
855
 
856
  function sdm_downloads_add_button($plugin_array) {
857
 
858
- $plugin_array['sdm_downloads'] = WP_SIMPLE_DL_MONITOR_URL . '/tinymce/sdm_editor_plugin.js';
859
- return $plugin_array;
860
  }
861
 
862
  function sdm_downloads_register_button($buttons) {
863
 
864
- $buttons[] = 'sdm_downloads';
865
- return $buttons;
866
  }
867
 
868
  }
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.5.9
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
10
+ * Text Domain: simple-download-monitor
11
+ * Domain Path: /languages/
12
  */
13
+
14
  if (!defined('ABSPATH')) {
15
  exit;
16
  }
17
 
18
+ define('WP_SIMPLE_DL_MONITOR_VERSION', '3.5.9');
19
  define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
20
  define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
21
  define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
93
  //Handle download request if any
94
  handle_sdm_download_via_direct_post();
95
  if (is_admin()) {
96
+ //Register Google Charts library
97
+ wp_register_script('sdm_google_charts', 'https://www.gstatic.com/charts/loader.js', array(), null, true);
98
+ wp_register_style('sdm_jquery_ui_style', WP_SIMPLE_DL_MONITOR_URL . '/css/jquery.ui.min.css', array(), null, 'all');
99
  }
100
  }
101
 
105
  add_action('wp_ajax_sdm_delete_data', 'sdm_delete_data_handler');
106
 
107
  if (is_admin()) {
108
+ if (user_can(wp_get_current_user(), 'administrator')) {
109
+ // user is an admin
110
+ if (isset($_GET['sdm-action'])) {
111
+ if ($_GET['sdm-action'] === 'view_log') {
112
+ $logfile = fopen(WP_SDM_LOG_FILE, 'rb');
113
+ header('Content-Type: text/plain');
114
+ fpassthru($logfile);
115
+ die;
116
+ }
117
+ }
118
+ }
119
  }
120
  }
121
 
127
 
128
  function sdm_delete_data_handler() {
129
  if (!check_ajax_referer('sdm_delete_data', 'nonce', false)) {
130
+ //nonce check failed
131
+ wp_die(0);
132
  }
133
  global $wpdb;
134
  //let's find and delete smd_download posts and meta
135
  $posts = $wpdb->get_results('SELECT id FROM ' . $wpdb->prefix . 'posts WHERE post_type="sdm_downloads"', ARRAY_A);
136
  if (!is_null($posts)) {
137
+ foreach ($posts as $post) {
138
+ wp_delete_post($post['id'], true);
139
+ }
140
  }
141
  //let's delete options
142
  delete_option('sdm_downloads_options');
161
 
162
  function sdm_db_update_check() {
163
  if (is_admin()) {//Check if DB needs to be upgraded
164
+ global $sdm_db_version;
165
+ $inst_db_version = get_option('sdm_db_version');
166
+ if ($inst_db_version != $sdm_db_version) {
167
+ sdm_install_db_table();
168
+ }
169
  }
170
  }
171
 
177
  function sdm_settings_link($links, $file) {
178
  static $this_plugin;
179
  if (!$this_plugin)
180
+ $this_plugin = plugin_basename(__FILE__);
181
  if ($file == $this_plugin) {
182
+ $settings_link = '<a href="edit.php?post_type=sdm_downloads&page=sdm-settings" title="SDM Settings Page">' . __("Settings", 'simple-download-monitor') . '</a>';
183
+ array_unshift($links, $settings_link);
184
  }
185
  return $links;
186
  }
190
 
191
  public function __construct() {
192
 
193
+ add_action('init', 'sdm_register_post_type'); // Create 'sdm_downloads' custom post type
194
+ add_action('init', 'sdm_create_taxonomies'); // Register 'tags' and 'categories' taxonomies
195
+ add_action('init', 'sdm_register_shortcodes'); //Register the shortcodes
196
+ add_action('wp_enqueue_scripts', array($this, 'sdm_frontend_scripts')); // Register frontend scripts
197
 
198
+ if (is_admin()) {
199
+ add_action('admin_menu', array($this, 'sdm_create_menu_pages')); // Create admin pages
200
+ add_action('add_meta_boxes', array($this, 'sdm_create_upload_metabox')); // Create metaboxes
201
 
202
+ add_action('save_post', array($this, 'sdm_save_description_meta_data')); // Save 'description' metabox
203
+ add_action('save_post', array($this, 'sdm_save_upload_meta_data')); // Save 'upload file' metabox
204
+ add_action('save_post', array($this, 'sdm_save_dispatch_meta_data')); // Save 'dispatch' metabox
205
+ add_action('save_post', array($this, 'sdm_save_thumbnail_meta_data')); // Save 'thumbnail' metabox
206
+ add_action('save_post', array($this, 'sdm_save_statistics_meta_data')); // Save 'statistics' metabox
207
+ add_action('save_post', array($this, 'sdm_save_other_details_meta_data')); // Save 'other details' metabox
208
 
209
+ add_action('admin_enqueue_scripts', array($this, 'sdm_admin_scripts')); // Register admin scripts
210
+ add_action('admin_print_styles', array($this, 'sdm_admin_styles')); // Register admin styles
211
 
212
+ add_action('admin_init', array($this, 'sdm_register_options')); // Register admin options
213
+ //add_filter('post_row_actions', array($this, 'sdm_remove_view_link_cpt'), 10, 2); // Remove 'View' link in all downloads list view
214
+ }
215
  }
216
 
217
  public function sdm_admin_scripts() {
218
 
219
+ global $current_screen, $post;
220
+
221
+ if (is_admin() && $current_screen->post_type == 'sdm_downloads' && $current_screen->base == 'post') {
222
+
223
+ // These scripts are needed for the media upload thickbox
224
+ wp_enqueue_script('media-upload');
225
+ wp_enqueue_script('thickbox');
226
+ wp_register_script('sdm-upload', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_admin_scripts.js', array('jquery', 'media-upload', 'thickbox'), WP_SIMPLE_DL_MONITOR_VERSION);
227
+ wp_enqueue_script('sdm-upload');
228
+
229
+ // Pass postID for thumbnail deletion
230
+ ?>
231
+ <script type="text/javascript">
232
+ var sdm_del_thumb_postid = '<?php echo $post->ID; ?>';
233
+ </script>
234
+ <?php
235
+ // Localize langauge strings used in js file
236
+ $sdmTranslations = array(
237
+ 'select_file' => __('Select File', 'simple-download-monitor'),
238
+ 'select_thumbnail' => __('Select Thumbnail', 'simple-download-monitor'),
239
+ 'insert' => __('Insert', 'simple-download-monitor'),
240
+ 'image_removed' => __('Image Successfully Removed', 'simple-download-monitor'),
241
+ 'ajax_error' => __('Error with AJAX', 'simple-download-monitor')
242
+ );
243
+ wp_localize_script('sdm-upload', 'sdm_translations', $sdmTranslations);
244
+ }
245
+
246
+ // Pass admin ajax url
247
+ ?>
248
+ <script type="text/javascript">
249
+ var sdm_admin_ajax_url = {sdm_admin_ajax_url: '<?php echo admin_url('admin-ajax.php?action=ajax'); ?>'};
250
+ var sdm_plugin_url = '<?php echo plugins_url(); ?>';
251
+ var tinymce_langs = {
252
+ select_download_item: '<?php _e('Please select a Download Item:', 'simple-download-monitor') ?>',
253
+ download_title: '<?php _e('Download Title', 'simple-download-monitor') ?>',
254
+ include_fancy: '<?php _e('Include Fancy Box', 'simple-download-monitor') ?>',
255
+ open_new_window: '<?php _e('Open New Window', 'simple-download-monitor') ?>',
256
+ button_color: '<?php _e('Button Color', 'simple-download-monitor'); ?>',
257
+ insert_shortcode: '<?php _e('Insert SDM Shortcode', 'simple-download-monitor') ?>'
258
+ };
259
+ var sdm_button_colors = <?php echo wp_json_encode(sdm_get_download_button_colors()); ?>;
260
+ </script>
261
+ <?php
262
  }
263
 
264
  public function sdm_frontend_scripts() {
265
+ //Use this function to enqueue fron-end js scripts.
266
+ wp_enqueue_style('sdm-styles', WP_SIMPLE_DL_MONITOR_URL . '/css/sdm_wp_styles.css');
267
+ wp_register_script('sdm-scripts', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_wp_scripts.js', array('jquery'));
268
+ wp_enqueue_script('sdm-scripts');
269
 
270
+ // Localize ajax script for frontend
271
+ wp_localize_script('sdm-scripts', 'sdm_ajax_script', array('ajaxurl' => admin_url('admin-ajax.php')));
272
  }
273
 
274
  public function sdm_admin_styles() {
275
 
276
+ wp_enqueue_style('thickbox'); // Needed for media upload thickbox
277
+ 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
278
  }
279
 
280
  public function sdm_create_menu_pages() {
281
+ include_once('includes/sdm-admin-menu-handler.php');
282
+ sdm_handle_admin_menu();
283
  }
284
 
285
  public function sdm_create_upload_metabox() {
286
 
287
+ //***** Create metaboxes for the custom post type
288
+ add_meta_box('sdm_description_meta_box', __('Description', 'simple-download-monitor'), array($this, 'display_sdm_description_meta_box'), 'sdm_downloads', 'normal', 'default');
289
+ add_meta_box('sdm_upload_meta_box', __('Downloadable File (Visitors will download this item)', 'simple-download-monitor'), array($this, 'display_sdm_upload_meta_box'), 'sdm_downloads', 'normal', 'default');
290
+ add_meta_box('sdm_dispatch_meta_box', __('PHP Dispatch or Redirect', 'simple-download-monitor'), array($this, 'display_sdm_dispatch_meta_box'), 'sdm_downloads', 'normal', 'default');
291
+ add_meta_box('sdm_thumbnail_meta_box', __('File Thumbnail (Optional)', 'simple-download-monitor'), array($this, 'display_sdm_thumbnail_meta_box'), 'sdm_downloads', 'normal', 'default');
292
+ add_meta_box('sdm_stats_meta_box', __('Statistics', 'simple-download-monitor'), array($this, 'display_sdm_stats_meta_box'), 'sdm_downloads', 'normal', 'default');
293
+ add_meta_box('sdm_other_details_meta_box', __('Other Details (Optional)', 'simple-download-monitor'), array($this, 'display_sdm_other_details_meta_box'), 'sdm_downloads', 'normal', 'default');
294
+ add_meta_box('sdm_shortcode_meta_box', __('Shortcodes', 'simple-download-monitor'), array($this, 'display_sdm_shortcode_meta_box'), 'sdm_downloads', 'normal', 'default');
295
  }
296
 
297
  public function display_sdm_description_meta_box($post) { // Description metabox
298
+ _e('Add a description for this download item.', 'simple-download-monitor');
299
+ echo '<br /><br />';
300
 
301
+ $old_description = get_post_meta($post->ID, 'sdm_description', true);
302
+ $sdm_description_field = array('textarea_name' => 'sdm_description');
303
+ wp_editor($old_description, "sdm_description_editor_content", $sdm_description_field);
304
 
305
+ wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');
306
  }
307
 
308
  public function display_sdm_upload_meta_box($post) { // File Upload metabox
309
+ $old_upload = get_post_meta($post->ID, 'sdm_upload', true);
310
+ $old_value = isset($old_upload) ? $old_upload : '';
311
 
312
+ _e('Manually enter a valid URL of the file in the text box below, or click "Select File" button to upload (or choose) the downloadable file.', 'simple-download-monitor');
313
+ echo '<br /><br />';
314
 
315
+ echo '<div class="sdm-download-edit-file-url-section">';
316
+ echo '<input id="sdm_upload" type="text" size="100" name="sdm_upload" value="' . esc_url($old_value) . '" placeholder="http://..." />';
317
+ echo '</div>';
318
 
319
+ echo '<br />';
320
+ echo '<input id="upload_image_button" type="button" class="button-primary" value="' . __('Select File', 'simple-download-monitor') . '" />';
321
 
322
+ echo '<br /><br />';
323
+ _e('Steps to upload a file or choose one from your media library:', 'simple-download-monitor');
324
+ echo '<ol>';
325
+ echo '<li>Hit the "Select File" button.</li>';
326
+ echo '<li>Upload a new file or choose an existing one from your media library.</li>';
327
+ echo '<li>Click the "Insert" button, this will populate the uploaded file\'s URL in the above text field.</li>';
328
+ echo '</ol>';
329
 
330
+ wp_nonce_field('sdm_upload_box_nonce', 'sdm_upload_box_nonce_check');
331
  }
332
 
333
  public function display_sdm_dispatch_meta_box($post) {
334
+ $dispatch = get_post_meta($post->ID, 'sdm_item_dispatch', true);
335
 
336
+ if ($dispatch === '') {
337
+ // No value yet (either new item or saved with older version of plugin)
338
+ $screen = get_current_screen();
339
 
340
+ if ($screen->action === 'add') {
341
+ // New item: set default value as per plugin settings.
342
+ $main_opts = get_option('sdm_downloads_options');
343
+ $dispatch = isset($main_opts['general_default_dispatch_value']) && $main_opts['general_default_dispatch_value'];
344
+ }
345
+ }
346
 
347
+ echo '<input id="sdm_item_dispatch" type="checkbox" name="sdm_item_dispatch" value="yes"' . checked(true, $dispatch, false) . ' />';
348
+ echo '<label for="sdm_item_dispatch">' . __('Dispatch the file via PHP directly instead of redirecting to it. PHP Dispatching keeps the download URL hidden. Dispatching works only for local files (files that you uploaded to this site via this plugin or media library).', 'simple-download-monitor') . '</label>';
349
 
350
+ wp_nonce_field('sdm_dispatch_box_nonce', 'sdm_dispatch_box_nonce_check');
351
  }
352
 
353
  public function display_sdm_thumbnail_meta_box($post) { // Thumbnail upload metabox
354
+ $old_thumbnail = get_post_meta($post->ID, 'sdm_upload_thumbnail', true);
355
+ $old_value = isset($old_thumbnail) ? $old_thumbnail : '';
356
+ _e('Manually enter a valid URL, or click "Select Image" to upload (or choose) the file thumbnail image.', 'simple-download-monitor');
357
+ ?>
358
+ <br /><br />
359
+ <input id="sdm_upload_thumbnail" type="text" size="100" name="sdm_upload_thumbnail" value="<?php echo esc_url($old_value); ?>" placeholder="http://..." />
360
+ <br /><br />
361
+ <input id="upload_thumbnail_button" type="button" class="button-primary" value="<?php _e('Select Image', 'simple-download-monitor'); ?>" />
362
+ <input id="remove_thumbnail_button" type="button" class="button" value="<?php _e('Remove Image', 'simple-download-monitor'); ?>" />
363
+ <br /><br />
364
+
365
+ <span id="sdm_admin_thumb_preview">
366
+ <?php
367
+ if (!empty($old_value)) {
368
+ ?><img id="sdm_thumbnail_image" src="<?php echo $old_value; ?>" style="max-width:200px;" />
369
+ <?php
370
+ }
371
+ ?>
372
+ </span>
373
+
374
+ <?php
375
+ echo '<p class="description">';
376
+ _e('This thumbnail image will be used to create a fancy file download box if you want to use it.', 'simple-download-monitor');
377
+ echo '</p>';
378
+
379
+ wp_nonce_field('sdm_thumbnail_box_nonce', 'sdm_thumbnail_box_nonce_check');
380
  }
381
 
382
  public function display_sdm_stats_meta_box($post) { //Stats metabox
383
+ $old_count = get_post_meta($post->ID, 'sdm_count_offset', true);
384
+ $value = isset($old_count) && $old_count != '' ? $old_count : '0';
385
 
386
+ // Get checkbox for "disable download logging"
387
+ $no_logs = get_post_meta($post->ID, 'sdm_item_no_log', true);
388
+ $checked = isset($no_logs) && $no_logs === 'on' ? 'checked="checked"' : '';
389
 
390
+ _e('These are the statistics for this download item.', 'simple-download-monitor');
391
+ echo '<br /><br />';
392
 
393
+ global $wpdb;
394
+ $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id=%s', $post->ID));
395
 
396
+ echo '<div class="sdm-download-edit-dl-count">';
397
+ _e('Number of Downloads:', 'simple-download-monitor');
398
+ echo ' <strong>' . $wpdb->num_rows . '</strong>';
399
+ echo '</div>';
400
 
401
+ echo '<div class="sdm-download-edit-offset-count">';
402
+ _e('Offset Count: ', 'simple-download-monitor');
403
+ echo '<br />';
404
+ echo ' <input type="text" size="10" name="sdm_count_offset" value="' . esc_attr($value) . '" />';
405
+ echo '<p class="description">' . __('Enter any positive or negative numerical value; to offset the download count shown to the visitors (when using the download counter shortcode).', 'simple-download-monitor') . '</p>';
406
+ echo '</div>';
407
 
408
+ echo '<br />';
409
+ echo '<div class="sdm-download-edit-disable-logging">';
410
+ echo '<input type="checkbox" name="sdm_item_no_log" ' . $checked . ' />';
411
+ echo '<span style="margin-left: 5px;"></span>';
412
+ _e('Disable download logging for this item.', 'simple-download-monitor');
413
+ echo '</div>';
414
 
415
+ wp_nonce_field('sdm_count_offset_nonce', 'sdm_count_offset_nonce_check');
416
  }
417
 
418
  public function display_sdm_other_details_meta_box($post) { //Other details metabox
419
+ $file_size = get_post_meta($post->ID, 'sdm_item_file_size', true);
420
+ $file_size = isset($file_size) ? $file_size : '';
421
 
422
+ $version = get_post_meta($post->ID, 'sdm_item_version', true);
423
+ $version = isset($version) ? $version : '';
424
 
425
+ echo '<div class="sdm-download-edit-filesize">';
426
+ _e('File Size: ', 'simple-download-monitor');
427
+ echo '<br />';
428
+ echo ' <input type="text" name="sdm_item_file_size" value="' . esc_attr($file_size) . '" size="20" />';
429
+ 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>';
430
+ echo '</div>';
431
 
432
+ echo '<div class="sdm-download-edit-version">';
433
+ _e('Version: ', 'simple-download-monitor');
434
+ echo '<br />';
435
+ echo ' <input type="text" name="sdm_item_version" value="' . esc_attr($version) . '" size="20" />';
436
+ 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>';
437
+ echo '</div>';
438
 
439
+ wp_nonce_field('sdm_other_details_nonce', 'sdm_other_details_nonce_check');
440
  }
441
 
442
  public function display_sdm_shortcode_meta_box($post) { //Shortcode metabox
443
+ _e('The following shortcode can be used on posts or pages to embed a download now button for this file. You can also use the shortcode inserter (in the post editor) to add this shortcode to a post or page.', 'simple-download-monitor');
444
+ echo '<br />';
445
+ $shortcode_text = '[sdm_download id="' . $post->ID . '" fancy="0"]';
446
+ echo "<input type='text' class='code' onfocus='this.select();' readonly='readonly' value='" . $shortcode_text . "' size='40'>";
447
+ echo "<br /><br />";
448
 
449
+ _e('The following shortcode can be used to show a download counter for this item.', 'simple-download-monitor');
450
+ echo '<br />';
451
+ $shortcode_text = '[sdm_download_counter id="' . $post->ID . '"]';
452
+ echo "<input type='text' class='code' onfocus='this.select();' readonly='readonly' value='" . $shortcode_text . "' size='40'>";
453
 
454
+ echo '<br /><br />';
455
+ echo 'Read the full shortcode usage documentation <a href="https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin" target="_blank">here</a>.';
456
  }
457
 
458
  public function sdm_save_description_meta_data($post_id) { // Save Description metabox
459
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
460
+ return;
461
+ }
462
+ if (!isset($_POST['sdm_description_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_description_box_nonce_check'], 'sdm_description_box_nonce')){
463
+ return;
464
+ }
465
+ if (isset($_POST['sdm_description'])) {
466
+ update_post_meta($post_id, 'sdm_description', wp_kses_post($_POST['sdm_description']));
467
+ }
468
  }
469
 
470
  public function sdm_save_upload_meta_data($post_id) { // Save File Upload metabox
471
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
472
+ return;
473
+ if (!isset($_POST['sdm_upload_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_upload_box_nonce_check'], 'sdm_upload_box_nonce'))
474
+ return;
475
 
476
+ if (isset($_POST['sdm_upload'])) {
477
+ update_post_meta($post_id, 'sdm_upload', sanitize_text_field($_POST['sdm_upload']));
478
+ }
479
  }
480
 
481
  public function sdm_save_dispatch_meta_data($post_id) { // Save "Dispatch or Redirect" metabox
482
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
483
+ return;
484
+ }
485
+ if (!isset($_POST['sdm_dispatch_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_dispatch_box_nonce_check'], 'sdm_dispatch_box_nonce')) {
486
+ return;
487
+ }
488
+ // Get POST-ed data as boolean value
489
+ $value = filter_input(INPUT_POST, 'sdm_item_dispatch', FILTER_VALIDATE_BOOLEAN);
490
+ update_post_meta($post_id, 'sdm_item_dispatch', $value);
491
  }
492
 
493
  public function sdm_save_thumbnail_meta_data($post_id) { // Save Thumbnail Upload metabox
494
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
495
+ return;
496
+ }
497
+ if (!isset($_POST['sdm_thumbnail_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_thumbnail_box_nonce_check'], 'sdm_thumbnail_box_nonce')){
498
+ return;
499
+ }
500
+ if (isset($_POST['sdm_upload_thumbnail'])) {
501
+ update_post_meta($post_id, 'sdm_upload_thumbnail', sanitize_text_field($_POST['sdm_upload_thumbnail']));
502
+ }
503
  }
504
 
505
  public function sdm_save_statistics_meta_data($post_id) { // Save Statistics Upload metabox
506
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
507
+ return;
508
+ }
509
+ if (!isset($_POST['sdm_count_offset_nonce_check']) || !wp_verify_nonce($_POST['sdm_count_offset_nonce_check'], 'sdm_count_offset_nonce')){
510
+ return;
511
+ }
512
+ if (isset($_POST['sdm_count_offset']) && is_numeric($_POST['sdm_count_offset'])) {
513
+ update_post_meta($post_id, 'sdm_count_offset', intval($_POST['sdm_count_offset']));
514
+ }
515
+
516
+ // Checkbox for disabling download logging for this item
517
+ if (isset($_POST['sdm_item_no_log'])) {
518
+ update_post_meta($post_id, 'sdm_item_no_log', sanitize_text_field($_POST['sdm_item_no_log']));
519
+ } else {
520
+ delete_post_meta($post_id, 'sdm_item_no_log');
521
+ }
522
  }
523
 
524
  public function sdm_save_other_details_meta_data($post_id) { // Save Statistics Upload metabox
525
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
526
+ return;
527
+ }
528
+ if (!isset($_POST['sdm_other_details_nonce_check']) || !wp_verify_nonce($_POST['sdm_other_details_nonce_check'], 'sdm_other_details_nonce')) {
529
+ return;
530
+ }
531
 
532
+ if (isset($_POST['sdm_item_file_size'])) {
533
+ update_post_meta($post_id, 'sdm_item_file_size', sanitize_text_field($_POST['sdm_item_file_size']));
534
+ }
535
 
536
+ if (isset($_POST['sdm_item_version'])) {
537
+ update_post_meta($post_id, 'sdm_item_version', sanitize_text_field($_POST['sdm_item_version']));
538
+ }
539
  }
540
 
541
  public function sdm_remove_view_link_cpt($action, $post) {
542
 
543
+ // Only execute on SDM CPT posts page
544
+ if ($post->post_type == 'sdm_downloads') {
545
+ unset($action['view']);
546
+ }
547
 
548
+ return $action;
549
  }
550
 
551
  public function sdm_register_options() {
552
 
553
+ //Register the main setting
554
+ register_setting('sdm_downloads_options', 'sdm_downloads_options');
555
 
556
+ //Add all the settings section that will go under the main settings
557
+ add_settings_section('general_options', __('General Options', 'simple-download-monitor'), array($this, 'general_options_cb'), 'general_options_section');
558
+ add_settings_section('admin_options', __('Admin Options', 'simple-download-monitor'), array($this, 'admin_options_cb'), 'admin_options_section');
559
+ add_settings_section('sdm_colors', __('Colors', 'simple-download-monitor'), array($this, 'sdm_colors_cb'), 'sdm_colors_section');
560
+ add_settings_section('sdm_debug', __('Debug', 'simple-download-monitor'), array($this, 'sdm_debug_cb'), 'sdm_debug_section');
561
+ add_settings_section('sdm_deldata', __('Delete Plugin Data', 'simple-download-monitor'), array($this, 'sdm_deldata_cb'), 'sdm_deldata_section');
562
 
563
+ //Add all the individual settings fields that goes under the sections
564
+ add_settings_field('general_hide_donwload_count', __('Hide Download Count', 'simple-download-monitor'), array($this, 'hide_download_count_cb'), 'general_options_section', 'general_options');
565
+ add_settings_field('general_default_dispatch_value', __('PHP Dispatching', 'simple-download-monitor'), array($this, 'general_default_dispatch_value_cb'), 'general_options_section', 'general_options');
566
+ add_settings_field('only_logged_in_can_download', __('Only Allow Logged-in Users to Download', 'simple-download-monitor'), array($this, 'general_only_logged_in_can_download_cb'), 'general_options_section', 'general_options');
567
+ add_settings_field('general_login_page_url', __('Login Page URL', 'simple-download-monitor'), array($this, 'general_login_page_url_cb'), 'general_options_section', 'general_options');
568
 
569
+ add_settings_field('admin_tinymce_button', __('Remove Tinymce Button', 'simple-download-monitor'), array($this, 'admin_tinymce_button_cb'), 'admin_options_section', 'admin_options');
570
+ add_settings_field('admin_log_unique', __('Log Unique IP', 'simple-download-monitor'), array($this, 'admin_log_unique'), 'admin_options_section', 'admin_options');
571
+ 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');
572
+ 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');
573
+ add_settings_field('admin_no_logs', __('Disable Download Logs', 'simple-download-monitor'), array($this, 'admin_no_logs_cb'), 'admin_options_section', 'admin_options');
574
 
575
+ add_settings_field('download_button_color', __('Download Button Color', 'simple-download-monitor'), array($this, 'download_button_color_cb'), 'sdm_colors_section', 'sdm_colors');
576
 
577
+ add_settings_field('enable_debug', __('Enable Debug', 'simple-download-monitor'), array($this, 'enable_debug_cb'), 'sdm_debug_section', 'sdm_debug');
578
  }
579
 
580
  public function general_options_cb() {
581
+ //Set the message that will be shown below the general options settings heading
582
+ _e('General options settings', 'simple-download-monitor');
583
  }
584
 
585
  public function admin_options_cb() {
586
+ //Set the message that will be shown below the admin options settings heading
587
+ _e('Admin options settings', 'simple-download-monitor');
588
  }
589
 
590
  public function sdm_colors_cb() {
591
+ //Set the message that will be shown below the color options settings heading
592
+ _e('Front End colors settings', 'simple-download-monitor');
593
  }
594
 
595
  public function sdm_debug_cb() {
596
+ //Set the message that will be shown below the debug options settings heading
597
+ _e('Debug settings', 'simple-download-monitor');
598
  }
599
 
600
  public function sdm_deldata_cb() {
601
+ //Set the message that will be shown below the debug options settings heading
602
+ _e('You can delete all the data related to this plugin from database using the button below. Useful when you\'re uninstalling the plugin and don\'t want any leftovers remaining.', 'simple-download-monitor');
603
+ echo '<p><b>' . __('Warning', 'simple-download-monitor') . ': </b> ' . __('this can\'t be undone. All settings, download items, download logs will be deleted.', 'simple-download-monitor') . '</p>';
604
+ echo '<p><button id="sdmDeleteData" class="button" style="color:red;">' . __('Delete all data and deactivate plugin', 'simple-download-monitor') . '</button></p>';
605
+ echo '<br />';
606
  }
607
 
608
  public function hide_download_count_cb() {
609
+ $main_opts = get_option('sdm_downloads_options');
610
+ echo '<input name="sdm_downloads_options[general_hide_donwload_count]" id="general_hide_download_count" type="checkbox" ' . checked(1, isset($main_opts['general_hide_donwload_count']), false) . ' /> ';
611
+ echo '<label for="general_hide_download_count">' . __('Hide the download count that is shown in some of the fancy templates.', 'simple-download-monitor') . '</label>';
612
  }
613
 
614
  public function general_default_dispatch_value_cb() {
615
+ $main_opts = get_option('sdm_downloads_options');
616
+ $value = isset($main_opts['general_default_dispatch_value']) && $main_opts['general_default_dispatch_value'];
617
+ echo '<input name="sdm_downloads_options[general_default_dispatch_value]" id="general_default_dispatch_value" type="checkbox" value="1"' . checked(true, $value, false) . ' />';
618
+ echo '<label for="general_default_dispatch_value">' . __('When you create a new download item, The PHP Dispatching option should be enabled by default. PHP Dispatching keeps the URL of the downloadable files hidden.', 'simple-download-monitor') . '</label>';
619
  }
620
 
621
  public function general_only_logged_in_can_download_cb() {
622
+ $main_opts = get_option('sdm_downloads_options');
623
+ $value = isset($main_opts['only_logged_in_can_download']) && $main_opts['only_logged_in_can_download'];
624
+ echo '<input name="sdm_downloads_options[only_logged_in_can_download]" id="only_logged_in_can_download" type="checkbox" value="1"' . checked(true, $value, false) . ' />';
625
+ echo '<label for="only_logged_in_can_download">' . __('Enable this option if you want to allow downloads only for logged-in users. When enabled, anonymous users clicking on the download button will receive an error message.', 'simple-download-monitor') . '</label>';
626
  }
627
 
628
  public function general_login_page_url_cb() {
629
+ $main_opts = get_option('sdm_downloads_options');
630
+ $value = isset($main_opts['general_login_page_url']) ? $main_opts['general_login_page_url'] : '';
631
+ echo '<input size="100" name="sdm_downloads_options[general_login_page_url]" id="general_login_page_url" type="text" value="' . $value . '" />';
632
+ 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>';
633
  }
634
 
635
  public function admin_tinymce_button_cb() {
636
+ $main_opts = get_option('sdm_downloads_options');
637
+ 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) . ' /> ';
638
+ echo '<label for="admin_tinymce_button">' . __('Removes the SDM Downloads button from the WP content editor.', 'simple-download-monitor') . '</label>';
639
  }
640
 
641
  public function admin_log_unique() {
642
+ $main_opts = get_option('sdm_downloads_options');
643
+ 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) . ' /> ';
644
+ echo '<label for="admin_log_unique">' . __('Only logs downloads from unique IP addresses.', 'simple-download-monitor') . '</label>';
645
+ }
646
+
647
+ public function admin_do_not_capture_ip() {
648
+ $main_opts = get_option('sdm_downloads_options');
649
+ echo '<input name="sdm_downloads_options[admin_do_not_capture_ip]" id="admin_do_not_capture_ip" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_do_not_capture_ip']), false) . ' /> ';
650
+ echo '<label for="admin_do_not_capture_ip">' . __('Use this if you do not want to capture the IP address and Country of the visitors when they download an item.', 'simple-download-monitor') . '</label>';
651
+ }
652
+
653
+ public function admin_dont_log_bots() {
654
+ $main_opts = get_option('sdm_downloads_options');
655
+ 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) . ' /> ';
656
+ echo '<label for="admin_dont_log_bots">' . __('When enabled, the plugin won\'t count and log downloads from bots.', 'simple-download-monitor') . '</label>';
657
  }
658
 
659
  public function admin_no_logs_cb() {
660
+ $main_opts = get_option('sdm_downloads_options');
661
+ echo '<input name="sdm_downloads_options[admin_no_logs]" id="admin_no_logs" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_no_logs']), false) . ' /> ';
662
+ echo '<label for="admin_no_logs">' . __('Disables all download logs. (This global option overrides the individual download item option.)', 'simple-download-monitor') . '</label>';
663
  }
664
 
665
  public function download_button_color_cb() {
666
+ $main_opts = get_option('sdm_downloads_options');
667
+ // Read current color class.
668
+ $color_opt = isset($main_opts['download_button_color']) ? $main_opts['download_button_color'] : null;
669
+ $color_opts = sdm_get_download_button_colors();
670
 
671
+ echo '<select name="sdm_downloads_options[download_button_color]" id="download_button_color" class="sdm_opts_ajax_dropdowns">';
672
+ foreach ($color_opts as $color_class => $color_name) {
673
+ echo '<option value="' . $color_class . '"' . selected($color_class, $color_opt, false) . '>' . $color_name . '</option>';
674
+ }
675
+ echo '</select> ';
676
+ esc_html_e('Adjusts the color of the "Download Now" button.', 'simple-download-monitor');
677
  }
678
 
679
  public function enable_debug_cb() {
680
+ $main_opts = get_option('sdm_downloads_options');
681
+ echo '<input name="sdm_downloads_options[enable_debug]" id="enable_debug" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['enable_debug']), false) . ' /> ';
682
+ echo '<label for="enable_debug">' . __('Check this option to enable debug logging.', 'simple-download-monitor') .
683
+ '<p class="description"><a href="' . get_admin_url() . '?sdm-action=view_log" target="_blank">' .
684
+ __('Click here', 'simple-download-monitor') . '</a>' .
685
+ __(' to view log file.', 'simple-download-monitor') . '<br>' .
686
+ '<a id="sdm-reset-log" href="#0" style="color: red">' . __('Click here', 'simple-download-monitor') . '</a>' .
687
+ __(' to reset log file.', 'simple-download-monitor') . '</p></label>';
688
  }
689
 
690
  }
698
  add_action('wp_ajax_sdm_tiny_get_post_ids', 'sdm_tiny_get_post_ids_ajax_call');
699
 
700
  function sdm_tiny_get_post_ids_ajax_call() {
701
+
702
  $posts = get_posts(array(
703
+ 'post_type' => 'sdm_downloads',
704
+ 'numberposts' => -1,
705
+ )
706
  );
707
  foreach ($posts as $item) {
708
+ $test[] = array('post_id' => $item->ID, 'post_title' => $item->post_title);
709
+ }
710
 
711
  $response = json_encode(array('success' => true, 'test' => $test));
712
 
721
 
722
  function sdm_remove_thumbnail_image_ajax_call() {
723
  if (!current_user_can('edit_posts')) {
724
+ //Permission denied
725
+ wp_die(__('Permission denied!', 'simple-download-monitor'));
726
+ exit;
727
  }
728
 
729
+ //Go ahead with the thumbnail removal
730
+ $post_id = intval($_POST['post_id_del']);
731
  $key_exists = metadata_exists('post', $post_id, 'sdm_upload_thumbnail');
732
  if ($key_exists) {
733
+ $success = delete_post_meta($post_id, 'sdm_upload_thumbnail');
734
+ if ($success) {
735
+ $response = json_encode(array('success' => true));
736
+ }
737
  } else {
738
+ // in order for frontend script to not display "Ajax error", let's return some data
739
+ $response = json_encode(array('not_exists' => true));
740
  }
741
 
742
  header('Content-Type: application/json');
750
 
751
  function sdm_pop_cats_ajax_call() {
752
 
753
+ $cat_slug = sanitize_text_field($_POST['cat_slug']); // Get button cpt slug
754
+ $parent_id = intval($_POST['parent_id']); // Get button cpt id
755
+
756
+ // Query custom posts based on taxonomy slug
757
  $posts = get_posts(array(
758
+ 'post_type' => 'sdm_downloads',
759
+ 'numberposts' => -1,
760
+ 'tax_query' => array(
761
+ array(
762
+ 'taxonomy' => 'sdm_categories',
763
+ 'field' => 'slug',
764
+ 'terms' => $cat_slug,
765
+ 'include_children' => 0
766
+ )
767
+ ),
768
+ 'orderby' => 'title',
769
+ 'order' => 'ASC')
770
  );
771
 
772
  $final_array = array();
773
 
774
+ // Loop results
775
  foreach ($posts as $post) {
776
+ // Create array of variables to pass to js
777
+ $final_array[] = array('id' => $post->ID, 'permalink' => get_permalink($post->ID), 'title' => $post->post_title);
778
  }
779
 
780
+ // Generate ajax response
781
  $response = json_encode(array('final_array' => $final_array));
782
  header('Content-Type: application/json');
783
  echo $response;
822
  function sdm_downloads_columns_content($column_name, $post_ID) {
823
 
824
  if ($column_name == 'sdm_downloads_thumbnail') {
825
+ $old_thumbnail = get_post_meta($post_ID, 'sdm_upload_thumbnail', true);
826
+ //$old_value = isset($old_thumbnail) ? $old_thumbnail : '';
827
+ if ($old_thumbnail) {
828
+ echo '<p class="sdm_downloads_count"><img src="' . $old_thumbnail . '" style="width:50px;height:50px;" /></p>';
829
+ }
830
  }
831
  if ($column_name == 'sdm_downloads_id') {
832
+ echo '<p class="sdm_downloads_postid">' . $post_ID . '</p>';
833
  }
834
  if ($column_name == 'sdm_downloads_file') {
835
+ $old_file = get_post_meta($post_ID, 'sdm_upload', true);
836
+ $file = isset($old_file) ? $old_file : '--';
837
+ echo '<p class="sdm_downloads_file">' . $file . '</p>';
838
  }
839
  if ($column_name == 'sdm_downloads_count') {
840
+ global $wpdb;
841
+ $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id=%s', $post_ID));
842
+ echo '<p class="sdm_downloads_count">' . $wpdb->num_rows . '</p>';
843
  }
844
  }
845
 
870
 
871
  function sdm_downloads_tinymce_button() {
872
 
873
+ add_filter('mce_external_plugins', 'sdm_downloads_add_button');
874
+ add_filter('mce_buttons', 'sdm_downloads_register_button');
875
  }
876
 
877
  function sdm_downloads_add_button($plugin_array) {
878
 
879
+ $plugin_array['sdm_downloads'] = WP_SIMPLE_DL_MONITOR_URL . '/tinymce/sdm_editor_plugin.js';
880
+ return $plugin_array;
881
  }
882
 
883
  function sdm_downloads_register_button($buttons) {
884
 
885
+ $buttons[] = 'sdm_downloads';
886
+ return $buttons;
887
  }
888
 
889
  }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Simple Download Monitor ===
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.9
7
- Stable tag: 3.4.8
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -45,6 +45,7 @@ https://www.youtube.com/watch?v=utYIH0fILuQ
45
  * Option to upload a thumbnail image for each of your downloadable files.
46
  * Option to use a nice looking template to show your download now buttons.
47
  * Ability to search and sort your downloadable files in the admin dashboard.
 
48
  * Track the number of downloads for each of your files.
49
  * Track the visitors country.
50
  * View the daily download counts of your items in a chart.
@@ -63,9 +64,10 @@ https://www.youtube.com/watch?v=utYIH0fILuQ
63
  * Shortcode to show a number of latest downloads to your visitors.
64
  * Ability to disable the download monitoring (logging) for certain items (or all items).
65
  * You can also choose to only monitor downloads from unique IP address only.
66
- * Option to specify file size info so it can be shown to your visitors.
67
  * Option to specify version number info for the download item so it can be shown to your visitors.
68
  * Option to restrict downloads to logged-in users only.
 
69
 
70
  View more details on the [download monitor plugin](https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin) page.
71
 
@@ -120,15 +122,20 @@ Example Shortcode Usage:
120
 
121
  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.
122
 
123
- = Detailed Usage Documentation =
124
 
125
- View more usage instructions on the [Download Monitor Plugin](https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin) page.
 
126
 
127
- = Github Repository =
 
 
 
 
128
 
129
  https://github.com/Arsenal21/simple-download-monitor
130
 
131
- If you need some extra action hooks or filters for this plugin then let us know.
132
 
133
  == Installation ==
134
 
@@ -172,8 +179,45 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
172
 
173
  == Changelog ==
174
 
175
- = TODO 3.4.9 =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  - Updated the settings menu slug to make it unique.
 
177
 
178
  = 3.4.8 =
179
  - Fixed an issue with the shortcode inserter interface showing the last 5 items only.
1
  === Simple Download Monitor ===
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: 4.9
7
+ Stable tag: 3.5.9
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
45
  * Option to upload a thumbnail image for each of your downloadable files.
46
  * Option to use a nice looking template to show your download now buttons.
47
  * Ability to search and sort your downloadable files in the admin dashboard.
48
+ * Ability to create a search page and allow your visitors to search your downloads.
49
  * Track the number of downloads for each of your files.
50
  * Track the visitors country.
51
  * View the daily download counts of your items in a chart.
64
  * Shortcode to show a number of latest downloads to your visitors.
65
  * Ability to disable the download monitoring (logging) for certain items (or all items).
66
  * You can also choose to only monitor downloads from unique IP address only.
67
+ * Option to specify file size info so it can be shown to your visitors. [View the tutorial](https://simple-download-monitor.com/how-to-show-file-size-info-of-your-downloads/)
68
  * Option to specify version number info for the download item so it can be shown to your visitors.
69
  * Option to restrict downloads to logged-in users only.
70
+ * Option to ignore download count from bots.
71
 
72
  View more details on the [download monitor plugin](https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin) page.
73
 
122
 
123
  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.
124
 
125
+ ** 3rd Party or External Libraries/Services **
126
 
127
+ The plugin uses the Google Charts library to show the download count charts in the admin interface (if you use the stats menu of the plugin). You can see more details about this library at the following URL:
128
+ https://developers.google.com/chart/
129
 
130
+ ** Detailed Usage Documentation **
131
+
132
+ View more usage instructions on the [Download Monitor Plugin](https://simple-download-monitor.com/) page.
133
+
134
+ ** Github Repository **
135
 
136
  https://github.com/Arsenal21/simple-download-monitor
137
 
138
+ If you need extra action hooks or filters for this plugin then let us know.
139
 
140
  == Installation ==
141
 
179
 
180
  == Changelog ==
181
 
182
+ = 3.5.9 =
183
+ - Added a new option in the settings that allows you to disable capturing of visitor's IP address in the download logs menu. Helpful for GDPR
184
+
185
+ = 3.5.8 =
186
+ - Added a new shortcode to allow listing of all downloads on a post/page.
187
+
188
+ = 3.5.7 =
189
+ - Fixed an issue with the new shortcode that was added. Usage documentation of the shortcode: https://simple-download-monitor.com/showing-specific-details-of-a-download-item-using-a-shortcode/
190
+
191
+ = 3.5.6 =
192
+ - Added a new shortcode to show any info/details of the download item. Example shortcode: [sdm_show_download_info id="123" download_info="title"]
193
+
194
+ = 3.5.5 =
195
+ - Fixed a PHP warning.
196
+ - Added sanitization to the input fields that needed it.
197
+ - Listed the 3rd party libraries/services used in the readme file.
198
+
199
+ = 3.5.4 =
200
+ - Fixed stored-XSS bug. Thanks to d4wner.
201
+
202
+ = 3.5.3 =
203
+ - Added "Text Domain" and "Domain Path" to the File Header.
204
+
205
+ = 3.5.2 =
206
+ - Renamed the "langs" folder to "languages"
207
+
208
+ = 3.5.1 =
209
+ - Added a few more user-agents check in the is_bot function.
210
+ - Search shortcode has been improved so it performs the search using each keyword of a multi-word search phrase. It will ignore any word that are less than 4 characters long.
211
+ - Includes some missing translation strings to the POT file.
212
+
213
+ = 3.5.0 =
214
+ - Added check for a couple of user-agents in the is_bot function.
215
+ - Added a filter that can be used to override what you consider bot via your own custom function.
216
+
217
+ = 3.4.9 =
218
+ - Added a new option in the settings menu to ignore downloads from bots. The name of the new settings field is "Do Not Count Downloads from Bots".
219
  - Updated the settings menu slug to make it unique.
220
+ - Enhancement to the password protected download function.
221
 
222
  = 3.4.8 =
223
  - Fixed an issue with the shortcode inserter interface showing the last 5 items only.
sdm-post-type-content-handler.php CHANGED
@@ -4,7 +4,7 @@ add_filter('the_content', 'filter_sdm_post_type_content');
4
 
5
  function filter_sdm_post_type_content($content) {
6
  global $post;
7
- if ($post->post_type == "sdm_downloads") {//Handle the content for sdm_downloads type post
8
  //$download_id = $post->ID;
9
  //$args = array('id' => $download_id, 'fancy' => '1');
10
  //$content = sdm_create_download_shortcode($args);
@@ -48,7 +48,7 @@ function filter_sdm_post_type_content($content) {
48
  $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '">' . $button_text_string . '</a>';
49
 
50
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
51
- $download_button_code = sdm_get_password_entry_form($id);
52
  }
53
 
54
  // Check if we only allow the download for logged-in users
4
 
5
  function filter_sdm_post_type_content($content) {
6
  global $post;
7
+ if (isset($post->post_type) && $post->post_type == "sdm_downloads") {//Handle the content for sdm_downloads type post
8
  //$download_id = $post->ID;
9
  //$args = array('id' => $download_id, 'fancy' => '1');
10
  //$content = sdm_create_download_shortcode($args);
48
  $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '">' . $button_text_string . '</a>';
49
 
50
  if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
51
+ $download_button_code = sdm_get_password_entry_form($id,array(),'sdm_download ' . $def_color);
52
  }
53
 
54
  // Check if we only allow the download for logged-in users
sdm-shortcodes.php CHANGED
@@ -1,26 +1,33 @@
1
  <?php
2
 
3
- add_filter('widget_text', 'do_shortcode'); //Enable shortcode filtering in standard text widget
4
 
5
  /*
6
  * * Register and handle Shortcode
7
  */
8
 
9
  function sdm_register_shortcodes() {
10
- add_shortcode('sdm_download', 'sdm_create_download_shortcode'); // For download shortcode (underscores)
11
- add_shortcode('sdm-download', 'sdm_create_download_shortcode'); // For download shortcode (for backwards compatibility)
12
- add_shortcode('sdm_download_counter', 'sdm_create_counter_shortcode'); // For counter shortcode (underscores)
13
- add_shortcode('sdm-download-counter', 'sdm_create_counter_shortcode'); // For counter shortcode (for backwards compatibility)
14
- add_shortcode('sdm_latest_downloads', 'sdm_show_latest_downloads'); // For showing X number of latest downloads
15
- add_shortcode('sdm-latest-downloads', 'sdm_show_latest_downloads'); // For showing X number of latest downloads(for backwards compatibility)
16
 
17
- add_shortcode('sdm_download_link', 'sdm_create_simple_download_link');
18
 
19
- add_shortcode('sdm_show_dl_from_category', 'sdm_handle_category_shortcode'); //For category shortcode
20
- add_shortcode('sdm_download_categories', 'sdm_download_categories_shortcode'); // Ajax file tree browser
 
 
 
 
21
 
22
- add_shortcode('sdm_download_categories_list', 'sdm_download_categories_list_shortcode');
23
- add_shortcode('sdm_search_form', 'sdm_search_form_shortcode');
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
  /**
@@ -30,289 +37,297 @@ function sdm_register_shortcodes() {
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'] = isset($main_opts['download_button_color']) ? strtolower($main_opts['download_button_color']) // default values needs to be lowercased
44
- : 'green'
45
- ;
46
  }
47
 
48
  // Remove spaces from color key to make a proper CSS class name.
49
- $atts['color'] = str_replace(' ', '', $atts['color']);
50
 
51
  return $atts;
52
  }
53
 
54
  // Create Download Shortcode
55
- function sdm_create_download_shortcode($atts) {
56
 
57
  $shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
58
- shortcode_atts(array(
59
- 'id' => '',
60
- 'fancy' => '0',
61
- 'button_text' => __('Download Now!', 'simple-download-monitor'),
62
- 'new_window' => '',
63
- 'color' => '',
64
- 'css_class' => '',
65
- 'show_size' => '',
66
- 'show_version' => '',
67
- ), $atts)
68
  );
69
 
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>';
75
  }
76
 
77
  // Check to see if the download link cpt is password protected
78
- $get_cpt_object = get_post($id);
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, $atts);
92
  }
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);
113
  }
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
128
- function sdm_create_counter_shortcode($atts) {
129
 
130
- extract(shortcode_atts(array(
131
- 'id' => ''
132
- ), $atts));
133
 
134
- if (empty($id)) {
135
- return '<p style="color: red;">' . __('Error! Please enter an ID value with this shortcode.', 'simple-download-monitor') . '</p>';
136
  }
137
 
138
- $db_count = sdm_get_download_count_for_post($id);
139
 
140
  // Set string for singular/plural results
141
- $string = ($db_count == '1') ? __('Download', 'simple-download-monitor') : __('Downloads', 'simple-download-monitor');
142
 
143
  $output = '<div class="sdm_download_count"><span class="sdm_count_number">' . $db_count . '</span><span class="sdm_count_string"> ' . $string . '</span></div>';
144
  // Return result
145
- return apply_filters('sdm_download_count_output', $output, $atts);
146
  }
147
 
148
  // Create Category Shortcode
149
- function sdm_handle_category_shortcode($args) {
150
-
151
- extract(shortcode_atts(array(
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',
159
- 'pagination' => '',
160
- ), $args));
161
 
162
  // Define vars
163
- $field = '';
164
- $terms = '';
165
 
166
  // If category slug and category id are empty.. return error
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;
181
  }
182
  // Else setup query arguments for category_id
183
- else if (!empty($category_id) && empty($category_slug)) {
 
 
 
 
184
 
185
- $field = 'term_id';
186
- $terms = $category_id;
 
 
 
 
 
 
187
  }
188
 
189
  // For pagination
190
- $paged = ( get_query_var('paged') ) ? absint(get_query_var('paged')) : 1;
191
- if (isset($args['pagination'])) {
192
- if (!is_numeric($args['pagination'])) {
193
- return '<p style="color: red;">' . __('Error! You must enter a numeric number for the "pagination" parameter of the shortcode. Refer to the usage documentation.', 'simple-download-monitor') . '</p>';
194
- }
195
- $posts_per_page = $args['pagination'];
196
  } else {
197
- $posts_per_page = 9999;
198
  }
199
 
200
 
201
  // Query cpt's based on arguments above
202
- $get_posts = get_posts(array(
203
- 'post_type' => 'sdm_downloads',
204
- 'show_posts' => -1,
205
- 'posts_per_page' => $posts_per_page,
206
- 'tax_query' => array(
207
- array(
208
- 'taxonomy' => 'sdm_categories',
209
- 'field' => $field,
210
- 'terms' => $terms
211
- )
212
- ),
213
- 'orderby' => $orderby,
214
- 'order' => $order,
215
- 'paged' => $paged,
216
- ));
217
 
218
  // If no cpt's are found
219
- if (!$get_posts) {
220
- return '<p style="color: red;">' . __('There are no download items matching this category criteria.', 'simple-download-monitor') . '</p>';
221
  }
222
  // Else iterate cpt's
223
  else {
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') {
261
- include_once('includes/templates/fancy2/sdm-fancy-2.php');
262
- $output .= sdm_generate_fancy2_category_display_output($get_posts, $args);
263
- }
264
-
265
- // Pagination related
266
- if (isset($args['pagination'])) {
267
- $posts_per_page = $args['pagination'];
268
- $count_sdm_posts = wp_count_posts('sdm_downloads');
269
- $published_sdm_posts = $count_sdm_posts->publish;
270
- $total_pages = ceil($published_sdm_posts / $posts_per_page);
271
-
272
- $big = 999999999; // Need an unlikely integer
273
- $pagination = paginate_links(array(
274
- 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
275
- 'format' => '',
276
- 'add_args' => '',
277
- 'current' => max(1, get_query_var('paged')),
278
- 'total' => $total_pages,
279
- 'prev_text' => '&larr;',
280
- 'next_text' => '&rarr;',
281
- ));
282
- $output .= '<div class="sdm_pagination">' . $pagination . '</div>';
283
- }
284
-
285
- // Return results
286
- return apply_filters('sdm_category_download_items_shortcode_output', $output, $args, $get_posts);
287
  } // End else iterate cpt's
288
  }
289
 
290
  // Create category tree shortcode
291
  function sdm_download_categories_shortcode() {
292
 
293
- function custom_taxonomy_walker($taxonomy, $parent = 0) {
294
-
295
- // Get terms (check if has parent)
296
- $terms = get_terms($taxonomy, array('parent' => $parent, 'hide_empty' => false));
297
-
298
- // If there are terms, start displaying
299
- if (count($terms) > 0) {
300
- // Displaying as a list
301
- $out = '<ul>';
302
- // Cycle though the terms
303
- foreach ($terms as $term) {
304
- // Secret sauce. Function calls itself to display child elements, if any
305
- $out .= '<li class="sdm_cat" id="' . $term->slug . '"><span id="' . $term->term_id . '" class="sdm_cat_title" style="cursor:pointer;">' . $term->name . '</span>';
306
- $out .= '<p class="sdm_placeholder" style="margin-bottom:0;"></p>' . custom_taxonomy_walker($taxonomy, $term->term_id);
307
- $out .= '</li>';
308
- }
309
- $out .= '</ul>';
310
- return $out;
311
- }
312
- return;
313
  }
314
 
315
- return '<div class="sdm_object_tree">' . custom_taxonomy_walker('sdm_categories') . '</div>';
316
  }
317
 
318
  /**
@@ -321,35 +336,35 @@ function sdm_download_categories_shortcode() {
321
  * @param int $parent
322
  * @return string
323
  */
324
- function sdm_download_categories_list_walker($atts, $parent = 0) {
325
 
326
- $count = (bool) $atts['count'];
327
- $hierarchical = (bool) $atts['hierarchical'];
328
- $show_empty = (bool) $atts['empty'];
329
- $list_tag = $atts['numbered'] ? 'ol' : 'ul';
330
 
331
  // Get terms (check if has parent)
332
- $terms = get_terms(array(
333
- 'taxonomy' => 'sdm_categories',
334
- 'parent' => $parent,
335
- 'hide_empty' => !$show_empty
336
- ));
337
 
338
  // Return empty string, if no terms found.
339
- if (empty($terms)) {
340
- return '';
341
  }
342
 
343
  // Produce list of download categories under $parent.
344
  $out = '<' . $list_tag . '>';
345
 
346
- foreach ($terms as $term) {
347
- $out .= '<li>'
348
- . '<a href="' . get_term_link($term) . '">' . $term->name . '</a>' // link
349
- . ( $count ? (' <span>(' . $term->count . ')</span>') : '') // count
350
- . ( $hierarchical ? sdm_download_categories_list_walker($atts, $term->term_id) : '' ) // subcategories
351
- . '</li>'
352
- ;
353
  }
354
 
355
  $out .= '</' . $list_tag . '>';
@@ -362,21 +377,91 @@ function sdm_download_categories_list_walker($atts, $parent = 0) {
362
  * @param array $attributes
363
  * @return string
364
  */
365
- function sdm_download_categories_list_shortcode($attributes) {
366
 
367
  $atts = shortcode_atts(
368
- array(
369
- 'class' => 'sdm-download-categories', // wrapper class
370
- 'empty' => '0', // show empty categories
371
- 'numbered' => '0', // use <ol> instead of <ul> to wrap the list
372
- 'count' => '0', // display count of items in every category
373
- 'hierarchical' => '1', // display subcategories as well
374
- ), $attributes
375
  );
376
 
377
  return
378
- '<div class="' . esc_attr($atts['class']) . '">'
379
- . sdm_download_categories_list_walker($atts)
380
- . '</div>'
381
  ;
382
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ add_filter( 'widget_text', 'do_shortcode' ); //Enable shortcode filtering in standard text widget
4
 
5
  /*
6
  * * Register and handle Shortcode
7
  */
8
 
9
  function sdm_register_shortcodes() {
 
 
 
 
 
 
10
 
11
+ //Note: shortcode name should use underscores (not dashes). Some of the shortcodes have dashes for backwards compatibility.
12
 
13
+ add_shortcode( 'sdm_download', 'sdm_create_download_shortcode' ); // For download shortcode (underscores)
14
+ add_shortcode( 'sdm-download', 'sdm_create_download_shortcode' ); // For download shortcode (for backwards compatibility)
15
+ add_shortcode( 'sdm_download_counter', 'sdm_create_counter_shortcode' ); // For counter shortcode (underscores)
16
+ add_shortcode( 'sdm-download-counter', 'sdm_create_counter_shortcode' ); // For counter shortcode (for backwards compatibility)
17
+ add_shortcode( 'sdm_latest_downloads', 'sdm_show_latest_downloads' ); // For showing X number of latest downloads
18
+ add_shortcode( 'sdm-latest-downloads', 'sdm_show_latest_downloads' ); // For showing X number of latest downloads(for backwards compatibility)
19
 
20
+ add_shortcode( 'sdm_download_link', 'sdm_create_simple_download_link' );
21
+
22
+ add_shortcode( 'sdm_show_all_dl', 'sdm_handle_show_all_dl_shortcode' ); // For show all downloads shortcode
23
+
24
+ add_shortcode( 'sdm_show_dl_from_category', 'sdm_handle_category_shortcode' ); //For category shortcode
25
+ add_shortcode( 'sdm_download_categories', 'sdm_download_categories_shortcode' ); // Ajax file tree browser
26
+
27
+ add_shortcode( 'sdm_download_categories_list', 'sdm_download_categories_list_shortcode' );
28
+ add_shortcode( 'sdm_search_form', 'sdm_search_form_shortcode' );
29
+
30
+ add_shortcode( 'sdm_show_download_info', 'sdm_show_download_info_shortcode' );
31
  }
32
 
33
  /**
37
  * @param array $atts
38
  * @return array
39
  */
40
+ function sanitize_sdm_create_download_shortcode_atts( $atts ) {
41
 
42
  // Sanitize download item ID
43
+ $atts[ 'id' ] = absint( $atts[ 'id' ] );
44
 
45
  // See if user color option is selected
46
+ $main_opts = get_option( 'sdm_downloads_options' );
47
 
48
+ if ( empty( $atts[ 'color' ] ) ) {
49
+ // No color provided by shortcode, read color from plugin settings.
50
+ $atts[ 'color' ] = isset( $main_opts[ 'download_button_color' ] ) ? strtolower( $main_opts[ 'download_button_color' ] ) // default values needs to be lowercased
51
+ : 'green'
52
+ ;
53
  }
54
 
55
  // Remove spaces from color key to make a proper CSS class name.
56
+ $atts[ 'color' ] = str_replace( ' ', '', $atts[ 'color' ] );
57
 
58
  return $atts;
59
  }
60
 
61
  // Create Download Shortcode
62
+ function sdm_create_download_shortcode( $atts ) {
63
 
64
  $shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
65
+ shortcode_atts( array(
66
+ 'id' => '',
67
+ 'fancy' => '0',
68
+ 'button_text' => __( 'Download Now!', 'simple-download-monitor' ),
69
+ 'new_window' => '',
70
+ 'color' => '',
71
+ 'css_class' => '',
72
+ 'show_size' => '',
73
+ 'show_version' => '',
74
+ ), $atts )
75
  );
76
 
77
  // Make shortcode attributes available in function local scope.
78
+ extract( $shortcode_atts );
79
 
80
+ if ( empty( $id ) ) {
81
+ return '<p style="color: red;">' . __( 'Error! Please enter an ID value with this shortcode.', 'simple-download-monitor' ) . '</p>';
82
  }
83
 
84
  // Check to see if the download link cpt is password protected
85
+ $get_cpt_object = get_post( $id );
86
+ $cpt_is_password = ! empty( $get_cpt_object->post_password ) ? 'yes' : 'no'; // yes = download is password protected;
87
  // Get CPT title
88
+ $item_title = get_the_title( $id );
89
 
90
  //*** Generate the download now button code ***
91
+ $window_target = empty( $new_window ) ? '_self' : '_blank';
92
 
93
+ $homepage = get_bloginfo( 'url' );
94
+ $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
95
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
96
 
97
+ if ( $cpt_is_password !== 'no' ) {//This is a password protected download so replace the download now button with password requirement
98
+ $download_button_code = sdm_get_password_entry_form( $id, $shortcode_atts, 'sdm_download ' . $color );
99
  }
100
  //End of download now button code generation
101
 
102
  $output = '';
103
+ switch ( $fancy ) {
104
+ case '1':
105
+ include_once('includes/templates/fancy1/sdm-fancy-1.php');
106
+ $output .= sdm_generate_fancy1_display_output( $shortcode_atts );
107
+ $output .= '<div class="sdm_clear_float"></div>';
108
+ break;
109
+ case '2':
110
+ include_once('includes/templates/fancy2/sdm-fancy-2.php');
111
+ $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 . '" />';
112
+ $output .= sdm_generate_fancy2_display_output( $shortcode_atts );
113
+ $output .= '<div class="sdm_clear_float"></div>';
114
+ break;
115
+ default: // Default output is the standard download now button (fancy 0)
116
+ $output = '<div class="sdm_download_link">' . $download_button_code . '</div>';
117
  }
118
 
119
+ return apply_filters( 'sdm_download_shortcode_output', $output, $atts );
120
  }
121
 
122
+ function sdm_create_simple_download_link( $atts ) {
123
+ extract( shortcode_atts( array(
124
+ 'id' => '',
125
+ ), $atts ) );
126
 
127
+ if ( empty( $id ) ) {
128
+ return '<p style="color: red;">' . __( 'Error! Please enter an ID value with this shortcode.', 'simple-download-monitor' ) . '</p>';
129
  }
130
 
131
  return WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
132
  }
133
 
134
  // Create Counter Shortcode
135
+ function sdm_create_counter_shortcode( $atts ) {
136
 
137
+ extract( shortcode_atts( array(
138
+ 'id' => ''
139
+ ), $atts ) );
140
 
141
+ if ( empty( $id ) ) {
142
+ return '<p style="color: red;">' . __( 'Error! Please enter an ID value with this shortcode.', 'simple-download-monitor' ) . '</p>';
143
  }
144
 
145
+ $db_count = sdm_get_download_count_for_post( $id );
146
 
147
  // Set string for singular/plural results
148
+ $string = ($db_count == '1') ? __( 'Download', 'simple-download-monitor' ) : __( 'Downloads', 'simple-download-monitor' );
149
 
150
  $output = '<div class="sdm_download_count"><span class="sdm_count_number">' . $db_count . '</span><span class="sdm_count_string"> ' . $string . '</span></div>';
151
  // Return result
152
+ return apply_filters( 'sdm_download_count_output', $output, $atts );
153
  }
154
 
155
  // Create Category Shortcode
156
+ function sdm_handle_category_shortcode( $args ) {
157
+
158
+ extract( shortcode_atts( array(
159
+ 'category_slug' => '',
160
+ 'category_id' => '',
161
+ 'fancy' => '0',
162
+ 'button_text' => __( 'Download Now!', 'simple-download-monitor' ),
163
+ 'new_window' => '',
164
+ 'orderby' => 'post_date',
165
+ 'order' => 'DESC',
166
+ 'pagination' => '',
167
+ ), $args ) );
168
 
169
  // Define vars
170
+ $field = '';
171
+ $terms = '';
172
 
173
  // If category slug and category id are empty.. return error
174
+ if ( empty( $category_slug ) && empty( $category_id ) && empty( $args[ 'show_all' ] ) ) {
175
+ 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>';
176
  }
177
 
178
  // If both category slug AND category id are defined... return error
179
+ if ( ! empty( $category_slug ) && ! empty( $category_id ) ) {
180
+ return '<p style="color: red;">' . __( 'Error! Please enter a category slug OR id; not both.', 'simple-download-monitor' ) . '</p>';
181
  }
182
 
183
  // Else setup query arguments for category_slug
184
+ if ( ! empty( $category_slug ) && empty( $category_id ) ) {
185
 
186
+ $field = 'slug';
187
+ $terms = $category_slug;
188
  }
189
  // Else setup query arguments for category_id
190
+ else if ( ! empty( $category_id ) && empty( $category_slug ) ) {
191
+
192
+ $field = 'term_id';
193
+ $terms = $category_id;
194
+ }
195
 
196
+ if ( isset( $args[ 'show_all' ] ) ) {
197
+ $tax_query = array();
198
+ } else {
199
+ $tax_query = array( array(
200
+ 'taxonomy' => 'sdm_categories',
201
+ 'field' => $field,
202
+ 'terms' => $terms
203
+ ) );
204
  }
205
 
206
  // For pagination
207
+ $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
208
+ if ( isset( $args[ 'pagination' ] ) ) {
209
+ if ( ! is_numeric( $args[ 'pagination' ] ) ) {
210
+ return '<p style="color: red;">' . __( 'Error! You must enter a numeric number for the "pagination" parameter of the shortcode. Refer to the usage documentation.', 'simple-download-monitor' ) . '</p>';
211
+ }
212
+ $posts_per_page = $args[ 'pagination' ];
213
  } else {
214
+ $posts_per_page = 9999;
215
  }
216
 
217
 
218
  // Query cpt's based on arguments above
219
+ $get_posts_args = array(
220
+ 'post_type' => 'sdm_downloads',
221
+ 'show_posts' => -1,
222
+ 'posts_per_page' => $posts_per_page,
223
+ 'tax_query' => $tax_query,
224
+ 'orderby' => $orderby,
225
+ 'order' => $order,
226
+ 'paged' => $paged,
227
+ );
228
+
229
+ $query = new WP_Query;
230
+
231
+ $get_posts = $query->query( $get_posts_args );
 
 
232
 
233
  // If no cpt's are found
234
+ if ( ! $get_posts ) {
235
+ return '<p style="color: red;">' . __( 'There are no download items matching this category criteria.', 'simple-download-monitor' ) . '</p>';
236
  }
237
  // Else iterate cpt's
238
  else {
239
 
240
+ $output = '';
241
+
242
+ // See if user color option is selected
243
+ $main_opts = get_option( 'sdm_downloads_options' );
244
+ $color_opt = $main_opts[ 'download_button_color' ];
245
+ $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : 'green';
246
+
247
+ if ( $fancy == '0' ) {
248
+
249
+ // Setup download location
250
+ $homepage = get_bloginfo( 'url' );
251
+
252
+ $window_target = empty( $new_window ) ? '_self' : '_blank';
253
+
254
+ // Iterate cpt's
255
+ foreach ( $get_posts as $item ) {
256
+
257
+ // Set download location
258
+ $id = $item->ID; // get each cpt ID
259
+ $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
260
+
261
+ // Get each cpt title
262
+ $item_title = get_the_title( $id );
263
+
264
+ // Setup download button code
265
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
266
+
267
+ // Generate download buttons
268
+ $output .= '<div class="sdm_download_link">' . $download_button_code . '</div><br />';
269
+ } // End foreach
270
+ }
271
+ // Fancy 1 and onwards handles the loop inside the template function
272
+ else if ( $fancy == '1' ) {
273
+ include_once('includes/templates/fancy1/sdm-fancy-1.php');
274
+ $output .= sdm_generate_fancy1_category_display_output( $get_posts, $args );
275
+ } else if ( $fancy == '2' ) {
276
+ include_once('includes/templates/fancy2/sdm-fancy-2.php');
277
+ $output .= sdm_generate_fancy2_category_display_output( $get_posts, $args );
278
+ }
279
+
280
+ // Pagination related
281
+ if ( isset( $args[ 'pagination' ] ) ) {
282
+ $posts_per_page = $args[ 'pagination' ];
283
+ $count_sdm_posts = $query->found_posts;
284
+ $published_sdm_posts = $count_sdm_posts;
285
+ $total_pages = ceil( $published_sdm_posts / $posts_per_page );
286
+
287
+ $big = 999999999; // Need an unlikely integer
288
+ $pagination = paginate_links( array(
289
+ 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
290
+ 'format' => '',
291
+ 'add_args' => '',
292
+ 'current' => max( 1, get_query_var( 'paged' ) ),
293
+ 'total' => $total_pages,
294
+ 'prev_text' => '&larr;',
295
+ 'next_text' => '&rarr;',
296
+ ) );
297
+ $output .= '<div class="sdm_pagination">' . $pagination . '</div>';
298
+ }
299
+
300
+ // Return results
301
+ return apply_filters( 'sdm_category_download_items_shortcode_output', $output, $args, $get_posts );
302
  } // End else iterate cpt's
303
  }
304
 
305
  // Create category tree shortcode
306
  function sdm_download_categories_shortcode() {
307
 
308
+ function custom_taxonomy_walker( $taxonomy, $parent = 0 ) {
309
+
310
+ // Get terms (check if has parent)
311
+ $terms = get_terms( $taxonomy, array( 'parent' => $parent, 'hide_empty' => false ) );
312
+
313
+ // If there are terms, start displaying
314
+ if ( count( $terms ) > 0 ) {
315
+ // Displaying as a list
316
+ $out = '<ul>';
317
+ // Cycle though the terms
318
+ foreach ( $terms as $term ) {
319
+ // Secret sauce. Function calls itself to display child elements, if any
320
+ $out .= '<li class="sdm_cat" id="' . $term->slug . '"><span id="' . $term->term_id . '" class="sdm_cat_title" style="cursor:pointer;">' . $term->name . '</span>';
321
+ $out .= '<p class="sdm_placeholder" style="margin-bottom:0;"></p>' . custom_taxonomy_walker( $taxonomy, $term->term_id );
322
+ $out .= '</li>';
323
+ }
324
+ $out .= '</ul>';
325
+ return $out;
326
+ }
327
+ return;
328
  }
329
 
330
+ return '<div class="sdm_object_tree">' . custom_taxonomy_walker( 'sdm_categories' ) . '</div>';
331
  }
332
 
333
  /**
336
  * @param int $parent
337
  * @return string
338
  */
339
+ function sdm_download_categories_list_walker( $atts, $parent = 0 ) {
340
 
341
+ $count = (bool) $atts[ 'count' ];
342
+ $hierarchical = (bool) $atts[ 'hierarchical' ];
343
+ $show_empty = (bool) $atts[ 'empty' ];
344
+ $list_tag = $atts[ 'numbered' ] ? 'ol' : 'ul';
345
 
346
  // Get terms (check if has parent)
347
+ $terms = get_terms( array(
348
+ 'taxonomy' => 'sdm_categories',
349
+ 'parent' => $parent,
350
+ 'hide_empty' => ! $show_empty
351
+ ) );
352
 
353
  // Return empty string, if no terms found.
354
+ if ( empty( $terms ) ) {
355
+ return '';
356
  }
357
 
358
  // Produce list of download categories under $parent.
359
  $out = '<' . $list_tag . '>';
360
 
361
+ foreach ( $terms as $term ) {
362
+ $out .= '<li>'
363
+ . '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>' // link
364
+ . ( $count ? (' <span>(' . $term->count . ')</span>') : '') // count
365
+ . ( $hierarchical ? sdm_download_categories_list_walker( $atts, $term->term_id ) : '' ) // subcategories
366
+ . '</li>'
367
+ ;
368
  }
369
 
370
  $out .= '</' . $list_tag . '>';
377
  * @param array $attributes
378
  * @return string
379
  */
380
+ function sdm_download_categories_list_shortcode( $attributes ) {
381
 
382
  $atts = shortcode_atts(
383
+ array(
384
+ 'class' => 'sdm-download-categories', // wrapper class
385
+ 'empty' => '0', // show empty categories
386
+ 'numbered' => '0', // use <ol> instead of <ul> to wrap the list
387
+ 'count' => '0', // display count of items in every category
388
+ 'hierarchical' => '1', // display subcategories as well
389
+ ), $attributes
390
  );
391
 
392
  return
393
+ '<div class="' . esc_attr( $atts[ 'class' ] ) . '">'
394
+ . sdm_download_categories_list_walker( $atts )
395
+ . '</div>'
396
  ;
397
  }
398
+
399
+ function sdm_show_download_info_shortcode( $args ) {
400
+ extract( shortcode_atts( array(
401
+ 'id' => '',
402
+ 'download_info' => '',
403
+ ), $args ) );
404
+
405
+ if ( empty( $id ) || empty( $download_info ) ) {
406
+ return '<div class="sdm_shortcode_error">Error! you must enter a value for "id" and "download_info" parameters.</div>';
407
+ }
408
+
409
+ //Available values: title, description, download_url, thumbnail, file_size, file_version, download_count
410
+
411
+ $id = absint( $id );
412
+ $get_cpt_object = get_post( $id );
413
+
414
+ if ( $download_info == "title" ) {//download title
415
+ $item_title = get_the_title( $id );
416
+ return $item_title;
417
+ }
418
+
419
+ if ( $download_info == "description" ) {//download description
420
+ $item_description = sdm_get_item_description_output( $id );
421
+ return $item_description;
422
+ }
423
+
424
+ if ( $download_info == "download_url" ) {//download URL
425
+ $download_link = get_post_meta( $id, 'sdm_upload', true );
426
+ return $download_link;
427
+ }
428
+
429
+ if ( $download_info == "thumbnail" ) {//download thumb
430
+ $download_thumbnail = get_post_meta( $id, 'sdm_upload_thumbnail', true );
431
+ $download_thumbnail = '<img class="sdm_download_thumbnail_image" src="' . $download_thumbnail . '" />';
432
+ return $download_thumbnail;
433
+ }
434
+
435
+ if ( $download_info == "thumbnail_url" ) {//download thumbnail raw URL
436
+ $download_thumbnail = get_post_meta( $id, 'sdm_upload_thumbnail', true );
437
+ return $download_thumbnail;
438
+ }
439
+
440
+ if ( $download_info == "file_size" ) {//download file size
441
+ $file_size = get_post_meta( $id, 'sdm_item_file_size', true );
442
+ return $file_size;
443
+ }
444
+
445
+ if ( $download_info == "file_version" ) {//download file version
446
+ $file_version = get_post_meta( $id, 'sdm_item_version', true );
447
+ return $file_version;
448
+ }
449
+
450
+ if ( $download_info == "download_count" ) {//download count
451
+ $dl_count = sdm_get_download_count_for_post( $id );
452
+ return $dl_count;
453
+ }
454
+
455
+ return '<div class="sdm_shortcode_error">Error! The value of "download_info" field does not match any availalbe parameters.</div>';
456
+ }
457
+
458
+ function sdm_handle_show_all_dl_shortcode( $args ) {
459
+ if ( isset( $args[ 'category_id' ] ) ) {
460
+ unset( $args[ 'category_id' ] );
461
+ }
462
+ if ( isset( $args[ 'category_slug' ] ) ) {
463
+ unset( $args[ 'category_slug' ] );
464
+ }
465
+ $args[ 'show_all' ] = 1;
466
+ return sdm_handle_category_shortcode( $args );
467
+ }
tinymce/img/Thumbs.db DELETED
Binary file
tinymce/img/sdm_downloads.png DELETED
Binary file