rest_is_ip_address( string $ip )
Determines if an IP address is valid.
Description Description
Handles both IPv4 and IPv6 addresses.
Parameters Parameters
- $ip
-
(string) (Required) IP address.
Return Return
(string|false) The valid IP address, otherwise false.
Source Source
File: wp-includes/rest-api.php
function rest_is_ip_address( $ip ) { $ipv4_pattern = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/'; if ( ! preg_match( $ipv4_pattern, $ip ) && ! Requests_IPv6::check_ipv6( $ip ) ) { return false; } return $ip; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |