insert( Database::table( 'logs' ), array( 'created_at' => current_time( 'mysql', true ), 'order_id' => absint( $data['order_id'] ?? 0 ), 'customer' => sanitize_text_field( $data['customer'] ?? '' ), 'template' => sanitize_text_field( $data['template'] ?? '' ), 'trigger_name' => sanitize_key( $data['trigger'] ?? '' ), 'status' => sanitize_key( $data['status'] ?? 'failed' ), 'response' => wp_json_encode( $data['response'] ?? array() ), 'retry_count' => absint( $data['retry_count'] ?? 0 ) ), array( '%s','%d','%s','%s','%s','%s','%s','%d' ) ); } public function recent( int $limit = 20 ) : array { global $wpdb; return $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . Database::table( 'logs' ) . ' ORDER BY id DESC LIMIT %d', $limit ) ); } }