Created
November 19, 2013 22:45
-
-
Save korymath/7553926 to your computer and use it in GitHub Desktop.
Eventbrite / WordPress Integration in PHP, handles repeating events, and removes past events.
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 | |
// load the API Client library | |
$authentication_tokens = array('app_key' => 'APPKEY', | |
'user_key' => 'USERKEY'); | |
$eb_client = new Eventbrite( $authentication_tokens ); | |
$events = $eb_client->user_list_events(array('event_statuses'=>'live,started','display'=>'repeat_schedule')); | |
$repeat_events = array(); | |
foreach ($events->events as $event) { | |
if ( 'yes' === $event->event->repeats ) { | |
foreach ( $event->event->repeat_schedule as $i => $repeat ) { | |
$repeat_event = clone $event; | |
$repeat_event->event = unserialize(serialize($repeat_event->event)); | |
$repeat_event->event->start_date = $repeat->start_date; | |
$repeat_event->event->end_date = $repeat->end_date; | |
$repeat_event->event->occurrence = $i; | |
$repeat_events[] = $repeat_event; | |
} | |
} | |
} | |
function date_compare($a, $b) | |
{ | |
$t1 = strtotime($a->event->start_date); | |
$t2 = strtotime($b->event->start_date); | |
return $t1 - $t2; | |
} | |
$repeat_events[] = usort($repeat_events,'date_compare'); | |
foreach ($repeat_events as $event) { | |
if (current_time( 'timestamp' ) <= strtotime( $event->event->end_date )) { | |
$finalList[] = $event; | |
} | |
} | |
/* $finalListSlice = array_slice($finalList, 0, 3); */ | |
$finalListSlice = $finalList; | |
foreach ($finalListSlice as $event) { | |
$buyTixURL = $event->event->url; | |
$dateRef = $event->event->start_date; | |
$dateFix = str_replace(' ', '+', $dateRef); | |
$eventTitle = $event->event->title; | |
$eventShortTitle = explode(' ', trim($eventTitle)); | |
$buyTixURL = $buyTixURL.'&selecteddate='.$dateFix; | |
?> | |
<div class="bs-callout col-md-4 col-xs-6 <?php echo($eventShortTitle[0].' '.$eventShortTitle[0].substr($dateFix, 0, 10)); ?>"> | |
<a href="<?php echo $buyTixURL; ?>"> | |
<div class="event-item"> | |
<div class="event-date"> | |
<span class="date-month"><?php echo date('M', strtotime($event->event->start_date)).'. '; echo date('d', strtotime($event->event->start_date)).' '; echo date('Y', strtotime($event->event->start_date));?></span> | |
</div> | |
<div class="event-details"> | |
<h2 class="event-title"><?php echo $event->event->title; echo(' | '); echo date('g:iA', strtotime($event->event->start_date)); ?></h2> | |
<div class="event-tickets"> | |
<span class="glyphicon glyphicon-shopping-cart"></span>Buy Tickets | |
</div> | |
</div> | |
</div> | |
</a> | |
</div> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment