On this page
WP_Community_Events::get_request_args( string $search = '', string $timezone = '' ): array
Builds an array of args to use in an HTTP request to the w.org Events API.
Parameters
$searchstring Optional-
City search string.
Default:
'' $timezonestring Optional-
Timezone string.
Default:
''
Return
array The request args.
Source
File: wp-admin/includes/class-wp-community-events.php. View all references
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,
);
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Community_Events::get_unsafe_client_ip() wp-admin/includes/class-wp-community-events.php | Determines the user’s actual IP address and attempts to partially anonymize an IP address by converting it to a network ID. |
| get_user_locale() wp-includes/l10n.php | Retrieves the locale of a user. |
Used By
| Used By | Description |
|---|---|
| WP_Community_Events::get_events() wp-admin/includes/class-wp-community-events.php | Gets data about events near a particular location. |
Changelog
| Version | Description |
|---|---|
| 4.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_community_events/get_request_args