From 2814d91690004a7a206d7ce97f17de90c577fa87 Mon Sep 17 00:00:00 2001 From: Nguyen Tuan Date: Wed, 13 Dec 2017 16:45:51 +0700 Subject: [PATCH] Release version 2.0.1 * 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 * Tweak - Added Settings link to plugins description on plugins menu * Tweak - Remove console log from script as it was causing theme Customizer to load slowly * Tweak - Tested for compatibility with WordPress 4.9.1 * Fix - Update regex expression in the REST endpoint so that it accepts array-like params as expected. * Fix - Get correct item ID if params is parse as array * Credit - Thanks to Cypwu for the Github contribution for REST endpoint modification --- admin/plugin-init.php | 12 ++++-------- api/pvc-api.php | 2 +- assets/js/pvc.backbone.js | 12 ++++++------ assets/js/pvc.backbone.min.js | 2 +- page-views-count.php | 6 +++--- readme.txt | 17 +++++++++++++++-- 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/admin/plugin-init.php b/admin/plugin-init.php index 1a0c588..5325765 100755 --- a/admin/plugin-init.php +++ b/admin/plugin-init.php @@ -3,7 +3,7 @@ * Process when plugin is activated */ function pvc_install(){ - update_option( 'a3_pvc_version', '2.0.0' ); + update_option( 'a3_pvc_version', '2.0.1' ); // empty pvc_daily table for daily wp_schedule_event( time(), 'daily', 'pvc_empty_daily_table_daily_event_hook' ); @@ -30,15 +30,11 @@ function pvc_deactivation() { update_option('a3rev_auth_pvc', ''); function a3_pvc_plugin_init() { - if ( get_option('pvc_just_installed') ) { - delete_option('pvc_just_installed'); - wp_redirect( admin_url( 'options-general.php?page=a3-pvc', 'relative' ) ); - exit; - } // Set up localisation a3_pvc_load_plugin_textdomain(); } + add_action( 'init', 'a3_pvc_plugin_init' ); // Add custom style to dashboard @@ -68,7 +64,7 @@ function pvc_empty_daily_table_do_daily() { } $pvc_settings = get_option( 'pvc_settings', array( 'position' => 'bottom' ) ); -if ( 'top' == $pvc_settings['position'] ) { +if ( isset( $pvc_settings['position'] ) && 'top' == $pvc_settings['position'] ) { add_action('genesis_before_post_content', array('A3_PVC', 'genesis_pvc_stats_echo')); } else { add_action('genesis_after_post_content', array('A3_PVC', 'genesis_pvc_stats_echo')); @@ -135,7 +131,7 @@ function pvc_lite_upgrade_plugin () { $a3_pvc_less->plugin_build_sass(); } - update_option('a3_pvc_version', '2.0.0'); + update_option('a3_pvc_version', '2.0.1'); } diff --git a/api/pvc-api.php b/api/pvc-api.php index 8525459..78244de 100755 --- a/api/pvc-api.php +++ b/api/pvc-api.php @@ -135,4 +135,4 @@ public function view_stats( WP_REST_Request $request ) { global $pvc_api; $pvc_api = new PVC_API(); -?> +?> \ No newline at end of file diff --git a/assets/js/pvc.backbone.js b/assets/js/pvc.backbone.js index ea6e371..bcbd228 100755 --- a/assets/js/pvc.backbone.js +++ b/assets/js/pvc.backbone.js @@ -36,7 +36,7 @@ jQuery( function( $ ) { }, render: function() { - console.log('Rendering Page View Count of ID #' + this.model.get('post_id') + ' - Today: #' + this.model.get('today_view') + ' - Total: #' + this.model.get('total_view')); + //console.log('Rendering Page View Count of ID #' + this.model.get('post_id') + ' - Today: #' + this.model.get('today_view') + ' - Total: #' + this.model.get('total_view')); this.$el.html( this.template( this.model.toJSON() ) ); return this; @@ -59,22 +59,22 @@ jQuery( function( $ ) { pvc.apps.app = { initialize: function( pvc_ids, rest_api_url ) { this.rest_api_url = rest_api_url; - console.log('Load Page View Count of ' + JSON.stringify(pvc_ids) ); + //console.log('Load Page View Count of ' + JSON.stringify(pvc_ids) ); view_pvc_ids = []; increase_pvc_ids = []; $.each( pvc_ids, function (index, data) { if ( data.ask_update ) { - increase_pvc_ids.push( post_id ); + increase_pvc_ids.push( data.post_id ); } else { - view_pvc_ids.push( post_id ); + view_pvc_ids.push( data.post_id ); } }); if ( increase_pvc_ids.length ) { $.get( this.rest_api_url + '/increase/' + increase_pvc_ids.join(','), function( data_pvc ) { - console.log(data_pvc); + //console.log(data_pvc); if ( data_pvc.success ) { $.each( data_pvc.items, function (index, data) { collection = new pvc.collections.Stats; @@ -88,7 +88,7 @@ jQuery( function( $ ) { if ( view_pvc_ids.length ) { $.get( this.rest_api_url + '/view/' + view_pvc_ids.join(','), function( data_pvc ) { - console.log(data_pvc); + //console.log(data_pvc); if ( data_pvc.success ) { $.each( data_pvc.items , function (index, data) { collection = new pvc.collections.Stats; diff --git a/assets/js/pvc.backbone.min.js b/assets/js/pvc.backbone.min.js index 4e495b9..432639b 100755 --- a/assets/js/pvc.backbone.min.js +++ b/assets/js/pvc.backbone.min.js @@ -1 +1 @@ -jQuery(function(e){var t=vars.rest_api_url;pvc={apps:{},models:{},collections:{},views:{}},_.templateSettings={evaluate:/[<{][%{](.+?)[%}][}>]/g,interpolate:/[<{][%{]=(.+?)[%}][}>]/g,escape:/[<{][%{]-(.+?)[%}][}>]/g},pvc.models.State=Backbone.Model.extend({defaults:{post_id:0,total_view:1,today_view:1}}),pvc.collections.Stats=Backbone.Collection.extend({model:pvc.models.State,url:t}),pvc.views.State=Backbone.View.extend({model:pvc.models.State,tagName:"span",template:_.template(e("#pvc-stats-view-template").html()),initialize:function(){},render:function(){return console.log("Rendering Page View Count of ID #"+this.model.get("post_id")+" - Today: #"+this.model.get("today_view")+" - Total: #"+this.model.get("total_view")),this.$el.html(this.template(this.model.toJSON())),this}}),pvc.views.AppView=Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"add",this.addOne)},addOne:function(e){var t=new pvc.views.State({model:e});this.$el.html(t.render().el)}}),pvc.apps.app={initialize:function(t,i){this.rest_api_url=i,console.log("Load Page View Count of "+JSON.stringify(t)),view_pvc_ids=[],increase_pvc_ids=[],e.each(t,function(e,t){t.ask_update?increase_pvc_ids.push(post_id):view_pvc_ids.push(post_id)}),increase_pvc_ids.length&&e.get(this.rest_api_url+"/increase/"+increase_pvc_ids.join(","),function(t){console.log(t),t.success&&e.each(t.items,function(t,i){collection=new pvc.collections.Stats,new pvc.views.AppView({collection:collection,el:e("#pvc_stats_"+t)}),collection.add(i)})}),view_pvc_ids.length&&e.get(this.rest_api_url+"/view/"+view_pvc_ids.join(","),function(t){console.log(t),t.success&&e.each(t.items,function(t,i){collection=new pvc.collections.Stats,new pvc.views.AppView({collection:collection,el:e("#pvc_stats_"+t)}),collection.add(i)})})}}}),jQuery(document).ready(function(e){if(e(".pvc_stats").length){var t={};e(".pvc_stats").each(function(){post_id=e(this).attr("element-id"),update_status=e(this).hasClass("pvc_load_by_ajax_update"),t[post_id]={post_id:post_id,ask_update:update_status}}),pvc.apps.app.initialize(t,vars.rest_api_url)}}); \ No newline at end of file +jQuery(function(a){var b=vars.rest_api_url;pvc={apps:{},models:{},collections:{},views:{}};_.templateSettings={evaluate:/[<{][%{](.+?)[%}][}>]/g,interpolate:/[<{][%{]=(.+?)[%}][}>]/g,escape:/[<{][%{]-(.+?)[%}][}>]/g};pvc.models.State=Backbone.Model.extend({defaults:{post_id:0,total_view:1,today_view:1}});pvc.collections.Stats=Backbone.Collection.extend({model:pvc.models.State,url:b});pvc.views.State=Backbone.View.extend({model:pvc.models.State,tagName:"span",template:_.template(a("#pvc-stats-view-template").html()),initialize:function(){},render:function(){this.$el.html(this.template(this.model.toJSON()));return this}});pvc.views.AppView=Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"add",this.addOne)},addOne:function(a){a=new pvc.views.State({model:a});this.$el.html(a.render().el)}});pvc.apps.app={initialize:function(b,e){this.rest_api_url=e;view_pvc_ids=[];increase_pvc_ids=[];a.each(b,function(a,c){c.ask_update?increase_pvc_ids.push(c.post_id):view_pvc_ids.push(c.post_id)});increase_pvc_ids.length&&a.get(this.rest_api_url+"/increase/"+increase_pvc_ids.join(","),function(b){b.success&&a.each(b.items,function(b,d){collection=new pvc.collections.Stats;new pvc.views.AppView({collection:collection,el:a("#pvc_stats_"+b)});collection.add(d)})});view_pvc_ids.length&&a.get(this.rest_api_url+"/view/"+view_pvc_ids.join(","),function(b){b.success&&a.each(b.items,function(b,d){collection=new pvc.collections.Stats;new pvc.views.AppView({collection:collection,el:a("#pvc_stats_"+b)});collection.add(d)})})}}});jQuery(document).ready(function(a){if(a(".pvc_stats").length){var b={};a(".pvc_stats").each(function(){post_id=a(this).attr("element-id");update_status=a(this).hasClass("pvc_load_by_ajax_update");b[post_id]={post_id:post_id,ask_update:update_status}});pvc.apps.app.initialize(b,vars.rest_api_url)}}); \ No newline at end of file diff --git a/page-views-count.php b/page-views-count.php index f7007d4..07bffc9 100755 --- a/page-views-count.php +++ b/page-views-count.php @@ -2,9 +2,9 @@ /* 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.0 +Version: 2.0.1 Requires at least: 4.6 -Tested up to: 4.9.0 +Tested up to: 4.9.1 Author: a3rev Software Author URI: https://a3rev.com Text Domain: page-views-count @@ -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.0'); +define('A3_PVC_VERSION', '2.0.1'); /** * Load Localisation files. diff --git a/readme.txt b/readme.txt index db8dd78..2ce33e9 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ 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.0 -Stable tag: 2.0.0 +Tested up to: 4.9.1 +Stable tag: 2.0.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -89,6 +89,16 @@ The manual installation method involves down loading our plugin and uploading it == Changelog == += 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 +* Tweak - Added Settings link to plugins description on plugins menu +* Tweak - Remove console log from script as it was causing theme Customizer to load slowly +* Tweak - Tested for compatibility with WordPress 4.9.1 +* Fix - Update regex expression in the REST endpoint so that it accepts array-like params as expected. +* Fix - Get correct item ID if params is parse as array +* Credit - Thanks to Cypwu for the Github contribution for REST endpoint modification + = 2.0.0 - 2017/06/02 = * Feature - Upgrade Stats image icon to fontawesome Chart Icon * Feature - Add new + Counter Position and Style options box on plugins admin panel @@ -254,6 +264,9 @@ The manual installation method involves down loading our plugin and uploading it == Upgrade Notice == += 2.0.1 = +Maintenance Update. 3 code tweaks for compatibility with WordPress 4.9.1 and 2 bug fixes + = 2.0.0 = Major Feature Upgrade. Release of 7 new features and 2 code tweaks for compatibility with upcoming WordPress major version 4.8.0