W3cubDocs

/WordPress

Curl::__construct()

Constructor

Source

	$curl          = curl_version();
	$this->version = $curl['version_number'];
	$this->handle  = curl_init();

	curl_setopt($this->handle, CURLOPT_HEADER, false);
	curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1);
	if ($this->version >= self::CURL_7_10_5) {
		curl_setopt($this->handle, CURLOPT_ENCODING, '');
	}

	if (defined('CURLOPT_PROTOCOLS')) {
		// phpcs:ignore PHPCompatibility.Constants.NewConstants.curlopt_protocolsFound
		curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
	}

	if (defined('CURLOPT_REDIR_PROTOCOLS')) {
		// phpcs:ignore PHPCompatibility.Constants.NewConstants.curlopt_redir_protocolsFound
		curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
	}
}

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wporg-requests-transport-curl/__construct