On this page
wp_http_supports( array $capabilities = array(), string $url = null ): bool
Determines if there is an HTTP Transport that can process this request.
Parameters
$capabilitiesarray Optional-
Array of capabilities to test or a wp_remote_request() $args array.
More Arguments from wp_remote_request( ... $args )
Request arguments.Default:
array() $urlstring 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 );
}
Related
Uses
| Uses | Description |
|---|---|
| _wp_http_get_object() wp-includes/http.php | Returns the initialized WP_Http Object |
| wp_parse_args() wp-includes/functions.php | Merges user defined arguments into defaults array. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Pattern_Directory_Controller::get_items() wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php | Search and retrieve block patterns metadata |
| WP_Site_Health::get_test_ssl_support() wp-admin/includes/class-wp-site-health.php | Checks if the HTTP API can handle SSL/TLS requests. |
| wp_check_php_version() wp-admin/includes/misc.php | Checks if the user needs to update PHP. |
| WP_Community_Events::get_events() wp-admin/includes/class-wp-community-events.php | Gets data about events near a particular location. |
| translations_api() wp-admin/includes/translation-install.php | Retrieve translations from WordPress Translation API. |
| themes_api() wp-admin/includes/theme.php | Retrieves theme installer pages from the WordPress.org Themes API. |
| get_core_checksums() wp-admin/includes/update.php | Gets and caches the checksums for the given version of WordPress. |
| wp_check_browser_version() wp-admin/includes/dashboard.php | Checks if the user needs a browser update. |
| plugins_api() wp-admin/includes/plugin-install.php | Retrieves plugin installer pages from the WordPress.org Plugins API. |
| wp_get_popular_importers() wp-admin/includes/import.php | Returns a list from WordPress.org of popular importer plugins. |
| wp_credits() wp-admin/includes/credits.php | Retrieve the contributor credits. |
| wp_version_check() wp-includes/update.php | Checks WordPress version against the newest version. |
| wp_update_plugins() wp-includes/update.php | Checks for available updates to plugins based on the latest versions hosted on WordPress.org. |
| wp_update_themes() wp-includes/update.php | Checks for available updates to themes based on the latest versions hosted on WordPress.org. |
Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_http_supports