WP Statistics - Version 13.0.8

Version Description

  • Improvement getting page id & type queries for the admin page
  • Added no-cache in the hit endpoint response to compatibility with Cloudflare HTML caching
  • Improvement exceptions to make sure working properly
Download this release

Release Info

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

Code changes from version 13.0.7 to 13.0.8

includes/admin/pages/class-wp-statistics-admin-page-pages.php CHANGED
@@ -16,7 +16,18 @@ class pages_page
16
 
17
  // Check Exist Statistics For Custom Page
18
  if (self::is_custom_page()) {
19
- $page_count = $wpdb->get_var("SELECT COUNT(*) FROM " . DB::table('pages') . " WHERE `id` = " . esc_sql($_GET['ID']) . " AND `type` = '" . esc_sql($_GET['type']) . "'");
 
 
 
 
 
 
 
 
 
 
 
20
  if ($page_count < 1) {
21
  wp_die(__('Your request is not valid.', 'wp-statistics'));
22
  }
16
 
17
  // Check Exist Statistics For Custom Page
18
  if (self::is_custom_page()) {
19
+ /**
20
+ * Prepares the queries
21
+ * @since 13.0.8
22
+ */
23
+ $pageTablePage = DB::table('pages');
24
+ $preparedSql = $wpdb->prepare(
25
+ "SELECT COUNT(*) FROM {$pageTablePage} WHERE `id` = %s AND `type` = %s",
26
+ esc_sql($_GET['ID']),
27
+ esc_sql($_GET['type'])
28
+ );
29
+ $page_count = $wpdb->get_var($preparedSql);
30
+
31
  if ($page_count < 1) {
32
  wp_die(__('Your request is not valid.', 'wp-statistics'));
33
  }
includes/api/v2/class-wp-statistics-api-hit.php CHANGED
@@ -2,9 +2,7 @@
2
 
3
  namespace WP_STATISTICS\Api\v2;
4
 
5
- use WP_STATISTICS\Helper;
6
  use WP_STATISTICS\Hits;
7
- use WP_STATISTICS\Option;
8
 
9
  class Hit extends \WP_STATISTICS\RestAPI
10
  {
@@ -98,12 +96,30 @@ class Hit extends \WP_STATISTICS\RestAPI
98
  */
99
  public function hit_callback(\WP_REST_Request $request)
100
  {
101
-
102
  // Start Record
103
  Hits::record();
104
 
105
- // Return
106
- return new \WP_REST_Response(array('status' => true, 'message' => __('Visitor Hit was recorded successfully.', 'wp-statistics')), 200);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
 
109
  /**
2
 
3
  namespace WP_STATISTICS\Api\v2;
4
 
 
5
  use WP_STATISTICS\Hits;
 
6
 
7
  class Hit extends \WP_STATISTICS\RestAPI
8
  {
96
  */
97
  public function hit_callback(\WP_REST_Request $request)
98
  {
 
99
  // Start Record
100
  Hits::record();
101
 
102
+ $response = new \WP_REST_Response(array(
103
+ 'status' => true,
104
+ 'message' => __('Visitor Hit was recorded successfully.', 'wp-statistics'),
105
+ ), 200);
106
+
107
+ /**
108
+ * Set headers for the response
109
+ *
110
+ * @since 13.0.8
111
+ */
112
+ $response->set_headers(array(
113
+ /**
114
+ * Cache-Control for Cloudflare caching compatibility
115
+ *
116
+ * @link https://wordpress.org/support/topic/request-for-cloudflare-html-caching-compatibility/
117
+ */
118
+ 'Cache-Control' => 'no-cache',
119
+ ));
120
+
121
+ // Return response
122
+ return $response;
123
  }
124
 
125
  /**
includes/class-wp-statistics-exclusion.php CHANGED
@@ -373,7 +373,6 @@ class Exclusion
373
  */
374
  public static function exclusion_geoip()
375
  {
376
-
377
  // Get User Location
378
  $location = GeoIP::getCountry();
379
 
373
  */
374
  public static function exclusion_geoip()
375
  {
 
376
  // Get User Location
377
  $location = GeoIP::getCountry();
378
 
includes/class-wp-statistics-geoip.php CHANGED
@@ -95,23 +95,23 @@ class GeoIP
95
  */
96
  public static function Loader($pack)
97
  {
98
-
99
  // Check file Exist
100
  $file = self::get_geo_ip_path($pack);
 
101
  if (file_exists($file)) {
102
  try {
103
 
104
  //Load GeoIP Reader
105
- $reader = new \GeoIp2\Database\Reader($file);
106
- } catch (InvalidDatabaseException $e) {
 
107
  \WP_Statistics::log($e->getMessage());
108
  return false;
109
  }
 
110
  } else {
111
  return false;
112
  }
113
-
114
- return $reader;
115
  }
116
 
117
  /**
@@ -189,9 +189,8 @@ class GeoIP
189
  } else {
190
  $location = $record->country->{$return};
191
  }
192
- } catch (AddressNotFoundException $e) {
193
- \WP_Statistics::log($e->getMessage());
194
- } catch (InvalidDatabaseException $e) {
195
  \WP_Statistics::log($e->getMessage());
196
  }
197
  }
@@ -508,10 +507,11 @@ class GeoIP
508
  } else {
509
  $location = $record->city->{$return};
510
  }
511
- } catch (AddressNotFoundException $e) {
512
- //Don't Stuff
513
- } catch (InvalidDatabaseException $e) {
514
- //Don't Stuff
 
515
  }
516
  }
517
 
95
  */
96
  public static function Loader($pack)
97
  {
 
98
  // Check file Exist
99
  $file = self::get_geo_ip_path($pack);
100
+
101
  if (file_exists($file)) {
102
  try {
103
 
104
  //Load GeoIP Reader
105
+ return new \GeoIp2\Database\Reader($file);
106
+
107
+ } catch (\Exception $e) {
108
  \WP_Statistics::log($e->getMessage());
109
  return false;
110
  }
111
+
112
  } else {
113
  return false;
114
  }
 
 
115
  }
116
 
117
  /**
189
  } else {
190
  $location = $record->country->{$return};
191
  }
192
+
193
+ } catch (\Exception $e) {
 
194
  \WP_Statistics::log($e->getMessage());
195
  }
196
  }
507
  } else {
508
  $location = $record->city->{$return};
509
  }
510
+ } catch (\Exception $e) {
511
+ /**
512
+ * For debugging, you can comment out the logger.
513
+ */
514
+ //\WP_Statistics::log($e->getMessage());
515
  }
516
  }
517
 
includes/class-wp-statistics-helper.php CHANGED
@@ -721,9 +721,7 @@ class Helper
721
 
722
  } catch (Exception $e) {
723
  \WP_Statistics::log($e->getMessage());
724
-
725
- error_log($e->getMessage());
726
-
727
  return false;
728
  }
729
  }
721
 
722
  } catch (Exception $e) {
723
  \WP_Statistics::log($e->getMessage());
724
+
 
 
725
  return false;
726
  }
727
  }
includes/class-wp-statistics-pages.php CHANGED
@@ -389,6 +389,7 @@ class Pages
389
  'from' => '',
390
  'to' => ''
391
  );
 
392
  $args = wp_parse_args($args, $defaults);
393
 
394
  // Date Time SQL
389
  'from' => '',
390
  'to' => ''
391
  );
392
+
393
  $args = wp_parse_args($args, $defaults);
394
 
395
  // Date Time SQL
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.7
7
- Stable tag: 13.0.7
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -124,6 +124,11 @@ Before updating, make sure you disabled all your add-ons, then after that, try t
124
  If you encounter any bug, please create an issue on [Github](https://github.com/wp-statistics/wp-statistics/issues/new) where we can act upon them more efficiently. Since [Github](https://github.com/wp-statistics/wp-statistics) is not a support forum, just bugs are welcomed, and any other request will be closed.
125
 
126
  == Changelog ==
 
 
 
 
 
127
  = 13.0.7 =
128
  - Compatibility with WordPress v5.7
129
  - Fixes linking hits page from post meta box
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.7
7
+ Stable tag: 13.0.8
8
  Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
124
  If you encounter any bug, please create an issue on [Github](https://github.com/wp-statistics/wp-statistics/issues/new) where we can act upon them more efficiently. Since [Github](https://github.com/wp-statistics/wp-statistics) is not a support forum, just bugs are welcomed, and any other request will be closed.
125
 
126
  == Changelog ==
127
+ = 13.0.8 =
128
+ - Improvement getting page id & type queries for the admin page
129
+ - Added no-cache in the hit endpoint response to compatibility with Cloudflare HTML caching
130
+ - Improvement exceptions to make sure working properly
131
+
132
  = 13.0.7 =
133
  - Compatibility with WordPress v5.7
134
  - Fixes linking hits page from post meta box
wp-statistics.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP Statistics
4
  * Plugin URI: https://wp-statistics.com/
5
  * Description: This plugin gives you the complete information on your website's visitors.
6
- * Version: 13.0.7
7
  * Author: VeronaLabs
8
  * Author URI: https://veronalabs.com/
9
  * Text Domain: wp-statistics
3
  * Plugin Name: WP Statistics
4
  * Plugin URI: https://wp-statistics.com/
5
  * Description: This plugin gives you the complete information on your website's visitors.
6
+ * Version: 13.0.8
7
  * Author: VeronaLabs
8
  * Author URI: https://veronalabs.com/
9
  * Text Domain: wp-statistics