WpOrg\Requests\Transport
Fsockopen::format_get
Format a URL given GET data
Method of the class: Fsockopen{}
No Hooks.
Returns
String. URL with data
Usage
$result = Fsockopen::format_get( $url_parts, $data );
- $url_parts(array) (required)
- Array of URL parts as received from https://www.php.net/parse_url.
- $data(array|object) (required)
- Data to build query using, see https://www.php.net/http_build_query.
Fsockopen::format_get() Fsockopen::format get code WP 7.0
private static function format_get($url_parts, $data) {
if (!empty($data)) {
if (empty($url_parts['query'])) {
$url_parts['query'] = '';
}
$url_parts['query'] .= '&' . http_build_query($data, '', '&');
$url_parts['query'] = trim($url_parts['query'], '&');
}
if (isset($url_parts['path'])) {
if (isset($url_parts['query'])) {
$get = $url_parts['path'] . '?' . $url_parts['query'];
} else {
$get = $url_parts['path'];
}
} else {
$get = '/';
}
return $get;
}