'any', 'post_status' => 'publish', 'posts_per_page' => 1]); $post_id = !empty($fallback) ? $fallback[0]->ID : 0; } $chatbot_name = get_option('aiutoma_chatbot_name', 'AI Bot'); if (empty($chatbot_name)) { $chatbot_name = 'AI Bot'; } $chatbot_name = apply_filters('wpml_translate_single_string', $chatbot_name, 'aiutoma', 'chatbot_name'); $current_user = wp_get_current_user(); $user_name = $current_user->exists() ? $current_user->display_name : ''; wp_localize_script('aiutoma-chatbot-script', 'aiutomaChatbotData', [ 'rest_url' => esc_url_raw(rest_url('aiutoma/v1/chatbot')), 'nonce' => wp_create_nonce('wp_rest'), 'debugMode' => (defined('WP_DEBUG') && WP_DEBUG), 'resetConfirm' => __('Are you sure you want to start a new chat?', 'aiutoma'), 'post_id' => $post_id, 'chatbotName' => esc_html($chatbot_name), 'userName' => esc_html($user_name) ]); } public function render_chatbot() { if (is_admin()) return; if (wp_is_json_request()) return; if (isset($_REQUEST['context']) && $_REQUEST['context'] === 'edit') return; if (isset($_REQUEST['elementor-preview']) && $_REQUEST['elementor-preview']) return; if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'elementor') return; if (!get_option('aiutoma_chatbot_enabled', 1)) return; $icon = esc_attr(get_option('aiutoma_chatbot_icon', 'dashicons-format-chat')); $color = esc_attr(get_option('aiutoma_chatbot_color', '#2271b1')); $position = get_option('aiutoma_chatbot_position', 'bottom-right'); $chatbot_name = get_option('aiutoma_chatbot_name', ''); $chatbot_name = apply_filters('wpml_translate_single_string', $chatbot_name, 'aiutoma', 'chatbot_name'); $chatbot_name = esc_html($chatbot_name); $show_ai_badge = get_option('aiutoma_chatbot_show_ai_badge', 1); $default_greeting = __('Hello! I am an AI assistant for this website. How can I help you today?', 'aiutoma'); $greeting = get_option('aiutoma_chatbot_greeting', $default_greeting); $greeting = apply_filters('wpml_translate_single_string', $greeting, 'aiutoma', 'chatbot_greeting'); $greeting = esc_html($greeting); $default_disclaimer = __('AI assistant • Responses may contain inaccuracies.', 'aiutoma'); $disclaimer = get_option('aiutoma_chatbot_disclaimer_text', $default_disclaimer); $disclaimer = apply_filters('wpml_translate_single_string', $disclaimer, 'aiutoma', 'chatbot_disclaimer_text'); $show_privacy_link = get_option('aiutoma_chatbot_show_privacy_link', 1); $privacy_url = ($show_privacy_link && function_exists('get_privacy_policy_url')) ? get_privacy_policy_url() : ''; $pos_class = $position === 'bottom-left' ? 'aiutoma-pos-bottom-left' : 'aiutoma-pos-bottom-right'; ?>
' . esc_html__('Privacy Policy', 'aiutoma') . '' : esc_html__('Privacy Policy', 'aiutoma'); $default_gdpr_text = sprintf( /* translators: %s: Privacy Policy link */ __('I agree to the processing of conversation data in accordance with the %s.', 'aiutoma'), $privacy_link_html ); $custom_gdpr_text = get_option('aiutoma_chatbot_gdpr_text', ''); if (empty($custom_gdpr_text) || $custom_gdpr_text === 'By chatting, you agree to our processing of conversation logs to assist with your request.' || $custom_gdpr_text === 'By chatting, you agree to our processing of conversation logs to assist with your request. See our Privacy for your data rights.') { $gdpr_text = $default_gdpr_text; } else { $gdpr_text = apply_filters('wpml_translate_single_string', $custom_gdpr_text, 'aiutoma', 'chatbot_gdpr_text'); if (!empty($privacy_url) && strpos($gdpr_text, '
•