query( $wpdb->prepare( "TRUNCATE TABLE %i", $chat_table ) ); echo '

' . esc_html__( 'All chat history logs cleared successfully.', 'ai-support-assistant' ) . '

'; } $items_per_page = 20; $total_items = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM %i", $chat_table ) ); $total_pages = ceil( $total_items / $items_per_page ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $current_page = isset( $_GET['paged'] ) ? max( 1, intval( $_GET['paged'] ) ) : 1; $offset = ( $current_page - 1 ) * $items_per_page; $logs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM %i ORDER BY created_at DESC LIMIT %d OFFSET %d", $chat_table, $items_per_page, $offset ) ); ?>
messages ) ) { $decoded_turns = json_decode( $log->messages, true ); if ( is_array( $decoded_turns ) ) { $turns_count = count( $decoded_turns ); } } ?>
session_id, 0, 12 ) ); ?>... 2 ) : ?>
question ); ?> provider ) ); ?> • model ); ?> updated_at ) ? $log->updated_at : $log->created_at ) ); ?>
add_query_arg( 'paged', '%#%' ), 'format' => '', 'prev_text' => __( '« Prev', 'ai-support-assistant' ), 'next_text' => __( 'Next »', 'ai-support-assistant' ), 'total' => $total_pages, 'current' => $current_page, ) ); if ( $page_links ) { echo '
' . wp_kses_post( $page_links ) . '
'; } ?>