Simple Download Monitor - Version 3.7.2

Version Description

  • Bugfix: the new custom button text option did not work when used with the recaptcha feature.
Download this release

Release Info

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

Code changes from version 3.7.0 to 3.7.2

includes/sdm-utility-functions.php CHANGED
@@ -41,10 +41,10 @@ function sdm_get_download_count_for_post($id) {
41
  function sdm_get_password_entry_form($id, $args = array(), $class = '') {
42
  $action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
43
 
44
- //Get the download button text
45
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
46
  if (empty($button_text)) {//Use the default text for the button
47
- $button_text_string = __('Download Now!', 'simple-download-monitor');
48
  } else {//Use the custom text
49
  $button_text_string = $button_text;
50
  }
@@ -214,7 +214,7 @@ function sdm_get_download_form_with_recaptcha($id, $args = array(), $class = '')
214
  //Get the download button text
215
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
216
  if (empty($button_text)) {//Use the default text for the button
217
- $button_text_string = __('Download Now!', 'simple-download-monitor');
218
  } else {//Use the custom text
219
  $button_text_string = $button_text;
220
  }
@@ -267,11 +267,11 @@ function sdm_get_download_form_with_termsncond($id, $args = array(), $class = ''
267
  //Get the download button text
268
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
269
  if (empty($button_text)) {//Use the default text for the button
270
- $button_text_string = __('Download Now!', 'simple-download-monitor');
271
  } else {//Use the custom text
272
  $button_text_string = $button_text;
273
  }
274
-
275
  $main_advanced_opts = get_option('sdm_advanced_options');
276
  $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
277
 
@@ -286,4 +286,12 @@ function sdm_get_download_form_with_termsncond($id, $args = array(), $class = ''
286
  $data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
287
  $data .= '</form>';
288
  return $data;
289
- }
 
 
 
 
 
 
 
 
41
  function sdm_get_password_entry_form($id, $args = array(), $class = '') {
42
  $action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
43
 
44
+ //Get the download button text
45
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
46
  if (empty($button_text)) {//Use the default text for the button
47
+ $button_text_string = sdm_get_default_download_button_text($id);
48
  } else {//Use the custom text
49
  $button_text_string = $button_text;
50
  }
214
  //Get the download button text
215
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
216
  if (empty($button_text)) {//Use the default text for the button
217
+ $button_text_string = sdm_get_default_download_button_text($id);
218
  } else {//Use the custom text
219
  $button_text_string = $button_text;
220
  }
267
  //Get the download button text
268
  $button_text = isset($args['button_text']) ? $args['button_text'] : '';
269
  if (empty($button_text)) {//Use the default text for the button
270
+ $button_text_string = sdm_get_default_download_button_text($id);
271
  } else {//Use the custom text
272
  $button_text_string = $button_text;
273
  }
274
+
275
  $main_advanced_opts = get_option('sdm_advanced_options');
276
  $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
277
 
286
  $data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
287
  $data .= '</form>';
288
  return $data;
289
+ }
290
+
291
+ function sdm_get_default_download_button_text($download_id){
292
+ $default_text = __('Download Now!', 'simple-download-monitor');
293
+ $meta_text = get_post_meta($download_id, 'sdm_download_button_text', true);
294
+
295
+ $button_text = !empty($meta_text) ? $meta_text : $default_text;
296
+ return $button_text;
297
+ }
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.0
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.0');
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__));
@@ -220,7 +220,7 @@ class simpleDownloadManager {
220
  }
221
 
222
  }
223
-
224
  public function sdm_admin_scripts() {
225
 
226
  global $current_screen, $post;
@@ -320,7 +320,7 @@ class simpleDownloadManager {
320
  $old_description = get_post_meta($post->ID, 'sdm_description', true);
321
  $sdm_description_field = array('textarea_name' => 'sdm_description');
322
  wp_editor($old_description, "sdm_description_editor_content", $sdm_description_field);
323
-
324
  wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');
325
  }
326
 
@@ -465,6 +465,9 @@ class simpleDownloadManager {
465
  $version = get_post_meta($post->ID, 'sdm_item_version', true);
466
  $version = isset($version) ? $version : '';
467
 
 
 
 
468
  echo '<div class="sdm-download-edit-filesize">';
469
  echo '<strong>'.__('File Size: ', 'simple-download-monitor').'</strong>';
470
  echo '<br />';
@@ -490,7 +493,14 @@ class simpleDownloadManager {
490
  echo '<br /> <input id="sdm_item_show_date_fd" type="checkbox" name="sdm_item_show_date_fd" value="yes"' . checked(true, $show_date_fd, false) . ' />';
491
  echo '<label for="sdm_item_show_date_fd">' . __('Show download published date in fancy display.', 'simple-download-monitor') . '</label>';
492
  echo '</div>';
 
493
 
 
 
 
 
 
 
494
  wp_nonce_field('sdm_other_details_nonce', 'sdm_other_details_nonce_check');
495
  }
496
 
@@ -613,6 +623,11 @@ class simpleDownloadManager {
613
  if (isset($_POST['sdm_item_version'])) {
614
  update_post_meta($post_id, 'sdm_item_version', sanitize_text_field($_POST['sdm_item_version']));
615
  }
 
 
 
 
 
616
  }
617
 
618
  public function sdm_remove_view_link_cpt($action, $post) {
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
  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__));
220
  }
221
 
222
  }
223
+
224
  public function sdm_admin_scripts() {
225
 
226
  global $current_screen, $post;
320
  $old_description = get_post_meta($post->ID, 'sdm_description', true);
321
  $sdm_description_field = array('textarea_name' => 'sdm_description');
322
  wp_editor($old_description, "sdm_description_editor_content", $sdm_description_field);
323
+
324
  wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');
325
  }
326
 
465
  $version = get_post_meta($post->ID, 'sdm_item_version', true);
466
  $version = isset($version) ? $version : '';
467
 
468
+ $download_button_text = get_post_meta($post->ID, 'sdm_download_button_text', true);
469
+ $download_button_text = isset($download_button_text) ? $download_button_text : '';
470
+
471
  echo '<div class="sdm-download-edit-filesize">';
472
  echo '<strong>'.__('File Size: ', 'simple-download-monitor').'</strong>';
473
  echo '<br />';
493
  echo '<br /> <input id="sdm_item_show_date_fd" type="checkbox" name="sdm_item_show_date_fd" value="yes"' . checked(true, $show_date_fd, false) . ' />';
494
  echo '<label for="sdm_item_show_date_fd">' . __('Show download published date in fancy display.', 'simple-download-monitor') . '</label>';
495
  echo '</div>';
496
+ echo '<hr />';
497
 
498
+ echo '<div class="sdm-download-edit-button-text">';
499
+ echo '<strong>'.__('Download Button Text: ', 'simple-download-monitor').'</strong>';
500
+ echo '<br />';
501
+ echo "<input id='sdm-download-button-text' type='text' name='sdm_download_button_text' value='{$download_button_text}' />";
502
+ echo '<p class="description">' . __('You can use this field to customize the download now button text of this item.', 'simple-download-monitor') . '</p>';
503
+
504
  wp_nonce_field('sdm_other_details_nonce', 'sdm_other_details_nonce_check');
505
  }
506
 
623
  if (isset($_POST['sdm_item_version'])) {
624
  update_post_meta($post_id, 'sdm_item_version', sanitize_text_field($_POST['sdm_item_version']));
625
  }
626
+
627
+ if (isset($_POST['sdm_download_button_text'])) {
628
+ update_post_meta($post_id, 'sdm_download_button_text', sanitize_text_field($_POST['sdm_download_button_text']));
629
+ }
630
+
631
  }
632
 
633
  public function sdm_remove_view_link_cpt($action, $post) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.tipsandtricks-hq.com
4
  Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
5
  Requires at least: 4.1.0
6
  Tested up to: 5.0
7
- Stable tag: 3.7.0
8
  License: GPLv2 or later
9
 
10
  Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
@@ -184,7 +184,13 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
184
 
185
  == Changelog ==
186
 
187
- = 3.7.0.=
 
 
 
 
 
 
188
  - Fixed "Open in new window" option was ignored when for downloads with reCaptcha, password and/or Terms and Conditions.
189
 
