Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/http.php

    r14079 r17915  
    192192}
    193193
    194 ?>
     194/**
     195 * Determines if there is an HTTP Transport that can process this request.
     196 *
     197 * @since 3.2.0
     198 *
     199 * @param array  $capabilities Array of capabilities to test or a wp_remote_request() $args array.
     200 * @param string $url Optional.  If given, will check if the URL requires SSL and adds that requirement to the capabilities array.
     201 *
     202 * @return bool
     203 */
     204function wp_http_supports( $capabilities = array(), $url = null ) {
     205    $objFetchSite = _wp_http_get_object();
     206
     207    $capabilities = wp_parse_args( $capabilities );
     208
     209    $count = count( $capabilities );
     210
     211    // If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array
     212    if ( $count && count( array_filter( array_keys( $capabilities ), 'is_numeric' ) ) == $count ) {
     213        $capabilities = array_combine( array_values( $capabilities ), array_fill( 0, $count, true ) );
     214    }
     215
     216    if ( $url && !isset( $capabilities['ssl'] ) ) {
     217        $scheme = parse_url( $url, PHP_URL_SCHEME );
     218        if ( 'https' == $scheme || 'ssl' == $scheme ) {
     219            $capabilities['ssl'] = true;
     220        }
     221    }
     222
     223    return (bool) $objFetchSite->_get_first_available_transport( $capabilities );
     224}
Note: See TracChangeset for help on using the changeset viewer.