WP_Http::_get_first_available_transport
Устарела с версии 6.4.0. Больше не поддерживается и может быть удалена. Используйте WpOrg\Requests\Requests::get_transport_class().
Tests which transports are capable of supporting the request.
Метод класса: WP_Http{}
Хуки из метода
Возвращает
Строку|false. Class name for the first transport that claims to support the request. False if no transport claims to support the request.
Использование
$WP_Http = new WP_Http(); $WP_Http->_get_first_available_transport( $args, $url );
- $args(массив) (обязательный)
- Request arguments.
- $url(строка)
- URL to request.
По умолчанию:null
Заметки
- Смотрите: WpOrg\Requests[Requests::get_transport_class()](/function/Requests::get_transport_class)
Список изменений
| С версии 3.2.0 | Введена. |
| Устарела с 6.4.0 | Use WpOrg\Requests\Requests::get_transport_class() |
Код WP_Http::_get_first_available_transport() WP Http:: get first available transport WP 7.0.1
public function _get_first_available_transport( $args, $url = null ) {
$transports = array( 'curl', 'streams' );
/**
* Filters which HTTP transports are available and in what order.
*
* @since 3.7.0
* @deprecated 6.4.0 Use WpOrg\Requests\Requests::get_transport_class()
*
* @param string[] $transports Array of HTTP transports to check. Default array contains
* 'curl' and 'streams', in that order.
* @param array $args HTTP request arguments.
* @param string $url The URL to request.
*/
$request_order = apply_filters_deprecated( 'http_api_transports', array( $transports, $args, $url ), '6.4.0' );
// Loop over each transport on each HTTP request looking for one which will serve this request's needs.
foreach ( $request_order as $transport ) {
if ( in_array( $transport, $transports, true ) ) {
$transport = ucfirst( $transport );
}
$class = 'WP_Http_' . $transport;
// Check to see if this transport is a possibility, calls the transport statically.
if ( ! call_user_func( array( $class, 'test' ), $args, $url ) ) {
continue;
}
return $class;
}
return false;
}