How to open Google Calendar link in a new tab

Home Forums Calendar Products Events Calendar PRO How to open Google Calendar link in a new tab

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1184429
    Brian
    Participant

    Hi,

    Client wants the Google Calendar to open in a new tab, on a single event page like http://841.ab2.mwp.accessdomain.com/event/lafayette-boot-camp/ .

    I thought to rework and apply the code in venue.php, to ical.php, but no dice:

    	function tribe_get_gcal_link( $post_id = null, $label = null ) {
    		$url = tribe_get_gcal_link_url( $post_id );
    
    		if ( ! empty( $url ) ) {
    			$label = is_null( $label ) ? $url : $label;
    			if ( ! empty( $url ) ) {
    				$parseUrl = parse_url( $url );
    				if ( empty( $parseUrl['scheme'] ) ) {
    					$url = "http://$url";
    				}
    			}
    			$html = sprintf(
    				'<a href="%s" target="%s">%s</a>',
    				esc_attr( esc_url( $url ) ),
    				apply_filters( 'tribe_get_gcal_link_target', '_blank' ),
    				apply_filters( 'tribe_get_gcal_link_label', esc_html( $label ) )
    			);
    		} else {
    			$html = '';
    		}
    
    		return apply_filters( 'tribe_get_gcal_link', $html );
    	}

    Which returns this error: Fatal error: Call to undefined function tribe_get_gcal_link_url() in /home/content/p3pnexwpnas15_data02/33/3250433/html/wp-content/plugins/the-events-calendar/src/functions/template-tags/ical.php on line 4

    So we have to define a function, but this is where I go off the rails. Any ideas to help get this back on track?

    Thanks in advance,

    #1184819
    Hunter
    Moderator

    Hey Brian,

    Thank you for choosing PRO and welcome to the forums! Try editing line 76 on /the-events-calendar/src/Tribe/ical.php. Add in target=”_blank” and you should be good to go.

    Let me know how it works out and have a great rest of the weekend. Cheers!

    #1185272
    Brian
    Participant

    Yep, all set Hunter. Thanks!

    echo '<a class="tribe-events-gcal tribe-events-button" href="' . Tribe__Events__Main::instance()->esc_gcal_url( tribe_get_gcal_link() ) . '" title="' . esc_attr__( 'Add to Google Calendar', 'the-events-calendar' ) . '" target="_blank"' . ' >+ ' . esc_html__( 'Google Calendar', 'the-events-calendar' ) . '</a>';

    #1185583
    Hunter
    Moderator

    Glad to hear it! Feel free to open a new thread if you have any more questions. Enjoy the rest of your week 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to open Google Calendar link in a new tab’ is closed to new replies.