Version Description
- Fixed compatibility with WordPress 2.9
- Fixed XHTML validation errors in output code
- Added buttons to reset post count of overall and daily posts
Download this release
Release Info
Developer | Ajay |
Plugin | Top 10 – Popular posts plugin for WordPress |
Version | 1.4.1 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 1.4.1
- admin.inc.php +26 -4
- readme.txt +7 -2
- top-10-daily.js.php +1 -1
- top-10.php +19 -12
admin.inc.php
CHANGED
@@ -42,6 +42,18 @@ function tptn_options() {
|
|
42 |
$str = '<div id="message" class="updated fade"><p>'. __('Options set to Default.',TPTN_LOCAL_NAME) .'</p></div>';
|
43 |
echo $str;
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
?>
|
46 |
|
47 |
<div class="wrap">
|
@@ -148,8 +160,18 @@ function tptn_options() {
|
|
148 |
</label>
|
149 |
</p>
|
150 |
<p>
|
151 |
-
<input type="submit" name="tptn_save" id="tptn_save" value="Save Options" style="border:#
|
152 |
-
<input name="tptn_default" type="submit" id="tptn_default" value="Default Options" style="border:#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
</p>
|
154 |
</fieldset>
|
155 |
</form>
|
@@ -214,7 +236,7 @@ function tptn_pop_display($daily = false, $page = 0, $limit = 10) {
|
|
214 |
$sql .= "ORDER BY cntaccess DESC";
|
215 |
} else {
|
216 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
217 |
-
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL
|
218 |
|
219 |
$sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
|
220 |
$sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
|
@@ -394,7 +416,7 @@ function tptn_value($column_name, $id) {
|
|
394 |
$table_name = $wpdb->prefix . "top_ten_daily";
|
395 |
|
396 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
397 |
-
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL
|
398 |
$resultscount = $wpdb->get_row("SELECT postnumber, SUM(cntaccess) as sumCount FROM $table_name WHERE postnumber = $id AND dp_date >= '$current_date' GROUP BY postnumber ");
|
399 |
$cntaccess .= number_format((($resultscount) ? $resultscount->sumCount : 0));
|
400 |
|
42 |
$str = '<div id="message" class="updated fade"><p>'. __('Options set to Default.',TPTN_LOCAL_NAME) .'</p></div>';
|
43 |
echo $str;
|
44 |
}
|
45 |
+
|
46 |
+
if ($_POST['tptn_trunc_all']){
|
47 |
+
tptn_trunc_count(false);
|
48 |
+
$str = '<div id="message" class="updated fade"><p>'. __('Top 10 popular posts reset',TPTN_LOCAL_NAME) .'</p></div>';
|
49 |
+
echo $str;
|
50 |
+
}
|
51 |
+
|
52 |
+
if ($_POST['tptn_trunc_daily']){
|
53 |
+
tptn_trunc_count(true);
|
54 |
+
$str = '<div id="message" class="updated fade"><p>'. __('Top 10 daily popular posts reset',TPTN_LOCAL_NAME) .'</p></div>';
|
55 |
+
echo $str;
|
56 |
+
}
|
57 |
?>
|
58 |
|
59 |
<div class="wrap">
|
160 |
</label>
|
161 |
</p>
|
162 |
<p>
|
163 |
+
<input type="submit" name="tptn_save" id="tptn_save" value="Save Options" style="border:#0c0 1px solid" />
|
164 |
+
<input name="tptn_default" type="submit" id="tptn_default" value="Default Options" style="border:#f00 1px solid" onclick="if (!confirm('<?php _e('Do you want to set options to Default?',TPTN_LOCAL_NAME); ?>')) return false;" />
|
165 |
+
</p>
|
166 |
+
<h4>
|
167 |
+
<?php _e('Reset count',TPTN_LOCAL_NAME); ?>
|
168 |
+
</h4>
|
169 |
+
<p>
|
170 |
+
<?php _e('This cannot be reversed. Make sure that your database has been backed up before proceeding',TPTN_LOCAL_NAME); ?>
|
171 |
+
</p>
|
172 |
+
<p>
|
173 |
+
<input name="tptn_trunc_all" type="submit" id="tptn_trunc_all" value="Reset Popular Posts" style="border:#900 1px solid" onclick="if (!confirm('<?php _e('Are you sure you want to reset the popular posts?',TPTN_LOCAL_NAME); ?>')) return false;" />
|
174 |
+
<input name="tptn_trunc_daily" type="submit" id="tptn_trunc_daily" value="Reset Daily Popular Posts" style="border:#C00 1px solid" onclick="if (!confirm('<?php _e('Are you sure you want to reset the daily popular posts?',TPTN_LOCAL_NAME); ?>')) return false;" />
|
175 |
</p>
|
176 |
</fieldset>
|
177 |
</form>
|
236 |
$sql .= "ORDER BY cntaccess DESC";
|
237 |
} else {
|
238 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
239 |
+
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ".$daily_range."), INTERVAL 1 DAY) ");
|
240 |
|
241 |
$sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
|
242 |
$sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
|
416 |
$table_name = $wpdb->prefix . "top_ten_daily";
|
417 |
|
418 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
419 |
+
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ".$daily_range."), INTERVAL 1 DAY) ");
|
420 |
$resultscount = $wpdb->get_row("SELECT postnumber, SUM(cntaccess) as sumCount FROM $table_name WHERE postnumber = $id AND dp_date >= '$current_date' GROUP BY postnumber ");
|
421 |
$cntaccess .= number_format((($resultscount) ? $resultscount->sumCount : 0));
|
422 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: Ajay, Mark Ghosh
|
|
4 |
Donate link: http://ajaydsouza.com/donate/
|
5 |
Stable tag: trunk
|
6 |
Requires at least: 2.5
|
7 |
-
Tested up to: 2.
|
8 |
|
9 |
|
10 |
Track daily and total visits on your blog posts and display the count as well as popular posts.
|
@@ -23,11 +23,16 @@ Includes a sidebar widget to display the popular posts. And, all settings can be
|
|
23 |
* Sidebar widgets available for daily popular and overall popular posts.
|
24 |
* View list of daily and/or overall popular posts from within the dashboard itself
|
25 |
* Clean uninstall if you choose to delete the plugin from within WP-Admin
|
26 |
-
* Works with caching plugins like WP-Super-Cache
|
27 |
|
28 |
|
29 |
== Changelog ==
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
= 1.4 =
|
32 |
* Added localisation support
|
33 |
* Separate options to display number of views on posts and pages
|
4 |
Donate link: http://ajaydsouza.com/donate/
|
5 |
Stable tag: trunk
|
6 |
Requires at least: 2.5
|
7 |
+
Tested up to: 2.9
|
8 |
|
9 |
|
10 |
Track daily and total visits on your blog posts and display the count as well as popular posts.
|
23 |
* Sidebar widgets available for daily popular and overall popular posts.
|
24 |
* View list of daily and/or overall popular posts from within the dashboard itself
|
25 |
* Clean uninstall if you choose to delete the plugin from within WP-Admin
|
26 |
+
* Works with caching plugins like WP-Super-Cache and W3 Total Cache
|
27 |
|
28 |
|
29 |
== Changelog ==
|
30 |
|
31 |
+
= 1.4.1 =
|
32 |
+
* Fixed compatibility with WordPress 2.9
|
33 |
+
* Fixed XHTML validation errors in output code
|
34 |
+
* Added buttons to reset post count of overall and daily posts
|
35 |
+
|
36 |
= 1.4 =
|
37 |
* Added localisation support
|
38 |
* Separate options to display number of views on posts and pages
|
top-10-daily.js.php
CHANGED
@@ -32,7 +32,7 @@ function tptn_daily_lists() {
|
|
32 |
|
33 |
$results = $wpdb->get_results($sql);
|
34 |
|
35 |
-
$output = '<div id="
|
36 |
if(!$is_widget) $output .= $tptn_settings['title_daily'];
|
37 |
$output .= '<ul>';
|
38 |
if ($results) {
|
32 |
|
33 |
$results = $wpdb->get_results($sql);
|
34 |
|
35 |
+
$output = '<div id="tptn_related_daily">';
|
36 |
if(!$is_widget) $output .= $tptn_settings['title_daily'];
|
37 |
$output .= '<ul>';
|
38 |
if ($results) {
|
top-10.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Top 10
|
4 |
-
Version: 1.4
|
5 |
Plugin URI: http://ajaydsouza.com/wordpress/plugins/top-10/
|
6 |
Description: Count daily and total visits per post and display the most popular posts based on the number of views. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>. <a href="options-general.php?page=tptn_options">Configure...</a>
|
7 |
Author: Ajay D'Souza
|
@@ -38,8 +38,8 @@ add_action('init', 'ald_tptn_init');
|
|
38 |
* Main Function (Do not edit) *
|
39 |
********************************************************************/
|
40 |
// Update post views
|
41 |
-
|
42 |
-
function tptn_add_viewed_count() {
|
43 |
global $post, $wpdb, $single;
|
44 |
$table_name = $wpdb->prefix . "top_ten";
|
45 |
$tptn_settings = tptn_read_options();
|
@@ -51,11 +51,18 @@ function tptn_add_viewed_count() {
|
|
51 |
if (!(($post_author)&&(!$tptn_settings['track_authors']))) {
|
52 |
$id = intval($post->ID);
|
53 |
$output = '<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/top-10/top-10-addcount.js.php?top_ten_id='.$id.'"></script>';
|
54 |
-
|
55 |
}
|
|
|
|
|
|
|
56 |
}
|
|
|
|
|
|
|
57 |
}
|
58 |
|
|
|
59 |
// Function to add count to content
|
60 |
function tptn_pc_content($content) {
|
61 |
global $single, $post;
|
@@ -124,7 +131,7 @@ function tptn_show_daily_pop_posts() {
|
|
124 |
$output .= '<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/top-10/top-10-daily.js.php"></script>';
|
125 |
} else {
|
126 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
127 |
-
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL
|
128 |
|
129 |
$sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
|
130 |
$sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
|
@@ -135,7 +142,7 @@ function tptn_show_daily_pop_posts() {
|
|
135 |
|
136 |
$results = $wpdb->get_results($sql);
|
137 |
|
138 |
-
$output .= '<div id="
|
139 |
$output .= '<ul>';
|
140 |
if ($results) {
|
141 |
foreach ($results as $result) {
|
@@ -277,16 +284,16 @@ function tptn_install() {
|
|
277 |
}
|
278 |
if (function_exists('register_activation_hook')) {
|
279 |
register_activation_hook(__FILE__,'tptn_install');
|
280 |
-
//register_activation_hook(__FILE__, 'tptn_cron_install');
|
281 |
}
|
282 |
|
283 |
|
284 |
-
// Function to delete all rows in the
|
285 |
-
function tptn_trunc_count() {
|
286 |
global $wpdb;
|
287 |
-
$
|
|
|
288 |
|
289 |
-
$sql = "TRUNCATE TABLE $
|
290 |
$wpdb->query($sql);
|
291 |
}
|
292 |
|
@@ -308,7 +315,7 @@ function widget_tptn_pop_daily($args) {
|
|
308 |
echo '<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/top-10/top-10-daily.js.php?widget=1"></script>';
|
309 |
} else {
|
310 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
311 |
-
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL
|
312 |
|
313 |
$sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
|
314 |
$sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Top 10
|
4 |
+
Version: 1.4.1
|
5 |
Plugin URI: http://ajaydsouza.com/wordpress/plugins/top-10/
|
6 |
Description: Count daily and total visits per post and display the most popular posts based on the number of views. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>. <a href="options-general.php?page=tptn_options">Configure...</a>
|
7 |
Author: Ajay D'Souza
|
38 |
* Main Function (Do not edit) *
|
39 |
********************************************************************/
|
40 |
// Update post views
|
41 |
+
add_filter('the_content','tptn_add_viewed_count',9000);
|
42 |
+
function tptn_add_viewed_count($content) {
|
43 |
global $post, $wpdb, $single;
|
44 |
$table_name = $wpdb->prefix . "top_ten";
|
45 |
$tptn_settings = tptn_read_options();
|
51 |
if (!(($post_author)&&(!$tptn_settings['track_authors']))) {
|
52 |
$id = intval($post->ID);
|
53 |
$output = '<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/top-10/top-10-addcount.js.php?top_ten_id='.$id.'"></script>';
|
54 |
+
return $content.$output;
|
55 |
}
|
56 |
+
else {
|
57 |
+
return $content;
|
58 |
+
}
|
59 |
}
|
60 |
+
else {
|
61 |
+
return $content;
|
62 |
+
}
|
63 |
}
|
64 |
|
65 |
+
|
66 |
// Function to add count to content
|
67 |
function tptn_pc_content($content) {
|
68 |
global $single, $post;
|
131 |
$output .= '<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/top-10/top-10-daily.js.php"></script>';
|
132 |
} else {
|
133 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
134 |
+
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ".$daily_range."), INTERVAL 1 DAY) ");
|
135 |
|
136 |
$sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
|
137 |
$sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
|
142 |
|
143 |
$results = $wpdb->get_results($sql);
|
144 |
|
145 |
+
$output .= '<div id="tptn_related_daily">'.$tptn_settings['title_daily'];
|
146 |
$output .= '<ul>';
|
147 |
if ($results) {
|
148 |
foreach ($results as $result) {
|
284 |
}
|
285 |
if (function_exists('register_activation_hook')) {
|
286 |
register_activation_hook(__FILE__,'tptn_install');
|
|
|
287 |
}
|
288 |
|
289 |
|
290 |
+
// Function to delete all rows in the posts table
|
291 |
+
function tptn_trunc_count($daily = false) {
|
292 |
global $wpdb;
|
293 |
+
$table_name = $wpdb->prefix . "top_ten";
|
294 |
+
if ($daily) $table_name .= "_daily";
|
295 |
|
296 |
+
$sql = "TRUNCATE TABLE $table_name";
|
297 |
$wpdb->query($sql);
|
298 |
}
|
299 |
|
315 |
echo '<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/top-10/top-10-daily.js.php?widget=1"></script>';
|
316 |
} else {
|
317 |
$daily_range = $tptn_settings[daily_range]. ' DAY';
|
318 |
+
$current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ".$daily_range."), INTERVAL 1 DAY) ");
|
319 |
|
320 |
$sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
|
321 |
$sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
|