Automattic\WooCommerce\StoreApi

Authentication::validate_ip()protected staticWC 1.0

Uses filter_var() to validate and return ipv4 and ipv6 addresses Will return 0.0.0.0 if the ip is not valid. This is done to group and still rate limit invalid ips.

Method of the class: Authentication{}

No Hooks.

Return

String.

Usage

$result = Authentication::validate_ip( $ip );
$ip(string) (required)
ipv4 or ipv6 ip string.

Authentication::validate_ip() code WC 8.6.1

protected static function validate_ip( $ip ) {
	$ip = filter_var(
		$ip,
		FILTER_VALIDATE_IP,
		array( FILTER_FLAG_NO_RES_RANGE, FILTER_FLAG_IPV6 )
	);

	return $ip ?: '0.0.0.0';
}