PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / 0.4.2
Code Engine – PHP Snippets, AI Functions & Automation for WordPress v0.4.2
0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.9 0.4.8 0.4.7 0.4.6 trunk 0.0.1 0.0.2 0.2.8 0.2.9 0.3.0 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 0.3.8 All 32 releases
← All changes | common/admin.php +22 -436 trunk0.4.2 View file →
@@ -3,12 +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';
9 - public static $network_license_modal_added = false;
10 - public static $network_license_plugins = [];
7 + public static $version = '4.0';
8 + public static $admin_version = '4.0';
11 9
12 10 /**
13 11 * Storage for instances that need deferred initialization.
14 12 *
@@ -157,13 +155,8 @@
157 155 if ( $page === 'meowapps-main-menu' ) {
158 156 add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ], 100000, 1 );
159 157 }
160 158
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_enqueue_scripts', [ $this, 'maybe_render_wpai_promo' ] );
165 -
166 159 MeowKit_MWCODE_Admin::$loaded = true;
167 160 }
168 161
169 162 // PER-INSTANCE SETUP: Run for each plugin that uses this library
@@ -203,195 +196,21 @@
203 196 return $links;
204 197 }
205 198 $isIssue = $this->isPro && !$this->is_registered();
206 199 if ( strpos( $pathName, $thisPathName ) !== false ) {
207 - // In network admin, handle differently (no settings page available)
208 - if ( is_network_admin() ) {
209 - if ( $this->isPro && !$this->is_registered() ) {
210 - // Show "Register License" link for unregistered Pro plugins
211 - $new_links = [
212 - 'license' => sprintf(
213 - '<a href="#" class="meowapps-network-license-link" data-prefix="%s" data-plugin="%s" style="color: #d63638;">%s</a>',
214 - esc_attr( $this->prefix ),
215 - esc_attr( $this->nice_name_from_file( $this->mainfile ) ),
216 - __( 'Register License', $this->domain )
217 - ),
218 - ];
219 - // Track this plugin for the modal
220 - self::$network_license_plugins[ $this->prefix ] = $this->nice_name_from_file( $this->mainfile );
221 - // Add modal output hook (only once)
222 - if ( !self::$network_license_modal_added ) {
223 - add_action( 'admin_footer', [ __CLASS__, 'output_network_license_modal' ] );
224 - self::$network_license_modal_added = true;
225 - }
226 - }
227 - elseif ( $this->isPro && $this->is_registered() ) {
228 - // Pro plugin is registered
229 - $new_links = [
230 - 'license' => '<span style="color: #a75bd6;">' . __( 'Pro Version', $this->domain ) . '</span>',
231 - ];
232 - }
233 - else {
234 - // Free plugin
235 - $new_links = [
236 - 'license' => sprintf( '<span>' . __( '<a target="_blank" href="https://meowapps.com">Get the <u>Pro Version</u></a>', $this->domain ), $this->prefix ) . '</span>',
237 - ];
238 - }
239 - }
240 - else {
241 - // Regular admin - show settings and license status
242 - $new_links = [
243 - 'settings' =>
244 - sprintf( __( '<a href="admin.php?page=%s_settings">Settings</a>', $this->domain ), $this->prefix ),
245 - 'license' =>
246 - $this->is_registered() ?
247 - ( '<span style="color: #a75bd6;">' . __( 'Pro Version', $this->domain ) . '</span>' ) :
248 - ( $isIssue ? ( sprintf( '<span style="color: #ff3434;">' . __( 'License Issue', $this->domain ), $this->prefix ) . '</span>' ) : ( sprintf( '<span>' . __( '<a target="_blank" href="https://meowapps.com">Get the <u>Pro Version</u></a>', $this->domain ), $this->prefix ) . '</span>' ) ),
249 - ];
250 - }
200 + $new_links = [
201 + 'settings' =>
202 + sprintf( __( '<a href="admin.php?page=%s_settings">Settings</a>', $this->domain ), $this->prefix ),
203 + 'license' =>
204 + $this->is_registered() ?
205 + ( '<span style="color: #a75bd6;">' . __( 'Pro Version', $this->domain ) . '</span>' ) :
206 + ( $isIssue ? ( sprintf( '<span style="color: #ff3434;">' . __( 'License Issue', $this->domain ), $this->prefix ) . '</span>' ) : ( sprintf( '<span>' . __( '<a target="_blank" href="https://meowapps.com">Get the <u>Pro Version</u></a>', $this->domain ), $this->prefix ) . '</span>' ) ),
207 + ];
251 208 $links = array_merge( $new_links, $links );
252 209 }
253 210 return $links;
254 211 }
255 212
256 - /**
257 - * Output the network license registration modal.
258 - * Called via admin_footer hook in network admin.
259 - */
260 - public static function output_network_license_modal() {
261 - $rest_url = esc_url( rest_url() );
262 - $nonce = wp_create_nonce( 'wp_rest' );
263 - ?>
264 - <div id="meowapps-network-license-modal" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.6); z-index:100000; align-items:center; justify-content:center;">
265 - <div style="background:#fff; padding:24px; border-radius:8px; max-width:450px; width:90%; box-shadow:0 4px 20px rgba(0,0,0,0.3);">
266 - <h2 style="margin:0 0 8px 0; font-size:18px;">Register License</h2>
267 - <p id="meowapps-license-plugin-name" style="margin:0 0 16px 0; color:#666;"></p>
268 - <input type="text" id="meowapps-license-key-input" placeholder="Enter your license key" style="width:100%; padding:10px; font-size:14px; border:1px solid #8c8f94; border-radius:4px; box-sizing:border-box;" />
269 - <p id="meowapps-license-message" style="margin:12px 0 0 0; padding:10px; border-radius:4px; display:none;"></p>
270 - <div style="margin-top:16px; display:flex; gap:10px; justify-content:flex-end;">
271 - <button type="button" id="meowapps-license-cancel" class="button">Cancel</button>
272 - <button type="button" id="meowapps-license-submit" class="button button-primary">Validate & Register</button>
273 - </div>
274 - </div>
275 - </div>
276 - <?php
277 - ob_start();
278 - ?>
279 - (function() {
280 - var modal = document.getElementById('meowapps-network-license-modal');
281 - var input = document.getElementById('meowapps-license-key-input');
282 - var message = document.getElementById('meowapps-license-message');
283 - var pluginName = document.getElementById('meowapps-license-plugin-name');
284 - var submitBtn = document.getElementById('meowapps-license-submit');
285 - var cancelBtn = document.getElementById('meowapps-license-cancel');
286 - var currentPrefix = '';
287 -
288 - function showMessage(text, isError) {
289 - message.textContent = text;
290 - message.style.display = 'block';
291 - message.style.background = isError ? '#fcf0f1' : '#edfaef';
292 - message.style.color = isError ? '#d63638' : '#1e7e34';
293 - message.style.border = '1px solid ' + (isError ? '#d63638' : '#1e7e34');
294 - }
295 -
296 - function hideMessage() {
297 - message.style.display = 'none';
298 - }
299 -
300 - function openModal(prefix, plugin) {
301 - currentPrefix = prefix;
302 - pluginName.textContent = plugin;
303 - input.value = '';
304 - hideMessage();
305 - submitBtn.disabled = false;
306 - submitBtn.textContent = 'Validate & Register';
307 - modal.style.display = 'flex';
308 - input.focus();
309 - }
310 -
311 - function closeModal() {
312 - modal.style.display = 'none';
313 - currentPrefix = '';
314 - }
315 -
316 - // Handle click on "Register License" links
317 - document.addEventListener('click', function(e) {
318 - if (e.target.classList.contains('meowapps-network-license-link')) {
319 - e.preventDefault();
320 - var prefix = e.target.getAttribute('data-prefix');
321 - var plugin = e.target.getAttribute('data-plugin');
322 - openModal(prefix, plugin);
323 - }
324 - });
325 -
326 - // Close modal on cancel or clicking outside
327 - cancelBtn.addEventListener('click', closeModal);
328 - modal.addEventListener('click', function(e) {
329 - if (e.target === modal) closeModal();
330 - });
331 -
332 - // Handle escape key
333 - document.addEventListener('keydown', function(e) {
334 - if (e.key === 'Escape' && modal.style.display === 'flex') {
335 - closeModal();
336 - }
337 - });
338 -
339 - // Handle enter key in input
340 - input.addEventListener('keydown', function(e) {
341 - if (e.key === 'Enter') {
342 - submitBtn.click();
343 - }
344 - });
345 -
346 - // Submit license
347 - submitBtn.addEventListener('click', function() {
348 - var licenseKey = input.value.trim();
349 - if (!licenseKey) {
350 - showMessage('Please enter a license key.', true);
351 - return;
352 - }
353 -
354 - submitBtn.disabled = true;
355 - submitBtn.textContent = 'Validating...';
356 - hideMessage();
357 -
358 - var restUrl = '<?php echo $rest_url; ?>meow-licenser/' + currentPrefix + '/v1/set_license/';
359 -
360 - fetch(restUrl, {
361 - method: 'POST',
362 - headers: {
363 - 'Content-Type': 'application/json',
364 - 'X-WP-Nonce': '<?php echo $nonce; ?>'
365 - },
366 - body: JSON.stringify({ serialKey: licenseKey })
367 - })
368 - .then(function(response) { return response.json(); })
369 - .then(function(data) {
370 - if (data.success && data.data && !data.data.issue) {
371 - showMessage('License registered successfully! Reloading...', false);
372 - setTimeout(function() { location.reload(); }, 1500);
373 - } else {
374 - var errorMsg = 'License validation failed.';
375 - if (data.data && data.data.issue) {
376 - errorMsg = 'License issue: ' + data.data.issue;
377 - }
378 - showMessage(errorMsg, true);
379 - submitBtn.disabled = false;
380 - submitBtn.textContent = 'Validate & Register';
381 - }
382 - })
383 - .catch(function(error) {
384 - showMessage('Error: ' + error.message, true);
385 - submitBtn.disabled = false;
386 - submitBtn.textContent = 'Validate & Register';
387 - });
388 - });
389 - })();
390 - <?php
391 - wp_print_inline_script_tag( ob_get_clean() );
392 - }
393 -
394 213 public function request_verify_ssl() {
395 214 return get_option( 'force_sslverify', false );
396 215 }
397 216
@@ -407,12 +226,9 @@
407 226 return $file;
408 227 }
409 228
410 229 public function admin_notices_licensed_free() {
411 - // Verify the nonce before removing the license from a POST request (CSRF protection).
412 - if ( isset( $_POST[$this->prefix . '_reset_sub'] )
413 - && isset( $_POST[ $this->prefix . '_reset_sub_nonce' ] )
414 - && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ $this->prefix . '_reset_sub_nonce' ] ) ), $this->prefix . '_reset_sub' ) ) {
230 + if ( isset( $_POST[$this->prefix . '_reset_sub'] ) ) {
415 231 delete_option( $this->prefix . '_pro_serial' );
416 232 delete_option( $this->prefix . '_license' );
417 233 return;
418 234 }
@@ -422,9 +238,9 @@
422 238 $this->nice_name_from_file( $this->mainfile )
423 239 );
424 240 $html .= '<p>
425 241 <form method="post" action="">
426 - <input type="hidden" name="' . $this->prefix . '_reset_sub" value="true"><input type="hidden" name="' . $this->prefix . '_reset_sub_nonce" value="' . esc_attr( wp_create_nonce( $this->prefix . '_reset_sub' ) ) . '">
242 + <input type="hidden" name="' . $this->prefix . '_reset_sub" value="true">
427 243 <input type="submit" name="submit" id="submit" class="button" value="'
428 244 . __( 'Remove the license', $this->domain ) . '">
429 245 </form>
430 246 </p>';
@@ -434,23 +250,19 @@
434 250
435 251 public function admin_menu_start() {
436 252 // Hide the admin if user doesn't like Meow much
437 253 if ( get_option( 'meowapps_hide_meowapps', false ) ) {
438 - register_setting( 'general', 'meowapps_hide_meowapps', [ 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean' ] );
254 + register_setting( 'general', 'meowapps_hide_meowapps' );
439 255 add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', [ $this, 'meowapps_hide_dashboard_callback' ], 'general' );
440 256 return;
441 257 }
442 258
443 - // Create standard menu if it does not already exist.
444 - // The cat logo is injected as an <img> inside the menu title (rather than passed as
445 - // the $icon_url argument) so the original SVG fills are preserved — passing it via
446 - // $icon_url makes WordPress add the .svg class and the admin color scheme strips
447 - // the colors to a single fill.
259 + // Create standard menu if it does not already exist
448 260 global $submenu;
449 261 if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) {
450 262 add_menu_page(
451 263 'Meow Apps',
452 - '<img alt="Meow Apps" class="meowapps-menu-icon" src="' . MeowKit_MWCODE_Admin::$logo . '" />Meow Apps',
264 + '<img alt="Meow Apps" style="width: 21px; margin-left: -28px; position: absolute; margin-top: 2px;" src="' . MeowKit_MWCODE_Admin::$logo . '" />Meow Apps',
453 265 'manage_options',
454 266 'meowapps-main-menu',
455 267 [ $this, 'admin_meow_apps' ],
456 268 '',
@@ -465,46 +277,15 @@
465 277 [ $this, 'admin_meow_apps' ]
466 278 );
467 279 }
468 280
469 - // Position the cat icon so it sits in the standard icon column in both the
470 - // expanded and the collapsed (folded) sidebar.
471 - //
472 - // The image lives inside the .wp-menu-name title (where the original code
473 - // put it) so the <img> renders with its native SVG fills. When the sidebar
474 - // is collapsed, WP hides .wp-menu-name (and everything inside it), so a
475 - // small JS snippet below clones the same <img> into the .wp-menu-image
476 - // slot — which WP keeps visible in both states. We use a real <img>
477 - // (not a background-image) on purpose: at small sizes WP's admin renders
478 - // background-image SVGs noticeably lighter than the equivalent <img>,
479 - // and we want the colored cat in both states.
480 - //
481 - // The !important rules also override an older "display: none" style that
482 - // previous-generation Meow Apps common copies inject for .wp-menu-image;
483 - // if any of them load first, ours still wins.
484 - // Enqueue the menu-icon CSS/JS through the assets API instead of echoing inline tags.
485 - add_action( 'admin_enqueue_scripts', function () {
486 - $css = '
487 - #toplevel_page_meowapps-main-menu .meowapps-menu-icon { width: 20px; height: auto; position: absolute; margin-left: -28px; margin-top: 3px; }
488 - #toplevel_page_meowapps-main-menu .wp-menu-image { display: block !important; position: relative; }
489 - #toplevel_page_meowapps-main-menu .wp-menu-image::before { display: none !important; }
490 - #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, calc(-50% - 3px)); width: 20px; height: auto; }
491 - body.folded #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { display: block; }
492 - body.folded #toplevel_page_meowapps-main-menu .meowapps-menu-icon { display: none; }
493 - @media only screen and (max-width: 960px) {
494 - body.auto-fold #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { display: block; }
495 - body.auto-fold #toplevel_page_meowapps-main-menu .meowapps-menu-icon { display: none; }
496 - }';
497 - wp_add_inline_style( 'admin-menu', $css );
498 -
499 - // Clone the in-title cat icon into the .wp-menu-image slot (CSS shows it only when folded).
500 - $js = 'document.addEventListener("DOMContentLoaded", function () {'
501 - . 'var li = document.getElementById("toplevel_page_meowapps-main-menu"); if ( !li ) { return; }'
502 - . 'var src = li.querySelector(".meowapps-menu-icon"); var slot = li.querySelector(".wp-menu-image");'
503 - . 'if ( !src || !slot || slot.querySelector(".meowapps-menu-icon-folded") ) { return; }'
504 - . 'var clone = src.cloneNode(); clone.className = "meowapps-menu-icon-folded"; clone.removeAttribute("style"); slot.appendChild(clone);'
505 - . '});';
506 - wp_add_inline_script( 'common', $js );
281 + // Add CSS to hide the default icon
282 + add_action( 'admin_head', function () {
283 + echo '<style>
284 + #toplevel_page_meowapps-main-menu .wp-menu-image {
285 + display: none;
286 + }
287 + </style>';
507 288 } );
508 289 }
509 290
510 291 public function meowapps_hide_dashboard_callback() {
@@ -548,202 +329,7 @@
548 329 __( '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 ),
549 330 MeowKit_MWCODE_Admin::$version,
550 331 __FILE__
551 332 );
552 - }
553 -
554 - /**
555 - * Renders a promo banner on WordPress 7's Connectors page when AI Engine
556 - * isn't installed. Kept self-contained so the common library stays simple:
557 - * no new file, no REST endpoint, dismissal persists in localStorage.
558 - */
559 - public function maybe_render_wpai_promo() {
560 - // WordPress 7+ only.
561 - if ( ! class_exists( 'WP_Connector_Registry' ) ) {
562 - return;
563 - }
564 - // If AI Engine is installed, its own Connectors banner takes over.
565 - if ( class_exists( 'Meow_MWAI_Core' ) ) {
566 - return;
567 - }
568 - // Another Meow Apps plugin's common copy may have rendered already.
569 - if ( defined( 'MEOWAPPS_WPAI_PROMO_RENDERED' ) ) {
570 - return;
571 - }
572 - // Gate on the Connectors screen. The hook suffix differs between the
573 - // direct file (`options-connectors.php`) and the menu-page variant.
574 - $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
575 - $id = $screen ? $screen->id : ( isset( $GLOBALS['hook_suffix'] ) ? $GLOBALS['hook_suffix'] : '' );
576 - $targets = array( 'options-connectors', 'options-connectors.php', 'settings_page_options-connectors-wp-admin' );
577 - if ( ! in_array( $id, $targets, true ) ) {
578 - return;
579 - }
580 - define( 'MEOWAPPS_WPAI_PROMO_RENDERED', true );
581 -
582 - // Install button → WordPress's own plugin-install search page, pre-
583 - // filtered for AI Engine. One click from there to install. This is the
584 - // most reliable path: no custom nonces, native progress UI, native
585 - // filesystem credential prompt if needed.
586 - $can_install = current_user_can( 'install_plugins' );
587 - $install_url = $can_install
588 - ? self_admin_url( 'plugin-install.php?tab=search&type=term&s=AI+Engine' )
589 - : 'https://wordpress.org/plugins/ai-engine/';
590 - $wporg_url = 'https://wordpress.org/plugins/ai-engine/';
591 - $learn_url = 'https://meowapps.com/wordpress-7-ai-engine-gateway/';
592 -
593 - // Title is split so "AI Engine" can carry an anchor to wp.org. Keeping
594 - // the pieces as data (not one HTML string) avoids escaping surprises and
595 - // keeps the translation unit stable.
596 - $payload = array(
597 - 'titleBefore' => __( 'Highly recommended: Let ', 'meowapps' ),
598 - 'titleLink' => __( 'AI Engine', 'meowapps' ),
599 - 'titleAfter' => __( ' handle your connections.', 'meowapps' ),
600 - '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' ),
601 - 'install' => __( 'Install AI Engine', 'meowapps' ),
602 - 'learn' => __( 'Learn more', 'meowapps' ),
603 - 'dismiss' => __( 'Dismiss', 'meowapps' ),
604 - 'installUrl' => $install_url,
605 - 'wporgUrl' => $wporg_url,
606 - 'learnUrl' => $learn_url,
607 - );
608 - wp_register_style( 'meowapps-common-inline', false );
609 - wp_enqueue_style( 'meowapps-common-inline' );
610 - ob_start();
611 - ?>
612 - .meowapps-wpai-promo {
613 - margin: 0 0 16px; padding: 14px 18px;
614 - display: flex; align-items: flex-start; gap: 14px;
615 - background: #f0f4ff; border: 1px solid #d6deff; border-radius: 4px;
616 - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
617 - font-size: 13px; line-height: 1.45; color: #1e1e1e;
618 - }
619 - .meowapps-wpai-promo-icon {
620 - width: 32px; height: 32px; border-radius: 50%;
621 - background: #2f5fff; color: #fff;
622 - display: flex; align-items: center; justify-content: center;
623 - flex-shrink: 0;
624 - margin-top: 1px;
625 - }
626 - .meowapps-wpai-promo-icon svg { width: 18px; height: 18px; display: block; }
627 - .meowapps-wpai-promo-body {
628 - flex: 1; min-width: 0;
629 - display: flex; flex-direction: column; gap: 10px;
630 - }
631 - .meowapps-wpai-promo-text strong { font-weight: 700; display: block; margin-bottom: 3px; }
632 - .meowapps-wpai-promo-text span { color: #50575e; }
633 - .meowapps-wpai-promo-titlelink {
634 - color: #2f5fff; text-decoration: none; border-bottom: 1px dashed #2f5fff;
635 - }
636 - .meowapps-wpai-promo-titlelink:hover { color: #2448cc; border-bottom-color: #2448cc; }
637 - .meowapps-wpai-promo-actions {
638 - display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
639 - }
640 - .meowapps-wpai-promo-btn {
641 - appearance: none; border: 1px solid transparent; border-radius: 4px;
642 - padding: 7px 16px; font: inherit; font-size: 12.5px; font-weight: 600;
643 - cursor: pointer; text-decoration: none;
644 - transition: background 0.12s ease, border-color 0.12s ease;
645 - }
646 - .meowapps-wpai-promo-btn-primary { background: #2f5fff; color: #fff; }
647 - .meowapps-wpai-promo-btn-primary:hover { background: #2448cc; color: #fff; }
648 - .meowapps-wpai-promo-btn-secondary { background: #7c3aed; color: #fff; }
649 - .meowapps-wpai-promo-btn-secondary:hover { background: #6527c9; color: #fff; }
650 - .meowapps-wpai-promo-btn-dismiss {
651 - margin-left: auto;
652 - background: transparent; color: #6b7280;
653 - font-weight: 500; padding: 7px 10px;
654 - }
655 - .meowapps-wpai-promo-btn-dismiss:hover { color: #1e1e1e; background: rgba(0,0,0,0.04); }
656 - <?php
657 - wp_add_inline_style( 'meowapps-common-inline', ob_get_clean() );
658 -
659 - wp_register_script( 'meowapps-common-inline', false, array(), false, true );
660 - wp_enqueue_script( 'meowapps-common-inline' );
661 - ob_start();
662 - ?>
663 - (function () {
664 - var D = <?php echo wp_json_encode( $payload ); ?>;
665 - try { if (localStorage.getItem('meowapps-wpai-promo-dismissed') === '1') return; } catch (e) {}
666 -
667 - function build() {
668 - var host = document.createElement('div');
669 - host.className = 'meowapps-wpai-promo';
670 - host.setAttribute('role', 'status');
671 - 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>';
672 - host.innerHTML = [
673 - '<span class="meowapps-wpai-promo-icon">', iconSvg, '</span>',
674 - '<div class="meowapps-wpai-promo-body">',
675 - '<div class="meowapps-wpai-promo-text">',
676 - '<strong></strong> <span class="meowapps-wpai-promo-sub"></span>',
677 - '</div>',
678 - '<div class="meowapps-wpai-promo-actions"></div>',
679 - '</div>'
680 - ].join('');
681 - // Title carries an anchor on "AI Engine" → wp.org plugin page.
682 - var strong = host.querySelector('strong');
683 - strong.appendChild(document.createTextNode(D.titleBefore));
684 - var tLink = document.createElement('a');
685 - tLink.href = D.wporgUrl;
686 - tLink.target = '_blank';
687 - tLink.rel = 'noopener noreferrer';
688 - tLink.className = 'meowapps-wpai-promo-titlelink';
689 - tLink.textContent = D.titleLink;
690 - strong.appendChild(tLink);
691 - strong.appendChild(document.createTextNode(D.titleAfter));
692 - host.querySelector('.meowapps-wpai-promo-sub').textContent = D.sub;
693 - var actions = host.querySelector('.meowapps-wpai-promo-actions');
694 -
695 - function link(label, cls, href, newTab) {
696 - var a = document.createElement('a');
697 - a.className = 'meowapps-wpai-promo-btn ' + cls;
698 - a.textContent = label;
699 - a.href = href;
700 - if (newTab) { a.target = '_blank'; a.rel = 'noopener noreferrer'; }
701 - actions.appendChild(a);
702 - return a;
703 - }
704 -
705 - // Install → WordPress's plugin-install search page, pre-filtered.
706 - // User lands on a familiar screen with AI Engine as the top hit and
707 - // can install with the native WordPress UX.
708 - link(D.install, 'meowapps-wpai-promo-btn-primary', D.installUrl, false);
709 - link(D.learn, 'meowapps-wpai-promo-btn-secondary', D.learnUrl, true);
710 -
711 - var d = document.createElement('button');
712 - d.type = 'button';
713 - d.className = 'meowapps-wpai-promo-btn meowapps-wpai-promo-btn-dismiss';
714 - d.textContent = D.dismiss;
715 - d.addEventListener('click', function () {
716 - try { localStorage.setItem('meowapps-wpai-promo-dismissed', '1'); } catch (e) {}
717 - if (host.parentNode) host.parentNode.removeChild(host);
718 - });
719 - actions.appendChild(d);
720 - return host;
721 - }
722 -
723 - function ensure() {
724 - if (document.querySelector('.meowapps-wpai-promo')) return;
725 - var page = document.querySelector('.connectors-page');
726 - if (page) { page.insertBefore(build(), page.firstChild); return; }
727 - var header = document.querySelector('.boot-layout__stage header');
728 - if (header && header.parentNode) {
729 - header.parentNode.insertBefore(build(), header.nextSibling);
730 - }
731 - }
732 -
733 - var tries = 0;
734 - var iv = setInterval(function () {
735 - ensure();
736 - if (document.querySelector('.meowapps-wpai-promo') || ++tries > 40) clearInterval(iv);
737 - }, 120);
738 -
739 - var app = document.getElementById('options-connectors-wp-admin-app')
740 - || document.getElementById('options-connectors-app');
741 - if (app && 'MutationObserver' in window) {
742 - new MutationObserver(ensure).observe(app, { childList: true, subtree: true });
743 - }
744 - })();
745 - <?php
746 - wp_add_inline_script( 'meowapps-common-inline', ob_get_clean() );
747 333 }
748 334 }
749 335 }