prefix . "communievents_events"; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id INT(1) NOT NULL, `group` INT(1) NOT NULL, title TEXT NOT NULL, location TEXT NOT NULL, description TEXT NOT NULL, start CHAR(19) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, end CHAR(19) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, allday BOOLEAN NOT NULL, official BOOLEAN NOT NULL, url TEXT NOT NULL, lastsync BIGINT(1) NOT NULL, PRIMARY KEY (id), KEY start_idx (start), KEY end_idx (end) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); communievents_setup_ical_feed(); // need to call it here for the rewrite flush flush_rewrite_rules(); if (!wp_next_scheduled('communievents_cron_hook')) { wp_schedule_event(time(), 'hourly', 'communievents_cron_hook'); } } register_activation_hook(__FILE__, 'communievents_install'); function communievents_uninstall() { global $wpdb; $table_name = $wpdb->prefix . "communievents_events"; $wpdb->query("DROP TABLE IF EXISTS $table_name"); flush_rewrite_rules(); $timestamp = wp_next_scheduled('communievents_cron_hook'); if ($timestamp) { wp_unschedule_event($timestamp, 'communievents_cron_hook'); } } register_deactivation_hook(__FILE__, 'communievents_uninstall'); /* INIT - register stuff * */ function communievents_init() { communievents_setup_ical_feed(); communievents_setup_event_list(); communievents_setup_event_calendar(); communievents_setup_cron_hook(); communievents_setup_healthcheck(); communievents_setup_admin_page(); } add_action('init', 'communievents_init');