Requests Interfaces
All interfaces defined in the Requests library.
Source files:
wp-includes/Requests/src/Auth.phpwp-includes/Requests/src/Capability.phpwp-includes/Requests/src/HookManager.phpwp-includes/Requests/src/Proxy.phpwp-includes/Requests/src/Transport.php
WpOrgRequestsAuth
Authentication provider interface.
Source: wp-includes/Requests/src/Auth.php
Package: RequestsAuthentication
Implement this interface to act as an authentication provider. Parameters should be passed via the constructor.
Methods
register()
public function register( WpOrgRequestsHooks $hooks ): voidCalled by Requests::request() when an Auth instance is set as the 'auth' option. Register all needed hooks here.
Implementations
WpOrgRequestsAuthBasic— Basic HTTP authentication
WpOrgRequestsCapability
Capability interface declaring known transport capabilities.
Source: wp-includes/Requests/src/Capability.php
Package: RequestsUtilities
Constants
| Constant | Type | Value | Description |
|---|---|---|---|
SSL | string | 'ssl' | Support for SSL |
ALL | string[] | [self::SSL] | Collection of all capabilities supported in Requests |
This interface defines no methods — it serves as an authoritative source of queryable capability identifiers. Used by Transport::test() to check transport capabilities.
WpOrgRequestsHookManager
Event dispatcher interface.
Source: wp-includes/Requests/src/HookManager.php
Package: RequestsEventDispatcher
Methods
register()
public function register( string $hook, callable $callback, int $priority = 0 ): void| Parameter | Type | Description |
|---|---|---|
$hook | string | Hook name |
$callback | callable | Callback to invoke |
$priority | int | Priority. Negative = earlier, positive = later |
dispatch()
public function dispatch( string $hook, array $parameters = [] ): bool| Parameter | Type | Description |
|---|---|---|
$hook | string | Hook name |
$parameters | array | Parameters passed to callbacks |
Returns: bool — Whether dispatching was successful.
Implementations
WpOrgRequestsHooks— Default hook manager
WpOrgRequestsProxy
Proxy connection interface.
Source: wp-includes/Requests/src/Proxy.php
Package: RequestsProxy
Since: 1.6
Implement this interface to handle proxy settings and authentication. Parameters should be passed via the constructor.
Methods
register()
public function register( WpOrgRequestsHooks $hooks ): voidCalled by Requests::request() when a Proxy instance is set as the 'proxy' option. Register all needed hooks here.
Implementations
WpOrgRequestsProxyHttp— HTTP proxy support
WpOrgRequestsTransport
Base HTTP transport interface.
Source: wp-includes/Requests/src/Transport.php
Package: RequestsTransport
Methods
request()
Perform a single HTTP request.
public function request( string $url, array $headers = [], string|array $data = [], array $options = [] ): string| Parameter | Type | Description |
|---|---|---|
$url | string | URL to request |
$headers | array | Associative array of request headers |
$data | string|array | POST body or GET/HEAD URL parameters |
$options | array | Request options |
Returns: string — Raw HTTP result.
request_multiple()
Send multiple requests simultaneously.
public function request_multiple( array $requests, array $options ): array| Parameter | Type | Description |
|---|---|---|
$requests | array | Array of request data arrays (url, headers, data, options) |
$options | array | Global options |
Returns: array — Array of Response objects (may contain Exception or string values).
test()
Self-test whether the transport can be used.
public static function test( array $capabilities = [] ): bool| Parameter | Type | Description |
|---|---|---|
$capabilities | array<string, bool> | Capabilities to test (e.g., ['ssl' => true]) |
Returns: bool — Whether the transport is available.
Implementations
WpOrgRequestsTransportCurl— cURL transportWpOrgRequestsTransportFsockopen— fsockopen transport