Last active
July 27, 2020 03:21
-
-
Save 1naveengiri/638b90d01db68d73ba8aa2a69884c404 to your computer and use it in GitHub Desktop.
Geodirectory Add event to google calendar Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode( 'buddy-add-to-calender', 'buddy_add_to_calender' ); | |
function buddy_add_to_calender( $atts, $content = "" ) { | |
$event_id = get_the_ID(); | |
global $gd_post; | |
$event_details = maybe_unserialize($gd_post->event_dates); | |
$title = get_the_title( $event_id ); | |
if( !empty( $event_details['start_date'] ) && !empty( $event_details['start_date'] )){ | |
$start_date = $event_details['start_date'] .' '.$event_details['start_time']; | |
$end_date = $event_details['end_date'] .' '.$event_details['end_time']; | |
// $event_start_date = date('Ymd\\THi00\\Z', strtotime( $start_date )); | |
// $event_end_date = date('Ymd\\THi00\\Z', strtotime( $end_date )); | |
$event_start_date = date('Ymd\\THi00', strtotime( $start_date )); | |
$event_end_date = date('Ymd\\THi00', strtotime( $end_date )); | |
$content = '<a href="https://www.google.com/calendar/render?action=TEMPLATE&text='. get_the_title() .'&dates='.$event_start_date.'/'. $event_end_date .'&details=For+details,+link+here:+'. get_permalink().'&sf=true&output=xml" class="add-to-calender" target="_blank" ctz="America/New_York"><i class="far fa-calendar-alt"></i></a>'; | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment