function eventorganiser_uninstall_site()
{
    global $wpdb, $eventorganiser_roles, $wp_roles, $wp_taxonomies;
    eventorganiser_clear_cron_jobs();
    eventorganiser_create_event_taxonomies();
    //Remove 	custom taxonomies and terms.
    $taxs = array('event-category', 'event-venue', 'event-tag');
    $terms = get_terms($taxs, 'hide_empty=0');
    if ($terms) {
        foreach ($terms as $term) {
            $term_id = (int) $term->term_id;
            wp_delete_term($term_id, $term->taxonomy);
        }
    }
    //Remove all posts of CPT Event
    //?? $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'event'");
    //Delete options
    delete_option('eventorganiser_options');
    delete_option('eventorganiser_admin_notices');
    delete_option('eventorganiser_version');
    delete_option('eo_notice');
    delete_option('widget_eo_calendar_widget');
    delete_option('widget_eo_list_widget');
    //Remove Event Organiser capabilities
    $all_roles = $wp_roles->roles;
    foreach ($all_roles as $role_name => $display_name) {
        $role = $wp_roles->get_role($role_name);
        foreach ($eventorganiser_roles as $eo_role => $eo_role_display) {
            $role->remove_cap($eo_role);
        }
    }
    eventorganiser_clear_cron_jobs();
    //Drop tables
    $wpdb->query("DROP TABLE IF EXISTS {$wpdb->eo_events}");
    $eventorganiser_venue_table = $wpdb->prefix . "eo_venues";
    $wpdb->query("DROP TABLE IF EXISTS {$eventorganiser_venue_table}");
    $wpdb->query("DROP TABLE IF EXISTS {$wpdb->eo_venuemeta}");
    //Remove user-meta-data:
    $meta_keys = array('metaboxhidden_event', 'closedpostboxes_event', 'wp_event_page_venues_per_page', 'manageedit-eventcolumnshidden');
    $sql = $wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE ");
    foreach ($meta_keys as $key) {
        $sql .= $wpdb->prepare("meta_key = %s OR ", $key);
    }
    $sql .= " 1=0 ";
    //Deal with final 'OR', must be something false!
    $re = $wpdb->get_results($sql);
    flush_rewrite_rules();
}
 function validate($option)
 {
     /* Backwards compatibility: all EO options are in one row, but on seperate pages. Merge with existing options*/
     if (isset($option['tab'])) {
         $tab = $option['tab'];
         unset($option['tab']);
     } else {
         $tab = false;
     }
     $clean = array();
     switch ($tab) {
         case 'general':
             $checkboxes = array('showpast', 'templates', 'excludefromsearch', 'deleteexpired', 'feed', 'group_events', 'disable_css');
             $text = array('navtitle', 'dateformat', 'runningisnotpast', 'addtomenu');
             foreach ($checkboxes as $cb) {
                 //Empty checkboxes send no data..
                 $value = isset($option[$cb]) ? $option[$cb] : 0;
                 $clean[$cb] = $this->validate_checkbox($value);
             }
             foreach ($text as $txt) {
                 if (!isset($option[$txt])) {
                     continue;
                 }
                 $clean[$txt] = $this->validate_text($option[$txt]);
             }
             //Group events is handled differently
             $clean['group_events'] = !empty($clean['group_events']) ? 'series' : '';
             //Post type supports
             $clean['supports'] = isset($option['supports']) ? array_map('esc_html', $option['supports']) : array();
             $clean['supports'] = array_merge($clean['supports'], array('title', 'editor'));
             //Navigation menu - $addtomenu int 0 if no menu, menu databse ID otherwise
             $clean['menu_item_db_id'] = $this->update_nav_menu($clean['addtomenu'], $clean['navtitle']);
             if ($clean['deleteexpired'] && !eventorganiser_get_next_cron_time('eventorganiser_delete_expired')) {
                 eventorganiser_cron_jobs();
             } elseif (!$clean['deleteexpired']) {
                 eventorganiser_clear_cron_jobs();
             }
             break;
         case 'permalinks':
             $permalinks = array('url_event', 'url_events', 'url_venue', 'url_cat', 'url_tag', 'url_on');
             foreach ($permalinks as $permalink) {
                 if (!isset($option[$permalink])) {
                     continue;
                 }
                 $value = $this->validate_permalink($option[$permalink]);
                 if (!empty($value)) {
                     $clean[$permalink] = $value;
                 }
             }
             $clean['prettyurl'] = isset($option['prettyurl']) ? $this->validate_checkbox($option['prettyurl']) : 0;
             break;
         case 'permissions':
             //Permissions
             $permissions = isset($option['permissions']) ? $option['permissions'] : array();
             $this->update_roles($permissions);
             break;
         default:
             $keys = array('hide_addon_page');
             foreach ($keys as $key) {
                 if (!isset($option[$key])) {
                     continue;
                 }
                 $clean[$key] = (int) $option[$key];
             }
             break;
     }
     $existing_options = get_option('eventorganiser_options', array());
     $clean = array_merge($existing_options, $clean);
     return $clean;
 }