*/ class A1AI_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * The data manager instance. * * @since 1.0.0 * @access private * @var A1AI_Data_Manager $data_manager Handles database operations. */ private $data_manager; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param A1AI_Data_Manager $data_manager The data manager instance. */ public function __construct($plugin_name = 'a1ai', $version = '1.3.0', $data_manager = null) { $this->plugin_name = $plugin_name; $this->version = $version; $this->data_manager = $data_manager; // If data manager wasn't passed, create one if (null === $this->data_manager) { require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-a1ai-data-manager.php'; $this->data_manager = new A1AI_Data_Manager(); } } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles($hook) { // Only load on our plugin pages if (!$this->is_plugin_page($hook)) { return; } wp_enqueue_style( 'a1ai-admin', plugin_dir_url(__FILE__) . 'css/a1ai-admin.css', array(), $this->version, 'all' ); // Enqueue adjustments-specific styles // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Used only for style enqueuing, not form processing if (strpos($hook, 'a1ai') !== false && isset($_GET['page']) && sanitize_text_field(wp_unslash($_GET['page'])) === 'a1ai-chatbots') { wp_enqueue_style( 'a1ai-admin-adjustments', plugin_dir_url(__FILE__) . 'css/a1ai-admin-adjustments.css', array('a1ai-admin'), $this->version, 'all' ); } // phpcs:enable WordPress.Security.NonceVerification.Recommended } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts($hook) { // Only load on our plugin pages if (!$this->is_plugin_page($hook)) { return; } // Enqueue Chart.js if needed on dashboard if (strpos($hook, 'page_a1ai') !== false) { wp_enqueue_script( 'a1ai-chartjs', plugin_dir_url(dirname(__FILE__)) . 'assets/js/chart.min.js', array(), '4.4.2', true ); } wp_enqueue_script( 'a1ai-admin', plugin_dir_url(__FILE__) . 'js/a1ai-admin.js', array('jquery', 'a1ai-chartjs'), $this->version, true ); // Enqueue page-specific scripts if (strpos($hook, 'a1ai') !== false) { // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Used only for script enqueuing, not form processing // Chatbots page (includes adjustments tab) if (isset($_GET['page']) && sanitize_text_field(wp_unslash($_GET['page'])) === 'a1ai-chatbots') { wp_enqueue_script( 'a1ai-admin-chatbots', plugin_dir_url(__FILE__) . 'js/a1ai-admin-chatbots.js', array('jquery', 'a1ai-admin'), $this->version, true ); wp_enqueue_script( 'a1ai-admin-adjustments', plugin_dir_url(__FILE__) . 'js/a1ai-admin-adjustments.js', array('jquery', 'a1ai-admin'), $this->version, true ); } // Chatbot edit page if (isset($_GET['page']) && sanitize_text_field(wp_unslash($_GET['page'])) === 'a1ai-chatbots' && isset($_GET['action']) && sanitize_text_field(wp_unslash($_GET['action'])) === 'edit') { wp_enqueue_script( 'a1ai-admin-chatbot-edit', plugin_dir_url(__FILE__) . 'js/a1ai-admin-chatbot-edit.js', array('jquery', 'a1ai-admin'), $this->version, true ); } // phpcs:enable WordPress.Security.NonceVerification.Recommended } // Localize script with necessary data and nonce wp_localize_script( 'a1ai-admin', 'a1aichAdmin', array( 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('a1ai_admin_nonce'), 'copiedText' => esc_html__('Copied!', 'a1ai-chatbot'), 'defaultGdprText' => esc_html__('By clicking "I Agree", you consent to the use of AI-powered chat services and acknowledge that your conversations may be processed to provide you with assistance. You can withdraw your consent at any time by closing this chat.', 'a1ai-chatbot'), 'strings' => array( 'saveSuccess' => esc_html__('Settings saved successfully.', 'a1ai-chatbot'), 'saveError' => esc_html__('Error saving settings.', 'a1ai-chatbot'), 'deleteSuccess' => esc_html__('Chatbot deleted successfully.', 'a1ai-chatbot'), 'deleteError' => esc_html__('Error deleting chatbot.', 'a1ai-chatbot'), 'confirmDelete' => esc_html__('Are you sure you want to delete this chatbot? This action cannot be undone.', 'a1ai-chatbot'), ) ) ); } /** * Check if current page is a plugin page. * * @since 1.0.0 * @param string $hook Current admin page. * @return bool True if it's a plugin page. */ private function is_plugin_page($hook) { $plugin_pages = array( 'toplevel_page_a1ai', 'a1ai_page_a1ai-chatbots', 'a1ai_page_a1ai-settings', ); return in_array($hook, $plugin_pages) || strpos($hook, 'a1ai') !== false; } /** * Register the admin menu. * * @since 1.0.0 */ public function register_admin_menu() { // Main menu add_menu_page( __('A1AI Chatbot', 'a1ai-chatbot'), __('A1AI Chatbot', 'a1ai-chatbot'), 'manage_options', 'a1ai', array($this, 'render_dashboard_page'), 'dashicons-format-chat', 30 ); // Submenu - Dashboard add_submenu_page( 'a1ai', __('Dashboard', 'a1ai-chatbot'), __('Dashboard', 'a1ai-chatbot'), 'manage_options', 'a1ai', array($this, 'render_dashboard_page') ); // Submenu - Chatbots add_submenu_page( 'a1ai', __('Chatbots', 'a1ai-chatbot'), __('Chatbots', 'a1ai-chatbot'), 'manage_options', 'a1ai-chatbots', array($this, 'render_chatbots_page') ); // Submenu - Settings add_submenu_page( 'a1ai', __('Settings', 'a1ai-chatbot'), __('Settings', 'a1ai-chatbot'), 'manage_options', 'a1ai-settings', array($this, 'render_settings_page') ); } /** * Add settings link to plugin list. * * @since 1.0.0 * @param array $links Existing plugin action links. * @return array Modified plugin action links. */ public function add_settings_link($links) { $settings_link = '' . __('Settings', 'a1ai-chatbot') . ''; array_unshift($links, $settings_link); return $links; } /** * Render the dashboard page. * * @since 1.0.0 */ public function render_dashboard_page() { require_once plugin_dir_path(__FILE__) . 'partials/a1ai-admin-dashboard.php'; } /** * Render the chatbots page. * * @since 1.0.0 */ public function render_chatbots_page() { // Verify nonce if action is present if (isset($_GET['action']) && in_array($_GET['action'], array('edit', 'delete'))) { if (!isset($_GET['_wpnonce']) || !wp_verify_nonce(sanitize_key($_GET['_wpnonce']), 'a1ai_chatbot_action')) { wp_die(esc_html__('Security check failed.', 'a1ai-chatbot')); } } $action = isset($_GET['action']) ? sanitize_text_field(wp_unslash($_GET['action'])) : ''; if ('add' === $action || 'edit' === $action) { require_once plugin_dir_path(__FILE__) . 'partials/a1ai-admin-chatbot-edit.php'; } else { require_once plugin_dir_path(__FILE__) . 'partials/a1ai-admin-chatbots.php'; } } /** * Render the settings page. * * @since 1.0.0 */ public function render_settings_page() { require_once plugin_dir_path(__FILE__) . 'partials/a1ai-admin-settings.php'; } /** * Handle admin AJAX requests. * * @since 1.0.0 */ public function handle_admin_ajax() { // Check nonce if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_key($_POST['nonce']), 'a1ai_admin_nonce')) { wp_send_json_error(array('message' => __('Security check failed.', 'a1ai-chatbot'))); } // Check capabilities if (!current_user_can('manage_options')) { wp_send_json_error(array('message' => __('You do not have sufficient permissions.', 'a1ai-chatbot'))); } // Handle different actions $action_type = isset($_POST['action_type']) ? sanitize_text_field(wp_unslash($_POST['action_type'])) : ''; switch ($action_type) { case 'save_settings': $this->save_settings(); break; case 'save_chatbot': $this->save_chatbot(); break; case 'delete_chatbot': $this->delete_chatbot(); break; case 'get_analytics': $this->get_analytics(); break; case 'get_conversation': $this->get_conversation(); break; case 'delete_conversation': $this->delete_conversation(); break; case 'save_adjustment': $this->save_adjustment(); break; case 'delete_adjustment': $this->delete_adjustment(); break; default: wp_send_json_error(array('message' => __('Invalid action.', 'a1ai-chatbot'))); break; } } /** * Save plugin settings. * * @since 1.0.0 */ private function save_settings() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() // General settings if (isset($_POST['a1ai_openai_api_key'])) { update_option('a1ai_openai_api_key', sanitize_text_field(wp_unslash($_POST['a1ai_openai_api_key']))); } // AI Settings if (isset($_POST['a1ai_default_model'])) { update_option('a1ai_default_model', sanitize_text_field(wp_unslash($_POST['a1ai_default_model']))); } if (isset($_POST['a1ai_default_temperature'])) { $temperature = min(max(0, floatval($_POST['a1ai_default_temperature'])), 2); update_option('a1ai_default_temperature', $temperature); } if (isset($_POST['a1ai_default_max_tokens'])) { $max_tokens = min(max(100, intval($_POST['a1ai_default_max_tokens'])), 4000); update_option('a1ai_default_max_tokens', $max_tokens); } // Global Chatbot Settings $global_enabled = isset($_POST['a1ai_global_chatbot_enabled']) ? (bool) $_POST['a1ai_global_chatbot_enabled'] : false; update_option('a1ai_global_chatbot_enabled', $global_enabled); if (isset($_POST['a1ai_global_chatbot_id'])) { update_option('a1ai_global_chatbot_id', intval($_POST['a1ai_global_chatbot_id'])); } if (isset($_POST['a1ai_global_chatbot_position'])) { update_option('a1ai_global_chatbot_position', sanitize_text_field(wp_unslash($_POST['a1ai_global_chatbot_position']))); } // Advanced Settings $keep_history = isset($_POST['a1ai_keep_conversation_history']) ? (bool) $_POST['a1ai_keep_conversation_history'] : false; update_option('a1ai_keep_conversation_history', $keep_history); if (isset($_POST['a1ai_conversation_retention_days'])) { $retention_days = min(max(1, intval($_POST['a1ai_conversation_retention_days'])), 365); update_option('a1ai_conversation_retention_days', $retention_days); } $keep_data = isset($_POST['a1ai_keep_data_on_uninstall']) ? (bool) $_POST['a1ai_keep_data_on_uninstall'] : false; update_option('a1ai_keep_data_on_uninstall', $keep_data); $show_powered_by = isset($_POST['a1ai_show_powered_by']) ? (bool) $_POST['a1ai_show_powered_by'] : false; update_option('a1ai_show_powered_by', $show_powered_by); // phpcs:enable WordPress.Security.NonceVerification.Missing wp_send_json_success(array('message' => __('Settings saved successfully.', 'a1ai-chatbot'))); } /** * Save chatbot data. * * @since 1.0.0 */ private function save_chatbot() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() // Get chatbot ID and name $chatbot_id = isset($_POST['chatbot_id']) ? intval($_POST['chatbot_id']) : 0; $chatbot_name = isset($_POST['chatbot_name']) ? sanitize_text_field(wp_unslash($_POST['chatbot_name'])) : ''; // Validate required fields if (empty($chatbot_name)) { wp_send_json_error(array('message' => __('Chatbot name is required.', 'a1ai-chatbot'))); } // Get and sanitize settings array $raw_settings = array(); if (isset($_POST['settings']) && is_array($_POST['settings'])) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $raw_settings = wp_kses_post_deep(wp_unslash($_POST['settings'])); } $settings = $this->sanitize_settings($raw_settings); // Save chatbot $result = $this->data_manager->save_chatbot($chatbot_id, $chatbot_name, $settings); // Save system prompt and custom instructions to dedicated tables if ($result !== false) { $final_chatbot_id = $chatbot_id > 0 ? $chatbot_id : $result; // Handle system prompt - save if provided, deactivate if empty if (!empty($settings['system_prompt'])) { $this->data_manager->save_custom_instruction( $final_chatbot_id, 'System Prompt', $settings['system_prompt'], 'system', 0 ); } else { // Deactivate existing system prompt if none provided $existing_system_instructions = $this->data_manager->get_custom_instructions($final_chatbot_id, 'system'); if (!empty($existing_system_instructions)) { foreach ($existing_system_instructions as $instruction) { if ($instruction['instruction_name'] === 'System Prompt') { $this->data_manager->update_custom_instruction($instruction['id'], array('is_active' => 0)); break; } } } } // Save custom instructions if provided if (!empty($settings['custom_instructions'])) { $this->data_manager->save_custom_instruction( $final_chatbot_id, 'Custom Instructions', $settings['custom_instructions'], 'general', 1 ); } else { // Clear existing custom instructions if none provided $existing_instructions = $this->data_manager->get_custom_instructions($final_chatbot_id); if (!empty($existing_instructions)) { foreach ($existing_instructions as $instruction) { // Only deactivate general instructions, keep system prompt if ($instruction['instruction_type'] !== 'system') { $this->data_manager->update_custom_instruction($instruction['id'], array('is_active' => 0)); } } } } } if ($result === false) { wp_send_json_error(array('message' => __('Error saving chatbot.', 'a1ai-chatbot'))); } $success_message = $chatbot_id > 0 ? __('Chatbot updated successfully.', 'a1ai-chatbot') : __('Chatbot created successfully.', 'a1ai-chatbot'); $response_data = array('message' => $success_message); // If this is a new chatbot, add the redirect URL to the edit page if ($chatbot_id === 0) { $edit_url = add_query_arg( array( 'page' => 'a1ai-chatbots', 'action' => 'edit', 'id' => $result, '_wpnonce' => wp_create_nonce('a1ai_chatbot_action') ), admin_url('admin.php') ); $response_data['redirect'] = $edit_url; } // phpcs:enable WordPress.Security.NonceVerification.Missing wp_send_json_success($response_data); } /** * Delete a chatbot. * * @since 1.0.0 */ private function delete_chatbot() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() $chatbot_id = isset($_POST['chatbot_id']) ? intval($_POST['chatbot_id']) : 0; if ($chatbot_id <= 0) { wp_send_json_error(array('message' => __('Invalid chatbot ID.', 'a1ai-chatbot'))); } // Check if this is the global chatbot $global_chatbot_id = get_option('a1ai_global_chatbot_id', 0); if ($global_chatbot_id == $chatbot_id) { update_option('a1ai_global_chatbot_id', 0); update_option('a1ai_global_chatbot_enabled', false); } $result = $this->data_manager->delete_chatbot($chatbot_id); // phpcs:enable WordPress.Security.NonceVerification.Missing if ($result) { wp_send_json_success(array('message' => __('Chatbot deleted successfully.', 'a1ai-chatbot'))); } else { wp_send_json_error(array('message' => __('Error deleting chatbot.', 'a1ai-chatbot'))); } } /** * Get analytics data for charts. * * @since 1.0.0 */ private function get_analytics() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() $period = isset($_POST['period']) ? sanitize_text_field(wp_unslash($_POST['period'])) : 'month'; $valid_periods = array('day', 'week', 'month', 'year'); if (!in_array($period, $valid_periods)) { $period = 'month'; } $stats = $this->data_manager->get_usage_stats($period); // Format data for Chart.js $labels = array(); $messages_data = array(); $conversations_data = array(); // Process message counts foreach ($stats['messages'] as $message) { $labels[] = $message['date']; $messages_data[] = intval($message['count']); } // Process conversation counts // Create conversation data array with same labels foreach ($labels as $label) { $count = 0; // Find matching conversation count foreach ($stats['conversations'] as $conversation) { if ($conversation['date'] === $label) { $count = intval($conversation['count']); break; } } $conversations_data[] = $count; } $chart_data = array( 'labels' => $labels, 'messages' => $messages_data, 'conversations' => $conversations_data, 'totals' => $stats['totals'], ); // phpcs:enable WordPress.Security.NonceVerification.Missing wp_send_json_success($chart_data); } /** * Sanitize settings array. * * @since 1.0.0 * @param array $settings The settings array to sanitize. * @return array The sanitized settings array. */ private function sanitize_settings($settings) { if (!is_array($settings)) { return array(); } $sanitized_settings = array(); // Text fields $text_fields = array('chat_bubble_text', 'chatbot_title', 'welcome_message', 'chat_width', 'chat_height', 'primary_color', 'font_size', 'model', 'placeholder'); foreach ($text_fields as $field) { $sanitized_settings[$field] = isset($settings[$field]) ? sanitize_text_field(wp_unslash($settings[$field])) : ''; } // Email field with validation if (isset($settings['notification_email']) && !empty($settings['notification_email'])) { $email = sanitize_email(wp_unslash($settings['notification_email'])); if (is_email($email)) { $sanitized_settings['notification_email'] = $email; } else { $sanitized_settings['notification_email'] = ''; } } else { $sanitized_settings['notification_email'] = ''; } // Textarea fields $textarea_fields = array('system_prompt', 'custom_instructions', 'gdpr_consent_text'); foreach ($textarea_fields as $field) { $sanitized_settings[$field] = isset($settings[$field]) ? sanitize_textarea_field(wp_unslash($settings[$field])) : ''; } // Boolean fields - explicitly set to true only if value is "1" $sanitized_settings['gdpr_enabled'] = (isset($settings['gdpr_enabled']) && $settings['gdpr_enabled'] === "1") ? true : false; // Numeric fields $sanitized_settings['temperature'] = isset($settings['temperature']) ? min(max(0, floatval($settings['temperature'])), 2) : 0.7; $sanitized_settings['max_tokens'] = isset($settings['max_tokens']) ? min(max(100, intval($settings['max_tokens'])), 4000) : 1000; return $sanitized_settings; } /** * Get conversation details for admin view. * * @since 1.0.0 */ private function get_conversation() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() $conversation_id = isset($_POST['conversation_id']) ? intval($_POST['conversation_id']) : 0; if ($conversation_id <= 0) { wp_send_json_error(array('message' => __('Invalid conversation ID.', 'a1ai-chatbot'))); } // Get conversation details $conversation = $this->data_manager->get_conversation($conversation_id); if (empty($conversation)) { wp_send_json_error(array('message' => __('Conversation not found.', 'a1ai-chatbot'))); } // Get messages for this conversation $messages = $this->data_manager->get_messages($conversation_id); // Get chatbot name $chatbot = $this->data_manager->get_chatbot($conversation['chatbot_id']); $chatbot_name = $chatbot ? $chatbot['name'] : __('Unknown Chatbot', 'a1ai-chatbot'); // Get user name $user_name = __('Guest', 'a1ai-chatbot'); if ($conversation['user_id'] > 0) { $user = get_user_by('id', $conversation['user_id']); if ($user) { $user_name = $user->display_name; } } // Add additional info to conversation $conversation['chatbot_name'] = $chatbot_name; $conversation['user_name'] = $user_name; $response_data = array( 'conversation' => $conversation, 'messages' => $messages, ); // phpcs:enable WordPress.Security.NonceVerification.Missing wp_send_json_success($response_data); } /** * Delete a conversation. * * @since 1.0.0 */ private function delete_conversation() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() $conversation_id = isset($_POST['conversation_id']) ? intval($_POST['conversation_id']) : 0; if ($conversation_id <= 0) { wp_send_json_error(array('message' => __('Invalid conversation ID.', 'a1ai-chatbot'))); } // Get conversation to verify it exists $conversation = $this->data_manager->get_conversation($conversation_id); if (empty($conversation)) { wp_send_json_error(array('message' => __('Conversation not found.', 'a1ai-chatbot'))); } // Delete messages first (foreign key constraint) $deleted_messages = $this->data_manager->delete_messages_by_conversation($conversation_id); // Delete conversation $deleted_conversation = $this->data_manager->delete_conversation($conversation_id); if (false === $deleted_conversation) { wp_send_json_error(array('message' => __('Failed to delete conversation.', 'a1ai-chatbot'))); } // phpcs:enable WordPress.Security.NonceVerification.Missing wp_send_json_success(array('message' => __('Conversation deleted successfully.', 'a1ai-chatbot'))); } /** * Save adjustment. * * @since 1.0.0 */ private function save_adjustment() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() $chatbot_id = isset($_POST['chatbot_id']) ? intval($_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'])) : ''; $ui_match_type = isset($_POST['ui_match_type']) ? sanitize_text_field(wp_unslash($_POST['ui_match_type'])) : 'Broad'; $ai_match_type = isset($_POST['ai_match_type']) ? sanitize_text_field(wp_unslash($_POST['ai_match_type'])) : 'Broad'; if ($chatbot_id <= 0) { wp_send_json_error(array('message' => __('Invalid chatbot ID.', 'a1ai-chatbot'))); } if (empty($user_input) || empty($ai_output)) { wp_send_json_error(array('message' => __('User input and AI output are required.', 'a1ai-chatbot'))); } // Validate match types $valid_match_types = array('Flexible', 'Broad', 'Phrase', 'Exact'); if (!in_array($ui_match_type, $valid_match_types, true)) { $ui_match_type = 'Broad'; } if (!in_array($ai_match_type, $valid_match_types, true)) { $ai_match_type = 'Broad'; } // Save adjustment $result = $this->data_manager->add_adjustment($chatbot_id, $user_input, $ai_output, $ui_match_type, $ai_match_type); if (false === $result) { wp_send_json_error(array('message' => __('Failed to save adjustment.', 'a1ai-chatbot'))); } // phpcs:enable WordPress.Security.NonceVerification.Missing wp_send_json_success(array( 'message' => __('Adjustment saved successfully.', 'a1ai-chatbot'), 'adjustment_id' => $result )); } /** * Delete adjustment. * * @since 1.0.0 */ private function delete_adjustment() { // Nonce and capabilities already verified in handle_admin_ajax() // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in handle_admin_ajax() $adjustment_id = isset($_POST['adjustment_id']) ? intval($_POST['adjustment_id']) : 0; if ($adjustment_id <= 0) { wp_send_json_error(array('message' => __('Invalid adjustment ID.', 'a1ai-chatbot'))); } // Get adjustment to verify it exists $adjustment = $this->data_manager->get_adjustment($adjustment_id); if (empty($adjustment)) { wp_send_json_error(array('message' => __('Adjustment not found.', 'a1ai-chatbot'))); } // Delete adjustment $result = $this->data_manager->delete_adjustment($adjustment_id); if (false === $result) { wp_send_json_error(array('message' => __('Failed to delete adjustment.', 'a1ai-chatbot'))); } // phpcs:enable WordPress.Security.NonceVerification.Missing wp_send_json_success(array('message' => __('Adjustment deleted successfully.', 'a1ai-chatbot'))); } }