Tribe__Events__Pro__Main::ugly_link( string $eventUrl, string $type, string $secondary )

Add support for ugly links for ugly links with PRO views.


Parameters

$eventUrl

(string) (Required) The current URL.

$type

(string) (Required) The type of endpoint/view whose link was requested.

$secondary

(string) (Required) More data that is necessary for generating the link.


Top ↑

Return

(string) The ugly-linked URL.


Top ↑

Source

File: src/Tribe/Main.php

		public function ugly_link( $eventUrl, $type, $secondary ) {
			switch ( $type ) {
				case 'week':
					if ( ! apply_filters( 'tribe_events_force_ugly_link', false ) && empty( $_POST['baseurl'] ) ) {
						$eventUrl = add_query_arg( 'post_type', Tribe__Events__Main::POSTTYPE, $eventUrl );
					}

					$eventUrl = add_query_arg( array( 'tribe_event_display' => $type ), $eventUrl );
					if ( $secondary ) {
						$eventUrl = add_query_arg( array( 'date' => $secondary ), $eventUrl );
					}
					break;
				case 'photo':
				case 'map':
					$eventUrl = add_query_arg( array( 'tribe_event_display' => $type ), $eventUrl );
					break;
				case 'all':
					remove_filter(
						'post_type_link',
						array( $this->permalink_editor, 'filter_recurring_event_permalinks' ),
						10, 4
					);
					$post_id = $secondary ? $secondary : get_the_ID();
					$parent_id = wp_get_post_parent_id( $post_id );
					if ( ! empty( $parent_id ) ) {
						$post_id = $parent_id;
					}

					/**
					 * Filters the "all" part of the all recurrences link for a recurring event.
					 *
					 * @param string $all_frag Defaults to the localized versions of the "all" word.
					 * @param int $post_id The event post object ID.
					 * @param int $parent_id The event post object parent ID; this value will be the same as
					 *                             `$post_id` if the event has no parent.
					 */
					$all_frag = apply_filters(
						'tribe_events_pro_all_link_frag',
						$this->all_slug,
						$post_id,
						$parent_id
					);

					$eventUrl = add_query_arg( 'eventDisplay', $all_frag, get_permalink( $post_id ) );
					add_filter(
						'post_type_link',
						array( $this->permalink_editor, 'filter_recurring_event_permalinks' ),
						10, 4
					);
					break;
				default:
					break;
			}

			return apply_filters( 'tribe_events_pro_ugly_link', $eventUrl, $type, $secondary );
		}