| @@ -160,9 +160,9 @@ | ||
| 160 | 160 | |
| 161 | 161 | // Promote AI Engine on the WordPress 7 Connectors page when AI Engine |
| 162 | 162 | // itself isn't installed. When AI Engine is active, its own banner |
| 163 | 163 | // takes over — so this path only runs on "bare" Meow Apps installs. |
| 164 | - add_action( 'admin_enqueue_scripts', [ $this, 'maybe_render_wpai_promo' ] ); | |
| 164 | + add_action( 'admin_footer', [ $this, 'maybe_render_wpai_promo' ] ); | |
| 165 | 165 | |
| 166 | 166 | MeowKit_MWCODE_Admin::$loaded = true; |
| 167 | 167 | } |
| 168 | 168 | |
| @@ -202,45 +202,8 @@ | ||
| 202 | 202 | if ( !$isActive ) { |
| 203 | 203 | return $links; |
| 204 | 204 | } |
| 205 | 205 | $isIssue = $this->isPro && !$this->is_registered(); |
| 206 | - | |
| 207 | - // The licenser already knows WHY validation failed and stores it as | |
| 208 | - // license['issue'] (licenser.php), but this badge used to render a flat | |
| 209 | - // "License Issue" for every case. That sent people to support to ask a | |
| 210 | - // question the plugin could have answered: the most common one by far is a | |
| 211 | - // licence whose activation slot is held by another site, which reads as | |
| 212 | - // "my licence is broken" and gets reported as a billing problem. | |
| 213 | - $issueLabel = __( 'License Issue', $this->domain ); | |
| 214 | - if ( $isIssue ) { | |
| 215 | - $license = get_option( $this->prefix . '_license', '' ); | |
| 216 | - $issue = is_array( $license ) && !empty( $license['issue'] ) ? $license['issue'] : null; | |
| 217 | - // Codes the store actually sends. Verified against EDD Software Licensing | |
| 218 | - // rather than guessed: an invented key would silently never match, and a | |
| 219 | - // wrong label is worse than the generic one. | |
| 220 | - $labels = [ | |
| 221 | - // `error` codes, from a failed activation. | |
| 222 | - 'no_activations_left' => __( 'License in use on another site', $this->domain ), | |
| 223 | - 'expired' => __( 'License expired', $this->domain ), | |
| 224 | - 'disabled' => __( 'License revoked', $this->domain ), | |
| 225 | - 'missing' => __( 'License key not recognized', $this->domain ), | |
| 226 | - 'key_mismatch' => __( 'License key not recognized', $this->domain ), | |
| 227 | - 'item_name_mismatch' => __( 'License is for another plugin', $this->domain ), | |
| 228 | - 'invalid_item_id' => __( 'License is for another plugin', $this->domain ), | |
| 229 | - 'missing_item_id' => __( 'License is for another plugin', $this->domain ), | |
| 230 | - 'bundle_activation_not_allowed' => __( 'This license cannot be activated directly', $this->domain ), | |
| 231 | - // `license` statuses, when the key is known but not valid here. | |
| 232 | - 'site_inactive' => __( 'License not activated on this site', $this->domain ), | |
| 233 | - 'inactive' => __( 'License not activated on this site', $this->domain ), | |
| 234 | - // Genuinely no answer from the store. NOT invalid_response, which means the | |
| 235 | - // store replied and we could not make sense of it: blaming the connection | |
| 236 | - // there would send people chasing a firewall that is working fine. | |
| 237 | - 'no_response' => __( 'License server unreachable', $this->domain ), | |
| 238 | - ]; | |
| 239 | - if ( $issue !== null && isset( $labels[ $issue ] ) ) { | |
| 240 | - $issueLabel = $labels[ $issue ]; | |
| 241 | - } | |
| 242 | - } | |
| 243 | 206 | if ( strpos( $pathName, $thisPathName ) !== false ) { |
| 244 | 207 | // In network admin, handle differently (no settings page available) |
| 245 | 208 | if ( is_network_admin() ) { |
| 246 | 209 | if ( $this->isPro && !$this->is_registered() ) { |
| @@ -281,9 +244,9 @@ | ||
| 281 | 244 | sprintf( __( '<a href="admin.php?page=%s_settings">Settings</a>', $this->domain ), $this->prefix ), |
| 282 | 245 | 'license' => |
| 283 | 246 | $this->is_registered() ? |
| 284 | 247 | ( '<span style="color: #a75bd6;">' . __( 'Pro Version', $this->domain ) . '</span>' ) : |
| 285 | - ( $isIssue ? ( '<span style="color: #ff3434;">' . esc_html( $issueLabel ) . '</span>' ) : ( sprintf( '<span>' . __( '<a target="_blank" href="https://meowapps.com">Get the <u>Pro Version</u></a>', $this->domain ), $this->prefix ) . '</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>' ) ), | |
| 286 | 249 | ]; |
| 287 | 250 | } |
| 288 | 251 | $links = array_merge( $new_links, $links ); |
| 289 | 252 | } |
| @@ -309,11 +272,9 @@ | ||
| 309 | 272 | <button type="button" id="meowapps-license-submit" class="button button-primary">Validate & Register</button> |
| 310 | 273 | </div> |
| 311 | 274 | </div> |
| 312 | 275 | </div> |
| 313 | - <?php | |
| 314 | - ob_start(); | |
| 315 | - ?> | |
| 276 | + <script> | |
| 316 | 277 | (function() { |
| 317 | 278 | var modal = document.getElementById('meowapps-network-license-modal'); |
| 318 | 279 | var input = document.getElementById('meowapps-license-key-input'); |
| 319 | 280 | var message = document.getElementById('meowapps-license-message'); |
| @@ -423,10 +384,10 @@ | ||
| 423 | 384 | submitBtn.textContent = 'Validate & Register'; |
| 424 | 385 | }); |
| 425 | 386 | }); |
| 426 | 387 | })(); |
| 388 | + </script> | |
| 427 | 389 | <?php |
| 428 | - wp_print_inline_script_tag( ob_get_clean() ); | |
| 429 | 390 | } |
| 430 | 391 | |
| 431 | 392 | public function request_verify_ssl() { |
| 432 | 393 | return get_option( 'force_sslverify', false ); |
| @@ -444,12 +405,9 @@ | ||
| 444 | 405 | return $file; |
| 445 | 406 | } |
| 446 | 407 | |
| 447 | 408 | public function admin_notices_licensed_free() { |
| 448 | - // Verify the nonce before removing the license from a POST request (CSRF protection). | |
| 449 | - if ( isset( $_POST[$this->prefix . '_reset_sub'] ) | |
| 450 | - && isset( $_POST[ $this->prefix . '_reset_sub_nonce' ] ) | |
| 451 | - && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ $this->prefix . '_reset_sub_nonce' ] ) ), $this->prefix . '_reset_sub' ) ) { | |
| 409 | + if ( isset( $_POST[$this->prefix . '_reset_sub'] ) ) { | |
| 452 | 410 | delete_option( $this->prefix . '_pro_serial' ); |
| 453 | 411 | delete_option( $this->prefix . '_license' ); |
| 454 | 412 | return; |
| 455 | 413 | } |
| @@ -459,9 +417,9 @@ | ||
| 459 | 417 | $this->nice_name_from_file( $this->mainfile ) |
| 460 | 418 | ); |
| 461 | 419 | $html .= '<p> |
| 462 | 420 | <form method="post" action=""> |
| 463 | - <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' ) ) . '"> | |
| 421 | + <input type="hidden" name="' . $this->prefix . '_reset_sub" value="true"> | |
| 464 | 422 | <input type="submit" name="submit" id="submit" class="button" value="' |
| 465 | 423 | . __( 'Remove the license', $this->domain ) . '"> |
| 466 | 424 | </form> |
| 467 | 425 | </p>'; |
| @@ -471,23 +429,19 @@ | ||
| 471 | 429 | |
| 472 | 430 | public function admin_menu_start() { |
| 473 | 431 | // Hide the admin if user doesn't like Meow much |
| 474 | 432 | if ( get_option( 'meowapps_hide_meowapps', false ) ) { |
| 475 | - register_setting( 'general', 'meowapps_hide_meowapps', [ 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean' ] ); | |
| 433 | + register_setting( 'general', 'meowapps_hide_meowapps' ); | |
| 476 | 434 | add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', [ $this, 'meowapps_hide_dashboard_callback' ], 'general' ); |
| 477 | 435 | return; |
| 478 | 436 | } |
| 479 | 437 | |
| 480 | - // Create standard menu if it does not already exist. | |
| 481 | - // The cat logo is injected as an <img> inside the menu title (rather than passed as | |
| 482 | - // the $icon_url argument) so the original SVG fills are preserved — passing it via | |
| 483 | - // $icon_url makes WordPress add the .svg class and the admin color scheme strips | |
| 484 | - // the colors to a single fill. | |
| 438 | + // Create standard menu if it does not already exist | |
| 485 | 439 | global $submenu; |
| 486 | 440 | if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) { |
| 487 | 441 | add_menu_page( |
| 488 | 442 | 'Meow Apps', |
| 489 | - '<img alt="Meow Apps" class="meowapps-menu-icon" src="' . MeowKit_MWCODE_Admin::$logo . '" />Meow Apps', | |
| 443 | + '<img alt="Meow Apps" style="width: 21px; margin-left: -28px; position: absolute; margin-top: 2px;" src="' . MeowKit_MWCODE_Admin::$logo . '" />Meow Apps', | |
| 490 | 444 | 'manage_options', |
| 491 | 445 | 'meowapps-main-menu', |
| 492 | 446 | [ $this, 'admin_meow_apps' ], |
| 493 | 447 | '', |
| @@ -502,46 +456,15 @@ | ||
| 502 | 456 | [ $this, 'admin_meow_apps' ] |
| 503 | 457 | ); |
| 504 | 458 | } |
| 505 | 459 | |
| 506 | - // Position the cat icon so it sits in the standard icon column in both the | |
| 507 | - // expanded and the collapsed (folded) sidebar. | |
| 508 | - // | |
| 509 | - // The image lives inside the .wp-menu-name title (where the original code | |
| 510 | - // put it) so the <img> renders with its native SVG fills. When the sidebar | |
| 511 | - // is collapsed, WP hides .wp-menu-name (and everything inside it), so a | |
| 512 | - // small JS snippet below clones the same <img> into the .wp-menu-image | |
| 513 | - // slot — which WP keeps visible in both states. We use a real <img> | |
| 514 | - // (not a background-image) on purpose: at small sizes WP's admin renders | |
| 515 | - // background-image SVGs noticeably lighter than the equivalent <img>, | |
| 516 | - // and we want the colored cat in both states. | |
| 517 | - // | |
| 518 | - // The !important rules also override an older "display: none" style that | |
| 519 | - // previous-generation Meow Apps common copies inject for .wp-menu-image; | |
| 520 | - // if any of them load first, ours still wins. | |
| 521 | - // Enqueue the menu-icon CSS/JS through the assets API instead of echoing inline tags. | |
| 522 | - add_action( 'admin_enqueue_scripts', function () { | |
| 523 | - $css = ' | |
| 524 | - #toplevel_page_meowapps-main-menu .meowapps-menu-icon { width: 20px; height: auto; position: absolute; margin-left: -28px; margin-top: 3px; } | |
| 525 | - #toplevel_page_meowapps-main-menu .wp-menu-image { display: block !important; position: relative; } | |
| 526 | - #toplevel_page_meowapps-main-menu .wp-menu-image::before { display: none !important; } | |
| 527 | - #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; } | |
| 528 | - body.folded #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { display: block; } | |
| 529 | - body.folded #toplevel_page_meowapps-main-menu .meowapps-menu-icon { display: none; } | |
| 530 | - @media only screen and (max-width: 960px) { | |
| 531 | - body.auto-fold #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { display: block; } | |
| 532 | - body.auto-fold #toplevel_page_meowapps-main-menu .meowapps-menu-icon { display: none; } | |
| 533 | - }'; | |
| 534 | - wp_add_inline_style( 'admin-menu', $css ); | |
| 535 | - | |
| 536 | - // Clone the in-title cat icon into the .wp-menu-image slot (CSS shows it only when folded). | |
| 537 | - $js = 'document.addEventListener("DOMContentLoaded", function () {' | |
| 538 | - . 'var li = document.getElementById("toplevel_page_meowapps-main-menu"); if ( !li ) { return; }' | |
| 539 | - . 'var src = li.querySelector(".meowapps-menu-icon"); var slot = li.querySelector(".wp-menu-image");' | |
| 540 | - . 'if ( !src || !slot || slot.querySelector(".meowapps-menu-icon-folded") ) { return; }' | |
| 541 | - . 'var clone = src.cloneNode(); clone.className = "meowapps-menu-icon-folded"; clone.removeAttribute("style"); slot.appendChild(clone);' | |
| 542 | - . '});'; | |
| 543 | - wp_add_inline_script( 'common', $js ); | |
| 460 | + // Add CSS to hide the default icon | |
| 461 | + add_action( 'admin_head', function () { | |
| 462 | + echo '<style> | |
| 463 | + #toplevel_page_meowapps-main-menu .wp-menu-image { | |
| 464 | + display: none; | |
| 465 | + } | |
| 466 | + </style>'; | |
| 544 | 467 | } ); |
| 545 | 468 | } |
| 546 | 469 | |
| 547 | 470 | public function meowapps_hide_dashboard_callback() { |
| @@ -641,12 +564,10 @@ | ||
| 641 | 564 | 'installUrl' => $install_url, |
| 642 | 565 | 'wporgUrl' => $wporg_url, |
| 643 | 566 | 'learnUrl' => $learn_url, |
| 644 | 567 | ); |
| 645 | - wp_register_style( 'meowapps-common-inline', false ); | |
| 646 | - wp_enqueue_style( 'meowapps-common-inline' ); | |
| 647 | - ob_start(); | |
| 648 | 568 | ?> |
| 569 | + <style> | |
| 649 | 570 | .meowapps-wpai-promo { |
| 650 | 571 | margin: 0 0 16px; padding: 14px 18px; |
| 651 | 572 | display: flex; align-items: flex-start; gap: 14px; |
| 652 | 573 | background: #f0f4ff; border: 1px solid #d6deff; border-radius: 4px; |
| @@ -689,15 +610,10 @@ | ||
| 689 | 610 | background: transparent; color: #6b7280; |
| 690 | 611 | font-weight: 500; padding: 7px 10px; |
| 691 | 612 | } |
| 692 | 613 | .meowapps-wpai-promo-btn-dismiss:hover { color: #1e1e1e; background: rgba(0,0,0,0.04); } |
| 693 | - <?php | |
| 694 | - wp_add_inline_style( 'meowapps-common-inline', ob_get_clean() ); | |
| 695 | - | |
| 696 | - wp_register_script( 'meowapps-common-inline', false, array(), false, true ); | |
| 697 | - wp_enqueue_script( 'meowapps-common-inline' ); | |
| 698 | - ob_start(); | |
| 699 | - ?> | |
| 614 | + </style> | |
| 615 | + <script> | |
| 700 | 616 | (function () { |
| 701 | 617 | var D = <?php echo wp_json_encode( $payload ); ?>; |
| 702 | 618 | try { if (localStorage.getItem('meowapps-wpai-promo-dismissed') === '1') return; } catch (e) {} |
| 703 | 619 | |
| @@ -778,9 +694,9 @@ | ||
| 778 | 694 | if (app && 'MutationObserver' in window) { |
| 779 | 695 | new MutationObserver(ensure).observe(app, { childList: true, subtree: true }); |
| 780 | 696 | } |
| 781 | 697 | })(); |
| 698 | + </script> | |
| 782 | 699 | <?php |
| 783 | - wp_add_inline_script( 'meowapps-common-inline', ob_get_clean() ); | |
| 784 | 700 | } |
| 785 | 701 | } |
| 786 | 702 | } |