190
  = 3.6.9 =
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.
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 =
sdm-post-type-content-handler.php CHANGED
@@ -1,180 +1,180 @@
1
- <?php
2
-
3
- //Handles the output on the SDM individual download page (Custom Post Type)
4
- add_filter('the_content', 'filter_sdm_post_type_content');
5
-
6
- function filter_sdm_post_type_content($content) {
7
- global $post;
8
- if (isset($post->post_type) && $post->post_type == "sdm_downloads") {//Handle the content for sdm_downloads type post
9
- //$download_id = $post->ID;
10
- //$args = array('id' => $download_id, 'fancy' => '1');
11
- //$content = sdm_create_download_shortcode($args);
12
- $id = $post->ID;
13
-
14
- //Check to see if the download link cpt is password protected
15
- $get_cpt_object = get_post($id);
16
- $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
17
- //Get item thumbnail
18
- $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
19
- $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_post_thumbnail_image" src="' . $item_download_thumbnail . '" />' : '';
20
-
21
- //Get item title
22
- $item_title = get_the_title($id);
23
- $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
24
-
25
- //Get item description
26
- $isset_item_description = sdm_get_item_description_output($id);
27
-
28
- //$isset_item_description = apply_filters('the_content', $isset_item_description);
29
- //Get item file size
30
- $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
31
- $isset_item_file_size = isset($item_file_size) ? $item_file_size : '';
32
-
33
- //Get item version
34
- $item_version = get_post_meta($id, 'sdm_item_version', true);
35
- $isset_item_version = isset($item_version) ? $item_version : '';
36
-
37
- //Check if show published date is enabled
38
- $show_date_fd = get_post_meta($id, 'sdm_item_show_date_fd', true);
39
- //Get published date
40
- $published_date = get_the_date(get_option('date_format'), $id);
41
-
42
- // See if user color option is selected
43
- $main_opts = get_option('sdm_downloads_options');
44
- $color_opt = $main_opts['download_button_color'];
45
- $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : __('green', 'simple-download-monitor');
46
-
47
- //Download counter
48
- //$dl_counter = sdm_create_counter_shortcode(array('id'=>$id));
49
- //*** Generate the download now button code ***
50
- $button_text_string = __('Download Now!', 'simple-download-monitor');
51
-
52
- // See if new window parameter is set
53
- $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
54
- $window_target = empty($new_window) ? '_self' : '_blank';
55
-
56
- $homepage = get_bloginfo('url');
57
- $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
58
- $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" target="' . $window_target . '">' . $button_text_string . '</a>';
59
-
60
- $main_advanced_opts = get_option('sdm_advanced_options');
61
-
62
- //Check if Terms & Condition enabled
63
- $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
64
- if ($termscond_enable) {
65
- $download_button_code = sdm_get_download_form_with_termsncond($id, array(),'sdm_download ' . $def_color);
66
- }
67
-
68
- //Check if reCAPTCHA enabled
69
- $recaptcha_enable = isset($main_advanced_opts['recaptcha_enable']) ? true : false;
70
- if ($recaptcha_enable && $cpt_is_password == 'no') {
71
- $download_button_code = sdm_get_download_form_with_recaptcha($id, array(),'sdm_download ' . $def_color);
72
- }
73
-
74
- if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
75
- $download_button_code = sdm_get_password_entry_form($id, array(),'sdm_download ' . $def_color);
76
- }
77
-
78
- // Check if we only allow the download for logged-in users
79
- // if (isset($main_opts['only_logged_in_can_download'])) {
80
- // if ($main_opts['only_logged_in_can_download'] && sdm_get_logged_in_user()===false) {
81
- // // User not logged in, let's display the message
82
- // $download_button_code = __('You need to be logged in to download this file.','simple-download-monitor');
83
- // }
84
- // }
85
-
86
- $db_count = sdm_get_download_count_for_post($id);
87
- $string = ($db_count == '1') ? __('Download', 'simple-download-monitor') : __('Downloads', 'simple-download-monitor');
88
- $download_count_string = '<span class="sdm_post_count_number">' . $db_count . '</span><span class="sdm_post_count_string"> ' . $string . '</span>';
89
-
90
- //Output the download item details
91
- $content = '<div class="sdm_post_item">';
92
- $content .= '<div class="sdm_post_item_top">';
93
-
94
- $content .= '<div class="sdm_post_item_top_left">';
95
- $content .= '<div class="sdm_post_thumbnail">' . $isset_download_thumbnail . '</div>';
96
- $content .= '</div>'; //end .sdm_post_item_top_left
97
-
98
- $content .= '<div class="sdm_post_item_top_right">';
99
- $content .= '<div class="sdm_post_title">' . $isset_item_title . '</div>';
100
-
101
- if (!isset($main_opts['general_hide_donwload_count'])) {//The hide download count is enabled.
102
- $content .= '<div class="sdm_post_download_count">' . $download_count_string . '</div>';
103
- }
104
-
105
- $content .= '<div class="sdm_post_description">' . $isset_item_description . '</div>';
106
-
107
- //This hook can be used to add content below the description
108
- $content .= apply_filters('sdm_cpt_below_download_description','');
109
-
110
- $content .= '<div class="sdm_post_download_section"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
111
-
112
- if (!empty($isset_item_file_size)) {//Show file size info
113
- $content .= '<div class="sdm_post_download_file_size">';
114
- $content .= '<span class="sdm_post_download_size_label">' . __('Size: ', 'simple-download-monitor') . '</span>';
115
- $content .= '<span class="sdm_post_download_size_value">' . $isset_item_file_size . '</span>';
116
- $content .= '</div>';
117
- }
118
-
119
- if (!empty($isset_item_version)) {//Show version info
120
- $content .= '<div class="sdm_post_download_version">';
121
- $content .= '<span class="sdm_post_download_version_label">' . __('Version: ', 'simple-download-monitor') . '</span>';
122
- $content .= '<span class="sdm_post_download_version_value">' . $isset_item_version . '</span>';
123
- $content .= '</div>';
124
- }
125
-
126
- if ($show_date_fd) {//Show Published date
127
- $content .= '<div class="sdm_post_download_published_date">';
128
- $content .= '<span class="sdm_post_download_published_date_label">' . __('Published: ', 'simple-download-monitor') . '</span>';
129
- $content .= '<span class="sdm_post_download_published_date_value">' . $published_date . '</span>';
130
- $content .= '</div>';
131
- }
132
-
133
- //$content .= '<div class="sdm_post_meta_section"></div>';//TODO - Show post meta (category and tags)
134
- $content .= '</div>'; //end .sdm_post_item_top_right
135
-
136
- $content .= '</div>'; //end of .sdm_download_item_top
137
-
138
- $content .= '<div style="clear:both;"></div>';
139
-
140
- $content .= '</div>'; //end .sdm_post_item
141
-
142
- return $content;
143
- }
144
-
145
- return $content;
146
- }
147
-
148
- //The following filters are applied to the output of the SDM description field.
149
- add_filter('sdm_downloads_description', 'do_shortcode' );
150
- add_filter('sdm_downloads_description', 'wptexturize' );
151
- add_filter('sdm_downloads_description', 'convert_smilies' );
152
- add_filter('sdm_downloads_description', 'convert_chars' );
153
- add_filter('sdm_downloads_description', 'wpautop' );
154
- add_filter('sdm_downloads_description', 'shortcode_unautop' );
155
- add_filter('sdm_downloads_description', 'prepend_attachment' );
156
-
157
- function sdm_get_item_description_output($id) {
158
- $item_description = get_post_meta($id, 'sdm_description', true);
159
- $isset_item_description = isset($item_description) && !empty($item_description) ? $item_description : '';
160
- //$isset_item_description = apply_filters('the_content', $isset_item_description);
161
-
162
- //Lets apply all the filters like do_shortcode, wptexturize, convert_smilies, wpautop etc.
163
- $filtered_item_description = apply_filters('sdm_downloads_description', $isset_item_description);
164
-
165
- return $filtered_item_description;
166
- }
167
-
168
- //Add adsense or ad code below the description (if applicable)
169
- add_filter('sdm_cpt_below_download_description', 'sdm_add_ad_code_below_description');
170
- add_filter('sdm_fancy1_below_download_description', 'sdm_add_ad_code_below_description');
171
-
172
- function sdm_add_ad_code_below_description($output){
173
- $main_advanced_opts = get_option('sdm_advanced_options');
174
- $adsense_below_desc = isset($main_advanced_opts['adsense_below_description']) ? $main_advanced_opts['adsense_below_description'] : '';
175
- if(!empty($adsense_below_desc)){
176
- //Ad code is configured in settings. Lets add it to the output.
177
- $output .= '<div class="sdm_below_description_ad_code">' . $adsense_below_desc . '</div>';
178
- }
179
- return $output;
180
  }
