wp_http_supports

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

Description

wp_http_supports( (array) $capabilities = array(), (null) $url = null ); 

Parameters (2)

0. $capabilities — Optional. (array) => array()
Array of capabilities to test or a wp_remote_request() $args array.
1. $url — Optional. (null) => null
If given, will check if the URL requires SSL and adds that requirement to the capabilities array.

Usage

  1. if ( !function_exists( 'wp_http_supports' ) ) { 
  2. require_once ABSPATH . WPINC . '/http.php'; 
  3.  
  4. // Array of capabilities to test or a wp_remote_request() $args array. 
  5. $capabilities = array(); 
  6.  
  7. // Optional. If given, will check if the URL requires SSL and adds 
  8. // that requirement to the capabilities array. 
  9. $url = null; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = wp_http_supports($capabilities, $url); 
  13.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/http.php  
  1. function wp_http_supports( $capabilities = array(), $url = null ) { 
  2. $http = _wp_http_get_object(); 
  3.  
  4. $capabilities = wp_parse_args( $capabilities ); 
  5.  
  6. $count = count( $capabilities ); 
  7.  
  8. // If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array 
  9. if ( $count && count( array_filter( array_keys( $capabilities ), 'is_numeric' ) ) == $count ) { 
  10. $capabilities = array_combine( array_values( $capabilities ), array_fill( 0, $count, true ) ); 
  11.  
  12. if ( $url && !isset( $capabilities['ssl'] ) ) { 
  13. $scheme = parse_url( $url, PHP_URL_SCHEME ); 
  14. if ( 'https' == $scheme || 'ssl' == $scheme ) { 
  15. $capabilities['ssl'] = true; 
  16.  
  17. return (bool) $http->_get_first_available_transport( $capabilities );