http_allowed_safe_ports filter-hookWP 5.9.0

Controls the list of ports considered safe in HTTP API.

Allows to change and allow external requests for the HTTP request.

Usage

add_filter( 'http_allowed_safe_ports', 'wp_kama_http_allowed_safe_ports_filter', 10, 3 );

/**
 * Function for `http_allowed_safe_ports` filter-hook.
 * 
 * @param array  $allowed_ports Array of integers for valid ports.
 * @param string $host          Host name of the requested URL.
 * @param string $url           Requested URL.
 *
 * @return array
 */
function wp_kama_http_allowed_safe_ports_filter( $allowed_ports, $host, $url ){

	// filter...
	return $allowed_ports;
}
$allowed_ports(array)
Array of integers for valid ports.
$host(string)
Host name of the requested URL.
$url(string)
Requested URL.

Changelog

Since 5.9.0 Introduced.

Where the hook is called

wp_http_validate_url()
http_allowed_safe_ports
wp-includes/http.php 596
$allowed_ports = apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url );

Where the hook is used in WordPress

Usage not found.