WP Statistics - Version 12.5.5

Version Description

  • Improved: The WP-Statistics Metaboxes for Gutenberg!
  • Improved: The params() method.
  • Improved: Referrers URL to be valid.
Download this release

Release Info

Developer mostafa.s1990
Plugin Icon 128x128 WP Statistics
Version 12.5.5
Comparing to
See all releases

Code changes from version 12.5.4 to 12.5.5

assets/css/admin.css CHANGED
@@ -299,4 +299,23 @@ i.mce-i-icon-statistic {
299
  html[dir="rtl"] .wp-statistic-mce-desc {
300
  text-align: right !important;
301
  margin: 0 82px 0px 0px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  }
299
  html[dir="rtl"] .wp-statistic-mce-desc {
300
  text-align: right !important;
301
  margin: 0 82px 0px 0px !important;
302
+ }
303
+
304
+ .about-text img {
305
+ width: 90px;
306
+ }
307
+
308
+ .wps-return-to-dashboard {
309
+ margin: 30px 0 0 -5px;
310
+ font-size: 14px;
311
+ font-weight: 600;
312
+ }
313
+
314
+ .wps-return-to-dashboard a {
315
+ text-decoration: none;
316
+ padding: 0 5px;
317
+ }
318
+
319
+ .wps-gutenberg-chart-js {
320
+ height: 350px;
321
  }
includes/classes/class-wp-statistics-editor.php CHANGED
@@ -69,7 +69,11 @@ class WP_Statistics_Editor {
69
  'WP_Statistics_Editor::meta_box',
70
  $screen,
71
  'normal',
72
- 'high'
 
 
 
 
73
  );
74
  }
75
  }
@@ -89,17 +93,23 @@ class WP_Statistics_Editor {
89
  }
90
 
91
  static function generate_postbox_contents( $post, $args ) {
92
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
93
- plugins_url( 'wp-statistics/assets/images/' ) .
94
- 'ajax-loading.gif" alt="' .
95
- __( 'Loading...', 'wp-statistics' ) .
96
- '"></div>';
97
- $widget = $args['args']['widget'];
98
- $container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
99
-
100
- echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
101
- echo '<script type="text/javascript">var wp_statistics_current_id = \'' . $post . '\';</script>';
102
- wp_statistics_generate_widget_load_javascript( $widget, $container_id );
 
 
 
 
 
 
103
  }
104
 
105
  static function inline_javascript() {
@@ -112,36 +122,26 @@ class WP_Statistics_Editor {
112
 
113
  WP_Statistics_Dashboard::load_widget_css_and_scripts();
114
 
115
- $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' .
116
- plugins_url( 'wp-statistics/assets/images/' ) .
117
- 'ajax-loading.gif" alt="' .
118
- __( 'Reloading...', 'wp-statistics' ) .
119
- '"></div>';
120
-
121
- $new_buttons
122
- = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
123
- wp_statistics_icons( 'dashicons-update' ) .
124
- '<span class="screen-reader-text">' .
125
- __( 'Reload', 'wp-statistics' ) .
126
- '</span></button><button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' .
127
- wp_statistics_icons( 'dashicons-migrate' ) .
128
- '<span class="screen-reader-text">' .
129
- __( 'More Details', 'wp-statistics' ) .
130
- '</span></button>';
131
- $new_button
132
- = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' .
133
- wp_statistics_icons( 'dashicons-update' ) .
134
- '<span class="screen-reader-text">' .
135
- __( 'Reload', 'wp-statistics' ) .
136
- '</span></button>';
137
 
138
  $admin_url = get_admin_url() . "/admin.php?page=";
139
 
140
  $page_urls = array();
141
 
142
- $page_urls['wp_statistics_editor_meta_box_more_button'] = $admin_url .
143
- WP_Statistics::$page['pages'] .
144
- '&page-id=';
 
 
 
 
145
 
146
  ?>
147
  <script type="text/javascript">
@@ -155,8 +155,7 @@ class WP_Statistics_Editor {
155
  }
156
 
157
  jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
158
- jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more);
159
-
160
  jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
161
  }
162
 
@@ -189,6 +188,10 @@ class WP_Statistics_Editor {
189
  <?php
190
  }
191
 
 
 
 
 
192
  public static function get_list_post_type() {
193
  $post_types = array( 'post', 'page' );
194
  $get_post_types = get_post_types( array(
@@ -201,4 +204,15 @@ class WP_Statistics_Editor {
201
 
202
  return $post_types;
203
  }
 
 
 
 
 
 
 
 
 
 
 
204
  }
69
  'WP_Statistics_Editor::meta_box',
70
  $screen,
71
  'normal',
72
+ 'high',
73
+ array(
74
+ '__block_editor_compatible_meta_box' => true,
75
+ '__back_compat_meta_box' => false,
76
+ )
77
  );
78
  }
79
  }
93
  }
94
 
