[wp-trac] [WordPress Trac] #52428: Create a Filter for Blocking Outgoing HTTP Calls | Single URL
WordPress Trac
noreply at wordpress.org
Wed Feb 3 00:03:58 UTC 2021
#52428: Create a Filter for Blocking Outgoing HTTP Calls | Single URL
-------------------------------------------------+-------------------------
Reporter: jetxpert | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: HTTP API | Version: 2.7
Severity: normal | Resolution:
Keywords: 2nd-opinion close reporter-feedback | Focuses:
-------------------------------------------------+-------------------------
Changes (by TimothyBlynJacobs):
* keywords: dev-feedback needs-unit-tests 2nd-opinion needs-design => 2nd-
opinion close reporter-feedback
* version: 5.6 => 2.7
* component: General => HTTP API
Comment:
Hi @jetxpert,
Welcome to trac! This should be doable with the existing
`pre_http_request` filter. For example:
{{{
add_filter( 'pre_http_request', function ( $result, $args, $url ) {
if ( wp_parse_url( $url, PHP_URL_HOST ) === 'github.com' ) {
return new WP_Error( 'http_request_not_executed', __(
'User has blocked requests through HTTP.' ) );
}
return $result;
}, 10, 3 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52428#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list