WordPress filter hook · part of WordPress core

http_allowed_safe_ports

A WordPress core filter that 13 plugins also fire themselves, running on 1.1M+ sites between them.

“This filter is documented in wp-includes/http.php”

How to use http_allowed_safe_ports

It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'http_allowed_safe_ports', function( $value, $host, $url ) {
	// Change $value here.
	return $value;
}, 10, 3 );

Argument names come from Limit Login Attempts Security's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

13 plugins that fire http_allowed_safe_ports

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Limit Login Attempts Security icon Limit Login Attempts Security1+ million installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ) core/http/Http.php:285
  2. Web Stories icon Web Stories50,000+ installs apply_filters( 'http_allowed_safe_ports', [ 80, 443, 8080 ], $host, $url ) includes/REST_API/Hotlinking_Controller.php:813
  3. Bit Form icon Bit Form10,000+ installs apply_filters( 'http_allowed_safe_ports', [80, 443, 8080], $host, $url ) backend/app/Integrations/WebHooks/WebHooksHandler.php:215
  4. Agent Abilities for MCP icon Agent Abilities for MCP1,000+ installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ) includes/abilities/media.php:1265
  5. SScribe Export Site Pages icon SScribe Export Site Pages20+ installs apply_filters( 'http_allowed_safe_ports', self::SAFE_PORTS, $host, $url ) includes/class-sscribe-outbound-guard.php:68
  6. TSO Link Inspector icon TSO Link Inspector10+ installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, (string) $url ) includes/class-tso-lc-http.php:2054
  7. Webhook Actions icon Webhook Actions10+ installs apply_filters( 'http_allowed_safe_ports', [80, 443, 8080], '', '' ) src/Controllers/AdminController.php:181
  8. PerfLocale icon PerfLocaleFewer than 10 installs apply_filters( 'http_allowed_safe_ports', [ 80, 443, 8080 ], $parts['host'], $url ) src/Webhook/Delivery.php:105
  9. BuildWithHumza Broken Link Checker icon BuildWithHumza Broken Link CheckerFewer than 10 installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ) includes/class-bwh-blc-checker.php:396
  10. Postlude icon PostludeFewer than 10 installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $parts['host'], $configured ) includes/class-api-client.php:361
  11. Soapbox for Blygger icon Soapbox for BlyggerFewer than 10 installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ) src/Mentions/Address.php:155
  12. Quilio Link Checker icon Quilio Link CheckerFewer than 10 installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ) src/Checker/Checker.php:267
  13. Cybexsoft SMTP icon Cybexsoft SMTPFewer than 10 installs apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ) includes/class-cybex-smtp-alert-channels.php:101

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.