tribe_get_venue_object( null|int|WP_Post $venue = null, string|null $output = OBJECT, string $filter = 'raw', bool $force = false )

Fetches and returns a decorated post object representing a Venue.


Parameters

$venue

(null|int|WP_Post) (Optional) The venue ID or post object or null to use the global one.

Default value: null

$output

(string|null) (Optional) The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively. Defaults to OBJECT.

Default value: OBJECT

$filter

(string) (Optional) Type of filter to apply. Accepts 'raw'.

Default value: 'raw'

$force

(bool) (Optional) Whether to force a re-fetch ignoring cached results or not.

Default value: false


Top ↑

Return

(array|mixed|void|WP_Post|null) The Venue post object or array, null if not found.

  • 'address'
    (string) The venue address field, normally street and number.
  • 'country'
    (string) Which country the venue happens, full name of the country, no abbr.
  • 'city'
    (string) The city for the venue.
  • 'state_province'
    (string) State or province for the venue, available for venues outside of the US.
  • 'state'
    (string) The state for the venue in case of a US based venue.
  • 'province'
    (string) Province for the venue, mostly deprecated, use state_province.
  • 'zip'
    (string) Zip code of the venue.
  • 'overwrite_coordinates'
    (boolean) Did this venue get it's coordinates overwritten manually.
  • 'latitude'
    (string) The latitude of the venue.
  • 'longitude'
    (string) The longitude of the venue.
  • 'geolocation_string'
    (string) The string we use to crawl and link to the maps provider.


Top ↑

Source

File: src/functions/template-tags/venue.php

function tribe_get_venue_object( $venue = null, $output = OBJECT, $filter = 'raw' ) {
	/**
	 * Filters the venue result before any logic applies.
	 *
	 * Returning a non `null` value here will short-circuit the function and return the value.
	 * Note: this value will not be cached and the caching of this value is a duty left to the filtering function.
	 *
	 * @since 4.9.9
	 *
	 * @param mixed       $return      The venue object to return.
	 * @param mixed       $venue       The venue object to fetch.
	 * @param string|null $output      The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
	 *                                 correspond to a `WP_Post` object, an associative array, or a numeric array,
	 *                                 respectively. Defaults to `OBJECT`.
	 * @param string      $filter      Type of filter to apply. Accepts 'raw'.
	 */
	$return = apply_filters( 'tribe_get_venue_object_before', null, $venue, $output, $filter );

	if ( null !== $return ) {
		return $return;
	}

	$post = Venue::from_post( $venue )->to_post( $output, $filter );

	if ( empty( $post ) ) {
		return null;
	}

	/**
	 * Filters the venue post object before caching it and returning it.
	 *
	 * Note: this value will be cached; as such this filter might not run on each request.
	 * If you need to filter the output value on each call of this function then use the `tribe_get_venue_object_before`
	 * filter.
	 *
	 * @since 4.9.7
	 *
	 * @param WP_Post $post   The venue post object, decorated with a set of custom properties.
	 * @param string  $output The output format to use.
	 * @param string  $filter The filter, or context of the fetch.
	 */
	$post = apply_filters( 'tribe_get_venue_object', $post, $output, $filter );

	if ( OBJECT !== $output ) {
		$post = ARRAY_A === $output ? (array) $post : array_values( (array) $post );
	}

	return $post;
}

Top ↑

Changelog

Changelog
Version Description
4.9.9 Introduced.