Requests::get_transport_class()protected staticWP 1.0

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

Method of the class: Requests{}

No Hooks.


String. 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 );
Default: []

Requests::get_transport_class() code WP 6.5.3

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.
	$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)) {

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

	return self::$transport[$cap_string];