95
  static function generate_postbox_contents( $post, $args ) {
96
+ if ( self::is_gutenberg() ) {
97
+ //If Gutenberg Editor
98
+ if ( isset( $_GET['post'] ) and ! empty( $_GET['post'] ) ) {
99
+ echo '<div class="wps-gutenberg-chart-js">';
100
+ require( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/page.php' );
101
+ wp_statistics_generate_page_postbox_content( null, $_GET['post'] );
102
+ echo '</div>';
103
+ echo '<style>button#wp_statistics_editor_meta_box_more_button { z-index: 9999;position: absolute;top: 1px;right: 3%;}</style>';
104
+ }
105
+ } else {
106
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Loading...', 'wp-statistics' ) . '"></div>';
107
+ $widget = $args['args']['widget'];
108
+ $container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div';
109
+ echo '<div id="' . $container_id . '">' . $loading_img . '</div>';
110
+ echo '<script type="text/javascript">var wp_statistics_current_id = \'' . $post . '\';</script>';
111
+ wp_statistics_generate_widget_load_javascript( $widget, $container_id );
112
+ }
113
  }
114
 
115
  static function inline_javascript() {
122
 
123
  WP_Statistics_Dashboard::load_widget_css_and_scripts();
124
 
125
+ $loading_img = '<div style="width: 100%; text-align: center;"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'ajax-loading.gif" alt="' . __( 'Reloading...', 'wp-statistics' ) . '"></div>';
126
+ $new_buttons = '</button>';
127
+ //If Classic Editor
128
+ if ( self::is_gutenberg() === false ) {
129
+ $new_buttons .= '<button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '<span class="screen-reader-text">' . __( 'Reload', 'wp-statistics' ) . '</span></button>';
130
+ }
131
+ $new_buttons .= '<button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-migrate' ) . '<span class="screen-reader-text">' . __( 'More Details', 'wp-statistics' ) . '</span></button>';
132
+ $new_button = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '<span class="screen-reader-text">' . __( 'Reload', 'wp-statistics' ) . '</span></button>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
  $admin_url = get_admin_url() . "/admin.php?page=";
135
 
136
  $page_urls = array();
137
 
138
+ $page_urls['wp_statistics_editor_meta_box_more_button'] = $admin_url . WP_Statistics::$page['pages'] . '&page-id=';
139
+
140
+ //Button for Gutenberg
141
+ $btn_more_action = 'wp_statistics_goto_more';
142
+ if ( self::is_gutenberg() ) {
143
+ $btn_more_action = "function () { window.location.href = '" . wp_normalize_path( $page_urls['wp_statistics_editor_meta_box_more_button'] . ( isset( $_GET['post'] ) === true ? $_GET['post'] : '' ) ) . "';}";
144
+ }
145
 
146
  ?>
147
  <script type="text/javascript">
155
  }
156
 
157
  jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget);
158
+ jQuery('.wps-more').unbind('click').on('click', <?php echo $btn_more_action; ?>);
 
159
  jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget);
160
  }
161
 
188
  <?php
189
  }
190
 
191
+ /**
192
+ * Get List Post Type
193
+ * @return array
194
+ */
195
  public static function get_list_post_type() {
196
  $post_types = array( 'post', 'page' );
197
  $get_post_types = get_post_types( array(
204
 
205
  return $post_types;
206
  }
207
+
208
+ /**
209
+ * Check Is Gutenberg Editor
210
+ */
211
+ public static function is_gutenberg() {
212
+ $current_screen = get_current_screen();
213
+ if ( ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) || ( function_exists( 'is_gutenberg_page' ) ) && is_gutenberg_page() ) {
214
+ return true;
215
+ }
216
+ return false;
217
+ }
218
  }
includes/classes/class-wp-statistics-hits.php CHANGED
@@ -488,26 +488,28 @@ class WP_Statistics_Hits {
488
  }
489
 
490
  // Parse the URL in to it's component parts.
491
- $parts = parse_url( $referred );
 
492
 
493
- // Loop through the SE list until we find which search engine matches.
494
- foreach ( $search_engines as $key => $value ) {
495
- $search_regex = wp_statistics_searchengine_regex( $key );
496
 
497
- preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
498
 
499
- if ( isset( $matches[1] ) ) {
500
- $data['last_counter'] = $WP_Statistics->Current_date( 'Y-m-d' );
501
- $data['engine'] = $key;
502
- $data['words'] = $WP_Statistics->Search_Engine_QueryString( $referred );
503
- $data['host'] = $parts['host'];
504
- $data['visitor'] = $wpdb->insert_id;
505
 
506
- if ( $data['words'] == 'No search query found!' ) {
507
- $data['words'] = '';
508
- }
509
 
510
- $wpdb->insert( $wpdb->prefix . 'statistics_search', $data );
 
511
  }
512
  }
513
  }
488
  }
489
 
490
  // Parse the URL in to it's component parts.
