WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Requests::request_multiple() public WP 1.0

Send multiple HTTP requests simultaneously

The $requests parameter takes an associative or indexed array of request fields. The key of each request can be used to match up the request with the returned data, or with the request passed into your multiple.request.complete callback.

The request fields value is an associative array with the following keys:

  • url: Request URL Same as the $url parameter to
    [Requests::request](https://wp-kama.ru/function/Requests::request 'Main interface for HTTP requests')
    (string, required)
  • headers: Associative array of header fields. Same as the $headers
    parameter to [Requests::request](https://wp-kama.ru/function/Requests::request 'Main interface for HTTP requests')
    (array, default: `array()`)
  • data: Associative array of data fields or a string. Same as the
    `$data` parameter to [Requests::request](https://wp-kama.ru/function/Requests::request 'Main interface for HTTP requests')
    (array|string, default: `array()`)
  • type: HTTP request type (use Requests constants). Same as the $type
    parameter to [Requests::request](https://wp-kama.ru/function/Requests::request 'Main interface for HTTP requests')
    (string, default: `Requests::GET`)
  • cookies: Associative array of cookie name to value, or cookie jar.

If the $options parameter is specified, individual requests will inherit options from it. This can be used to use a single hooking system, or set all the types to Requests::POST, for example.

In addition, the $options parameter takes the following global options:

  • complete: A callback for when a request is complete. Takes two
    parameters, a Requests_Response/Requests_Exception reference, and the
    ID from the request array (Note: this can also be overridden on a
    per-request basis, although that's a little silly)

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

Хуков нет.


Массив. Responses (either Requests_Response or a Requests_Exception object)


$result = Requests::request_multiple( $requests, $options );
$requests(массив) (обязательный)
Requests data (see description for more information)
Global and default options (see Requests::request)

Код Requests::request_multiple() WP 5.7

public static function request_multiple($requests, $options = array()) {
	$options = array_merge(self::get_default_options(true), $options);

	if (!empty($options['hooks'])) {
		$options['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple'));
		if (!empty($options['complete'])) {
			$options['hooks']->register('multiple.request.complete', $options['complete']);

	foreach ($requests as $id => &$request) {
		if (!isset($request['headers'])) {
			$request['headers'] = array();
		if (!isset($request['data'])) {
			$request['data'] = array();
		if (!isset($request['type'])) {
			$request['type'] = self::GET;
		if (!isset($request['options'])) {
			$request['options'] = $options;
			$request['options']['type'] = $request['type'];
		else {
			if (empty($request['options']['type'])) {
				$request['options']['type'] = $request['type'];
			$request['options'] = array_merge($options, $request['options']);

		self::set_defaults($request['url'], $request['headers'], $request['data'], $request['type'], $request['options']);

		// Ensure we only hook in once
		if ($request['options']['hooks'] !== $options['hooks']) {
			$request['options']['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple'));
			if (!empty($request['options']['complete'])) {
				$request['options']['hooks']->register('multiple.request.complete', $request['options']['complete']);

	if (!empty($options['transport'])) {
		$transport = $options['transport'];

		if (is_string($options['transport'])) {
			$transport = new $transport();
	else {
		$transport = self::get_transport();
	$responses = $transport->request_multiple($requests, $options);

	foreach ($responses as $id => &$response) {
		// If our hook got messed with somehow, ensure we end up with the
		// correct response
		if (is_string($response)) {
			$request = $requests[$id];
			self::parse_multiple($response, $request);
			$request['options']['hooks']->dispatch('multiple.request.complete', array(&$response, $id));

	return $responses;