WordPress at Your Fingertips
function is not described

WP_Community_Events::get_request_args() protected WP 4.8.0

Builds an array of args to use in an HTTP request to the w.org Events API.

{} It's a method of the class: WP_Community_Events{}

No Hooks.

Return

Array. The request args.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_request_args( $search, $timezone );
$search(string)
City search string.
Default: empty string
$timezone(string)
Timezone string.
Default: empty string

Changelog

Since 4.8.0 Introduced.

Code of WP_Community_Events::get_request_args() WP 5.8.2

protected function get_request_args( $search = '', $timezone = '' ) {
	$args = array(
		'number' => 5, // Get more than three in case some get trimmed out.
		'ip'     => self::get_unsafe_client_ip(),
	);

	/*
	 * Include the minimal set of necessary arguments, in order to increase the
	 * chances of a cache-hit on the API side.
	 */
	if ( empty( $search ) && isset( $this->user_location['latitude'], $this->user_location['longitude'] ) ) {
		$args['latitude']  = $this->user_location['latitude'];
		$args['longitude'] = $this->user_location['longitude'];
	} else {
		$args['locale'] = get_user_locale( $this->user_id );

		if ( $timezone ) {
			$args['timezone'] = $timezone;
		}

		if ( $search ) {
			$args['location'] = $search;
		}
	}

	// Wrap the args in an array compatible with the second parameter of `wp_remote_get()`.
	return array(
		'body' => $args,
	);
}