PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 2.2.1
MxChat – AI Chatbot & Content Generation for WordPress v2.2.1
3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
← All changes | includes/class-mxchat-public.php +89 -103 2.0.32.2.1 View file →
@@ -5,97 +5,59 @@
5 5
6 6 class MxChat_Public {
7 7 private $options;
8 8
9 -public function __construct() {
10 - $this->options = get_option('mxchat_options', $this->get_default_options());
11 - add_shortcode('mxchat_chatbot', array($this, 'render_chatbot_shortcode'));
12 - add_action('wp_footer', array($this, 'append_chatbot_to_body'));
13 -}
14 -
15 -private function get_default_options() {
16 - return array(
17 - 'user_message_bg_color' => '#fff',
18 - 'user_message_font_color' => '#212121',
19 - 'bot_message_bg_color' => '#212121',
20 - 'bot_message_font_color' => '#fff',
21 - 'live_agent_message_bg_color' => '#212121',
22 - 'live_agent_message_font_color' => '#fff',
23 - 'top_bar_bg_color' => '#212121',
24 - 'send_button_font_color' => '#212121',
25 - 'close_button_color' => '#fff',
26 - 'chatbot_bg_color' => '#fff',
27 - 'chatbot_background_color' => '#212121',
28 - 'icon_color' => '#fff',
29 - 'chat_input_font_color' => '#212121',
30 - 'api_key' => '',
31 - 'system_prompt_instructions' => __(
32 - '[EXAMPLE INSTRUCTIONS] You are an AI Chatbot assistant for this website. The primary subject you should focus on is [insert proper subject here]. Your main goal is to assist visitors with questions related to this specific topic. Here are some key things to keep in mind:
33 - - Your name is [Chatbot Name]. Always introduce yourself as this name when appropriate.
34 - - Stay focused on topics related to [insert proper subject here]. If a visitor asks about an unrelated topic, politely redirect the conversation to how you can assist them with this subject. If there is an exception topic (e.g., "parking") that you should assist with, you may do so if instructed.
35 - - When appropriate, highlight the benefits of [insert proper subject here]. Offer to guide visitors to relevant pages or provide them with more information.
36 - - If a visitor asks for a purchase link or further information, provide them with this link: [Insert Purchase Link Here]. Always ensure that the link is relevant and directly related to the website\'s offerings.
37 - - Keep your responses short, concise, and to the point. Provide clear and direct answers suitable for a chatbot interaction.
38 - - If you reference specific content, provide a hyperlink to the relevant page using hypertext. Avoid including links that do not directly relate to the content or answer the visitor\'s query.
39 - - Provide answers based on the knowledge available to you. If you do not have an answer to a specific question, let the visitor know that you don’t have the information and suggest where they might find it or offer to help with something else.',
40 - 'mxchat'
41 - ),
42 - 'model' => 'gpt-3.5-turbo',
43 - 'rate_limit' => '100',
44 - 'rate_limit_message' => esc_html__('Rate limit exceeded. Please try again later.', 'mxchat'),
45 - 'top_bar_title' => esc_html__('MxChat: Basic', 'mxchat'),
46 - 'intro_message' => esc_html__('Hello! How can I assist you today?', 'mxchat'),
47 - 'append_to_body' => 'on',
48 - 'enable_email_block' => '', // Default to disabled
49 -
50 - );
9 + public function __construct() {
10 + // Simply get the options without defining duplicated defaults
11 + $this->options = get_option('mxchat_options', array());
12 + add_shortcode('mxchat_chatbot', array($this, 'render_chatbot_shortcode'));
13 + add_action('wp_footer', array($this, 'append_chatbot_to_body'));
51 14 }
52 15
53 -public function append_chatbot_to_body() {
54 - $options = get_option('mxchat_options', $this->get_default_options());
55 - $consent_category = 'marketing';
56 -
57 - if (isset($options['append_to_body']) && $options['append_to_body'] === 'on') {
58 - // Store consent status but always render
59 - $has_consent = true;
16 + public function append_chatbot_to_body() {
17 + // Use only the options we need with isset checks
18 + $consent_category = 'marketing';
60 19
61 - if (
62 - isset($options['complianz_toggle']) &&
63 - $options['complianz_toggle'] === 'on' &&
64 - function_exists('cmplz_has_consent')
65 - ) {
66 - $has_consent = cmplz_has_consent($consent_category);
20 + if (isset($this->options['append_to_body']) && $this->options['append_to_body'] === 'on') {
21 + // Store consent status but always render
22 + $has_consent = true;
23 +
24 + if (
25 + isset($this->options['complianz_toggle']) &&
26 + $this->options['complianz_toggle'] === 'on' &&
27 + function_exists('cmplz_has_consent')
28 + ) {
29 + $has_consent = cmplz_has_consent($consent_category);
30 + }
31 +
32 + // Add consent status as a parameter to the shortcode
33 + echo do_shortcode('[mxchat_chatbot floating="yes" has_consent="' . ($has_consent ? 'yes' : 'no') . '"]');
67 34 }
68 -
69 - // Add consent status as a parameter to the shortcode
70 - echo do_shortcode('[mxchat_chatbot floating="yes" has_consent="' . ($has_consent ? 'yes' : 'no') . '"]');
71 35 }
72 -}
73 36
74 37 private function mxchat_get_user_identifier() {
75 38 return sanitize_text_field($_SERVER['REMOTE_ADDR']);
76 39 }
77 40
78 -public function render_chatbot_shortcode($atts) {
79 - $attributes = shortcode_atts(array(
80 - 'floating' => 'yes',
81 - 'has_consent' => 'yes' // Add default
82 - ), $atts);
41 + public function render_chatbot_shortcode($atts) {
42 + $attributes = shortcode_atts(array(
43 + 'floating' => 'yes',
44 + 'has_consent' => 'yes' // Add default
45 + ), $atts);
83 46
84 - $is_floating = $attributes['floating'] === 'yes';
85 - $this->options = get_option('mxchat_options', $this->get_default_options());
86 -
87 - // Check for Complianz consent if the toggle is enabled
88 - $initial_visibility = 'hidden';
89 - $additional_class = '';
90 -
91 - if (isset($this->options['complianz_toggle']) && $this->options['complianz_toggle'] === 'on') {
92 - // If Complianz is enabled, add no-consent class by default
93 - $additional_class = ' no-consent';
94 - }
95 - $visibility_class = $initial_visibility . $additional_class;
47 + $is_floating = $attributes['floating'] === 'yes';
48 +
49 + // Check for Complianz consent if the toggle is enabled
50 + $initial_visibility = 'hidden';
51 + $additional_class = '';
52 +
53 + if (isset($this->options['complianz_toggle']) && $this->options['complianz_toggle'] === 'on') {
54 + // If Complianz is enabled, add no-consent class by default
55 + $additional_class = ' no-consent';
56 + }
57 + $visibility_class = $initial_visibility . $additional_class;
96 58
97 -
59 + // Use null coalescing operator (??) for fallbacks instead of having duplicate defaults
98 60 $bg_color = $this->options['chatbot_background_color'] ?? '#fff';
99 61 $user_message_bg_color = $this->options['user_message_bg_color'] ?? '#fff';
100 62 $user_message_font_color = $this->options['user_message_font_color'] ?? '#212121';
101 63 $bot_message_bg_color = $this->options['bot_message_bg_color'] ?? '#212121';
@@ -113,9 +75,11 @@
113 75 $user_id = sanitize_key($this->mxchat_get_user_identifier());
114 76 $transient_key = 'mxchat_pre_chat_message_dismissed_' . $user_id;
115 77 $input_copy = isset($this->options['input_copy']) ? esc_attr($this->options['input_copy']) : esc_attr__('How can I assist?', 'mxchat');
116 78 $rate_limit_message = isset($this->options['rate_limit_message']) ? esc_attr($this->options['rate_limit_message']) : esc_attr__('Rate limit exceeded. Please try again later.', 'mxchat');
117 -
79 + $mode_indicator_bg_color = $this->options['mode_indicator_bg_color'] ?? '#212121';
80 + $mode_indicator_font_color = $this->options['mode_indicator_font_color'] ?? '#fff';
81 +
118 82 $privacy_toggle = isset($this->options['privacy_toggle']) && $this->options['privacy_toggle'] === 'on';
119 83 $privacy_text = isset($this->options['privacy_text']) ? wp_kses_post($this->options['privacy_text']) : wp_kses_post(__('By chatting, you agree to our <a href="https://example.com/privacy-policy" target="_blank">privacy policy</a>.', 'mxchat'));
120 84
121 85 $popular_question_1 = isset($this->options['popular_question_1']) ? esc_html($this->options['popular_question_1']) : '';
@@ -123,10 +87,10 @@
123 87 $popular_question_3 = isset($this->options['popular_question_3']) ? esc_html($this->options['popular_question_3']) : '';
124 88 $additional_questions = isset($this->options['additional_popular_questions']) ? $this->options['additional_popular_questions'] : [];
125 89 $custom_icon = isset($this->options['custom_icon']) ? esc_url($this->options['custom_icon']) : '';
126 90 $title_icon = isset($this->options['title_icon']) ? esc_url($this->options['title_icon']) : '';
91 + $ai_agent_text = isset($this->options['ai_agent_text']) ? esc_html($this->options['ai_agent_text']) : esc_html__('AI Agent', 'mxchat');
127 92
128 -
129 93 $live_agent_message_bg_color = $this->options['live_agent_message_bg_color'] ?? '#212121';
130 94 $live_agent_message_font_color = $this->options['live_agent_message_font_color'] ?? '#fff';
131 95 $enable_email_block = isset($this->options['enable_email_block']) &&
132 96 ($this->options['enable_email_block'] === '1' || $this->options['enable_email_block'] === 'on');
@@ -134,9 +98,9 @@
134 98 ob_start();
135 99
136 100 // Check if floating attribute is set to 'yes' and wrap accordingly
137 101 if ($is_floating) {
138 - echo '<div id="floating-chatbot" class="' . $initial_visibility . $additional_class . '">';
102 + echo '<div id="floating-chatbot" class="' . $initial_visibility . $additional_class . '">';
139 103 }
140 104
141 105 echo '<div id="mxchat-chatbot-wrapper">';
142 106 echo ' <div class="chatbot-top-bar" id="exit-chat-button" style="background: ' . esc_attr($top_bar_bg_color) . ';">';
@@ -146,12 +110,11 @@
146 110 echo ' <img src="' . esc_url($title_icon) . '" alt="" class="chatbot-title-icon">';
147 111 }
148 112 echo ' <p class="chatbot-title" style="color: ' . esc_attr($close_button_color) . ';">' . esc_html($top_bar_title) . '</p>';
149 113 echo ' </div>';
150 - echo ' <span class="chat-mode-indicator" id="chat-mode-indicator" style="color: ' . esc_attr($close_button_color) . ';">' . esc_html__('AI Agent', 'mxchat') . '</span>';
114 + echo '<span class="chat-mode-indicator" id="chat-mode-indicator" data-ai-text="' . $ai_agent_text . '" style="color: ' . esc_attr($mode_indicator_font_color) . '; background-color: ' . esc_attr($mode_indicator_bg_color) . ';">' . $ai_agent_text . '</span>';
151 115 echo ' </div>';
152 116 echo ' <button class="exit-chat" type="button" aria-label="' . esc_attr__('Minimize', 'mxchat') . '" style="color: ' . esc_attr($close_button_color) . ';">';
153 -
154 117 echo ' <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24" id="ic-minimize" style="fill: ' . esc_attr($close_button_color) . ';">';
155 118 echo ' <path d="M0 0h24v24H0z" fill="none"></path>';
156 119 echo ' <path d="M11.67 3.87L9.9 2.1 0 12l9.9 9.9 1.77-1.77L3.54 12z"></path>';
157 120 echo ' </svg>';
@@ -189,12 +152,12 @@
189 152 }
190 153
191 154 echo ' <div id="chat-container" style="' . ($enable_email_block ? 'display: none;' : '') . '">';
192 155 echo ' <div id="chat-box">';
193 - echo ' <div class="bot-message" style="background: '
194 - . esc_attr($bot_message_bg_color) . '; color: '
195 - . esc_attr($bot_message_font_color) . ';">';
196 - echo nl2br(esc_html($intro_message));
156 + echo ' <div class="bot-message" style="background: ' . esc_attr($bot_message_bg_color) . ';">';
157 + echo ' <div dir="auto" style="color: ' . esc_attr($bot_message_font_color) . ';">';
158 + echo wp_kses_post($intro_message);
159 + echo ' </div>';
197 160 echo ' </div>';
198 161 echo ' </div>'; // end #chat-box
199 162
200 163 // Add the popular questions section
@@ -201,21 +164,21 @@
201 164 echo ' <div id="mxchat-popular-questions">';
202 165 echo ' <div class="mxchat-popular-questions-container">';
203 166
204 167 if (!empty($popular_question_1)) {
205 - echo '<button class="mxchat-popular-question">' . esc_html($popular_question_1) . '</button>';
168 + echo '<button class="mxchat-popular-question" dir="auto">' . esc_html($popular_question_1) . '</button>';
206 169 }
207 170 if (!empty($popular_question_2)) {
208 - echo '<button class="mxchat-popular-question">' . esc_html($popular_question_2) . '</button>';
171 + echo '<button class="mxchat-popular-question" dir="auto">' . esc_html($popular_question_2) . '</button>';
209 172 }
210 173 if (!empty($popular_question_3)) {
211 - echo '<button class="mxchat-popular-question">' . esc_html($popular_question_3) . '</button>';
174 + echo '<button class="mxchat-popular-question" dir="auto">' . esc_html($popular_question_3) . '</button>';
212 175 }
213 176
214 177 if (!empty($additional_questions) && is_array($additional_questions)) {
215 178 foreach ($additional_questions as $index => $question) {
216 179 if (!empty($question)) {
217 - echo '<button class="mxchat-popular-question">' . esc_html($question) . '</button>';
180 + echo '<button class="mxchat-popular-question" dir="auto">' . esc_html($question) . '</button>';
218 181 }
219 182 }
220 183 }
221 184
@@ -220,12 +183,13 @@
220 183 }
221 184
222 185 echo ' </div>';
223 186 echo ' </div>';
187 +
224 188
225 189
226 190 echo ' <div id="input-container">';
227 - echo ' <textarea id="chat-input" placeholder="' . esc_attr($input_copy) . '" style="color: ' . esc_attr($chat_input_font_color) . ';"></textarea>';
191 + echo ' <textarea id="chat-input" dir="auto" placeholder="' . esc_attr($input_copy) . '" style="color: ' . esc_attr($chat_input_font_color) . ';"></textarea>';
228 192 echo ' <button id="send-button">';
229 193 echo ' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="fill: ' . esc_attr($send_button_font_color) . ';">';
230 194 echo ' <path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/>';
231 195 echo ' </svg>';
@@ -230,23 +194,34 @@
230 194 echo ' <path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/>';
231 195 echo ' </svg>';
232 196 echo ' </button>';
233 197 echo ' </div>';
198 +
234 199 echo ' <div class="chat-toolbar">';
235 - echo ' <input type="file" id="pdf-upload" accept=".pdf" style="display: none;">';
236 - echo ' <button id="pdf-upload-btn" class="toolbar-btn" title="' . esc_attr__('Upload PDF', 'mxchat') . '">';
237 - echo ' <!-- Icon from Font Awesome Free: https://fontawesome.com/license/free -->';
238 - echo ' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" stroke="currentColor">';
239 - echo ' <path d="M64 464l48 0 0 48-48 0c-35.3 0-64-28.7-64-64L0 64C0 28.7 28.7 0 64 0L229.5 0c17 0 33.3 6.7 45.3 18.7l90.5 90.5c12 12 18.7 28.3 18.7 45.3L384 304l-48 0 0-144-80 0c-17.7 0-32-14.3-32-32l0-80L64 48c-8.8 0-16 7.2-16 16l0 384c0 8.8 7.2 16 16 16zM176 352l32 0c30.9 0 56 25.1 56 56s-25.1 56-56 56l-16 0 0 32c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48 0-80c0-8.8 7.2-16 16-16zm32 80c13.3 0 24-10.7 24-24s-10.7-24-24-24l-16 0 0 48 16 0zm96-80l32 0c26.5 0 48 21.5 48 48l0 64c0 26.5-21.5 48-48 48l-32 0c-8.8 0-16-7.2-16-16l0-128c0-8.8 7.2-16 16-16zm32 128c8.8 0 16-7.2 16-16l0-64c0-8.8-7.2-16-16-16l-16 0 0 96 16 0zm80-112c0-8.8 7.2-16 16-16l48 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 32 32 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 48c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-64 0-64z"></path>';
240 - echo ' </svg>';
241 - echo ' </button>';
242 200
243 - echo ' <input type="file" id="word-upload" accept=".docx" style="display: none;">';
244 - echo ' <button id="word-upload-btn" class="toolbar-btn" title="' . esc_attr__('Upload Word Document', 'mxchat') . '">';
245 - echo ' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" stroke="currentColor">';
246 - echo ' <path d="M48 448L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm55 241.1c-3.8-12.7-17.2-19.9-29.9-16.1s-19.9 17.2-16.1 29.9l48 160c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l25-83.4 25 83.4c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l48-160c3.8-12.7-3.4-26.1-16.1-29.9s-26.1 3.4-29.9 16.1l-25 83.4-25-83.4c-3-10.2-12.4-17.1-23-17.1s-19.9 7-23 17.1l-25 83.4-25-83.4z"/></svg>';
247 - echo ' </button>';
201 + // PDF Upload Button - wrapped in conditional
202 + $show_pdf_button = isset($this->options['show_pdf_upload_button']) ? $this->options['show_pdf_upload_button'] : 'on';
203 + if ($show_pdf_button === 'on') {
204 + echo ' <input type="file" id="pdf-upload" accept=".pdf" style="display: none;">';
205 + echo ' <button id="pdf-upload-btn" class="toolbar-btn" title="' . esc_attr__('Upload PDF', 'mxchat') . '">';
206 + echo ' <!-- Icon from Font Awesome Free: https://fontawesome.com/license/free -->';
207 + echo ' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" stroke="currentColor">';
208 + echo ' <path d="M64 464l48 0 0 48-48 0c-35.3 0-64-28.7-64-64L0 64C0 28.7 28.7 0 64 0L229.5 0c17 0 33.3 6.7 45.3 18.7l90.5 90.5c12 12 18.7 28.3 18.7 45.3L384 304l-48 0 0-144-80 0c-17.7 0-32-14.3-32-32l0-80L64 48c-8.8 0-16 7.2-16 16l0 384c0 8.8 7.2 16 16 16zM176 352l32 0c30.9 0 56 25.1 56 56s-25.1 56-56 56l-16 0 0 32c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48 0-80c0-8.8 7.2-16 16-16zm32 80c13.3 0 24-10.7 24-24s-10.7-24-24-24l-16 0 0 48 16 0zm96-80l32 0c26.5 0 48 21.5 48 48l0 64c0 26.5-21.5 48-48 48l-32 0c-8.8 0-16-7.2-16-16l0-128c0-8.8 7.2-16 16-16zm32 128c8.8 0 16-7.2 16-16l0-64c0-8.8-7.2-16-16-16l-16 0 0 96 16 0zm80-112c0-8.8 7.2-16 16-16l48 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 32 32 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 48c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-64 0-64z"></path>';
209 + echo ' </svg>';
210 + echo ' </button>';
211 + }
212 +
213 + // Word Upload Button - wrapped in conditional
214 + $show_word_button = isset($this->options['show_word_upload_button']) ? $this->options['show_word_upload_button'] : 'on';
215 + if ($show_word_button === 'on') {
216 + echo ' <input type="file" id="word-upload" accept=".docx" style="display: none;">';
217 + echo ' <button id="word-upload-btn" class="toolbar-btn" title="' . esc_attr__('Upload Word Document', 'mxchat') . '">';
218 + echo ' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" stroke="currentColor">';
219 + echo ' <path d="M48 448L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm55 241.1c-3.8-12.7-17.2-19.9-29.9-16.1s-19.9 17.2-16.1 29.9l48 160c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l25-83.4 25 83.4c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l48-160c3.8-12.7-3.4-26.1-16.1-29.9s-26.1 3.4-29.9 16.1l-25 83.4-25-83.4c-3-10.2-12.4-17.1-23-17.1s-19.9 7-23 17.1l-25 83.4-25-83.4z"/></svg>';
220 + echo ' </button>';
221 + }
248 222
223 + // File containers (unchanged)
249 224 echo ' <div id="active-pdf-container" class="active-pdf-container" style="display: none;">';
250 225 echo ' <span id="active-pdf-name" class="active-pdf-name"></span>';
251 226 echo ' <button id="remove-pdf-btn" class="remove-pdf-btn" title="' . esc_attr__('Remove PDF', 'mxchat') . '">';
252 227 echo ' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2">';
@@ -264,9 +239,20 @@
264 239 echo ' <line x1="6" y1="6" x2="18" y2="18"></line>';
265 240 echo ' </svg>';
266 241 echo ' </button>';
267 242 echo ' </div>';
243 +
244 + // Perplexity Button (unchanged except for the conditional)
245 + if (apply_filters('mxchat_perplexity_should_show_logo', true)) {
246 + echo ' <button id="perplexity-search-btn" class="toolbar-btn" title="' . esc_attr__('Search with Perplexity', 'mxchat-perplexity') . '">';
247 + echo ' <svg fill="currentColor" height="1em" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg">';
248 + echo ' <path d="M19.785 0v7.272H22.5V17.62h-2.935V24l-7.037-6.194v6.145h-1.091v-6.152L4.392 24v-6.465H1.5V7.188h2.884V0l7.053 6.494V.19h1.09v6.49L19.786 0zm-7.257 9.044v7.319l5.946 5.234V14.44l-5.946-5.397zm-1.099-.08l-5.946 5.398v7.235l5.946-5.234V8.965zm8.136 7.58h1.844V8.349H13.46l6.105 5.54v2.655zm-8.982-8.28H2.59v8.195h1.8v-2.576l6.192-5.62zM5.475 2.476v4.71h5.115l-5.115-4.71zm13.219 0l-5.115 4.71h5.115v-4.71z"></path>';
249 + echo ' </svg>';
250 + echo ' </button>';
251 + }
252 +
268 253 echo ' </div>';
254 +
269 255 echo ' <div class="chatbot-footer">';
270 256
271 257 // Output the privacy notice if enabled
272 258 if ($privacy_toggle && !empty($privacy_text)) {