Plugin Directory

Changeset 3404845


Ignore:
Timestamp:
11/28/2025 08:12:20 AM (2 weeks ago)
Author:
DvanKooten
Message:

v2.0.21

Location:
koko-analytics
Files:
2 added
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • koko-analytics/tags/2.0.21/CHANGELOG.md

    r3395565 r3404845  
    11# 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.
    29
    310
  • koko-analytics/tags/2.0.21/data/referrer-blocklist

    r3395565 r3404845  
    199199ascotgoods.xyz
    200200ask-yug.com
     201astimvnc.online
    201202asupro.com
    202203asynt.net
     
    11741175kursy-ege.ru
    11751176l2soft.eu
     1177labguamec.online
    11761178lafppshop.xyz
     1179laitrcus.online
    11771180lakiikraski.ru
    11781181lalalove.ru
     
    16291632rapidsites.pro
    16301633raschtextil.com.ua
     1634ratraiser.online
    16311635raymondblog.top
    16321636razborka-skoda.org.ua
  • koko-analytics/tags/2.0.21/koko-analytics.php

    r3395565 r3404845  
    44Plugin Name: Koko Analytics
    55Plugin URI: https://www.kokoanalytics.com/#utm_source=wp-plugin&utm_medium=koko-analytics&utm_campaign=plugins-page
    6 Version: 2.0.20
     6Version: 2.0.21
    77Description: Privacy-friendly and efficient statistics for your WordPress site.
    88Author: ibericode
     
    3939use KokoAnalytics\Widgets\Most_Viewed_Posts_Widget;
    4040
    41 \define('KOKO_ANALYTICS_VERSION', '2.0.20');
     41\define('KOKO_ANALYTICS_VERSION', '2.0.21');
    4242\define('KOKO_ANALYTICS_PLUGIN_FILE', __FILE__);
    4343\define('KOKO_ANALYTICS_PLUGIN_DIR', __DIR__);
  • koko-analytics/tags/2.0.21/readme.txt

    r3397056 r3404845  
    1 === Koko Analytics - Google Analytics alternative for WordPress ===
     1=== Koko Analytics - Privacy+Friendly stats for WordPress ===
    22Contributors: Ibericode, DvanKooten
    33Donate link: https://www.kokoanalytics.com/pricing/
     
    55Requires at least: 6.0
    66Tested up to: 6.8
    7 Stable tag: 2.0.20
     7Stable tag: 2.0.21
    88License: GPL-3.0-or-later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
    1010Requires PHP: 7.4
    1111
    12 Simple, privacy-friendly and lightweight statistics. Google Analytics alternative for WordPress sites.
     12Analytics plugin for WordPress that is GDPR compliant, plug and play, simple to use and very fast.
    1313
    1414== Description ==
    1515
     16### Get privacy-friendly and easy to use statistics with Koko Analytics
     17
    1618Koko Analytics is a lightweight and privacy-friendly statistics plugin that runs entirely on your own WordPress site without requiring any third-party services.
    1719
    18 It aims to be an intuitive alternative 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?**
     20It aims to be a simpler alternative to Google Analytics for WordPress sites.
     21
     22Whether 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?
    2325
    2426- **Plug and play** – Activate the plugin and statistics will start working right away.
    2527- **Simple & effective** – No complicated pages to navigate, but a single page showing all that truly matters.
    2628- **Privacy-friendly** – GDPR and CCPA compliant by design.
    27 - **Own your data** – Statistics are processed and stored on your server only.
     29- **Own your data** – All data is processed and stored on your server only.
    2830- **Fast and lightweight** – Adds less than 500 bytes of JavaScript and handles traffic spikes with ease.
    2931- **No cookies needed** – Choose between cookie-based, cookieless, or no tracking at all.
    3032- **Accurate essentials** – Counts visitors, unique pageviews, and referral URLs.
    3133
    32 Koko Analytics is perfect for site owners who want effective and reliable website analytics without sharing their visitor data with companies that also happen to sell advertisements.
     34Koko Analytics provides you with effective and reliable website analytics without sharing visitor data with companies that also happen to sell advertisements.
    3335
    3436You can [view a live demo here](https://www.kokoanalytics.com/koko-analytics-dashboard/).
    3537
    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).
     38This 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
     42You 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
    4144
    4245== Installation ==
     
    102105
    103106== 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.
    104114
    105115
     
    418428- Migrations runner now has a simple lock mechanism to ensure it runs atomically.
    419429- 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  
    2626    public function aggregate($args, $assoc_args)
    2727    {
     28        WP_CLI::line('Aggregating data...');
    2829        Aggregator::run();
    29         WP_CLI::success('Stats aggregated.');
     30        WP_CLI::success('Data aggregated');
    3031    }
    3132
     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    }
    3242
     43    /**
     44     * Migrates the post_stats database qtable to the new v2 structure.
     45     */
    3346    public function migrate_post_stats_to_v2($args, $assoc_args)
    3447    {
    3548        WP_CLI::line('Migrating post stats...');
    3649        Actions::migrate_post_stats_to_v2();
    37         WP_CLI::success('Done!');
     50        WP_CLI::success('Post stats migrated');
    3851    }
    3952
     53    /**
     54     * Migrates referrer stats to the new v2 format.
     55     */
    4056    public function migrate_referrer_stats_to_v2($args, $assoc_args)
    4157    {
    4258        WP_CLI::line('Migrating referrer stats...');
    4359        Actions::migrate_referrer_stats_to_v2();
    44         WP_CLI::success('Done!');
     60        WP_CLI::success('Referrer stats migrated');
    4561    }
    4662}
  • koko-analytics/tags/2.0.21/src/Pageview_Aggregator.php

    r3378632 r3404845  
    185185
    186186        // run custom blocklist first
    187         // @see https://github.com/ibericode/koko-analytics/blob/master/code-snippets/add-domains-to-referrer-blocklist.php
     187        // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/add-domains-to-referrer-blocklist.php
    188188        $custom_blocklist = apply_filters('koko_analytics_referrer_blocklist', []);
    189189        foreach ($custom_blocklist as $blocklisted_domain) {
     
    193193        }
    194194
    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;
    213198        }
    214199
    215200        // 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/master/code-snippets/ignore-some-referrer-traffic-using-regex.php
     201        // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/ignore-some-referrer-traffic-using-regex.php
    217202        return apply_filters('koko_analytics_ignore_referrer_url', false, $url);
    218203    }
  • koko-analytics/tags/2.0.21/src/Pruner.php

    r3350963 r3404845  
    4040        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_stats WHERE date < %s", $date));
    4141
    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    }
    4446
    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        }
    4796    }
    4897}
  • koko-analytics/tags/2.0.21/src/Resources/external-strings.php

    r3364374 r3404845  
    942942__('Pageviews', 'koko-analytics');
    943943
    944 // ../koko-analytics-pro/includes/class-updates.php#150
     944// ../koko-analytics-pro/includes/class-updates.php#154
    945945__('Please activate Koko Analytics Pro in order to use it and download plugin updates.', 'koko-analytics');
    946946
    947 // ../koko-analytics-pro/includes/class-updates.php#151
     947// ../koko-analytics-pro/includes/class-updates.php#155
    948948__('Activate now', 'koko-analytics');
    949949
    950 // ../koko-analytics-pro/includes/class-updates.php#164
     950// ../koko-analytics-pro/includes/class-updates.php#168
    951951__('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  
    144144
    145145                <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') ?>">
    147147                </div>
    148148
  • koko-analytics/trunk/CHANGELOG.md

    r3395565 r3404845  
    11# 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.
    29
    310
  • koko-analytics/trunk/data/referrer-blocklist

    r3395565 r3404845  
    199199ascotgoods.xyz
    200200ask-yug.com
     201astimvnc.online
    201202asupro.com
    202203asynt.net
     
    11741175kursy-ege.ru
    11751176l2soft.eu
     1177labguamec.online
    11761178lafppshop.xyz
     1179laitrcus.online
    11771180lakiikraski.ru
    11781181lalalove.ru
     
    16291632rapidsites.pro
    16301633raschtextil.com.ua
     1634ratraiser.online
    16311635raymondblog.top
    16321636razborka-skoda.org.ua
  • koko-analytics/trunk/koko-analytics.php

    r3395565 r3404845  
    44Plugin Name: Koko Analytics
    55Plugin URI: https://www.kokoanalytics.com/#utm_source=wp-plugin&utm_medium=koko-analytics&utm_campaign=plugins-page
    6 Version: 2.0.20
     6Version: 2.0.21
    77Description: Privacy-friendly and efficient statistics for your WordPress site.
    88Author: ibericode
     
    3939use KokoAnalytics\Widgets\Most_Viewed_Posts_Widget;
    4040
    41 \define('KOKO_ANALYTICS_VERSION', '2.0.20');
     41\define('KOKO_ANALYTICS_VERSION', '2.0.21');
    4242\define('KOKO_ANALYTICS_PLUGIN_FILE', __FILE__);
    4343\define('KOKO_ANALYTICS_PLUGIN_DIR', __DIR__);
  • koko-analytics/trunk/readme.txt

    r3397056 r3404845  
    1 === Koko Analytics - Google Analytics alternative for WordPress ===
     1=== Koko Analytics - Privacy+Friendly stats for WordPress ===
    22Contributors: Ibericode, DvanKooten
    33Donate link: https://www.kokoanalytics.com/pricing/
     
    55Requires at least: 6.0
    66Tested up to: 6.8
    7 Stable tag: 2.0.20
     7Stable tag: 2.0.21
    88License: GPL-3.0-or-later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
    1010Requires PHP: 7.4
    1111
    12 Simple, privacy-friendly and lightweight statistics. Google Analytics alternative for WordPress sites.
     12Analytics plugin for WordPress that is GDPR compliant, plug and play, simple to use and very fast.
    1313
    1414== Description ==
    1515
     16### Get privacy-friendly and easy to use statistics with Koko Analytics
     17
    1618Koko Analytics is a lightweight and privacy-friendly statistics plugin that runs entirely on your own WordPress site without requiring any third-party services.
    1719
    18 It aims to be an intuitive alternative 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?**
     20It aims to be a simpler alternative to Google Analytics for WordPress sites.
     21
     22Whether 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?
    2325
    2426- **Plug and play** – Activate the plugin and statistics will start working right away.
    2527- **Simple & effective** – No complicated pages to navigate, but a single page showing all that truly matters.
    2628- **Privacy-friendly** – GDPR and CCPA compliant by design.
    27 - **Own your data** – Statistics are processed and stored on your server only.
     29- **Own your data** – All data is processed and stored on your server only.
    2830- **Fast and lightweight** – Adds less than 500 bytes of JavaScript and handles traffic spikes with ease.
    2931- **No cookies needed** – Choose between cookie-based, cookieless, or no tracking at all.
    3032- **Accurate essentials** – Counts visitors, unique pageviews, and referral URLs.
    3133
    32 Koko Analytics is perfect for site owners who want effective and reliable website analytics without sharing their visitor data with companies that also happen to sell advertisements.
     34Koko Analytics provides you with effective and reliable website analytics without sharing visitor data with companies that also happen to sell advertisements.
    3335
    3436You can [view a live demo here](https://www.kokoanalytics.com/koko-analytics-dashboard/).
    3537
    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).
     38This 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
     42You 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
    4144
    4245== Installation ==
     
    102105
    103106== 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.
    104114
    105115
     
    418428- Migrations runner now has a simple lock mechanism to ensure it runs atomically.
    419429- 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  
    2626    public function aggregate($args, $assoc_args)
    2727    {
     28        WP_CLI::line('Aggregating data...');
    2829        Aggregator::run();
    29         WP_CLI::success('Stats aggregated.');
     30        WP_CLI::success('Data aggregated');
    3031    }
    3132
     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    }
    3242
     43    /**
     44     * Migrates the post_stats database qtable to the new v2 structure.
     45     */
    3346    public function migrate_post_stats_to_v2($args, $assoc_args)
    3447    {
    3548        WP_CLI::line('Migrating post stats...');
    3649        Actions::migrate_post_stats_to_v2();
    37         WP_CLI::success('Done!');
     50        WP_CLI::success('Post stats migrated');
    3851    }
    3952
     53    /**
     54     * Migrates referrer stats to the new v2 format.
     55     */
    4056    public function migrate_referrer_stats_to_v2($args, $assoc_args)
    4157    {
    4258        WP_CLI::line('Migrating referrer stats...');
    4359        Actions::migrate_referrer_stats_to_v2();
    44         WP_CLI::success('Done!');
     60        WP_CLI::success('Referrer stats migrated');
    4561    }
    4662}
  • koko-analytics/trunk/src/Pageview_Aggregator.php

    r3378632 r3404845  
    185185
    186186        // run custom blocklist first
    187         // @see https://github.com/ibericode/koko-analytics/blob/master/code-snippets/add-domains-to-referrer-blocklist.php
     187        // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/add-domains-to-referrer-blocklist.php
    188188        $custom_blocklist = apply_filters('koko_analytics_referrer_blocklist', []);
    189189        foreach ($custom_blocklist as $blocklisted_domain) {
     
    193193        }
    194194
    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;
    213198        }
    214199
    215200        // 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/master/code-snippets/ignore-some-referrer-traffic-using-regex.php
     201        // @see https://github.com/ibericode/koko-analytics/blob/main/code-snippets/ignore-some-referrer-traffic-using-regex.php
    217202        return apply_filters('koko_analytics_ignore_referrer_url', false, $url);
    218203    }
  • koko-analytics/trunk/src/Pruner.php

    r3350963 r3404845  
    4040        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}koko_analytics_referrer_stats WHERE date < %s", $date));
    4141
    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    }
    4446
    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        }
    4796    }
    4897}
  • koko-analytics/trunk/src/Resources/external-strings.php

    r3364374 r3404845  
    942942__('Pageviews', 'koko-analytics');
    943943
    944 // ../koko-analytics-pro/includes/class-updates.php#150
     944// ../koko-analytics-pro/includes/class-updates.php#154
    945945__('Please activate Koko Analytics Pro in order to use it and download plugin updates.', 'koko-analytics');
    946946
    947 // ../koko-analytics-pro/includes/class-updates.php#151
     947// ../koko-analytics-pro/includes/class-updates.php#155
    948948__('Activate now', 'koko-analytics');
    949949
    950 // ../koko-analytics-pro/includes/class-updates.php#164
     950// ../koko-analytics-pro/includes/class-updates.php#168
    951951__('Success! You now have full access to Koko Analytics Pro.', 'koko-analytics');
  • koko-analytics/trunk/src/Resources/views/settings-page.php

    r3378632 r3404845  
    144144
    145145                <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') ?>">
    147147                </div>
    148148
Note: See TracChangeset for help on using the changeset viewer.