Top 10 – Popular posts plugin for WordPress - Version 2.6.1

Version Description

  • Bug fixes:
    • Fixed widget daily and hourly range not working which was broken in v2.6.0
Download this release

Release Info

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

Code changes from version 2.6.0 to 2.6.1

includes/admin/admin-columns.php CHANGED
@@ -63,9 +63,6 @@ function tptn_value( $column_name, $id ) {
63
  if ( ( 'tptn_daily' === $column_name ) && ( tptn_get_option( 'pv_in_admin' ) ) ) {
64
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
65
 
66
- $daily_range = tptn_get_option( 'daily_range' );
67
- $hour_range = tptn_get_option( 'hour_range' );
68
-
69
  $from_date = tptn_get_from_date();
70
 
71
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= %s AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
@@ -82,9 +79,6 @@ function tptn_value( $column_name, $id ) {
82
 
83
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
84
 
85
- $daily_range = tptn_get_option( 'daily_range' );
86
- $hour_range = tptn_get_option( 'hour_range' );
87
-
88
  $from_date = tptn_get_from_date();
89
 
90
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= %s AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
@@ -142,9 +136,6 @@ function tptn_column_clauses( $clauses, $wp_query ) {
142
 
143
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
144
 
145
- $daily_range = tptn_get_option( 'daily_range' );
146
- $hour_range = tptn_get_option( 'hour_range' );
147
-
148
  $from_date = tptn_get_from_date();
149
 
150
  $clauses['join'] .= "LEFT OUTER JOIN {$table_name} ON {$wpdb->posts}.ID={$table_name}.postnumber";
63
  if ( ( 'tptn_daily' === $column_name ) && ( tptn_get_option( 'pv_in_admin' ) ) ) {
64
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
65
 
 
 
 
66
  $from_date = tptn_get_from_date();
67
 
68
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= %s AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
79
 
80
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
81
 
 
 
 
82
  $from_date = tptn_get_from_date();
83
 
84
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as sum_count FROM {$table_name} WHERE postnumber = %d AND dp_date >= %s AND blog_id = %d GROUP BY postnumber ", $id, $from_date, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
136
 
137
  $table_name = $wpdb->base_prefix . 'top_ten_daily';
138
 
 
 
 
139
  $from_date = tptn_get_from_date();
140
 
141
  $clauses['join'] .= "LEFT OUTER JOIN {$table_name} ON {$wpdb->posts}.ID={$table_name}.postnumber";
includes/counter.php CHANGED
@@ -200,9 +200,6 @@ function get_tptn_post_count_only( $id = false, $count = 'total', $blog_id = fal
200
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess as visits FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ", $id, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
201
  break;
202
  case 'daily':
203
- $daily_range = tptn_get_option( 'daily_range' );
204
- $hour_range = tptn_get_option( 'hour_range' );
205
-
206
  $from_date = tptn_get_from_date();
207
 
208
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as visits FROM {$table_name_daily} WHERE postnumber = %d AND blog_id = %d AND dp_date >= %s GROUP BY postnumber ", array( $id, $blog_id, $from_date ) ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
200
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, cntaccess as visits FROM {$table_name} WHERE postnumber = %d AND blog_id = %d ", $id, $blog_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
201
  break;
202
  case 'daily':
 
 
 
203
  $from_date = tptn_get_from_date();
204
 
205
  $resultscount = $wpdb->get_row( $wpdb->prepare( "SELECT postnumber, SUM(cntaccess) as visits FROM {$table_name_daily} WHERE postnumber = %d AND blog_id = %d AND dp_date >= %s GROUP BY postnumber ", array( $id, $blog_id, $from_date ) ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
includes/helpers.php CHANGED
@@ -29,18 +29,22 @@ function tptn_trunc_count( $daily = true ) {
29
  *
30
  * @since 2.6.0
31
  *
32
- * @param string $time A date/time string.
 
 
33
  * @return string From date
34
  */
35
- function tptn_get_from_date( $time = null ) {
36
 
37
  $current_time = isset( $time ) ? strtotime( $time ) : current_time( 'timestamp', 0 );
 
 
38
 
39
  if ( tptn_get_option( 'daily_midnight' ) ) {
40
- $from_date = $current_time - ( max( 0, ( tptn_get_option( 'daily_range' ) - 1 ) ) * DAY_IN_SECONDS );
41
  $from_date = gmdate( 'Y-m-d 0', $from_date );
42
  } else {
43
- $from_date = $current_time - ( tptn_get_option( 'daily_range' ) * DAY_IN_SECONDS + tptn_get_option( 'hour_range' ) * HOUR_IN_SECONDS );
44
  $from_date = gmdate( 'Y-m-d H', $from_date );
45
  }
46
 
@@ -49,9 +53,12 @@ function tptn_get_from_date( $time = null ) {
49
  *
50
  * @since 2.6.0
51
  *
52
- * @param string $time From date.
 
 
 
53
  */
54
- return apply_filters( 'tptn_get_from_date', $from_date );
55
  }
56
 
57
 
29
  *
30
  * @since 2.6.0
31
  *
32
+ * @param string $time A date/time string.
33
+ * @param int $daily_range Daily range.
34
+ * @param int $hour_range Hour range.
35
  * @return string From date
36
  */
37
+ function tptn_get_from_date( $time = null, $daily_range = null, $hour_range = null ) {
38
 
39
  $current_time = isset( $time ) ? strtotime( $time ) : current_time( 'timestamp', 0 );
40
+ $daily_range = isset( $daily_range ) ? $daily_range : tptn_get_option( 'daily_range' );
41
+ $hour_range = isset( $hour_range ) ? $hour_range : tptn_get_option( 'hour_range' );
42
 
43
  if ( tptn_get_option( 'daily_midnight' ) ) {
44
+ $from_date = $current_time - ( max( 0, ( $daily_range - 1 ) ) * DAY_IN_SECONDS );
45
  $from_date = gmdate( 'Y-m-d 0', $from_date );
46
  } else {
47
+ $from_date = $current_time - ( $daily_range * DAY_IN_SECONDS + $hour_range * HOUR_IN_SECONDS );
48
  $from_date = gmdate( 'Y-m-d H', $from_date );
49
  }
50
 
53
  *
54
  * @since 2.6.0
55
  *
56
+ * @param string $from_date From date.
57
+ * @param string $time A date/time string.
58
+ * @param int $daily_range Daily range.
59
+ * @param int $hour_range Hour range.
60
  */
61
+ return apply_filters( 'tptn_get_from_date', $from_date, $time, $daily_range, $hour_range );
62
  }
63
 
64
 
includes/public/display-posts.php CHANGED
@@ -327,7 +327,7 @@ function get_tptn_pop_posts( $args = array() ) {
327
 
328
  $blog_id = get_current_blog_id();
329
 
330
- $from_date = tptn_get_from_date();
331
 
332
  /**
333
  *
327
 
328
  $blog_id = get_current_blog_id();
329
 
330
+ $from_date = tptn_get_from_date( null, $args['daily_range'], $args['hour_range'] );
331
 
332
  /**
333
  *
languages/top-10-en_US.mo CHANGED
Binary file
languages/top-10-en_US.po CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Top 10\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2019-02-09 17:23+0530\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
8
  "Language-Team: WebberZone <plugins@webberzone.com>\n"
2
  msgstr ""
3
  "Project-Id-Version: Top 10\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2019-02-11 12:07+0530\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
8
  "Language-Team: WebberZone <plugins@webberzone.com>\n"
languages/top-10-en_US.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: Top 10\n"
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2019-02-09 17:24+0530\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
9
  "Language-Team: WebberZone <plugins@webberzone.com>\n"
3
  msgstr ""
4
  "Project-Id-Version: Top 10\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2019-02-11 12:07+0530\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
9
  "Language-Team: WebberZone <plugins@webberzone.com>\n"
readme.txt CHANGED
@@ -170,6 +170,11 @@ add_filter( 'manage_edit-projects_sortable_columns', 'tptn_column_register_sorta
170
 
171
  == Changelog ==
172
 
 
 
 
 
 
173
  = 2.6.0 =
174
 
175
  * Features:
@@ -303,7 +308,7 @@ For previous changelog entries, please refer to the separate changelog.txt file
303
 
304
  == Upgrade Notice ==
305
 
306
- = 2.6.0 =
307
- * Major release! Brand new settings interface so please do verify your settings after the upgrade. Several new features and bug fixes.
308
  Check the Changelog for more details
309
 
170
 
171
  == Changelog ==
172
 
173
+ = 2.6.1 =
174
+
175
+ * Bug fixes:
176
+ * Fixed widget daily and hourly range not working which was broken in v2.6.0
177
+
178
  = 2.6.0 =
179
 
180
  * Features:
308
 
309
  == Upgrade Notice ==
310
 
311
+ = 2.6.1 =
312
+ * Major release! Several new features and bug fixes. Please verify your settings after upgrade.
313
  Check the Changelog for more details
314
 
top-10.php CHANGED
@@ -14,7 +14,7 @@
14
  * Plugin Name: Top 10
15
  * Plugin URI: https://webberzone.com/plugins/top-10/
16
  * Description: Count daily and total visits per post and display the most popular posts based on the number of views
17
- * Version: 2.6.0
18
  * Author: Ajay D'Souza
19
  * Author URI: https://webberzone.com
20
  * License: GPL-2.0+
14
  * Plugin Name: Top 10
15
  * Plugin URI: https://webberzone.com/plugins/top-10/
16
  * Description: Count daily and total visits per post and display the most popular posts based on the number of views
17
+ * Version: 2.6.1
18
  * Author: Ajay D'Souza
19
  * Author URI: https://webberzone.com
20
  * License: GPL-2.0+