| @@ -3,10 +3,10 @@ | ||
| 3 | 3 | if ( !class_exists( 'MeowKit_MWCODE_Admin' ) ) { |
| 4 | 4 | |
| 5 | 5 | class MeowKit_MWCODE_Admin { |
| 6 | 6 | public static $loaded = false; |
| 7 | - public static $version = '5.0'; | |
| 8 | - public static $admin_version = '5.0'; | |
| 7 | + public static $version = '4.0'; | |
| 8 | + public static $admin_version = '4.0'; | |
| 9 | 9 | public static $network_license_modal_added = false; |
| 10 | 10 | public static $network_license_plugins = []; |
| 11 | 11 | |
| 12 | 12 | /** |
| @@ -157,13 +157,8 @@ | ||
| 157 | 157 | if ( $page === 'meowapps-main-menu' ) { |
| 158 | 158 | add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ], 100000, 1 ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - // Promote AI Engine on the WordPress 7 Connectors page when AI Engine | |
| 162 | - // itself isn't installed. When AI Engine is active, its own banner | |
| 163 | - // takes over — so this path only runs on "bare" Meow Apps installs. | |
| 164 | - add_action( 'admin_footer', [ $this, 'maybe_render_wpai_promo' ] ); | |
| 165 | - | |
| 166 | 161 | MeowKit_MWCODE_Admin::$loaded = true; |
| 167 | 162 | } |
| 168 | 163 | |
| 169 | 164 | // PER-INSTANCE SETUP: Run for each plugin that uses this library |
| @@ -508,195 +503,7 @@ | ||
| 508 | 503 | __( 'Thanks for using <a href="https://meowapps.com">Meow Apps</a>! This is the Meow Admin %1$s <br /><i>Loaded from %2$s </i>', $this->domain ), |
| 509 | 504 | MeowKit_MWCODE_Admin::$version, |
| 510 | 505 | __FILE__ |
| 511 | 506 | ); |
| 512 | - } | |
| 513 | - | |
| 514 | - /** | |
| 515 | - * Renders a promo banner on WordPress 7's Connectors page when AI Engine | |
| 516 | - * isn't installed. Kept self-contained so the common library stays simple: | |
| 517 | - * no new file, no REST endpoint, dismissal persists in localStorage. | |
| 518 | - */ | |
| 519 | - public function maybe_render_wpai_promo() { | |
| 520 | - // WordPress 7+ only. | |
| 521 | - if ( ! class_exists( 'WP_Connector_Registry' ) ) { | |
| 522 | - return; | |
| 523 | - } | |
| 524 | - // If AI Engine is installed, its own Connectors banner takes over. | |
| 525 | - if ( class_exists( 'Meow_MWAI_Core' ) ) { | |
| 526 | - return; | |
| 527 | - } | |
| 528 | - // Another Meow Apps plugin's common copy may have rendered already. | |
| 529 | - if ( defined( 'MEOWAPPS_WPAI_PROMO_RENDERED' ) ) { | |
| 530 | - return; | |
| 531 | - } | |
| 532 | - // Gate on the Connectors screen. The hook suffix differs between the | |
| 533 | - // direct file (`options-connectors.php`) and the menu-page variant. | |
| 534 | - $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; | |
| 535 | - $id = $screen ? $screen->id : ( isset( $GLOBALS['hook_suffix'] ) ? $GLOBALS['hook_suffix'] : '' ); | |
| 536 | - $targets = array( 'options-connectors', 'options-connectors.php', 'settings_page_options-connectors-wp-admin' ); | |
| 537 | - if ( ! in_array( $id, $targets, true ) ) { | |
| 538 | - return; | |
| 539 | - } | |
| 540 | - define( 'MEOWAPPS_WPAI_PROMO_RENDERED', true ); | |
| 541 | - | |
| 542 | - // Install button → WordPress's own plugin-install search page, pre- | |
| 543 | - // filtered for AI Engine. One click from there to install. This is the | |
| 544 | - // most reliable path: no custom nonces, native progress UI, native | |
| 545 | - // filesystem credential prompt if needed. | |
| 546 | - $can_install = current_user_can( 'install_plugins' ); | |
| 547 | - $install_url = $can_install | |
| 548 | - ? self_admin_url( 'plugin-install.php?tab=search&type=term&s=AI+Engine' ) | |
| 549 | - : 'https://wordpress.org/plugins/ai-engine/'; | |
| 550 | - $wporg_url = 'https://wordpress.org/plugins/ai-engine/'; | |
| 551 | - $learn_url = 'https://meowapps.com/wordpress-7-ai-engine-gateway/'; | |
| 552 | - | |
| 553 | - // Title is split so "AI Engine" can carry an anchor to wp.org. Keeping | |
| 554 | - // the pieces as data (not one HTML string) avoids escaping surprises and | |
| 555 | - // keeps the translation unit stable. | |
| 556 | - $payload = array( | |
| 557 | - 'titleBefore' => __( 'Highly recommended: Let ', 'meowapps' ), | |
| 558 | - 'titleLink' => __( 'AI Engine', 'meowapps' ), | |
| 559 | - 'titleAfter' => __( ' handle your connections.', 'meowapps' ), | |
| 560 | - 'sub' => __( 'One plugin for every provider. Keep your AI setup clean and consistent: monitor your API costs in one place, log every single request, and avoid the mess of juggling separate plugins for each AI model.', 'meowapps' ), | |
| 561 | - 'install' => __( 'Install AI Engine', 'meowapps' ), | |
| 562 | - 'learn' => __( 'Learn more', 'meowapps' ), | |
| 563 | - 'dismiss' => __( 'Dismiss', 'meowapps' ), | |
| 564 | - 'installUrl' => $install_url, | |
| 565 | - 'wporgUrl' => $wporg_url, | |
| 566 | - 'learnUrl' => $learn_url, | |
| 567 | - ); | |
| 568 | - ?> | |
| 569 | - <style> | |
| 570 | - .meowapps-wpai-promo { | |
| 571 | - margin: 0 0 16px; padding: 14px 18px; | |
| 572 | - display: flex; align-items: flex-start; gap: 14px; | |
| 573 | - background: #f0f4ff; border: 1px solid #d6deff; border-radius: 4px; | |
| 574 | - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; | |
| 575 | - font-size: 13px; line-height: 1.45; color: #1e1e1e; | |
| 576 | - } | |
| 577 | - .meowapps-wpai-promo-icon { | |
| 578 | - width: 32px; height: 32px; border-radius: 50%; | |
| 579 | - background: #2f5fff; color: #fff; | |
| 580 | - display: flex; align-items: center; justify-content: center; | |
| 581 | - flex-shrink: 0; | |
| 582 | - margin-top: 1px; | |
| 583 | - } | |
| 584 | - .meowapps-wpai-promo-icon svg { width: 18px; height: 18px; display: block; } | |
| 585 | - .meowapps-wpai-promo-body { | |
| 586 | - flex: 1; min-width: 0; | |
| 587 | - display: flex; flex-direction: column; gap: 10px; | |
| 588 | - } | |
| 589 | - .meowapps-wpai-promo-text strong { font-weight: 700; display: block; margin-bottom: 3px; } | |
| 590 | - .meowapps-wpai-promo-text span { color: #50575e; } | |
| 591 | - .meowapps-wpai-promo-titlelink { | |
| 592 | - color: #2f5fff; text-decoration: none; border-bottom: 1px dashed #2f5fff; | |
| 593 | - } | |
| 594 | - .meowapps-wpai-promo-titlelink:hover { color: #2448cc; border-bottom-color: #2448cc; } | |
| 595 | - .meowapps-wpai-promo-actions { | |
| 596 | - display: flex; gap: 8px; flex-wrap: wrap; align-items: center; | |
| 597 | - } | |
| 598 | - .meowapps-wpai-promo-btn { | |
| 599 | - appearance: none; border: 1px solid transparent; border-radius: 4px; | |
| 600 | - padding: 7px 16px; font: inherit; font-size: 12.5px; font-weight: 600; | |
| 601 | - cursor: pointer; text-decoration: none; | |
| 602 | - transition: background 0.12s ease, border-color 0.12s ease; | |
| 603 | - } | |
| 604 | - .meowapps-wpai-promo-btn-primary { background: #2f5fff; color: #fff; } | |
| 605 | - .meowapps-wpai-promo-btn-primary:hover { background: #2448cc; color: #fff; } | |
| 606 | - .meowapps-wpai-promo-btn-secondary { background: #7c3aed; color: #fff; } | |
| 607 | - .meowapps-wpai-promo-btn-secondary:hover { background: #6527c9; color: #fff; } | |
| 608 | - .meowapps-wpai-promo-btn-dismiss { | |
| 609 | - margin-left: auto; | |
| 610 | - background: transparent; color: #6b7280; | |
| 611 | - font-weight: 500; padding: 7px 10px; | |
| 612 | - } | |
| 613 | - .meowapps-wpai-promo-btn-dismiss:hover { color: #1e1e1e; background: rgba(0,0,0,0.04); } | |
| 614 | - </style> | |
| 615 | - <script> | |
| 616 | - (function () { | |
| 617 | - var D = <?php echo wp_json_encode( $payload ); ?>; | |
| 618 | - try { if (localStorage.getItem('meowapps-wpai-promo-dismissed') === '1') return; } catch (e) {} | |
| 619 | - | |
| 620 | - function build() { | |
| 621 | - var host = document.createElement('div'); | |
| 622 | - host.className = 'meowapps-wpai-promo'; | |
| 623 | - host.setAttribute('role', 'status'); | |
| 624 | - var iconSvg = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>'; | |
| 625 | - host.innerHTML = [ | |
| 626 | - '<span class="meowapps-wpai-promo-icon">', iconSvg, '</span>', | |
| 627 | - '<div class="meowapps-wpai-promo-body">', | |
| 628 | - '<div class="meowapps-wpai-promo-text">', | |
| 629 | - '<strong></strong> <span class="meowapps-wpai-promo-sub"></span>', | |
| 630 | - '</div>', | |
| 631 | - '<div class="meowapps-wpai-promo-actions"></div>', | |
| 632 | - '</div>' | |
| 633 | - ].join(''); | |
| 634 | - // Title carries an anchor on "AI Engine" → wp.org plugin page. | |
| 635 | - var strong = host.querySelector('strong'); | |
| 636 | - strong.appendChild(document.createTextNode(D.titleBefore)); | |
| 637 | - var tLink = document.createElement('a'); | |
| 638 | - tLink.href = D.wporgUrl; | |
| 639 | - tLink.target = '_blank'; | |
| 640 | - tLink.rel = 'noopener noreferrer'; | |
| 641 | - tLink.className = 'meowapps-wpai-promo-titlelink'; | |
| 642 | - tLink.textContent = D.titleLink; | |
| 643 | - strong.appendChild(tLink); | |
| 644 | - strong.appendChild(document.createTextNode(D.titleAfter)); | |
| 645 | - host.querySelector('.meowapps-wpai-promo-sub').textContent = D.sub; | |
| 646 | - var actions = host.querySelector('.meowapps-wpai-promo-actions'); | |
| 647 | - | |
| 648 | - function link(label, cls, href, newTab) { | |
| 649 | - var a = document.createElement('a'); | |
| 650 | - a.className = 'meowapps-wpai-promo-btn ' + cls; | |
| 651 | - a.textContent = label; | |
| 652 | - a.href = href; | |
| 653 | - if (newTab) { a.target = '_blank'; a.rel = 'noopener noreferrer'; } | |
| 654 | - actions.appendChild(a); | |
| 655 | - return a; | |
| 656 | - } | |
| 657 | - | |
| 658 | - // Install → WordPress's plugin-install search page, pre-filtered. | |
| 659 | - // User lands on a familiar screen with AI Engine as the top hit and | |
| 660 | - // can install with the native WordPress UX. | |
| 661 | - link(D.install, 'meowapps-wpai-promo-btn-primary', D.installUrl, false); | |
| 662 | - link(D.learn, 'meowapps-wpai-promo-btn-secondary', D.learnUrl, true); | |
| 663 | - | |
| 664 | - var d = document.createElement('button'); | |
| 665 | - d.type = 'button'; | |
| 666 | - d.className = 'meowapps-wpai-promo-btn meowapps-wpai-promo-btn-dismiss'; | |
| 667 | - d.textContent = D.dismiss; | |
| 668 | - d.addEventListener('click', function () { | |
| 669 | - try { localStorage.setItem('meowapps-wpai-promo-dismissed', '1'); } catch (e) {} | |
| 670 | - if (host.parentNode) host.parentNode.removeChild(host); | |
| 671 | - }); | |
| 672 | - actions.appendChild(d); | |
| 673 | - return host; | |
| 674 | - } | |
| 675 | - | |
| 676 | - function ensure() { | |
| 677 | - if (document.querySelector('.meowapps-wpai-promo')) return; | |
| 678 | - var page = document.querySelector('.connectors-page'); | |
| 679 | - if (page) { page.insertBefore(build(), page.firstChild); return; } | |
| 680 | - var header = document.querySelector('.boot-layout__stage header'); | |
| 681 | - if (header && header.parentNode) { | |
| 682 | - header.parentNode.insertBefore(build(), header.nextSibling); | |
| 683 | - } | |
| 684 | - } | |
| 685 | - | |
| 686 | - var tries = 0; | |
| 687 | - var iv = setInterval(function () { | |
| 688 | - ensure(); | |
| 689 | - if (document.querySelector('.meowapps-wpai-promo') || ++tries > 40) clearInterval(iv); | |
| 690 | - }, 120); | |
| 691 | - | |
| 692 | - var app = document.getElementById('options-connectors-wp-admin-app') | |
| 693 | - || document.getElementById('options-connectors-app'); | |
| 694 | - if (app && 'MutationObserver' in window) { | |
| 695 | - new MutationObserver(ensure).observe(app, { childList: true, subtree: true }); | |
| 696 | - } | |
| 697 | - })(); | |
| 698 | - </script> | |
| 699 | - <?php | |
| 700 | 507 | } |
| 701 | 508 | } |
| 702 | 509 | } |