WpOrg\Requests

Requests::get_transport_class()protected staticWP 1.0

Get the fully qualified class name (FQCN) for a working transport.

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

Хуков нет.

Возвращает

Строку. FQCN of the transport to use, or an empty string if no transport was found which provided the requested capabilities.

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

$result = Requests::get_transport_class( $capabilities );
$capabilities(массив)
-
По умолчанию: []

Код Requests::get_transport_class() WP 6.5.2

protected static function get_transport_class(array $capabilities = []) {
	// Caching code, don't bother testing coverage.
	// @codeCoverageIgnoreStart
	// Array of capabilities as a string to be used as an array key.
	ksort($capabilities);
	$cap_string = serialize($capabilities);

	// Don't search for a transport if it's already been done for these $capabilities.
	if (isset(self::$transport[$cap_string])) {
		return self::$transport[$cap_string];
	}

	// Ensure we will not run this same check again later on.
	self::$transport[$cap_string] = '';
	// @codeCoverageIgnoreEnd

	if (empty(self::$transports)) {
		self::$transports = self::DEFAULT_TRANSPORTS;
	}

	// Find us a working transport.
	foreach (self::$transports as $class) {
		if (!class_exists($class)) {
			continue;
		}

		$result = $class::test($capabilities);
		if ($result === true) {
			self::$transport[$cap_string] = $class;
			break;
		}
	}

	return self::$transport[$cap_string];
}