1
+ <?php
2
+
3
+ //Handles the output on the SDM individual download page (Custom Post Type)
4
+ add_filter('the_content', 'filter_sdm_post_type_content');
5
+
6
+ function filter_sdm_post_type_content($content) {
7
+ global $post;
8
+ if (isset($post->post_type) && $post->post_type == "sdm_downloads") {//Handle the content for sdm_downloads type post
9
+ //$download_id = $post->ID;
10
+ //$args = array('id' => $download_id, 'fancy' => '1');
11
+ //$content = sdm_create_download_shortcode($args);
12
+ $id = $post->ID;
13
+
14
+ //Check to see if the download link cpt is password protected
15
+ $get_cpt_object = get_post($id);
16
+ $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected;
17
+ //Get item thumbnail
18
+ $item_download_thumbnail = get_post_meta($id, 'sdm_upload_thumbnail', true);
19
+ $isset_download_thumbnail = isset($item_download_thumbnail) && !empty($item_download_thumbnail) ? '<img class="sdm_post_thumbnail_image" src="' . $item_download_thumbnail . '" />' : '';
20
+
21
+ //Get item title
22
+ $item_title = get_the_title($id);
23
+ $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : '';
24
+
25
+ //Get item description
26
+ $isset_item_description = sdm_get_item_description_output($id);
27
+
28
+ //$isset_item_description = apply_filters('the_content', $isset_item_description);
29
+ //Get item file size
30
+ $item_file_size = get_post_meta($id, 'sdm_item_file_size', true);
31
+ $isset_item_file_size = isset($item_file_size) ? $item_file_size : '';
32
+
33
+ //Get item version
34
+ $item_version = get_post_meta($id, 'sdm_item_version', true);
35
+ $isset_item_version = isset($item_version) ? $item_version : '';
36
+
37
+ //Check if show published date is enabled
38
+ $show_date_fd = get_post_meta($id, 'sdm_item_show_date_fd', true);
39
+ //Get published date
40
+ $published_date = get_the_date(get_option('date_format'), $id);
41
+
42
+ // See if user color option is selected
43
+ $main_opts = get_option('sdm_downloads_options');
44
+ $color_opt = $main_opts['download_button_color'];
45
+ $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : __('green', 'simple-download-monitor');
46
+
47
+ //Download counter
48
+ //$dl_counter = sdm_create_counter_shortcode(array('id'=>$id));
49
+ //*** Generate the download now button code ***
50
+ $button_text_string = sdm_get_default_download_button_text($post->ID);
51
+
52
+ // See if new window parameter is set
53
+ $new_window = get_post_meta( $id, 'sdm_item_new_window', true );
54
+ $window_target = empty($new_window) ? '_self' : '_blank';
55
+
56
+ $homepage = get_bloginfo('url');
57
+ $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id;
58
+ $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" target="' . $window_target . '">' . $button_text_string . '</a>';
59
+
60
+ $main_advanced_opts = get_option('sdm_advanced_options');
61
+
62
+ //Check if Terms & Condition enabled
63
+ $termscond_enable = isset($main_advanced_opts['termscond_enable']) ? true : false;
64
+ if ($termscond_enable) {
65
+ $download_button_code = sdm_get_download_form_with_termsncond($id, array(),'sdm_download ' . $def_color);
66
+ }
67
+
68
+ //Check if reCAPTCHA enabled
69
+ $recaptcha_enable = isset($main_advanced_opts['recaptcha_enable']) ? true : false;
70
+ if ($recaptcha_enable && $cpt_is_password == 'no') {
71
+ $download_button_code = sdm_get_download_form_with_recaptcha($id, array(),'sdm_download ' . $def_color);
72
+ }
73
+
74
+ if ($cpt_is_password !== 'no') {//This is a password protected download so replace the download now button with password requirement
75
+ $download_button_code = sdm_get_password_entry_form($id, array(),'sdm_download ' . $def_color);
76
+ }
77
+
78
+ // Check if we only allow the download for logged-in users
79
+ // if (isset($main_opts['only_logged_in_can_download'])) {
80
+ // if ($main_opts['only_logged_in_can_download'] && sdm_get_logged_in_user()===false) {
81
+ // // User not logged in, let's display the message
82
+ // $download_button_code = __('You need to be logged in to download this file.','simple-download-monitor');
83
+ // }
84
+ // }
85
+
86
+ $db_count = sdm_get_download_count_for_post($id);
87
+ $string = ($db_count == '1') ? __('Download', 'simple-download-monitor') : __('Downloads', 'simple-download-monitor');
88
+ $download_count_string = '<span class="sdm_post_count_number">' . $db_count . '</span><span class="sdm_post_count_string"> ' . $string . '</span>';
89
+
90
+ //Output the download item details
91
+ $content = '<div class="sdm_post_item">';
92
+ $content .= '<div class="sdm_post_item_top">';
93
+
94
+ $content .= '<div class="sdm_post_item_top_left">';
95
+ $content .= '<div class="sdm_post_thumbnail">' . $isset_download_thumbnail . '</div>';
96
+ $content .= '</div>'; //end .sdm_post_item_top_left
97
+
98
+ $content .= '<div class="sdm_post_item_top_right">';
99
+ $content .= '<div class="sdm_post_title">' . $isset_item_title . '</div>';
100
+
101
+ if (!isset($main_opts['general_hide_donwload_count'])) {//The hide download count is enabled.
102
+ $content .= '<div class="sdm_post_download_count">' . $download_count_string . '</div>';
103
+ }
104
+
105
+ $content .= '<div class="sdm_post_description">' . $isset_item_description . '</div>';
106
+
107
+ //This hook can be used to add content below the description
108
+ $content .= apply_filters('sdm_cpt_below_download_description','');
109
+
110
+ $content .= '<div class="sdm_post_download_section"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
111
+
112
+ if (!empty($isset_item_file_size)) {//Show file size info
113
+ $content .= '<div class="sdm_post_download_file_size">';
114
+ $content .= '<span class="sdm_post_download_size_label">' . __('Size: ', 'simple-download-monitor') . '</span>';
115
+ $content .= '<span class="sdm_post_download_size_value">' . $isset_item_file_size . '</span>';
116
+ $content .= '</div>';
117
+ }
118
+
119
+ if (!empty($isset_item_version)) {//Show version info
120
+ $content .= '<div class="sdm_post_download_version">';
121
+ $content .= '<span class="sdm_post_download_version_label">' . __('Version: ', 'simple-download-monitor') . '</span>';
122
+ $content .= '<span class="sdm_post_download_version_value">' . $isset_item_version . '</span>';
123
+ $content .= '</div>';
124
+ }
125
+
126
+ if ($show_date_fd) {//Show Published date
127
+ $content .= '<div class="sdm_post_download_published_date">';
128
+ $content .= '<span class="sdm_post_download_published_date_label">' . __('Published: ', 'simple-download-monitor') . '</span>';
129
+ $content .= '<span class="sdm_post_download_published_date_value">' . $published_date . '</span>';
130
+ $content .= '</div>';
131
+ }
132
+
133
+ //$content .= '<div class="sdm_post_meta_section"></div>';//TODO - Show post meta (category and tags)
134
+ $content .= '</div>'; //end .sdm_post_item_top_right
135
+
136
+ $content .= '</div>'; //end of .sdm_download_item_top
137
+
138
+ $content .= '<div style="clear:both;"></div>';
139
+
140
+ $content .= '</div>'; //end .sdm_post_item
141
+
142
+ return $content;
143
+ }
144
+
145
+ return $content;
146
+ }
147
+
148
+ //The following filters are applied to the output of the SDM description field.
149
+ add_filter('sdm_downloads_description', 'do_shortcode' );
150
+ add_filter('sdm_downloads_description', 'wptexturize' );
151
+ add_filter('sdm_downloads_description', 'convert_smilies' );
152
+ add_filter('sdm_downloads_description', 'convert_chars' );
153
+ add_filter('sdm_downloads_description', 'wpautop' );
154
+ add_filter('sdm_downloads_description', 'shortcode_unautop' );
155
+ add_filter('sdm_downloads_description', 'prepend_attachment' );
156
+
157
+ function sdm_get_item_description_output($id) {
158
+ $item_description = get_post_meta($id, 'sdm_description', true);
159
+ $isset_item_description = isset($item_description) && !empty($item_description) ? $item_description : '';
160
+ //$isset_item_description = apply_filters('the_content', $isset_item_description);
161
+
162
+ //Lets apply all the filters like do_shortcode, wptexturize, convert_smilies, wpautop etc.
163
+ $filtered_item_description = apply_filters('sdm_downloads_description', $isset_item_description);
164
+
165
+ return $filtered_item_description;
166
+ }
167
+
168
+ //Add adsense or ad code below the description (if applicable)
169
+ add_filter('sdm_cpt_below_download_description', 'sdm_add_ad_code_below_description');
170
+ add_filter('sdm_fancy1_below_download_description', 'sdm_add_ad_code_below_description');
171
+
172
+ function sdm_add_ad_code_below_description($output){
173
+ $main_advanced_opts = get_option('sdm_advanced_options');
174
+ $adsense_below_desc = isset($main_advanced_opts['adsense_below_description']) ? $main_advanced_opts['adsense_below_description'] : '';
175
+ if(!empty($adsense_below_desc)){
176
+ //Ad code is configured in settings. Lets add it to the output.
177
+ $output .= '<div class="sdm_below_description_ad_code">' . $adsense_below_desc . '</div>';
178
+ }
179
+ return $output;
180
  }
sdm-shortcodes.php CHANGED
@@ -65,7 +65,7 @@ function 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' => '',
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' => '',