Tribe__Events__Pro__Geo_Loc::google_map_link( string $link, int $post_id )

Update the Google Map Link to add the coordinates if present to increase accuracy on it.


Parameters

$link

(string) (Required) The Google Map Link.

$post_id

(int) (Required) The ID of the post being modified.


Top ↑

Return

(string)


Top ↑

Source

File: src/Tribe/Geo_Loc.php

	public function google_map_link( $link, $post_id ) {
		$venue_id = function_exists( 'tribe_get_venue_id' ) ? tribe_get_venue_id( $post_id ) : $post_id;
		$is_venue = function_exists( 'tribe_is_venue' ) ? tribe_is_venue( $venue_id ) : false;

		/**
		 * Disable the behavior to add the coordinates if present on the Google Map Link
		 *
		 * @since 4.4.26
		 *
		 * @param $disable true to disable the behavior / false to keep doing it
		 * @param $post_id The ID of the post being modified
		 *
		 * @return boolean
		 */
		$disable_behavior = apply_filters( 'tribe_events_pro_google_map_link_disable_coordinates', false, $post_id );

		if ( ! $is_venue || $disable_behavior ) {
			return $link;
		}

		$coordinates = tribe_get_coordinates( $post_id );
		if ( empty( $coordinates['lat'] ) || empty( $coordinates['lng'] ) || ! function_exists( 'tribe_is_venue' ) ) {
			return $link;
		}

		return add_query_arg(
			array(
				'api'   => 1,
				'query' => urlencode( $coordinates['lat'] . ',' . $coordinates['lng'] ),
			),
			'https://www.google.com/maps/search/'
		);
	}

Top ↑

Changelog

Changelog
Version Description
4.4.26 Introduced.