# simpleanalytics/1.107/src/TrackingRules.php

Simple Analytics, version 1.107. 42 lines.

- Page: https://pluginprobe.com/plugins/simpleanalytics/1.107/code/src/TrackingRules.php
- Raw: https://pluginprobe.com/plugins/simpleanalytics/1.107/raw/src/TrackingRules.php
- Modified: 2026-06-18T13:36:38+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/simpleanalytics/1.107/code/src/TrackingRules.php#L10-L20`.

```php
<?php

namespace SimpleAnalytics;

class TrackingRules
{
    protected $settings;

    public function __construct(WordPressSettings $settings)
    {
        $this->settings = $settings;
    }

    public function hasExcludedIp(): bool
    {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? ($_SERVER['REMOTE_ADDR'] ?? null);

        if (empty($ip)) return false;

        $list = $this->settings->array(SettingName::EXCLUDED_IP_ADDRESSES);

        return in_array($ip, $list);
    }

    public function hasExcludedUserRole(): bool
    {
        if (! is_user_logged_in()) {
            return false;
        }

        $needle = $this->settings->array(SettingName::EXCLUDED_ROLES);

        if ($needle === []) {
            return true;
        }

        $current = wp_get_current_user()->roles;

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

```
