File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -6,24 +6,31 @@ class TrackingPolicy
66{
77 public function shouldCollectAnalytics (): bool
88 {
9- if ($ this ->clientIpExcluded ( $ _SERVER [ ' HTTP_X_FORWARDED_FOR ' ] ?? $ _SERVER [ ' REMOTE_ADDR ' ] )) {
9+ if ($ this ->isClientIpExcluded ( )) {
1010 return false ;
1111 }
1212
1313 if (! is_user_logged_in ()) {
1414 return true ;
1515 }
1616
17- return ! $ this ->containsExcludedRole (wp_get_current_user ()-> roles );
17+ return ! $ this ->containsExcludedRole ();
1818 }
1919
20- protected function clientIpExcluded ( string $ ip ): bool
20+ protected function isClientIpExcluded ( ): bool
2121 {
22+ $ ip = $ _SERVER ['HTTP_X_FORWARDED_FOR ' ] ?? $ _SERVER ['REMOTE_ADDR ' ];
23+
24+ if (empty ($ ip )) return false ;
25+
2226 return in_array ($ ip , Setting::array (SettingName::EXCLUDED_IP_ADDRESSES ));
2327 }
2428
25- protected function containsExcludedRole (array $ roles ): bool
29+ protected function containsExcludedRole (): bool
2630 {
27- return array_intersect (Setting::array (SettingName::EXCLUDED_ROLES ), $ roles ) !== [];
31+ $ currentRoles = wp_get_current_user ()->roles ;
32+ $ excludedRoles = Setting::array (SettingName::EXCLUDED_ROLES );
33+
34+ return array_intersect ($ excludedRoles , $ currentRoles ) !== [];
2835 }
2936}
You can’t perform that action at this time.
0 commit comments