/**
* Sanitize every venue field.
*
* If the context is 'raw', then the venue object or array will get minimal
* sanitization of the integer fields.
*
* @since 1.0.0
*
* @see btb_sanitize_venue_field($field, $value, $venue_id, $context = 'display')
*
* @param object|BTB_Event|array	$venue		The venue object or array.
* @param string					$context	Optional. How to sanitize the venue 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_venue($venue, $context = 'display')
{
    if (is_object($venue)) {
        // Check if venue already filtered for this context.
        if (isset($venue->filter) && $context == $venue->filter) {
            return $venue;
        }
        if (!isset($venue->ID)) {
            $venue->ID = 0;
        }
        foreach (array_keys(get_object_vars($venue)) as $field) {
            $venue->{$field} = btb_sanitize_venue_field($field, $venue->{$field}, $venue->ID, $context);
        }
        $venue->filter = $context;
    } elseif (is_array($venue)) {
        // Check if venue already filtered for this context.
        if (isset($venue['filter']) && $context == $venue['filter']) {
            return $venue;
        }
        if (!isset($venue['ID'])) {
            $venue['ID'] = 0;
        }
        foreach (array_keys($venue) as $field) {
            $venue[$field] = btb_sanitize_venue_field($field, $venue[$field], $venue['ID'], $context);
        }
        $venue['filter'] = $context;
    }
    return $venue;
}
 /**
  * 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->code;
     }
     if ('post_type' == $key) {
         return 'btb_venue';
     }
     if ('post_parent' == $key) {
         return 0;
     }
     $value = get_post_meta($this->ID, $key, true);
     if ($this->filter) {
         $value = btb_sanitize_venue_field($key, $value, $this->ID, $this->filter);
     }
     return $value;
 }