WP_Http_Curl::test() WordPress Method

The WP_Http_Curl::test() method is used to test whether the cURL extension is installed and enabled on the server. This is important because the cURL extension is required for the WP_Http_Curl class to function properly.

WP_Http_Curl::test( array $args = array() ) #

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


Parameters

$args

(array)(Optional) Array of request arguments.

Default value: array()


Top ↑

Return

(bool) False means this class can not be used, true means it can.


Top ↑

Source

File: wp-includes/class-wp-http-curl.php

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.