wppaste
WordPress

apply_filters( 'http_allowed_safe_ports', int[] $allowed_ports, string $host, string $url )

Since
5.9.0
Controls the list of ports considered safe in HTTP API.

Description

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

Compatibility

WordPress
since 5.9.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$allowed_portsint[]
Array of integers for valid ports. Default allowed ports are 80, 443, and 8080.
$hoststring
Host name of the requested URL.
$urlstring
Requested URL.

Where this hook fires · 1

  • wp-includes/http.php:660wp_http_validate_url()

Source code

	 *	 * @param int[]  $allowed_ports Array of integers for valid ports. Default allowed ports	 *                              are 80, 443, and 8080.	 * @param string $host          Host name of the requested URL.	 * @param string $url           Requested URL.	 */	$allowed_ports = apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url );	if ( is_array( $allowed_ports ) && in_array( $port, $allowed_ports, true ) ) {		return $url;	} 	if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port ) {		return $url;

Changelog

Introduced in 5.9.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.