http_allowed_safe_ports
Filter HookDescription
Controls the list of ports considered safe in HTTP API. Allows to change and allow external requests for the HTTP request.Hook Information
File Location |
wp-includes/http.php
View on GitHub
|
Hook Type | Filter |
Line Number | 631 |
Hook Parameters
Type | Name | Description |
---|---|---|
int[]
|
$allowed_ports
|
Array of integers for valid ports. |
string
|
$host
|
Host name of the requested URL. |
string
|
$url
|
Requested URL. |
Usage Examples
Basic Usage
<?php
// Hook into http_allowed_safe_ports
add_filter('http_allowed_safe_ports', 'my_custom_filter', 10, 3);
function my_custom_filter($allowed_ports, $host, $url) {
// Your custom filtering logic here
return $allowed_ports;
}
Source Code Context
wp-includes/http.php:631
- How this hook is used in WordPress core
<?php
626 *
627 * @param int[] $allowed_ports Array of integers for valid ports.
628 * @param string $host Host name of the requested URL.
629 * @param string $url Requested URL.
630 */
631 $allowed_ports = apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url );
632 if ( is_array( $allowed_ports ) && in_array( $port, $allowed_ports, true ) ) {
633 return $url;
634 }
635
636 if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port ) {
PHP Documentation
<?php
/**
* Controls the list of ports considered safe in HTTP API.
*
* Allows to change and allow external requests for the HTTP request.
*
* @since 5.9.0
*
* @param int[] $allowed_ports Array of integers for valid ports.
* @param string $host Host name of the requested URL.
* @param string $url Requested URL.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/http.php
Related Hooks
Related hooks will be displayed here in future updates.