WP_Community_Events::get_request_args() WordPress Method

The WP_Community_Events::get_request_args() method is used to get the arguments for a community events request. These arguments can be used to modify the behavior of the request.

WP_Community_Events::get_request_args( string $search = '', string $timezone = '' ) #

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


Parameters

$search

(string)(Optional) City search string.

Default value: ''

$timezone

(string)(Optional) Timezone string.

Default value: ''


Top ↑

Return

(array) The request args.


Top ↑

Source

File: wp-admin/includes/class-wp-community-events.php

	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,
		);
	}


Top ↑

Changelog

Changelog
VersionDescription
4.8.0Introduced.

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.