wp_http_supports() WordPress Function

The wp_http_supports() function is used to check whether a specified feature is supported by the HTTP transport layer.

wp_http_supports( array $capabilities = array(), string $url = null ) #

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.

Default value: array()

$url

(string)(Optional) If given, will check if the URL requires SSL and adds that requirement to the capabilities array.

Default value: null


Top ↑

Return

(bool)


Top ↑

Source

File: wp-includes/http.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
3.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.