Top 10 – Popular posts plugin for WordPress - Version 1.9.8.4

Version Description

Fixed PHP notice errors on Admin pages

=

Download this release

Release Info

Developer Ajay
Plugin Icon 128x128 Top 10 – Popular posts plugin for WordPress
Version 1.9.8.4
Comparing to
See all releases

Code changes from version 1.9.8.3 to 1.9.8.4

Files changed (3) hide show
  1. admin.inc.php +17 -8
  2. readme.txt +18 -2
  3. top-10.php +4 -4
admin.inc.php CHANGED
@@ -3,8 +3,8 @@
3
  * Admin Page *
4
  *********************************************************************/
5
  if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?");
6
- if (!defined('ALD_TPTN_DIR')) define('ALD_TPTN_DIR', dirname(__FILE__));
7
- if (!defined('TPTN_LOCAL_NAME')) define('TPTN_LOCAL_NAME', 'tptn');
8
 
9
  /**
10
  * Plugin settings.
@@ -93,7 +93,7 @@ function tptn_options() {
93
  $tptn_settings['exclude_categories'] = (isset($exclude_categories)) ? join(',', $exclude_categories) : '';
94
 
95
  // Cron maintenance functions
96
- if ( ($_POST['cron_on']) && ( ($tptn_settings['cron_on']==false) || (intval($_POST['cron_hour'])!=$tptn_settings['cron_hour']) || (intval($_POST['cron_min'])!=$tptn_settings['cron_min']) || ($_POST['cron_recurrence']!=$tptn_settings['cron_recurrence']) ) ) {
97
  $tptn_settings['cron_on'] = true;
98
  $tptn_settings['cron_hour'] = intval($_POST['cron_hour']);
99
  $tptn_settings['cron_min'] = intval($_POST['cron_min']);
@@ -101,7 +101,7 @@ function tptn_options() {
101
 
102
  tptn_enable_run($tptn_settings['cron_hour'], $tptn_settings['cron_min'], $tptn_settings['cron_recurrence']);
103
  echo '<div id="message" class="updated fade"><p>' . __('Scheduled maintenance enabled / modified',TPTN_LOCAL_NAME) .'</p></div>';
104
- } elseif ($_POST['cron_on']==false) {
105
  $tptn_settings['cron_on'] = false;
106
  tptn_disable_run();
107
  echo '<div id="message" class="updated fade"><p>'. __('Scheduled maintenance disabled',TPTN_LOCAL_NAME) .'</p></div>';
@@ -938,7 +938,7 @@ add_filter('manage_pages_columns', 'tptn_column');
938
  */
