Skip to content

Commit d4c0ee0

Browse files
committed
Release new version 2.2.0
= 2.2.0 - 2019/09/12 = * This feature upgrade is a full refactor of the plugins PHP to PHP dependency manager Composer with autoloading. * Feature - Plugin fully refactored to Composer for cleaner code and faster PHP code
1 parent b80ff91 commit d4c0ee0

20 files changed

+480
-265
lines changed

admin/plugin-init.php

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function pvc_install(){
88
// empty pvc_daily table for daily
99
wp_schedule_event( time(), 'daily', 'pvc_empty_daily_table_daily_event_hook' );
1010

11-
A3_PVC::install_database();
11+
\A3Rev\PageViewsCount\A3_PVC::install_database();
1212

1313
// Set Settings Default from Admin Init
1414
global $wp_pvc_admin_init;
@@ -38,21 +38,21 @@ function a3_pvc_plugin_init() {
3838
add_action( 'init', 'a3_pvc_plugin_init' );
3939

4040
// Add custom style to dashboard
41-
add_action( 'admin_enqueue_scripts', array( 'A3_PVC', 'a3_wp_admin' ) );
41+
add_action( 'admin_enqueue_scripts', array( '\A3Rev\PageViewsCount\A3_PVC', 'a3_wp_admin' ) );
4242

4343
// Add extra link on left of Deactivate link on Plugin manager page
44-
add_action('plugin_action_links_'.A3_PVC_PLUGIN_NAME, array('A3_PVC', 'settings_plugin_links') );
44+
add_action('plugin_action_links_'.A3_PVC_PLUGIN_NAME, array('\A3Rev\PageViewsCount\A3_PVC', 'settings_plugin_links') );
4545

4646
// Add text on right of Visit the plugin on Plugin manager page
47-
add_filter( 'plugin_row_meta', array('A3_PVC', 'plugin_extra_links'), 10, 2 );
47+
add_filter( 'plugin_row_meta', array('\A3Rev\PageViewsCount\A3_PVC', 'plugin_extra_links'), 10, 2 );
4848

4949

5050
// Need to call Admin Init to show Admin UI
5151
global $wp_pvc_admin_init;
5252
$wp_pvc_admin_init->init();
5353

5454
// Add upgrade notice to Dashboard pages
55-
add_filter( $wp_pvc_admin_init->plugin_name . '_plugin_extension_boxes', array( 'A3_PVC', 'plugin_extension_box' ) );
55+
add_filter( $wp_pvc_admin_init->plugin_name . '_plugin_extension_boxes', array( '\A3Rev\PageViewsCount\A3_PVC', 'plugin_extension_box' ) );
5656

5757
/**
5858
* On the scheduled action hook, run the function.
@@ -65,17 +65,17 @@ function pvc_empty_daily_table_do_daily() {
6565

6666
$pvc_settings = get_option( 'pvc_settings', array( 'position' => 'bottom' ) );
6767
if ( isset( $pvc_settings['position'] ) && 'top' == $pvc_settings['position'] ) {
68-
add_action('genesis_before_post_content', array('A3_PVC', 'genesis_pvc_stats_echo'));
68+
add_action('genesis_before_post_content', array('\A3Rev\PageViewsCount\A3_PVC', 'genesis_pvc_stats_echo'));
6969
} else {
70-
add_action('genesis_after_post_content', array('A3_PVC', 'genesis_pvc_stats_echo'));
70+
add_action('genesis_after_post_content', array('\A3Rev\PageViewsCount\A3_PVC', 'genesis_pvc_stats_echo'));
7171
}
72-
//add_action('loop_end', array('A3_PVC', 'pvc_stats_echo'), 9);
73-
add_filter('the_content', array('A3_PVC','pvc_stats_show'), 8);
74-
add_filter('the_excerpt', array('A3_PVC','excerpt_pvc_stats_show'), 8);
75-
//add_filter('get_the_excerpt', array('A3_PVC','excerpt_pvc_stats_show'), 8);
72+
//add_action('loop_end', array('\A3Rev\PageViewsCount\A3_PVC', 'pvc_stats_echo'), 9);
73+
add_filter('the_content', array('\A3Rev\PageViewsCount\A3_PVC','pvc_stats_show'), 8);
74+
add_filter('the_excerpt', array('\A3Rev\PageViewsCount\A3_PVC','excerpt_pvc_stats_show'), 8);
75+
//add_filter('get_the_excerpt', array('\A3Rev\PageViewsCount\A3_PVC','excerpt_pvc_stats_show'), 8);
7676

7777
// Add ajax script to load page view count stats into footer
78-
add_action( 'wp_enqueue_scripts', array( 'A3_PVC', 'register_plugin_scripts' ) );
78+
add_action( 'wp_enqueue_scripts', array( '\A3Rev\PageViewsCount\A3_PVC', 'register_plugin_scripts' ) );
7979

8080
// Check upgrade functions
8181
add_action('plugins_loaded', 'pvc_lite_upgrade_plugin');
@@ -84,7 +84,7 @@ function pvc_lite_upgrade_plugin () {
8484

8585
if(version_compare(get_option('a3_pvc_version'), '1.2') === -1){
8686
update_option('a3_pvc_version', '1.2');
87-
A3_PVC::upgrade_version_1_2();
87+
\A3Rev\PageViewsCount\A3_PVC::upgrade_version_1_2();
8888
}
8989

9090
if(version_compare(get_option('a3_pvc_version'), '1.3.5') === -1){
@@ -132,4 +132,52 @@ function pvc_lite_upgrade_plugin () {
132132

133133
}
134134

135+
if ( 'responsi' === get_template() ) {
136+
remove_filter('the_content', array(
137+
'\A3Rev\PageViewsCount\A3_PVC',
138+
'pvc_stats_show'
139+
), 8);
140+
remove_filter('the_excerpt', array(
141+
'\A3Rev\PageViewsCount\A3_PVC',
142+
'excerpt_pvc_stats_show'
143+
), 8);
144+
145+
if (!function_exists( 'add_view_count')) {
146+
function add_view_count()
147+
{
148+
$postid = get_the_ID();
149+
$html = '';
150+
$class = '';
151+
if (!is_single() && !is_page() && !is_404()) {
152+
$class = ' custom_box';
153+
}
154+
if (function_exists('pvc_check_exclude') && pvc_check_exclude())
155+
return '';
156+
157+
if (function_exists('pvc_stats_update'))
158+
$html .= '<div class="add_view_count' . $class . '">' . pvc_stats_update($postid, 0) . '</div>';
159+
echo $html;
160+
}
161+
}
162+
163+
if (!function_exists( 'add_view_count_for_theme')) {
164+
function add_view_count_for_theme()
165+
{
166+
remove_filter('the_content', array( '\A3Rev\PageViewsCount\A3_PVC', 'pvc_stats_show'), 8);
167+
remove_filter('the_excerpt', array( '\A3Rev\PageViewsCount\A3_PVC', 'excerpt_pvc_stats_show'), 8);
168+
if ( !is_admin() && !is_home() ) {
169+
global $pvc_settings;
170+
if ( 'top' == $pvc_settings['position'] ) {
171+
add_action('responsi_loop_before', 'add_view_count', 30);
172+
} else {
173+
add_action('responsi_loop_after', 'add_view_count', 30);
174+
}
175+
}
176+
}
177+
}
178+
179+
remove_action('wp_head', 'add_view_count_for_theme');
180+
add_action('wp_head', 'add_view_count_for_theme');
181+
}
182+
135183
?>

admin/settings/general-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function set_default_settings() {
120120
public function clean_on_deletion() {
121121
if ( isset( $_POST['bt_save_settings'] ) && isset( $_POST['pvc_reset_all_individual'] ) ) {
122122
delete_option( 'pvc_reset_all_individual' );
123-
A3_PVC::pvc_reset_individual_items();
123+
\A3Rev\PageViewsCount\A3_PVC::pvc_reset_individual_items();
124124
}
125125

126126
if ( ( isset( $_POST['bt_save_settings'] ) || isset( $_POST['bt_reset_settings'] ) ) && get_option( $this->plugin_name . '_clean_on_deletion' ) == 0 ) {

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "a3rev/pageviewscount",
3+
"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.",
4+
"license": "A \"Slug\" license name e.g. GPL2",
5+
"authors": [
6+
{
7+
"name": "a3rev Software",
8+
"email": "admin@a3rev.com"
9+
}
10+
],
11+
"config": {
12+
"optimize-autoloader": true
13+
},
14+
"require": {
15+
"php": ">=5.6|>=7.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"A3Rev\\PageViewsCount\\": "src/"
20+
}
21+
}
22+
}

dist/blocks.build.js

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

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "page-views-count-cgb-guten-block",
3+
"version": "1.0.0",
4+
"private": true,
5+
"scripts": {
6+
"start": "cgb-scripts start",
7+
"build": "cgb-scripts build",
8+
"eject": "cgb-scripts eject"
9+
},
10+
"dependencies": {
11+
"cgb-scripts": "1.13.0"
12+
},
13+
"devDependencies": {
14+
"@svgr/webpack": "^4.3.2"
15+
}
16+
}

page-views-count.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
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.1.3
5+
Version: 2.2.0
66
Requires at least: 4.6
7-
Tested up to: 5.2.2
7+
Tested up to: 5.2.3
88
Author: a3rev Software
99
Author URI: https://a3rev.com
1010
Text Domain: page-views-count
@@ -22,9 +22,22 @@
2222
define('A3_PVC_IMAGES_URL', A3_PVC_URL . '/assets/images');
2323

2424
define( 'A3_PVC_KEY', 'a3_page_view_count' );
25-
define( 'A3_PVC_VERSION', '2.1.3' );
25+
define( 'A3_PVC_VERSION', '2.2.0' );
2626
define( 'A3_PVC_G_FONTS', false );
2727

28+
if ( version_compare( PHP_VERSION, '5.6.0', '>=' ) ) {
29+
require __DIR__ . '/vendor/autoload.php';
30+
31+
// Gutenberg blocks init
32+
new \A3Rev\PageViewsCount\Blocks();
33+
new \A3Rev\PageViewsCount\MetaBox();
34+
35+
global $pvc_api;
36+
$pvc_api = new \A3Rev\PageViewsCount\API();
37+
} else {
38+
return;
39+
}
40+
2841
/**
2942
* Load Localisation files.
3043
*
@@ -42,9 +55,6 @@ function a3_pvc_load_plugin_textdomain() {
4255
load_plugin_textdomain( 'page-views-count', false, A3_PVC_FOLDER . '/languages/' );
4356
}
4457

45-
// API Class
46-
include_once( 'api/pvc-api.php' );
47-
4858
include ('admin/admin-ui.php');
4959
include ('admin/admin-interface.php');
5060

@@ -53,10 +63,6 @@ function a3_pvc_load_plugin_textdomain() {
5363
include ('admin/admin-init.php');
5464
include ('admin/less/sass.php');
5565

56-
include ("pvc_class.php");
57-
include ("classes/class-pvc-metabox.php");
58-
include ('src/blocks.php');
59-
6066
include ('admin/plugin-init.php');
6167

6268
/**
@@ -70,15 +76,15 @@ function a3_pvc_load_plugin_textdomain() {
7076
register_deactivation_hook(__FILE__, 'pvc_deactivation');
7177

7278
function pvc_stats( $postid, $have_echo = 1, $attributes = array() ) {
73-
return A3_PVC::custom_stats_echo( $postid, $have_echo, $attributes );
79+
return \A3Rev\PageViewsCount\A3_PVC::custom_stats_echo( $postid, $have_echo, $attributes );
7480
}
7581

7682
function pvc_stats_update( $postid, $have_echo = 1, $attributes = array() ) {
77-
return A3_PVC::custom_stats_update_echo( $postid, $have_echo, $attributes );
83+
return \A3Rev\PageViewsCount\A3_PVC::custom_stats_update_echo( $postid, $have_echo, $attributes );
7884
}
7985

8086
function pvc_is_activated( $postid = 0 ) {
81-
return A3_PVC::pvc_is_activated( $postid );
87+
return \A3Rev\PageViewsCount\A3_PVC::pvc_is_activated( $postid );
8288
}
8389

8490
// For Support 3rd party plugins have used this on their custom code

prettier.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
printWidth: 100,
3+
singleQuote: true,
4+
trailingComma: 'all',
5+
bracketSpacing: true,
6+
jsxBracketSameLine: false,
7+
tabWidth: 2,
8+
semi: true
9+
};

readme.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: a3rev, a3rev Software, nguyencongtuan
33
Tags: wordpress page view, page view count , post views, post view count, gutenberg
44
Requires at least: 4.6
5-
Tested up to: 5.2.2
6-
Stable tag: 2.1.3
5+
Tested up to: 5.2.3
6+
Stable tag: 2.2.0
77
License: GPLv3
88
License URI: http://www.gnu.org/licenses/gpl-3.0.html
99

@@ -98,6 +98,10 @@ The manual installation method involves down loading our plugin and uploading it
9898

9999
== Changelog ==
100100

101+
= 2.2.0 - 2019/09/12 =
102+
* This feature upgrade is a full refactor of the plugins PHP to PHP dependency manager Composer with autoloading.
103+
* Feature - Plugin fully refactored to Composer for cleaner code and faster PHP code
104+
101105
= 2.1.3 - 2019/08/01 =
102106
* This maintenance upgrade is to fix a style conflict with fontawesome icons
103107
* Fix - fontawesome icons not able to get correct style on frontend when the fontawesome script is loaded on the page by theme or another plugin.
@@ -326,6 +330,9 @@ The manual installation method involves down loading our plugin and uploading it
326330

327331
== Upgrade Notice ==
328332

333+
= 2.2.0 =
334+
This feature upgrade is a full refactor of the plugins PHP to PHP dependency manager Composer with autoloading.
335+
329336
= 2.1.3 =
330337
This maintenance upgrade is to fix a style conflict with fontawesome icons
331338

api/pvc-api.php renamed to src/api/pvc-api.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
2-
if (!defined('ABSPATH')) exit;
3-
// Exit if accessed directly
2+
namespace A3Rev\PageViewsCount;
43

54
// File Security Check
65
if ( ! defined( 'ABSPATH' ) ) {
76
exit;
87
}
98

10-
class PVC_API
9+
class API
1110
{
1211

1312
public $namespace = 'pvc/v1';
@@ -62,7 +61,7 @@ public function get_stats( $ids = array() ) {
6261
return $items_data;
6362
}
6463

65-
public function increase_stats( WP_REST_Request $request ) {
64+
public function increase_stats( \WP_REST_Request $request ) {
6665
@ini_set( 'display_errors', false );
6766

6867
$post_ids_text = $request->get_param( 'post_ids' );
@@ -101,7 +100,7 @@ public function increase_stats( WP_REST_Request $request ) {
101100
return wp_send_json( $json_data );
102101
}
103102

104-
public function view_stats( WP_REST_Request $request ) {
103+
public function view_stats( \WP_REST_Request $request ) {
105104
@ini_set( 'display_errors', false );
106105

107106
$post_ids_text = $request->get_param( 'post_ids' );
@@ -133,7 +132,4 @@ public function view_stats( WP_REST_Request $request ) {
133132
}
134133
}
135134

136-
global $pvc_api;
137-
$pvc_api = new PVC_API();
138-
139135
?>

0 commit comments

Comments
 (0)