wp_http_validate_url
wp_http_validate_url ( $url )
Parameters:- (string) url Request URL.
Returns:- (string|false) URL or false on failure.
Defined at: - Introduced in WordPress: 3.5.2
- Deprecated in WordPress: —
Description
Validates a URL for safe use in the HTTP API.Examples of URLs that are considered unsafe:
- ftp://example.com/caniload.php - Invalid protocol - only http and https are allowed.
- http:///example.com/caniload.php - Malformed URL.
- http://user:pass@example.com/caniload.php - Login information.
- http://example.invalid/caniload.php - Invalid hostname, as the IP cannot be looked up in DNS.
Examples of URLs that are considered unsafe by default:
- http://192.168.0.1/caniload.php - IPs from LAN networks.
This can be changed with the {@see 'http_request_host_is_external'} filter.
- http://198.143.164.252:81/caniload.php - By default, only 80, 443, and 8080 ports are allowed.
This can be changed with the {@see 'http_allowed_safe_ports'} filter.