| @@ -70,11 +70,21 @@ | ||
| 70 | 70 | |
| 71 | 71 | protected function removeIdsFilter($tag, $handle): string |
| 72 | 72 | { |
| 73 | 73 | foreach ($this->scripts as $script) { |
| 74 | - if ($script instanceof HideScriptId && $script->handle() === $handle) { | |
| 75 | - // Remove the id attribute from the script tag | |
| 76 | - return preg_replace('/ id=([\'"])[^\'"]*\\1/', '', $tag); | |
| 74 | + if ($script->handle() === $handle) { | |
| 75 | + $updatedTag = $tag; | |
| 76 | + | |
| 77 | + if ($script instanceof HideScriptId) { | |
| 78 | + // Remove the id attribute from the script tag | |
| 79 | + $updatedTag = preg_replace('/ id=([\'"])[^\'"]*\\1/', '', $updatedTag); | |
| 80 | + } | |
| 81 | + | |
| 82 | + if ($handle === 'simpleanalytics') { | |
| 83 | + return "<!-- Simple Analytics - 100% privacy-first analytics (official WordPress plugin) -->\n" . $updatedTag; | |
| 84 | + } | |
| 85 | + | |
| 86 | + return $updatedTag; | |
| 77 | 87 | } |
| 78 | 88 | } |
| 79 | 89 | |
| 80 | 90 | return $tag; |