PluginProbe
PhastPress / 1.82
PhastPress v1.82
3.12 3.11 1.75 1.76 1.77 1.78 1.79 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.90 1.91 1.92 1.93 1.94 1.95 1.96 1.97 All 119 releases
phastpress / classes / Compat / Slimstat.php

Slimstat.php in PhastPress 1.82, at classes/Compat/Slimstat.php

27 lines 902 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Kibo\PhastPlugins\PhastPress\Compat;
3
4 class Slimstat {
5 public function setup() {
6 // Don't delay Slimstat Analytics.
7 add_filter('wp_print_scripts', function () {
8 if (!wp_script_is('wp_slimstat')) {
9 return;
10 }
11
12 // Don't defer the tracker script.
13 add_filter('script_loader_tag', function ($tag, $handle, $src) {
14 if ($handle !== 'wp_slimstat') {
15 return $tag;
16 }
17 return preg_replace('~<script\b~', '$0 data-phast-no-defer async', $tag);
18 }, 10, 3);
19
20 // Don't defer the inline parameters script.
21 ob_start(function ($chunk) {
22 return preg_replace('~(<script\b)([^>]*>\s*(/\*.*?\*/)?\s*var\s+SlimStatParams\s*=)~', '$1 data-phast-no-defer$2', $chunk);
23 }, 8192);
24 });
25 }
26 }
27