| @@ -86,8 +86,9 @@ | ||
| 86 | 86 | <button class="mxch-mobile-nav-sub-link" data-target="integrations-loops"><?php esc_html_e('Loops', 'mxchat'); ?></button> |
| 87 | 87 | <button class="mxch-mobile-nav-sub-link" data-target="integrations-brave"><?php esc_html_e('Brave Search', 'mxchat'); ?></button> |
| 88 | 88 | <button class="mxch-mobile-nav-sub-link" data-target="integrations-slack"><?php esc_html_e('Slack', 'mxchat'); ?></button> |
| 89 | 89 | <button class="mxch-mobile-nav-sub-link" data-target="integrations-telegram"><?php esc_html_e('Telegram', 'mxchat'); ?></button> |
| 90 | + <button class="mxch-mobile-nav-sub-link" data-target="integrations-webhook"><?php esc_html_e('Webhook', 'mxchat'); ?></button> | |
| 90 | 91 | </div> |
| 91 | 92 | </div> |
| 92 | 93 | <!-- Resources Section --> |
| 93 | 94 | <div class="mxch-mobile-nav-section"> |
| @@ -188,8 +189,9 @@ | ||
| 188 | 189 | <button class="mxch-nav-sub-link" data-target="integrations-loops"><?php esc_html_e('Loops', 'mxchat'); ?></button> |
| 189 | 190 | <button class="mxch-nav-sub-link" data-target="integrations-brave"><?php esc_html_e('Brave Search', 'mxchat'); ?></button> |
| 190 | 191 | <button class="mxch-nav-sub-link" data-target="integrations-slack"><?php esc_html_e('Slack', 'mxchat'); ?></button> |
| 191 | 192 | <button class="mxch-nav-sub-link" data-target="integrations-telegram"><?php esc_html_e('Telegram', 'mxchat'); ?></button> |
| 193 | + <button class="mxch-nav-sub-link" data-target="integrations-webhook"><?php esc_html_e('Webhook', 'mxchat'); ?></button> | |
| 192 | 194 | </div> |
| 193 | 195 | </div> |
| 194 | 196 | </div> |
| 195 | 197 | |
| @@ -336,8 +338,14 @@ | ||
| 336 | 338 | mxchat_render_field_wrapper('citation_links', __('Citation Links', 'mxchat'), function() use ($admin_instance) { |
| 337 | 339 | $admin_instance->mxchat_citation_links_toggle_callback(); |
| 338 | 340 | }, __('Allow the AI to include citation links from your knowledge database in responses. If disabled, ensure your AI Behavior settings do not mention links or the AI may fabricate URLs.', 'mxchat')); |
| 339 | 341 | |
| 342 | + // Strip Unapproved Links (plan 58f8b4) — enforcement is now | |
| 343 | + // its own control instead of riding Citation Links. | |
| 344 | + mxchat_render_field_wrapper('strip_unapproved_links', __('Strip Unapproved Links', 'mxchat'), function() use ($admin_instance) { | |
| 345 | + $admin_instance->mxchat_strip_unapproved_links_toggle_callback(); | |
| 346 | + }, __('Remove links the AI invents from its answers, even when Citation Links is off. Approved citations, real pages on this site, and links returned by your integrations (e.g. WooCommerce products) are always kept. On by default for new installs; existing sites keep their current behavior until enabled.', 'mxchat')); | |
| 347 | + | |
| 340 | 348 | // Satisfaction Rating Prompt |
| 341 | 349 | // The toggle callback inline-renders the 5 customization |
| 342 | 350 | // fields inside a single sub-options wrapper (plan-29caac). |
| 343 | 351 | // No separate customization group needed — the wrapper handles |
| @@ -489,8 +497,33 @@ | ||
| 489 | 497 | // Name Placeholder |
| 490 | 498 | mxchat_render_field_wrapper('name_placeholder', __('Name Field Placeholder', 'mxchat'), function() use ($admin_instance) { |
| 491 | 499 | $admin_instance->name_field_placeholder_callback(); |
| 492 | 500 | }, __('Placeholder text for the name input field.', 'mxchat')); |
| 501 | + | |
| 502 | + // Consent Checkbox (b062c4) | |
| 503 | + mxchat_render_field_wrapper('enable_consent_checkbox', __('Consent Checkbox', 'mxchat'), function() use ($admin_instance) { | |
| 504 | + $admin_instance->enable_consent_checkbox_callback(); | |
| 505 | + }, __('Show a consent checkbox on the email form. The decision, time, and exact label shown are stored with the lead.', 'mxchat')); | |
| 506 | + | |
| 507 | + // Consent Label | |
| 508 | + mxchat_render_field_wrapper('consent_checkbox_label', __('Consent Label', 'mxchat'), function() use ($admin_instance) { | |
| 509 | + $admin_instance->consent_checkbox_label_callback(); | |
| 510 | + }, __('Text shown beside the checkbox. Anchor tags are allowed so you can link your Privacy Policy; other HTML is stripped.', 'mxchat')); | |
| 511 | + | |
| 512 | + // Consent Required | |
| 513 | + mxchat_render_field_wrapper('consent_checkbox_required', __('Require Consent to Submit', 'mxchat'), function() use ($admin_instance) { | |
| 514 | + $admin_instance->consent_checkbox_required_callback(); | |
| 515 | + }, __('Block form submission until the box is ticked. Off means the checkbox is optional (a soft opt-in).', 'mxchat')); | |
| 516 | + | |
| 517 | + // Also show for logged-in users (c0cfaf) | |
| 518 | + mxchat_render_field_wrapper('lead_capture_logged_in_toggle', __('Also Show for Logged-In Users', 'mxchat'), function() use ($admin_instance) { | |
| 519 | + $admin_instance->lead_capture_logged_in_toggle_callback(); | |
| 520 | + }, __('Show the form to signed-in visitors too, pre-filled from their profile. Off means signed-in visitors skip it, as they do today.', 'mxchat')); | |
| 521 | + | |
| 522 | + // Require email (c0cfaf) | |
| 523 | + mxchat_render_field_wrapper('lead_capture_require_email_toggle', __('Require Email Address', 'mxchat'), function() use ($admin_instance) { | |
| 524 | + $admin_instance->lead_capture_require_email_toggle_callback(); | |
| 525 | + }, __('Off means the email field is optional, so you can collect a name (and consent) without an address.', 'mxchat')); | |
| 493 | 526 | ?> |
| 494 | 527 | </div> |
| 495 | 528 | </div> |
| 496 | 529 | |
| @@ -664,8 +697,21 @@ | ||
| 664 | 697 | <li><strong><?php esc_html_e('On User Interaction:', 'mxchat'); ?></strong> <?php esc_html_e('Script loads when user scrolls, moves mouse, or touches screen. Best for Core Web Vitals but chat appears with slight delay.', 'mxchat'); ?></li> |
| 665 | 698 | </ul> |
| 666 | 699 | </div> |
| 667 | 700 | </div> |
| 701 | + | |
| 702 | + <?php | |
| 703 | + // Plan b76ed6 (Support Ticket 468): the floating launcher is rendered hidden | |
| 704 | + // and revealed by chat-script.js, so a cache plugin's "Delay JavaScript" | |
| 705 | + // that holds the script until the visitor interacts shows no chatbot at all. | |
| 706 | + ?> | |
| 707 | + <div class="mxch-notice mxch-notice-warning" style="margin-top: 16px;"> | |
| 708 | + <svg class="mxch-notice-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg> | |
| 709 | + <div> | |
| 710 | + <strong><?php esc_html_e('Using Delay JavaScript in a cache or performance plugin?', 'mxchat'); ?></strong> | |
| 711 | + <?php esc_html_e('Leave chat-script.js out of the delay (FlyingPress, WP Rocket, LiteSpeed Cache and Perfmatters all have an exclusion list). The chat launcher stays hidden until that script runs, so a page that holds it back until the visitor interacts shows no chatbot. If you want the script delayed, pick a strategy above instead: MxChat then loads it on interaction or after a short wait.', 'mxchat'); ?> | |
| 712 | + </div> | |
| 713 | + </div> | |
| 668 | 714 | </div> |
| 669 | 715 | </div> |
| 670 | 716 | |
| 671 | 717 | <!-- Page Cache Compatibility Card --> |
| @@ -675,9 +721,19 @@ | ||
| 675 | 721 | <svg class="mxch-card-title-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg> |
| 676 | 722 | <?php esc_html_e('Page Cache Compatibility', 'mxchat'); ?> |
| 677 | 723 | </h3> |
| 678 | 724 | </div> |
| 679 | - <div class="mxch-card-body"> | |
| 725 | + <div class="mxch-card-body mxchat-autosave-section"> | |
| 726 | + <?php | |
| 727 | + // Page-cache purge on settings save (plan b76ed6, Support Ticket 468). | |
| 728 | + // Standalone option, default ON — never part of mxchat_options, so | |
| 729 | + // mxchat_sanitize() cannot strip it. Read by MxChat_Cache_Purge. | |
| 730 | + mxchat_render_field_wrapper('mxchat_cache_purge_enabled', __('Clear page cache when MxChat settings change', 'mxchat'), function() use ($admin_instance) { | |
| 731 | + $admin_instance->mxchat_cache_purge_toggle_callback(); | |
| 732 | + }, __('On, MxChat clears the page caches it can reach (WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache, FlyingPress) after its settings are saved, at most once every 30 seconds, so visitors do not keep seeing the old chatbot. Off, nothing is cleared: clear your page cache yourself after changing the chatbot. Turn it off on a large site where every save would throw away the whole cache.', 'mxchat'), | |
| 733 | + __('Developers can narrow which settings trigger the clear with the mxchat_cache_purge_watched_options filter.', 'mxchat')); | |
| 734 | + ?> | |
| 735 | + | |
| 680 | 736 | <p class="mxch-field-description" style="margin-top: 0;"><?php esc_html_e('MxChat\'s chat send (and stream send, plus PDF / Word upload) all POST to /wp-admin/admin-ajax.php. Page-cache plugins occasionally cache those responses, which breaks the per-session nonce flow on the first message. MxChat auto-tells the five most common cache plugins to never cache chat AJAX via their own filter APIs — no setup needed for those. For other cache plugins (or Cloudflare APO), copy the manual exclusion string into your cache plugin\'s exclusion list.', 'mxchat'); ?></p> |
| 681 | 737 | |
| 682 | 738 | <?php |
| 683 | 739 | $mxch_cache_rows = array( |
| @@ -1092,8 +1148,69 @@ | ||
| 1092 | 1148 | <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align: middle; margin-right: 4px;"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg> |
| 1093 | 1149 | <?php esc_html_e('Enter your Bot Token above and save to generate the registration URL.', 'mxchat'); ?> |
| 1094 | 1150 | </p> |
| 1095 | 1151 | <?php endif; ?> |
| 1152 | + </div> | |
| 1153 | + </div> | |
| 1154 | + </div> | |
| 1155 | + | |
| 1156 | + <!-- ======================================== | |
| 1157 | + INTEGRATIONS - WEBHOOK HANDOFF (plan d88e22) | |
| 1158 | + ======================================== --> | |
| 1159 | + <div id="integrations-webhook" class="mxch-section"> | |
| 1160 | + <div class="mxch-content-header"> | |
| 1161 | + <h1 class="mxch-content-title"><?php esc_html_e('Webhook', 'mxchat'); ?></h1> | |
| 1162 | + <p class="mxch-content-subtitle"><?php esc_html_e('Route live-agent handoffs to any URL you choose — your helpdesk, an automation flow, a CRM.', 'mxchat'); ?></p> | |
| 1163 | + </div> | |
| 1164 | + | |
| 1165 | + <div class="mxch-notice mxch-notice-info" style="margin-bottom: 24px;"> | |
| 1166 | + <svg class="mxch-notice-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg> | |
| 1167 | + <div> | |
| 1168 | + <?php esc_html_e('This destination is outbound-only: MxChat delivers the handoff to your URL and the chatbot keeps assisting the visitor. Your team follows up separately — by email, phone, or your own support tool.', 'mxchat'); ?> | |
| 1169 | + </div> | |
| 1170 | + </div> | |
| 1171 | + | |
| 1172 | + <div class="mxch-card"> | |
| 1173 | + <div class="mxch-card-body mxchat-autosave-section"> | |
| 1174 | + <table class="form-table"> | |
| 1175 | + <?php do_settings_fields('mxchat-embed', 'mxchat_webhook_handoff_section'); ?> | |
| 1176 | + </table> | |
| 1177 | + </div> | |
| 1178 | + </div> | |
| 1179 | + | |
| 1180 | + <div class="mxch-card" style="margin-top: 24px;"> | |
| 1181 | + <div class="mxch-card-header"> | |
| 1182 | + <h3 class="mxch-card-title"> | |
| 1183 | + <svg class="mxch-card-title-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg> | |
| 1184 | + <?php esc_html_e('Payload Reference', 'mxchat'); ?> | |
| 1185 | + </h3> | |
| 1186 | + </div> | |
| 1187 | + <div class="mxch-card-body"> | |
| 1188 | + <p class="mxch-field-description" style="margin-bottom: 12px;"> | |
| 1189 | + <?php esc_html_e('Each handoff arrives at your URL as an HTTPS POST with Content-Type application/json:', 'mxchat'); ?> | |
| 1190 | + </p> | |
| 1191 | + <pre style="background: #f8f9fa; padding: 16px; border-radius: 8px; font-size: 12px; overflow-x: auto; margin: 0 0 16px;"><?php echo esc_html('{ | |
| 1192 | + "event": "live_agent_handoff", | |
| 1193 | + "site": { "name": "Your Site", "url": "https://your-site.com" }, | |
| 1194 | + "session_id": "mxchat_chat_…", | |
| 1195 | + "user_id": 0, | |
| 1196 | + "visitor": { "name": "Ada", "email": "[email protected]" }, | |
| 1197 | + "current_message": "I need to talk to a human", | |
| 1198 | + "recent_messages": [ | |
| 1199 | + { "role": "user", "content": "…", "timestamp": 1755900000 }, | |
| 1200 | + { "role": "assistant", "content": "…", "timestamp": 1755900012 } | |
| 1201 | + ], | |
| 1202 | + "requested_at": "2026-08-22T14:30:00+00:00" | |
| 1203 | +}'); ?></pre> | |
| 1204 | + <p class="mxch-field-description" style="margin-bottom: 12px;"> | |
| 1205 | + <?php esc_html_e('When a Signing Secret is set, each request also carries this header so your endpoint can verify the sender — compute the HMAC of the raw request body with your secret and compare:', 'mxchat'); ?> | |
| 1206 | + </p> | |
| 1207 | + <div class="mxch-webhook-url-display" style="margin-bottom: 16px;"> | |
| 1208 | + <code>X-MxChat-Signature: sha256=<hex hmac-sha256 of the raw body></code> | |
| 1209 | + </div> | |
| 1210 | + <p class="mxch-field-description"> | |
| 1211 | + <?php esc_html_e('Answer with any 2xx status. Delivery uses a 5-second timeout with one retry on transport errors and 5xx responses; redirects are not followed. The last failed delivery is shown under the Webhook URL field above.', 'mxchat'); ?> | |
| 1212 | + </p> | |
| 1096 | 1213 | </div> |
| 1097 | 1214 | </div> |
| 1098 | 1215 | </div> |
| 1099 | 1216 | |