public static function admin_controller() { global $wpdb; $tab = isset($_GET['tab']) ? $_GET['tab'] : 'list'; if ($tab == 'list') { self::list_emails_page(); $fue_table = $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}followup_emails'"); if ($fue_table != $wpdb->prefix . 'followup_emails' || false == get_option('fue_installed_tables', false)) { FollowUpEmails::update_db(true); } if (false === wp_next_scheduled('sfn_followup_emails')) { wp_schedule_event(time(), 'minute', 'sfn_followup_emails'); } if (false === wp_next_scheduled('sfn_optimize_tables')) { wp_schedule_event(time(), 'weekly', 'sfn_optimize_tables'); } } elseif ($tab == 'edit') { self::email_form(1, $_GET['id']); } elseif ($tab == 'send') { $id = $_GET['id']; $email = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}followup_emails` WHERE `id` = %d AND `email_type` = 'manual'", $id)); if (!$email) { wp_die("The requested data could not be found!"); } self::send_manual_form($email); } else { // allow add-ons to add tabs do_action('fue_admin_controller', $tab); } }