' . esc_html__('Chatbot not found.', 'a1ai-chatbot') . ''; } // Get settings $settings = array(); if (is_string($chatbot['settings'])) { // Try to decode as JSON first $decoded = json_decode($chatbot['settings'], true); if (json_last_error() === JSON_ERROR_NONE) { $settings = $decoded; } else { // Fall back to unserialize if JSON fails $settings = maybe_unserialize($chatbot['settings']); } } elseif (is_array($chatbot['settings'])) { // Settings is already an array $settings = $chatbot['settings']; } $chatbot_name = isset($settings['name']) ? sanitize_text_field($settings['name']) : __('AI Assistant', 'a1ai-chatbot'); $chatbot_title = isset($settings['chatbot_title']) ? sanitize_text_field($settings['chatbot_title']) : __('Chat Support', 'a1ai-chatbot'); $welcome_message = isset($settings['welcome_message']) ? wp_kses_post($settings['welcome_message']) : __('Hello! How can I help you today?', 'a1ai-chatbot'); $placeholder_text = isset($settings['placeholder']) ? sanitize_text_field($settings['placeholder']) : __('Type your message here...', 'a1ai-chatbot'); $primary_color = isset($settings['primary_color']) ? sanitize_hex_color($settings['primary_color']) : '#0073aa'; $chatbot_width = isset($settings['chat_width']) ? sanitize_text_field($settings['chat_width']) : '350px'; $chatbot_height = isset($settings['chat_height']) ? sanitize_text_field($settings['chat_height']) : '500px'; $font_size = isset($settings['font_size']) ? sanitize_text_field($settings['font_size']) : 'medium'; // GDPR settings $gdpr_enabled = isset($settings['gdpr_enabled']) && $settings['gdpr_enabled'] ? true : false; $gdpr_consent_text = isset($settings['gdpr_consent_text']) ? wp_kses_post($settings['gdpr_consent_text']) : __('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.', 'a1ai-chatbot'); // Debug output for GDPR settings if (defined('WP_DEBUG') && WP_DEBUG) { echo ''; } // Voice input: per-chatbot override; default on when upgrade active or global voice enabled $upgrade_settings = get_option('a1ai_upgrade_settings', array()); $upgrade_active_voice = class_exists('A1AI_Upgrade_Helper') && A1AI_Upgrade_Helper::is_upgrade_active(); $global_voice_enabled = isset($upgrade_settings['voice_input_settings']['enabled']) ? !empty($upgrade_settings['voice_input_settings']['enabled']) : $upgrade_active_voice; if (isset($settings['voice_enabled'])) { $voice_enabled = ( !empty($settings['voice_enabled']) || $settings['voice_enabled'] === true ) ? '1' : '0'; } else { $voice_enabled = $global_voice_enabled ? '1' : '0'; } $voice_language = !empty($settings['voice_language']) ? sanitize_text_field($settings['voice_language']) : ( isset($upgrade_settings['voice_input_settings']['language']) ? $upgrade_settings['voice_input_settings']['language'] : 'en-US' ); // Review chatbot: needed for container class so chat input is hidden on load $upgrade_active = class_exists('A1AI_Upgrade_Helper') && A1AI_Upgrade_Helper::is_upgrade_active(); $review_chatbot_id = get_option('a1ai_review_chatbot_id', 0); $is_review_chatbot = ($chatbot_id == $review_chatbot_id && $review_chatbot_id > 0); // Generate unique container ID $container_id = 'a1ai-chatbot-' . $chatbot_id . '-' . wp_rand(); ?>