p+=U`P==U@PAH=U<=UPuH=U<P=U0=Up+=U==UPA=U`A E=U<0=UPp+=UP@=p+=U`0==U PAH=U0<=U0PuH=U@<P=U@0=Up+=U==UpPA=U``A E=U<0=U0p+=UP =p+=U`==UPAH=U`<=U`PuH=Up<P=Up0=Up p+=U` ==UP PA=U@ `A E=U<0=U p+=UP =p+=U` ==U PAH=U<=UPuH=U<P=U0=UP p+=U@ ==U0 PA=U `A E=U<0=U h=U >D@D@.@X@0A@@P2@@@@@8@@?@@?@p8@8@8@x|P2@p|ЂӷX@X@D@(j@@`A0Aв{X@X@D@@@@D@A`k@y}X@X@@(j@@H0A {X@X@@@@@@A`k@p{@{0A z}X@X@@@(j@@0A{X@X@@@@@@@@P`k@z}X@X@@?@(j@@Ks0A@X@X@@?@@@@@?@xu@`@0:@|@~X@X@8@(j@@|0AX@X@8@@@@8@@@xu@`@@0:@XY@(|~X@X@w(j@@0A`{X@X@w@@@|A`k@{@ط0A{visibility( $visible ); // Return return $visible; } /** * {@inheritDoc} */ public function get_label( View $view = null ): string { return $this->filter_get_label( $this->label(), $view ); } /** * Returns the label for the link. * * @since 6.8.2.1 * * @return string */ abstract protected function label(): string; /** * Filters the label for the link. * * @since 6.8.2.1 * * @param string $value The label to filter. * @param View|null $view The current View object. * * @return string */ protected function filter_get_label( string $value, View $view = null ): string { $slug = self::get_slug(); /** * Allows filtering of the labels for the Single Event view labels. * * @since 5.12.0 * * @param string $label The label that will be displayed. * @param Link_Abstract $link_obj The link object the label is for. * @param View $view The current View object. * * @return string $label The label that will be displayed. */ return (string) apply_filters( "tec_views_v2_subscribe_links_{$slug}_label", $value, $this, $view ); } /** * {@inheritDoc} */ public function get_single_label( View $view = null ): string { return $this->filter_get_single_label( $this->single_label(), $view ); } /** * Returns the label for the single event view. * * @since 6.8.2.1 * * @return string */ abstract protected function single_label(): string; /** * Filters the single label for the link. * * @since 6.8.2.1 * * @param string $value The label to filter. * @param View|null $view The current View object. * * @return string */ protected function filter_get_single_label( string $value, View $view = null ): string { $slug = self::get_slug(); /** * Allows filtering of the labels for the Single Event view labels. * * @since 5.12.0 * * @param string $single_label The label that will be displayed. * @param Link_Abstract $link_obj The link object the label is for. * @param View $view The current View object. * * @return string $label The label that will be displayed. */ return (string) apply_filters( "tec_views_v2_single_subscribe_links_{$slug}_label", $value, $this, $view ); } /** * Fetches the slug of this particular instance of the Link. * * @since 5.12.0 * * @return string */ public static function get_slug() { return static::$slug; } /** * {@inheritDoc} */ public function set_visibility( bool $visible ) { $this->visible = $visible; } /** * {@inheritDoc} */ public function get_uri( View $view = null ) { // If we're on a Single Event view, let's bypass the canonical function call and logic. if ( is_single() ) { $feed_url = null === $view ? tribe_get_single_ical_link() : $view->get_context()->get( 'single_ical_link', false ); } if ( empty( $feed_url ) && null !== $view ) { $feed_url = $this->get_canonical_ics_feed_url( $view ); } if ( empty( $feed_url ) ) { return ''; } $feed_url = str_replace( [ 'http://', 'https://' ], 'webcal://', $feed_url ); /** * Filters the feed URL for the subscribe link. * * @since 6.11.0 * * @param string $feed_url The feed URL. * @param View $view The view. */ return (string) apply_filters( 'tec_views_v2_subscribe_links_feed_url', $feed_url, $view ); } /** * Retrieve the iCal Feed URL with current context parameters. * * Both iCal and gCal URIs can be built from the Feed URL which simply * points to a canonical URL that the generator can parse * via `tribe_get_global_query_object` and spew out results in the * ICS format. * * This is exactly what \Tribe__Events__iCal::do_ical_template does * and lets it generate from a less vague and a more context-bound URL * for more granular functionality. This lets us have shortcode support * among other things. * * We strip some of the things that we don't need for subscriptions * like end dates, view types, etc., ignores pagination and always returns * fresh future events. * * The URL generated is also inert to the Permalink and Rewrite Rule settings * in WordPress, so it will work out of the box on any website, even if * the settings are changed or break. * * @param View $view The View we're being called from. * * @return string The iCal Feed URI. */ protected function get_canonical_ics_feed_url( View $view = null ) { if ( null === $view ) { return ''; } $view_url_args = $view->get_url_args(); // Some date magic. if ( isset( $view_url_args['eventDate'] ) ) { // Subscribe from the calendar date (pagination, shortcode calendars, etc). $view_url_args['tribe-bar-date'] = $view_url_args['eventDate']; } // Clean query params to only contain canonical arguments. $canonical_args = [ 'post_type', 'tribe-bar-date', 'tribe_events_cat', 'post_tag' ]; /** * Allows other plugins to alter what gets passed to the subscribe link. * * @since 5.12.0 * * @param array $canonical_args A list of "passthrough" argument keys. * @param View|null $view The View we're being called from. * * @return array $canonical_args The modified list of "passthrough" argument keys. */ $canonical_args = apply_filters( 'tec_views_v2_subscribe_links_canonical_args', $canonical_args, $view ); // This array will become the args we pass to `add_query_arg()` $passthrough_args = []; foreach ( $view_url_args as $arg => $value ) { if ( in_array( $arg, $canonical_args, true ) ) { $passthrough_args[ $arg ] = $view_url_args[ $arg ]; } } // iCalendarize! $passthrough_args['ical'] = 1; // Allow all views to utilize the list view so they collect the appropriate number of events. // Note: this is only applied to subscription links - the ics direct link downloads what you see on the page! $passthrough_args["eventDisplay"] = \Tribe\Events\Views\V2\Views\List_View::get_view_slug(); // Tidy (remove empty-value pairs). $passthrough_args = array_filter( $passthrough_args ); /** * Allows other plugins to alter the query args that get passed to the subscribe link. * * @since 5.12.0 * * @param array $passthrough_args The arguments used to build the ical links. * @param array $canonical_args A list of allowed argument keys. * @param View $view The View we're being called from. * * @return array $passthrough_args The modified list of arguments used to build the ical links. */ $passthrough_args = apply_filters( 'tec_views_v2_subscribe_links_url_args', $passthrough_args, $view ); return add_query_arg( urlencode_deep( $passthrough_args ), home_url( '/' ) ); } /** * Magic method to allow getting the label and single_label properties. * These two params are deprecated and will be removed in a future release. * * @since 6.8.2.1 * * @param string $name The property name. * * @return string|null */ public function __get( $name ) { if ( 'label' === $name ) { _doing_it_wrong( __METHOD__, 'The `label` property is deprecated and will be removed in a future release.', '6.8.2.1' ); return $this->get_label(); } if ( 'single_label' === $name ) { _doing_it_wrong( __METHOD__, 'The `single_label` property is deprecated and will be removed in a future release.', '6.8.2.1' ); return $this->get_single_label(); } return null; } /** * Magic method surrounding the JSON serialization to enable the object to be serialized with all props. * * @since 6.8.2.1 * * @return array */ #[\ReturnTypeWillChange] public function jsonSerialize() { return [ 'label' => $this->get_label(), 'single_label' => $this->get_single_label(), 'visible' => $this->is_visible(), 'block_slug' => $this->block_slug, ]; } }