Version Description
- Added a new feature to hide the download counts that is shown in some of the fancy templates. This new option can be found in the settings menu of the plugin.
- Added delete confirm dialogue in the individual download logs delete option.
- Simplified the settings menu page style.
- Fixed multiple vulnerabilities (thanks to NCSC-NL).
Download this release
Release Info
Developer | mra13 |
Plugin | Simple Download Monitor |
Version | 3.3.1 |
Comparing to | |
See all releases |
Code changes from version 3.2.8 to 3.3.1
- css/sdm_admin_styles.css +0 -51
- includes/sdm-admin-menu-handler.php +57 -83
- includes/sdm-logs-list-table.php +39 -48
- includes/sdm-utility-functions-admin-side.php +28 -0
- includes/sdm-utility-functions.php +24 -0
- includes/templates/fancy1/sdm-fancy-1.php +3 -1
- js/sdm_admin_scripts.js +47 -47
- js/sdm_wp_scripts.js +43 -77
- main.php +115 -187
- readme.txt +22 -3
- sdm-download-logs.csv +0 -0
- sdm-post-type-and-taxonomy.php +4 -4
- sdm-post-type-content-handler.php +5 -1
css/sdm_admin_styles.css
CHANGED
@@ -1,54 +1,3 @@
|
|
1 |
-
/*
|
2 |
-
** Used for sliding divs on admin settings page
|
3 |
-
*/
|
4 |
-
#plus_minus_email, #plus_minus_colors {
|
5 |
-
float:right;
|
6 |
-
margin-top:-3px;
|
7 |
-
margin-right:10px;
|
8 |
-
}
|
9 |
-
.slidingDiv {
|
10 |
-
width:60%;
|
11 |
-
background-color: #ECECEC;
|
12 |
-
padding:10px;
|
13 |
-
margin-top:1px;
|
14 |
-
border-bottom:3px solid #E1E1E1;
|
15 |
-
|
16 |
-
-webkit-border-radius: 0 0 10px 10px;
|
17 |
-
-moz-border-radius: 0 0 10px 10px;
|
18 |
-
border-radius: 0 0 10px 10px;
|
19 |
-
}
|
20 |
-
.sdm_sliding_div_title {
|
21 |
-
width:60%;
|
22 |
-
height:25px;
|
23 |
-
background-color:#E1E1E1;
|
24 |
-
padding:10px;
|
25 |
-
margin-top:10px;
|
26 |
-
|
27 |
-
-webkit-border-radius: 10px 10px 0 0;
|
28 |
-
-moz-border-radius: 10px 10px 0 0;
|
29 |
-
border-radius: 10px 10px 0 0;
|
30 |
-
}
|
31 |
-
.sdm_slider_title {
|
32 |
-
float:left;
|
33 |
-
width:20%;
|
34 |
-
font-size:22px;
|
35 |
-
margin-top:5px;
|
36 |
-
text-shadow: 2px 2px #FFF;
|
37 |
-
}
|
38 |
-
.sdm_desc {
|
39 |
-
float:left;
|
40 |
-
width:60%;
|
41 |
-
font-size:14px;
|
42 |
-
margin-top:7px;
|
43 |
-
text-shadow: 1px 1px #FFF;
|
44 |
-
}
|
45 |
-
.sdm_open_close {
|
46 |
-
float:left;
|
47 |
-
width:20%;
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
/*
|
53 |
** Used for AJAX Loading overlay
|
54 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/*
|
2 |
** Used for AJAX Loading overlay
|
3 |
*/
|
includes/sdm-admin-menu-handler.php
CHANGED
@@ -1,57 +1,23 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
function sdm_handle_admin_menu() {
|
4 |
-
|
5 |
-
if (isset($_GET['download_log'])) {
|
6 |
-
global $wpdb;
|
7 |
-
$csv_output = '';
|
8 |
-
$table = $wpdb->prefix . 'sdm_downloads';
|
9 |
-
|
10 |
-
$result = mysql_query("SHOW COLUMNS FROM " . $table . "");
|
11 |
-
|
12 |
-
$i = 0;
|
13 |
-
if (mysql_num_rows($result) > 0) {
|
14 |
-
while ($row = mysql_fetch_assoc($result)) {
|
15 |
-
$csv_output = $csv_output . $row['Field'] . ",";
|
16 |
-
$i++;
|
17 |
-
}
|
18 |
-
}
|
19 |
-
$csv_output .= "\n";
|
20 |
-
|
21 |
-
$values = mysql_query("SELECT * FROM " . $table . "");
|
22 |
-
while ($rowr = mysql_fetch_row($values)) {
|
23 |
-
for ($j = 0; $j < $i; $j++) {
|
24 |
-
$csv_output .= $rowr[$j] . ",";
|
25 |
-
}
|
26 |
-
$csv_output .= "\n";
|
27 |
-
}
|
28 |
-
|
29 |
-
header("Pragma: public");
|
30 |
-
header("Expires: 0");
|
31 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
32 |
-
header("Cache-Control: private", false);
|
33 |
-
header("Content-Type: application/octet-stream");
|
34 |
-
header("Content-Disposition: attachment; filename=\"report.csv\";");
|
35 |
-
header("Content-Transfer-Encoding: binary");
|
36 |
-
|
37 |
-
echo $csv_output;
|
38 |
-
exit;
|
39 |
-
}
|
40 |
-
|
41 |
-
//*****
|
42 |
//***** Create the 'logs' and 'settings' submenu pages
|
43 |
$sdm_logs_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Logs', 'simple-download-monitor'), __('Logs', 'simple-download-monitor'), 'manage_options', 'logs', 'sdm_create_logs_page');
|
44 |
$sdm_settings_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Settings', 'simple-download-monitor'), __('Settings', 'simple-download-monitor'), 'manage_options', 'settings', 'sdm_create_settings_page');
|
45 |
}
|
46 |
|
47 |
/*
|
48 |
-
* Settings page
|
49 |
*/
|
50 |
function sdm_create_settings_page() {
|
51 |
echo '<div class="wrap">';
|
52 |
-
echo '<div id="poststuff"><div id="post-body">';
|
53 |
?>
|
54 |
-
<
|
55 |
|
56 |
<div style="background: #FFF6D5; border: 1px solid #D1B655; color: #3F2502; padding: 15px 10px">
|
57 |
Read the full plugin usage documentation <a href="https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin" target="_blank">here</a>.
|
@@ -61,44 +27,34 @@ function sdm_create_settings_page() {
|
|
61 |
<!-- settings page form -->
|
62 |
<form method="post" action="options.php">
|
63 |
|
64 |
-
<!-- BEGIN
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
<!-- END ADMIN OPTIONS DIV -->
|
83 |
|
84 |
<!-- BEGIN COLORS DIV -->
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
</div>
|
93 |
-
<div id="sliding_div2" class="slidingDiv">
|
94 |
-
<?php
|
95 |
-
// This prints out all hidden setting fields
|
96 |
-
do_settings_sections('sdm_colors_section');
|
97 |
-
settings_fields('sdm_downloads_options');
|
98 |
-
|
99 |
-
submit_button();
|
100 |
-
?>
|
101 |
-
</div>
|
102 |
<!-- END COLORS OPTIONS DIV -->
|
103 |
|
104 |
<!-- End of settings page form -->
|
@@ -110,15 +66,23 @@ function sdm_create_settings_page() {
|
|
110 |
</div>
|
111 |
|
112 |
<?php
|
113 |
-
echo '</div></div>'; //end of post-stuff
|
114 |
echo '</div>'; //end of wrap
|
115 |
}
|
116 |
|
117 |
/*
|
118 |
-
* * Logs
|
119 |
*/
|
120 |
function sdm_create_logs_page() {
|
121 |
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
if (isset($_POST['sdm_reset_log_entries'])) {
|
124 |
//reset log entries
|
@@ -146,19 +110,30 @@ function sdm_create_logs_page() {
|
|
146 |
</div>
|
147 |
|
148 |
<div id="poststuff"><div id="post-body">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
<!-- Log reset button -->
|
150 |
<div class="postbox">
|
151 |
<h3 class="hndle"><label for="title"><?php _e('Reset Download Log Entries', 'simple-download-monitor'); ?></label></h3>
|
152 |
<div class="inside">
|
153 |
-
|
154 |
-
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" onSubmit="return confirm('Are you sure you want to reset all the log entries?');" >
|
155 |
<div class="submit">
|
156 |
<input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e('Reset Log Entries', 'simple-download-monitor'); ?>" />
|
157 |
</div>
|
158 |
</form>
|
159 |
-
|
160 |
</div></div>
|
161 |
-
|
|
|
162 |
|
163 |
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
|
164 |
<form id="sdm_downloads-filter" method="post">
|
@@ -166,7 +141,6 @@ function sdm_create_logs_page() {
|
|
166 |
<!-- Now we can render the completed list table -->
|
167 |
<?php $sdmListTable->display() ?>
|
168 |
</form>
|
169 |
-
|
170 |
|
171 |
</div><!-- end of wrap -->
|
172 |
<script type="text/javascript">
|
1 |
<?php
|
2 |
|
3 |
+
/*
|
4 |
+
* Creates/adds the other admin menu page links to the main SDM custom post type menu
|
5 |
+
*/
|
6 |
function sdm_handle_admin_menu() {
|
7 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
//***** Create the 'logs' and 'settings' submenu pages
|
9 |
$sdm_logs_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Logs', 'simple-download-monitor'), __('Logs', 'simple-download-monitor'), 'manage_options', 'logs', 'sdm_create_logs_page');
|
10 |
$sdm_settings_page = add_submenu_page('edit.php?post_type=sdm_downloads', __('Settings', 'simple-download-monitor'), __('Settings', 'simple-download-monitor'), 'manage_options', 'settings', 'sdm_create_settings_page');
|
11 |
}
|
12 |
|
13 |
/*
|
14 |
+
* Settings menu page
|
15 |
*/
|
16 |
function sdm_create_settings_page() {
|
17 |
echo '<div class="wrap">';
|
18 |
+
//echo '<div id="poststuff"><div id="post-body">';
|
19 |
?>
|
20 |
+
<h1><?php _e('Simple Download Monitor Settings Page', 'simple-download-monitor') ?></h1>
|
21 |
|
22 |
<div style="background: #FFF6D5; border: 1px solid #D1B655; color: #3F2502; padding: 15px 10px">
|
23 |
Read the full plugin usage documentation <a href="https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin" target="_blank">here</a>.
|
27 |
<!-- settings page form -->
|
28 |
<form method="post" action="options.php">
|
29 |
|
30 |
+
<!-- BEGIN GENERAL OPTIONS DIV -->
|
31 |
+
<?php
|
32 |
+
// This prints out all hidden setting fields
|
33 |
+
do_settings_sections('general_options_section');
|
34 |
+
settings_fields('sdm_downloads_options');
|
35 |
+
|
36 |
+
submit_button();
|
37 |
+
?>
|
38 |
+
<!-- END GENERAL OPTIONS DIV -->
|
39 |
+
|
40 |
+
<!-- BEGIN ADMIN OPTIONS DIV -->
|
41 |
+
<?php
|
42 |
+
// This prints out all hidden setting fields
|
43 |
+
do_settings_sections('admin_options_section');
|
44 |
+
settings_fields('sdm_downloads_options');
|
45 |
+
|
46 |
+
submit_button();
|
47 |
+
?>
|
48 |
<!-- END ADMIN OPTIONS DIV -->
|
49 |
|
50 |
<!-- BEGIN COLORS DIV -->
|
51 |
+
<?php
|
52 |
+
// This prints out all hidden setting fields
|
53 |
+
do_settings_sections('sdm_colors_section');
|
54 |
+
settings_fields('sdm_downloads_options');
|
55 |
+
|
56 |
+
submit_button();
|
57 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
<!-- END COLORS OPTIONS DIV -->
|
59 |
|
60 |
<!-- End of settings page form -->
|
66 |
</div>
|
67 |
|
68 |
<?php
|
|
|
69 |
echo '</div>'; //end of wrap
|
70 |
}
|
71 |
|
72 |
/*
|
73 |
+
* * Logs menu page
|
74 |
*/
|
75 |
function sdm_create_logs_page() {
|
76 |
global $wpdb;
|
77 |
+
|
78 |
+
if (isset($_POST['sdm_export_log_entries'])) {
|
79 |
+
//Export log entries
|
80 |
+
$log_file_url = sdm_export_download_logs_to_csv();
|
81 |
+
echo '<div id="message" class="updated"><p>';
|
82 |
+
_e('Log entries exported! Click on the following link to download the file.', 'simple-download-monitor');
|
83 |
+
echo '<br /><br /><a href="'.$log_file_url.'">' . __('Download Logs CSV File', 'simple-download-monitor') . '</a>';
|
84 |
+
echo '</p></div>';
|
85 |
+
}
|
86 |
|
87 |
if (isset($_POST['sdm_reset_log_entries'])) {
|
88 |
//reset log entries
|
110 |
</div>
|
111 |
|
112 |
<div id="poststuff"><div id="post-body">
|
113 |
+
|
114 |
+
<!-- Log export button -->
|
115 |
+
<div class="postbox">
|
116 |
+
<h3 class="hndle"><label for="title"><?php _e('Export Download Log Entries', 'simple-download-monitor'); ?></label></h3>
|
117 |
+
<div class="inside">
|
118 |
+
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" onSubmit="return confirm('Are you sure you want to export all the log entries?');" >
|
119 |
+
<div class="submit">
|
120 |
+
<input type="submit" class="button" name="sdm_export_log_entries" value="<?php _e('Export Log Entries to CSV File', 'simple-download-monitor'); ?>" />
|
121 |
+
</div>
|
122 |
+
</form>
|
123 |
+
</div></div>
|
124 |
+
|
125 |
<!-- Log reset button -->
|
126 |
<div class="postbox">
|
127 |
<h3 class="hndle"><label for="title"><?php _e('Reset Download Log Entries', 'simple-download-monitor'); ?></label></h3>
|
128 |
<div class="inside">
|
129 |
+
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" onSubmit="return confirm('Are you sure you want to reset all the log entries to a CSV file?');" >
|
|
|
130 |
<div class="submit">
|
131 |
<input type="submit" class="button" name="sdm_reset_log_entries" value="<?php _e('Reset Log Entries', 'simple-download-monitor'); ?>" />
|
132 |
</div>
|
133 |
</form>
|
|
|
134 |
</div></div>
|
135 |
+
|
136 |
+
</div></div><!-- end of .poststuff and .post-body -->
|
137 |
|
138 |
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
|
139 |
<form id="sdm_downloads-filter" method="post">
|
141 |
<!-- Now we can render the completed list table -->
|
142 |
<?php $sdmListTable->display() ?>
|
143 |
</form>
|
|
|
144 |
|
145 |
</div><!-- end of wrap -->
|
146 |
<script type="text/javascript">
|
includes/sdm-logs-list-table.php
CHANGED
@@ -23,7 +23,7 @@ class sdm_List_Table extends WP_List_Table {
|
|
23 |
}
|
24 |
|
25 |
function column_default($item, $column_name) {
|
26 |
-
|
27 |
switch ($column_name) {
|
28 |
case 'URL':
|
29 |
case 'visitor_ip':
|
@@ -39,11 +39,11 @@ class sdm_List_Table extends WP_List_Table {
|
|
39 |
}
|
40 |
|
41 |
function column_title($item) {
|
42 |
-
|
43 |
//Build row actions
|
44 |
$actions = array(
|
45 |
'edit' => sprintf('<a href="' . admin_url('post.php?post=' . $item['ID'] . '&action=edit') . '">' . __('Edit', 'simple-download-monitor') . '</a>'),
|
46 |
-
'delete' => sprintf('<a href="?post_type=sdm_downloads&page=%s&action=%s&download=%s&
|
47 |
);
|
48 |
|
49 |
//Return the title contents
|
@@ -59,7 +59,7 @@ class sdm_List_Table extends WP_List_Table {
|
|
59 |
return sprintf(
|
60 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
61 |
/* $1%s */ $this->_args['singular'], //Let's simply repurpose the table's singular label ("Download")
|
62 |
-
/* $2%s */ $item['
|
63 |
);
|
64 |
}
|
65 |
|
@@ -80,10 +80,10 @@ class sdm_List_Table extends WP_List_Table {
|
|
80 |
function get_sortable_columns() {
|
81 |
|
82 |
$sortable_columns = array(
|
83 |
-
'title' => array('
|
84 |
-
'URL' => array('
|
85 |
'visitor_ip' => array('visitor_ip', false),
|
86 |
-
'date' => array('
|
87 |
'visitor_country' => array('visitor_country', false),
|
88 |
'visitor_name' => array('visitor_name', false)
|
89 |
);
|
@@ -94,50 +94,36 @@ class sdm_List_Table extends WP_List_Table {
|
|
94 |
|
95 |
$actions = array();
|
96 |
$actions['delete2'] = __('Delete Permanently', 'simple-download-monitor');
|
97 |
-
$actions['export_all'] = __('Export All as Excel', 'simple-download-monitor');
|
98 |
-
//$actions['export-selected'] = __( 'Export Selected', 'simple-download-monitor' );
|
99 |
|
100 |
return $actions;
|
101 |
}
|
102 |
|
103 |
function process_bulk_action() {
|
104 |
|
105 |
-
//
|
106 |
-
if (
|
107 |
|
|
|
108 |
$nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
|
109 |
$action = 'bulk-' . $this->_args['plural'];
|
110 |
|
111 |
-
if (!wp_verify_nonce($nonce, $action))
|
112 |
wp_die(__('Nope! Security check failed!', 'simple-download-monitor'));
|
113 |
-
|
114 |
-
|
115 |
-
$action = $this->current_action();
|
116 |
-
|
117 |
-
// If bulk 'Export All' was clicked
|
118 |
-
if ('export_all' === $this->current_action()) {
|
119 |
-
|
120 |
-
echo '<div id="message" class="updated"><p><strong><a id="sdm_download_export" href="?post_type=sdm_downloads&page=logs&download_log">' . __('Download Export File', 'simple-download-monitor') . '</a></strong></p></div>';
|
121 |
-
}
|
122 |
-
|
123 |
-
// if bulk 'Delete Permanently' was clicked
|
124 |
-
if ('delete2' === $this->current_action()) {
|
125 |
-
|
126 |
if (!isset($_POST['download']) || $_POST['download'] == null) {
|
127 |
echo '<div id="message" class="updated fade"><p><strong>' . __('No entries were selected.', 'simple-download-monitor') . '</strong></p><p><em>' . __('Click to Dismiss', 'simple-download-monitor') . '</em></p></div>';
|
128 |
return;
|
129 |
}
|
130 |
|
131 |
foreach ($_POST['download'] as $item) {
|
132 |
-
$
|
133 |
-
|
|
|
|
|
134 |
|
135 |
global $wpdb;
|
136 |
-
$del_row = $wpdb->query(
|
137 |
-
'DELETE FROM ' . $wpdb->prefix . 'sdm_downloads
|
138 |
-
WHERE post_id = "' . $str_tok_id . '"
|
139 |
-
AND date_time = "' . $str_tok_datetime . '"'
|
140 |
-
);
|
141 |
}
|
142 |
if ($del_row) {
|
143 |
echo '<div id="message" class="updated fade"><p><strong>' . __('Entries Deleted!', 'simple-download-monitor') . '</strong></p><p><em>' . __('Click to Dismiss', 'simple-download-monitor') . '</em></p></div>';
|
@@ -149,15 +135,18 @@ class sdm_List_Table extends WP_List_Table {
|
|
149 |
// If single entry 'Delete' was clicked
|
150 |
if ('delete' === $this->current_action()) {
|
151 |
|
152 |
-
|
153 |
-
$
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
global $wpdb;
|
156 |
-
$del_row = $wpdb->query(
|
157 |
-
'DELETE FROM ' . $wpdb->prefix . 'sdm_downloads
|
158 |
-
WHERE post_id = "' . $item_id . '"
|
159 |
-
AND date_time = "' . $item_datetime . '"'
|
160 |
-
);
|
161 |
if ($del_row) {
|
162 |
echo '<div id="message" class="updated fade"><p><strong>' . __('Entry Deleted!', 'simple-download-monitor') . '</strong></p><p><em>' . __('Click to Dismiss', 'simple-download-monitor') . '</em></p></div>';
|
163 |
} else {
|
@@ -169,7 +158,7 @@ class sdm_List_Table extends WP_List_Table {
|
|
169 |
function prepare_items() {
|
170 |
|
171 |
global $wpdb; //This is used only if making any database queries
|
172 |
-
$per_page =
|
173 |
$columns = $this->get_columns();
|
174 |
$hidden = array();
|
175 |
$sortable = $this->get_sortable_columns();
|
@@ -178,14 +167,16 @@ class sdm_List_Table extends WP_List_Table {
|
|
178 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
179 |
$this->process_bulk_action();
|
180 |
|
181 |
-
//
|
182 |
-
$orderby_column = isset($_GET['orderby'])
|
183 |
-
$sort_order = isset($_GET['order'])
|
184 |
if(empty($orderby_column)){
|
185 |
-
|
186 |
-
|
187 |
}
|
188 |
-
|
|
|
|
|
189 |
//Do a query to find the total number of rows then calculate the query limit
|
190 |
$table_name = $wpdb->prefix . 'sdm_downloads';
|
191 |
$query = "SELECT COUNT(*) FROM $table_name";
|
@@ -201,7 +192,7 @@ class sdm_List_Table extends WP_List_Table {
|
|
201 |
//Prepare the array with the correct index names that the table is expecting.
|
202 |
$data = array();
|
203 |
foreach ($data_results as $data_result) {
|
204 |
-
$data[] = array('ID' => $data_result->post_id, 'title' => $data_result->post_title, 'URL' => $data_result->file_url, 'visitor_ip' => $data_result->visitor_ip, 'date' => $data_result->date_time, 'visitor_country' => $data_result->visitor_country, 'visitor_name' => $data_result->visitor_name);
|
205 |
}
|
206 |
|
207 |
// Now we add our *sorted* data to the items property, where it can be used by the rest of the class.
|
23 |
}
|
24 |
|
25 |
function column_default($item, $column_name) {
|
26 |
+
|
27 |
switch ($column_name) {
|
28 |
case 'URL':
|
29 |
case 'visitor_ip':
|
39 |
}
|
40 |
|
41 |
function column_title($item) {
|
42 |
+
$delete_log_nonce = wp_create_nonce('sdm_delete_log_entry');
|
43 |
//Build row actions
|
44 |
$actions = array(
|
45 |
'edit' => sprintf('<a href="' . admin_url('post.php?post=' . $item['ID'] . '&action=edit') . '">' . __('Edit', 'simple-download-monitor') . '</a>'),
|
46 |
+
'delete' => sprintf('<a href="?post_type=sdm_downloads&page=%s&action=%s&download=%s&row_id=%s&_wpnonce=%s" onclick="return confirm(\'Are you sure you want to delete this entry?\')">' . __('Delete', 'simple-download-monitor') . '</a>', $_REQUEST['page'], 'delete', $item['ID'], $item['row_id'], $delete_log_nonce),
|
47 |
);
|
48 |
|
49 |
//Return the title contents
|
59 |
return sprintf(
|
60 |
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
61 |
/* $1%s */ $this->_args['singular'], //Let's simply repurpose the table's singular label ("Download")
|
62 |
+
/* $2%s */ $item['row_id'] //The value of the checkbox should be the record's id
|
63 |
);
|
64 |
}
|
65 |
|
80 |
function get_sortable_columns() {
|
81 |
|
82 |
$sortable_columns = array(
|
83 |
+
'title' => array('post_title', false), //true means it's already sorted
|
84 |
+
'URL' => array('file_url', false),
|
85 |
'visitor_ip' => array('visitor_ip', false),
|
86 |
+
'date' => array('date_time', false),
|
87 |
'visitor_country' => array('visitor_country', false),
|
88 |
'visitor_name' => array('visitor_name', false)
|
89 |
);
|
94 |
|
95 |
$actions = array();
|
96 |
$actions['delete2'] = __('Delete Permanently', 'simple-download-monitor');
|
|
|
|
|
97 |
|
98 |
return $actions;
|
99 |
}
|
100 |
|
101 |
function process_bulk_action() {
|
102 |
|
103 |
+
// if bulk 'Delete Permanently' was clicked
|
104 |
+
if ('delete2' === $this->current_action()) {
|
105 |
|
106 |
+
//Check bulk delete nonce
|
107 |
$nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
|
108 |
$action = 'bulk-' . $this->_args['plural'];
|
109 |
|
110 |
+
if (!wp_verify_nonce($nonce, $action)){
|
111 |
wp_die(__('Nope! Security check failed!', 'simple-download-monitor'));
|
112 |
+
}
|
113 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
if (!isset($_POST['download']) || $_POST['download'] == null) {
|
115 |
echo '<div id="message" class="updated fade"><p><strong>' . __('No entries were selected.', 'simple-download-monitor') . '</strong></p><p><em>' . __('Click to Dismiss', 'simple-download-monitor') . '</em></p></div>';
|
116 |
return;
|
117 |
}
|
118 |
|
119 |
foreach ($_POST['download'] as $item) {
|
120 |
+
$row_id = sanitize_text_field($item);
|
121 |
+
if (!is_numeric($row_id)){
|
122 |
+
wp_die(__('Error! The row id value of a log entry must be numeric.', 'simple-download-monitor'));
|
123 |
+
}
|
124 |
|
125 |
global $wpdb;
|
126 |
+
$del_row = $wpdb->query('DELETE FROM ' . $wpdb->prefix . 'sdm_downloads WHERE id = "' . $row_id . '"');
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
if ($del_row) {
|
129 |
echo '<div id="message" class="updated fade"><p><strong>' . __('Entries Deleted!', 'simple-download-monitor') . '</strong></p><p><em>' . __('Click to Dismiss', 'simple-download-monitor') . '</em></p></div>';
|
135 |
// If single entry 'Delete' was clicked
|
136 |
if ('delete' === $this->current_action()) {
|
137 |
|
138 |
+
//Check bulk delete nonce
|
139 |
+
$nonce = filter_input(INPUT_GET, '_wpnonce', FILTER_SANITIZE_STRING);
|
140 |
+
$action = 'sdm_delete_log_entry';
|
141 |
+
if (!wp_verify_nonce($nonce, $action)){
|
142 |
+
wp_die(__('Nope! Security check failed!', 'simple-download-monitor'));
|
143 |
+
}
|
144 |
+
|
145 |
+
//Grab the row id
|
146 |
+
$row_id = filter_input(INPUT_GET, 'row_id', FILTER_SANITIZE_STRING);
|
147 |
+
|
148 |
global $wpdb;
|
149 |
+
$del_row = $wpdb->query('DELETE FROM ' . $wpdb->prefix . 'sdm_downloads WHERE id = "' . $row_id . '"');
|
|
|
|
|
|
|
|
|
150 |
if ($del_row) {
|
151 |
echo '<div id="message" class="updated fade"><p><strong>' . __('Entry Deleted!', 'simple-download-monitor') . '</strong></p><p><em>' . __('Click to Dismiss', 'simple-download-monitor') . '</em></p></div>';
|
152 |
} else {
|
158 |
function prepare_items() {
|
159 |
|
160 |
global $wpdb; //This is used only if making any database queries
|
161 |
+
$per_page = apply_filters('sdm_download_logs_menu_items_per_page', 50);
|
162 |
$columns = $this->get_columns();
|
163 |
$hidden = array();
|
164 |
$sortable = $this->get_sortable_columns();
|
167 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
168 |
$this->process_bulk_action();
|
169 |
|
170 |
+
// Grab the sort inputs then sanitize the values before using it in the query. Use a whitelist approach to sanitize it.
|
171 |
+
$orderby_column = isset($_GET['orderby'])? sanitize_text_field($_GET['orderby']):'';
|
172 |
+
$sort_order = isset($_GET['order'])? sanitize_text_field($_GET['order']):'';
|
173 |
if(empty($orderby_column)){
|
174 |
+
$orderby_column = "date_time";
|
175 |
+
$sort_order = "DESC";
|
176 |
}
|
177 |
+
$orderby_column = sdm_sanitize_value_by_array($orderby_column, array('post_title'=>'1', 'file_url'=>'1', 'visitor_ip'=>'1', 'date_time'=>'1', 'visitor_country'=>'1', 'visitor_name'=>'1'));
|
178 |
+
$sort_order = sdm_sanitize_value_by_array($sort_order, array('DESC' => '1', 'ASC' => '1'));
|
179 |
+
|
180 |
//Do a query to find the total number of rows then calculate the query limit
|
181 |
$table_name = $wpdb->prefix . 'sdm_downloads';
|
182 |
$query = "SELECT COUNT(*) FROM $table_name";
|
192 |
//Prepare the array with the correct index names that the table is expecting.
|
193 |
$data = array();
|
194 |
foreach ($data_results as $data_result) {
|
195 |
+
$data[] = array('row_id' => $data_result->id, 'ID' => $data_result->post_id, 'title' => $data_result->post_title, 'URL' => $data_result->file_url, 'visitor_ip' => $data_result->visitor_ip, 'date' => $data_result->date_time, 'visitor_country' => $data_result->visitor_country, 'visitor_name' => $data_result->visitor_name);
|
196 |
}
|
197 |
|
198 |
// Now we add our *sorted* data to the items property, where it can be used by the rest of the class.
|
includes/sdm-utility-functions-admin-side.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function sdm_export_download_logs_to_csv() {
|
4 |
+
|
5 |
+
global $wpdb;
|
6 |
+
$table_name = $wpdb->prefix . 'sdm_downloads';
|
7 |
+
$resultset = $wpdb->get_results("SELECT * FROM $table_name ORDER BY id DESC", OBJECT);
|
8 |
+
|
9 |
+
$csv_file_path = WP_SIMPLE_DL_MONITOR_PATH . "sdm-download-logs.csv";
|
10 |
+
$fp = fopen($csv_file_path, 'w');
|
11 |
+
|
12 |
+
$header_names = array("Log ID", "Download ID", "Download Title", "File URL", "Date", "IP Address", "Country", "Name");
|
13 |
+
fputcsv($fp, $header_names);
|
14 |
+
|
15 |
+
foreach ($resultset as $result) {
|
16 |
+
if (empty($result->purchase_qty)) {
|
17 |
+
$result->purchase_qty = 1;
|
18 |
+
}
|
19 |
+
|
20 |
+
$fields = array($result->id, $result->post_id, $result->post_title, $result->file_url, $result->date_time, $result->visitor_ip, $result->visitor_country, $result->visitor_name);
|
21 |
+
fputcsv($fp, $fields);
|
22 |
+
}
|
23 |
+
|
24 |
+
fclose($fp);
|
25 |
+
|
26 |
+
$file_url = WP_SIMPLE_DL_MONITOR_URL . '/sdm-download-logs.csv';
|
27 |
+
return $file_url;
|
28 |
+
}
|
includes/sdm-utility-functions.php
CHANGED
@@ -34,6 +34,17 @@ function sdm_get_item_description_output($id){
|
|
34 |
return $isset_item_description;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
//Use this function to redirect to a URL
|
38 |
function sdm_redirect_to_url($url, $delay = '0', $exit = '1') {
|
39 |
$url = apply_filters('sdm_before_redirect_to_url',$url);
|
@@ -117,4 +128,17 @@ function sdm_ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) {
|
|
117 |
}
|
118 |
}
|
119 |
return $output;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
34 |
return $isset_item_description;
|
35 |
}
|
36 |
|
37 |
+
function sdm_get_password_entry_form($id) {
|
38 |
+
$action_url = WP_SIMPLE_DL_MONITOR_SITE_HOME_URL . '/?smd_process_download=1&download_id=' . $id;
|
39 |
+
$data = __('Enter Password to Download:', 'simple-download-monitor');
|
40 |
+
$data .= '<form action="'.$action_url.'" method="post" >';
|
41 |
+
$data .= '<input type="password" name="pass_text" class="sdm_pass_text" value="" /> ';
|
42 |
+
$data .= '<input type="submit" name="sdm_dl_pass_submit" class="pass_sumbit" value="' . __('Submit', 'simple-download-monitor') . '" />';
|
43 |
+
$data .= '<input type="hidden" name="download_id" value="' . $id . '" />';
|
44 |
+
$data .= '</form>';
|
45 |
+
return $data;
|
46 |
+
}
|
47 |
+
|
48 |
//Use this function to redirect to a URL
|
49 |
function sdm_redirect_to_url($url, $delay = '0', $exit = '1') {
|
50 |
$url = apply_filters('sdm_before_redirect_to_url',$url);
|
128 |
}
|
129 |
}
|
130 |
return $output;
|
131 |
+
}
|
132 |
+
|
133 |
+
/*
|
134 |
+
* 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.
|
135 |
+
*/
|
136 |
+
function sdm_sanitize_value_by_array($to_check, $valid_values)
|
137 |
+
{
|
138 |
+
$keys = array_keys($valid_values);
|
139 |
+
$keys = array_map('strtolower', $keys);
|
140 |
+
if (in_array($to_check, $keys)) {
|
141 |
+
return $to_check;
|
142 |
+
}
|
143 |
+
return reset($keys);//Return the first element from the valid values
|
144 |
}
|
includes/templates/fancy1/sdm-fancy-1.php
CHANGED
@@ -120,7 +120,9 @@ function sdm_generate_fancy1_display_output($args) {
|
|
120 |
$output .= '<div class="sdm_download_description">' . $isset_item_description . '</div>';
|
121 |
$output .= '<div class="sdm_download_link">';
|
122 |
$output .= '<span class="sdm_download_button">' . $download_button_code . '</span>';
|
123 |
-
$
|
|
|
|
|
124 |
$output .= '</div>'; //end .sdm_download_link
|
125 |
$output .= '</div>'; //end .sdm_download_item
|
126 |
|
120 |
$output .= '<div class="sdm_download_description">' . $isset_item_description . '</div>';
|
121 |
$output .= '<div class="sdm_download_link">';
|
122 |
$output .= '<span class="sdm_download_button">' . $download_button_code . '</span>';
|
123 |
+
if(!isset($main_opts['general_hide_donwload_count'])) {//The hide download count is enabled.
|
124 |
+
$output .= '<span class="sdm_download_item_count">' . $download_count_string . '</span>';
|
125 |
+
}
|
126 |
$output .= '</div>'; //end .sdm_download_link
|
127 |
$output .= '</div>'; //end .sdm_download_item
|
128 |
|
js/sdm_admin_scripts.js
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
jQuery(document).ready(function($){
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
tb_show(
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
});
|
15 |
-
|
16 |
-
// Run media uploader for thumbnail upload
|
17 |
-
$('#upload_thumbnail_button').click(function() {
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
window.send_to_editor = function(html) {
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
});
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
});
|
1 |
+
jQuery(document).ready(function($) {
|
2 |
+
|
3 |
+
// Run media uploader for file upload
|
4 |
+
$('#upload_image_button').click(function() {
|
5 |
+
|
6 |
+
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
|
7 |
+
|
8 |
+
window.send_to_editor = function(html) {
|
9 |
+
|
10 |
+
imgurl = $(html).attr('href');
|
11 |
+
$('#sdm_upload').val(imgurl);
|
12 |
+
tb_remove();
|
13 |
+
}
|
14 |
});
|
|
|
|
|
|
|
15 |
|
16 |
+
// Run media uploader for thumbnail upload
|
17 |
+
$('#upload_thumbnail_button').click(function() {
|
18 |
+
|
19 |
+
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
|
20 |
+
|
21 |
window.send_to_editor = function(html) {
|
22 |
|
23 |
+
imgurl = $(html).attr('href');
|
24 |
+
$('#sdm_thumbnail_image').remove();
|
25 |
+
$('#sdm_admin_thumb_preview').html('<img id="sdm_thumbnail_image" src="' + imgurl + '" style="max-width:200px;" />');
|
26 |
+
|
27 |
+
$('#sdm_upload_thumbnail').val(imgurl);
|
28 |
+
tb_remove();
|
29 |
+
}
|
30 |
});
|
31 |
+
|
32 |
+
// Remove thumbnail image from CPT
|
33 |
+
$('#remove_thumbnail_button').click(function() {
|
34 |
+
$.post(
|
35 |
+
sdm_admin_ajax_url.sdm_admin_ajax_url,
|
36 |
+
{
|
37 |
+
action: 'sdm_remove_thumbnail_image',
|
38 |
+
post_id_del: sdm_del_thumb_postid
|
39 |
+
},
|
40 |
+
function(response) {
|
41 |
+
if (response) { // ** If response was successful
|
42 |
+
$('#sdm_thumbnail_image').remove();
|
43 |
+
$('#sdm_upload_thumbnail').val('');
|
44 |
+
alert(sdm_translations.image_removed);
|
45 |
+
}
|
46 |
+
else { // ** Else response was unsuccessful
|
47 |
+
alert(sdm_translations.ajax_error);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
);
|
51 |
+
});
|
52 |
+
|
53 |
});
|
js/sdm_wp_scripts.js
CHANGED
@@ -1,81 +1,47 @@
|
|
1 |
// Simple Download Monitor frontend scripts
|
2 |
|
3 |
jQuery(document).ready(function($) {
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$('.pass_sumbit').click(function() {
|
50 |
-
|
51 |
-
this_button_id = $(this).next().val(); // Get download cpt id from hidden input field
|
52 |
-
password_attempt = $(this).prev().val(); // Get password text
|
53 |
-
|
54 |
-
$.post(
|
55 |
-
sdm_ajax_script.ajaxurl,
|
56 |
-
{
|
57 |
-
action: 'sdm_check_pass',
|
58 |
-
pass_val: password_attempt,
|
59 |
-
button_id: this_button_id
|
60 |
-
},
|
61 |
-
function(response) {
|
62 |
-
|
63 |
-
if(response) { // ** If response was successful
|
64 |
-
|
65 |
-
if(response.success === 'no') { // If the password match failed
|
66 |
-
|
67 |
-
alert(sdm_frontend_translations.incorrect_password);
|
68 |
-
$('.pass_text').val(''); // Clear password field
|
69 |
-
}
|
70 |
-
|
71 |
-
if(response.url != '') { // If the password match was a success
|
72 |
-
|
73 |
-
window.location.href = response.url; // Redirect to download url
|
74 |
-
$('.pass_text').val(''); // Clear password field
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
78 |
-
);
|
79 |
-
});
|
80 |
-
|
81 |
});
|
1 |
// Simple Download Monitor frontend scripts
|
2 |
|
3 |
jQuery(document).ready(function($) {
|
4 |
+
|
5 |
+
// Populate all nested titles and links
|
6 |
+
$('li.sdm_cat').each(function() {
|
7 |
+
|
8 |
+
var $this = $(this);
|
9 |
+
this_slug = $this.attr('id');
|
10 |
+
this_id = $this.children('.sdm_cat_title').attr('id');
|
11 |
+
|
12 |
+
// Run ajax
|
13 |
+
$.post(
|
14 |
+
sdm_ajax_script.ajaxurl,
|
15 |
+
{
|
16 |
+
action: 'sdm_pop_cats',
|
17 |
+
cat_slug: this_slug,
|
18 |
+
parent_id: this_id
|
19 |
+
},
|
20 |
+
function(response) {
|
21 |
+
|
22 |
+
// Loop array returned from ajax function
|
23 |
+
$.each(response.final_array, function(key, value) {
|
24 |
+
|
25 |
+
// Populate each matched post title and permalink
|
26 |
+
$this.children('.sdm_placeholder').append('<a href="' + value['permalink'] + '"><span class="sdm_post_title" style="cursor:pointer;">' + value['title'] + '</span></a>');
|
27 |
+
});
|
28 |
+
|
29 |
+
$this.children('span').append('<span style="margin-left:5px;" class="sdm_arrow">↨</span>');
|
30 |
+
}
|
31 |
+
);
|
32 |
+
});
|
33 |
+
|
34 |
+
// Hide results on page load
|
35 |
+
$('li.sdm_cat').children('.sdm_placeholder').hide();
|
36 |
+
|
37 |
+
// Slide toggle for each list item
|
38 |
+
$('body').on('click', '.sdm_cat_title', function(e) {
|
39 |
+
|
40 |
+
// If there is any html.. then we have more elements
|
41 |
+
if ($(this).next().html() != '') {
|
42 |
+
|
43 |
+
$(this).next().slideToggle(); // toggle div titles
|
44 |
+
}
|
45 |
+
});
|
46 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
});
|
main.php
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
if (!defined('ABSPATH')) {
|
13 |
exit;
|
14 |
}
|
15 |
|
16 |
-
define('WP_SIMPLE_DL_MONITOR_VERSION', '3.
|
17 |
define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
|
18 |
define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
|
19 |
define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
|
@@ -24,6 +23,7 @@ $sdm_db_version = '1.2';
|
|
24 |
|
25 |
//File includes
|
26 |
include_once('includes/sdm-utility-functions.php');
|
|
|
27 |
include_once('includes/sdm-logs-list-table.php');
|
28 |
include_once('includes/sdm-latest-downloads.php');
|
29 |
include_once('sdm-post-type-and-taxonomy.php');
|
@@ -55,10 +55,10 @@ function sdm_install_db_table() {
|
|
55 |
dbDelta($sql);
|
56 |
|
57 |
update_option('sdm_db_version', $sdm_db_version);
|
58 |
-
|
59 |
//Register the post type so you can flush the rewrite rules
|
60 |
sdm_register_post_type();
|
61 |
-
|
62 |
// Flush rules after install/activation
|
63 |
flush_rewrite_rules();
|
64 |
}
|
@@ -67,6 +67,7 @@ function sdm_install_db_table() {
|
|
67 |
* * Handle Plugins loaded tasks
|
68 |
*/
|
69 |
add_action('plugins_loaded', 'sdm_plugins_loaded_tasks');
|
|
|
70 |
function sdm_plugins_loaded_tasks() {
|
71 |
//Load language
|
72 |
load_plugin_textdomain('simple-download-monitor', false, dirname(plugin_basename(__FILE__)) . '/langs/');
|
@@ -74,17 +75,17 @@ function sdm_plugins_loaded_tasks() {
|
|
74 |
//Handle db upgrade stuff
|
75 |
sdm_db_update_check();
|
76 |
}
|
|
|
77 |
/*
|
78 |
* * Handle Generic Init tasks
|
79 |
*/
|
80 |
add_action('init', 'sdm_init_time_tasks');
|
81 |
-
|
82 |
-
{
|
83 |
//Handle download request if any
|
84 |
handle_sdm_download_via_direct_post();
|
85 |
}
|
86 |
|
87 |
-
|
88 |
function sdm_db_update_check() {
|
89 |
if (is_admin()) {//Check if DB needs to be upgraded
|
90 |
global $sdm_db_version;
|
@@ -99,6 +100,7 @@ function sdm_db_update_check() {
|
|
99 |
* * Add a 'Settings' link to plugins list page
|
100 |
*/
|
101 |
add_filter('plugin_action_links', 'sdm_settings_link', 10, 2);
|
|
|
102 |
function sdm_settings_link($links, $file) {
|
103 |
static $this_plugin;
|
104 |
if (!$this_plugin)
|
@@ -133,7 +135,6 @@ class simpleDownloadManager {
|
|
133 |
add_action('admin_print_styles', array(&$this, 'sdm_admin_styles')); // Register admin styles
|
134 |
|
135 |
add_action('admin_init', array(&$this, 'sdm_register_options')); // Register admin options
|
136 |
-
|
137 |
//add_filter('post_row_actions', array(&$this, 'sdm_remove_view_link_cpt'), 10, 2); // Remove 'View' link in all downloads list view
|
138 |
}
|
139 |
}
|
@@ -170,8 +171,8 @@ class simpleDownloadManager {
|
|
170 |
var sdm_admin_ajax_url = {sdm_admin_ajax_url: '<?php echo admin_url('admin-ajax.php?action=ajax'); ?>'};
|
171 |
var sdm_plugin_url = '<?php echo plugins_url(); ?>';
|
172 |
var tinymce_langs = {
|
173 |
-
select_download_item: '<?php _e('Please select a Download Item:', 'simple-download-monitor') ?>',
|
174 |
-
download_title: '<?php _e('Download Title', 'simple-download-monitor') ?>',
|
175 |
include_fancy: '<?php _e('Include Fancy Box', 'simple-download-monitor') ?>',
|
176 |
open_new_window: '<?php _e('Open New Window', 'simple-download-monitor') ?>',
|
177 |
insert_shortcode: '<?php _e('Insert SDM Shortcode', 'simple-download-monitor') ?>'
|
@@ -181,13 +182,13 @@ class simpleDownloadManager {
|
|
181 |
}
|
182 |
|
183 |
public function sdm_frontend_scripts() {
|
|
|
|
|
|
|
|
|
184 |
|
185 |
-
//
|
186 |
-
|
187 |
-
<script type="text/javascript">
|
188 |
-
var sdm_frontend_translations = {incorrect_password: '<?php _e('Incorrect Password', 'simple-download-monitor') ?>'};
|
189 |
-
</script>
|
190 |
-
<?php
|
191 |
}
|
192 |
|
193 |
public function sdm_admin_styles() {
|
@@ -199,7 +200,6 @@ class simpleDownloadManager {
|
|
199 |
public function sdm_create_menu_pages() {
|
200 |
include_once('includes/sdm-admin-menu-handler.php');
|
201 |
sdm_handle_admin_menu();
|
202 |
-
|
203 |
}
|
204 |
|
205 |
public function sdm_create_upload_metabox() {
|
@@ -225,7 +225,7 @@ class simpleDownloadManager {
|
|
225 |
$old_description = get_post_meta($post->ID, 'sdm_description', true);
|
226 |
$sdm_description_field = array('textarea_name' => 'sdm_description');
|
227 |
wp_editor($old_description, "sdm_description_editor_content", $sdm_description_field);
|
228 |
-
|
229 |
wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');
|
230 |
}
|
231 |
|
@@ -247,7 +247,7 @@ class simpleDownloadManager {
|
|
247 |
$old_value = isset($old_thumbnail) ? $old_thumbnail : '';
|
248 |
_e('Manually enter a valid URL, or click "Select Image" to upload (or choose) the file thumbnail image.', 'simple-download-monitor');
|
249 |
echo '<br />';
|
250 |
-
|
251 |
?>
|
252 |
<br /><br />
|
253 |
<input id="sdm_upload_thumbnail" type="text" size="70" name="sdm_upload_thumbnail" value="<?php echo $old_value; ?>" placeholder="http://..." />
|
@@ -255,15 +255,15 @@ class simpleDownloadManager {
|
|
255 |
<input id="upload_thumbnail_button" type="button" class="button-primary" value="<?php _e('Select Image', 'simple-download-monitor'); ?>" />
|
256 |
<input id="remove_thumbnail_button" type="button" class="button" value="<?php _e('Remove Image', 'simple-download-monitor'); ?>" />
|
257 |
<br /><br />
|
258 |
-
|
259 |
<span id="sdm_admin_thumb_preview">
|
260 |
-
<?php
|
261 |
-
if (!empty($old_value)) {
|
262 |
-
?><img id="sdm_thumbnail_image" src="<?php echo $old_value; ?>" style="max-width:200px;" />
|
263 |
<?php
|
264 |
-
|
265 |
-
|
266 |
-
|
|
|
|
|
|
|
267 |
}
|
268 |
|
269 |
public function display_sdm_shortcode_meta_box($post) { // Shortcode metabox
|
@@ -280,7 +280,7 @@ class simpleDownloadManager {
|
|
280 |
public function display_sdm_stats_meta_box($post) { // Stats metabox
|
281 |
$old_count = get_post_meta($post->ID, 'sdm_count_offset', true);
|
282 |
$value = isset($old_count) && $old_count != '' ? $old_count : '0';
|
283 |
-
|
284 |
// Get checkbox for "disable download logging"
|
285 |
$no_logs = get_post_meta($post->ID, 'sdm_item_no_log', true);
|
286 |
$checked = isset($no_logs) && $no_logs === 'on' ? 'checked="checked"' : '';
|
@@ -296,12 +296,12 @@ class simpleDownloadManager {
|
|
296 |
_e('Offset Count', 'simple-download-monitor');
|
297 |
echo ' <input type="text" style="width:50px;" name="sdm_count_offset" value="' . $value . '" />';
|
298 |
echo ' <img src="' . WP_SIMPLE_DL_MONITOR_URL . '/css/images/info.png" style="margin-left:10px;" title="Enter any positive or negative numerical value; to offset the download count shown, when using the download counter shortcode." />';
|
299 |
-
|
300 |
echo '<br /><br />';
|
301 |
-
echo '<input type="checkbox" name="sdm_item_no_log" '
|
302 |
echo '<span style="margin-left: 5px;"></span>';
|
303 |
_e('Disable download logging for this item.', 'simple-download-monitor');
|
304 |
-
|
305 |
wp_nonce_field('sdm_count_offset_nonce', 'sdm_count_offset_nonce_check');
|
306 |
}
|
307 |
|
@@ -348,12 +348,11 @@ class simpleDownloadManager {
|
|
348 |
|
349 |
update_post_meta($post_id, 'sdm_count_offset', $_POST['sdm_count_offset']);
|
350 |
}
|
351 |
-
|
352 |
// Checkbox for disabling download logging for this item
|
353 |
-
if(isset($_POST['sdm_item_no_log'])) {
|
354 |
update_post_meta($post_id, 'sdm_item_no_log', $_POST['sdm_item_no_log']);
|
355 |
-
}
|
356 |
-
else {
|
357 |
delete_post_meta($post_id, 'sdm_item_no_log');
|
358 |
}
|
359 |
}
|
@@ -370,36 +369,57 @@ class simpleDownloadManager {
|
|
370 |
|
371 |
public function sdm_register_options() {
|
372 |
|
|
|
373 |
register_setting('sdm_downloads_options', 'sdm_downloads_options');
|
|
|
|
|
|
|
374 |
add_settings_section('admin_options', __('Admin Options', 'simple-download-monitor'), array($this, 'admin_options_cb'), 'admin_options_section');
|
375 |
add_settings_section('sdm_colors', __('Colors', 'simple-download-monitor'), array($this, 'sdm_colors_cb'), 'sdm_colors_section');
|
376 |
|
|
|
|
|
|
|
377 |
add_settings_field('admin_tinymce_button', __('Remove Tinymce Button', 'simple-download-monitor'), array($this, 'admin_tinymce_button_cb'), 'admin_options_section', 'admin_options');
|
378 |
add_settings_field('admin_log_unique', __('Log Unique IP', 'simple-download-monitor'), array($this, 'admin_log_unique'), 'admin_options_section', 'admin_options');
|
379 |
add_settings_field('admin_no_logs', __('Disable Download Logs', 'simple-download-monitor'), array($this, 'admin_no_logs_cb'), 'admin_options_section', 'admin_options');
|
|
|
380 |
add_settings_field('download_button_color', __('Download Button Color', 'simple-download-monitor'), array($this, 'download_button_color_cb'), 'sdm_colors_section', 'sdm_colors');
|
381 |
}
|
382 |
|
|
|
|
|
|
|
|
|
|
|
383 |
public function admin_options_cb() {
|
|
|
384 |
_e('Admin options settings', 'simple-download-monitor');
|
385 |
}
|
386 |
|
387 |
public function sdm_colors_cb() {
|
|
|
388 |
_e('Front End colors settings', 'simple-download-monitor');
|
389 |
}
|
390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
public function admin_tinymce_button_cb() {
|
392 |
$main_opts = get_option('sdm_downloads_options');
|
393 |
echo '<input name="sdm_downloads_options[admin_tinymce_button]" id="admin_tinymce_button" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_tinymce_button']), false) . ' /> ';
|
394 |
_e('Removes the SDM Downloads button from the WP content editor.', 'simple-download-monitor');
|
395 |
}
|
396 |
-
|
397 |
public function admin_log_unique() {
|
398 |
$main_opts = get_option('sdm_downloads_options');
|
399 |
echo '<input name="sdm_downloads_options[admin_log_unique]" id="admin_log_unique" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_log_unique']), false) . ' /> ';
|
400 |
_e('Only logs downloads from unique IP addresses.', 'simple-download-monitor');
|
401 |
}
|
402 |
-
|
403 |
public function admin_no_logs_cb() {
|
404 |
$main_opts = get_option('sdm_downloads_options');
|
405 |
echo '<input name="sdm_downloads_options[admin_no_logs]" id="admin_no_logs" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_no_logs']), false) . ' /> ';
|
@@ -421,92 +441,85 @@ class simpleDownloadManager {
|
|
421 |
_e('Adjusts the color of the "Download Now" button.', 'simple-download-monitor');
|
422 |
}
|
423 |
|
424 |
-
}
|
425 |
|
|
|
426 |
$simpleDownloadManager = new simpleDownloadManager();
|
427 |
|
428 |
-
|
429 |
-
$data = __('Enter Password to Download:', 'simple-download-monitor');
|
430 |
-
$data .= '<form method="post">';
|
431 |
-
$data .= '<input type="password" class="pass_text" value="" /> ';
|
432 |
-
$data .= '<input type="button" class="pass_sumbit" value="' . __('Submit', 'simple-download-monitor') . '" />';
|
433 |
-
$data .= '<input type="hidden" value="' . $id . '" />';
|
434 |
-
$data .= '</form>';
|
435 |
-
return $data;
|
436 |
-
}
|
437 |
-
|
438 |
-
/*
|
439 |
-
* * Register scripts for front-end posts/pages
|
440 |
-
*/
|
441 |
-
add_action('wp_enqueue_scripts', 'sdm_wp_scripts');
|
442 |
-
|
443 |
-
function sdm_wp_scripts() {
|
444 |
-
|
445 |
-
wp_enqueue_style('sdm-styles', WP_SIMPLE_DL_MONITOR_URL . '/css/sdm_wp_styles.css');
|
446 |
-
wp_register_script('sdm-scripts', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_wp_scripts.js', array('jquery'));
|
447 |
-
wp_enqueue_script('sdm-scripts');
|
448 |
-
|
449 |
-
// Localize ajax script for frontend
|
450 |
-
wp_localize_script('sdm-scripts', 'sdm_ajax_script', array('ajaxurl' => admin_url('admin-ajax.php')));
|
451 |
-
}
|
452 |
-
|
453 |
function handle_sdm_download_via_direct_post() {
|
454 |
if (isset($_REQUEST['smd_process_download']) && $_REQUEST['smd_process_download'] == '1') {
|
455 |
global $wpdb;
|
456 |
$download_id = strip_tags($_REQUEST['download_id']);
|
457 |
$download_title = get_the_title($download_id);
|
458 |
$download_link = get_post_meta($download_id, 'sdm_upload', true);
|
459 |
-
|
460 |
//Do some validation checks
|
461 |
-
if(empty($download_id)){
|
462 |
wp_die(__('Error! Incorrect download item id.', 'simple-download-monitor'));
|
463 |
}
|
464 |
-
if(empty($download_link)){
|
465 |
-
wp_die(__('Error! This download item ('
|
466 |
}
|
467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
$ipaddress = $_SERVER["REMOTE_ADDR"];
|
469 |
$date_time = current_time('mysql');
|
470 |
$visitor_country = sdm_ip_info('Visitor', 'Country');
|
471 |
-
|
472 |
-
if(is_user_logged_in()) { // Get user name (if logged in)
|
473 |
global $current_user;
|
474 |
get_currentuserinfo();
|
475 |
$visitor_name = $current_user->user_login;
|
|
|
|
|
476 |
}
|
477 |
-
|
478 |
-
$visitor_name = __('Not Logged In','simple-download-monitor');
|
479 |
-
}
|
480 |
-
|
481 |
// Get option for global disabling of download logging
|
482 |
$main_option = get_option('sdm_downloads_options');
|
483 |
$no_logs = isset($main_option['admin_no_logs']);
|
484 |
-
|
485 |
// Get optoin for logging only unique IPs
|
486 |
$unique_ips = isset($main_option['admin_log_unique']);
|
487 |
-
|
488 |
// Get post meta for individual disabling of download logging
|
489 |
$get_meta = get_post_meta($download_id, 'sdm_item_no_log', true);
|
490 |
$item_logging_checked = isset($get_meta) && $get_meta === 'on' ? 'on' : 'off';
|
491 |
-
|
492 |
$dl_logging_needed = true;
|
493 |
-
|
494 |
// Check if download logs have been disabled (globally or per download item)
|
495 |
if ($no_logs === true || $item_logging_checked === 'on') {
|
496 |
-
$dl_logging_needed = false;
|
497 |
}
|
498 |
|
499 |
// Check if we are only logging unique ips
|
500 |
-
if($unique_ips === true) {
|
501 |
-
$check_ip = $wpdb->get_results('SELECT * FROM '
|
502 |
|
503 |
//This IP is already logged for this download item. No need to log it again.
|
504 |
-
if($check_ip){
|
505 |
$dl_logging_needed = false;
|
506 |
}
|
507 |
}
|
508 |
-
|
509 |
-
if($dl_logging_needed){
|
510 |
// We need to log this download.
|
511 |
$table = $wpdb->prefix . 'sdm_downloads';
|
512 |
$data = array(
|
@@ -519,7 +532,7 @@ function handle_sdm_download_via_direct_post() {
|
|
519 |
'visitor_name' => $visitor_name
|
520 |
);
|
521 |
|
522 |
-
$data = array_filter($data)
|
523 |
$insert_table = $wpdb->insert($table, $data);
|
524 |
|
525 |
if ($insert_table) {
|
@@ -529,7 +542,7 @@ function handle_sdm_download_via_direct_post() {
|
|
529 |
wp_die(__('Error! Failed to log the download request in the database table', 'simple-download-monitor'));
|
530 |
}
|
531 |
}
|
532 |
-
|
533 |
//Downoad the item
|
534 |
sdm_redirect_to_url($download_link);
|
535 |
exit;
|
@@ -548,7 +561,6 @@ function sdm_tiny_get_post_ids_ajax_call() {
|
|
548 |
$loop = new WP_Query($args);
|
549 |
$test = '';
|
550 |
foreach ($loop->posts as $loop_post) {
|
551 |
-
//$test .= $loop_post->ID.'|'.$loop_post->post_title.'_';
|
552 |
$test[] = array('post_id' => $loop_post->ID, 'post_title' => $loop_post->post_title);
|
553 |
}
|
554 |
|
@@ -559,12 +571,18 @@ function sdm_tiny_get_post_ids_ajax_call() {
|
|
559 |
exit;
|
560 |
}
|
561 |
|
562 |
-
//
|
563 |
-
add_action('wp_ajax_nopriv_sdm_remove_thumbnail_image', '
|
564 |
-
add_action('wp_ajax_sdm_remove_thumbnail_image', 'sdm_remove_thumbnail_image_ajax_call')
|
565 |
|
566 |
function sdm_remove_thumbnail_image_ajax_call() {
|
|
|
|
|
|
|
|
|
|
|
567 |
|
|
|
568 |
$post_id = $_POST['post_id_del'];
|
569 |
$success = delete_post_meta($post_id, 'sdm_upload_thumbnail');
|
570 |
if ($success) {
|
@@ -576,95 +594,6 @@ function sdm_remove_thumbnail_image_ajax_call() {
|
|
576 |
exit;
|
577 |
}
|
578 |
|
579 |
-
// Check download password
|
580 |
-
add_action('wp_ajax_nopriv_sdm_check_pass', 'sdm_check_pass_ajax_call');
|
581 |
-
add_action('wp_ajax_sdm_check_pass', 'sdm_check_pass_ajax_call');
|
582 |
-
|
583 |
-
function sdm_check_pass_ajax_call() {
|
584 |
-
|
585 |
-
global $wpdb;
|
586 |
-
$button_id = $_POST['button_id']; // Get button cpt id
|
587 |
-
$pass_val = $_POST['pass_val']; // Get password attempt
|
588 |
-
$success = '';
|
589 |
-
$download_link = '';
|
590 |
-
|
591 |
-
// Get post object
|
592 |
-
$post_object = get_post($button_id);
|
593 |
-
// Get post password
|
594 |
-
$post_pass = $post_object->post_password;
|
595 |
-
|
596 |
-
// Check if password is a match
|
597 |
-
if ($post_pass != $pass_val) { // Match is a failure
|
598 |
-
$success = 'no'; // Pass back to ajax
|
599 |
-
} else { // Match is a success
|
600 |
-
$success = 'yes'; // Pass back to ajax
|
601 |
-
|
602 |
-
$download_id = $button_id;
|
603 |
-
$download_title = get_the_title($download_id);
|
604 |
-
$download_link = get_post_meta($download_id, 'sdm_upload', true);
|
605 |
-
$ipaddress = $_SERVER["REMOTE_ADDR"];
|
606 |
-
$date_time = current_time('mysql');
|
607 |
-
$visitor_country = sdm_ip_info('Visitor', 'Country');
|
608 |
-
|
609 |
-
if(is_user_logged_in()) { // Get user name (if logged in)
|
610 |
-
global $current_user;
|
611 |
-
get_currentuserinfo();
|
612 |
-
$visitor_name = $current_user->user_login;
|
613 |
-
}
|
614 |
-
else {
|
615 |
-
$visitor_name = __('Not Logged In','simple-download-monitor');
|
616 |
-
}
|
617 |
-
|
618 |
-
// Get option for global disabling of download logging
|
619 |
-
$main_option = get_option('sdm_downloads_options');
|
620 |
-
$no_logs = isset($main_option['admin_no_logs']);
|
621 |
-
|
622 |
-
// Get optoin for logging only unique IPs
|
623 |
-
$unique_ips = isset($main_option['admin_log_unique']);
|
624 |
-
|
625 |
-
// Get post meta for individual disabling of download logging
|
626 |
-
$get_meta = get_post_meta($download_id, 'sdm_item_no_log', true);
|
627 |
-
$item_logging_checked = isset($get_meta) && $get_meta === 'on' ? 'on' : 'off';
|
628 |
-
|
629 |
-
$dl_logging_needed = true;
|
630 |
-
|
631 |
-
// Check if download logs have been disabled (globally or per download item)
|
632 |
-
if ($no_logs === true || $item_logging_checked === 'on') {
|
633 |
-
$dl_logging_needed = false;
|
634 |
-
}
|
635 |
-
|
636 |
-
// Check if we are only logging unique ips
|
637 |
-
if($unique_ips === true) {
|
638 |
-
$check_ip = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'sdm_downloads WHERE post_id="'.$download_id.'" AND visitor_ip = "'.$ipaddress.'"');
|
639 |
-
|
640 |
-
//This IP is already logged for this download item. No need to log it again.
|
641 |
-
if($check_ip){
|
642 |
-
$dl_logging_needed = false;
|
643 |
-
}
|
644 |
-
}
|
645 |
-
|
646 |
-
if($dl_logging_needed){
|
647 |
-
$table = $wpdb->prefix . 'sdm_downloads';
|
648 |
-
$data = array(
|
649 |
-
'post_id' => $download_id,
|
650 |
-
'post_title' => $download_title,
|
651 |
-
'file_url' => $download_link,
|
652 |
-
'visitor_ip' => $ipaddress,
|
653 |
-
'date_time' => $date_time,
|
654 |
-
'visitor_country' => $visitor_country,
|
655 |
-
'visitor_name' => $visitor_name
|
656 |
-
);
|
657 |
-
$insert_table = $wpdb->insert($table, $data);
|
658 |
-
}
|
659 |
-
}
|
660 |
-
|
661 |
-
// Generate ajax response
|
662 |
-
$response = json_encode(array('success' => $success, 'url' => $download_link));
|
663 |
-
header('Content-Type: application/json');
|
664 |
-
echo $response;
|
665 |
-
exit;
|
666 |
-
}
|
667 |
-
|
668 |
// Populate category tree
|
669 |
add_action('wp_ajax_nopriv_sdm_pop_cats', 'sdm_pop_cats_ajax_call');
|
670 |
add_action('wp_ajax_sdm_pop_cats', 'sdm_pop_cats_ajax_call');
|
@@ -673,7 +602,6 @@ function sdm_pop_cats_ajax_call() {
|
|
673 |
|
674 |
$cat_slug = $_POST['cat_slug']; // Get button cpt slug
|
675 |
$parent_id = $_POST['parent_id']; // Get button cpt id
|
676 |
-
|
677 |
// Query custom posts based on taxonomy slug
|
678 |
$posts = get_posts(array(
|
679 |
'post_type' => 'sdm_downloads',
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: Simple Download Monitor
|
4 |
+
* Plugin URI: https://www.tipsandtricks-hq.com/simple-wordpress-download-monitor-plugin
|
5 |
+
* Description: Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
|
6 |
+
* Version: 3.3.1
|
7 |
+
* Author: Tips and Tricks HQ, Ruhul Amin, Josh Lobe
|
8 |
+
* Author URI: https://www.tipsandtricks-hq.com/development-center
|
9 |
+
* License: GPL2
|
10 |
+
*/
|
|
|
11 |
if (!defined('ABSPATH')) {
|
12 |
exit;
|
13 |
}
|
14 |
|
15 |
+
define('WP_SIMPLE_DL_MONITOR_VERSION', '3.3.1');
|
16 |
define('WP_SIMPLE_DL_MONITOR_DIR_NAME', dirname(plugin_basename(__FILE__)));
|
17 |
define('WP_SIMPLE_DL_MONITOR_URL', plugins_url('', __FILE__));
|
18 |
define('WP_SIMPLE_DL_MONITOR_PATH', plugin_dir_path(__FILE__));
|
23 |
|
24 |
//File includes
|
25 |
include_once('includes/sdm-utility-functions.php');
|
26 |
+
include_once('includes/sdm-utility-functions-admin-side.php');
|
27 |
include_once('includes/sdm-logs-list-table.php');
|
28 |
include_once('includes/sdm-latest-downloads.php');
|
29 |
include_once('sdm-post-type-and-taxonomy.php');
|
55 |
dbDelta($sql);
|
56 |
|
57 |
update_option('sdm_db_version', $sdm_db_version);
|
58 |
+
|
59 |
//Register the post type so you can flush the rewrite rules
|
60 |
sdm_register_post_type();
|
61 |
+
|
62 |
// Flush rules after install/activation
|
63 |
flush_rewrite_rules();
|
64 |
}
|
67 |
* * Handle Plugins loaded tasks
|
68 |
*/
|
69 |
add_action('plugins_loaded', 'sdm_plugins_loaded_tasks');
|
70 |
+
|
71 |
function sdm_plugins_loaded_tasks() {
|
72 |
//Load language
|
73 |
load_plugin_textdomain('simple-download-monitor', false, dirname(plugin_basename(__FILE__)) . '/langs/');
|
75 |
//Handle db upgrade stuff
|
76 |
sdm_db_update_check();
|
77 |
}
|
78 |
+
|
79 |
/*
|
80 |
* * Handle Generic Init tasks
|
81 |
*/
|
82 |
add_action('init', 'sdm_init_time_tasks');
|
83 |
+
|
84 |
+
function sdm_init_time_tasks() {
|
85 |
//Handle download request if any
|
86 |
handle_sdm_download_via_direct_post();
|
87 |
}
|
88 |
|
|
|
89 |
function sdm_db_update_check() {
|
90 |
if (is_admin()) {//Check if DB needs to be upgraded
|
91 |
global $sdm_db_version;
|
100 |
* * Add a 'Settings' link to plugins list page
|
101 |
*/
|
102 |
add_filter('plugin_action_links', 'sdm_settings_link', 10, 2);
|
103 |
+
|
104 |
function sdm_settings_link($links, $file) {
|
105 |
static $this_plugin;
|
106 |
if (!$this_plugin)
|
135 |
add_action('admin_print_styles', array(&$this, 'sdm_admin_styles')); // Register admin styles
|
136 |
|
137 |
add_action('admin_init', array(&$this, 'sdm_register_options')); // Register admin options
|
|
|
138 |
//add_filter('post_row_actions', array(&$this, 'sdm_remove_view_link_cpt'), 10, 2); // Remove 'View' link in all downloads list view
|
139 |
}
|
140 |
}
|
171 |
var sdm_admin_ajax_url = {sdm_admin_ajax_url: '<?php echo admin_url('admin-ajax.php?action=ajax'); ?>'};
|
172 |
var sdm_plugin_url = '<?php echo plugins_url(); ?>';
|
173 |
var tinymce_langs = {
|
174 |
+
select_download_item: '<?php _e('Please select a Download Item:', 'simple-download-monitor') ?>',
|
175 |
+
download_title: '<?php _e('Download Title', 'simple-download-monitor') ?>',
|
176 |
include_fancy: '<?php _e('Include Fancy Box', 'simple-download-monitor') ?>',
|
177 |
open_new_window: '<?php _e('Open New Window', 'simple-download-monitor') ?>',
|
178 |
insert_shortcode: '<?php _e('Insert SDM Shortcode', 'simple-download-monitor') ?>'
|
182 |
}
|
183 |
|
184 |
public function sdm_frontend_scripts() {
|
185 |
+
//Use this function to enqueue fron-end js scripts.
|
186 |
+
wp_enqueue_style('sdm-styles', WP_SIMPLE_DL_MONITOR_URL . '/css/sdm_wp_styles.css');
|
187 |
+
wp_register_script('sdm-scripts', WP_SIMPLE_DL_MONITOR_URL . '/js/sdm_wp_scripts.js', array('jquery'));
|
188 |
+
wp_enqueue_script('sdm-scripts');
|
189 |
|
190 |
+
// Localize ajax script for frontend
|
191 |
+
wp_localize_script('sdm-scripts', 'sdm_ajax_script', array('ajaxurl' => admin_url('admin-ajax.php')));
|
|
|
|
|
|
|
|
|
192 |
}
|
193 |
|
194 |
public function sdm_admin_styles() {
|
200 |
public function sdm_create_menu_pages() {
|
201 |
include_once('includes/sdm-admin-menu-handler.php');
|
202 |
sdm_handle_admin_menu();
|
|
|
203 |
}
|
204 |
|
205 |
public function sdm_create_upload_metabox() {
|
225 |
$old_description = get_post_meta($post->ID, 'sdm_description', true);
|
226 |
$sdm_description_field = array('textarea_name' => 'sdm_description');
|
227 |
wp_editor($old_description, "sdm_description_editor_content", $sdm_description_field);
|
228 |
+
|
229 |
wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');
|
230 |
}
|
231 |
|
247 |
$old_value = isset($old_thumbnail) ? $old_thumbnail : '';
|
248 |
_e('Manually enter a valid URL, or click "Select Image" to upload (or choose) the file thumbnail image.', 'simple-download-monitor');
|
249 |
echo '<br />';
|
250 |
+
_e('This thumbnail image will be used to create a fancy file download box if you want to use it.', 'simple-download-monitor');
|
251 |
?>
|
252 |
<br /><br />
|
253 |
<input id="sdm_upload_thumbnail" type="text" size="70" name="sdm_upload_thumbnail" value="<?php echo $old_value; ?>" placeholder="http://..." />
|
255 |
<input id="upload_thumbnail_button" type="button" class="button-primary" value="<?php _e('Select Image', 'simple-download-monitor'); ?>" />
|
256 |
<input id="remove_thumbnail_button" type="button" class="button" value="<?php _e('Remove Image', 'simple-download-monitor'); ?>" />
|
257 |
<br /><br />
|
258 |
+
|
259 |
<span id="sdm_admin_thumb_preview">
|
|
|
|
|
|
|
260 |
<?php
|
261 |
+
if (!empty($old_value)) {
|
262 |
+
?><img id="sdm_thumbnail_image" src="<?php echo $old_value; ?>" style="max-width:200px;" />
|
263 |
+
<?php
|
264 |
+
}
|
265 |
+
?></span><?php
|
266 |
+
wp_nonce_field('sdm_thumbnail_box_nonce', 'sdm_thumbnail_box_nonce_check');
|
267 |
}
|
268 |
|
269 |
public function display_sdm_shortcode_meta_box($post) { // Shortcode metabox
|
280 |
public function display_sdm_stats_meta_box($post) { // Stats metabox
|
281 |
$old_count = get_post_meta($post->ID, 'sdm_count_offset', true);
|
282 |
$value = isset($old_count) && $old_count != '' ? $old_count : '0';
|
283 |
+
|
284 |
// Get checkbox for "disable download logging"
|
285 |
$no_logs = get_post_meta($post->ID, 'sdm_item_no_log', true);
|
286 |
$checked = isset($no_logs) && $no_logs === 'on' ? 'checked="checked"' : '';
|
296 |
_e('Offset Count', 'simple-download-monitor');
|
297 |
echo ' <input type="text" style="width:50px;" name="sdm_count_offset" value="' . $value . '" />';
|
298 |
echo ' <img src="' . WP_SIMPLE_DL_MONITOR_URL . '/css/images/info.png" style="margin-left:10px;" title="Enter any positive or negative numerical value; to offset the download count shown, when using the download counter shortcode." />';
|
299 |
+
|
300 |
echo '<br /><br />';
|
301 |
+
echo '<input type="checkbox" name="sdm_item_no_log" ' . $checked . ' />';
|
302 |
echo '<span style="margin-left: 5px;"></span>';
|
303 |
_e('Disable download logging for this item.', 'simple-download-monitor');
|
304 |
+
|
305 |
wp_nonce_field('sdm_count_offset_nonce', 'sdm_count_offset_nonce_check');
|
306 |
}
|
307 |
|
348 |
|
349 |
update_post_meta($post_id, 'sdm_count_offset', $_POST['sdm_count_offset']);
|
350 |
}
|
351 |
+
|
352 |
// Checkbox for disabling download logging for this item
|
353 |
+
if (isset($_POST['sdm_item_no_log'])) {
|
354 |
update_post_meta($post_id, 'sdm_item_no_log', $_POST['sdm_item_no_log']);
|
355 |
+
} else {
|
|
|
356 |
delete_post_meta($post_id, 'sdm_item_no_log');
|
357 |
}
|
358 |
}
|
369 |
|
370 |
public function sdm_register_options() {
|
371 |
|
372 |
+
//Register the main setting
|
373 |
register_setting('sdm_downloads_options', 'sdm_downloads_options');
|
374 |
+
|
375 |
+
//Add all the settings section that will go under the main settings
|
376 |
+
add_settings_section('general_options', __('General Options', 'simple-download-monitor'), array($this, 'general_options_cb'), 'general_options_section');
|
377 |
add_settings_section('admin_options', __('Admin Options', 'simple-download-monitor'), array($this, 'admin_options_cb'), 'admin_options_section');
|
378 |
add_settings_section('sdm_colors', __('Colors', 'simple-download-monitor'), array($this, 'sdm_colors_cb'), 'sdm_colors_section');
|
379 |
|
380 |
+
//Add all the individual settings fields that goes under the sections
|
381 |
+
add_settings_field('general_hide_donwload_count', __('Hide Download Count', 'simple-download-monitor'), array($this, 'hide_download_count_cb'), 'general_options_section', 'general_options');
|
382 |
+
|
383 |
add_settings_field('admin_tinymce_button', __('Remove Tinymce Button', 'simple-download-monitor'), array($this, 'admin_tinymce_button_cb'), 'admin_options_section', 'admin_options');
|
384 |
add_settings_field('admin_log_unique', __('Log Unique IP', 'simple-download-monitor'), array($this, 'admin_log_unique'), 'admin_options_section', 'admin_options');
|
385 |
add_settings_field('admin_no_logs', __('Disable Download Logs', 'simple-download-monitor'), array($this, 'admin_no_logs_cb'), 'admin_options_section', 'admin_options');
|
386 |
+
|
387 |
add_settings_field('download_button_color', __('Download Button Color', 'simple-download-monitor'), array($this, 'download_button_color_cb'), 'sdm_colors_section', 'sdm_colors');
|
388 |
}
|
389 |
|
390 |
+
public function general_options_cb() {
|
391 |
+
//Set the message that will be shown below the general options settings heading
|
392 |
+
_e('General options settings', 'simple-download-monitor');
|
393 |
+
}
|
394 |
+
|
395 |
public function admin_options_cb() {
|
396 |
+
//Set the message that will be shown below the admin options settings heading
|
397 |
_e('Admin options settings', 'simple-download-monitor');
|
398 |
}
|
399 |
|
400 |
public function sdm_colors_cb() {
|
401 |
+
//Set the message that will be shown below the color options settings heading
|
402 |
_e('Front End colors settings', 'simple-download-monitor');
|
403 |
}
|
404 |
|
405 |
+
public function hide_download_count_cb() {
|
406 |
+
$main_opts = get_option('sdm_downloads_options');
|
407 |
+
echo '<input name="sdm_downloads_options[general_hide_donwload_count]" id="general_hide_donwload_count" type="checkbox" ' . checked(1, isset($main_opts['general_hide_donwload_count']), false) . ' /> ';
|
408 |
+
_e('Hide the download count that is shown in some of the fancy templates.', 'simple-download-monitor');
|
409 |
+
}
|
410 |
+
|
411 |
public function admin_tinymce_button_cb() {
|
412 |
$main_opts = get_option('sdm_downloads_options');
|
413 |
echo '<input name="sdm_downloads_options[admin_tinymce_button]" id="admin_tinymce_button" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_tinymce_button']), false) . ' /> ';
|
414 |
_e('Removes the SDM Downloads button from the WP content editor.', 'simple-download-monitor');
|
415 |
}
|
416 |
+
|
417 |
public function admin_log_unique() {
|
418 |
$main_opts = get_option('sdm_downloads_options');
|
419 |
echo '<input name="sdm_downloads_options[admin_log_unique]" id="admin_log_unique" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_log_unique']), false) . ' /> ';
|
420 |
_e('Only logs downloads from unique IP addresses.', 'simple-download-monitor');
|
421 |
}
|
422 |
+
|
423 |
public function admin_no_logs_cb() {
|
424 |
$main_opts = get_option('sdm_downloads_options');
|
425 |
echo '<input name="sdm_downloads_options[admin_no_logs]" id="admin_no_logs" type="checkbox" class="sdm_opts_ajax_checkboxes" ' . checked(1, isset($main_opts['admin_no_logs']), false) . ' /> ';
|
441 |
_e('Adjusts the color of the "Download Now" button.', 'simple-download-monitor');
|
442 |
}
|
443 |
|
444 |
+
}//End of simpleDownloadManager class
|
445 |
|
446 |
+
//Initialize the simpleDownloadManager class
|
447 |
$simpleDownloadManager = new simpleDownloadManager();
|
448 |
|
449 |
+
//Handles the download request
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
function handle_sdm_download_via_direct_post() {
|
451 |
if (isset($_REQUEST['smd_process_download']) && $_REQUEST['smd_process_download'] == '1') {
|
452 |
global $wpdb;
|
453 |
$download_id = strip_tags($_REQUEST['download_id']);
|
454 |
$download_title = get_the_title($download_id);
|
455 |
$download_link = get_post_meta($download_id, 'sdm_upload', true);
|
456 |
+
|
457 |
//Do some validation checks
|
458 |
+
if (empty($download_id)) {
|
459 |
wp_die(__('Error! Incorrect download item id.', 'simple-download-monitor'));
|
460 |
}
|
461 |
+
if (empty($download_link)) {
|
462 |
+
wp_die(__('Error! This download item (' . $download_id . ') does not have any download link. Edit this item and specify a downloadable file URL for it.', 'simple-download-monitor'));
|
463 |
}
|
464 |
+
|
465 |
+
//Check download password (if applicable for this download)
|
466 |
+
$post_object = get_post($download_id);// Get post object
|
467 |
+
$post_pass = $post_object->post_password;// Get post password
|
468 |
+
if(!empty($post_pass)){//This download item has a password. So validate the password.
|
469 |
+
$pass_val = $_REQUEST['pass_text'];
|
470 |
+
if(empty($pass_val)){//No password was submitted with the downoad request.
|
471 |
+
wp_die(__('Error! This download requires a password.', 'simple-download-monitor'));
|
472 |
+
}
|
473 |
+
if ($post_pass != $pass_val) {
|
474 |
+
//Incorrect password submitted.
|
475 |
+
wp_die(__('Error! Incorrect password. This download requires a valid password.', 'simple-download-monitor'));
|
476 |
+
} else {
|
477 |
+
//Password is valid. Go ahead with the download
|
478 |
+
}
|
479 |
+
}
|
480 |
+
//End of password check
|
481 |
+
|
482 |
$ipaddress = $_SERVER["REMOTE_ADDR"];
|
483 |
$date_time = current_time('mysql');
|
484 |
$visitor_country = sdm_ip_info('Visitor', 'Country');
|
485 |
+
|
486 |
+
if (is_user_logged_in()) { // Get user name (if logged in)
|
487 |
global $current_user;
|
488 |
get_currentuserinfo();
|
489 |
$visitor_name = $current_user->user_login;
|
490 |
+
} else {
|
491 |
+
$visitor_name = __('Not Logged In', 'simple-download-monitor');
|
492 |
}
|
493 |
+
|
|
|
|
|
|
|
494 |
// Get option for global disabling of download logging
|
495 |
$main_option = get_option('sdm_downloads_options');
|
496 |
$no_logs = isset($main_option['admin_no_logs']);
|
497 |
+
|
498 |
// Get optoin for logging only unique IPs
|
499 |
$unique_ips = isset($main_option['admin_log_unique']);
|
500 |
+
|
501 |
// Get post meta for individual disabling of download logging
|
502 |
$get_meta = get_post_meta($download_id, 'sdm_item_no_log', true);
|
503 |
$item_logging_checked = isset($get_meta) && $get_meta === 'on' ? 'on' : 'off';
|
504 |
+
|
505 |
$dl_logging_needed = true;
|
506 |
+
|
507 |
// Check if download logs have been disabled (globally or per download item)
|
508 |
if ($no_logs === true || $item_logging_checked === 'on') {
|
509 |
+
$dl_logging_needed = false;
|
510 |
}
|
511 |
|
512 |
// Check if we are only logging unique ips
|
513 |
+
if ($unique_ips === true) {
|
514 |
+
$check_ip = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'sdm_downloads WHERE post_id="' . $download_id . '" AND visitor_ip = "' . $ipaddress . '"');
|
515 |
|
516 |
//This IP is already logged for this download item. No need to log it again.
|
517 |
+
if ($check_ip) {
|
518 |
$dl_logging_needed = false;
|
519 |
}
|
520 |
}
|
521 |
+
|
522 |
+
if ($dl_logging_needed) {
|
523 |
// We need to log this download.
|
524 |
$table = $wpdb->prefix . 'sdm_downloads';
|
525 |
$data = array(
|
532 |
'visitor_name' => $visitor_name
|
533 |
);
|
534 |
|
535 |
+
$data = array_filter($data); //Remove any null values.
|
536 |
$insert_table = $wpdb->insert($table, $data);
|
537 |
|
538 |
if ($insert_table) {
|
542 |
wp_die(__('Error! Failed to log the download request in the database table', 'simple-download-monitor'));
|
543 |
}
|
544 |
}
|
545 |
+
|
546 |
//Downoad the item
|
547 |
sdm_redirect_to_url($download_link);
|
548 |
exit;
|
561 |
$loop = new WP_Query($args);
|
562 |
$test = '';
|
563 |
foreach ($loop->posts as $loop_post) {
|
|
|
564 |
$test[] = array('post_id' => $loop_post->ID, 'post_title' => $loop_post->post_title);
|
565 |
}
|
566 |
|
571 |
exit;
|
572 |
}
|
573 |
|
574 |
+
//Remove Thumbnail Image
|
575 |
+
//add_action('wp_ajax_nopriv_sdm_remove_thumbnail_image', '');//This is only available to logged-in users
|
576 |
+
add_action('wp_ajax_sdm_remove_thumbnail_image', 'sdm_remove_thumbnail_image_ajax_call');//Execute this for authenticated users only
|
577 |
|
578 |
function sdm_remove_thumbnail_image_ajax_call() {
|
579 |
+
if(!current_user_can('edit_posts')){
|
580 |
+
//Permission denied
|
581 |
+
wp_die(__('Permission denied!', 'simple-download-monitor'));
|
582 |
+
exit;
|
583 |
+
}
|
584 |
|
585 |
+
//Go ahead with the thumbnail removal
|
586 |
$post_id = $_POST['post_id_del'];
|
587 |
$success = delete_post_meta($post_id, 'sdm_upload_thumbnail');
|
588 |
if ($success) {
|
594 |
exit;
|
595 |
}
|
596 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
// Populate category tree
|
598 |
add_action('wp_ajax_nopriv_sdm_pop_cats', 'sdm_pop_cats_ajax_call');
|
599 |
add_action('wp_ajax_sdm_pop_cats', 'sdm_pop_cats_ajax_call');
|
602 |
|
603 |
$cat_slug = $_POST['cat_slug']; // Get button cpt slug
|
604 |
$parent_id = $_POST['parent_id']; // Get button cpt id
|
|
|
605 |
// Query custom posts based on taxonomy slug
|
606 |
$posts = get_posts(array(
|
607 |
'post_type' => 'sdm_downloads',
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Simple Download Monitor ===
|
2 |
-
Contributors: Tips and Tricks HQ, Ruhul Amin, josh401
|
3 |
Donate link: https://www.tipsandtricks-hq.com
|
4 |
Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
|
@@ -156,6 +156,25 @@ For screenshots please visit the [download monitor plugin page](https://www.tips
|
|
156 |
|
157 |
== Changelog ==
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
= 3.2.8 =
|
160 |
- WordPress 4.4 compatibility.
|
161 |
|
1 |
=== Simple Download Monitor ===
|
2 |
+
Contributors: Tips and Tricks HQ, Ruhul Amin, josh401, mbrsolution
|
3 |
Donate link: https://www.tipsandtricks-hq.com
|
4 |
Tags: download, downloads, count, counter, tracker, tracking, hits, logging, monitor, manager, files, media, digital, download monitor, download manager, downloadmanager, file manager, protect downloads, password, download category, file tree, ajax, download template, grid, documents, ip address
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.5
|
7 |
+
Stable tag: 3.3.1
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Easily manage downloadable files and monitor downloads of your digital files from your WordPress site.
|
156 |
|
157 |
== Changelog ==
|
158 |
|
159 |
+
= 3.3.1 =
|
160 |
+
- Added a new feature to hide the download counts that is shown in some of the fancy templates. This new option can be found in the settings menu of the plugin.
|
161 |
+
- Added delete confirm dialogue in the individual download logs delete option.
|
162 |
+
- Simplified the settings menu page style.
|
163 |
+
- Fixed multiple vulnerabilities (thanks to NCSC-NL).
|
164 |
+
|
165 |
+
= 3.3.0 =
|
166 |
+
- Better implementation of the export log data to CSV file.
|
167 |
+
- Added a new filter in the download logs menu so the items per page value can be customized.
|
168 |
+
- Fixed a bug in the logs menu sorting. Sorting for some columns weren't working correctly.
|
169 |
+
- Added sanitization for the order and orderby columns in the logs list table.
|
170 |
+
- Added sanitization for the log entry delete functionality.
|
171 |
+
|
172 |
+
= 3.2.9 =
|
173 |
+
- Renamed the label of categories and tags of this plugin to "Download Categories" and "Download Tags".
|
174 |
+
- Better implementation of password protected download items. The ajax method of checking password has been completely replaced with a more robust implementation.
|
175 |
+
- Fixed a bug with the remove thumbnail ajax query.
|
176 |
+
- Thanks to @James Golovich for pointing out the issues.
|
177 |
+
|
178 |
= 3.2.8 =
|
179 |
- WordPress 4.4 compatibility.
|
180 |
|
sdm-download-logs.csv
ADDED
File without changes
|
sdm-post-type-and-taxonomy.php
CHANGED
@@ -43,8 +43,8 @@ function sdm_create_taxonomies() {
|
|
43 |
|
44 |
//***** Create CATEGORIES Taxonomy
|
45 |
$labels_tags = array(
|
46 |
-
'name' => _x('Categories', 'simple-download-monitor'),
|
47 |
-
'singular_name' => _x('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'),
|
@@ -67,8 +67,8 @@ function sdm_create_taxonomies() {
|
|
67 |
|
68 |
//***** Create TAGS Taxonomy
|
69 |
$labels_tags = array(
|
70 |
-
'name' => _x('Tags', 'simple-download-monitor'),
|
71 |
-
'singular_name' => _x('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'),
|
43 |
|
44 |
//***** Create CATEGORIES Taxonomy
|
45 |
$labels_tags = array(
|
46 |
+
'name' => _x('Download Categories', 'simple-download-monitor'),
|
47 |
+
'singular_name' => _x('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'),
|
67 |
|
68 |
//***** Create TAGS Taxonomy
|
69 |
$labels_tags = array(
|
70 |
+
'name' => _x('Download Tags', 'simple-download-monitor'),
|
71 |
+
'singular_name' => _x('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'),
|
sdm-post-type-content-handler.php
CHANGED
@@ -58,7 +58,11 @@ function filter_sdm_post_type_content($content) {
|
|
58 |
|
59 |
$content .= '<div class="sdm_post_item_top_right">';
|
60 |
$content .= '<div class="sdm_post_title">' . $isset_item_title . '</div>';
|
61 |
-
|
|
|
|
|
|
|
|
|
62 |
$content .= '<div class="sdm_post_description">' . $isset_item_description . '</div>';
|
63 |
$content .= '<div class="sdm_post_download_section"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
|
64 |
//$content .= '<div class="sdm_post_meta_section"></div>';//TODO - Show post meta (category and tags)
|
58 |
|
59 |
$content .= '<div class="sdm_post_item_top_right">';
|
60 |
$content .= '<div class="sdm_post_title">' . $isset_item_title . '</div>';
|
61 |
+
|
62 |
+
if(!isset($main_opts['general_hide_donwload_count'])) {//The hide download count is enabled.
|
63 |
+
$content .= '<div class="sdm_post_download_count">' . $download_count_string . '</div>';
|
64 |
+
}
|
65 |
+
|
66 |
$content .= '<div class="sdm_post_description">' . $isset_item_description . '</div>';
|
67 |
$content .= '<div class="sdm_post_download_section"><div class="sdm_download_link">' . $download_button_code . '</div></div>';
|
68 |
//$content .= '<div class="sdm_post_meta_section"></div>';//TODO - Show post meta (category and tags)
|