491
+ if ( wp_http_validate_url( $referred ) ) {
492
+ $parts = parse_url( $referred );
493
 
494
+ // Loop through the SE list until we find which search engine matches.
495
+ foreach ( $search_engines as $key => $value ) {
496
+ $search_regex = wp_statistics_searchengine_regex( $key );
497
 
498
+ preg_match( '/' . $search_regex . '/', $parts['host'], $matches );
499
 
500
+ if ( isset( $matches[1] ) ) {
501
+ $data['last_counter'] = $WP_Statistics->Current_date( 'Y-m-d' );
502
+ $data['engine'] = $key;
503
+ $data['words'] = $WP_Statistics->Search_Engine_QueryString( $referred );
504
+ $data['host'] = $parts['host'];
505
+ $data['visitor'] = $wpdb->insert_id;
506
 
507
+ if ( $data['words'] == 'No search query found!' ) {
508
+ $data['words'] = '';
509
+ }
510
 
511
+ $wpdb->insert( $wpdb->prefix . 'statistics_search', $data );
512
+ }
513
  }
514
  }
515
  }
includes/classes/class-wp-statistics-rest.php CHANGED
@@ -109,9 +109,13 @@ class WP_Statistics_Rest {
109
  static public function params( $params ) {
110
  if ( isset( $_POST[ self::_POST ] ) ) {
111
  $data = wp_unslash( $_POST[ self::_POST ] );
112
- $json_data = json_decode( $data, true );
113
- if ( isset( $json_data[ $params ] ) ) {
114
- return $json_data[ $params ];
 
 
 
 
115
  }
116
  }
117
 
109
  static public function params( $params ) {
110
  if ( isset( $_POST[ self::_POST ] ) ) {
111
  $data = wp_unslash( $_POST[ self::_POST ] );
112
+
113
+ if ( is_object( $data ) ) {
114
+ $data = json_decode( $data, true );
115
+ }
116
+
117
+ if ( isset( $data[ $params ] ) ) {
118
+ return $data[ $params ];
119
  }
120
  }
121
 
includes/templates/welcome.php CHANGED
@@ -156,7 +156,7 @@
156
 
157
  <hr>
158
 
159
- <div class="return-to-dashboard">
160
  <a href="<?php echo admin_url( 'admin.php?page=wps_overview_page' ); ?>"><?php _e( 'Go to Statistics &rarr; Overview', 'wp-statistics' ); ?></a>
161
  </div>
162
  </div>
156
 
157
  <hr>
158
 
159
+ <div class="wps-return-to-dashboard">
160
  <a href="<?php echo admin_url( 'admin.php?page=wps_overview_page' ); ?>"><?php _e( 'Go to Statistics &rarr; Overview', 'wp-statistics' ); ?></a>
161
  </div>
162
  </div>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: mostafa.s1990, mehrshaddarzi, ghasemi71ir, GregRoss, dedidata
3
  Donate link: https://wp-statistics.com/donate/
4
  Tags: analytics, wordpress analytics, stats, statistics, visit, visitors, hits, chart, browser, today, yesterday, week, month, year, total, post, page, sidebar, google, live visit, search word, agent, google analytics, webmasters, google webmasters, geoip, location
5
  Requires at least: 3.0
6
- Tested up to: 4.9
7
- Stable tag: 12.5.4
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -116,6 +116,11 @@ http://yourwebsite.com/wp-json/wpstatistics/v1
116
  To register, go to the Permalink page and update the permalink with press Save Changes.
117
 
118
  == Changelog ==
 
 
 
 
 
119
  = 12.5.4 =
120
  * Disabled: Notice cache in all admin pages just enabled in the summary and setting of WP-Statistics pages.
121
  * Improved: Some methods. `params()` and `get_hash_string()`.
3
  Donate link: https://wp-statistics.com/donate/
4
  Tags: analytics, wordpress analytics, stats, statistics, visit, visitors, hits, chart, browser, today, yesterday, week, month, year, total, post, page, sidebar, google, live visit, search word, agent, google analytics, webmasters, google webmasters, geoip, location
5
  Requires at least: 3.0
6
+ Tested up to: 5.0
7
+ Stable tag: 12.5.5
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
116
  To register, go to the Permalink page and update the permalink with press Save Changes.
117
 
118
  == Changelog ==
119
+ = 12.5.5 =
120
+ * Improved: The WP-Statistics Metaboxes for Gutenberg!
121
+ * Improved: The `params()` method.
122
+ * Improved: Referrers URL to be valid.
123
+
124
  = 12.5.4 =
125
  * Disabled: Notice cache in all admin pages just enabled in the summary and setting of WP-Statistics pages.
126
  * Improved: Some methods. `params()` and `get_hash_string()`.
wp-statistics.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP Statistics
4
  * Plugin URI: https://wp-statistics.com/
5
  * Description: Complete WordPress Analytics and Statistics for your site!
6
- * Version: 12.5.4
7
  * Author: Verona Labs
8
  * Author URI: http://veronalabs.com/
9
  *
3
  * Plugin Name: WP Statistics
4
  * Plugin URI: https://wp-statistics.com/
5
  * Description: Complete WordPress Analytics and Statistics for your site!
6
+ * Version: 12.5.5
7
  * Author: Verona Labs
8
  * Author URI: http://veronalabs.com/
9
  *