Requests_Session::merge_request() WordPress Method

The Requests_Session::merge_request() method is used to merge two HTTP requests into a single request. This can be useful when you want to make a batch request and want to avoid making multiple HTTP requests.

Requests_Session::merge_request( array $request, boolean $merge_options = true ) #

Merge a request’s data with the default data


Parameters

$request

(array)(Required)Request data (same form as request_multiple)

$merge_options

(boolean)(Optional)Should we merge options as well?

Default value: true


Top ↑

Return

(array) Request data


Top ↑

Source

File: wp-includes/Requests/Session.php

	protected function merge_request($request, $merge_options = true) {
		if ($this->url !== null) {
			$request['url'] = Requests_IRI::absolutize($this->url, $request['url']);
			$request['url'] = $request['url']->uri;
		}

		if (empty($request['headers'])) {
			$request['headers'] = array();
		}
		$request['headers'] = array_merge($this->headers, $request['headers']);

		if (empty($request['data'])) {
			if (is_array($this->data)) {
				$request['data'] = $this->data;
			}
		}
		elseif (is_array($request['data']) && is_array($this->data)) {
			$request['data'] = array_merge($this->data, $request['data']);
		}

		if ($merge_options !== false) {
			$request['options'] = array_merge($this->options, $request['options']);

			// Disallow forcing the type, as that's a per request setting
			unset($request['options']['type']);
		}

		return $request;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.