WP_Http_Curl::test()public staticWP 2.7.0

Determines whether this class can be used for retrieving a URL.

Метод класса: WP_Http_Curl{}

Хуки из метода

Возвращает

true|false. False means this class can not be used, true means it can.

Использование

$result = WP_Http_Curl::test( $args );
$args(массив)
Array of request arguments.
По умолчанию: empty array

Список изменений

С версии 2.7.0 Введена.

Код WP_Http_Curl::test() WP 6.7.1

public static function test( $args = array() ) {
	if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) {
		return false;
	}

	$is_ssl = isset( $args['ssl'] ) && $args['ssl'];

	if ( $is_ssl ) {
		$curl_version = curl_version();
		// Check whether this cURL version support SSL requests.
		if ( ! ( CURL_VERSION_SSL & $curl_version['features'] ) ) {
			return false;
		}
	}

	/**
	 * Filters whether cURL can be used as a transport for retrieving a URL.
	 *
	 * @since 2.7.0
	 *
	 * @param bool  $use_class Whether the class can be used. Default true.
	 * @param array $args      An array of request arguments.
	 */
	return apply_filters( 'use_curl_transport', true, $args );
}