get_col("SELECT status_key FROM {$table}"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL if (!is_array($exists)) { $exists = []; } $sort = 0; foreach ($seeds as [$key, $label, $color, $is_closed, $is_default]) { if (in_array($key, $exists, true)) { continue; } $wpdb->insert($table, [ 'status_key' => $key, 'name' => $label, 'color' => $color, 'is_closed' => $is_closed, 'is_default' => $is_default, 'sort_order' => $sort++, 'created_at' => $now, ], ['%s', '%s', '%s', '%d', '%d', '%d', '%s']); } } /** 工单部门 seeds:按 name 幂等补齐。 */ private static function seed_ticket_types(string $prefix): void { global $wpdb; $table = $prefix . 'aksrt_ticket_type'; $now = current_time('mysql'); $seeds = ['技术支持', '账号问题', '财务问题', '产品建议', '其他']; $exists = $wpdb->get_col("SELECT name FROM {$table}"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL if (!is_array($exists)) { $exists = []; } $sort = 0; foreach ($seeds as $label) { if (in_array($label, $exists, true)) { continue; } $wpdb->insert($table, [ 'name' => $label, 'sort_order' => $sort++, 'created_at' => $now, ], ['%s', '%d', '%s']); } } }