[wp-trac] [WordPress Trac] #40142: WP Remote Remaining Methods
WordPress Trac
noreply at wordpress.org
Wed Apr 19 19:43:33 UTC 2023
#40142: WP Remote Remaining Methods
------------------------------------------+------------------------------
Reporter: bhubbard | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: HTTP API | Version: 2.7
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+------------------------------
Comment (by pingram3541):
I was close, this already exists with {{{wp_remote_request}}} &
{{{wp_safe_remote_request}}}.
ex.
{{{
$response = wp_safe_remote_request(
$post_url,
[
'method' => 'PUT', //DELETE, PATCH, etc.
'headers' => [
'Content-Type' => 'application/json; charset=utf-8',
'Authorization' => $token
],
'body' => [
'some_setting' => $some_value
]
]
);
}}}
Replying to [comment:15 pingram3541]:
> I know this is an old one and if there is a better approach than making
our own function like:
>
>
> {{{
> function wp_safe_remote_delete( $url, $args = array() ) {
> $args['reject_unsafe_urls'] = true;
> $http = _wp_http_get_object();
> return $http->delete( $url, $args );
> }
> }}}
>
> I'd love to know. Otherwise, I also like the idea of passing the method
via $args to a universal function like:
>
> {{{
> wp_safe_remote_http_request( $url, $args );
> }}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40142#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list