Advertisements

wp_http_supports

Definition:
function wp_http_supports( $capabilities = array() {}

Determines if there is an HTTP Transport that can process this request.

Parameters

  • array $capabilities: Array of capabilities to test or a wp_remote_request() $args array.
  • string $url: Optional. If given, will check if the URL requires SSL and adds that requirement to the capabilities array.

Source code

function wp_http_supports( $capabilities = array(), $url = null ) {

	$objFetchSite = _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) $objFetchSite->_get_first_available_transport( $capabilities );

}

15137

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: