static function add_defaults() { global $wpdb; $status_table = Kanban_Status::table_name(); $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$status_table}`\n\t\t;"; $status_count = $wpdb->get_var($sql); if ($status_count == 0) { $statuses = array('Backlog' => '#8224e3', 'Ready' => '#eeee22', 'In progress' => '#81d742', 'QA' => '#f7a738', 'Done' => '#1e73be', 'Archive' => '#333333'); $i = 0; foreach ($statuses as $status => $color) { $data = array('title' => $status, 'color_hex' => $color, 'position' => $i); Kanban_Status::replace($data); $i++; } } $estimate_table = Kanban_Estimate::table_name(); $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$estimate_table}`\n\t\t;"; $estimate_count = $wpdb->get_var($sql); if ($estimate_count == 0) { $estimates = array('2' => '2h', '4' => '4h', '8' => '1d', '16' => '2d', '32' => '4d'); $i = 0; foreach ($estimates as $hours => $title) { $data = array('title' => $title, 'hours' => $hours, 'position' => $i); Kanban_Estimate::replace($data); $i++; } } $boards_table = Kanban_Board::table_name(); $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$boards_table}`\n\t\t;"; $boards_count = $wpdb->get_var($sql); if ($boards_count == 0) { $data = array('title' => 'Your first kanban board', 'created_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'modified_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'user_id_author' => get_current_user_id(), 'is_active' => 1); Kanban_Board::replace($data); } $tasks_table = Kanban_Board::table_name(); $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$tasks_table}`\n\t\t;"; $tasks_count = $wpdb->get_var($sql); if ($tasks_count == 0) { $sql = "SELECT `id`\n\t\t\t\t\tFROM `{$boards_table}`\n\t\t\t\t\tLIMIT 1\n\t\t\t;"; $board_id = $wpdb->get_var($sql); $data = array('title' => 'Your first task', 'board_id' => $board_id, 'created_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'modified_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'user_id_author' => get_current_user_id(), 'is_active' => 1); Kanban_Board::replace($data); } $options_table = Kanban_Option::table_name(); $sql = "SELECT *\n\t\t\t\tFROM `{$options_table}`\n\t\t;"; $options = $wpdb->get_results($sql); $options_arr = array(); foreach ($options as $option) { $options_arr[$option->name] = $option->value; } $defaults = Kanban_Option::get_defaults(); foreach ($defaults as $name => $value) { if (isset($options_arr[$name])) { continue; } $data = array('name' => $name, 'value' => $value); Kanban_Option::replace($data); } }