data_manager->get_chatbots(); // Get adjustments for the selected chatbot $selected_chatbot_id = isset($_GET['chatbot_id']) ? intval($_GET['chatbot_id']) : 0; $adjustments = array(); if ($selected_chatbot_id > 0) { $adjustments = $this->data_manager->get_adjustments($selected_chatbot_id); } // Handle form submission if (isset($_POST['a1ai_action']) && $_POST['a1ai_action'] === 'save_adjustment') { if (isset($_POST['a1ai_adjustment_nonce']) && wp_verify_nonce(sanitize_key(wp_unslash($_POST['a1ai_adjustment_nonce'])), 'a1ai_save_adjustment')) { $chatbot_id = isset($_POST['chatbot_id']) ? intval(wp_unslash($_POST['chatbot_id'])) : 0; $user_input = isset($_POST['user_input']) ? sanitize_textarea_field(wp_unslash($_POST['user_input'])) : ''; $ai_output = isset($_POST['ai_output']) ? sanitize_textarea_field(wp_unslash($_POST['ai_output'])) : ''; if ($chatbot_id > 0 && !empty($user_input) && !empty($ai_output)) { $result = $this->data_manager->add_adjustment($chatbot_id, $user_input, $ai_output); if ($result) { echo '
' . esc_html__('Adjustment saved successfully!', 'a1ai-chatbot') . '
' . esc_html__('Failed to save adjustment.', 'a1ai-chatbot') . '
' . esc_html__('Please fill in all required fields.', 'a1ai-chatbot') . '
' . esc_html__('Adjustment deleted successfully!', 'a1ai-chatbot') . '
' . esc_html__('Failed to delete adjustment.', 'a1ai-chatbot') . '
' . esc_html__('Adjustment updated successfully!', 'a1ai-chatbot') . '
' . esc_html__('Failed to update adjustment.', 'a1ai-chatbot') . '
' . esc_html__('Please fill in all required fields.', 'a1ai-chatbot') . '