Version Description
- Added a new option in the download configuration to disable the individual download page of an item. Can be useful if you only want to allow downloading of the item from where you embed it.
Download this release
Release Info
Developer | mra13 |
Plugin | Simple Download Monitor |
Version | 3.7.8 |
Comparing to | |
See all releases |
Code changes from version 3.7.5 to 3.7.8
- css/sdm_wp_styles.css +21 -0
- includes/sdm-blocks.php +118 -0
- includes/sdm-download-request-handler.php +101 -102
- includes/sdm-latest-downloads.php +3 -0
- includes/sdm-popular-downloads.php +3 -0
- includes/sdm-search-shortcode-handler.php +3 -0
- includes/sdm-utility-functions.php +152 -145
- includes/templates/fancy0/sdm-fancy-0.php +2 -0
- includes/templates/fancy3/sdm-fancy-3.php +108 -0
- js/sdm_blocks.js +79 -0
- js/sdm_g_recaptcha.js +1 -1
- main.php +20 -5
- readme.txt +16 -3
- sdm-post-type-and-taxonomy.php +71 -71
- sdm-post-type-content-handler.php +15 -4
- sdm-shortcodes.php +8 -0
css/sdm_wp_styles.css
CHANGED
@@ -375,4 +375,25 @@
|
|
375 |
}
|
376 |
.sdm_disabled_button {
|
377 |
opacity: 0.2; /* use opacity to make the button appear disabled */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
}
|
375 |
}
|
376 |
.sdm_disabled_button {
|
377 |
opacity: 0.2; /* use opacity to make the button appear disabled */
|
378 |
+
}
|
379 |
+
|
380 |
+
/************************/
|
381 |
+
/*** Fancy 3 template ***/
|
382 |
+
/************************/
|
383 |
+
.sdm_fancy3_download_item{
|
384 |
+
display: block;
|
385 |
+
max-width: 320px;
|
386 |
+
border:1px solid #ccc;
|
387 |
+
margin-bottom:5px;
|
388 |
+
}
|
389 |
+
.sdm_fancy3_download_title{
|
390 |
+
font-weight: bold;
|
391 |
+
float: left;
|
392 |
+
padding: 5px 10px;
|
393 |
+
max-width: 170px;
|
394 |
+
overflow: hidden;
|
395 |
+
}
|
396 |
+
.sdm_fancy3_view_details_link{
|
397 |
+
float: right;
|
398 |
+
padding: 5px 10px;
|
399 |
}
|
includes/sdm-blocks.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SDMBlocks {
|
4 |
+
|
5 |
+
function __construct() {
|
6 |
+
add_action( 'init', array( $this, 'register_block' ) );
|
7 |
+
}
|
8 |
+
|
9 |
+
function register_block() {
|
10 |
+
if ( ! function_exists( 'register_block_type' ) ) {
|
11 |
+
// Gutenberg is not active.
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
wp_enqueue_style( 'sdm-styles', WP_SIMPLE_DL_MONITOR_URL . '/css/sdm_wp_styles.css' );
|
16 |
+
|
17 |
+
wp_register_script(
|
18 |
+
'sdm-blocks-script', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_blocks.js', array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ), WP_SIMPLE_DL_MONITOR_VERSION );
|
19 |
+
|
20 |
+
$fancyArr = array();
|
21 |
+
$fancyArr[] = array( 'label' => "Fancy 0", 'value' => 0 );
|
22 |
+
$fancyArr[] = array( 'label' => "Fancy 1", 'value' => 1 );
|
23 |
+
$fancyArr[] = array( 'label' => "Fancy 2", 'value' => 2 );
|
24 |
+
|
25 |
+
$defColorArr = sdm_get_download_button_colors();
|
26 |
+
|
27 |
+
$colorArr = array();
|
28 |
+
$colorArr[] = array( 'label' => __( 'Default', 'simple-download-monitor' ), 'value' => '' );
|
29 |
+
foreach ( $defColorArr as $value => $label ) {
|
30 |
+
$colorArr[] = array( 'label' => $label, 'value' => $value );
|
31 |
+
}
|
32 |
+
|
33 |
+
wp_localize_script( 'sdm-blocks-script', 'sdmDownloadBlockItems', $this->get_items_array() );
|
34 |
+
wp_localize_script( 'sdm-blocks-script', 'sdmDownloadBlockFancy', $fancyArr );
|
35 |
+
wp_localize_script( 'sdm-blocks-script', 'sdmDownloadBlockColor', $colorArr );
|
36 |
+
wp_localize_script( 'sdm-blocks-script', 'sdmBlockDownloadItemStr', array(
|
37 |
+
'title' => __( 'SDM Download', 'simple-download-monitor' ),
|
38 |
+
'download' => __( 'Download Item', 'simple-download-monitor' ),
|
39 |
+
'downloadHelp' => __( 'Select download item.', 'simple-download-monitor' ),
|
40 |
+
'buttonText' => __( 'Button Text', 'simple-download-monitor' ),
|
41 |
+
'buttonTextHelp' => __( 'Customized text for the download button. Leave it blank to use default text.', 'simple-download-monitor' ),
|
42 |
+
'fancy' => __( 'Template', 'simple-download-monitor' ),
|
43 |
+
'fancyHelp' => __( 'Select download item template.', 'simple-download-monitor' ),
|
44 |
+
'newWindow' => __( 'Open Download in a New Window', 'simple-download-monitor' ),
|
45 |
+
'color' => __( 'Button Color', 'simple-download-monitor' ),
|
46 |
+
'colorHelp' => __( 'Select button color. Note that this option may not work for some templates.', 'simple-download-monitor' ),
|
47 |
+
) );
|
48 |
+
|
49 |
+
register_block_type( 'simple-download-monitor/download-item', array(
|
50 |
+
'attributes' => array(
|
51 |
+
'itemId' => array(
|
52 |
+
'type' => 'string',
|
53 |
+
'default' => 0,
|
54 |
+
),
|
55 |
+
'fancyId' => array(
|
56 |
+
'type' => 'string',
|
57 |
+
'default' => 0,
|
58 |
+
),
|
59 |
+
'color' => array(
|
60 |
+
'type' => 'string',
|
61 |
+
'default' => '',
|
62 |
+
),
|
63 |
+
'buttonText' => array(
|
64 |
+
'type' => 'string',
|
65 |
+
'default' => '',
|
66 |
+
),
|
67 |
+
'newWindow' => array(
|
68 |
+
'type' => 'boolean',
|
69 |
+
'default' => false,
|
70 |
+
),
|
71 |
+
),
|
72 |
+
'editor_script' => 'sdm-blocks-script',
|
73 |
+
'render_callback' => array( $this, 'render_item_block' ),
|
74 |
+
) );
|
75 |
+
}
|
76 |
+
|
77 |
+
function render_item_block( $atts ) {
|
78 |
+
|
79 |
+
$itemId = ! empty( $atts[ 'itemId' ] ) ? intval( $atts[ 'itemId' ] ) : 0;
|
80 |
+
$fancyId = ! empty( $atts[ 'fancyId' ] ) ? intval( $atts[ 'fancyId' ] ) : 0;
|
81 |
+
$color = ! empty( $atts[ 'color' ] ) ? $atts[ 'color' ] : '';
|
82 |
+
$buttonText = ! empty( $atts[ 'buttonText' ] ) ? esc_attr( $atts[ 'buttonText' ] ) : sdm_get_download_form_with_termsncond( $itemId );
|
83 |
+
$newWindow = ! empty( $atts[ 'newWindow' ] ) ? 1 : 0;
|
84 |
+
|
85 |
+
if ( empty( $itemId ) ) {
|
86 |
+
return '<p>' . __( 'Select item to view', 'simple-download-monitor' ) . '</p>';
|
87 |
+
}
|
88 |
+
|
89 |
+
$sc_str = 'sdm_download id="%d" fancy="%d" button_text="%s" new_window="%d" color="%s"';
|
90 |
+
$sc_str = sprintf( $sc_str, $itemId, $fancyId, $buttonText, $newWindow, $color );
|
91 |
+
|
92 |
+
if ( ! empty( $atts[ 'btnOnly' ] ) ) {
|
93 |
+
$sc_str .= ' button_only="1"';
|
94 |
+
}
|
95 |
+
|
96 |
+
return do_shortcode( '[' . $sc_str . ']' );
|
97 |
+
}
|
98 |
+
|
99 |
+
private function get_items_array() {
|
100 |
+
$q = get_posts( array(
|
101 |
+
'post_type' => 'sdm_downloads',
|
102 |
+
'post_status' => 'publish',
|
103 |
+
'posts_per_page' => -1,
|
104 |
+
'orderby' => 'title',
|
105 |
+
'order' => 'ASC',
|
106 |
+
) );
|
107 |
+
$itemsArr = array( array( 'label' => __( '(Select item)', 'simple-download-monitor' ), 'value' => 0 ) );
|
108 |
+
foreach ( $q as $post ) {
|
109 |
+
$title = html_entity_decode( $post->post_title );
|
110 |
+
$itemsArr[] = array( 'label' => esc_attr( $title ), 'value' => $post->ID );
|
111 |
+
}
|
112 |
+
wp_reset_postdata();
|
113 |
+
return $itemsArr;
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
new SDMBlocks();
|
includes/sdm-download-request-handler.php
CHANGED
@@ -2,152 +2,152 @@
|
|
2 |
|
3 |
//Handles the download request
|
4 |
function handle_sdm_download_via_direct_post() {
|
5 |
-
if (isset($_REQUEST['smd_process_download']) && $_REQUEST['smd_process_download'] == '1') {
|
6 |
global $wpdb;
|
7 |
-
$download_id
|
8 |
-
$download_title
|
9 |
-
$download_link
|
10 |
|
11 |
//Do some validation checks
|
12 |
-
if (
|
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 |
-
|
20 |
|
21 |
//Check download password (if applicable for this download)
|
22 |
-
$post_object
|
23 |
-
$post_pass
|
24 |
-
if (!empty($post_pass)) {//This download item has a password. So validate the password.
|
25 |
-
$pass_val = $_REQUEST['pass_text'];
|
26 |
-
if (empty($pass_val)) {//No password was submitted with the downoad request.
|
27 |
-
$dl_post_url
|
28 |
-
$error_msg
|
29 |
-
$error_msg
|
30 |
-
$error_msg
|
31 |
-
$error_msg
|
32 |
-
$error_msg
|
33 |
-
wp_die($error_msg);
|
34 |
}
|
35 |
-
if ($post_pass != $pass_val) {
|
36 |
//Incorrect password submitted.
|
37 |
-
wp_die(__('Error! Incorrect password. This download requires a valid password.', 'simple-download-monitor'));
|
38 |
} else {
|
39 |
//Password is valid. Go ahead with the download
|
40 |
}
|
41 |
}
|
42 |
//End of password check
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
$date_time
|
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
|
58 |
-
if (isset($main_option['only_logged_in_can_download'])) {
|
59 |
-
if ($main_option['only_logged_in_can_download'] && $visitor_name === false) {
|
60 |
//User not logged in, let's display the error message.
|
61 |
//But first let's see if we have login page URL set so we can display it as well
|
62 |
$loginMsg = '';
|
63 |
-
if (isset($main_option['general_login_page_url']) && !empty($main_option['general_login_page_url'])) {
|
64 |
//We have a login page URL set. Lets use it.
|
65 |
-
$tpl
|
66 |
-
$loginMsg
|
67 |
}
|
68 |
-
wp_die(__('You need to be logged in to download this file.', 'simple-download-monitor') . $loginMsg);
|
69 |
}
|
70 |
}
|
71 |
|
72 |
-
$visitor_name = ($visitor_name === false) ? __('Not Logged In', 'simple-download-monitor') : $visitor_name;
|
73 |
|
74 |
// Get option for global disabling of download logging
|
75 |
-
$no_logs = isset($main_option['admin_no_logs']);
|
76 |
|
77 |
// Get optoin for logging only unique IPs
|
78 |
-
$unique_ips = isset($main_option['admin_log_unique']);
|
79 |
|
80 |
// Get post meta for individual disabling of download logging
|
81 |
-
$get_meta
|
82 |
-
$item_logging_checked
|
83 |
|
84 |
$dl_logging_needed = true;
|
85 |
|
86 |
// Check if download logs have been disabled (globally or per download item)
|
87 |
-
if ($no_logs === true || $item_logging_checked === 'on') {
|
88 |
$dl_logging_needed = false;
|
89 |
}
|
90 |
|
91 |
// Check if we are only logging unique ips
|
92 |
-
if ($unique_ips === true) {
|
93 |
-
$check_ip = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id="' . $download_id . '" AND visitor_ip = "' . $ipaddress . '"');
|
94 |
|
95 |
//This IP is already logged for this download item. No need to log it again.
|
96 |
-
if ($check_ip) {
|
97 |
$dl_logging_needed = false;
|
98 |
}
|
99 |
}
|
100 |
|
101 |
// Check if "Do Not Count Downloads from Bots" setting is enabled
|
102 |
-
if (isset($main_option['admin_dont_log_bots'])) {
|
103 |
//it is. Now let's check if visitor is a bot
|
104 |
-
if (sdm_visitor_is_bot()) {
|
105 |
//visitor is a bot. We neither log nor count this download
|
106 |
$dl_logging_needed = false;
|
107 |
}
|
108 |
}
|
109 |
|
110 |
-
if ($dl_logging_needed) {
|
111 |
// We need to log this download.
|
112 |
-
$table
|
113 |
-
$data
|
114 |
-
'post_id'
|
115 |
-
'post_title'
|
116 |
-
'file_url'
|
117 |
-
'visitor_ip'
|
118 |
-
'date_time'
|
119 |
-
'visitor_country'
|
120 |
-
'visitor_name'
|
121 |
);
|
122 |
|
123 |
-
$data
|
124 |
-
$insert_table
|
125 |
|
126 |
-
if ($insert_table) {
|
127 |
//Download request was logged successfully
|
128 |
} else {
|
129 |
//Failed to log the download request
|
130 |
-
wp_die(__('Error! Failed to log the download request in the database table', 'simple-download-monitor'));
|
131 |
}
|
132 |
}
|
133 |
|
134 |
// Allow plugin extensions to hook into download request.
|
135 |
-
do_action('sdm_process_download_request', $download_id, $download_link);
|
136 |
|
137 |
// Should the item be dispatched?
|
138 |
-
$dispatch = apply_filters('sdm_dispatch_downloads', get_post_meta($download_id, 'sdm_item_dispatch', true));
|
139 |
|
140 |
// Only local file can be dispatched.
|
141 |
-
if ($dispatch && (stripos($download_link, WP_CONTENT_URL) === 0)) {
|
142 |
// Get file path
|
143 |
-
$file = path_join(WP_CONTENT_DIR, ltrim(substr($download_link, strlen(WP_CONTENT_URL)), '/'));
|
144 |
// Try to dispatch file (terminates script execution on success)
|
145 |
-
sdm_dispatch_file($file);
|
146 |
}
|
147 |
|
148 |
// As a fallback or when dispatching is disabled, redirect to the file
|
149 |
// (and terminate script execution).
|
150 |
-
sdm_redirect_to_url($download_link);
|
151 |
}
|
152 |
}
|
153 |
|
@@ -157,28 +157,28 @@ function handle_sdm_download_via_direct_post() {
|
|
157 |
* @param string $filename
|
158 |
* @return void
|
159 |
*/
|
160 |
-
function sdm_dispatch_file($filename) {
|
161 |
|
162 |
-
if (headers_sent()) {
|
163 |
-
trigger_error(__FUNCTION__ . ": Cannot dispatch file $filename, headers already sent.");
|
164 |
return;
|
165 |
}
|
166 |
|
167 |
-
if (!is_readable($filename)) {
|
168 |
-
trigger_error(__FUNCTION__ . ": Cannot dispatch file $filename, file is not readable.");
|
169 |
return;
|
170 |
}
|
171 |
|
172 |
-
header('Content-Description: File Transfer');
|
173 |
-
header('Content-Type: application/octet-stream'); // http://stackoverflow.com/a/20509354
|
174 |
-
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
|
175 |
-
header('Expires: 0');
|
176 |
-
header('Cache-Control: must-revalidate');
|
177 |
-
header('Pragma: public');
|
178 |
-
header('Content-Length: ' . filesize($filename));
|
179 |
|
180 |
ob_end_clean();
|
181 |
-
readfile($filename);
|
182 |
exit;
|
183 |
}
|
184 |
|
@@ -186,27 +186,26 @@ function sdm_dispatch_file($filename) {
|
|
186 |
* If reCAPTCHA Enabled verify answer, send it to google API
|
187 |
* @return boolean
|
188 |
*/
|
189 |
-
function sdm_recaptcha_verify()
|
190 |
-
|
191 |
-
$
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
}
|
210 |
}
|
211 |
return true;
|
212 |
}
|
2 |
|
3 |
//Handles the download request
|
4 |
function handle_sdm_download_via_direct_post() {
|
5 |
+
if ( isset( $_REQUEST[ 'smd_process_download' ] ) && $_REQUEST[ 'smd_process_download' ] == '1' ) {
|
6 |
global $wpdb;
|
7 |
+
$download_id = absint( $_REQUEST[ 'download_id' ] );
|
8 |
+
$download_title = get_the_title( $download_id );
|
9 |
+
$download_link = get_post_meta( $download_id, 'sdm_upload', true );
|
10 |
|
11 |
//Do some validation checks
|
12 |
+
if ( ! $download_id ) {
|
13 |
+
wp_die( __( 'Error! Incorrect download item id.', 'simple-download-monitor' ) );
|
14 |
}
|
15 |
+
if ( empty( $download_link ) ) {
|
16 |
+
wp_die( 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
|
24 |
+
if ( ! empty( $post_pass ) ) {//This download item has a password. So validate the password.
|
25 |
+
$pass_val = $_REQUEST[ 'pass_text' ];
|
26 |
+
if ( empty( $pass_val ) ) {//No password was submitted with the downoad request.
|
27 |
+
$dl_post_url = get_permalink( $download_id );
|
28 |
+
$error_msg = __( 'Error! This download requires a password.', 'simple-download-monitor' );
|
29 |
+
$error_msg .= '<p>';
|
30 |
+
$error_msg .= '<a href="' . $dl_post_url . '">' . __( 'Click here', 'simple-download-monitor' ) . '</a>';
|
31 |
+
$error_msg .= __( ' and enter a valid password for this item', 'simple-download-monitor' );
|
32 |
+
$error_msg .= '</p>';
|
33 |
+
wp_die( $error_msg );
|
34 |
}
|
35 |
+
if ( $post_pass != $pass_val ) {
|
36 |
//Incorrect password submitted.
|
37 |
+
wp_die( __( 'Error! Incorrect password. This download requires a valid password.', 'simple-download-monitor' ) );
|
38 |
} else {
|
39 |
//Password is valid. Go ahead with the download
|
40 |
}
|
41 |
}
|
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
|
58 |
+
if ( isset( $main_option[ 'only_logged_in_can_download' ] ) ) {
|
59 |
+
if ( $main_option[ 'only_logged_in_can_download' ] && $visitor_name === false ) {
|
60 |
//User not logged in, let's display the error message.
|
61 |
//But first let's see if we have login page URL set so we can display it as well
|
62 |
$loginMsg = '';
|
63 |
+
if ( isset( $main_option[ 'general_login_page_url' ] ) && ! empty( $main_option[ 'general_login_page_url' ] ) ) {
|
64 |
//We have a login page URL set. Lets use it.
|
65 |
+
$tpl = __( "__Click here__ to go to login page.", 'simple-download-monitor' );
|
66 |
+
$loginMsg = preg_replace( '/__(.*)__/', ' <a href="' . $main_option[ 'general_login_page_url' ] . '">$1</a> $2', $tpl );
|
67 |
}
|
68 |
+
wp_die( __( 'You need to be logged in to download this file.', 'simple-download-monitor' ) . $loginMsg );
|
69 |
}
|
70 |
}
|
71 |
|
72 |
+
$visitor_name = ($visitor_name === false) ? __( 'Not Logged In', 'simple-download-monitor' ) : $visitor_name;
|
73 |
|
74 |
// Get option for global disabling of download logging
|
75 |
+
$no_logs = isset( $main_option[ 'admin_no_logs' ] );
|
76 |
|
77 |
// Get optoin for logging only unique IPs
|
78 |
+
$unique_ips = isset( $main_option[ 'admin_log_unique' ] );
|
79 |
|
80 |
// Get post meta for individual disabling of download logging
|
81 |
+
$get_meta = get_post_meta( $download_id, 'sdm_item_no_log', true );
|
82 |
+
$item_logging_checked = isset( $get_meta ) && $get_meta === 'on' ? 'on' : 'off';
|
83 |
|
84 |
$dl_logging_needed = true;
|
85 |
|
86 |
// Check if download logs have been disabled (globally or per download item)
|
87 |
+
if ( $no_logs === true || $item_logging_checked === 'on' ) {
|
88 |
$dl_logging_needed = false;
|
89 |
}
|
90 |
|
91 |
// Check if we are only logging unique ips
|
92 |
+
if ( $unique_ips === true ) {
|
93 |
+
$check_ip = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id="' . $download_id . '" AND visitor_ip = "' . $ipaddress . '"' );
|
94 |
|
95 |
//This IP is already logged for this download item. No need to log it again.
|
96 |
+
if ( $check_ip ) {
|
97 |
$dl_logging_needed = false;
|
98 |
}
|
99 |
}
|
100 |
|
101 |
// Check if "Do Not Count Downloads from Bots" setting is enabled
|
102 |
+
if ( isset( $main_option[ 'admin_dont_log_bots' ] ) ) {
|
103 |
//it is. Now let's check if visitor is a bot
|
104 |
+
if ( sdm_visitor_is_bot() ) {
|
105 |
//visitor is a bot. We neither log nor count this download
|
106 |
$dl_logging_needed = false;
|
107 |
}
|
108 |
}
|
109 |
|
110 |
+
if ( $dl_logging_needed ) {
|
111 |
// We need to log this download.
|
112 |
+
$table = $wpdb->prefix . 'sdm_downloads';
|
113 |
+
$data = array(
|
114 |
+
'post_id' => $download_id,
|
115 |
+
'post_title' => $download_title,
|
116 |
+
'file_url' => $download_link,
|
117 |
+
'visitor_ip' => $ipaddress,
|
118 |
+
'date_time' => $date_time,
|
119 |
+
'visitor_country' => $visitor_country,
|
120 |
+
'visitor_name' => $visitor_name
|
121 |
);
|
122 |
|
123 |
+
$data = array_filter( $data ); //Remove any null values.
|
124 |
+
$insert_table = $wpdb->insert( $table, $data );
|
125 |
|
126 |
+
if ( $insert_table ) {
|
127 |
//Download request was logged successfully
|
128 |
} else {
|
129 |
//Failed to log the download request
|
130 |
+
wp_die( __( 'Error! Failed to log the download request in the database table', 'simple-download-monitor' ) );
|
131 |
}
|
132 |
}
|
133 |
|
134 |
// Allow plugin extensions to hook into download request.
|
135 |
+
do_action( 'sdm_process_download_request', $download_id, $download_link );
|
136 |
|
137 |
// Should the item be dispatched?
|
138 |
+
$dispatch = apply_filters( 'sdm_dispatch_downloads', get_post_meta( $download_id, 'sdm_item_dispatch', true ) );
|
139 |
|
140 |
// Only local file can be dispatched.
|
141 |
+
if ( $dispatch && (stripos( $download_link, WP_CONTENT_URL ) === 0) ) {
|
142 |
// Get file path
|
143 |
+
$file = path_join( WP_CONTENT_DIR, ltrim( substr( $download_link, strlen( WP_CONTENT_URL ) ), '/' ) );
|
144 |
// Try to dispatch file (terminates script execution on success)
|
145 |
+
sdm_dispatch_file( $file );
|
146 |
}
|
147 |
|
148 |
// As a fallback or when dispatching is disabled, redirect to the file
|
149 |
// (and terminate script execution).
|
150 |
+
sdm_redirect_to_url( $download_link );
|
151 |
}
|
152 |
}
|
153 |
|
157 |
* @param string $filename
|
158 |
* @return void
|
159 |
*/
|
160 |
+
function sdm_dispatch_file( $filename ) {
|
161 |
|
162 |
+
if ( headers_sent() ) {
|
163 |
+
trigger_error( __FUNCTION__ . ": Cannot dispatch file $filename, headers already sent." );
|
164 |
return;
|
165 |
}
|
166 |
|
167 |
+
if ( ! is_readable( $filename ) ) {
|
168 |
+
trigger_error( __FUNCTION__ . ": Cannot dispatch file $filename, file is not readable." );
|
169 |
return;
|
170 |
}
|
171 |
|
172 |
+
header( 'Content-Description: File Transfer' );
|
173 |
+
header( 'Content-Type: application/octet-stream' ); // http://stackoverflow.com/a/20509354
|
174 |
+
header( 'Content-Disposition: attachment; filename="' . basename( $filename ) . '"' );
|
175 |
+
header( 'Expires: 0' );
|
176 |
+
header( 'Cache-Control: must-revalidate' );
|
177 |
+
header( 'Pragma: public' );
|
178 |
+
header( 'Content-Length: ' . filesize( $filename ) );
|
179 |
|
180 |
ob_end_clean();
|
181 |
+
readfile( $filename );
|
182 |
exit;
|
183 |
}
|
184 |
|
186 |
* If reCAPTCHA Enabled verify answer, send it to google API
|
187 |
* @return boolean
|
188 |
*/
|
189 |
+
function sdm_recaptcha_verify() {
|
190 |
+
$main_advanced_opts = get_option( 'sdm_advanced_options' );
|
191 |
+
$recaptcha_enable = isset( $main_advanced_opts[ 'recaptcha_enable' ] ) ? true : false;
|
192 |
+
if ( $recaptcha_enable ) {
|
193 |
+
if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" && isset( $_POST[ "g-recaptcha-response" ] ) ) {
|
194 |
+
$recaptcha_secret_key = $main_advanced_opts[ 'recaptcha_secret_key' ];
|
195 |
+
$recaptcha_response = filter_input( INPUT_POST, "g-recaptcha-response", FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
196 |
+
$response = wp_remote_get( "https://www.google.com/recaptcha/api/siteverify?secret={$recaptcha_secret_key}&response={$recaptcha_response}" );
|
197 |
+
$response = json_decode( $response[ "body" ], 1 );
|
198 |
+
|
199 |
+
if ( $response[ "success" ] ) {
|
200 |
+
return true;
|
201 |
+
} else {
|
202 |
+
wp_die( "<p><strong>" . __( "ERROR:", 'simple-download-monitor' ) . "</strong> " . __( "Google reCAPTCHA verification failed.", 'simple-download-monitor' ) . "</p>\n\n<p><a href=" . wp_get_referer() . ">« " . __( "Back", 'simple-download-monitor' ) . "</a>", "", 403 );
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
} else {
|
206 |
+
wp_die( "<p><strong>" . __( "ERROR:", 'simple-download-monitor' ) . "</strong> " . __( "Google reCAPTCHA verification failed.", 'simple-download-monitor' ) . " " . __( "Do you have JavaScript enabled?", 'simple-download-monitor' ) . "</p>\n\n<p><a href=" . wp_get_referer() . ">« " . __( "Back", 'simple-download-monitor' ) . "</a>", "", 403 );
|
207 |
+
return false;
|
208 |
+
}
|
|
|
209 |
}
|
210 |
return true;
|
211 |
}
|
includes/sdm-latest-downloads.php
CHANGED
@@ -56,6 +56,9 @@ function sdm_show_latest_downloads($args){
|
|
56 |
} else if ($fancy == '2') {
|
57 |
include_once(WP_SIMPLE_DL_MONITOR_PATH.'includes/templates/fancy2/sdm-fancy-2.php');
|
58 |
$output .= sdm_generate_fancy2_latest_downloads_display_output($get_posts, $args);
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
// Return results
|
56 |
} else if ($fancy == '2') {
|
57 |
include_once(WP_SIMPLE_DL_MONITOR_PATH.'includes/templates/fancy2/sdm-fancy-2.php');
|
58 |
$output .= sdm_generate_fancy2_latest_downloads_display_output($get_posts, $args);
|
59 |
+
} else if ($fancy == '3') {
|
60 |
+
include_once(WP_SIMPLE_DL_MONITOR_PATH.'includes/templates/fancy3/sdm-fancy-3.php');
|
61 |
+
$output .= sdm_generate_fancy3_latest_downloads_display_output($get_posts, $args);
|
62 |
}
|
63 |
|
64 |
// Return results
|
includes/sdm-popular-downloads.php
CHANGED
@@ -55,6 +55,9 @@ function sdm_show_popular_downloads( $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
|
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 |
+
} else if ( $fancy == '3' ) {
|
59 |
+
include_once(WP_SIMPLE_DL_MONITOR_PATH . 'includes/templates/fancy3/sdm-fancy-3.php');
|
60 |
+
$output .= sdm_generate_fancy3_popular_downloads_display_output( $get_posts, $args );
|
61 |
}
|
62 |
|
63 |
// Return results
|
includes/sdm-search-shortcode-handler.php
CHANGED
@@ -91,6 +91,9 @@ function sdm_generate_search_result_using_template($posts_collection, $args = ar
|
|
91 |
} else if ($args['fancy'] == '2') {
|
92 |
include_once(WP_SIMPLE_DL_MONITOR_PATH . 'includes/templates/fancy2/sdm-fancy-2.php');
|
93 |
$s_results .= sdm_generate_fancy2_category_display_output($posts_collection, $args);
|
|
|
|
|
|
|
94 |
}
|
95 |
} else {
|
96 |
//No fancy template is used. Show the search result using the standard search display
|
91 |
} else if ($args['fancy'] == '2') {
|
92 |
include_once(WP_SIMPLE_DL_MONITOR_PATH . 'includes/templates/fancy2/sdm-fancy-2.php');
|
93 |
$s_results .= sdm_generate_fancy2_category_display_output($posts_collection, $args);
|
94 |
+
} else if ($args['fancy'] == '3') {
|
95 |
+
include_once(WP_SIMPLE_DL_MONITOR_PATH . 'includes/templates/fancy3/sdm-fancy-3.php');
|
96 |
+
$s_results .= sdm_generate_fancy3_category_display_output($posts_collection, $args);
|
97 |
}
|
98 |
} else {
|
99 |
//No fancy template is used. Show the search result using the standard search display
|
includes/sdm-utility-functions.php
CHANGED
@@ -5,32 +5,32 @@
|
|
5 |
* @return array Array of colors: color key => color name.
|
6 |
*/
|
7 |
function sdm_get_download_button_colors() {
|
8 |
-
return apply_filters('sdm_download_button_color_options', array(
|
9 |
-
'green'
|
10 |
-
'blue'
|
11 |
-
'purple'
|
12 |
-
'teal'
|
13 |
-
'darkblue'
|
14 |
-
'black'
|
15 |
-
'grey'
|
16 |
-
'pink'
|
17 |
-
'orange'
|
18 |
-
'white'
|
19 |
-
|
20 |
}
|
21 |
|
22 |
-
function sdm_get_download_count_for_post($id) {
|
23 |
// Get number of downloads by counting db columns matching postID
|
24 |
global $wpdb;
|
25 |
-
$table
|
26 |
-
$wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $table . ' WHERE post_id=%s', $id));
|
27 |
// Count database rows
|
28 |
-
$db_count
|
29 |
|
30 |
// Check post meta to see if we need to offset the count before displaying to viewers
|
31 |
-
$get_offset = get_post_meta($id, 'sdm_count_offset', true);
|
32 |
|
33 |
-
if ($get_offset && $get_offset != '') {
|
34 |
|
35 |
$db_count = $db_count + $get_offset;
|
36 |
}
|
@@ -38,37 +38,44 @@ function sdm_get_download_count_for_post($id) {
|
|
38 |
return $db_count;
|
39 |
}
|
40 |
|
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 |
}
|
51 |
|
52 |
-
$uuid = uniqid('sdm-pass-');
|
53 |
|
54 |
-
$data =
|
55 |
-
|
56 |
-
|
57 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
$data .= '<form action="' . $action_url . '" method="post" id="' . $uuid . '" class="sdm-download-form"'.$window_target.'>';
|
60 |
-
$data .= '<input type="password" name="pass_text" class="sdm_pass_text" value="" /> ';
|
61 |
-
|
62 |
$data .= sdm_get_download_with_recaptcha();
|
63 |
-
|
64 |
//Check if Terms & Condition enabled
|
65 |
$data .= sdm_get_checkbox_for_termsncond();
|
66 |
-
|
67 |
-
$data
|
68 |
-
$data
|
69 |
-
$data
|
70 |
-
$data
|
71 |
-
$data
|
72 |
return $data;
|
73 |
}
|
74 |
|
@@ -79,14 +86,14 @@ function sdm_get_password_entry_form($id, $args = array(), $class = '') {
|
|
79 |
* @param bool $ignore_private_and_reserved Ignore IPs that fall into private or reserved IP ranges.
|
80 |
* @return mixed IP address as a string or null, if remote IP address cannot be determined (or is ignored).
|
81 |
*/
|
82 |
-
function sdm_get_ip_address($ignore_private_and_reserved = false) {
|
83 |
$flags = $ignore_private_and_reserved ? (FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) : 0;
|
84 |
-
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
|
85 |
-
if (array_key_exists($key, $_SERVER) === true) {
|
86 |
-
foreach (explode(',', $_SERVER[$key]) as $ip) {
|
87 |
-
$ip = trim($ip); // just to be safe
|
88 |
|
89 |
-
if (filter_var($ip, FILTER_VALIDATE_IP, $flags) !== false) {
|
90 |
return $ip;
|
91 |
}
|
92 |
}
|
@@ -101,38 +108,38 @@ function sdm_get_ip_address($ignore_private_and_reserved = false) {
|
|
101 |
* @param string $purpose
|
102 |
* @return mixed
|
103 |
*/
|
104 |
-
function sdm_ip_info($ip, $purpose = "location") {
|
105 |
|
106 |
$continents = array(
|
107 |
-
"AF"
|
108 |
-
"AN"
|
109 |
-
"AS"
|
110 |
-
"EU"
|
111 |
-
"OC"
|
112 |
-
"NA"
|
113 |
-
"SA"
|
114 |
);
|
115 |
|
116 |
-
$ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
|
117 |
|
118 |
-
if (@strlen(trim($ipdat->geoplugin_countryCode)) === 2) {
|
119 |
-
switch ($purpose) {
|
120 |
case "location":
|
121 |
return array(
|
122 |
-
"city"
|
123 |
-
"state"
|
124 |
-
"country"
|
125 |
-
"country_code"
|
126 |
-
"continent"
|
127 |
"continent_code" => @$ipdat->geoplugin_continentCode
|
128 |
);
|
129 |
case "address":
|
130 |
-
$address
|
131 |
-
if (@strlen($ipdat->geoplugin_regionName) >= 1)
|
132 |
-
$address[]
|
133 |
-
if (@strlen($ipdat->geoplugin_city) >= 1)
|
134 |
-
$address[]
|
135 |
-
return implode(", ", array_reverse($address));
|
136 |
case "city":
|
137 |
return @$ipdat->geoplugin_city;
|
138 |
case "state":
|
@@ -154,29 +161,29 @@ function sdm_ip_info($ip, $purpose = "location") {
|
|
154 |
* Checks if the string exists in the array key value of the provided array. If it doesn't exist, it returns the first key element from the valid values.
|
155 |
*/
|
156 |
|
157 |
-
function sdm_sanitize_value_by_array($to_check, $valid_values) {
|
158 |
-
$keys
|
159 |
-
$keys
|
160 |
-
if (in_array($to_check, $keys)) {
|
161 |
return $to_check;
|
162 |
}
|
163 |
-
return reset($keys); //Return the first element from the valid values
|
164 |
}
|
165 |
|
166 |
function sdm_get_logged_in_user() {
|
167 |
$visitor_name = false;
|
168 |
|
169 |
-
if (is_user_logged_in()) { // Get WP user name (if logged in)
|
170 |
-
$current_user
|
171 |
-
$visitor_name
|
172 |
}
|
173 |
|
174 |
//WP eMember plugin integration
|
175 |
-
if (class_exists('Emember_Auth')) {
|
176 |
//WP eMember plugin is installed.
|
177 |
-
$emember_auth
|
178 |
-
$username
|
179 |
-
if (!empty($username)) {//Member is logged in.
|
180 |
$visitor_name = $username; //Override the visitor name to emember username.
|
181 |
}
|
182 |
}
|
@@ -186,133 +193,133 @@ function sdm_get_logged_in_user() {
|
|
186 |
|
187 |
// Checks if current visitor is a bot
|
188 |
function sdm_visitor_is_bot() {
|
189 |
-
$bots = array('archiver', 'baiduspider', 'bingbot', 'binlar', 'casper', 'checkprivacy', 'clshttp', 'cmsworldmap', 'comodo', 'curl', 'diavol', 'dotbot', 'DuckDuckBot', 'Exabot', 'email', 'extract', 'facebookexternalhit', 'feedfinder', 'flicky', 'googlebot','grab', 'harvest', 'httrack', 'ia_archiver', 'jakarta', 'kmccrew', 'libwww', 'loader', 'MJ12bot', 'miner', 'msnbot', 'nikto', 'nutch', 'planetwork', 'purebot', 'pycurl', 'python', 'scan', 'skygrid', 'slurp', 'sucker', 'turnit', 'vikspider', 'wget', 'winhttp', 'yandex', 'yandexbot', 'yahoo', 'youda', 'zmeu', 'zune');
|
190 |
|
191 |
$isBot = false;
|
192 |
|
193 |
-
$user_agent = wp_kses_data($_SERVER['HTTP_USER_AGENT']);
|
194 |
|
195 |
-
foreach ($bots as $bot) {
|
196 |
-
if (stripos($user_agent, $bot) !== false) {
|
197 |
$isBot = true;
|
198 |
}
|
199 |
}
|
200 |
|
201 |
-
if (empty($user_agent) || $user_agent == ' ') {
|
202 |
$isBot = true;
|
203 |
}
|
204 |
|
205 |
//This filter can be used to override what you consider bot via your own custom function. You can read the user-agent value from the server var.
|
206 |
-
$isBot = apply_filters('sdm_visitor_is_bot', $isBot);
|
207 |
-
|
208 |
return $isBot;
|
209 |
}
|
210 |
|
211 |
-
function sdm_get_download_form_with_recaptcha($id, $args = array(), $class = '') {
|
212 |
$action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
|
213 |
|
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 |
}
|
221 |
-
|
222 |
-
$main_advanced_opts = get_option('sdm_advanced_options');
|
223 |
-
|
224 |
-
$new_window
|
225 |
-
$window_target=empty($new_window) ? '' : ' target="_blank"';
|
226 |
-
|
227 |
-
$data = '<form action="' . $action_url . '" method="post" class="sdm-g-recaptcha-form sdm-download-form"'
|
228 |
-
|
229 |
-
$data
|
230 |
-
$data
|
231 |
-
|
232 |
//Check if Terms & Condition enabled
|
233 |
$data .= sdm_get_checkbox_for_termsncond();
|
234 |
-
|
235 |
-
$data
|
236 |
-
$data
|
237 |
-
$data
|
238 |
-
$data
|
239 |
return $data;
|
240 |
}
|
241 |
|
242 |
function sdm_get_download_with_recaptcha() {
|
243 |
-
$main_advanced_opts
|
244 |
-
$recaptcha_enable
|
245 |
-
if ($recaptcha_enable) {
|
246 |
-
|
247 |
}
|
248 |
return '';
|
249 |
}
|
250 |
|
251 |
function sdm_get_checkbox_for_termsncond() {
|
252 |
-
$main_advanced_opts
|
253 |
-
$termscond_enable
|
254 |
-
if ($termscond_enable) {
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
}
|
260 |
return '';
|
261 |
}
|
262 |
|
263 |
-
|
264 |
-
function sdm_get_download_form_with_termsncond($id, $args = array(), $class = '') {
|
265 |
$action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
|
266 |
|
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
|
276 |
-
$termscond_enable
|
277 |
-
|
278 |
-
$new_window
|
279 |
-
$window_target=empty($new_window) ? '' : ' target="_blank"';
|
280 |
-
|
281 |
-
$data
|
282 |
-
$data
|
283 |
-
$data
|
284 |
-
$data
|
285 |
-
$data
|
286 |
-
$data
|
287 |
-
$data
|
288 |
return $data;
|
289 |
}
|
290 |
|
291 |
-
function sdm_get_default_download_button_text($download_id){
|
292 |
-
$default_text
|
293 |
-
$meta_text
|
294 |
|
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 |
-
|
303 |
-
|
304 |
-
|
|
|
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 |
-
}
|
5 |
* @return array Array of colors: color key => color name.
|
6 |
*/
|
7 |
function sdm_get_download_button_colors() {
|
8 |
+
return apply_filters( 'sdm_download_button_color_options', array(
|
9 |
+
'green' => __( 'Green', 'simple-download-monitor' ),
|
10 |
+
'blue' => __( 'Blue', 'simple-download-monitor' ),
|
11 |
+
'purple' => __( 'Purple', 'simple-download-monitor' ),
|
12 |
+
'teal' => __( 'Teal', 'simple-download-monitor' ),
|
13 |
+
'darkblue' => __( 'Dark Blue', 'simple-download-monitor' ),
|
14 |
+
'black' => __( 'Black', 'simple-download-monitor' ),
|
15 |
+
'grey' => __( 'Grey', 'simple-download-monitor' ),
|
16 |
+
'pink' => __( 'Pink', 'simple-download-monitor' ),
|
17 |
+
'orange' => __( 'Orange', 'simple-download-monitor' ),
|
18 |
+
'white' => __( 'White', 'simple-download-monitor' )
|
19 |
+
) );
|
20 |
}
|
21 |
|
22 |
+
function sdm_get_download_count_for_post( $id ) {
|
23 |
// Get number of downloads by counting db columns matching postID
|
24 |
global $wpdb;
|
25 |
+
$table = $wpdb->prefix . 'sdm_downloads';
|
26 |
+
$wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table . ' WHERE post_id=%s', $id ) );
|
27 |
// Count database rows
|
28 |
+
$db_count = $wpdb->num_rows;
|
29 |
|
30 |
// Check post meta to see if we need to offset the count before displaying to viewers
|
31 |
+
$get_offset = get_post_meta( $id, 'sdm_count_offset', true );
|
32 |
|
33 |
+
if ( $get_offset && $get_offset != '' ) {
|
34 |
|
35 |
$db_count = $db_count + $get_offset;
|
36 |
}
|
38 |
return $db_count;
|
39 |
}
|
40 |
|
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 |
}
|
51 |
|
52 |
+
$uuid = uniqid( 'sdm-pass-' );
|
53 |
|
54 |
+
$data = '';
|
55 |
+
|
56 |
+
//Enter password label
|
57 |
+
$enter_password_label = __( 'Enter Password to Download:', 'simple-download-monitor' );
|
58 |
+
$enter_password_label = apply_filters( 'sdm_enter_password_to_download_label', $enter_password_label );
|
59 |
+
$data .= '<span class="sdm_enter_password_label_text">' . $enter_password_label . '</span>';
|
60 |
+
|
61 |
+
//Check if new window is enabled
|
62 |
+
$new_window = get_post_meta( $id, 'sdm_item_new_window', true );
|
63 |
+
$window_target = empty( $new_window ) ? '' : ' target="_blank"';
|
64 |
+
|
65 |
+
//Form code
|
66 |
+
$data .= '<form action="' . $action_url . '" method="post" id="' . $uuid . '" class="sdm-download-form"' . $window_target . '>';
|
67 |
+
$data .= '<input type="password" name="pass_text" class="sdm_pass_text" value="" /> ';
|
68 |
|
|
|
|
|
|
|
69 |
$data .= sdm_get_download_with_recaptcha();
|
70 |
+
|
71 |
//Check if Terms & Condition enabled
|
72 |
$data .= sdm_get_checkbox_for_termsncond();
|
73 |
+
|
74 |
+
$data .= '<span class="sdm-download-button">';
|
75 |
+
$data .= '<a href="#" name="sdm_dl_pass_submit" class="pass_sumbit sdm_pass_protected_download sdm_download_with_condition ' . $class . '">' . $button_text_string . '</a>';
|
76 |
+
$data .= '</span>';
|
77 |
+
$data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
|
78 |
+
$data .= '</form>';
|
79 |
return $data;
|
80 |
}
|
81 |
|
86 |
* @param bool $ignore_private_and_reserved Ignore IPs that fall into private or reserved IP ranges.
|
87 |
* @return mixed IP address as a string or null, if remote IP address cannot be determined (or is ignored).
|
88 |
*/
|
89 |
+
function sdm_get_ip_address( $ignore_private_and_reserved = false ) {
|
90 |
$flags = $ignore_private_and_reserved ? (FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) : 0;
|
91 |
+
foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
|
92 |
+
if ( array_key_exists( $key, $_SERVER ) === true ) {
|
93 |
+
foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
|
94 |
+
$ip = trim( $ip ); // just to be safe
|
95 |
|
96 |
+
if ( filter_var( $ip, FILTER_VALIDATE_IP, $flags ) !== false ) {
|
97 |
return $ip;
|
98 |
}
|
99 |
}
|
108 |
* @param string $purpose
|
109 |
* @return mixed
|
110 |
*/
|
111 |
+
function sdm_ip_info( $ip, $purpose = "location" ) {
|
112 |
|
113 |
$continents = array(
|
114 |
+
"AF" => "Africa",
|
115 |
+
"AN" => "Antarctica",
|
116 |
+
"AS" => "Asia",
|
117 |
+
"EU" => "Europe",
|
118 |
+
"OC" => "Australia (Oceania)",
|
119 |
+
"NA" => "North America",
|
120 |
+
"SA" => "South America"
|
121 |
);
|
122 |
|
123 |
+
$ipdat = @json_decode( file_get_contents( "http://www.geoplugin.net/json.gp?ip=" . $ip ) );
|
124 |
|
125 |
+
if ( @strlen( trim( $ipdat->geoplugin_countryCode ) ) === 2 ) {
|
126 |
+
switch ( $purpose ) {
|
127 |
case "location":
|
128 |
return array(
|
129 |
+
"city" => @$ipdat->geoplugin_city,
|
130 |
+
"state" => @$ipdat->geoplugin_regionName,
|
131 |
+
"country" => @$ipdat->geoplugin_countryName,
|
132 |
+
"country_code" => @$ipdat->geoplugin_countryCode,
|
133 |
+
"continent" => @$continents[ strtoupper( $ipdat->geoplugin_continentCode ) ],
|
134 |
"continent_code" => @$ipdat->geoplugin_continentCode
|
135 |
);
|
136 |
case "address":
|
137 |
+
$address = array( $ipdat->geoplugin_countryName );
|
138 |
+
if ( @strlen( $ipdat->geoplugin_regionName ) >= 1 )
|
139 |
+
$address[] = $ipdat->geoplugin_regionName;
|
140 |
+
if ( @strlen( $ipdat->geoplugin_city ) >= 1 )
|
141 |
+
$address[] = $ipdat->geoplugin_city;
|
142 |
+
return implode( ", ", array_reverse( $address ) );
|
143 |
case "city":
|
144 |
return @$ipdat->geoplugin_city;
|
145 |
case "state":
|
161 |
* Checks if the string exists in the array key value of the provided array. If it doesn't exist, it returns the first key element from the valid values.
|
162 |
*/
|
163 |
|
164 |
+
function sdm_sanitize_value_by_array( $to_check, $valid_values ) {
|
165 |
+
$keys = array_keys( $valid_values );
|
166 |
+
$keys = array_map( 'strtolower', $keys );
|
167 |
+
if ( in_array( $to_check, $keys ) ) {
|
168 |
return $to_check;
|
169 |
}
|
170 |
+
return reset( $keys ); //Return the first element from the valid values
|
171 |
}
|
172 |
|
173 |
function sdm_get_logged_in_user() {
|
174 |
$visitor_name = false;
|
175 |
|
176 |
+
if ( is_user_logged_in() ) { // Get WP user name (if logged in)
|
177 |
+
$current_user = wp_get_current_user();
|
178 |
+
$visitor_name = $current_user->user_login;
|
179 |
}
|
180 |
|
181 |
//WP eMember plugin integration
|
182 |
+
if ( class_exists( 'Emember_Auth' ) ) {
|
183 |
//WP eMember plugin is installed.
|
184 |
+
$emember_auth = Emember_Auth::getInstance();
|
185 |
+
$username = $emember_auth->getUserInfo( 'user_name' );
|
186 |
+
if ( ! empty( $username ) ) {//Member is logged in.
|
187 |
$visitor_name = $username; //Override the visitor name to emember username.
|
188 |
}
|
189 |
}
|
193 |
|
194 |
// Checks if current visitor is a bot
|
195 |
function sdm_visitor_is_bot() {
|
196 |
+
$bots = array( 'archiver', 'baiduspider', 'bingbot', 'binlar', 'casper', 'checkprivacy', 'clshttp', 'cmsworldmap', 'comodo', 'curl', 'diavol', 'dotbot', 'DuckDuckBot', 'Exabot', 'email', 'extract', 'facebookexternalhit', 'feedfinder', 'flicky', 'googlebot', 'grab', 'harvest', 'httrack', 'ia_archiver', 'jakarta', 'kmccrew', 'libwww', 'loader', 'MJ12bot', 'miner', 'msnbot', 'nikto', 'nutch', 'planetwork', 'purebot', 'pycurl', 'python', 'scan', 'skygrid', 'slurp', 'sucker', 'turnit', 'vikspider', 'wget', 'winhttp', 'yandex', 'yandexbot', 'yahoo', 'youda', 'zmeu', 'zune' );
|
197 |
|
198 |
$isBot = false;
|
199 |
|
200 |
+
$user_agent = wp_kses_data( $_SERVER[ 'HTTP_USER_AGENT' ] );
|
201 |
|
202 |
+
foreach ( $bots as $bot ) {
|
203 |
+
if ( stripos( $user_agent, $bot ) !== false ) {
|
204 |
$isBot = true;
|
205 |
}
|
206 |
}
|
207 |
|
208 |
+
if ( empty( $user_agent ) || $user_agent == ' ' ) {
|
209 |
$isBot = true;
|
210 |
}
|
211 |
|
212 |
//This filter can be used to override what you consider bot via your own custom function. You can read the user-agent value from the server var.
|
213 |
+
$isBot = apply_filters( 'sdm_visitor_is_bot', $isBot );
|
214 |
+
|
215 |
return $isBot;
|
216 |
}
|
217 |
|
218 |
+
function sdm_get_download_form_with_recaptcha( $id, $args = array(), $class = '' ) {
|
219 |
$action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
|
220 |
|
221 |
//Get the download button text
|
222 |
+
$button_text = isset( $args[ 'button_text' ] ) ? $args[ 'button_text' ] : '';
|
223 |
+
if ( empty( $button_text ) ) {//Use the default text for the button
|
224 |
+
$button_text_string = sdm_get_default_download_button_text( $id );
|
225 |
} else {//Use the custom text
|
226 |
$button_text_string = $button_text;
|
227 |
}
|
228 |
+
|
229 |
+
$main_advanced_opts = get_option( 'sdm_advanced_options' );
|
230 |
+
|
231 |
+
$new_window = get_post_meta( $id, 'sdm_item_new_window', true );
|
232 |
+
$window_target = empty( $new_window ) ? '' : ' target="_blank"';
|
233 |
+
|
234 |
+
$data = '<form action="' . $action_url . '" method="post" class="sdm-g-recaptcha-form sdm-download-form"' . $window_target . '>';
|
235 |
+
|
236 |
+
$data .= '<div class="sdm-recaptcha-button">';
|
237 |
+
$data .= '<div class="g-recaptcha sdm-g-recaptcha"></div>';
|
238 |
+
|
239 |
//Check if Terms & Condition enabled
|
240 |
$data .= sdm_get_checkbox_for_termsncond();
|
241 |
+
|
242 |
+
$data .= '<a href="#" class="' . $class . ' sdm_download_with_condition">' . $button_text_string . '</a>';
|
243 |
+
$data .= '</div>';
|
244 |
+
$data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
|
245 |
+
$data .= '</form>';
|
246 |
return $data;
|
247 |
}
|
248 |
|
249 |
function sdm_get_download_with_recaptcha() {
|
250 |
+
$main_advanced_opts = get_option( 'sdm_advanced_options' );
|
251 |
+
$recaptcha_enable = isset( $main_advanced_opts[ 'recaptcha_enable' ] ) ? true : false;
|
252 |
+
if ( $recaptcha_enable ) {
|
253 |
+
return '<div class="g-recaptcha sdm-g-recaptcha"></div>';
|
254 |
}
|
255 |
return '';
|
256 |
}
|
257 |
|
258 |
function sdm_get_checkbox_for_termsncond() {
|
259 |
+
$main_advanced_opts = get_option( 'sdm_advanced_options' );
|
260 |
+
$termscond_enable = isset( $main_advanced_opts[ 'termscond_enable' ] ) ? true : false;
|
261 |
+
if ( $termscond_enable ) {
|
262 |
+
$data = '<div class="sdm-termscond-checkbox">';
|
263 |
+
$data .= '<input type="checkbox" class="agree_termscond" value="1"/> ' . __( 'I agree to the ', 'simple-download-monitor' ) . '<a href="' . $main_advanced_opts[ 'termscond_url' ] . '" target="_blank">' . __( 'terms and conditions', 'simple-download-monitor' ) . '</a>';
|
264 |
+
$data .= '</div>';
|
265 |
+
return $data;
|
266 |
}
|
267 |
return '';
|
268 |
}
|
269 |
|
270 |
+
function sdm_get_download_form_with_termsncond( $id, $args = array(), $class = '' ) {
|
|
|
271 |
$action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
|
272 |
|
273 |
//Get the download button text
|
274 |
+
$button_text = isset( $args[ 'button_text' ] ) ? $args[ 'button_text' ] : '';
|
275 |
+
if ( empty( $button_text ) ) {//Use the default text for the button
|
276 |
+
$button_text_string = sdm_get_default_download_button_text( $id );
|
277 |
} else {//Use the custom text
|
278 |
$button_text_string = $button_text;
|
279 |
}
|
280 |
|
281 |
+
$main_advanced_opts = get_option( 'sdm_advanced_options' );
|
282 |
+
$termscond_enable = isset( $main_advanced_opts[ 'termscond_enable' ] ) ? true : false;
|
283 |
+
|
284 |
+
$new_window = get_post_meta( $id, 'sdm_item_new_window', true );
|
285 |
+
$window_target = empty( $new_window ) ? '' : ' target="_blank"';
|
286 |
+
|
287 |
+
$data = '<form action="' . $action_url . '" method="post" class="sdm-download-form"' . $window_target . '>';
|
288 |
+
$data .= sdm_get_checkbox_for_termsncond();
|
289 |
+
$data .= '<div class="sdm-termscond-button">';
|
290 |
+
$data .= '<a href="#" class="' . $class . ' sdm_download_with_condition">' . $button_text_string . '</a>';
|
291 |
+
$data .= '</div>';
|
292 |
+
$data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
|
293 |
+
$data .= '</form>';
|
294 |
return $data;
|
295 |
}
|
296 |
|
297 |
+
function sdm_get_default_download_button_text( $download_id ) {
|
298 |
+
$default_text = __( 'Download Now!', 'simple-download-monitor' );
|
299 |
+
$meta_text = get_post_meta( $download_id, 'sdm_download_button_text', true );
|
300 |
|
301 |
+
$button_text = ! empty( $meta_text ) ? $meta_text : $default_text;
|
302 |
return $button_text;
|
303 |
}
|
304 |
|
305 |
/*
|
306 |
* Use this function to redirect to a URL
|
307 |
*/
|
308 |
+
|
309 |
+
function sdm_redirect_to_url( $url, $delay = '0', $exit = '1' ) {
|
310 |
+
$url = apply_filters( 'sdm_before_redirect_to_url', $url );
|
311 |
+
if ( empty( $url ) ) {
|
312 |
echo '<strong>';
|
313 |
+
_e( 'Error! The URL value is empty. Please specify a correct URL value to redirect to!', 'simple-download-monitor' );
|
314 |
echo '</strong>';
|
315 |
exit;
|
316 |
}
|
317 |
+
if ( ! headers_sent() ) {
|
318 |
+
header( 'Location: ' . $url );
|
319 |
} else {
|
320 |
echo '<meta http-equiv="refresh" content="' . $delay . ';url=' . $url . '" />';
|
321 |
}
|
322 |
+
if ( $exit == '1' ) {//exit
|
323 |
exit;
|
324 |
}
|
325 |
+
}
|
includes/templates/fancy0/sdm-fancy-0.php
CHANGED
@@ -83,6 +83,8 @@ function sdm_generate_fancy0_display_output( $args ) {
|
|
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' ) {
|
83 |
$color_opt = $main_opts[ 'download_button_color' ];
|
84 |
$def_color = isset( $color_opt ) ? str_replace( ' ', '', strtolower( $color_opt ) ) : __( 'green', 'simple-download-monitor' );
|
85 |
|
86 |
+
$def_color = empty( $args[ 'color' ] ) ? $def_color : $args[ 'color' ];
|
87 |
+
|
88 |
//See if new window parameter is seet
|
89 |
$window_target = '';
|
90 |
if ( isset( $args[ 'new_window' ] ) && $args[ 'new_window' ] == '1' ) {
|
includes/templates/fancy3/sdm-fancy-3.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function sdm_generate_fancy3_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_fancy3_display_output( $opts );
|
11 |
+
}
|
12 |
+
$output .= '<div class="sdm_clear_float"></div>';
|
13 |
+
return $output;
|
14 |
+
}
|
15 |
+
|
16 |
+
function sdm_generate_fancy3_latest_downloads_display_output( $get_posts, $args ) {
|
17 |
+
|
18 |
+
$output = "";
|
19 |
+
|
20 |
+
foreach ( $get_posts as $item ) {
|
21 |
+
$output .= sdm_generate_fancy3_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_fancy3_category_display_output( $get_posts, $args ) {
|
30 |
+
|
31 |
+
$output = "";
|
32 |
+
//TODO - when the CSS file is moved to the fancy3 folder, change it here
|
33 |
+
//$output .= '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL . '/includes/templates/fancy3/sdm-fancy-3-styles.css?ver=' . WP_SIMPLE_DL_MONITOR_VERSION . '" />';
|
34 |
+
|
35 |
+
foreach ( $get_posts as $item ) {
|
36 |
+
$output .= sdm_generate_fancy3_display_output(
|
37 |
+
array_merge( $args, array( 'id' => $item->ID ) )
|
38 |
+
);
|
39 |
+
}
|
40 |
+
$output .= '<div class="sdm_clear_float"></div>';
|
41 |
+
return $output;
|
42 |
+
}
|
43 |
+
|
44 |
+
/*
|
45 |
+
* Generates the output of a single item using fancy2 sytle
|
46 |
+
* $args array can have the following parameters
|
47 |
+
* id, fancy, button_text, new_window
|
48 |
+
*/
|
49 |
+
|
50 |
+
function sdm_generate_fancy3_display_output( $args ) {
|
51 |
+
|
52 |
+
$shortcode_atts = sanitize_sdm_create_download_shortcode_atts(
|
53 |
+
shortcode_atts( array(
|
54 |
+
'id' => '',
|
55 |
+
'button_text' => __( 'View Details', 'simple-download-monitor' ),
|
56 |
+
'new_window' => '',
|
57 |
+
'color' => '',
|
58 |
+
'css_class' => '',
|
59 |
+
'show_size' => '',
|
60 |
+
'show_version' => '',
|
61 |
+
), $args )
|
62 |
+
);
|
63 |
+
|
64 |
+
// Make shortcode attributes available in function local scope.
|
65 |
+
extract( $shortcode_atts );
|
66 |
+
|
67 |
+
// Check the download ID
|
68 |
+
if ( empty( $id ) ) {
|
69 |
+
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>';
|
70 |
+
}
|
71 |
+
|
72 |
+
// Read plugin settings
|
73 |
+
//$main_opts = get_option( 'sdm_downloads_options' );
|
74 |
+
|
75 |
+
// See if new window parameter is set
|
76 |
+
if ( empty( $new_window ) ) {
|
77 |
+
$new_window = get_post_meta( $id, 'sdm_item_new_window', true );
|
78 |
+
}
|
79 |
+
$window_target = empty( $new_window ) ? '_self' : '_blank';
|
80 |
+
|
81 |
+
// Get CPT title
|
82 |
+
$item_title = get_the_title( $id );
|
83 |
+
|
84 |
+
// Get download details page URL
|
85 |
+
$dl_post_url = get_permalink($id);
|
86 |
+
$link_text = __( 'View Details', 'simple-download-monitor' );
|
87 |
+
$download_details_link_code = '<a href="' . $dl_post_url . '" class="sdm_fancy3_view_details" title="' . $item_title . '" target="' . $window_target . '">' . $link_text . '</a>';
|
88 |
+
|
89 |
+
$output = '';
|
90 |
+
|
91 |
+
$output .= '<div class="sdm_fancy3_download_item ' . $css_class . '">';
|
92 |
+
$output .= '<div class="sdm_fancy3_download_item_left">';
|
93 |
+
$output .= '<span class="sdm_fancy3_download_title">' . $item_title . '</span>';
|
94 |
+
$output .= '</div>'; //End of .sdm_fancy3_download_title
|
95 |
+
|
96 |
+
$output .= '<div class="sdm_fancy3_download_right">';
|
97 |
+
|
98 |
+
//apply filter on view details button HTML code
|
99 |
+
$download_details_link_code = apply_filters( 'sdm_fancy3_view_details_link_code_html', $download_details_link_code );
|
100 |
+
|
101 |
+
$output .= '<span class="sdm_fancy3_view_details_link">' . $download_details_link_code . '</span>';
|
102 |
+
|
103 |
+
$output .= '</div>'; //end .sdm_fancy3_download_right
|
104 |
+
$output .= '<div class="sdm_clear_float"></div>';
|
105 |
+
$output .= '</div>'; //end .sdm_fancy3_download_item
|
106 |
+
|
107 |
+
return $output;
|
108 |
+
}
|
js/sdm_blocks.js
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var el = wp.element.createElement,
|
2 |
+
registerBlockType = wp.blocks.registerBlockType,
|
3 |
+
ServerSideRender = wp.components.ServerSideRender,
|
4 |
+
SelectControl = wp.components.SelectControl,
|
5 |
+
TextControl = wp.components.TextControl,
|
6 |
+
ToggleControl = wp.components.ToggleControl,
|
7 |
+
InspectorControls = wp.editor.InspectorControls;
|
8 |
+
|
9 |
+
registerBlockType('simple-download-monitor/download-item', {
|
10 |
+
title: sdmBlockDownloadItemStr.title,
|
11 |
+
icon: 'download',
|
12 |
+
category: 'common',
|
13 |
+
|
14 |
+
edit: function (props) {
|
15 |
+
return [
|
16 |
+
el(ServerSideRender, {
|
17 |
+
block: 'simple-download-monitor/download-item',
|
18 |
+
attributes: props.attributes,
|
19 |
+
}),
|
20 |
+
el(InspectorControls, {},
|
21 |
+
el(SelectControl, {
|
22 |
+
label: sdmBlockDownloadItemStr.download,
|
23 |
+
help: sdmBlockDownloadItemStr.downloadHelp,
|
24 |
+
value: props.attributes.itemId,
|
25 |
+
options: sdmDownloadBlockItems,
|
26 |
+
onChange: (value) => {
|
27 |
+
props.setAttributes({itemId: value});
|
28 |
+
},
|
29 |
+
})
|
30 |
+
),
|
31 |
+
el(InspectorControls, {},
|
32 |
+
el(SelectControl, {
|
33 |
+
label: sdmBlockDownloadItemStr.fancy,
|
34 |
+
help: sdmBlockDownloadItemStr.fancyHelp,
|
35 |
+
value: props.attributes.fancyId,
|
36 |
+
options: sdmDownloadBlockFancy,
|
37 |
+
onChange: (value) => {
|
38 |
+
props.setAttributes({fancyId: value});
|
39 |
+
},
|
40 |
+
})
|
41 |
+
),
|
42 |
+
el(InspectorControls, {},
|
43 |
+
el(SelectControl, {
|
44 |
+
label: sdmBlockDownloadItemStr.color,
|
45 |
+
help: sdmBlockDownloadItemStr.colorHelp,
|
46 |
+
value: props.attributes.color,
|
47 |
+
options: sdmDownloadBlockColor,
|
48 |
+
onChange: (value) => {
|
49 |
+
props.setAttributes({color: value});
|
50 |
+
},
|
51 |
+
})
|
52 |
+
),
|
53 |
+
el(InspectorControls, {},
|
54 |
+
el(TextControl, {
|
55 |
+
label: sdmBlockDownloadItemStr.buttonText,
|
56 |
+
value: props.attributes.buttonText,
|
57 |
+
help: sdmBlockDownloadItemStr.buttonTextHelp,
|
58 |
+
onChange: (value) => {
|
59 |
+
props.setAttributes({buttonText: value});
|
60 |
+
},
|
61 |
+
})
|
62 |
+
),
|
63 |
+
el(InspectorControls, {},
|
64 |
+
el(ToggleControl, {
|
65 |
+
label: sdmBlockDownloadItemStr.newWindow,
|
66 |
+
// help: aspBlockProdStr.button_only_help,
|
67 |
+
checked: props.attributes.newWindow,
|
68 |
+
onChange: (state) => {
|
69 |
+
props.setAttributes({newWindow: state});
|
70 |
+
},
|
71 |
+
})
|
72 |
+
),
|
73 |
+
];
|
74 |
+
},
|
75 |
+
|
76 |
+
save: function () {
|
77 |
+
return null;
|
78 |
+
},
|
79 |
+
});
|
js/sdm_g_recaptcha.js
CHANGED
@@ -5,6 +5,6 @@
|
|
5 |
var sdm_reCaptcha = function () {
|
6 |
var recaptcha = document.getElementsByClassName("g-recaptcha");
|
7 |
for (var i = 0; i < recaptcha.length; i++) {
|
8 |
-
|
9 |
}
|
10 |
};
|
5 |
var sdm_reCaptcha = function () {
|
6 |
var recaptcha = document.getElementsByClassName("g-recaptcha");
|
7 |
for (var i = 0; i < recaptcha.length; i++) {
|
8 |
+
grecaptcha.render(recaptcha.item(i), {"sitekey": sdm_recaptcha_opt.site_key});
|
9 |
}
|
10 |
};
|
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.
|
7 |
* Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
|
8 |
* Author URI: https://www.tipsandtricks-hq.com/development-center
|
9 |
* License: GPL2
|
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
-
define( 'WP_SIMPLE_DL_MONITOR_VERSION', '3.7.
|
18 |
define( 'WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname( plugin_basename( __FILE__ ) ) );
|
19 |
define( 'WP_SIMPLE_DL_MONITOR_URL', plugins_url( '', __FILE__ ) );
|
20 |
define( 'WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path( __FILE__ ) );
|
@@ -194,6 +194,7 @@ class simpleDownloadManager {
|
|
194 |
add_action( 'init', 'sdm_create_taxonomies' ); // Register 'tags' and 'categories' taxonomies
|
195 |
add_action( 'init', 'sdm_register_shortcodes' ); //Register the shortcodes
|
196 |
add_action( 'wp_enqueue_scripts', array( $this, 'sdm_frontend_scripts' ) ); // Register frontend scripts
|
|
|
197 |
|
198 |
if ( is_admin() ) {
|
199 |
add_action( 'admin_menu', array( $this, 'sdm_create_menu_pages' ) ); // Create admin pages
|
@@ -305,7 +306,7 @@ class simpleDownloadManager {
|
|
305 |
add_meta_box( 'sdm_description_meta_box', __( 'Description', 'simple-download-monitor' ), array( $this, 'display_sdm_description_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
306 |
add_meta_box( 'sdm_upload_meta_box', __( 'Downloadable File (Visitors will download this item)', 'simple-download-monitor' ), array( $this, 'display_sdm_upload_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
307 |
add_meta_box( 'sdm_dispatch_meta_box', __( 'PHP Dispatch or Redirect', 'simple-download-monitor' ), array( $this, 'display_sdm_dispatch_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
308 |
-
add_meta_box( 'sdm_misc_properties_meta_box', __( 'Miscellaneous Download Properties', 'simple-download-monitor' ), array( $this, 'display_sdm_misc_properties_meta_box' ), 'sdm_downloads', 'normal', 'default' ); // Meta box for misc properies/settings
|
309 |
add_meta_box( 'sdm_thumbnail_meta_box', __( 'File Thumbnail (Optional)', 'simple-download-monitor' ), array( $this, 'display_sdm_thumbnail_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
310 |
add_meta_box( 'sdm_stats_meta_box', __( 'Statistics', 'simple-download-monitor' ), array( $this, 'display_sdm_stats_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
311 |
do_action( 'sdm_admin_add_edit_download_before_other_details_meta_box_action' );
|
@@ -382,10 +383,21 @@ class simpleDownloadManager {
|
|
382 |
//Does nothing at the moment.
|
383 |
}
|
384 |
}
|
385 |
-
|
|
|
|
|
|
|
386 |
echo '<p> <input id="sdm_item_new_window" type="checkbox" name="sdm_item_new_window" value="yes"' . checked( true, $new_window, false ) . ' />';
|
387 |
echo '<label for="sdm_item_new_window">' . __( 'Open download in a new window.', 'simple-download-monitor' ) . '</label> </p>';
|
388 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
wp_nonce_field( 'sdm_misc_properties_box_nonce', 'sdm_misc_properties_box_nonce_check' );
|
390 |
}
|
391 |
|
@@ -565,8 +577,11 @@ class simpleDownloadManager {
|
|
565 |
}
|
566 |
// Get POST-ed data as boolean value
|
567 |
$new_window_open = filter_input( INPUT_POST, 'sdm_item_new_window', FILTER_VALIDATE_BOOLEAN );
|
568 |
-
|
|
|
|
|
569 |
update_post_meta( $post_id, 'sdm_item_new_window', $new_window_open );
|
|
|
570 |
}
|
571 |
|
572 |
public function sdm_save_thumbnail_meta_data( $post_id ) { // Save Thumbnail Upload metabox
|
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.8
|
7 |
* Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
|
8 |
* Author URI: https://www.tipsandtricks-hq.com/development-center
|
9 |
* License: GPL2
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define( 'WP_SIMPLE_DL_MONITOR_VERSION', '3.7.8' );
|
18 |
define( 'WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname( plugin_basename( __FILE__ ) ) );
|
19 |
define( 'WP_SIMPLE_DL_MONITOR_URL', plugins_url( '', __FILE__ ) );
|
20 |
define( 'WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path( __FILE__ ) );
|
194 |
add_action( 'init', 'sdm_create_taxonomies' ); // Register 'tags' and 'categories' taxonomies
|
195 |
add_action( 'init', 'sdm_register_shortcodes' ); //Register the shortcodes
|
196 |
add_action( 'wp_enqueue_scripts', array( $this, 'sdm_frontend_scripts' ) ); // Register frontend scripts
|
197 |
+
include_once('includes/sdm-blocks.php');
|
198 |
|
199 |
if ( is_admin() ) {
|
200 |
add_action( 'admin_menu', array( $this, 'sdm_create_menu_pages' ) ); // Create admin pages
|
306 |
add_meta_box( 'sdm_description_meta_box', __( 'Description', 'simple-download-monitor' ), array( $this, 'display_sdm_description_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
307 |
add_meta_box( 'sdm_upload_meta_box', __( 'Downloadable File (Visitors will download this item)', 'simple-download-monitor' ), array( $this, 'display_sdm_upload_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
308 |
add_meta_box( 'sdm_dispatch_meta_box', __( 'PHP Dispatch or Redirect', 'simple-download-monitor' ), array( $this, 'display_sdm_dispatch_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
309 |
+
add_meta_box( 'sdm_misc_properties_meta_box', __( 'Miscellaneous Download Item Properties', 'simple-download-monitor' ), array( $this, 'display_sdm_misc_properties_meta_box' ), 'sdm_downloads', 'normal', 'default' ); // Meta box for misc properies/settings
|
310 |
add_meta_box( 'sdm_thumbnail_meta_box', __( 'File Thumbnail (Optional)', 'simple-download-monitor' ), array( $this, 'display_sdm_thumbnail_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
311 |
add_meta_box( 'sdm_stats_meta_box', __( 'Statistics', 'simple-download-monitor' ), array( $this, 'display_sdm_stats_meta_box' ), 'sdm_downloads', 'normal', 'default' );
|
312 |
do_action( 'sdm_admin_add_edit_download_before_other_details_meta_box_action' );
|
383 |
//Does nothing at the moment.
|
384 |
}
|
385 |
}
|
386 |
+
|
387 |
+
//Check the sdm_item_disable_single_download_page value
|
388 |
+
$sdm_item_disable_single_download_page = get_post_meta( $post->ID, 'sdm_item_disable_single_download_page', true );
|
389 |
+
|
390 |
echo '<p> <input id="sdm_item_new_window" type="checkbox" name="sdm_item_new_window" value="yes"' . checked( true, $new_window, false ) . ' />';
|
391 |
echo '<label for="sdm_item_new_window">' . __( 'Open download in a new window.', 'simple-download-monitor' ) . '</label> </p>';
|
392 |
|
393 |
+
echo '<p> <input id="sdm_item_disable_single_download_page" type="checkbox" name="sdm_item_disable_single_download_page" value="yes"' . checked( true, $sdm_item_disable_single_download_page, false ) . ' />';
|
394 |
+
echo '<label for="sdm_item_disable_single_download_page">';
|
395 |
+
$disable_single_dl_label = __( 'Disable the Single Download Page for This Download Item. ', 'simple-download-monitor' );
|
396 |
+
$disable_single_dl_label .= __( 'This can be useful if you are using an addon like the ', 'simple-download-monitor' );
|
397 |
+
$disable_single_dl_label .= '<a href="https://simple-download-monitor.com/squeeze-form-addon-for-simple-download-monitor/" target="_blank">Squeeze Form</a>';
|
398 |
+
echo $disable_single_dl_label . '</label>';
|
399 |
+
echo '</p>';
|
400 |
+
|
401 |
wp_nonce_field( 'sdm_misc_properties_box_nonce', 'sdm_misc_properties_box_nonce_check' );
|
402 |
}
|
403 |
|
577 |
}
|
578 |
// Get POST-ed data as boolean value
|
579 |
$new_window_open = filter_input( INPUT_POST, 'sdm_item_new_window', FILTER_VALIDATE_BOOLEAN );
|
580 |
+
$sdm_item_disable_single_download_page = filter_input( INPUT_POST, 'sdm_item_disable_single_download_page', FILTER_VALIDATE_BOOLEAN );
|
581 |
+
|
582 |
+
//Save the data
|
583 |
update_post_meta( $post_id, 'sdm_item_new_window', $new_window_open );
|
584 |
+
update_post_meta( $post_id, 'sdm_item_disable_single_download_page', $sdm_item_disable_single_download_page );
|
585 |
}
|
586 |
|
587 |
public function sdm_save_thumbnail_meta_data( $post_id ) { // Save Thumbnail Upload metabox
|
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.2
|
7 |
-
Stable tag: 3.7.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
|
@@ -13,7 +13,7 @@ Easily manage downloadable files and monitor downloads of your digital files fro
|
|
13 |
|
14 |
I developed the Simple Download Monitor plugin because I needed a nice way to manage my digital downloads and monitor the number of downloads of my files and documents.
|
15 |
|
16 |
-
This plugin is very useful for managing and tracking your digital file download counts.
|
17 |
|
18 |
You can password protect your downloadable files and documents too (visitors will require a password before downloading the file when you use this option).
|
19 |
|
@@ -25,7 +25,7 @@ The plugin will log the IP addresses of the users who download your digital file
|
|
25 |
|
26 |
It has a very user-friendly interface for uploading, managing, monitoring and tracking file downloads.
|
27 |
|
28 |
-
https://www.youtube.com/watch?v=
|
29 |
|
30 |
= Simple Download Monitor Features =
|
31 |
|
@@ -74,6 +74,7 @@ https://www.youtube.com/watch?v=utYIH0fILuQ
|
|
74 |
* Option to add Terms and Condtions to your download buttons.
|
75 |
* Ability to easily clone/copy your existing download items.
|
76 |
* Ability to insert Adsense or other Ad code inside the download item display.
|
|
|
77 |
|
78 |
View more details on the [download monitor plugin](https://simple-download-monitor.com/) page.
|
79 |
|
@@ -185,6 +186,18 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
|
|
185 |
|
186 |
== Changelog ==
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
= 3.7.5 =
|
189 |
- Added an option to configure "after download redirect" in the hidden downloads addon.
|
190 |
|
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.8
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
|
13 |
|
14 |
I developed the Simple Download Monitor plugin because I needed a nice way to manage my digital downloads and monitor the number of downloads of my files and documents.
|
15 |
|
16 |
+
This plugin is very useful for managing and tracking your digital file download counts.
|
17 |
|
18 |
You can password protect your downloadable files and documents too (visitors will require a password before downloading the file when you use this option).
|
19 |
|
25 |
|
26 |
It has a very user-friendly interface for uploading, managing, monitoring and tracking file downloads.
|
27 |
|
28 |
+
https://www.youtube.com/watch?v=SjVaanbulRU
|
29 |
|
30 |
= Simple Download Monitor Features =
|
31 |
|
74 |
* Option to add Terms and Condtions to your download buttons.
|
75 |
* Ability to easily clone/copy your existing download items.
|
76 |
* Ability to insert Adsense or other Ad code inside the download item display.
|
77 |
+
* Gutenberg block to insert download now buttons on a post or page.
|
78 |
|
79 |
View more details on the [download monitor plugin](https://simple-download-monitor.com/) page.
|
80 |
|
186 |
|
187 |
== Changelog ==
|
188 |
|
189 |
+
= 3.7.8 =
|
190 |
+
- Added a new option in the download configuration to disable the individual download page of an item. Can be useful if you only want to allow downloading of the item from where you embed it.
|
191 |
+
|
192 |
+
= 3.7.7 =
|
193 |
+
- Fixed password protected download error when reCapcha is enabeld.
|
194 |
+
- Added CSS class to the "Enter Password" label (for password protected downloads).
|
195 |
+
|
196 |
+
= 3.7.6 =
|
197 |
+
- Added "SDM Download" Gutenberg block.
|
198 |
+
- Fixed "color" shortcode parameter was ignored for default template (fancy 0).
|
199 |
+
- Added a new compact template (fancy3). This can be useful in displaying a list of downloads in a compact form (maybe in a sidebar widget).
|
200 |
+
|
201 |
= 3.7.5 =
|
202 |
- Added an option to configure "after download redirect" in the hidden downloads addon.
|
203 |
|
sdm-post-type-and-taxonomy.php
CHANGED
@@ -4,88 +4,88 @@ function sdm_register_post_type() {
|
|
4 |
|
5 |
//***** Create 'sdm_downloads' Custom Post Type
|
6 |
$labels = array(
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
);
|
21 |
-
|
22 |
-
$sdm_permalink_base
|
23 |
-
$sdm_slug
|
24 |
-
$args
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
);
|
39 |
-
register_post_type('sdm_downloads', $args);
|
40 |
}
|
41 |
|
42 |
function sdm_create_taxonomies() {
|
43 |
|
44 |
//***** Create CATEGORIES Taxonomy
|
45 |
-
$labels_tags
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
);
|
58 |
-
$args_tags
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
);
|
66 |
-
register_taxonomy('sdm_categories', array('sdm_downloads'), $args_tags);
|
67 |
|
68 |
//***** Create TAGS Taxonomy
|
69 |
-
$labels_tags
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
);
|
82 |
-
$args_tags
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
);
|
90 |
-
register_taxonomy('sdm_tags', array('sdm_downloads'), $args_tags);
|
91 |
}
|
4 |
|
5 |
//***** Create 'sdm_downloads' Custom Post Type
|
6 |
$labels = array(
|
7 |
+
'name' => __( 'Downloads', 'simple-download-monitor' ),
|
8 |
+
'singular_name' => __( 'Downloads', 'simple-download-monitor' ),
|
9 |
+
'add_new' => __( 'Add New', 'simple-download-monitor' ),
|
10 |
+
'add_new_item' => __( 'Add New', 'simple-download-monitor' ),
|
11 |
+
'edit_item' => __( 'Edit Download', 'simple-download-monitor' ),
|
12 |
+
'new_item' => __( 'New Download', 'simple-download-monitor' ),
|
13 |
+
'all_items' => __( 'Downloads', 'simple-download-monitor' ),
|
14 |
+
'view_item' => __( 'View Download', 'simple-download-monitor' ),
|
15 |
+
'search_items' => __( 'Search Downloads', 'simple-download-monitor' ),
|
16 |
+
'not_found' => __( 'No Downloads found', 'simple-download-monitor' ),
|
17 |
+
'not_found_in_trash' => __( 'No Downloads found in Trash', 'simple-download-monitor' ),
|
18 |
+
'parent_item_colon' => __( 'Parent Download', 'simple-download-monitor' ),
|
19 |
+
'menu_name' => __( 'Downloads', 'simple-download-monitor' )
|
20 |
);
|
21 |
+
|
22 |
+
$sdm_permalink_base = 'sdm_downloads'; //TODO - add an option to configure in the settings maybe?
|
23 |
+
$sdm_slug = untrailingslashit( $sdm_permalink_base );
|
24 |
+
$args = array(
|
25 |
+
'labels' => $labels,
|
26 |
+
'public' => true,
|
27 |
+
'publicly_queryable' => true,
|
28 |
+
'show_ui' => true,
|
29 |
+
'show_in_menu' => true,
|
30 |
+
'query_var' => true,
|
31 |
+
'rewrite' => array( 'slug' => $sdm_slug ),
|
32 |
+
'capability_type' => 'post',
|
33 |
+
'has_archive' => true,
|
34 |
+
'hierarchical' => false,
|
35 |
+
'menu_position' => null,
|
36 |
+
'menu_icon' => 'dashicons-download',
|
37 |
+
'supports' => array( 'title' )
|
38 |
);
|
39 |
+
register_post_type( 'sdm_downloads', $args );
|
40 |
}
|
41 |
|
42 |
function sdm_create_taxonomies() {
|
43 |
|
44 |
//***** Create CATEGORIES Taxonomy
|
45 |
+
$labels_tags = array(
|
46 |
+
'name' => __( 'Download Categories', 'simple-download-monitor' ),
|
47 |
+
'singular_name' => __( 'Download Category', 'simple-download-monitor' ),
|
48 |
+
'search_items' => __( 'Search Categories', 'simple-download-monitor' ),
|
49 |
+
'all_items' => __( 'All Categories', 'simple-download-monitor' ),
|
50 |
+
'parent_item' => __( 'Categories Genre', 'simple-download-monitor' ),
|
51 |
+
'parent_item_colon' => __( 'Categories Genre:', 'simple-download-monitor' ),
|
52 |
+
'edit_item' => __( 'Edit Category', 'simple-download-monitor' ),
|
53 |
+
'update_item' => __( 'Update Category', 'simple-download-monitor' ),
|
54 |
+
'add_new_item' => __( 'Add New Category', 'simple-download-monitor' ),
|
55 |
+
'new_item_name' => __( 'New Category', 'simple-download-monitor' ),
|
56 |
+
'menu_name' => __( 'Categories', 'simple-download-monitor' )
|
57 |
);
|
58 |
+
$args_tags = array(
|
59 |
+
'hierarchical' => true,
|
60 |
+
'labels' => $labels_tags,
|
61 |
+
'show_ui' => true,
|
62 |
+
'query_var' => true,
|
63 |
+
'rewrite' => array( 'slug' => 'sdm_categories' ),
|
64 |
+
'show_admin_column' => true
|
65 |
);
|
66 |
+
register_taxonomy( 'sdm_categories', array( 'sdm_downloads' ), $args_tags );
|
67 |
|
68 |
//***** Create TAGS Taxonomy
|
69 |
+
$labels_tags = array(
|
70 |
+
'name' => __( 'Download Tags', 'simple-download-monitor' ),
|
71 |
+
'singular_name' => __( 'Download Tag', 'simple-download-monitor' ),
|
72 |
+
'search_items' => __( 'Search Tags', 'simple-download-monitor' ),
|
73 |
+
'all_items' => __( 'All Tags', 'simple-download-monitor' ),
|
74 |
+
'parent_item' => __( 'Tags Genre', 'simple-download-monitor' ),
|
75 |
+
'parent_item_colon' => __( 'Tags Genre:', 'simple-download-monitor' ),
|
76 |
+
'edit_item' => __( 'Edit Tag', 'simple-download-monitor' ),
|
77 |
+
'update_item' => __( 'Update Tag', 'simple-download-monitor' ),
|
78 |
+
'add_new_item' => __( 'Add New Tag', 'simple-download-monitor' ),
|
79 |
+
'new_item_name' => __( 'New Tag', 'simple-download-monitor' ),
|
80 |
+
'menu_name' => __( 'Tags', 'simple-download-monitor' )
|
81 |
);
|
82 |
+
$args_tags = array(
|
83 |
+
'hierarchical' => false,
|
84 |
+
'labels' => $labels_tags,
|
85 |
+
'show_ui' => true,
|
86 |
+
'query_var' => true,
|
87 |
+
'rewrite' => array( 'slug' => 'sdm_tags' ),
|
88 |
+
'show_admin_column' => true
|
89 |
);
|
90 |
+
register_taxonomy( 'sdm_tags', array( 'sdm_downloads' ), $args_tags );
|
91 |
}
|
sdm-post-type-content-handler.php
CHANGED
@@ -11,8 +11,19 @@ function filter_sdm_post_type_content( $content ) {
|
|
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 );
|
@@ -155,11 +166,11 @@ 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
|
159 |
-
$isset_item_description
|
160 |
//$isset_item_description = apply_filters('the_content', $isset_item_description);
|
161 |
//Lets apply all the filters like do_shortcode, wptexturize, convert_smilies, wpautop etc.
|
162 |
-
$filtered_item_description
|
163 |
|
164 |
return $filtered_item_description;
|
165 |
}
|
11 |
//$content = sdm_create_download_shortcode($args);
|
12 |
$id = $post->ID;
|
13 |
|
14 |
+
//Check if the single download page is disabled.
|
15 |
+
$sdm_item_disable_single_download_page = get_post_meta( $id, 'sdm_item_disable_single_download_page', true );
|
16 |
+
if ($sdm_item_disable_single_download_page){
|
17 |
+
//Page is disabled. Show message and return.
|
18 |
+
$content .= '<div class="sdm_post_single_download_page_disabled_msg">';
|
19 |
+
$msg = __('The admin of this site has disabled this download item page.', 'simple-download-monitor');
|
20 |
+
$content .= apply_filters('sdm_post_single_download_page_disabled_msg', $msg);
|
21 |
+
$content .= '</div>';
|
22 |
+
return $content;
|
23 |
+
}
|
24 |
+
|
25 |
//Check to see if the download link cpt is password protected
|
26 |
+
$get_cpt_object = get_post( $id );
|
27 |
$cpt_is_password = ! empty( $get_cpt_object->post_password ) ? 'yes' : 'no'; // yes = download is password protected;
|
28 |
//Get item thumbnail
|
29 |
$item_download_thumbnail = get_post_meta( $id, 'sdm_upload_thumbnail', true );
|
166 |
add_filter( 'sdm_downloads_description', 'prepend_attachment' );
|
167 |
|
168 |
function sdm_get_item_description_output( $id ) {
|
169 |
+
$item_description = get_post_meta( $id, 'sdm_description', true );
|
170 |
+
$isset_item_description = isset( $item_description ) && ! empty( $item_description ) ? $item_description : '';
|
171 |
//$isset_item_description = apply_filters('the_content', $isset_item_description);
|
172 |
//Lets apply all the filters like do_shortcode, wptexturize, convert_smilies, wpautop etc.
|
173 |
+
$filtered_item_description = apply_filters( 'sdm_downloads_description', $isset_item_description );
|
174 |
|
175 |
return $filtered_item_description;
|
176 |
}
|
sdm-shortcodes.php
CHANGED
@@ -130,6 +130,11 @@ function sdm_create_download_shortcode( $atts ) {
|
|
130 |
$output .= sdm_generate_fancy2_display_output( $shortcode_atts );
|
131 |
$output .= '<div class="sdm_clear_float"></div>';
|
132 |
break;
|
|
|
|
|
|
|
|
|
|
|
133 |
default: // Default output is the standard download now button (fancy 0)
|
134 |
include_once('includes/templates/fancy0/sdm-fancy-0.php');
|
135 |
$output .= sdm_generate_fancy0_display_output( $shortcode_atts );
|
@@ -318,6 +323,9 @@ function sdm_handle_category_shortcode( $args ) {
|
|
318 |
} else if ( $fancy == '2' ) {
|
319 |
include_once('includes/templates/fancy2/sdm-fancy-2.php');
|
320 |
$output .= sdm_generate_fancy2_category_display_output( $get_posts, $args );
|
|
|
|
|
|
|
321 |
}
|
322 |
|
323 |
// Pagination related
|
130 |
$output .= sdm_generate_fancy2_display_output( $shortcode_atts );
|
131 |
$output .= '<div class="sdm_clear_float"></div>';
|
132 |
break;
|
133 |
+
case '3':
|
134 |
+
include_once('includes/templates/fancy3/sdm-fancy-3.php');
|
135 |
+
$output .= sdm_generate_fancy3_display_output( $shortcode_atts );
|
136 |
+
$output .= '<div class="sdm_clear_float"></div>';
|
137 |
+
break;
|
138 |
default: // Default output is the standard download now button (fancy 0)
|
139 |
include_once('includes/templates/fancy0/sdm-fancy-0.php');
|
140 |
$output .= sdm_generate_fancy0_display_output( $shortcode_atts );
|
323 |
} else if ( $fancy == '2' ) {
|
324 |
include_once('includes/templates/fancy2/sdm-fancy-2.php');
|
325 |
$output .= sdm_generate_fancy2_category_display_output( $get_posts, $args );
|
326 |
+
} else if ( $fancy == '3' ) {
|
327 |
+
include_once('includes/templates/fancy3/sdm-fancy-3.php');
|
328 |
+
$output .= sdm_generate_fancy3_category_display_output( $get_posts, $args );
|
329 |
}
|
330 |
|
331 |
// Pagination related
|