Skip to content

Commit

Permalink
Release version 2.0.2
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alextuan committed Dec 14, 2017
1 parent 2814d91 commit 256a354
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 38 deletions.
2 changes: 1 addition & 1 deletion admin/admin-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,4 @@ public function admin_settings_tab( $current_page = '', $tab_data = array() ) {
global $wp_pvc_admin_init;
$wp_pvc_admin_init = new WP_PVC_Admin_Init();

?>
?>
2 changes: 1 addition & 1 deletion admin/admin-interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3701,4 +3701,4 @@ public function generate_background_color_css( $option, $transparency = 100 ) {
global $wp_pvc_admin_interface;
$wp_pvc_admin_interface = new WP_PVC_Admin_Interface();

?>
?>
2 changes: 1 addition & 1 deletion admin/admin-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,4 @@ public function get_version_message() {

}

?>
?>
2 changes: 1 addition & 1 deletion admin/includes/uploader/class-uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ public function upload_input ( $name_attribute, $id_attribute = '', $value = '',
global $wp_pvc_uploader;
$wp_pvc_uploader = new WP_PVC_Uploader();

?>
?>
3 changes: 2 additions & 1 deletion admin/less/compile_less_sass_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ public function compileLessFile( $less_file = '', $css_file = '', $css_min_file

}
}
?>

?>
2 changes: 1 addition & 1 deletion admin/less/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
</head>

<body>
<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>
<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>
</body>
</html>
3 changes: 2 additions & 1 deletion admin/less/sass.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,5 @@ public function get_css_file_version( $css_file_name = '' ) {
}
global $a3_pvc_less;
$a3_pvc_less = new A3_PVC_Less();
?>

?>
4 changes: 2 additions & 2 deletions admin/plugin-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Process when plugin is activated
*/
function pvc_install(){
update_option( 'a3_pvc_version', '2.0.1' );
update_option( 'a3_pvc_version', '2.0.2' );

// empty pvc_daily table for daily
wp_schedule_event( time(), 'daily', 'pvc_empty_daily_table_daily_event_hook' );
Expand Down Expand Up @@ -131,7 +131,7 @@ function pvc_lite_upgrade_plugin () {
$a3_pvc_less->plugin_build_sass();
}

update_option('a3_pvc_version', '2.0.1');
update_option('a3_pvc_version', '2.0.2');

}

Expand Down
1 change: 1 addition & 0 deletions api/pvc-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@ public function view_stats( WP_REST_Request $request ) {

global $pvc_api;
$pvc_api = new PVC_API();

?>
2 changes: 1 addition & 1 deletion assets/js/pvc.backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jQuery( document ).ready( function( $ ) {
if ( pvc_stats.length ) {
var pvc_ids = {};
$(".pvc_stats").each( function() {
post_id = $(this).attr('element-id');
post_id = $(this).data('element-id');
update_status = $(this).hasClass('pvc_load_by_ajax_update');
pvc_ids[post_id] = { post_id: post_id, ask_update : update_status };
});
Expand Down
2 changes: 1 addition & 1 deletion assets/js/pvc.backbone.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion classes/class-pvc-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@ public function save( $post_id ) {

}
new PVC_MetaBox();
?>

?>
7 changes: 4 additions & 3 deletions page-views-count.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: Page Views Count
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.
Version: 2.0.1
Version: 2.0.2
Requires at least: 4.6
Tested up to: 4.9.1
Author: a3rev Software
Expand All @@ -21,7 +21,7 @@
define('A3_PVC_JS_URL', A3_PVC_URL . '/assets/js');
define('A3_PVC_IMAGES_URL', A3_PVC_URL . '/assets/images');

define('A3_PVC_VERSION', '2.0.1');
define('A3_PVC_VERSION', '2.0.2');

/**
* Load Localisation files.
Expand Down Expand Up @@ -86,4 +86,5 @@ function pvc_check_exclude( $postid = 0 ) {
return true;
}
}
?>

?>
66 changes: 44 additions & 22 deletions pvc_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,38 @@ public static function pvc_fetch_posts_stats( $post_ids ) {
}

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

$sql = $wpdb->prepare( "SELECT t.postcount AS total, d.postcount AS today FROM ". $wpdb->prefix . "pvc_total AS t
LEFT JOIN ". $wpdb->prefix . "pvc_daily AS d ON t.postnum = d.postnum
WHERE t.postnum = %s AND d.time = %s", $post_id, $nowisnow );
return $wpdb->get_row($sql);
$post_counts = new stdClass();
$post_counts->total = 0;
$post_counts->today = 0;

if ( ! empty( $total ) ) {
$post_counts->total = $total;
}

if ( ! empty( $today ) ) {
$post_counts->today = $today;
}

return $post_counts;
}

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

$sql = $wpdb->prepare( "SELECT t.postcount AS total FROM ". $wpdb->prefix . "pvc_total AS t
WHERE t.postnum = %s", $post_id );
$sql = $wpdb->prepare( "SELECT postcount AS total FROM ". $wpdb->prefix . "pvc_total
WHERE postnum = %s", $post_id );
return $wpdb->get_var($sql);
}

public static function pvc_fetch_post_today( $post_id ) {
global $wpdb;
$nowisnow = date('Y-m-d');

$sql = $wpdb->prepare( "SELECT postcount AS today FROM ". $wpdb->prefix . "pvc_daily
WHERE postnum = %s AND time = %s", $post_id, $nowisnow );
return $wpdb->get_var($sql);
}

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

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

public static function pvc_stats_manual_update( $post_id, $new_total_views, $new_today_views ) {
Expand Down Expand Up @@ -117,23 +133,29 @@ public static function pvc_stats_manual_update( $post_id, $new_total_views, $new
}
}

public static function pvc_get_stats($post_id) {
public static function pvc_get_stats( $post_id ) {
global $wpdb;

$output_html = '';
// get all the post view info to display
$results = A3_PVC::pvc_fetch_post_counts( $post_id );
// get the stats and
if ( $results ){
$output_html .= number_format( $results->total ) . '&nbsp;' .__('total views', 'page-views-count') . ', ' . number_format( $results->today ) . '&nbsp;' .__('views today', 'page-views-count');
} else {
$total = A3_PVC::pvc_fetch_post_total( $post_id );
if ( $total > 0 ) {
$output_html .= number_format( $total ) . '&nbsp;' .__('total views', 'page-views-count') . ', ' .__('no views today', 'page-views-count');
$total = A3_PVC::pvc_fetch_post_total( $post_id );
$today = A3_PVC::pvc_fetch_post_today( $post_id );

if ( ! empty( $total ) ) {

$output_html .= number_format( $total ) . '&nbsp;' .__('total views', 'page-views-count');
$output_html .= ', ';

if ( ! empty( $today ) ) {
$output_html .= number_format( $results->today ) . '&nbsp;' .__('views today', 'page-views-count');
} else {
$output_html .= __('No views yet', 'page-views-count');
$output_html .= __('no views today', 'page-views-count');
}

} else {
$output_html .= __('No views yet', 'page-views-count');
}

$output_html = apply_filters( 'pvc_filter_get_stats', $output_html, $post_id );

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

if ( $pvc_settings['enable_ajax_load'] == 'yes' ) {
$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>';
$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>';
} else {
$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>';
$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>';
}

$html .= apply_filters( 'pvc_filter_stats', $stats_html, $post_id );
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: a3rev, a3rev Software, nguyencongtuan
Tags: wordpress page view, page view count , post views, postview count,
Requires at least: 4.6
Tested up to: 4.9.1
Stable tag: 2.0.1
Stable tag: 2.0.2
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

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

== Changelog ==

= 2.0.2 - 2017/12/14 =
* 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

= 2.0.1 - 2017/12/13 =
* Maintenance Update. 3 code tweaks for compatibility with WordPress 4.9.1 and 2 bug fixes
* Tweak - Removed auto redirect to plugins admin panel on activation
Expand Down Expand Up @@ -264,6 +270,9 @@ The manual installation method involves down loading our plugin and uploading it

== Upgrade Notice ==

= 2.0.2 =
Maintenance Update. This update includes 3 bug fixes, including AMP pages compatibility

= 2.0.1 =
Maintenance Update. 3 code tweaks for compatibility with WordPress 4.9.1 and 2 bug fixes

Expand Down

0 comments on commit 256a354

Please sign in to comment.