Tribe__Events__Main::uglyLink( string $type = 'home', bool|string $secondary = false )
If pretty perms are off, get the ugly link.
Contents
Parameters
- $type
-
(string) (Optional) The type of link requested.
Default value: 'home'
- $secondary
-
(bool|string) (Optional) Some secondary data for the link.
Default value: false
Return
(string) The ugly link.
Source
File: src/Tribe/Main.php
public function uglyLink( $type = 'home', $secondary = false ) {
$eventUrl = add_query_arg( 'post_type', self::POSTTYPE, home_url() );
/**
* If we need a specific base url, use that.
*
* @return string The base url.
*/
$eventUrl = apply_filters( 'tribe_events_ugly_link_baseurl', $eventUrl );
/**
* if this is an ajax request where the baseurl is provided, use that as the base url.
*
* @return string The AJAX provided base url.
*/
if ( tribe( 'context' )->doing_ajax() && ! empty( $_POST['baseurl'] ) ) {
$eventUrl = trailingslashit( $_POST['baseurl'] );
}
// if we're on an Event Cat, show the cat link, except for home.
if ( $type !== 'home' && is_tax( self::TAXONOMY ) ) {
if (
(
tribe( 'context' )->doing_ajax()
&& ! empty( $_POST['baseurl'] )
)
|| apply_filters( 'tribe_events_force_ugly_link', false )
) {
$eventUrl = add_query_arg( 'tribe_event_category', get_query_var( 'term' ), $eventUrl );
} else {
$eventUrl = add_query_arg( self::TAXONOMY, get_query_var( 'term' ), $eventUrl );
}
}
switch ( $type ) {
case 'day':
$eventUrl = add_query_arg( array( 'tribe_event_display' => $type ), $eventUrl );
if ( $secondary ) {
$eventUrl = add_query_arg( array( 'eventDate' => $secondary ), $eventUrl );
}
break;
case 'week':
case 'month':
$eventUrl = add_query_arg( array( 'tribe_event_display' => $type ), $eventUrl );
if ( is_string( $secondary ) ) {
$eventUrl = add_query_arg( array( 'eventDate' => $secondary ), $eventUrl );
} elseif ( is_array( $secondary ) ) {
$eventUrl = add_query_arg( $secondary, $eventUrl );
}
break;
case 'list':
case 'past':
case 'upcoming':
$eventUrl = add_query_arg( array( 'tribe_event_display' => $type ), $eventUrl );
break;
case 'dropdown':
$dropdown = add_query_arg( array( 'tribe_event_display' => 'month', 'eventDate' => ' ' ), $eventUrl );
$eventUrl = rtrim( $dropdown ); // tricksy
break;
case 'single':
global $post;
$p = $secondary ? $secondary : $post;
$eventUrl = get_permalink( $p );
break;
case 'home':
default:
break;
}
return apply_filters( 'tribe_events_ugly_link', $eventUrl, $type, $secondary );
}