Skip to content

Commit 256a354

Browse files
committed
Release version 2.0.2
* Maintenance Update. This update includes 3 bug fixes, including AMP pages conpatibility * Fix - Headers already sent warning. Delete trailing spaces at bottom of php file * Fix - Change attribute name element-id to data-element-id for compatibility with AMP. Thanks to @veenareddys for reporting the issue * Fix - Update SQL query for fix bug get incorrect total views when edit a Post or Page. Thanks to @groenhart for reporting this issue
1 parent 2814d91 commit 256a354

15 files changed

+74
-38
lines changed

admin/admin-init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,4 @@ public function admin_settings_tab( $current_page = '', $tab_data = array() ) {
319319
global $wp_pvc_admin_init;
320320
$wp_pvc_admin_init = new WP_PVC_Admin_Init();
321321

322-
?>
322+
?>

admin/admin-interface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3701,4 +3701,4 @@ public function generate_background_color_css( $option, $transparency = 100 ) {
37013701
global $wp_pvc_admin_interface;
37023702
$wp_pvc_admin_interface = new WP_PVC_Admin_Interface();
37033703

3704-
?>
3704+
?>

admin/admin-ui.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,4 @@ public function get_version_message() {
342342

343343
}
344344

345-
?>
345+
?>

admin/includes/uploader/class-uploader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,4 @@ public function upload_input ( $name_attribute, $id_attribute = '', $value = '',
134134
global $wp_pvc_uploader;
135135
$wp_pvc_uploader = new WP_PVC_Uploader();
136136

137-
?>
137+
?>

admin/less/compile_less_sass_class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ public function compileLessFile( $less_file = '', $css_file = '', $css_min_file
5353

5454
}
5555
}
56-
?>
56+
57+
?>

admin/less/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
</head>
2727

2828
<body>
29-
<p element-id="3466" class="pvc_stats pvc_load_by_ajax_update" id="pvc_stats_3466">3,894&nbsp;total views, 1&nbsp;views today</p>
29+
<p data-element-id="3466" class="pvc_stats pvc_load_by_ajax_update" id="pvc_stats_3466">3,894&nbsp;total views, 1&nbsp;views today</p>
3030
</body>
3131
</html>

admin/less/sass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,5 @@ public function get_css_file_version( $css_file_name = '' ) {
179179
}
180180
global $a3_pvc_less;
181181
$a3_pvc_less = new A3_PVC_Less();
182-
?>
182+
183+
?>

admin/plugin-init.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Process when plugin is activated
44
*/
55
function pvc_install(){
6-
update_option( 'a3_pvc_version', '2.0.1' );
6+
update_option( 'a3_pvc_version', '2.0.2' );
77

88
// empty pvc_daily table for daily
99
wp_schedule_event( time(), 'daily', 'pvc_empty_daily_table_daily_event_hook' );
@@ -131,7 +131,7 @@ function pvc_lite_upgrade_plugin () {
131131
$a3_pvc_less->plugin_build_sass();
132132
}
133133

134-
update_option('a3_pvc_version', '2.0.1');
134+
update_option('a3_pvc_version', '2.0.2');
135135

136136
}
137137

api/pvc-api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,5 @@ public function view_stats( WP_REST_Request $request ) {
135135

136136
global $pvc_api;
137137
$pvc_api = new PVC_API();
138+
138139
?>

assets/js/pvc.backbone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jQuery( document ).ready( function( $ ) {
110110
if ( pvc_stats.length ) {
111111
var pvc_ids = {};
112112
$(".pvc_stats").each( function() {
113-
post_id = $(this).attr('element-id');
113+
post_id = $(this).data('element-id');
114114
update_status = $(this).hasClass('pvc_load_by_ajax_update');
115115
pvc_ids[post_id] = { post_id: post_id, ask_update : update_status };
116116
});

assets/js/pvc.backbone.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/class-pvc-metabox.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,5 @@ public function save( $post_id ) {
153153

154154
}
155155
new PVC_MetaBox();
156-
?>
156+
157+
?>

page-views-count.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
Plugin Name: Page Views Count
44
Description: Show front end users all time views and views today on posts, pages, index pages and custom post types with the Page Views Count Plugin. Use the Page Views Count function to add page views to any content type or object created by your theme or plugins.
5-
Version: 2.0.1
5+
Version: 2.0.2
66
Requires at least: 4.6
77
Tested up to: 4.9.1
88
Author: a3rev Software
@@ -21,7 +21,7 @@
2121
define('A3_PVC_JS_URL', A3_PVC_URL . '/assets/js');
2222
define('A3_PVC_IMAGES_URL', A3_PVC_URL . '/assets/images');
2323

24-
define('A3_PVC_VERSION', '2.0.1');
24+
define('A3_PVC_VERSION', '2.0.2');
2525

2626
/**
2727
* Load Localisation files.
@@ -86,4 +86,5 @@ function pvc_check_exclude( $postid = 0 ) {
8686
return true;
8787
}
8888
}
89-
?>
89+
90+
?>

pvc_class.php

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,38 @@ public static function pvc_fetch_posts_stats( $post_ids ) {
4949
}
5050

5151
public static function pvc_fetch_post_counts( $post_id ) {
52-
global $wpdb;
53-
$nowisnow = date('Y-m-d');
52+
$total = A3_PVC::pvc_fetch_post_total( $post_id );
53+
$today = A3_PVC::pvc_fetch_post_today( $post_id );
5454

55-
$sql = $wpdb->prepare( "SELECT t.postcount AS total, d.postcount AS today FROM ". $wpdb->prefix . "pvc_total AS t
56-
LEFT JOIN ". $wpdb->prefix . "pvc_daily AS d ON t.postnum = d.postnum
57-
WHERE t.postnum = %s AND d.time = %s", $post_id, $nowisnow );
58-
return $wpdb->get_row($sql);
55+
$post_counts = new stdClass();
56+
$post_counts->total = 0;
57+
$post_counts->today = 0;
58+
59+
if ( ! empty( $total ) ) {
60+
$post_counts->total = $total;
61+
}
62+
63+
if ( ! empty( $today ) ) {
64+
$post_counts->today = $today;
65+
}
66+
67+
return $post_counts;
5968
}
6069

6170
public static function pvc_fetch_post_total( $post_id ) {
6271
global $wpdb;
6372

64-
$sql = $wpdb->prepare( "SELECT t.postcount AS total FROM ". $wpdb->prefix . "pvc_total AS t
65-
WHERE t.postnum = %s", $post_id );
73+
$sql = $wpdb->prepare( "SELECT postcount AS total FROM ". $wpdb->prefix . "pvc_total
74+
WHERE postnum = %s", $post_id );
75+
return $wpdb->get_var($sql);
76+
}
77+
78+
public static function pvc_fetch_post_today( $post_id ) {
79+
global $wpdb;
80+
$nowisnow = date('Y-m-d');
81+
82+
$sql = $wpdb->prepare( "SELECT postcount AS today FROM ". $wpdb->prefix . "pvc_daily
83+
WHERE postnum = %s AND time = %s", $post_id, $nowisnow );
6684
return $wpdb->get_var($sql);
6785
}
6886

@@ -88,8 +106,6 @@ public static function pvc_stats_update($post_id) {
88106
$wpdb->query( $wpdb->prepare( "INSERT INTO ". $wpdb->prefix . "pvc_daily (time, postnum, postcount) VALUES ('%s', '%s', 1)", $nowisnow, $post_id ) );
89107
}
90108

91-
// get all the post view info so we can update meta fields
92-
//$row = A3_PVC::pvc_fetch_post_counts( $post_id );
93109
}
94110

95111
public static function pvc_stats_manual_update( $post_id, $new_total_views, $new_today_views ) {
@@ -117,23 +133,29 @@ public static function pvc_stats_manual_update( $post_id, $new_total_views, $new
117133
}
118134
}
119135

120-
public static function pvc_get_stats($post_id) {
136+
public static function pvc_get_stats( $post_id ) {
121137
global $wpdb;
122138

123139
$output_html = '';
124140
// get all the post view info to display
125-
$results = A3_PVC::pvc_fetch_post_counts( $post_id );
126-
// get the stats and
127-
if ( $results ){
128-
$output_html .= number_format( $results->total ) . '&nbsp;' .__('total views', 'page-views-count') . ', ' . number_format( $results->today ) . '&nbsp;' .__('views today', 'page-views-count');
129-
} else {
130-
$total = A3_PVC::pvc_fetch_post_total( $post_id );
131-
if ( $total > 0 ) {
132-
$output_html .= number_format( $total ) . '&nbsp;' .__('total views', 'page-views-count') . ', ' .__('no views today', 'page-views-count');
141+
$total = A3_PVC::pvc_fetch_post_total( $post_id );
142+
$today = A3_PVC::pvc_fetch_post_today( $post_id );
143+
144+
if ( ! empty( $total ) ) {
145+
146+
$output_html .= number_format( $total ) . '&nbsp;' .__('total views', 'page-views-count');
147+
$output_html .= ', ';
148+
149+
if ( ! empty( $today ) ) {
150+
$output_html .= number_format( $results->today ) . '&nbsp;' .__('views today', 'page-views-count');
133151
} else {
134-
$output_html .= __('No views yet', 'page-views-count');
152+
$output_html .= __('no views today', 'page-views-count');
135153
}
154+
155+
} else {
156+
$output_html .= __('No views yet', 'page-views-count');
136157
}
158+
137159
$output_html = apply_filters( 'pvc_filter_get_stats', $output_html, $post_id );
138160

139161
return $output_html;
@@ -151,9 +173,9 @@ public static function pvc_stats_counter( $post_id, $increase_views = false ) {
151173
$html = '<div class="pvc_clear"></div>';
152174

153175
if ( $pvc_settings['enable_ajax_load'] == 'yes' ) {
154-
$stats_html = '<p id="pvc_stats_'.$post_id.'" class="pvc_stats '.$load_by_ajax_update_class.'" element-id="'.$post_id.'"><i class="fa fa-bar-chart pvc-stats-icon '.$pvc_settings['icon_size'].'" aria-hidden="true"></i> <img src="'.A3_PVC_URL.'/ajax-loader.gif" border=0 /></p>';
176+
$stats_html = '<p id="pvc_stats_'.$post_id.'" class="pvc_stats '.$load_by_ajax_update_class.'" data-element-id="'.$post_id.'"><i class="fa fa-bar-chart pvc-stats-icon '.$pvc_settings['icon_size'].'" aria-hidden="true"></i> <img src="'.A3_PVC_URL.'/ajax-loader.gif" border=0 /></p>';
155177
} else {
156-
$stats_html = '<p class="pvc_stats" element-id="'.$post_id.'"><i class="fa fa-bar-chart pvc-stats-icon '.$pvc_settings['icon_size'].'" aria-hidden="true"></i> ' . A3_PVC::pvc_get_stats( $post_id ) . '</p>';
178+
$stats_html = '<p class="pvc_stats" data-element-id="'.$post_id.'"><i class="fa fa-bar-chart pvc-stats-icon '.$pvc_settings['icon_size'].'" aria-hidden="true"></i> ' . A3_PVC::pvc_get_stats( $post_id ) . '</p>';
157179
}
158180

159181
$html .= apply_filters( 'pvc_filter_stats', $stats_html, $post_id );

readme.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: a3rev, a3rev Software, nguyencongtuan
33
Tags: wordpress page view, page view count , post views, postview count,
44
Requires at least: 4.6
55
Tested up to: 4.9.1
6-
Stable tag: 2.0.1
6+
Stable tag: 2.0.2
77
License: GPLv3
88
License URI: http://www.gnu.org/licenses/gpl-3.0.html
99

@@ -89,6 +89,12 @@ The manual installation method involves down loading our plugin and uploading it
8989

9090
== Changelog ==
9191

92+
= 2.0.2 - 2017/12/14 =
93+
* Maintenance Update. This update includes 3 bug fixes, including AMP pages conpatibility
94+
* Fix - Headers already sent warning. Delete trailing spaces at bottom of php file
95+
* Fix - Change attribute name element-id to data-element-id for compatibility with AMP. Thanks to @veenareddys for reporting the issue
96+
* Fix - Update SQL query for fix bug get incorrect total views when edit a Post or Page. Thanks to @groenhart for reporting this issue
97+
9298
= 2.0.1 - 2017/12/13 =
9399
* Maintenance Update. 3 code tweaks for compatibility with WordPress 4.9.1 and 2 bug fixes
94100
* Tweak - Removed auto redirect to plugins admin panel on activation
@@ -264,6 +270,9 @@ The manual installation method involves down loading our plugin and uploading it
264270

265271
== Upgrade Notice ==
266272

273+
= 2.0.2 =
274+
Maintenance Update. This update includes 3 bug fixes, including AMP pages compatibility
275+
267276
= 2.0.1 =
268277
Maintenance Update. 3 code tweaks for compatibility with WordPress 4.9.1 and 2 bug fixes
269278

0 commit comments

Comments
 (0)