Tribe__Events__Pro__Main::get_link( string $event_url, string $type, string $secondary, string $term )
filter Tribe__Events__Main::getLink for pro views
Contents
Parameters
- $event_url
-
(string) (Required)
- $type
-
(string) (Required)
- $secondary
-
(string) (Required)
- $term
-
(string) (Required)
Return
(string)
Source
File: src/Tribe/Main.php
public function get_link( $event_url, $type, $secondary, $term ) {
switch ( $type ) {
case 'week':
$event_url = trailingslashit( esc_url_raw( $event_url . $this->weekSlug ) );
if ( ! empty( $secondary ) ) {
$event_url = esc_url_raw( trailingslashit( $event_url ) . $secondary );
}
break;
case 'photo':
$event_url = trailingslashit( esc_url_raw( $event_url . $this->photoSlug ) );
if ( ! empty( $secondary ) ) {
$event_url = esc_url_raw( trailingslashit( $event_url ) . $secondary );
}
break;
case 'map':
$event_url = trailingslashit( esc_url_raw( $event_url . Tribe__Events__Pro__Geo_Loc::instance()->rewrite_slug ) );
if ( ! empty( $secondary ) ) {
$event_url = esc_url_raw( trailingslashit( $event_url ) . $secondary );
}
break;
case 'all':
// Temporarily disable the post_type_link filter for recurring events
$link_filter = array( $this->permalink_editor, 'filter_recurring_event_permalinks' );
remove_filter( 'post_type_link', $link_filter, 10, 4 );
// Obtain the ID of the parent event
$post_id = $secondary ? $secondary : get_the_ID();
$parent_id = wp_get_post_parent_id( $post_id );
$event_id = ( 0 === $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,
$event_id,
$parent_id
);
$permalink = get_permalink( $event_id );
$event_url = tribe_append_path( $permalink, $all_frag );
// Restore the temporarily disabled permalink filter
add_filter( 'post_type_link', $link_filter, 10, 4 );
/**
* Filters the link to the "all" recurrences view for a recurring event.
*
* @param string $event_url The link to the "all" recurrences view for the event
* @param int $event_id The recurring event post ID
*/
$event_url = apply_filters( 'tribe_events_pro_get_all_link', $event_url, $event_id );
break;
default:
break;
}
return apply_filters( 'tribe_events_pro_get_link', $event_url, $type, $secondary, $term );
}