$implied_read ) {
$scope_implied_by[ $implied_read ][] = $write_scope;
}
$all_scope_keys = AICOM_Auth::scope_slugs();
// ── System presets ─────────────────────────────────────────────────────────
$presets = AICOM_Admin::system_presets();
// ── Working Hours helper ───────────────────────────────────────────────────
// Renders the same field group in both Generate and Edit forms. Site uses the
// short day labels from Safety; we mirror them here so the UI feels familiar.
$day_labels = [
0 => __( 'Sun', 'aicom' ),
1 => __( 'Mon', 'aicom' ),
2 => __( 'Tue', 'aicom' ),
3 => __( 'Wed', 'aicom' ),
4 => __( 'Thu', 'aicom' ),
5 => __( 'Fri', 'aicom' ),
6 => __( 'Sat', 'aicom' ),
];
$render_working_hours = function ( bool $enabled, array $days, string $start, string $end ) use ( $day_labels ) {
?>
get_results(
// phpcs:ignore WordPress.DB.DirectDatabaseQuery
"SELECT id, name, scopes_json FROM {$wpdb->prefix}aicom_presets ORDER BY created_at ASC",
ARRAY_A
) ?: [];
// ── Edit mode ─────────────────────────────────────────────────────────────
$edit_key_id = ( isset( $_GET['action'], $_GET['key_id'] ) && $_GET['action'] === 'edit_key' )
? absint( wp_unslash( $_GET['key_id'] ) ) : 0;
$edit_key = $edit_key_id
? $wpdb->get_row( $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}aicom_api_keys WHERE id = %d", $edit_key_id
), ARRAY_A )
: null;
$show_archived = ! empty( $_GET['show_archived'] );
$archived_sql = $show_archived ? '' : "AND status != 'archived'";
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$keys = $wpdb->get_results(
"SELECT id, label, key_prefix, scopes_json, restrictions_json, status, last_used_at, created_at, expires_at FROM {$wpdb->prefix}aicom_api_keys WHERE 1=1 $archived_sql ORDER BY created_at DESC",
ARRAY_A
);
?>
0 ) : ?>