/** * Determine if a given object, given ID, or the current post is an Eventbrite event. * * @param mixed $post The current post object or event ID needed by Eventbrite_Event. * @return bool True if it's an Eventbrite event, false otherwise. */ function eventbrite_is_event($post = null) { // If no post is given, assume the current post. if (!$post) { global $post; } // Check if the post is an Eventbrite_Event object. if (is_a($post, 'Eventbrite_Event')) { return true; } // Maybe we're working with an event ID. if (is_integer($post) && 10 < strlen(strval($id))) { $event = eventbrite_get_event(absint($post)); return empty($event->error); } // No dice. return false; }
/** * Retrieve Eventbrite_Event instance. * * @static * @access public * * @param int $event_id Event ID on eventbrite.com (commonly ten digits). * @return Eventbrite_Event|bool Eventbrite_Event object, false otherwise. */ public static function get_instance($event_id) { // We can bail if no event ID was passed, or it wasn't an integer. if (!$event_id || !is_int($event_id)) { return false; } // Get the raw event. $event = eventbrite_get_event($event_id); // Return false if the ID was invalid or we got an error from the API call. if (!$event || !empty($event->error)) { return false; } // We've got an event, let's dress it up. return new Eventbrite_Event($event->events[0]); }