Requests_Transport_cURL::format_get() WordPress Method

The Requests_Transport_cURL::format_get() method is used to format the GET data for a cURL request. This is used to generate the data that will be sent to the server via the GET method.

Requests_Transport_cURL::format_get( string $url, array|object $data ) #

Format a URL given GET data


Parameters

$url

(string)(Required)

$data

(array|object)(Required)Data to build query using, see https://secure.php.net/http_build_query


Top ↑

Return

(string) URL with data


Top ↑

Source

File: wp-includes/Requests/Transport/cURL.php

	protected static function format_get($url, $data) {
		if (!empty($data)) {
			$query     = '';
			$url_parts = parse_url($url);
			if (empty($url_parts['query'])) {
				$url_parts['query'] = '';
			}
			else {
				$query = $url_parts['query'];
			}

			$query .= '&' . http_build_query($data, null, '&');
			$query  = trim($query, '&');

			if (empty($url_parts['query'])) {
				$url .= '?' . $query;
			}
			else {
				$url = str_replace($url_parts['query'], $query, $url);
			}
		}
		return $url;
	}

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.