Usage
PHP
nebula()->get_ip_address($anonymize)
Parameters
$anonymize
(Optional) (Boolean) Return an anonymized IP address
Default: true
Parameter Notes
Note that the anonymize parameter defaults to true! If you are processing non-anonymized IP addresses you must first have consent from the user to comply with privacy regulations such as the GDPR.
Source File
Located in /libs/Utilities/Utilities.php on line 42.
No Hooks
This function does not have any filters or actions available. Request one?
PHP
public function get_ip_address($anonymize=true){ $ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'); foreach ( $ip_keys as $key ){ if ( array_key_exists($key, $this->super->server) === true ){ foreach ( explode(',', $this->super->server[$key]) as $ip ){ $ip = trim($ip); if ( filter_var($ip, FILTER_VALIDATE_IP) ){ //Validate IP return ( !empty($anonymize) )? wp_privacy_anonymize_ip($ip) : $ip; //Return the exact or anonymized IP address } } } } return false; }
Override
This function can not be short-circuited with an override filter. Request one?