Skip to content

Commit 0738fba

Browse files
committed
wip
1 parent efdada9 commit 0738fba

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/Plugin.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,15 @@ public function onInit(): void
4848
{
4949
$tracking = ! $this->trackingRules->hasExcludedIp() && ! $this->trackingRules->hasExcludedUserRole();
5050

51-
if ($tracking && $this->settings->get(SettingName::NOSCRIPT)) {
52-
AddNoScriptTag::register();
53-
}
54-
55-
if (! $tracking) {
56-
AddInactiveComment::register();
57-
}
58-
5951
if ($tracking) {
6052
$this->scripts->push(new AnalyticsScript);
6153
} else {
6254
$this->scripts->push(new InactiveScript);
55+
AddInactiveComment::register();
56+
}
57+
58+
if ($tracking && $this->settings->get(SettingName::NOSCRIPT)) {
59+
AddNoScriptTag::register();
6360
}
6461

6562
if ($this->settings->boolean(SettingName::AUTOMATED_EVENTS)) {

src/TrackingRules.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@ public function hasExcludedIp(): bool
2424

2525
public function hasExcludedUserRole(): bool
2626
{
27-
if (! is_user_logged_in()) return false;
27+
if (! is_user_logged_in()) {
28+
return false;
29+
}
2830

2931
$needle = $this->settings->array(SettingName::EXCLUDED_ROLES);
32+
33+
if ($needle === []) {
34+
return true;
35+
}
36+
3037
$current = wp_get_current_user()->roles;
3138

3239
return array_intersect($needle, $current) !== [];

0 commit comments

Comments
 (0)