WpOrg\Requests\Transport
Curl::format_get()
Format a URL given GET data
Method of the class: Curl{}
No Hooks.
Return
String
. URL with data
Usage
$result = Curl::format_get( $url, $data );
- $url(string) (required)
- Original URL.
- $data(array|object) (required)
- Data to build query using, see https://www.php.net/http_build_query
Curl::format_get() Curl::format get code WP 6.6.2
private 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, '', '&'); $query = trim($query, '&'); if (empty($url_parts['query'])) { $url .= '?' . $query; } else { $url = str_replace($url_parts['query'], $query, $url); } } return $url; }