/**
* Sanitize every event field.
*
* If the context is 'raw', then the event object or array will get minimal
* sanitization of the integer fields.
*
* @since 1.0.0
*
* @see btb_sanitize_event_field($field, $value, $event_id, $context = 'display')
*
* @param object|BTB_Event|array	$event		The event object or array.
* @param string					$context	Optional. How to sanitize the event fields.
												Accepts 'raw', 'edit', 'db', 'attribute', 'js' or 'display'.
												Default 'display'.
* @return object|BTB_Event|array The now sanitized BTB_Event object or array.
*/
function btb_sanitize_event($event, $context = 'display')
{
    if (is_object($event)) {
        // Check if event already filtered for this context.
        if (isset($event->filter) && $context == $event->filter) {
            return $event;
        }
        if (!isset($event->ID)) {
            $event->ID = 0;
        }
        foreach (array_keys(get_object_vars($event)) as $field) {
            $event->{$field} = btb_sanitize_event_field($field, $event->{$field}, $event->ID, $context);
        }
        $event->filter = $context;
    } elseif (is_array($event)) {
        // Check if event already filtered for this context.
        if (isset($event['filter']) && $context == $event['filter']) {
            return $event;
        }
        if (!isset($event['ID'])) {
            $event['ID'] = 0;
        }
        foreach (array_keys($event) as $field) {
            $event[$field] = btb_sanitize_event_field($field, $event[$field], $event['ID'], $context);
        }
        $event['filter'] = $context;
    }
    return $event;
}
 /**
  * Getter
  *
  * @param string $key Key to get.
  * @return mixed
  */
 public function __get($key)
 {
     if ('page_template' == $key && $this->__isset($key)) {
         return get_post_meta($this->ID, '_wp_page_template', true);
     }
     if ('post_category' == $key) {
         return array();
     }
     if ('tags_input' == $key) {
         return array();
     }
     if ('ancestors' == $key) {
         return array();
     }
     if ('post_title' == $key) {
         return $this->name;
     }
     if ('post_parent' == $key) {
         return $this->venue;
     }
     $value = get_post_meta($this->ID, $key, true);
     if ($this->filter) {
         $value = btb_sanitize_event_field($key, $value, $this->ID, $this->filter);
     }
     return $value;
 }