Hooks::filter_tec_views_v2_subscribe_links_url_args( TribeEventsProViewsV2Shortcodesarray $args, TribeEventsProViewsV2ShortcodesView_Interface $view )
Filter the iCal link args to allow shortcodes to pass through params that would be “hidden” in their params otherwise.
Topics
Parameters #
- $args
-
(<span class="TribeEventsProViewsV2ShortcodesarrayTribeEventsProViewsV2Shortcodesarray<string|">TribeEventsProViewsV2Shortcodesmixed>) (Required) The array of args (params) that will be added to the URL.
- $view
-
(TribeEventsProViewsV2ShortcodesView_Interface) (Required) The view instance.
Return #
(void)
Source #
File: src/Tribe/Views/V2/Shortcodes/Hooks.php
public function filter_tec_views_v2_subscribe_links_url_args( $args, $view ) { $view_url_args = $view->get_url_args(); // Shortcode is stripped out of the passthrough args already - it doesn't belong in the subscribe URL. if ( empty( $view_url_args['shortcode'] ) ) { return $args; } $database_args = tribe( Tribe_Events::class )->get_database_arguments( $view_url_args['shortcode'] ); if ( empty( $database_args['category'] ) && empty( $database_args['tag'] ) ) { return $args; } // `tribe_events` allows multiple tags/categories, let's pass them all and let the repository handle it. // If we have category args, add them. if ( ! empty( $database_args['category'] ) ) { $cats = []; foreach( $database_args['category'] as $cat_id ) { $cats[] = get_term( $cat_id )->slug; } // Note: WP allows us to use `,` (OR) or `+` (AND) for a separator - // but our current rewrite rules break using `+` so we'll stick to `,` for now. $args[TEC::TAXONOMY] = implode( ',', $cats ); } // If we have tag args, add them. if ( ! empty( $database_args['tag'] ) ) { $tags = []; foreach( $database_args['tag'] as $tag_id ) { $tags[] = get_term( $tag_id )->slug; } $args['post_tag'] = implode( ',', $tags ); } return $args; }
Changelog #
Version | Description |
---|---|
5.11.1 | Introduced. |