Simple Download Monitor - Version 3.7.4.2

Version Description

  • Fixed [sdm_popular_downloads] shortcode was ignoring button_text parameter for fancy 1 and fancy 2 templates.
Download this release

Release Info

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

Code changes from version 3.7.2 to 3.7.4.2

includes/admin-side/sdm-admin-individual-item-logs-page.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function sdm_handle_individual_logs_tab_page(){
4
+ echo '<h2>';
5
+ _e( 'Specific Download Item Logs', 'simple-download-monitor' );
6
+ echo '</h2>';
7
+
8
+ $sdm_logs_dl_id = isset($_REQUEST['sdm_logs_dl_id'])? sanitize_text_field($_REQUEST['sdm_logs_dl_id']): '';
9
+
10
+ if(isset($_REQUEST['sdm_show_specific_item_logs'])){
11
+ $sdm_specific_download_id = isset($_REQUEST['sdm_specific_download_id'])? sanitize_text_field($_REQUEST['sdm_specific_download_id']): '';
12
+ if(!empty($sdm_specific_download_id)){
13
+ $target_url = 'edit.php?post_type=sdm_downloads&page=sdm-logs&action=sdm-logs-by-download&sdm_logs_dl_id='.$sdm_specific_download_id;
14
+ sdm_redirect_to_url( $target_url );
15
+ exit;
16
+ }
17
+ }
18
+
19
+ ?>
20
+
21
+ <div style="background:#ECECEC;border:1px solid #CCC;padding:0 10px;margin-top:5px;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;">
22
+ <p><?php _e( 'This menu allows you to view the download logs of individual items.', 'simple-download-monitor' ); ?></p>
23
+ </div>
24
+
25
+ <div id="poststuff"><div id="post-body">
26
+
27
+ <div class="postbox">
28
+ <h3 class="hndle"><label for="title"><?php _e( 'View Specific Item Logs', 'simple-download-monitor' ); ?></label></h3>
29
+ <div class="inside">
30
+ <form method="post" action="" >
31
+ <?php _e('Enter the Download ID of the item: ', 'simple-download-monitor' ); ?>
32
+ <input type="text" name="sdm_specific_download_id" value="<?php echo esc_attr($sdm_logs_dl_id); ?>" size="10" />
33
+ <p class='description'>
34
+ <?php _e('You can find the Download ID of an item from the Downloads menu of the plugin.', 'simple-download-monitor' ); ?>
35
+ </p>
36
+ <div class="submit">
37
+ <input type="submit" class="button" name="sdm_show_specific_item_logs" value="<?php _e( 'View Logs', 'simple-download-monitor' ); ?>" />
38
+ </div>
39
+ </form>
40
+ </div>
41
+ </div>
42
+
43
+ </div></div><!-- end of .poststuff and .post-body -->
44
+
45
+ <?php
46
+ if(isset($sdm_logs_dl_id) && !empty($sdm_logs_dl_id)){
47
+ //Show the specific item logs
48
+
49
+ /* Prepare everything for the specific logs table */
50
+ //Create an instance of our package class...
51
+ $sdmListTable = new sdm_List_Table();
52
+ //Fetch, prepare, sort, and filter our data...
53
+ $sdmListTable->prepare_items();
54
+ echo '<strong>' . __('The following table shows the download logs of the item with Download ID: ', 'simple-download-monitor') . $sdm_logs_dl_id . '</strong>'
55
+ ?>
56
+ <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
57
+ <form id="sdm_downloads-filter" method="post">
58
+ <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST[ 'page' ] ) ?>" />
59
+ <!-- Now we can render the completed list table -->
60
+ <?php $sdmListTable->display() ?>
61
+ </form>
62
+ <?php
63
+ }
64
+
65
+ }
includes/sdm-admin-menu-handler.php CHANGED
@@ -278,8 +278,56 @@ function sdm_admin_menu_advanced_settings() {
278
  /*
279
  * * Logs menu page
280
  */
 
 
 
 
281
 
282
- function sdm_create_logs_page() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  global $wpdb;
284
 
285
  if ( isset( $_POST[ 'sdm_export_log_entries' ] ) ) {
@@ -306,8 +354,7 @@ function sdm_create_logs_page() {
306
  $sdmListTable = new sdm_List_Table();
307
  //Fetch, prepare, sort, and filter our data...
308
  $sdmListTable->prepare_items();
309
- ?>
310
- <div class="wrap">
311
 
312
  <h2><?php _e( 'Download Logs', 'simple-download-monitor' ); ?></h2>
313
 
@@ -326,7 +373,8 @@ function sdm_create_logs_page() {
326
  <input type="submit" class="button" name="sdm_export_log_entries" value="<?php _e( 'Export Log Entries to CSV File', 'simple-download-monitor' ); ?>" />
327
  </div>
328
  </form>
329
- </div></div>
 
330
 
331
  <!-- Log reset button -->
332
  <div class="postbox">
@@ -337,7 +385,8 @@ function sdm_create_logs_page() {
337
  <input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e( 'Reset Log Entries', 'simple-download-monitor' ); ?>" />
338
  </div>
339
  </form>
340
- </div></div>
 
341
 
342
  </div></div><!-- end of .poststuff and .post-body -->
343
 
@@ -348,7 +397,6 @@ function sdm_create_logs_page() {
348
  <?php $sdmListTable->display() ?>
349
  </form>
350
 
351
- </div><!-- end of wrap -->
352
  <script type="text/javascript">
353
  jQuery(document).ready(function ($) {
354
  $('.fade').click(function () {
278
  /*
279
  * * Logs menu page
280
  */
281
+ function sdm_create_logs_page(){
282
+ if (!current_user_can('manage_options')) {
283
+ wp_die('You do not have permission to access this settings page.');
284
+ }
285
 
286
+ echo '<div class="wrap">';
287
+
288
+ $sdm_logs_menu_tabs = array(
289
+ 'sdm-logs' => __('Main Logs', 'simple-download-monitor'),
290
+ 'sdm-logs&action=sdm-logs-by-download' => __('Specific Item Logs', 'simple-download-monitor'),
291
+ );
292
+
293
+ $current = "";
294
+ if (isset($_GET['page'])) {
295
+ $current = sanitize_text_field($_GET['page']);
296
+ if (isset($_GET['action'])) {
297
+ $current .= "&action=" . sanitize_text_field($_GET['action']);
298
+ }
299
+ }
300
+ $content = '';
301
+ $content .= '<h2 class="nav-tab-wrapper">';
302
+ foreach ($sdm_logs_menu_tabs as $location => $tabname) {
303
+ if ($current == $location) {
304
+ $class = ' nav-tab-active';
305
+ } else {
306
+ $class = '';
307
+ }
308
+ $content .= '<a class="nav-tab' . $class . '" href="?post_type=sdm_downloads&page=' . $location . '">' . $tabname . '</a>';
309
+ }
310
+ $content .= '</h2>';
311
+ echo $content;
312
+
313
+ if (isset($_GET['action'])) {
314
+ switch ($_GET['action']) {
315
+ case 'sdm-logs-by-download':
316
+ include_once (WP_SIMPLE_DL_MONITOR_PATH . 'includes/admin-side/sdm-admin-individual-item-logs-page.php');
317
+ sdm_handle_individual_logs_tab_page();
318
+ break;
319
+ default:
320
+ sdm_handle_logs_main_tab_page();
321
+ break;
322
+ }
323
+ } else {
324
+ sdm_handle_logs_main_tab_page();
325
+ }
326
+
327
+ echo '</div>';//<!-- end of wrap -->
328
+ }
329
+
330
+ function sdm_handle_logs_main_tab_page() {
331
  global $wpdb;
332
 
333
  if ( isset( $_POST[ 'sdm_export_log_entries' ] ) ) {
354
  $sdmListTable = new sdm_List_Table();
355
  //Fetch, prepare, sort, and filter our data...
356
  $sdmListTable->prepare_items();
357
+ ?>
 
358
 
359
  <h2><?php _e( 'Download Logs', 'simple-download-monitor' ); ?></h2>
360
 
373
  <input type="submit" class="button" name="sdm_export_log_entries" value="<?php _e( 'Export Log Entries to CSV File', 'simple-download-monitor' ); ?>" />
374
  </div>
375
  </form>
376
+ </div>
377
+ </div>
378
 
379
  <!-- Log reset button -->
380
  <div class="postbox">
385
  <input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e( 'Reset Log Entries', 'simple-download-monitor' ); ?>" />
386
  </div>
387
  </form>
388
+ </div>
389
+ </div>
390
 
391
  </div></div><!-- end of .poststuff and .post-body -->
392
 
397
  <?php $sdmListTable->display() ?>
398
  </form>
399
 
 
400
  <script type="text/javascript">
401
  jQuery(document).ready(function ($) {
402
  $('.fade').click(function () {
includes/sdm-download-request-handler.php CHANGED
@@ -13,11 +13,11 @@ function handle_sdm_download_via_direct_post() {
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
  sdm_recaptcha_verify();
20
-
21
  //Check download password (if applicable for this download)
22
  $post_object = get_post($download_id); // Get post object
23
  $post_pass = $post_object->post_password; // Get post password
@@ -42,16 +42,16 @@ function handle_sdm_download_via_direct_post() {
42
  //End of password check
43
 
44
  $main_option = get_option('sdm_downloads_options');
45
-
46
  $ipaddress = '';
47
  //Check if do not capture IP is enabled.
48
  if (!isset($main_option['admin_do_not_capture_ip'])) {
49
  $ipaddress = sdm_get_ip_address();
50
  }
51
-
52
  $date_time = current_time('mysql');
53
  $visitor_country = !empty($ipaddress) ? sdm_ip_info($ipaddress, 'country') : '';
54
-
55
  $visitor_name = sdm_get_logged_in_user();
56
 
57
  // Check if we only allow the download for logged-in users
@@ -151,28 +151,6 @@ function handle_sdm_download_via_direct_post() {
151
  }
152
  }
153
 
154
- /*
155
- * Use this function to redirect to a URL
156
- */
157
-
158
- function sdm_redirect_to_url($url, $delay = '0', $exit = '1') {
159
- $url = apply_filters('sdm_before_redirect_to_url', $url);
160
- if (empty($url)) {
161
- echo '<strong>';
162
- _e('Error! The URL value is empty. Please specify a correct URL value to redirect to!', 'simple-download-monitor');
163
- echo '</strong>';
164
- exit;
165
- }
166
- if (!headers_sent()) {
167
- header('Location: ' . $url);
168
- } else {
169
- echo '<meta http-equiv="refresh" content="' . $delay . ';url=' . $url . '" />';
170
- }
171
- if ($exit == '1') {//exit
172
- exit;
173
- }
174
- }
175
-
176
  /**
177
  * Dispatch file with $filename and terminate script execution, if the file is
178
  * readable and headers have not been sent yet.
13
  wp_die(__('Error! Incorrect download item id.', 'simple-download-monitor'));
14
  }
15
  if (empty($download_link)) {
16
+ wp_die(printf(__('Error! This download item (%s) does not have any download link. Edit this item and specify a downloadable file URL for it.', 'simple-download-monitor'), $download_id));
17
  }
18
 
19
  sdm_recaptcha_verify();
20
+
21
  //Check download password (if applicable for this download)
22
  $post_object = get_post($download_id); // Get post object
23
  $post_pass = $post_object->post_password; // Get post password
42
  //End of password check
43
 
44
  $main_option = get_option('sdm_downloads_options');
45
+
46
  $ipaddress = '';
47
  //Check if do not capture IP is enabled.
48
  if (!isset($main_option['admin_do_not_capture_ip'])) {
49
  $ipaddress = sdm_get_ip_address();
50
  }
51
+
52
  $date_time = current_time('mysql');
53
  $visitor_country = !empty($ipaddress) ? sdm_ip_info($ipaddress, 'country') : '';
54
+
55
  $visitor_name = sdm_get_logged_in_user();
56
 
57
  // Check if we only allow the download for logged-in users
151
  }
152
  }
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  /**
155
  * Dispatch file with $filename and terminate script execution, if the file is
156
  * readable and headers have not been sent yet.
includes/sdm-logs-list-table.php CHANGED
@@ -179,10 +179,20 @@ class sdm_List_Table extends WP_List_Table {
179
 
180
  //Do a query to find the total number of rows then calculate the query limit
181
  $table_name = $wpdb->prefix . 'sdm_downloads';
182
- $query = "SELECT COUNT(*) FROM $table_name";
183
- $total_items = $wpdb->get_var($query);//For pagination requirement
184
-
185
- $query = "SELECT * FROM $table_name ORDER BY $orderby_column $sort_order";
 
 
 
 
 
 
 
 
 
 
186
 
187
  $offset = ($current_page - 1) * $per_page;
188
  $query.=' LIMIT ' . (int) $offset . ',' . (int) $per_page;//Limit to query to only load a limited number of records
179
 
180
  //Do a query to find the total number of rows then calculate the query limit
181
  $table_name = $wpdb->prefix . 'sdm_downloads';
182
+
183
+ if(isset($_REQUEST['sdm_logs_dl_id']) && !empty($_REQUEST['sdm_logs_dl_id'])){
184
+ //For specific download logs
185
+ $dl_id = sanitize_text_field($_REQUEST['sdm_logs_dl_id']);
186
+ $query = "SELECT COUNT(*) FROM $table_name WHERE post_id = $dl_id";
187
+ $total_items = $wpdb->get_var($query);//For pagination requirement
188
+ $query = "SELECT * FROM $table_name WHERE post_id = $dl_id ORDER BY $orderby_column $sort_order";
189
+ } else {
190
+ //For all download logs
191
+ $query = "SELECT COUNT(*) FROM $table_name";
192
+ $total_items = $wpdb->get_var($query);//For pagination requirement
193
+
194
+ $query = "SELECT * FROM $table_name ORDER BY $orderby_column $sort_order";
195
+ }
196
 
197
  $offset = ($current_page - 1) * $per_page;
198
  $query.=' LIMIT ' . (int) $offset . ',' . (int) $per_page;//Limit to query to only load a limited number of records
includes/sdm-popular-downloads.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function sdm_show_popular_downloads( $args ) {
4
+
5
+ extract( shortcode_atts( array(
6
+ 'number' => '5',
7
+ 'fancy' => '0',
8
+ 'button_text' => '',
9
+ 'new_window' => '',
10
+ 'orderby' => 'post_date',
11
+ 'order' => 'DESC',
12
+ 'category_slug' => '',
13
+ ), $args ) );
14
+
15
+ global $wpdb;
16
+ //Check if the query needs to be for a category
17
+ if ( ! empty( $category_slug ) ) {
18
+ $q = "SELECT posts.*, downloads.id, downloads.post_id, terms.*, termrel.*, postmeta.*, (COUNT(downloads.post_id) + postmeta.meta_value) AS cnt"
19
+ . " FROM " . $wpdb->prefix . "posts as posts, " . $wpdb->prefix . "sdm_downloads as downloads, " . $wpdb->prefix . "terms as terms, " . $wpdb->prefix . "term_relationships as termrel, " . $wpdb->prefix . "postmeta as postmeta WHERE"
20
+ . " posts.id=downloads.post_id"
21
+ . " AND (postmeta.meta_key='sdm_count_offset' AND postmeta.post_id=downloads.post_id)"
22
+ . " AND (terms.slug= %s AND termrel.object_id=downloads.post_id AND termrel.term_taxonomy_id=terms.term_id)"
23
+ . " GROUP BY downloads.post_id"
24
+ . " ORDER BY cnt DESC, %s %s"
25
+ . " LIMIT %d;";
26
+ $q = $wpdb->prepare( $q, $category_slug, $orderby, $order, $number );
27
+ } else {
28
+ //no categury_slug present
29
+ $q = "SELECT posts.*, downloads.id, downloads.post_id, postmeta.*, (COUNT(downloads.post_id) + postmeta.meta_value) AS cnt"
30
+ . " FROM " . $wpdb->prefix . "posts as posts, " . $wpdb->prefix . "sdm_downloads as downloads, " . $wpdb->prefix . "postmeta as postmeta WHERE"
31
+ . " posts.id=downloads.post_id"
32
+ . " AND (postmeta.meta_key='sdm_count_offset' AND postmeta.post_id=downloads.post_id)"
33
+ . " GROUP BY downloads.post_id"
34
+ . " ORDER BY cnt DESC, %s %s"
35
+ . " LIMIT %d;";
36
+ $q = $wpdb->prepare( $q, $orderby, $order, $number );
37
+ }
38
+
39
+ $get_posts = $wpdb->get_results( $q );
40
+
41
+ // If no cpt's are found
42
+ if ( ! $get_posts ) {
43
+ return '<p style="color: red;">' . __( 'There are no download items matching this shortcode criteria.', 'simple-download-monitor' ) . '</p>';
44
+ }
45
+ // Else iterate cpt's
46
+ else {
47
+
48
+ $output = '';
49
+ if ( $fancy == '0' ) {
50
+ include_once(WP_SIMPLE_DL_MONITOR_PATH . 'includes/templates/fancy0/sdm-fancy-0.php');
51
+ $output .= sdm_generate_fancy0_popular_downloads_display_output( $get_posts, $args );
52
+ } else if ( $fancy == '1' ) {
53
+ include_once(WP_SIMPLE_DL_MONITOR_PATH . 'includes/templates/fancy1/sdm-fancy-1.php');
54
+ $output .= sdm_generate_fancy1_popular_downloads_display_output( $get_posts, $args );
55
+ } else if ( $fancy == '2' ) {
56
+ include_once(WP_SIMPLE_DL_MONITOR_PATH . 'includes/templates/fancy2/sdm-fancy-2.php');
57
+ $output .= sdm_generate_fancy2_popular_downloads_display_output( $get_posts, $args );
58
+ }
59
+
60
+ // Return results
61
+ return apply_filters( 'sdm_popular_downloads_shortcode_output', $output, $args, $get_posts );
62
+ } // End else iterate cpt's
63
+ }
includes/sdm-utility-functions.php CHANGED
@@ -295,3 +295,24 @@ function sdm_get_default_download_button_text($download_id){
295
  $button_text = !empty($meta_text) ? $meta_text : $default_text;
296
  return $button_text;
297
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  $button_text = !empty($meta_text) ? $meta_text : $default_text;
296
  return $button_text;
297
  }
298
+
299
+ /*
300
+ * Use this function to redirect to a URL
301
+ */
302
+ function sdm_redirect_to_url($url, $delay = '0', $exit = '1') {
303
+ $url = apply_filters('sdm_before_redirect_to_url', $url);
304
+ if (empty($url)) {
305
+ echo '<strong>';
306
+ _e('Error! The URL value is empty. Please specify a correct URL value to redirect to!', 'simple-download-monitor');
307
+ echo '</strong>';
308
+ exit;
309
+ }
310
+ if (!headers_sent()) {
311
+ header('Location: ' . $url);
312
+ } else {
313
+ echo '<meta http-equiv="refresh" content="' . $delay . ';url=' . $url . '" />';
314
+ }
315
+ if ($exit == '1') {//exit
316
+ exit;
317
+ }
318
+ }
includes/templates/fancy0/sdm-fancy-0.php CHANGED
@@ -1,20 +1,40 @@
1
  <?php
2
 
3
- 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
11
- $args = array(
12
- 'id' => $id,
13
- 'fancy' => '0',
14
- 'button_text' => $button_text,
15
- 'new_window' => $new_window,
16
- );
17
- $output .= sdm_generate_fancy0_display_output($args);
 
 
18
  }
19
  $output .= '<div class="sdm_clear_float"></div>';
20
  return $output;
@@ -50,69 +70,69 @@ function sdm_generate_fancy0_latest_downloads_display_output($get_posts, $args)
50
  * id, fancy, button_text, new_window
51
  */
52
 
53
- function sdm_generate_fancy0_display_output($args) {
54
 
55
  //Get the download ID
56
- $id = $args['id'];
57
- if (!is_numeric($id)) {
58
- 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>';
59
  }
60
 
61
  // See if user color option is selected
62
- $main_opts = get_option('sdm_downloads_options');
63
- $color_opt = $main_opts['download_button_color'];
64
- $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : __('green', 'simple-download-monitor');
65
 
66
  //See if new window parameter is seet
67
  $window_target = '';
68
- if (isset($args['new_window']) && $args['new_window'] == '1') {
69
- $window_target = 'target="_blank"';
70
  }
71
 
72
  //Get the download button text
73
- $button_text = isset($args['button_text']) ? $args['button_text'] : '';
74
- if (empty($button_text)) {//Use the default text for the button
75
- $button_text_string = __('Download Now!', 'simple-download-monitor');
76
  } else {//Use the custom text
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
 
84
  // Get download button
85
- $homepage = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL;
86
- $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
87
- $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" ' . $window_target . '>' . $button_text_string . '</a>';
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
-
93
-
94
- $main_advanced_opts = get_option('sdm_advanced_options');
95
-
96
  //Check if Terms & Condition enabled
97
- $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
98
- if ($termscond_enable) {
99
- $download_button_code = sdm_get_download_form_with_termsncond($id, $args,'sdm_download ' . $def_color);
100
  }
101
-
102
  //Check if reCAPTCHA enabled
103
- $recaptcha_enable = isset($main_advanced_opts['recaptcha_enable']) ? true : false;
104
- if ($recaptcha_enable && $cpt_is_password == 'no') {
105
- $download_button_code = sdm_get_download_form_with_recaptcha($id, $args, 'sdm_download ' . $def_color);
106
  }
107
-
108
- if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
109
- $download_button_code = sdm_get_password_entry_form($id, $args, 'sdm_download ' . $def_color);
110
  }
111
-
112
  $output = "";
113
 
114
  //apply filter on button HTML code
115
- $download_button_code=apply_filters('sdm_download_button_code_html', $download_button_code );
116
 
117
  $output .= '<div class="sdm_download_button_box_default"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
118
 
1
  <?php
2
 
3
+ function sdm_generate_fancy0_popular_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
11
+ $args = array(
12
+ 'id' => $id,
13
+ 'fancy' => '0',
14
+ 'button_text' => $button_text,
15
+ 'new_window' => $new_window,
16
+ );
17
+ $output .= sdm_generate_fancy0_display_output( $args );
18
+ }
19
+ $output .= '<div class="sdm_clear_float"></div>';
20
+ return $output;
21
+ }
22
 
23
+ function sdm_generate_fancy0_latest_downloads_display_output( $get_posts, $args ) {
24
+
25
+ $output = "";
26
+ isset( $args[ 'button_text' ] ) ? $button_text = $args[ 'button_text' ] : $button_text = '';
27
+ isset( $args[ 'new_window' ] ) ? $new_window = $args[ 'new_window' ] : $new_window = '';
28
+ foreach ( $get_posts as $item ) {
29
+ $id = $item->ID; //Get the post ID
30
+ //Create a args array
31
+ $args = array(
32
+ 'id' => $id,
33
+ 'fancy' => '0',
34
+ 'button_text' => $button_text,
35
+ 'new_window' => $new_window,
36
+ );
37
+ $output .= sdm_generate_fancy0_display_output( $args );
38
  }
39
  $output .= '<div class="sdm_clear_float"></div>';
40
  return $output;
70
  * id, fancy, button_text, new_window
71
  */
72
 
73
+ function sdm_generate_fancy0_display_output( $args ) {
74
 
75
  //Get the download ID
76
+ $id = $args[ 'id' ];
77
+ if ( ! is_numeric( $id ) ) {
78
+ 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>';
79
  }
80
 
81
  // See if user color option is selected
82
+ $main_opts = get_option( 'sdm_downloads_options' );
83
+ $color_opt = $main_opts[ 'download_button_color' ];
84
+ $def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : __( 'green', 'simple-download-monitor' );
85
 
86
  //See if new window parameter is seet
87
  $window_target = '';
88
+ if ( isset( $args[ 'new_window' ] ) && $args[ 'new_window' ] == '1' ) {
89
+ $window_target = 'target="_blank"';
90
  }
91
 
92
  //Get the download button text
93
+ $button_text = isset( $args[ 'button_text' ] ) ? $args[ 'button_text' ] : '';
94
+ if ( empty( $button_text ) ) {//Use the default text for the button
95
+ $button_text_string = __( 'Download Now!', 'simple-download-monitor' );
96
  } else {//Use the custom text
97
+ $button_text_string = $button_text;
98
  }
99
 
100
  // Get CPT title
101
+ $item_title = get_the_title( $id );
102
+ $isset_item_title = isset( $item_title ) && ! empty( $item_title ) ? $item_title : '';
103
 
104
  // Get download button
105
+ $homepage = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL;
106
+ $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
107
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" ' . $window_target . '>' . $button_text_string . '</a>';
108
 
109
  // Check to see if the download link cpt is password protected
110
+ $get_cpt_object = get_post( $id );
111
+ $cpt_is_password = ! empty( $get_cpt_object->post_password ) ? 'yes' : 'no'; // yes = download is password protected;
112
+
113
+
114
+ $main_advanced_opts = get_option( 'sdm_advanced_options' );
115
+
116
  //Check if Terms & Condition enabled
117
+ $termscond_enable = isset( $main_advanced_opts[ 'termscond_enable' ] ) ? true : false;
118
+ if ( $termscond_enable ) {
119
+ $download_button_code = sdm_get_download_form_with_termsncond( $id, $args, 'sdm_download ' . $def_color );
120
  }
121
+
122
  //Check if reCAPTCHA enabled
123
+ $recaptcha_enable = isset( $main_advanced_opts[ 'recaptcha_enable' ] ) ? true : false;
124
+ if ( $recaptcha_enable && $cpt_is_password == 'no' ) {
125
+ $download_button_code = sdm_get_download_form_with_recaptcha( $id, $args, 'sdm_download ' . $def_color );
126
  }
127
+
128
+ if ( $cpt_is_password !== 'no' ) {//This is a password protected download so replace the download now button with password requirement
129
+ $download_button_code = sdm_get_password_entry_form( $id, $args, 'sdm_download ' . $def_color );
130
  }
131
+
132
  $output = "";
133
 
134
  //apply filter on button HTML code
135
+ $download_button_code = apply_filters( 'sdm_download_button_code_html', $download_button_code );
136
 
137
  $output .= '<div class="sdm_download_button_box_default"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
138
 
includes/templates/fancy1/sdm-fancy-1.php CHANGED
@@ -1,29 +1,42 @@
1
  <?php
2
 
3
- function sdm_generate_fancy1_latest_downloads_display_output($get_posts, $args) {
4
 
5
  $output = "";
6
 
7
- foreach ($get_posts as $item) {
8
- $output .= sdm_generate_fancy1_display_output(
9
- array_merge($args, array('id' => $item->ID))
10
- );
11
  }
12
  $output .= '<div class="sdm_clear_float"></div>';
13
  return $output;
14
  }
15
 
16
- function sdm_generate_fancy1_category_display_output($get_posts, $args) {
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  $output = "";
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>';
29
  return $output;
@@ -35,149 +48,145 @@ function sdm_generate_fancy1_category_display_output($get_posts, $args) {
35
  * id, fancy, button_text, new_window
36
  */
37
 
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
 
60
  // Read plugin settings
61
- $main_opts = get_option('sdm_downloads_options');
62
 
63
  // See if new window parameter is set
64
- if(empty($new_window)){
65
- $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
66
  }
67
- $window_target = empty($new_window) ? '_self' : '_blank';
68
 
69
  // Get CPT thumbnail
70
- $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
71
- $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_download_thumbnail_image" src="' . $item_download_thumbnail . '" />' : '';
72
- $isset_download_thumbnail = apply_filters('sdm_download_fancy_1_thumbnail', $isset_download_thumbnail, $args);//Apply filter so it can be customized.
73
-
74
  // Get CPT title
75
- $item_title = get_the_title($id);
76
 
77
  // Get CPT description
78
- $isset_item_description = sdm_get_item_description_output($id);
79
 
80
  // Get download button
81
- $homepage = get_bloginfo('url');
82
- $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
83
- $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
84
 
85
  //Get item file size
86
- $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
87
  //Check if show file size is enabled
88
- if(empty($show_size)){
89
- //Disabled in shortcode. Lets check if it is enabled in the download meta.
90
- $show_size = get_post_meta($id, 'sdm_item_show_file_size_fd', true);
91
  }
92
- $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
93
-
94
  //Get item version
95
- $item_version = get_post_meta($id, 'sdm_item_version', true);
96
  //Check if show version is enabled
97
- if(empty($show_version)){
98
- //Disabled in shortcode. Lets check if it is enabled in the download meta.
99
- $show_version = get_post_meta($id, 'sdm_item_show_item_version_fd', true);
100
  }
101
- $isset_item_version = ($show_version && isset($item_version)) ? $item_version : ''; //check if show_version is enabled and if there is a version value
102
-
103
  //Check to see if the download link cpt is password protected
104
- $get_cpt_object = get_post($id);
105
- $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
106
-
107
  //Check if show date is enabled
108
- $show_date_fd = get_post_meta($id, 'sdm_item_show_date_fd', true);
109
  //Get item date
110
- $download_date = get_the_date(get_option('date_format'), $id) ;
111
-
112
- $main_advanced_opts = get_option('sdm_advanced_options');
113
-
114
  //Check if Terms & Condition enabled
115
- $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
116
- if ($termscond_enable) {
117
- $download_button_code = sdm_get_download_form_with_termsncond($id, $shortcode_atts, 'sdm_download ' . $color);
118
  }
119
-
120
  //Check if reCAPTCHA enabled
121
- $recaptcha_enable = isset($main_advanced_opts['recaptcha_enable']) ? true : false;
122
- if ($recaptcha_enable && $cpt_is_password == 'no') {
123
- $download_button_code = sdm_get_download_form_with_recaptcha($id, $shortcode_atts, 'sdm_download ' . $color);
124
  }
125
-
126
- if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
127
- $download_button_code = sdm_get_password_entry_form($id, $shortcode_atts, 'sdm_download ' . $color);
128
  }
129
 
130
- $db_count = sdm_get_download_count_for_post($id);
131
- $string = ($db_count == '1') ? __('Download', 'simple-download-monitor') : __('Downloads', 'simple-download-monitor');
132
- $download_count_string = '<span class="sdm_item_count_number">' . $db_count . '</span><span class="sdm_item_count_string"> ' . $string . '</span>';
133
 
134
  $output = '';
135
 
136
- $output .= '<div class="sdm_download_item ' . $css_class . '">';
137
- $output .= '<div class="sdm_download_item_top">';
138
- $output .= '<div class="sdm_download_thumbnail">' . $isset_download_thumbnail . '</div>';
139
- $output .= '<div class="sdm_download_title">' . $item_title . '</div>';
140
- $output .= '</div>'; //End of .sdm_download_item_top
141
- $output .= '<div style="clear:both;"></div>';
142
 
143
  $output .= '<div class="sdm_download_description">' . $isset_item_description . '</div>';
144
 
145
  //This hook can be used to add content below the description in fancy1 template
146
- $output .= apply_filters('sdm_fancy1_below_download_description','');
147
-
148
- if (!empty($isset_item_file_size)) {//Show file size info
149
- $output .= '<div class="sdm_download_size">';
150
- $output .= '<span class="sdm_download_size_label">' . __('Size: ', 'simple-download-monitor') . '</span>';
151
- $output .= '<span class="sdm_download_size_value">' . $isset_item_file_size . '</span>';
152
- $output .= '</div>';
153
  }
154
 
155
- if (!empty($isset_item_version)) {//Show version info
156
- $output .= '<div class="sdm_download_version">';
157
- $output .= '<span class="sdm_download_version_label">' . __('Version: ', 'simple-download-monitor') . '</span>';
158
- $output .= '<span class="sdm_download_version_value">' . $isset_item_version . '</span>';
159
- $output .= '</div>';
160
  }
161
-
162
- if ($show_date_fd) {//Show date
163
- $output .= '<div class="sdm_download_date">';
164
- $output .= '<span class="sdm_download_date_label">' . __('Published: ', 'simple-download-monitor') . '</span>';
165
- $output .= '<span class="sdm_download_date_value">' . $download_date . '</span>';
166
- $output .= '</div>';
167
  }
168
-
169
 
170
  $output .= '<div class="sdm_download_link">';
171
-
172
  //apply filter on button HTML code
173
- $download_button_code=apply_filters('sdm_download_button_code_html', $download_button_code );
174
-
175
  $output .= '<span class="sdm_download_button">' . $download_button_code . '</span>';
176
- if (!isset($main_opts['general_hide_donwload_count'])) {//The hide download count is enabled.
177
- $output .= '<span class="sdm_download_item_count">' . $download_count_string . '</span>';
178
  }
179
- $output .= '</div>'; //end .sdm_download_link
180
- $output .= '</div>'; //end .sdm_download_item
181
 
182
 
183
  return $output;
1
  <?php
2
 
3
+ function sdm_generate_fancy1_popular_downloads_display_output( $get_posts, $args ) {
4
 
5
  $output = "";
6
 
7
+ foreach ( $get_posts as $item ) {
8
+ $opts = $args;
9
+ $opts[ 'id' ] = $item->ID;
10
+ $output .= sdm_generate_fancy1_display_output( $opts );
11
  }
12
  $output .= '<div class="sdm_clear_float"></div>';
13
  return $output;
14
  }
15
 
16
+ function sdm_generate_fancy1_latest_downloads_display_output( $get_posts, $args ) {
17
+
18
+ $output = "";
19
+
20
+ foreach ( $get_posts as $item ) {
21
+ $output .= sdm_generate_fancy1_display_output(
22
+ array_merge( $args, array( 'id' => $item->ID ) )
23
+ );
24
+ }
25
+ $output .= '<div class="sdm_clear_float"></div>';
26
+ return $output;
27
+ }
28
+
29
+ function sdm_generate_fancy1_category_display_output( $get_posts, $args ) {
30
 
31
  $output = "";
32
 
33
  //TODO - when the CSS file is moved to the fancy1 folder, change it here
34
  //$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 . '" />';
35
 
36
+ foreach ( $get_posts as $item ) {
37
+ $output .= sdm_generate_fancy1_display_output(
38
+ array_merge( $args, array( 'id' => $item->ID ) )
39
+ );
40
  }
41
  $output .= '<div class="sdm_clear_float"></div>';
42
  return $output;
48
  * id, fancy, button_text, new_window
49
  */
50
 
51
+ function sdm_generate_fancy1_display_output( $args ) {
52
 
53
  $shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
54
+ shortcode_atts( array(
55
+ 'id' => '',
56
+ 'button_text' => __( 'Download Now!', 'simple-download-monitor' ),
57
+ 'new_window' => '',
58
+ 'color' => '',
59
+ 'css_class' => '',
60
+ 'show_size' => '',
61
+ 'show_version' => '',
62
+ ), $args )
63
  );
64
 
65
  // Make shortcode attributes available in function local scope.
66
+ extract( $shortcode_atts );
67
 
68
  // Check the download ID
69
+ if ( empty( $id ) ) {
70
+ 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>';
71
  }
72
 
73
  // Read plugin settings
74
+ $main_opts = get_option( 'sdm_downloads_options' );
75
 
76
  // See if new window parameter is set
77
+ if ( empty( $new_window ) ) {
78
+ $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
79
  }
80
+ $window_target = empty( $new_window ) ? '_self' : '_blank';
81
 
82
  // Get CPT thumbnail
83
+ $item_download_thumbnail = get_post_meta( $id, 'sdm_upload_thumbnail', true );
84
+ $isset_download_thumbnail = isset( $item_download_thumbnail ) && ! empty( $item_download_thumbnail ) ? '<img class="sdm_download_thumbnail_image" src="' . $item_download_thumbnail . '" />' : '';
85
+ $isset_download_thumbnail = apply_filters( 'sdm_download_fancy_1_thumbnail', $isset_download_thumbnail, $args ); //Apply filter so it can be customized.
 
86
  // Get CPT title
87
+ $item_title = get_the_title( $id );
88
 
89
  // Get CPT description
90
+ $isset_item_description = sdm_get_item_description_output( $id );
91
 
92
  // Get download button
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
  //Get item file size
98
+ $item_file_size = get_post_meta( $id, 'sdm_item_file_size', true );
99
  //Check if show file size is enabled
100
+ if ( empty( $show_size ) ) {
101
+ //Disabled in shortcode. Lets check if it is enabled in the download meta.
102
+ $show_size = get_post_meta( $id, 'sdm_item_show_file_size_fd', true );
103
  }
104
+ $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
 
105
  //Get item version
106
+ $item_version = get_post_meta( $id, 'sdm_item_version', true );
107
  //Check if show version is enabled
108
+ if ( empty( $show_version ) ) {
109
+ //Disabled in shortcode. Lets check if it is enabled in the download meta.
110
+ $show_version = get_post_meta( $id, 'sdm_item_show_item_version_fd', true );
111
  }
112
+ $isset_item_version = ($show_version && isset( $item_version )) ? $item_version : ''; //check if show_version is enabled and if there is a version value
 
113
  //Check to see if the download link cpt is password protected
114
+ $get_cpt_object = get_post( $id );
115
+ $cpt_is_password = ! empty( $get_cpt_object->post_password ) ? 'yes' : 'no'; // yes = download is password protected;
 
116
  //Check if show date is enabled
117
+ $show_date_fd = get_post_meta( $id, 'sdm_item_show_date_fd', true );
118
  //Get item date
119
+ $download_date = get_the_date( get_option( 'date_format' ), $id );
120
+
121
+ $main_advanced_opts = get_option( 'sdm_advanced_options' );
122
+
123
  //Check if Terms & Condition enabled
124
+ $termscond_enable = isset( $main_advanced_opts[ 'termscond_enable' ] ) ? true : false;
125
+ if ( $termscond_enable ) {
126
+ $download_button_code = sdm_get_download_form_with_termsncond( $id, $shortcode_atts, 'sdm_download ' . $color );
127
  }
128
+
129
  //Check if reCAPTCHA enabled
130
+ $recaptcha_enable = isset( $main_advanced_opts[ 'recaptcha_enable' ] ) ? true : false;
131
+ if ( $recaptcha_enable && $cpt_is_password == 'no' ) {
132
+ $download_button_code = sdm_get_download_form_with_recaptcha( $id, $shortcode_atts, 'sdm_download ' . $color );
133
  }
134
+
135
+ if ( $cpt_is_password !== 'no' ) {//This is a password protected download so replace the download now button with password requirement
136
+ $download_button_code = sdm_get_password_entry_form( $id, $shortcode_atts, 'sdm_download ' . $color );
137
  }
138
 
139
+ $db_count = sdm_get_download_count_for_post( $id );
140
+ $string = ($db_count == '1') ? __( 'Download', 'simple-download-monitor' ) : __( 'Downloads', 'simple-download-monitor' );
141
+ $download_count_string = '<span class="sdm_item_count_number">' . $db_count . '</span><span class="sdm_item_count_string"> ' . $string . '</span>';
142
 
143
  $output = '';
144
 
145
+ $output .= '<div class="sdm_download_item ' . $css_class . '">';
146
+ $output .= '<div class="sdm_download_item_top">';
147
+ $output .= '<div class="sdm_download_thumbnail">' . $isset_download_thumbnail . '</div>';
148
+ $output .= '<div class="sdm_download_title">' . $item_title . '</div>';
149
+ $output .= '</div>'; //End of .sdm_download_item_top
150
+ $output .= '<div style="clear:both;"></div>';
151
 
152
  $output .= '<div class="sdm_download_description">' . $isset_item_description . '</div>';
153
 
154
  //This hook can be used to add content below the description in fancy1 template
155
+ $output .= apply_filters( 'sdm_fancy1_below_download_description', '' );
156
+
157
+ if ( ! empty( $isset_item_file_size ) ) {//Show file size info
158
+ $output .= '<div class="sdm_download_size">';
159
+ $output .= '<span class="sdm_download_size_label">' . __( 'Size: ', 'simple-download-monitor' ) . '</span>';
160
+ $output .= '<span class="sdm_download_size_value">' . $isset_item_file_size . '</span>';
161
+ $output .= '</div>';
162
  }
163
 
164
+ if ( ! empty( $isset_item_version ) ) {//Show version info
165
+ $output .= '<div class="sdm_download_version">';
166
+ $output .= '<span class="sdm_download_version_label">' . __( 'Version: ', 'simple-download-monitor' ) . '</span>';
167
+ $output .= '<span class="sdm_download_version_value">' . $isset_item_version . '</span>';
168
+ $output .= '</div>';
169
  }
170
+
171
+ if ( $show_date_fd ) {//Show date
172
+ $output .= '<div class="sdm_download_date">';
173
+ $output .= '<span class="sdm_download_date_label">' . __( 'Published: ', 'simple-download-monitor' ) . '</span>';
174
+ $output .= '<span class="sdm_download_date_value">' . $download_date . '</span>';
175
+ $output .= '</div>';
176
  }
177
+
178
 
179
  $output .= '<div class="sdm_download_link">';
180
+
181
  //apply filter on button HTML code
182
+ $download_button_code = apply_filters( 'sdm_download_button_code_html', $download_button_code );
183
+
184
  $output .= '<span class="sdm_download_button">' . $download_button_code . '</span>';
185
+ if ( ! isset( $main_opts[ 'general_hide_donwload_count' ] ) ) {//The hide download count is enabled.
186
+ $output .= '<span class="sdm_download_item_count">' . $download_count_string . '</span>';
187
  }
188
+ $output .= '</div>'; //end .sdm_download_link
189
+ $output .= '</div>'; //end .sdm_download_item
190
 
191
 
192
  return $output;
includes/templates/fancy2/sdm-fancy-2.php CHANGED
@@ -2,44 +2,66 @@
2
 
3
  //TODO write a function for doing grid display then the conditional function calls this grid display function
4
 
5
- function sdm_generate_fancy2_latest_downloads_display_output($get_posts, $args) {
6
 
7
- $output = "";
8
- $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 . '" />';
9
 
10
  $count = 1;
11
  //$output .= '<ul class="sdm_fancy2_category_items">';
12
- foreach ($get_posts as $item) {
13
- $output .= sdm_generate_fancy2_display_output(
14
- array_merge($args, array('id' => $item->ID))
15
- );
16
-
17
- if ($count % 3 == 0) {//Clear after every 3 items in the grid
18
- $output .= '<div class="sdm_clear_float"></div>';
19
- }
20
- $count++;
21
  }
22
  //$output .= '</ul>';
23
  $output .= '<div class="sdm_clear_float"></div>';
24
  return $output;
25
  }
26
 
27
- function sdm_generate_fancy2_category_display_output($get_posts, $args) {
28
 
29
- $output = "";
30
- $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 . '" />';
31
 
32
  $count = 1;
33
  //$output .= '<ul class="sdm_fancy2_category_items">';
34
- foreach ($get_posts as $item) {
35
- $output .= sdm_generate_fancy2_display_output(
36
- array_merge($args, array('id' => $item->ID))
37
- );
38
-
39
- if ($count % 3 == 0) {//Clear after every 3 items in the grid
40
- $output .= '<div class="sdm_clear_float"></div>';
41
- }
42
- $count++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
  //$output .= '</ul>';
45
  $output .= '<div class="sdm_clear_float"></div>';
@@ -52,133 +74,130 @@ function sdm_generate_fancy2_category_display_output($get_posts, $args) {
52
  * id, fancy, button_text, new_window
53
  */
54
 
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
 
77
  // See if new window parameter is set
78
- if(empty($new_window)){
79
- $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
80
  }
81
- $window_target = empty($new_window) ? '_self' : '_blank';
82
 
83
- $homepage = get_bloginfo('url');
84
- $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
85
- $download_button_code = '<a href="' . $download_url . '" class="sdm_fancy2_download_dl_link" target="' . $window_target . '">' . $button_text . '</a>';
86
 
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
-
91
  // Read plugin settings
92
- $main_opts = get_option('sdm_downloads_options');
93
-
94
- $main_advanced_opts = get_option('sdm_advanced_options');
95
-
96
  //Check if Terms & Condition enabled
97
- $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
98
- if ($termscond_enable) {
99
- $download_button_code = sdm_get_download_form_with_termsncond($id, $shortcode_atts, 'sdm_fancy2_download_dl_link');
100
  }
101
-
102
  //Check if reCAPTCHA enabled
103
- $recaptcha_enable = isset($main_advanced_opts['recaptcha_enable']) ? true : false;
104
- if ($recaptcha_enable && $cpt_is_password == 'no') {
105
- $download_button_code = sdm_get_download_form_with_recaptcha($id, $shortcode_atts, 'sdm_fancy2_download_dl_link');
106
  }
107
-
108
- if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
109
- $download_button_code = sdm_get_password_entry_form($id, $shortcode_atts, 'sdm_fancy2_download_dl_link');
110
  }
111
 
112
  // Get item thumbnail
113
- $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
114
- $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_fancy2_thumb_image" src="' . $item_download_thumbnail . '" />' : '';
115
- $isset_download_thumbnail = apply_filters('sdm_download_fancy_2_thumbnail', $isset_download_thumbnail, $args);//Apply filter so it can be customized.
116
-
117
  // Get item title
118
- $item_title = get_the_title($id);
119
 
120
  // Get item description
121
- $isset_item_description = sdm_get_item_description_output($id);
122
 
123
  //Get item file size
124
- $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
125
  //Check if show file size is enabled
126
- if(empty($show_size)){
127
- //Disabled in shortcode. Lets check if it is enabled in the download meta.
128
- $show_size = get_post_meta($id, 'sdm_item_show_file_size_fd', true);
129
- }
130
- $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
131
  //Get item version
132
- $item_version = get_post_meta($id, 'sdm_item_version', true);
133
  //Check if show version is enabled
134
- if(empty($show_version)){
135
- //Disabled in shortcode. Lets check if it is enabled in the download meta.
136
- $show_version = get_post_meta($id, 'sdm_item_show_item_version_fd', true);
137
- }
138
- $isset_item_version = ($show_version && isset($item_version)) ? $item_version : ''; //check if show_version is enabled and if there is a version value
139
-
140
  // check show date in fancy display
141
- $show_date_fd = get_post_meta($id, 'sdm_item_show_date_fd', true);
142
  // Get item date
143
- $download_date = get_the_date(get_option('date_format'), $id) ;
144
 
145
- $output = '';
146
- $output .= '<div class="sdm_fancy2_item ' . $css_class . '">';
147
- $output .= '<div class="sdm_fancy2_wrapper">';
148
 
149
- $output .= '<div class="sdm_fancy2_download_item_top">';
150
- $output .= '<div class="sdm_fancy2_download_thumbnail">' . $isset_download_thumbnail . '</div>';
151
- $output .= '</div>'; //End of .sdm_download_item_top
152
 
153
  $output .= '<div class="sdm_fancy2_download_title">' . $item_title . '</div>';
154
 
155
- if (!empty($isset_item_file_size)) {//Show file size info if specified in the shortcode
156
- $output .= '<div class="sdm_fancy2_download_size">';
157
- $output .= '<span class="sdm_fancy2_download_size_label">' . __('Size: ', 'simple-download-monitor') . '</span>';
158
- $output .= '<span class="sdm_fancy2_download_size_value">' . $isset_item_file_size . '</span>';
159
- $output .= '</div>';
160
  }
161
 
162
- if (!empty($isset_item_version)) {//Show version info if specified in the shortcode
163
- $output .= '<div class="sdm_fancy2_download_version">';
164
- $output .= '<span class="sdm_fancy2_download_version_label">' . __('Version: ', 'simple-download-monitor') . '</span>';
165
- $output .= '<span class="sdm_fancy2_download_version_value">' . $isset_item_version . '</span>';
166
- $output .= '</div>';
167
  }
168
-
169
- if ($show_date_fd) {//Show version info if specified in the shortcode
170
- $output .= '<div class="sdm_fancy2_download_date">';
171
- $output .= '<span class="sdm_fancy2_download_date_label">' . __('Published: ', 'simple-download-monitor') . '</span>';
172
- $output .= '<span class="sdm_fancy2_download_date_value">' . $download_date . '</span>';
173
- $output .= '</div>';
174
  }
175
-
176
  //apply filter on button HTML code
177
- $download_button_code=apply_filters('sdm_download_button_code_html', $download_button_code );
178
 
179
  $output .= '<div class="sdm_fancy2_download_link">' . $download_button_code . '</div>';
180
 
181
- $output .= '</div>'; //end .sdm_fancy2_item
182
- $output .= '</div>'; //end .sdm_fancy2_wrapper
183
  return $output;
184
  }
2
 
3
  //TODO write a function for doing grid display then the conditional function calls this grid display function
4
 
5
+ function sdm_generate_fancy2_popular_downloads_display_output( $get_posts, $args ) {
6
 
7
+ $output = "";
8
+ $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 . '" />';
9
 
10
  $count = 1;
11
  //$output .= '<ul class="sdm_fancy2_category_items">';
12
+ foreach ( $get_posts as $item ) {
13
+ $opts = $args;
14
+ $opts[ 'id' ] = $item->ID;
15
+ $output .= sdm_generate_fancy2_display_output( $opts );
16
+
17
+ if ( $count % 3 == 0 ) {//Clear after every 3 items in the grid
18
+ $output .= '<div class="sdm_clear_float"></div>';
19
+ }
20
+ $count ++;
21
  }
22
  //$output .= '</ul>';
23
  $output .= '<div class="sdm_clear_float"></div>';
24
  return $output;
25
  }
26
 
27
+ function sdm_generate_fancy2_latest_downloads_display_output( $get_posts, $args ) {
28
 
29
+ $output = "";
30
+ $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 . '" />';
31
 
32
  $count = 1;
33
  //$output .= '<ul class="sdm_fancy2_category_items">';
34
+ foreach ( $get_posts as $item ) {
35
+ $output .= sdm_generate_fancy2_display_output(
36
+ array_merge( $args, array( 'id' => $item->ID ) )
37
+ );
38
+
39
+ if ( $count % 3 == 0 ) {//Clear after every 3 items in the grid
40
+ $output .= '<div class="sdm_clear_float"></div>';
41
+ }
42
+ $count ++;
43
+ }
44
+ //$output .= '</ul>';
45
+ $output .= '<div class="sdm_clear_float"></div>';
46
+ return $output;
47
+ }
48
+
49
+ function sdm_generate_fancy2_category_display_output( $get_posts, $args ) {
50
+
51
+ $output = "";
52
+ $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 . '" />';
53
+
54
+ $count = 1;
55
+ //$output .= '<ul class="sdm_fancy2_category_items">';
56
+ foreach ( $get_posts as $item ) {
57
+ $output .= sdm_generate_fancy2_display_output(
58
+ array_merge( $args, array( 'id' => $item->ID ) )
59
+ );
60
+
61
+ if ( $count % 3 == 0 ) {//Clear after every 3 items in the grid
62
+ $output .= '<div class="sdm_clear_float"></div>';
63
+ }
64
+ $count ++;
65
  }
66
  //$output .= '</ul>';
67
  $output .= '<div class="sdm_clear_float"></div>';
74
  * id, fancy, button_text, new_window
75
  */
76
 
77
+ function sdm_generate_fancy2_display_output( $args ) {
78
 
79
  $shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
80
+ shortcode_atts( array(
81
+ 'id' => '',
82
+ 'button_text' => __( 'Download Now!', 'simple-download-monitor' ),
83
+ 'new_window' => '',
84
+ 'color' => '',
85
+ 'css_class' => 'sdm_fancy2_grid',
86
+ 'show_size' => '',
87
+ 'show_version' => '',
88
+ ), $args )
89
  );
90
 
91
  // Make shortcode attributes available in function local scope.
92
+ extract( $shortcode_atts );
93
 
94
  // Check the download ID
95
+ if ( empty( $id ) ) {
96
+ 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>';
97
  }
98
 
99
  // See if new window parameter is set
100
+ if ( empty( $new_window ) ) {
101
+ $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
102
  }
103
+ $window_target = empty( $new_window ) ? '_self' : '_blank';
104
 
105
+ $homepage = get_bloginfo( 'url' );
106
+ $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
107
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_fancy2_download_dl_link" target="' . $window_target . '">' . $button_text . '</a>';
108
 
109
  // Check to see if the download link cpt is password protected
110
+ $get_cpt_object = get_post( $id );
111
+ $cpt_is_password = ! empty( $get_cpt_object->post_password ) ? 'yes' : 'no'; // yes = download is password protected;
 
112
  // Read plugin settings
113
+ $main_opts = get_option( 'sdm_downloads_options' );
114
+
115
+ $main_advanced_opts = get_option( 'sdm_advanced_options' );
116
+
117
  //Check if Terms & Condition enabled
118
+ $termscond_enable = isset( $main_advanced_opts[ 'termscond_enable' ] ) ? true : false;
119
+ if ( $termscond_enable ) {
120
+ $download_button_code = sdm_get_download_form_with_termsncond( $id, $shortcode_atts, 'sdm_fancy2_download_dl_link' );
121
  }
122
+
123
  //Check if reCAPTCHA enabled
124
+ $recaptcha_enable = isset( $main_advanced_opts[ 'recaptcha_enable' ] ) ? true : false;
125
+ if ( $recaptcha_enable && $cpt_is_password == 'no' ) {
126
+ $download_button_code = sdm_get_download_form_with_recaptcha( $id, $shortcode_atts, 'sdm_fancy2_download_dl_link' );
127
  }
128
+
129
+ if ( $cpt_is_password !== 'no' ) {//This is a password protected download so replace the download now button with password requirement
130
+ $download_button_code = sdm_get_password_entry_form( $id, $shortcode_atts, 'sdm_fancy2_download_dl_link' );
131
  }
132
 
133
  // Get item thumbnail
134
+ $item_download_thumbnail = get_post_meta( $id, 'sdm_upload_thumbnail', true );
135
+ $isset_download_thumbnail = isset( $item_download_thumbnail ) && ! empty( $item_download_thumbnail ) ? '<img class="sdm_fancy2_thumb_image" src="' . $item_download_thumbnail . '" />' : '';
136
+ $isset_download_thumbnail = apply_filters( 'sdm_download_fancy_2_thumbnail', $isset_download_thumbnail, $args ); //Apply filter so it can be customized.
 
137
  // Get item title
138
+ $item_title = get_the_title( $id );
139
 
140
  // Get item description
141
+ $isset_item_description = sdm_get_item_description_output( $id );
142
 
143
  //Get item file size
144
+ $item_file_size = get_post_meta( $id, 'sdm_item_file_size', true );
145
  //Check if show file size is enabled
146
+ if ( empty( $show_size ) ) {
147
+ //Disabled in shortcode. Lets check if it is enabled in the download meta.
148
+ $show_size = get_post_meta( $id, 'sdm_item_show_file_size_fd', true );
149
+ }
150
+ $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
151
  //Get item version
152
+ $item_version = get_post_meta( $id, 'sdm_item_version', true );
153
  //Check if show version is enabled
154
+ if ( empty( $show_version ) ) {
155
+ //Disabled in shortcode. Lets check if it is enabled in the download meta.
156
+ $show_version = get_post_meta( $id, 'sdm_item_show_item_version_fd', true );
157
+ }
158
+ $isset_item_version = ($show_version && isset( $item_version )) ? $item_version : ''; //check if show_version is enabled and if there is a version value
 
159
  // check show date in fancy display
160
+ $show_date_fd = get_post_meta( $id, 'sdm_item_show_date_fd', true );
161
  // Get item date
162
+ $download_date = get_the_date( get_option( 'date_format' ), $id );
163
 
164
+ $output = '';
165
+ $output .= '<div class="sdm_fancy2_item ' . $css_class . '">';
166
+ $output .= '<div class="sdm_fancy2_wrapper">';
167
 
168
+ $output .= '<div class="sdm_fancy2_download_item_top">';
169
+ $output .= '<div class="sdm_fancy2_download_thumbnail">' . $isset_download_thumbnail . '</div>';
170
+ $output .= '</div>'; //End of .sdm_download_item_top
171
 
172
  $output .= '<div class="sdm_fancy2_download_title">' . $item_title . '</div>';
173
 
174
+ if ( ! empty( $isset_item_file_size ) ) {//Show file size info if specified in the shortcode
175
+ $output .= '<div class="sdm_fancy2_download_size">';
176
+ $output .= '<span class="sdm_fancy2_download_size_label">' . __( 'Size: ', 'simple-download-monitor' ) . '</span>';
177
+ $output .= '<span class="sdm_fancy2_download_size_value">' . $isset_item_file_size . '</span>';
178
+ $output .= '</div>';
179
  }
180
 
181
+ if ( ! empty( $isset_item_version ) ) {//Show version info if specified in the shortcode
182
+ $output .= '<div class="sdm_fancy2_download_version">';
183
+ $output .= '<span class="sdm_fancy2_download_version_label">' . __( 'Version: ', 'simple-download-monitor' ) . '</span>';
184
+ $output .= '<span class="sdm_fancy2_download_version_value">' . $isset_item_version . '</span>';
185
+ $output .= '</div>';
186
  }
187
+
188
+ if ( $show_date_fd ) {//Show version info if specified in the shortcode
189
+ $output .= '<div class="sdm_fancy2_download_date">';
190
+ $output .= '<span class="sdm_fancy2_download_date_label">' . __( 'Published: ', 'simple-download-monitor' ) . '</span>';
191
+ $output .= '<span class="sdm_fancy2_download_date_value">' . $download_date . '</span>';
192
+ $output .= '</div>';
193
  }
194
+
195
  //apply filter on button HTML code
196
+ $download_button_code = apply_filters( 'sdm_download_button_code_html', $download_button_code );
197
 
198
  $output .= '<div class="sdm_fancy2_download_link">' . $download_button_code . '</div>';
199
 
200
+ $output .= '</div>'; //end .sdm_fancy2_item
201
+ $output .= '</div>'; //end .sdm_fancy2_wrapper
202
  return $output;
203
  }
main.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://simple-download-monitor.com/
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
- * Version: 3.7.2
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
15
  exit;
16
  }
17
 
18
- define('WP_SIMPLE_DL_MONITOR_VERSION', '3.7.2');
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__));
@@ -32,6 +32,7 @@ include_once('includes/sdm-utility-functions-admin-side.php');
32
  include_once('includes/sdm-download-request-handler.php');
33
  include_once('includes/sdm-logs-list-table.php');
34
  include_once('includes/sdm-latest-downloads.php');
 
35
  include_once('includes/sdm-search-shortcode-handler.php');
36
  include_once('sdm-post-type-and-taxonomy.php');
37
  include_once('sdm-shortcodes.php');
3
  * Plugin Name: Simple Download Monitor
4
  * Plugin URI: https://simple-download-monitor.com/
5
  * Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
6
+ * Version: 3.7.4.2
7
  * Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
8
  * Author URI: https://www.tipsandtricks-hq.com/development-center
9
  * License: GPL2
15
  exit;
16
  }
17
 
18
+ define('WP_SIMPLE_DL_MONITOR_VERSION', '3.7.4.2');
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__));
32
  include_once('includes/sdm-download-request-handler.php');
33
  include_once('includes/sdm-logs-list-table.php');
34
  include_once('includes/sdm-latest-downloads.php');
35
+ include_once('includes/sdm-popular-downloads.php');
36
  include_once('includes/sdm-search-shortcode-handler.php');
37
  include_once('sdm-post-type-and-taxonomy.php');
38
  include_once('sdm-shortcodes.php');
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Tips and Tricks HQ, Ruhul Amin, josh401, mbrsolution, alexanderfox
3
  Donate link: https://www.tipsandtricks-hq.com
4
  Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
5
  Requires at least: 4.1.0
6
- Tested up to: 5.0
7
- Stable tag: 3.7.2
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -62,6 +62,7 @@ https://www.youtube.com/watch?v=utYIH0fILuQ
62
  * Export all the file download logs to a CSV file.
63
  * Ability to reset the log entries.
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/)
@@ -184,13 +185,26 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
184
 
185
  == Changelog ==
186
 
187
- = 3.7.2 =
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  - Bugfix: the new custom button text option did not work when used with the recaptcha feature.
189
 
190
  = 3.7.1 =
191
  - There is a new option to specify a custom button text for the download item. Check the "Download Button Text" field under the other details section.
192
 
193
- = 3.7.0=
194
  - Fixed "Open in new window" option was ignored when for downloads with reCaptcha, password and/or Terms and Conditions.
195
 
196
  = 3.6.9 =
3
  Donate link: https://www.tipsandtricks-hq.com
4
  Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
5
  Requires at least: 4.1.0
6
+ Tested up to: 5.2
7
+ Stable tag: 3.7.4.2
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
62
  * Export all the file download logs to a CSV file.
63
  * Ability to reset the log entries.
64
  * Shortcode to show a number of latest downloads to your visitors.
65
+ * Shortcode to show a number of popular downloads to your visitors.
66
  * Ability to disable the download monitoring (logging) for certain items (or all items).
67
  * You can also choose to only monitor downloads from unique IP address only.
68
  * 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/)
185
 
186
  == Changelog ==
187
 
188
+ = 3.7.4.2 =
189
+ - Fixed [sdm_popular_downloads] shortcode was ignoring button_text parameter for fancy 1 and fancy 2 templates.
190
+
191
+ = 3.7.4.1 =
192
+ - Updated the popular downloads shortcode to factor in the download counter offset setting.
193
+
194
+ = 3.7.4 =
195
+ - Added new shortcode [sdm_popular_downloads] to display popular downloads.
196
+ - Updated broken i18n string to properly use printf w/ variable replacement. Thanks to Garrett for fixing this.
197
+
198
+ = 3.7.3 =
199
+ - Added a new feature in the "Logs" menu that allows you to view the log entries of a specific download item.
200
+
201
+ = 3.7.2 =
202
  - Bugfix: the new custom button text option did not work when used with the recaptcha feature.
203
 
204
  = 3.7.1 =
205
  - There is a new option to specify a custom button text for the download item. Check the "Download Button Text" field under the other details section.
206
 
207
+ = 3.7.0 =
208
  - Fixed "Open in new window" option was ignored when for downloads with reCaptcha, password and/or Terms and Conditions.
209
 
210
  = 3.6.9 =
sdm-shortcodes.php CHANGED
@@ -16,6 +16,7 @@ function sdm_register_shortcodes() {
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
 
@@ -65,7 +66,7 @@ function sdm_create_download_shortcode( $atts ) {
65
  shortcode_atts( array(
66
  'id' => '',
67
  'fancy' => '0',
68
- 'button_text' => sdm_get_default_download_button_text($atts['id']),
69
  'new_window' => '',
70
  'color' => '',
71
  'css_class' => '',
@@ -88,8 +89,8 @@ function sdm_create_download_shortcode( $atts ) {
88
  $item_title = get_the_title( $id );
89
 
90
  //*** Generate the download now button code ***
91
- if(empty($new_window)){
92
- $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
93
  }
94
  $window_target = empty( $new_window ) ? '_self' : '_blank';
95
 
@@ -97,25 +98,25 @@ function sdm_create_download_shortcode( $atts ) {
97
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
98
  $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
99
 
100
- $main_advanced_opts = get_option('sdm_advanced_options');
101
-
102
  //Check if Terms & Condition enabled
103
- $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
104
- if ($termscond_enable) {
105
- $download_button_code = sdm_get_download_form_with_termsncond($id, $shortcode_atts,'sdm_download ' . $color);
106
  }
107
-
108
  //Check if reCAPTCHA enabled
109
- $recaptcha_enable = isset($main_advanced_opts['recaptcha_enable']) ? true : false;
110
- if ($recaptcha_enable && $cpt_is_password == 'no') {
111
- $download_button_code = sdm_get_download_form_with_recaptcha($id, $shortcode_atts, 'sdm_download ' . $color);
112
  }
113
-
114
  if ( $cpt_is_password !== 'no' ) {//This is a password protected download so replace the download now button with password requirement
115
  $download_button_code = sdm_get_password_entry_form( $id, $shortcode_atts, 'sdm_download ' . $color );
116
  }
117
  //End of download now button code generation
118
-
119
  $output = '';
120
  switch ( $fancy ) {
121
  case '1':
@@ -200,20 +201,20 @@ function sdm_handle_category_shortcode( $args ) {
200
  // Else setup query arguments for category_slug
201
  if ( ! empty( $category_slug ) && empty( $category_id ) ) {
202
 
203
- $field = 'slug';
204
-
205
- $terms = array_filter(explode(',', $category_slug), function($value) {
206
- return !empty($value) ? trim($value) : false;
207
- });
208
  }
209
  // Else setup query arguments for category_id
210
  else if ( ! empty( $category_id ) && empty( $category_slug ) ) {
211
 
212
  $field = 'term_id';
213
  //$terms = $category_id;
214
- $terms = array_filter(explode(',', $category_id), function($value) {
215
- return !empty($value) ? trim($value) : false;
216
- });
217
  }
218
 
219
  if ( isset( $args[ 'show_all' ] ) ) {
@@ -271,10 +272,10 @@ function sdm_handle_category_shortcode( $args ) {
271
 
272
  // Setup download location
273
  $homepage = get_bloginfo( 'url' );
274
- if(empty($new_window)){
275
- $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
276
- }
277
-
278
  $window_target = empty( $new_window ) ? '_self' : '_blank';
279
 
280
  // Iterate cpt's
@@ -290,21 +291,21 @@ function sdm_handle_category_shortcode( $args ) {
290
  // Setup download button code
291
  $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
292
 
293
-
294
- $main_advanced_opts = get_option('sdm_advanced_options');
295
-
296
- //Check if Terms & Condition enabled
297
- $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
298
- if ($termscond_enable) {
299
- $download_button_code = sdm_get_download_form_with_termsncond($id, $args,'sdm_download ' . $def_color);
300
- }
301
-
302
- //Check if reCAPTCHA enabled
303
- $recaptcha_enable = isset($main_advanced_opts['recaptcha_enable']) ? true : false;
304
- if ($recaptcha_enable) {
305
- $download_button_code = sdm_get_download_form_with_recaptcha($id, $args, 'sdm_download ' . $def_color);
306
- }
307
-
308
  // Generate download buttons
309
  $output .= '<div class="sdm_download_link">' . $download_button_code . '</div><br />';
310
  } // End foreach
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
+ add_shortcode( 'sdm_popular_downloads', 'sdm_show_popular_downloads' ); // For showing X number of popular downloads
20
 
21
  add_shortcode( 'sdm_download_link', 'sdm_create_simple_download_link' );
22
 
66
  shortcode_atts( array(
67
  'id' => '',
68
  'fancy' => '0',
69
+ 'button_text' => sdm_get_default_download_button_text( $atts[ 'id' ] ),
70
  'new_window' => '',
71
  'color' => '',
72
  'css_class' => '',
89
  $item_title = get_the_title( $id );
90
 
91
  //*** Generate the download now button code ***
92
+ if ( empty( $new_window ) ) {
93
+ $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
94
  }
95
  $window_target = empty( $new_window ) ? '_self' : '_blank';
96
 
98
  $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
99
  $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
100
 
101
+ $main_advanced_opts = get_option( 'sdm_advanced_options' );
102
+
103
  //Check if Terms & Condition enabled
104
+ $termscond_enable = isset( $main_advanced_opts[ 'termscond_enable' ] ) ? true : false;
105
+ if ( $termscond_enable ) {
106
+ $download_button_code = sdm_get_download_form_with_termsncond( $id, $shortcode_atts, 'sdm_download ' . $color );
107
  }
108
+
109
  //Check if reCAPTCHA enabled
110
+ $recaptcha_enable = isset( $main_advanced_opts[ 'recaptcha_enable' ] ) ? true : false;
111
+ if ( $recaptcha_enable && $cpt_is_password == 'no' ) {
112
+ $download_button_code = sdm_get_download_form_with_recaptcha( $id, $shortcode_atts, 'sdm_download ' . $color );
113
  }
114
+
115
  if ( $cpt_is_password !== 'no' ) {//This is a password protected download so replace the download now button with password requirement
116
  $download_button_code = sdm_get_password_entry_form( $id, $shortcode_atts, 'sdm_download ' . $color );
117
  }
118
  //End of download now button code generation
119
+
120
  $output = '';
121
  switch ( $fancy ) {
122
  case '1':
201
  // Else setup query arguments for category_slug
202
  if ( ! empty( $category_slug ) && empty( $category_id ) ) {
203
 
204
+ $field = 'slug';
205
+
206
+ $terms = array_filter( explode( ',', $category_slug ), function($value) {
207
+ return ! empty( $value ) ? trim( $value ) : false;
208
+ } );
209
  }
210
  // Else setup query arguments for category_id
211
  else if ( ! empty( $category_id ) && empty( $category_slug ) ) {
212
 
213
  $field = 'term_id';
214
  //$terms = $category_id;
215
+ $terms = array_filter( explode( ',', $category_id ), function($value) {
216
+ return ! empty( $value ) ? trim( $value ) : false;
217
+ } );
218
  }
219
 
220
  if ( isset( $args[ 'show_all' ] ) ) {
272
 
273
  // Setup download location
274
  $homepage = get_bloginfo( 'url' );
275
+ if ( empty( $new_window ) ) {
276
+ $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
277
+ }
278
+
279
  $window_target = empty( $new_window ) ? '_self' : '_blank';
280
 
281
  // Iterate cpt's
291
  // Setup download button code
292
  $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $item_title . '" target="' . $window_target . '">' . $button_text . '</a>';
293
 
294
+
295
+ $main_advanced_opts = get_option( 'sdm_advanced_options' );
296
+
297
+ //Check if Terms & Condition enabled
298
+ $termscond_enable = isset( $main_advanced_opts[ 'termscond_enable' ] ) ? true : false;
299
+ if ( $termscond_enable ) {
300
+ $download_button_code = sdm_get_download_form_with_termsncond( $id, $args, 'sdm_download ' . $def_color );
301
+ }
302
+
303
+ //Check if reCAPTCHA enabled
304
+ $recaptcha_enable = isset( $main_advanced_opts[ 'recaptcha_enable' ] ) ? true : false;
305
+ if ( $recaptcha_enable ) {
306
+ $download_button_code = sdm_get_download_form_with_recaptcha( $id, $args, 'sdm_download ' . $def_color );
307
+ }
308
+
309
  // Generate download buttons
310
  $output .= '<div class="sdm_download_link">' . $download_button_code . '</div><br />';
311
  } // End foreach