Version Description
- Fix: Chart data not updating for object cached installs due to missing expire parameter
- Fix: Bug preventing hiding the counter based on user role.
- Fix: Undefined notice in the admin dashboard request
Download this release
Release Info
Developer | dfactory |
Plugin | Post Views Counter |
Version | 1.2.7 |
Comparing to | |
See all releases |
Code changes from version 1.2.6 to 1.2.7
- includes/dashboard.php +9 -1
- includes/frontend.php +1 -1
- includes/functions.php +8 -3
- post-views-counter.php +3 -3
- readme.txt +10 -3
includes/dashboard.php
CHANGED
@@ -81,7 +81,7 @@ class Post_Views_Counter_Dashboard {
|
|
81 |
);
|
82 |
|
83 |
// set range
|
84 |
-
$
|
85 |
|
86 |
// $now = getdate( current_time( 'timestamp', get_option( 'gmt_offset' ) ) );
|
87 |
$now = getdate( current_time( 'timestamp', get_option( 'gmt_offset' ) ) - 2592000 );
|
@@ -172,6 +172,10 @@ class Post_Views_Counter_Dashboard {
|
|
172 |
foreach ( $post_views as $id => $views ) {
|
173 |
// generate chart data for specific post types
|
174 |
$data['data']['datasets'][$post_type_id]['data'][] = $views;
|
|
|
|
|
|
|
|
|
175 |
$sum[$id] += $views;
|
176 |
}
|
177 |
}
|
@@ -244,6 +248,10 @@ class Post_Views_Counter_Dashboard {
|
|
244 |
foreach ( $post_views as $id => $views ) {
|
245 |
// generate chart data for specific post types
|
246 |
$data['data']['datasets'][$post_type_id]['data'][] = $views;
|
|
|
|
|
|
|
|
|
247 |
$sum[$id] += $views;
|
248 |
}
|
249 |
}
|
81 |
);
|
82 |
|
83 |
// set range
|
84 |
+
$range = 'this_month';
|
85 |
|
86 |
// $now = getdate( current_time( 'timestamp', get_option( 'gmt_offset' ) ) );
|
87 |
$now = getdate( current_time( 'timestamp', get_option( 'gmt_offset' ) ) - 2592000 );
|
172 |
foreach ( $post_views as $id => $views ) {
|
173 |
// generate chart data for specific post types
|
174 |
$data['data']['datasets'][$post_type_id]['data'][] = $views;
|
175 |
+
|
176 |
+
if ( ! array_key_exists( $id, $sum ) )
|
177 |
+
$sum[$id] = 0;
|
178 |
+
|
179 |
$sum[$id] += $views;
|
180 |
}
|
181 |
}
|
248 |
foreach ( $post_views as $id => $views ) {
|
249 |
// generate chart data for specific post types
|
250 |
$data['data']['datasets'][$post_type_id]['data'][] = $views;
|
251 |
+
|
252 |
+
if ( ! array_key_exists( $id, $sum ) )
|
253 |
+
$sum[$id] = 0;
|
254 |
+
|
255 |
$sum[$id] += $views;
|
256 |
}
|
257 |
}
|
includes/frontend.php
CHANGED
@@ -116,7 +116,7 @@ class Post_Views_Counter_Frontend {
|
|
116 |
if ( in_array( 'users', $groups, true ) )
|
117 |
$display = false;
|
118 |
// exclude specific roles?
|
119 |
-
elseif ( in_array( 'roles', $groups, true ) && Post_Views_Counter()->counter->is_user_role_excluded( Post_Views_Counter()->options['display']['restrict_display']['roles'] ) )
|
120 |
$display = false;
|
121 |
}
|
122 |
// exclude guests?
|
116 |
if ( in_array( 'users', $groups, true ) )
|
117 |
$display = false;
|
118 |
// exclude specific roles?
|
119 |
+
elseif ( in_array( 'roles', $groups, true ) && Post_Views_Counter()->counter->is_user_role_excluded( get_current_user_id(), Post_Views_Counter()->options['display']['restrict_display']['roles'] ) )
|
120 |
$display = false;
|
121 |
}
|
122 |
// exclude guests?
|
includes/functions.php
CHANGED
@@ -42,8 +42,11 @@ if ( ! function_exists( 'pvc_get_post_views' ) ) {
|
|
42 |
// cached data not found?
|
43 |
if ( $post_views === false ) {
|
44 |
$post_views = (int) $wpdb->get_var( $query );
|
|
|
|
|
|
|
45 |
|
46 |
-
wp_cache_add( md5( $query ), $post_views, 'pvc-get_post_views' );
|
47 |
}
|
48 |
|
49 |
return apply_filters( 'pvc_get_post_views', $post_views, $post_id );
|
@@ -219,8 +222,10 @@ if ( ! function_exists( 'pvc_get_views' ) ) {
|
|
219 |
$post_views = (int) $wpdb->get_var( $query );
|
220 |
}
|
221 |
|
222 |
-
// cache
|
223 |
-
|
|
|
|
|
224 |
}
|
225 |
|
226 |
return apply_filters( 'pvc_get_views', $post_views );
|
42 |
// cached data not found?
|
43 |
if ( $post_views === false ) {
|
44 |
$post_views = (int) $wpdb->get_var( $query );
|
45 |
+
|
46 |
+
// set the cache expiration, 5 minutes by default
|
47 |
+
$expire = absint( apply_filters( 'pvc_object_cache_expire', 5 * 60 ) );
|
48 |
|
49 |
+
wp_cache_add( md5( $query ), $post_views, 'pvc-get_post_views', $expire );
|
50 |
}
|
51 |
|
52 |
return apply_filters( 'pvc_get_post_views', $post_views, $post_id );
|
222 |
$post_views = (int) $wpdb->get_var( $query );
|
223 |
}
|
224 |
|
225 |
+
// set the cache expiration, 5 minutes by default
|
226 |
+
$expire = absint( apply_filters( 'pvc_object_cache_expire', 5 * 60 ) );
|
227 |
+
|
228 |
+
wp_cache_add( md5( $query ), $post_views, 'pvc-get_views', $expire );
|
229 |
}
|
230 |
|
231 |
return apply_filters( 'pvc_get_views', $post_views );
|
post-views-counter.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Post Views Counter
|
4 |
Description: Post Views Counter allows you to display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
|
5 |
-
Version: 1.2.
|
6 |
Author: dFactory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/post-views-counter/
|
@@ -31,7 +31,7 @@ if ( ! class_exists( 'Post_Views_Counter' ) ) :
|
|
31 |
* Post Views Counter final class.
|
32 |
*
|
33 |
* @class Post_Views_Counter
|
34 |
-
* @version 1.2.
|
35 |
*/
|
36 |
final class Post_Views_Counter {
|
37 |
|
@@ -80,7 +80,7 @@ if ( ! class_exists( 'Post_Views_Counter' ) ) :
|
|
80 |
'link_to_post' => true,
|
81 |
'icon_class' => 'dashicons-chart-bar'
|
82 |
),
|
83 |
-
'version' => '1.2.
|
84 |
);
|
85 |
|
86 |
/**
|
2 |
/*
|
3 |
Plugin Name: Post Views Counter
|
4 |
Description: Post Views Counter allows you to display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
|
5 |
+
Version: 1.2.7
|
6 |
Author: dFactory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/post-views-counter/
|
31 |
* Post Views Counter final class.
|
32 |
*
|
33 |
* @class Post_Views_Counter
|
34 |
+
* @version 1.2.7
|
35 |
*/
|
36 |
final class Post_Views_Counter {
|
37 |
|
80 |
'link_to_post' => true,
|
81 |
'icon_class' => 'dashicons-chart-bar'
|
82 |
),
|
83 |
+
'version' => '1.2.7'
|
84 |
);
|
85 |
|
86 |
/**
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.dfactory.eu/
|
|
4 |
Tags: counter, hits, posts, postviews, post views, views, count, statistics, stats, analytics, pageviews, tracking
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.7.2
|
7 |
-
Stable tag: 1.2.
|
8 |
License: MIT License
|
9 |
License URI: http://opensource.org/licenses/MIT
|
10 |
|
@@ -59,6 +59,11 @@ No questions yet.
|
|
59 |
|
60 |
== Changelog ==
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
= 1.2.6 =
|
63 |
* Fix: Hardcoded post_views database table prefix
|
64 |
|
@@ -151,5 +156,7 @@ Initial release
|
|
151 |
|
152 |
== Upgrade Notice ==
|
153 |
|
154 |
-
= 1.2.
|
155 |
-
* Fix:
|
|
|
|
4 |
Tags: counter, hits, posts, postviews, post views, views, count, statistics, stats, analytics, pageviews, tracking
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.7.2
|
7 |
+
Stable tag: 1.2.7
|
8 |
License: MIT License
|
9 |
License URI: http://opensource.org/licenses/MIT
|
10 |
|
59 |
|
60 |
== Changelog ==
|
61 |
|
62 |
+
= 1.2.7 =
|
63 |
+
* Fix: Chart data not updating for object cached installs due to missing expire parameter
|
64 |
+
* Fix: Bug preventing hiding the counter based on user role.
|
65 |
+
* Fix: Undefined notice in the admin dashboard request
|
66 |
+
|
67 |
= 1.2.6 =
|
68 |
* Fix: Hardcoded post_views database table prefix
|
69 |
|
156 |
|
157 |
== Upgrade Notice ==
|
158 |
|
159 |
+
= 1.2.7 =
|
160 |
+
* Fix: Chart data not updating for object cached installs due to missing expire parameter
|
161 |
+
* Fix: Bug preventing hiding the counter based on user role.
|
162 |
+
* Fix: Undefined notice in admin dashboard request
|