939
  function tptn_value($column_name, $id) {
940
  global $wpdb;
941
- $tptn_settings = tptn_read_options();
942
 
943
  // Add Total count
944
  if (($column_name == 'tptn_total')&&($tptn_settings['pv_in_admin'])) {
@@ -947,6 +947,7 @@ function tptn_value($column_name, $id) {
947
 
948
  $resultscount = $wpdb->get_row("SELECT postnumber, cntaccess from $table_name WHERE postnumber = $id");
949
  $cntaccess = number_format_i18n((($resultscount) ? $resultscount->cntaccess : 0));
 
950
  }
951
 
952
  // Now process daily count
@@ -959,10 +960,9 @@ function tptn_value($column_name, $id) {
959
  $current_date = date ( 'Y-m-j' , $current_date );
960
 
961
  $resultscount = $wpdb->get_row("SELECT postnumber, SUM(cntaccess) as sumCount FROM $table_name WHERE postnumber = $id AND dp_date >= '$current_date' GROUP BY postnumber ");
962
- $cntaccess .= number_format_i18n((($resultscount) ? $resultscount->sumCount : 0));
 
963
  }
964
-
965
- echo $cntaccess;
966
  }
967
  add_action('manage_posts_custom_column', 'tptn_value', 10, 2);
968
  add_action('manage_pages_custom_column', 'tptn_value', 10, 2);
@@ -986,6 +986,14 @@ add_filter( 'manage_edit-post_sortable_columns', 'tptn_column_register_sortable'
986
  add_filter( 'manage_edit-page_sortable_columns', 'tptn_column_register_sortable' );
987
 
988
 
 
 
 
 
 
 
 
 
989
  function tptn_column_clauses( $clauses, $wp_query ) {
990
  global $wpdb;
991
  $tptn_settings = tptn_read_options();
@@ -1018,6 +1026,7 @@ function tptn_column_clauses( $clauses, $wp_query ) {
1018
  }
1019
  add_filter( 'posts_clauses', 'tptn_column_clauses', 10, 2 );
1020
 
 
1021
  /**
1022
  * Output CSS for width of new column.
1023
  *
3
  * Admin Page *
4
  *********************************************************************/
5
  if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?");
6
+ //if (!defined('ALD_TPTN_DIR')) define('ALD_TPTN_DIR', dirname(__FILE__));
7
+ //if (!defined('TPTN_LOCAL_NAME')) define('TPTN_LOCAL_NAME', 'tptn');
8
 
9
  /**
10
  * Plugin settings.
93
  $tptn_settings['exclude_categories'] = (isset($exclude_categories)) ? join(',', $exclude_categories) : '';
94
 
95
  // Cron maintenance functions
96
+ if ( isset($_POST['cron_on']) && ( ($tptn_settings['cron_on']==false) || (intval($_POST['cron_hour'])!=$tptn_settings['cron_hour']) || (intval($_POST['cron_min'])!=$tptn_settings['cron_min']) || ($_POST['cron_recurrence']!=$tptn_settings['cron_recurrence']) ) ) {
97
  $tptn_settings['cron_on'] = true;
98
  $tptn_settings['cron_hour'] = intval($_POST['cron_hour']);
99
  $tptn_settings['cron_min'] = intval($_POST['cron_min']);
101
 
102
  tptn_enable_run($tptn_settings['cron_hour'], $tptn_settings['cron_min'], $tptn_settings['cron_recurrence']);
103
  echo '<div id="message" class="updated fade"><p>' . __('Scheduled maintenance enabled / modified',TPTN_LOCAL_NAME) .'</p></div>';
104
+ } else {
105
  $tptn_settings['cron_on'] = false;
106
  tptn_disable_run();
107
  echo '<div id="message" class="updated fade"><p>'. __('Scheduled maintenance disabled',TPTN_LOCAL_NAME) .'</p></div>';
938
  */
939
  function tptn_value($column_name, $id) {
940
  global $wpdb;
941
+ global $tptn_settings;
942
 
943
  // Add Total count
944
  if (($column_name == 'tptn_total')&&($tptn_settings['pv_in_admin'])) {
947
 
948
  $resultscount = $wpdb->get_row("SELECT postnumber, cntaccess from $table_name WHERE postnumber = $id");
949
  $cntaccess = number_format_i18n((($resultscount) ? $resultscount->cntaccess : 0));
950
+ echo $cntaccess;
951
  }
952
 
953
  // Now process daily count
960
  $current_date = date ( 'Y-m-j' , $current_date );
961
 
962
  $resultscount = $wpdb->get_row("SELECT postnumber, SUM(cntaccess) as sumCount FROM $table_name WHERE postnumber = $id AND dp_date >= '$current_date' GROUP BY postnumber ");
963
+ $cntaccess = number_format_i18n((($resultscount) ? $resultscount->sumCount : 0));
964
+ echo $cntaccess;
965
  }
 
 
966
  }
967
  add_action('manage_posts_custom_column', 'tptn_value', 10, 2);
968
  add_action('manage_pages_custom_column', 'tptn_value', 10, 2);
986
  add_filter( 'manage_edit-page_sortable_columns', 'tptn_column_register_sortable' );
987
 
988
 
989
+ /**
990
+ * Add custom post clauses to sort the columns.
991
+ *
992
+ * @access public
993
+ * @param mixed $clauses
994
+ * @param mixed $wp_query
995
+ * @return void
996
+ */
997
  function tptn_column_clauses( $clauses, $wp_query ) {
998
  global $wpdb;
999
  $tptn_settings = tptn_read_options();
1026
  }
1027
  add_filter( 'posts_clauses', 'tptn_column_clauses', 10, 2 );
1028
 
1029
+
1030
  /**
1031
  * Output CSS for width of new column.
1032
  *
readme.txt CHANGED
@@ -46,12 +46,15 @@ Includes a sidebar widget to display the popular posts. And, all settings can be
46
 
47
  == Upgrade Notice ==
48
 
49
- = 1.9.8.3 =
50
- Fixed Daily count was selecting an extra date when using the widget; Admin columns will be sorted by descending order by default
51
 
52
 
53
  == Changelog ==
54
 
 
 
 
55
  = 1.9.8.3 =
56
  * Fixed: Daily count was selecting an extra date when using the widget
57
  * Fixed: Default settings for the widget weren't initiated correctly in some cases
@@ -295,6 +298,19 @@ Never. This plugin is designed to only track the number of pageviews on your blo
295
  When you enabled the scheduled maintenance, Top 10 will create a cron job that will run at a predefined interval and truncate the `wp_top_ten_daily` table.
296
  *Note: If you enable this option, WordPress will execute this job when it is scheduled the first time*
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  == Wishlist ==
299
 
300
  Below are a few features that I plan on implementing in future versions of the plugin. However, there is no fixed time-frame for this and largely depends on how much time I can contribute to development.
46
 
47
  == Upgrade Notice ==
48
 
49
+ = 1.9.8.4 =
50
+ Fixed PHP notice errors on Admin pages
51
 
52
 
53
  == Changelog ==
54
 
55
+ = 1.9.8.3 =
56
+ * Fixed PHP notices on Admin pages
57
+
58
  = 1.9.8.3 =
59
  * Fixed: Daily count was selecting an extra date when using the widget
60
  * Fixed: Default settings for the widget weren't initiated correctly in some cases
298
  When you enabled the scheduled maintenance, Top 10 will create a cron job that will run at a predefined interval and truncate the `wp_top_ten_daily` table.
299
  *Note: If you enable this option, WordPress will execute this job when it is scheduled the first time*
300
 
301
+ = How to make the columns on the Custom Posts pages sortable? =
302
+ Add the following code to your functions.php file of your theme.
303
+
304
+ `
305
+ add_filter( 'manage_edit-{$cpt}_sortable_columns', 'tptn_column_register_sortable' );
306
+ `
307
+
308
+ Replace `{$cpt}` by the slug of your custom post type. E.g. to make the columns on your 'projects' post type sortable, you will need to add:
309
+ `
310
+ add_filter( 'manage_edit-projects_sortable_columns', 'tptn_column_register_sortable' );
311
+ `
312
+
313
+
314
  == Wishlist ==
315
 
316
  Below are a few features that I plan on implementing in future versions of the plugin. However, there is no fixed time-frame for this and largely depends on how much time I can contribute to development.
top-10.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Top 10
4
- Version: 1.9.8.3
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>
7
  Author: Ajay D'Souza
@@ -78,12 +78,12 @@ function tptn_add_viewed_count($content) {
78
  }
79
  }
80
 
81
- return $content.$output;
82
  } else {
83
- return $content;
84
  }
85
  } else {
86
- return $content;
87
  }
88
  }
89
  add_filter('the_content','tptn_add_viewed_count');
1
  <?php
2
  /*
3
  Plugin Name: Top 10
4
+ Version: 1.9.8.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>
7
  Author: Ajay D'Souza
78
  }
79
  }
80
 
81
+ return $content.$output."<!-- Inside INCLUDE -->";
82
  } else {
83
+ return $content."<!-- Outside INCLUDE -->";
84
  }
85
  } else {
86
+ return $content."<!-- Ouside Singular -->";
87
  }
88
  }
89
  add_filter('the_content','tptn_add_viewed_count');