wp_http_supports( array $capabilities = array(), string $url = null ): bool
Determines if there is an HTTP Transport that can process this request.
Parameters
-
$capabilities
array Optional -
Array of capabilities to test or a wp_remote_request() $args array.
More Arguments from wp_remote_request( ... $args )
Array or string of HTTP request arguments.
method
stringRequest method. Accepts'GET'
,'POST'
,'HEAD'
,'PUT'
,'DELETE'
,'TRACE'
,'OPTIONS'
, or'PATCH'
.
Some transports technically allow others, but should not be assumed. Default'GET'
.timeout
floatHow long the connection should stay open in seconds. Default 5.redirection
intNumber of allowed redirects. Not supported by all transports.
Default 5.httpversion
stringVersion of the HTTP protocol to use. Accepts'1.0'
and'1.1'
.
Default'1.0'
.user-agent
stringUser-agent value sent.
Default'WordPress/'
. get_bloginfo('version'
) . '; ' . get_bloginfo('url'
).reject_unsafe_urls
boolblocking
boolWhether the calling code requires the result of the request.
If set to false, the request will be sent to the remote server, and processing returned to the calling code immediately, the caller will know if the request succeeded or failed, but will not receive any response from the remote server. Default true.headers
string|arrayArray or string of headers to send with the request.
cookies
arrayList of cookies to send with the request.body
string|arrayBody to send with the request. Default null.compress
boolWhether to compress the $body when sending the request.
Default false.decompress
boolWhether to decompress a compressed response. If set to false and compressed content is returned in the response anyway, it will need to be separately decompressed. Default true.sslverify
boolWhether to verify SSL for the request. Default true.sslcertificates
stringAbsolute path to an SSL certificate .crt file.
Default ABSPATH . WPINC .'/certificates/ca-bundle.crt'
.stream
boolWhether to stream to a file. If set to true and no filename was given, it will be dropped it in the WP temp dir and its name will be set using the basename of the URL. Default false.filename
stringFilename of the file to write to when streaming. $stream must be set to true. Default null.limit_response_size
intSize in bytes to limit the response to. Default null.
Default:
array()
-
$url
string Optional -
If given, will check if the URL requires SSL and adds that requirement to the capabilities array.
Default:
null
Return
bool
Source
File: wp-includes/http.php
.
View all references
function wp_http_supports( $capabilities = array(), $url = null ) {
$http = _wp_http_get_object();
$capabilities = wp_parse_args( $capabilities );
$count = count( $capabilities );
// If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array.
if ( $count && count( array_filter( array_keys( $capabilities ), 'is_numeric' ) ) === $count ) {
$capabilities = array_combine( array_values( $capabilities ), array_fill( 0, $count, true ) );
}
if ( $url && ! isset( $capabilities['ssl'] ) ) {
$scheme = parse_url( $url, PHP_URL_SCHEME );
if ( 'https' === $scheme || 'ssl' === $scheme ) {
$capabilities['ssl'] = true;
}
}
return (bool) $http->_get_first_available_transport( $capabilities );
}
Changelog
Version | Description |
---|---|
3.2.0 | Introduced. |