# phastpress/1.82/classes/Compat/Slimstat.php

PhastPress, version 1.82. 27 lines.

- Page: https://pluginprobe.com/plugins/phastpress/1.82/code/classes/Compat/Slimstat.php
- Raw: https://pluginprobe.com/plugins/phastpress/1.82/raw/classes/Compat/Slimstat.php
- Modified: 2020-09-21T11:38:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/phastpress/1.82/code/classes/Compat/Slimstat.php#L10-L20`.

```php
<?php
namespace Kibo\PhastPlugins\PhastPress\Compat;

class Slimstat {
    public function setup() {
        // Don't delay Slimstat Analytics.
        add_filter('wp_print_scripts', function () {
            if (!wp_script_is('wp_slimstat')) {
                return;
            }

            // Don't defer the tracker script.
            add_filter('script_loader_tag', function ($tag, $handle, $src) {
                if ($handle !== 'wp_slimstat') {
                    return $tag;
                }
                return preg_replace('~<script\b~', '$0 data-phast-no-defer async', $tag);
            }, 10, 3);

            // Don't defer the inline parameters script.
            ob_start(function ($chunk) {
                return preg_replace('~(<script\b)([^>]*>\s*(/\*.*?\*/)?\s*var\s+SlimStatParams\s*=)~', '$1 data-phast-no-defer$2', $chunk);
            }, 8192);
        });
    }
}

```
