Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Last active December 18, 2015 08:59
Show Gist options
  • Save sidharrell/5758246 to your computer and use it in GitHub Desktop.
Save sidharrell/5758246 to your computer and use it in GitHub Desktop.
EE google calendar
<?php
$date_time_format = get_option('date_format') . " H:i";
$start_date_time = DateTime::createFromFormat($date_time_format,
$all_meta['start_date'] . " " . $all_meta['start_time']);
$end_date_time = DateTime::createFromFormat($date_time_format,
$all_meta['end_date'] . " " . $all_meta['end_time']);
$gc_start_date = $start_date_time->getTimestamp();
$gc_end_date = $end_date_time->getTimestamp();
$startyear = date('Y', $gc_start_date);
$startmonth = date('m', $gc_start_date);
$startday = date('d', $gc_start_date);
$starttime = gmdate('His', $gc_start_date);
$endyear = date('Y', $gc_end_date);
$endmonth = date('m', $gc_end_date);
$endday = date('d', $gc_end_date);
$endtime = gmdate('His', $gc_end_date);
$fullstart = $startyear . $startmonth . $startday . "T" . $starttime . "Z";
$fullend = $endyear . $endmonth . $endday . "T" . $endtime . "Z";
?>
<?php
//NEEDED
$orgname = get_option('events_organization_settings');
$orgname = $orgname['organization'];
$venue = array();
if (!empty($all_meta['venue_title']))
$venue[] = $all_meta['venue_title'];
if (!empty($all_meta['venue_address']))
$venue[] = $all_meta['venue_address'];
if (!empty($all_meta['venue_address2']))
$venue[] = $all_meta['venue_address2'];
if (!empty($all_meta['venue_city']))
$venue[] = $all_meta['venue_city'];
if (!empty($all_meta['venue_state']))
$venue[] = $all_meta['venue_state'];
if (!empty($all_meta['venue_zip']))
$venue[] = $all_meta['venue_zip'];
if (!empty($all_meta['venue_country']))
$venue[] = $all_meta['venue_country'];
$location = implode($venue, ',');
?>
<a href="http://www.google.com/calendar/event?action=TEMPLATE&text=<?php
echo $all_meta['event_name'];
?>&dates=<?php echo $fullstart;
?>/<?php echo $fullend;
?>&details=<?php echo wp_strip_all_tags($all_meta['event_desc']);
?>&location=<?php echo $location;
?>&trp=false&sprop=<?php echo $orgname;
?>&sprop=name:<?php echo site_url();
?>" target="_blank"><img src="//www.google.com/calendar/images/ext/gc_button3.gif" border=0></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment