Changeset 3404845
- Timestamp:
- 11/28/2025 08:12:20 AM (2 weeks ago)
- Location:
- koko-analytics
- Files:
-
- 2 added
- 18 edited
- 1 copied
-
tags/2.0.21 (copied) (copied from koko-analytics/trunk)
-
tags/2.0.21/CHANGELOG.md (modified) (1 diff)
-
tags/2.0.21/data/referrer-blocklist (modified) (3 diffs)
-
tags/2.0.21/koko-analytics.php (modified) (2 diffs)
-
tags/2.0.21/readme.txt (modified) (4 diffs)
-
tags/2.0.21/src/Blocklist.php (added)
-
tags/2.0.21/src/Command.php (modified) (1 diff)
-
tags/2.0.21/src/Pageview_Aggregator.php (modified) (2 diffs)
-
tags/2.0.21/src/Pruner.php (modified) (1 diff)
-
tags/2.0.21/src/Resources/external-strings.php (modified) (1 diff)
-
tags/2.0.21/src/Resources/views/settings-page.php (modified) (1 diff)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/data/referrer-blocklist (modified) (3 diffs)
-
trunk/koko-analytics.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/src/Blocklist.php (added)
-
trunk/src/Command.php (modified) (1 diff)
-
trunk/src/Pageview_Aggregator.php (modified) (2 diffs)
-
trunk/src/Pruner.php (modified) (1 diff)
-
trunk/src/Resources/external-strings.php (modified) (1 diff)
-
trunk/src/Resources/views/settings-page.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
koko-analytics/tags/2.0.21/CHANGELOG.md
r3395565 r3404845 1 1 # Changelog 2 3 ### 2.0.21 - Nov 28, 2025 4 5 - Prune blocked referrer domains retro-actively. 6 - Fix double echo on settings page. 7 - Fix hanging query on certain MySQL installations for deleting orphaned referrer rows. 8 - Add `wp koko-analytics prune` command for WP CLI. 2 9 3 10 -
koko-analytics/tags/2.0.21/data/referrer-blocklist
r3395565 r3404845 199 199 ascotgoods.xyz 200 200 ask-yug.com 201 astimvnc.online 201 202 asupro.com 202 203 asynt.net … … 1174 1175 kursy-ege.ru 1175 1176 l2soft.eu 1177 labguamec.online 1176 1178 lafppshop.xyz 1179 laitrcus.online 1177 1180 lakiikraski.ru 1178 1181 lalalove.ru … … 1629 1632 rapidsites.pro 1630 1633 raschtextil.com.ua 1634 ratraiser.online 1631 1635 raymondblog.top 1632 1636 razborka-skoda.org.ua -
koko-analytics/tags/2.0.21/koko-analytics.php
r3395565 r3404845 4 4 Plugin Name: Koko Analytics 5 5 Plugin URI: https://www.kokoanalytics.com/#utm_source=wp-plugin&utm_medium=koko-analytics&utm_campaign=plugins-page 6 Version: 2.0.2 06 Version: 2.0.21 7 7 Description: Privacy-friendly and efficient statistics for your WordPress site. 8 8 Author: ibericode … … 39 39 use KokoAnalytics\Widgets\Most_Viewed_Posts_Widget; 40 40 41 \define('KOKO_ANALYTICS_VERSION', '2.0.2 0');41 \define('KOKO_ANALYTICS_VERSION', '2.0.21'); 42 42 \define('KOKO_ANALYTICS_PLUGIN_FILE', __FILE__); 43 43 \define('KOKO_ANALYTICS_PLUGIN_DIR', __DIR__); -
koko-analytics/tags/2.0.21/readme.txt
r3397056 r3404845 1 === Koko Analytics - Google Analytics alternativefor WordPress ===1 === Koko Analytics - Privacy+Friendly stats for WordPress === 2 2 Contributors: Ibericode, DvanKooten 3 3 Donate link: https://www.kokoanalytics.com/pricing/ … … 5 5 Requires at least: 6.0 6 6 Tested up to: 6.8 7 Stable tag: 2.0.2 07 Stable tag: 2.0.21 8 8 License: GPL-3.0-or-later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 Requires PHP: 7.4 11 11 12 Simple, privacy-friendly and lightweight statistics. Google Analytics alternative for WordPress sites.12 Analytics plugin for WordPress that is GDPR compliant, plug and play, simple to use and very fast. 13 13 14 14 == Description == 15 15 16 ### Get privacy-friendly and easy to use statistics with Koko Analytics 17 16 18 Koko Analytics is a lightweight and privacy-friendly statistics plugin that runs entirely on your own WordPress site without requiring any third-party services. 17 19 18 It aims to be a n intuitivealternative to Google Analytics for WordPress sites.19 20 Whether you want to track visits, see your most popular pages or understand where your visitors are coming from. Koko Analytics tracks the essential metrics without compromising privacy or performance.21 22 **Why Koko Analytics?** 20 It aims to be a simpler alternative to Google Analytics for WordPress sites. 21 22 Whether you want to see your most popular pages or understand where your visitors are coming from. Koko Analytics tracks all the essential metrics without compromising the privacy of your visitors or the performance of your site. 23 24 ### Why Koko Analytics? 23 25 24 26 - **Plug and play** – Activate the plugin and statistics will start working right away. 25 27 - **Simple & effective** – No complicated pages to navigate, but a single page showing all that truly matters. 26 28 - **Privacy-friendly** – GDPR and CCPA compliant by design. 27 - **Own your data** – Statistics areprocessed and stored on your server only.29 - **Own your data** – All data is processed and stored on your server only. 28 30 - **Fast and lightweight** – Adds less than 500 bytes of JavaScript and handles traffic spikes with ease. 29 31 - **No cookies needed** – Choose between cookie-based, cookieless, or no tracking at all. 30 32 - **Accurate essentials** – Counts visitors, unique pageviews, and referral URLs. 31 33 32 Koko Analytics is perfect for site owners who want effective and reliable website analytics without sharing theirvisitor data with companies that also happen to sell advertisements.34 Koko Analytics provides you with effective and reliable website analytics without sharing visitor data with companies that also happen to sell advertisements. 33 35 34 36 You can [view a live demo here](https://www.kokoanalytics.com/koko-analytics-dashboard/). 35 37 36 Koko Analytics is 100% free, open-source and self-hosted — no account required. 37 38 The [source code for Koko Analytics is available on GitHub here](https://github.com/ibericode/koko-analytics). 39 40 Several more advanced features are available through [Koko Analytics Pro](https://www.kokoanalytics.com/pricing). 38 This plugin is free, open-source and self-hosted — no account required. The [source code for Koko Analytics is available on GitHub here](https://github.com/ibericode/koko-analytics). 39 40 ### Unlock advanced statistics with Koko Analytics Pro 41 42 You can benefit from several advanced features with [Koko Analytics Pro](https://www.kokoanalytics.com/pricing), like custom event tracking, counting visitor countries and periodic email reports. 43 41 44 42 45 == Installation == … … 102 105 103 106 == Changelog == 107 108 ### 2.0.21 - Nov 28, 2025 109 110 - Prune blocked referrer domains retro-actively. 111 - Fix double echo on settings page. 112 - Fix hanging query on certain MySQL installations for deleting orphaned referrer rows. 113 - Add `wp koko-analytics prune` command for WP CLI. 104 114 105 115 … … 418 428 - Migrations runner now has a simple lock mechanism to ensure it runs atomically. 419 429 - Output database size in localized format. 420 - Output dates in localized format through `wp_date()`. Thanks to [Dominik Schilling](https://dominikschilling.de/). 421 - Add missing text domain on settings page. Thanks to [Dominik Schilling](https://dominikschilling.de/). 422 423 424 #### 1.4.5 - Nov 14, 2024 425 426 - Use localized number formatting for all numbers troughout the dashboard. 427 - Add feature to export and import data. ... 428 430 - Output dates in localized format through `wp_date()`. Thanks ... 431 -
koko-analytics/tags/2.0.21/src/Command.php
r3351822 r3404845 26 26 public function aggregate($args, $assoc_args) 27 27 { 28 WP_CLI::line('Aggregating data...'); 28 29 Aggregator::run(); 29 WP_CLI::success(' Stats aggregated.');30 WP_CLI::success('Data aggregated'); 30 31 } 31 32 33 /** 34 * Removes data older than the treshold specified on the settings page 35 */ 36 public function prune($args, $assoc_args) 37 { 38 WP_CLI::line('Pruning data...'); 39 do_action('koko_analytics_prune_data'); 40 WP_CLI::success('Data pruned'); 41 } 32 42 43 /** 44 * Migrates the post_stats database qtable to the new v2 structure. 45 */ 33 46 public function migrate_post_stats_to_v2($args, $assoc_args) 34 47 { 35 48 WP_CLI::line('Migrating post stats...'); 36 49 Actions::migrate_post_stats_to_v2(); 37 WP_CLI::success(' Done!');50 WP_CLI::success('Post stats migrated'); 38 51 } 39 52 53 /** 54 * Migrates referrer stats to the new v2 format. 55 */ 40 56 public function migrate_referrer_stats_to_v2($args, $assoc_args) 41 57 { 42 58 WP_CLI::line('Migrating referrer stats...'); 43 59 Actions::migrate_referrer_stats_to_v2(); 44 WP_CLI::success(' Done!');60 WP_CLI::success('Referrer stats migrated'); 45 61 } 46 62 } -
koko-analytics/tags/2.0.21/src/Pageview_Aggregator.php
r3378632 r3404845 185 185 186 186 // run custom blocklist first 187 // @see https://github.com/ibericode/koko-analytics/blob/ma ster/code-snippets/add-domains-to-referrer-blocklist.php187 // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/add-domains-to-referrer-blocklist.php 188 188 $custom_blocklist = apply_filters('koko_analytics_referrer_blocklist', []); 189 189 foreach ($custom_blocklist as $blocklisted_domain) { … … 193 193 } 194 194 195 // read built-in blocklist file line-by-line to prevent OOM errors 196 $fh = fopen(KOKO_ANALYTICS_PLUGIN_DIR . '/data/referrer-blocklist', "r"); 197 if ($fh) { 198 while (($blocklisted_domain = fgets($fh)) !== false) { 199 // trim newline and other whitespace 200 $blocklisted_domain = rtrim($blocklisted_domain); 201 if ($blocklisted_domain === '') { 202 continue; 203 } 204 205 // simply check if domain is in referrer string 206 if (false !== strpos($url, $blocklisted_domain)) { 207 fclose($fh); 208 return true; 209 } 210 } 211 212 fclose($fh); 195 // check community maintained blocklist 196 if ((new Blocklist())->contains($url)) { 197 return true; 213 198 } 214 199 215 200 // run return value through filter so user can apply more advanced logic to determine whether to ignore referrer url 216 // @see https://github.com/ibericode/koko-analytics/blob/ma ster/code-snippets/ignore-some-referrer-traffic-using-regex.php201 // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/ignore-some-referrer-traffic-using-regex.php 217 202 return apply_filters('koko_analytics_ignore_referrer_url', false, $url); 218 203 } -
koko-analytics/tags/2.0.21/src/Pruner.php
r3350963 r3404845 40 40 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_stats WHERE date < %s", $date)); 41 41 42 // delete unused referrer URL's 43 $wpdb->query("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE id NOT IN (SELECT DISTINCT(id) FROM {$wpdb->prefix}koko_analytics_referrer_stats )"); 42 self::delete_orphaned_referrer_urls(); 43 self::delete_orphaned_paths(); 44 self::delete_blocked_referrers(); 45 } 44 46 45 // delete unused paths 46 $wpdb->query("DELETE FROM {$wpdb->prefix}koko_analytics_paths WHERE id NOT IN (SELECT DISTINCT(path_id) FROM {$wpdb->prefix}koko_analytics_post_stats )"); 47 protected static function delete_orphaned_referrer_urls(): void 48 { 49 /** @var \wpdb $wpdb */ 50 global $wpdb; 51 52 // delete unused referrer urls 53 $results = $wpdb->get_results("SELECT id FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE id NOT IN (SELECT DISTINCT(id) FROM {$wpdb->prefix}koko_analytics_referrer_stats)"); 54 55 // we explicitly delete the rows one-by-one here because the bulk with subquery approach we used before 56 // would hang on certain MySQL installations (according to user reports) 57 foreach ($results as $r) { 58 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE id = %d LIMIT 1", [$r->id])); 59 } 60 } 61 62 protected static function delete_orphaned_paths(): void 63 { 64 /** @var \wpdb $wpdb */ 65 global $wpdb; 66 67 $results = $wpdb->get_results("SELECT id FROM {$wpdb->prefix}koko_analytics_paths WHERE id NOT IN (SELECT DISTINCT(path_id) FROM {$wpdb->prefix}koko_analytics_post_stats)"); 68 69 // we explicitly delete the rows one-by-one here because the bulk with subquery approach we used before 70 // would hang on certain MySQL installations (according to user reports) 71 foreach ($results as $r) { 72 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_paths WHERE id = %d LIMIT 1", [$r->id])); 73 } 74 } 75 76 protected static function delete_blocked_referrers(): void 77 { 78 global $wpdb; 79 80 $blocklist = new Blocklist(); 81 $list = array_merge($blocklist->read(), apply_filters('koko_analytics_referrer_blocklist', [])); 82 $count = count($list); 83 84 // process list in batches of 100 85 for ($offset = 0; $offset < $count; $offset += 100) { 86 $chunk = array_slice($list, $offset, 100); 87 $chunk = array_map(function ($v) use ($wpdb) { 88 return $wpdb->esc_like("%{$v}%"); 89 }, $chunk); 90 91 $where = str_repeat("url LIKE %s OR ", count($chunk)); 92 $where = substr($where, 0, strlen($where) - 4); 93 94 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE {$where}", $chunk)); 95 } 47 96 } 48 97 } -
koko-analytics/tags/2.0.21/src/Resources/external-strings.php
r3364374 r3404845 942 942 __('Pageviews', 'koko-analytics'); 943 943 944 // ../koko-analytics-pro/includes/class-updates.php#15 0944 // ../koko-analytics-pro/includes/class-updates.php#154 945 945 __('Please activate Koko Analytics Pro in order to use it and download plugin updates.', 'koko-analytics'); 946 946 947 // ../koko-analytics-pro/includes/class-updates.php#15 1947 // ../koko-analytics-pro/includes/class-updates.php#155 948 948 __('Activate now', 'koko-analytics'); 949 949 950 // ../koko-analytics-pro/includes/class-updates.php#16 4950 // ../koko-analytics-pro/includes/class-updates.php#168 951 951 __('Success! You now have full access to Koko Analytics Pro.', 'koko-analytics'); -
koko-analytics/tags/2.0.21/src/Resources/views/settings-page.php
r3378632 r3404845 144 144 145 145 <div class="mb-5"> 146 <input type="submit" class="btn btn-primary" value="<?= esc_attr_ e('Save Changes') ?>">146 <input type="submit" class="btn btn-primary" value="<?= esc_attr__('Save Changes') ?>"> 147 147 </div> 148 148 -
koko-analytics/trunk/CHANGELOG.md
r3395565 r3404845 1 1 # Changelog 2 3 ### 2.0.21 - Nov 28, 2025 4 5 - Prune blocked referrer domains retro-actively. 6 - Fix double echo on settings page. 7 - Fix hanging query on certain MySQL installations for deleting orphaned referrer rows. 8 - Add `wp koko-analytics prune` command for WP CLI. 2 9 3 10 -
koko-analytics/trunk/data/referrer-blocklist
r3395565 r3404845 199 199 ascotgoods.xyz 200 200 ask-yug.com 201 astimvnc.online 201 202 asupro.com 202 203 asynt.net … … 1174 1175 kursy-ege.ru 1175 1176 l2soft.eu 1177 labguamec.online 1176 1178 lafppshop.xyz 1179 laitrcus.online 1177 1180 lakiikraski.ru 1178 1181 lalalove.ru … … 1629 1632 rapidsites.pro 1630 1633 raschtextil.com.ua 1634 ratraiser.online 1631 1635 raymondblog.top 1632 1636 razborka-skoda.org.ua -
koko-analytics/trunk/koko-analytics.php
r3395565 r3404845 4 4 Plugin Name: Koko Analytics 5 5 Plugin URI: https://www.kokoanalytics.com/#utm_source=wp-plugin&utm_medium=koko-analytics&utm_campaign=plugins-page 6 Version: 2.0.2 06 Version: 2.0.21 7 7 Description: Privacy-friendly and efficient statistics for your WordPress site. 8 8 Author: ibericode … … 39 39 use KokoAnalytics\Widgets\Most_Viewed_Posts_Widget; 40 40 41 \define('KOKO_ANALYTICS_VERSION', '2.0.2 0');41 \define('KOKO_ANALYTICS_VERSION', '2.0.21'); 42 42 \define('KOKO_ANALYTICS_PLUGIN_FILE', __FILE__); 43 43 \define('KOKO_ANALYTICS_PLUGIN_DIR', __DIR__); -
koko-analytics/trunk/readme.txt
r3397056 r3404845 1 === Koko Analytics - Google Analytics alternativefor WordPress ===1 === Koko Analytics - Privacy+Friendly stats for WordPress === 2 2 Contributors: Ibericode, DvanKooten 3 3 Donate link: https://www.kokoanalytics.com/pricing/ … … 5 5 Requires at least: 6.0 6 6 Tested up to: 6.8 7 Stable tag: 2.0.2 07 Stable tag: 2.0.21 8 8 License: GPL-3.0-or-later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 Requires PHP: 7.4 11 11 12 Simple, privacy-friendly and lightweight statistics. Google Analytics alternative for WordPress sites.12 Analytics plugin for WordPress that is GDPR compliant, plug and play, simple to use and very fast. 13 13 14 14 == Description == 15 15 16 ### Get privacy-friendly and easy to use statistics with Koko Analytics 17 16 18 Koko Analytics is a lightweight and privacy-friendly statistics plugin that runs entirely on your own WordPress site without requiring any third-party services. 17 19 18 It aims to be a n intuitivealternative to Google Analytics for WordPress sites.19 20 Whether you want to track visits, see your most popular pages or understand where your visitors are coming from. Koko Analytics tracks the essential metrics without compromising privacy or performance.21 22 **Why Koko Analytics?** 20 It aims to be a simpler alternative to Google Analytics for WordPress sites. 21 22 Whether you want to see your most popular pages or understand where your visitors are coming from. Koko Analytics tracks all the essential metrics without compromising the privacy of your visitors or the performance of your site. 23 24 ### Why Koko Analytics? 23 25 24 26 - **Plug and play** – Activate the plugin and statistics will start working right away. 25 27 - **Simple & effective** – No complicated pages to navigate, but a single page showing all that truly matters. 26 28 - **Privacy-friendly** – GDPR and CCPA compliant by design. 27 - **Own your data** – Statistics areprocessed and stored on your server only.29 - **Own your data** – All data is processed and stored on your server only. 28 30 - **Fast and lightweight** – Adds less than 500 bytes of JavaScript and handles traffic spikes with ease. 29 31 - **No cookies needed** – Choose between cookie-based, cookieless, or no tracking at all. 30 32 - **Accurate essentials** – Counts visitors, unique pageviews, and referral URLs. 31 33 32 Koko Analytics is perfect for site owners who want effective and reliable website analytics without sharing theirvisitor data with companies that also happen to sell advertisements.34 Koko Analytics provides you with effective and reliable website analytics without sharing visitor data with companies that also happen to sell advertisements. 33 35 34 36 You can [view a live demo here](https://www.kokoanalytics.com/koko-analytics-dashboard/). 35 37 36 Koko Analytics is 100% free, open-source and self-hosted — no account required. 37 38 The [source code for Koko Analytics is available on GitHub here](https://github.com/ibericode/koko-analytics). 39 40 Several more advanced features are available through [Koko Analytics Pro](https://www.kokoanalytics.com/pricing). 38 This plugin is free, open-source and self-hosted — no account required. The [source code for Koko Analytics is available on GitHub here](https://github.com/ibericode/koko-analytics). 39 40 ### Unlock advanced statistics with Koko Analytics Pro 41 42 You can benefit from several advanced features with [Koko Analytics Pro](https://www.kokoanalytics.com/pricing), like custom event tracking, counting visitor countries and periodic email reports. 43 41 44 42 45 == Installation == … … 102 105 103 106 == Changelog == 107 108 ### 2.0.21 - Nov 28, 2025 109 110 - Prune blocked referrer domains retro-actively. 111 - Fix double echo on settings page. 112 - Fix hanging query on certain MySQL installations for deleting orphaned referrer rows. 113 - Add `wp koko-analytics prune` command for WP CLI. 104 114 105 115 … … 418 428 - Migrations runner now has a simple lock mechanism to ensure it runs atomically. 419 429 - Output database size in localized format. 420 - Output dates in localized format through `wp_date()`. Thanks to [Dominik Schilling](https://dominikschilling.de/). 421 - Add missing text domain on settings page. Thanks to [Dominik Schilling](https://dominikschilling.de/). 422 423 424 #### 1.4.5 - Nov 14, 2024 425 426 - Use localized number formatting for all numbers troughout the dashboard. 427 - Add feature to export and import data. ... 428 430 - Output dates in localized format through `wp_date()`. Thanks ... 431 -
koko-analytics/trunk/src/Command.php
r3351822 r3404845 26 26 public function aggregate($args, $assoc_args) 27 27 { 28 WP_CLI::line('Aggregating data...'); 28 29 Aggregator::run(); 29 WP_CLI::success(' Stats aggregated.');30 WP_CLI::success('Data aggregated'); 30 31 } 31 32 33 /** 34 * Removes data older than the treshold specified on the settings page 35 */ 36 public function prune($args, $assoc_args) 37 { 38 WP_CLI::line('Pruning data...'); 39 do_action('koko_analytics_prune_data'); 40 WP_CLI::success('Data pruned'); 41 } 32 42 43 /** 44 * Migrates the post_stats database qtable to the new v2 structure. 45 */ 33 46 public function migrate_post_stats_to_v2($args, $assoc_args) 34 47 { 35 48 WP_CLI::line('Migrating post stats...'); 36 49 Actions::migrate_post_stats_to_v2(); 37 WP_CLI::success(' Done!');50 WP_CLI::success('Post stats migrated'); 38 51 } 39 52 53 /** 54 * Migrates referrer stats to the new v2 format. 55 */ 40 56 public function migrate_referrer_stats_to_v2($args, $assoc_args) 41 57 { 42 58 WP_CLI::line('Migrating referrer stats...'); 43 59 Actions::migrate_referrer_stats_to_v2(); 44 WP_CLI::success(' Done!');60 WP_CLI::success('Referrer stats migrated'); 45 61 } 46 62 } -
koko-analytics/trunk/src/Pageview_Aggregator.php
r3378632 r3404845 185 185 186 186 // run custom blocklist first 187 // @see https://github.com/ibericode/koko-analytics/blob/ma ster/code-snippets/add-domains-to-referrer-blocklist.php187 // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/add-domains-to-referrer-blocklist.php 188 188 $custom_blocklist = apply_filters('koko_analytics_referrer_blocklist', []); 189 189 foreach ($custom_blocklist as $blocklisted_domain) { … … 193 193 } 194 194 195 // read built-in blocklist file line-by-line to prevent OOM errors 196 $fh = fopen(KOKO_ANALYTICS_PLUGIN_DIR . '/data/referrer-blocklist', "r"); 197 if ($fh) { 198 while (($blocklisted_domain = fgets($fh)) !== false) { 199 // trim newline and other whitespace 200 $blocklisted_domain = rtrim($blocklisted_domain); 201 if ($blocklisted_domain === '') { 202 continue; 203 } 204 205 // simply check if domain is in referrer string 206 if (false !== strpos($url, $blocklisted_domain)) { 207 fclose($fh); 208 return true; 209 } 210 } 211 212 fclose($fh); 195 // check community maintained blocklist 196 if ((new Blocklist())->contains($url)) { 197 return true; 213 198 } 214 199 215 200 // run return value through filter so user can apply more advanced logic to determine whether to ignore referrer url 216 // @see https://github.com/ibericode/koko-analytics/blob/ma ster/code-snippets/ignore-some-referrer-traffic-using-regex.php201 // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/ignore-some-referrer-traffic-using-regex.php 217 202 return apply_filters('koko_analytics_ignore_referrer_url', false, $url); 218 203 } -
koko-analytics/trunk/src/Pruner.php
r3350963 r3404845 40 40 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_stats WHERE date < %s", $date)); 41 41 42 // delete unused referrer URL's 43 $wpdb->query("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE id NOT IN (SELECT DISTINCT(id) FROM {$wpdb->prefix}koko_analytics_referrer_stats )"); 42 self::delete_orphaned_referrer_urls(); 43 self::delete_orphaned_paths(); 44 self::delete_blocked_referrers(); 45 } 44 46 45 // delete unused paths 46 $wpdb->query("DELETE FROM {$wpdb->prefix}koko_analytics_paths WHERE id NOT IN (SELECT DISTINCT(path_id) FROM {$wpdb->prefix}koko_analytics_post_stats )"); 47 protected static function delete_orphaned_referrer_urls(): void 48 { 49 /** @var \wpdb $wpdb */ 50 global $wpdb; 51 52 // delete unused referrer urls 53 $results = $wpdb->get_results("SELECT id FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE id NOT IN (SELECT DISTINCT(id) FROM {$wpdb->prefix}koko_analytics_referrer_stats)"); 54 55 // we explicitly delete the rows one-by-one here because the bulk with subquery approach we used before 56 // would hang on certain MySQL installations (according to user reports) 57 foreach ($results as $r) { 58 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE id = %d LIMIT 1", [$r->id])); 59 } 60 } 61 62 protected static function delete_orphaned_paths(): void 63 { 64 /** @var \wpdb $wpdb */ 65 global $wpdb; 66 67 $results = $wpdb->get_results("SELECT id FROM {$wpdb->prefix}koko_analytics_paths WHERE id NOT IN (SELECT DISTINCT(path_id) FROM {$wpdb->prefix}koko_analytics_post_stats)"); 68 69 // we explicitly delete the rows one-by-one here because the bulk with subquery approach we used before 70 // would hang on certain MySQL installations (according to user reports) 71 foreach ($results as $r) { 72 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_paths WHERE id = %d LIMIT 1", [$r->id])); 73 } 74 } 75 76 protected static function delete_blocked_referrers(): void 77 { 78 global $wpdb; 79 80 $blocklist = new Blocklist(); 81 $list = array_merge($blocklist->read(), apply_filters('koko_analytics_referrer_blocklist', [])); 82 $count = count($list); 83 84 // process list in batches of 100 85 for ($offset = 0; $offset < $count; $offset += 100) { 86 $chunk = array_slice($list, $offset, 100); 87 $chunk = array_map(function ($v) use ($wpdb) { 88 return $wpdb->esc_like("%{$v}%"); 89 }, $chunk); 90 91 $where = str_repeat("url LIKE %s OR ", count($chunk)); 92 $where = substr($where, 0, strlen($where) - 4); 93 94 $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_urls WHERE {$where}", $chunk)); 95 } 47 96 } 48 97 } -
koko-analytics/trunk/src/Resources/external-strings.php
r3364374 r3404845 942 942 __('Pageviews', 'koko-analytics'); 943 943 944 // ../koko-analytics-pro/includes/class-updates.php#15 0944 // ../koko-analytics-pro/includes/class-updates.php#154 945 945 __('Please activate Koko Analytics Pro in order to use it and download plugin updates.', 'koko-analytics'); 946 946 947 // ../koko-analytics-pro/includes/class-updates.php#15 1947 // ../koko-analytics-pro/includes/class-updates.php#155 948 948 __('Activate now', 'koko-analytics'); 949 949 950 // ../koko-analytics-pro/includes/class-updates.php#16 4950 // ../koko-analytics-pro/includes/class-updates.php#168 951 951 __('Success! You now have full access to Koko Analytics Pro.', 'koko-analytics'); -
koko-analytics/trunk/src/Resources/views/settings-page.php
r3378632 r3404845 144 144 145 145 <div class="mb-5"> 146 <input type="submit" class="btn btn-primary" value="<?= esc_attr_ e('Save Changes') ?>">146 <input type="submit" class="btn btn-primary" value="<?= esc_attr__('Save Changes') ?>"> 147 147 </div> 148 148
Note: See TracChangeset
for help on using the changeset viewer.