tribe_get_venue_single_line_address( int $event_id, boolean $link = true )

Gets the venue name and address on a single line.


Parameters #

$event_id

(int) (Required) The event ID.

$link

(boolean) (Optional) Whether or not to wrap the text in a venue link.

Default value: true


Top ↑

Return #

(string) Single-line address string.


Top ↑

Source #

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

	function tribe_get_venue_single_line_address( $event_id, $link = true ) {
		$venue = null;

		if ( tribe_has_venue( $event_id ) ) {
			$venue_id      = tribe_get_venue_id( $event_id );
			$venue_name    = tribe_get_venue( $event_id );
			$venue_url     = tribe_get_venue_link( $event_id, false );
			$venue_address = array(
				'city'          => tribe_get_city( $event_id ),
				'stateprovince' => tribe_get_stateprovince( $event_id ),
				'zip'           => tribe_get_zip( $event_id ),
			);

			/**
			 * Filters the parts of a venue address.
			 *
			 * @since ??
			 * @since 4.5.11 Added docblock and event ID to filter.
			 *
			 * @var array Array of address parts
			 * @var int Event ID
			 */
			$venue_address = apply_filters( 'tribe_events_venue_single_line_address_parts', $venue_address, $event_id );

			// get rid of blank elements
			$venue_address = array_filter( $venue_address );

			$venue = $venue_name;

			$separator = _x( ', ', 'Address separator', 'the-events-calendar' );
			if ( $venue_address ) {
				$venue .= $separator . implode( $separator, $venue_address );
			}

			if ( $link && $venue_url ) {
				$attr_title = the_title_attribute( array( 'post' => $venue_id, 'echo' => false ) );

				$venue = '<a href="' . esc_url( $venue_url ) . '" title="' . $attr_title . '">' . $venue . '</a>';
			}
		}

		/**
		 * Filters the venue single-line address.
		 *
		 * @since ??
		 * @since 4.5.11 Added docblock and function args to filter.
		 *
		 * @var string Venue address line
		 * @var int Event ID
		 * @var boolean Whether or not the venue should be linked
		 */
		return apply_filters( 'tribe_events_get_venue_single_line_address', $venue, $event_id, $link );
	}

Top ↑

Changelog #

Changelog
Version Description
?? Introduced.