| @@ -90,8 +90,9 @@ | ||
| 90 | 90 | $base_url = trailingslashit(get_rest_url(null, 'mxchat/v1')); |
| 91 | 91 | $health_url = $base_url . 'health'; |
| 92 | 92 | $transcripts_u = $base_url . 'transcripts'; |
| 93 | 93 | $knowledge_url = $base_url . 'knowledge'; |
| 94 | + $leads_url = $base_url . 'leads'; | |
| 94 | 95 | |
| 95 | 96 | $plugin_url = plugin_dir_url(dirname(__FILE__)); |
| 96 | 97 | $masked = $token_set |
| 97 | 98 | ? substr($stored_token, 0, 4) . str_repeat('•', 24) . substr($stored_token, -4) |
| @@ -350,8 +351,20 @@ | ||
| 350 | 351 | <td><?php esc_html_e('Push content into the knowledge base. Body: content, source_url, optional bot_id and content_type.', 'mxchat'); ?></td> |
| 351 | 352 | </tr> |
| 352 | 353 | <tr> |
| 353 | 354 | <td><span class="mxch-api-method mxch-api-method-delete">DELETE</span></td> |
| 355 | + <td><code><?php echo esc_html($knowledge_url); ?></code></td> | |
| 356 | + <td><span class="mxch-api-auth mxch-api-auth-bearer"><?php esc_html_e('Bearer', 'mxchat'); ?></span></td> | |
| 357 | + <td><?php esc_html_e('Remove knowledge entries by source_url — one, or an array of up to 50. Removing a URL that is not stored reports deleted:false rather than failing, so a sync job can re-run safely.', 'mxchat'); ?></td> | |
| 358 | + </tr> | |
| 359 | + <tr> | |
| 360 | + <td><span class="mxch-api-method mxch-api-method-get">GET</span></td> | |
| 361 | + <td><code><?php echo esc_html($leads_url); ?></code></td> | |
| 362 | + <td><span class="mxch-api-auth mxch-api-auth-bearer"><?php esc_html_e('Bearer', 'mxchat'); ?></span></td> | |
| 363 | + <td><?php esc_html_e('Read lead-capture submissions — the same rows the Leads tab shows, with consent state. Filterable by since, search and status; supports page + per_page pagination (max 200).', 'mxchat'); ?></td> | |
| 364 | + </tr> | |
| 365 | + <tr> | |
| 366 | + <td><span class="mxch-api-method mxch-api-method-delete">DELETE</span></td> | |
| 354 | 367 | <td><code><?php echo esc_html($transcripts_u); ?></code></td> |
| 355 | 368 | <td><span class="mxch-api-auth mxch-api-auth-bearer"><?php esc_html_e('Bearer', 'mxchat'); ?></span></td> |
| 356 | 369 | <td><?php esc_html_e('Bulk-delete chat sessions by session_id, with optional cascade to translations and click-tracking. Capped at 1000 per call.', 'mxchat'); ?></td> |
| 357 | 370 | </tr> |
| @@ -401,8 +414,32 @@ | ||
| 401 | 414 | </div> |
| 402 | 415 | |
| 403 | 416 | <div class="mxch-card"> |
| 404 | 417 | <div class="mxch-card-header"> |
| 418 | + <h3 class="mxch-card-title"><?php esc_html_e('Remove documents deleted in your source system', 'mxchat'); ?></h3> | |
| 419 | + </div> | |
| 420 | + <div class="mxch-card-body"> | |
| 421 | + <p class="mxch-field-description"><?php esc_html_e('When a file is deleted in SharePoint, Drive or your CMS, delete it here by the same source_url you pushed it with — otherwise the bot keeps answering from it. Up to 50 per call, and a URL that is already gone comes back as deleted:false instead of an error, so an automation can re-send the same batch safely.', 'mxchat'); ?></p> | |
| 422 | + <pre class="mxch-api-codeblock"><code>curl -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \ | |
| 423 | + -H "Content-Type: application/json" \ | |
| 424 | + -d '{"source_url":["https://example.com/handbook.pdf","https://example.com/policy-2024.docx"]}' \ | |
| 425 | + "<?php echo esc_html($knowledge_url); ?>"</code></pre> | |
| 426 | + </div> | |
| 427 | + </div> | |
| 428 | + | |
| 429 | + <div class="mxch-card"> | |
| 430 | + <div class="mxch-card-header"> | |
| 431 | + <h3 class="mxch-card-title"><?php esc_html_e('Sync new leads into your CRM', 'mxchat'); ?></h3> | |
| 432 | + </div> | |
| 433 | + <div class="mxch-card-body"> | |
| 434 | + <p class="mxch-field-description"><?php esc_html_e('Poll incrementally by passing the timestamp of the last lead you imported.', 'mxchat'); ?></p> | |
| 435 | + <pre class="mxch-api-codeblock"><code>curl -H "Authorization: Bearer YOUR_TOKEN" \ | |
| 436 | + "<?php echo esc_html($leads_url); ?>?since=2026-05-01T00:00:00Z&per_page=200"</code></pre> | |
| 437 | + </div> | |
| 438 | + </div> | |
| 439 | + | |
| 440 | + <div class="mxch-card"> | |
| 441 | + <div class="mxch-card-header"> | |
| 405 | 442 | <h3 class="mxch-card-title"><?php esc_html_e('Bulk-delete two chat sessions', 'mxchat'); ?></h3> |
| 406 | 443 | </div> |
| 407 | 444 | <div class="mxch-card-body"> |
| 408 | 445 | <pre class="mxch-api-codeblock"><code>curl -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \ |
| @@ -469,26 +506,11 @@ | ||
| 469 | 506 | border-radius: var(--mxch-radius-sm, 4px); |
| 470 | 507 | font-size: 13px; |
| 471 | 508 | color: var(--mxch-text-primary, #1d2327); |
| 472 | 509 | } |
| 473 | - .mxch-status-pill { | |
| 474 | - display: inline-flex; | |
| 475 | - align-items: center; | |
| 476 | - gap: 6px; | |
| 477 | - padding: 4px 10px; | |
| 478 | - border-radius: 999px; | |
| 479 | - font-size: 12px; | |
| 480 | - font-weight: 600; | |
| 481 | - } | |
| 482 | - .mxch-status-pill .mxch-status-dot { | |
| 483 | - width: 8px; | |
| 484 | - height: 8px; | |
| 485 | - border-radius: 50%; | |
| 486 | - } | |
| 487 | - .mxch-status-pill-active { background: #e6f4ea; color: #1d7a3a; } | |
| 488 | - .mxch-status-pill-active .mxch-status-dot { background: #1d7a3a; } | |
| 489 | - .mxch-status-pill-disabled { background: #fef3e2; color: #a04a00; } | |
| 490 | - .mxch-status-pill-disabled .mxch-status-dot { background: #a04a00; } | |
| 510 | + /* mxch-status-pill rules moved to css/admin-sidebar.css (plan b6e4d4) | |
| 511 | + — it is a documented shell component and every admin page loads | |
| 512 | + that sheet, so it must not live in one page's inline block. */ | |
| 491 | 513 | |
| 492 | 514 | .mxch-api-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; } |
| 493 | 515 | .mxch-api-form { display: inline; margin: 0; } |
| 494 | 516 | |
| @@ -570,76 +592,9 @@ | ||
| 570 | 592 | text-transform: uppercase; |
| 571 | 593 | letter-spacing: 0.5px; |
| 572 | 594 | } |
| 573 | 595 | </style> |
| 574 | - | |
| 575 | - <script> | |
| 576 | - (function(){ | |
| 577 | - // Sidebar tab switcher: clicking any [data-target] button toggles .mxch-section.active | |
| 578 | - document.addEventListener('DOMContentLoaded', function () { | |
| 579 | - var wrapper = document.querySelector('.mxch-api-wrapper'); | |
| 580 | - if (!wrapper) return; | |
| 581 | - | |
| 582 | - var navButtons = wrapper.querySelectorAll('[data-target]'); | |
| 583 | - navButtons.forEach(function (btn) { | |
| 584 | - btn.addEventListener('click', function (e) { | |
| 585 | - e.preventDefault(); | |
| 586 | - var targetId = btn.getAttribute('data-target'); | |
| 587 | - if (!targetId) return; | |
| 588 | - | |
| 589 | - wrapper.querySelectorAll('.mxch-section').forEach(function (s) { | |
| 590 | - s.classList.remove('active'); | |
| 591 | - }); | |
| 592 | - var target = wrapper.querySelector('#' + targetId); | |
| 593 | - if (target) target.classList.add('active'); | |
| 594 | - | |
| 595 | - // Toggle active state on sidebar + mobile nav matching this target | |
| 596 | - wrapper.querySelectorAll('.mxch-nav-link, .mxch-mobile-nav-link').forEach(function (l) { | |
| 597 | - l.classList.remove('active'); | |
| 598 | - }); | |
| 599 | - wrapper.querySelectorAll('[data-target="' + targetId + '"]').forEach(function (l) { | |
| 600 | - l.classList.add('active'); | |
| 601 | - }); | |
| 602 | - | |
| 603 | - // Close mobile menu if open | |
| 604 | - wrapper.querySelector('.mxch-mobile-menu')?.classList.remove('open'); | |
| 605 | - wrapper.querySelector('.mxch-mobile-overlay')?.classList.remove('open'); | |
| 606 | - }); | |
| 607 | - }); | |
| 608 | - | |
| 609 | - // Mobile menu open/close | |
| 610 | - var mobileBtn = wrapper.querySelector('.mxch-mobile-menu-btn'); | |
| 611 | - var mobileMenu = wrapper.querySelector('.mxch-mobile-menu'); | |
| 612 | - var mobileOverlay = wrapper.querySelector('.mxch-mobile-overlay'); | |
| 613 | - var mobileClose = wrapper.querySelector('.mxch-mobile-menu-close'); | |
| 614 | - function openMenu() { mobileMenu?.classList.add('open'); mobileOverlay?.classList.add('open'); } | |
| 615 | - function closeMenu() { mobileMenu?.classList.remove('open'); mobileOverlay?.classList.remove('open'); } | |
| 616 | - mobileBtn?.addEventListener('click', openMenu); | |
| 617 | - mobileClose?.addEventListener('click', closeMenu); | |
| 618 | - mobileOverlay?.addEventListener('click', closeMenu); | |
| 619 | - | |
| 620 | - // Copy-to-clipboard for the just-rotated token | |
| 621 | - wrapper.querySelectorAll('[data-mxch-copy]').forEach(function (btn) { | |
| 622 | - btn.addEventListener('click', function () { | |
| 623 | - var val = btn.getAttribute('data-mxch-copy'); | |
| 624 | - if (!val) return; | |
| 625 | - var label = btn.querySelector('span'); | |
| 626 | - var original = label ? label.textContent : ''; | |
| 627 | - var done = function () { | |
| 628 | - if (label) label.textContent = '<?php echo esc_js(__('Copied', 'mxchat')); ?>'; | |
| 629 | - setTimeout(function () { if (label) label.textContent = original; }, 1500); | |
| 630 | - }; | |
| 631 | - if (navigator.clipboard && navigator.clipboard.writeText) { | |
| 632 | - navigator.clipboard.writeText(val).then(done).catch(function(){ done(); }); | |
| 633 | - } else { | |
| 634 | - var ta = document.createElement('textarea'); | |
| 635 | - ta.value = val; document.body.appendChild(ta); ta.select(); | |
| 636 | - try { document.execCommand('copy'); } catch(e){} | |
| 637 | - document.body.removeChild(ta); done(); | |
| 638 | - } | |
| 639 | - }); | |
| 640 | - }); | |
| 641 | - }); | |
| 642 | - })(); | |
| 643 | - </script> | |
| 644 | 596 | <?php |
| 597 | + // Tab switcher / mobile menu / copy-to-clipboard are wired by the shared | |
| 598 | + // mxchat-basic/js/admin-sidebar.js, enqueued in class-mxchat-admin.php for | |
| 599 | + // the mxchat-api-access screen. | |
| 645 | 600 | } |