| @@ -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 | |
| @@ -272,11 +272,9 @@ | ||
| 272 | 272 | <button type="button" id="meowapps-license-submit" class="button button-primary">Validate & Register</button> |
| 273 | 273 | </div> |
| 274 | 274 | </div> |
| 275 | 275 | </div> |
| 276 | - <?php | |
| 277 | - ob_start(); | |
| 278 | - ?> | |
| 276 | + <script> | |
| 279 | 277 | (function() { |
| 280 | 278 | var modal = document.getElementById('meowapps-network-license-modal'); |
| 281 | 279 | var input = document.getElementById('meowapps-license-key-input'); |
| 282 | 280 | var message = document.getElementById('meowapps-license-message'); |
| @@ -386,10 +384,10 @@ | ||
| 386 | 384 | submitBtn.textContent = 'Validate & Register'; |
| 387 | 385 | }); |
| 388 | 386 | }); |
| 389 | 387 | })(); |
| 388 | + </script> | |
| 390 | 389 | <?php |
| 391 | - wp_print_inline_script_tag( ob_get_clean() ); | |
| 392 | 390 | } |
| 393 | 391 | |
| 394 | 392 | public function request_verify_ssl() { |
| 395 | 393 | return get_option( 'force_sslverify', false ); |
| @@ -407,12 +405,9 @@ | ||
| 407 | 405 | return $file; |
| 408 | 406 | } |
| 409 | 407 | |
| 410 | 408 | 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' ) ) { | |
| 409 | + if ( isset( $_POST[$this->prefix . '_reset_sub'] ) ) { | |
| 415 | 410 | delete_option( $this->prefix . '_pro_serial' ); |
| 416 | 411 | delete_option( $this->prefix . '_license' ); |
| 417 | 412 | return; |
| 418 | 413 | } |
| @@ -422,9 +417,9 @@ | ||
| 422 | 417 | $this->nice_name_from_file( $this->mainfile ) |
| 423 | 418 | ); |
| 424 | 419 | $html .= '<p> |
| 425 | 420 | <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' ) ) . '"> | |
| 421 | + <input type="hidden" name="' . $this->prefix . '_reset_sub" value="true"> | |
| 427 | 422 | <input type="submit" name="submit" id="submit" class="button" value="' |
| 428 | 423 | . __( 'Remove the license', $this->domain ) . '"> |
| 429 | 424 | </form> |
| 430 | 425 | </p>'; |
| @@ -434,9 +429,9 @@ | ||
| 434 | 429 | |
| 435 | 430 | public function admin_menu_start() { |
| 436 | 431 | // Hide the admin if user doesn't like Meow much |
| 437 | 432 | if ( get_option( 'meowapps_hide_meowapps', false ) ) { |
| 438 | - register_setting( 'general', 'meowapps_hide_meowapps', [ 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean' ] ); | |
| 433 | + register_setting( 'general', 'meowapps_hide_meowapps' ); | |
| 439 | 434 | add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', [ $this, 'meowapps_hide_dashboard_callback' ], 'general' ); |
| 440 | 435 | return; |
| 441 | 436 | } |
| 442 | 437 | |
| @@ -480,31 +475,69 @@ | ||
| 480 | 475 | // |
| 481 | 476 | // The !important rules also override an older "display: none" style that |
| 482 | 477 | // previous-generation Meow Apps common copies inject for .wp-menu-image; |
| 483 | 478 | // 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; } | |
| 479 | + add_action( 'admin_head', function () { | |
| 480 | + echo '<style> | |
| 481 | + #toplevel_page_meowapps-main-menu .meowapps-menu-icon { | |
| 482 | + width: 20px; | |
| 483 | + height: auto; | |
| 484 | + position: absolute; | |
| 485 | + margin-left: -28px; | |
| 486 | + margin-top: 3px; | |
| 487 | + } | |
| 488 | + #toplevel_page_meowapps-main-menu .wp-menu-image { | |
| 489 | + display: block !important; | |
| 490 | + position: relative; | |
| 491 | + } | |
| 492 | + #toplevel_page_meowapps-main-menu .wp-menu-image::before { | |
| 493 | + display: none !important; | |
| 494 | + } | |
| 495 | + #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { | |
| 496 | + display: none; | |
| 497 | + position: absolute; | |
| 498 | + top: 50%; | |
| 499 | + left: 50%; | |
| 500 | + transform: translate(-50%, calc(-50% - 3px)); | |
| 501 | + width: 20px; | |
| 502 | + height: auto; | |
| 503 | + } | |
| 504 | + body.folded #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { | |
| 505 | + display: block; | |
| 506 | + } | |
| 507 | + body.folded #toplevel_page_meowapps-main-menu .meowapps-menu-icon { | |
| 508 | + display: none; | |
| 509 | + } | |
| 493 | 510 | @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 ); | |
| 511 | + body.auto-fold #toplevel_page_meowapps-main-menu .wp-menu-image .meowapps-menu-icon-folded { | |
| 512 | + display: block; | |
| 513 | + } | |
| 514 | + body.auto-fold #toplevel_page_meowapps-main-menu .meowapps-menu-icon { | |
| 515 | + display: none; | |
| 516 | + } | |
| 517 | + } | |
| 518 | + </style>'; | |
| 519 | + }, 999 ); | |
| 498 | 520 | |
| 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 ); | |
| 521 | + // Inject a clone of the in-title cat icon into the .wp-menu-image slot. | |
| 522 | + // CSS above shows it only when the sidebar is folded; in the normal | |
| 523 | + // expanded state the .wp-menu-name <img> stays the visible icon. | |
| 524 | + add_action( 'admin_footer', function () { | |
| 525 | + ?> | |
| 526 | + <script> | |
| 527 | + ( function () { | |
| 528 | + var li = document.getElementById( 'toplevel_page_meowapps-main-menu' ); | |
| 529 | + if ( !li ) { return; } | |
| 530 | + var src = li.querySelector( '.meowapps-menu-icon' ); | |
| 531 | + var slot = li.querySelector( '.wp-menu-image' ); | |
| 532 | + if ( !src || !slot || slot.querySelector( '.meowapps-menu-icon-folded' ) ) { return; } | |
| 533 | + var clone = src.cloneNode(); | |
| 534 | + clone.className = 'meowapps-menu-icon-folded'; | |
| 535 | + clone.removeAttribute( 'style' ); | |
| 536 | + slot.appendChild( clone ); | |
| 537 | + } )(); | |
| 538 | + </script> | |
| 539 | + <?php | |
| 507 | 540 | } ); |
| 508 | 541 | } |
| 509 | 542 | |
| 510 | 543 | public function meowapps_hide_dashboard_callback() { |
| @@ -604,12 +637,10 @@ | ||
| 604 | 637 | 'installUrl' => $install_url, |
| 605 | 638 | 'wporgUrl' => $wporg_url, |
| 606 | 639 | 'learnUrl' => $learn_url, |
| 607 | 640 | ); |
| 608 | - wp_register_style( 'meowapps-common-inline', false ); | |
| 609 | - wp_enqueue_style( 'meowapps-common-inline' ); | |
| 610 | - ob_start(); | |
| 611 | 641 | ?> |
| 642 | + <style> | |
| 612 | 643 | .meowapps-wpai-promo { |
| 613 | 644 | margin: 0 0 16px; padding: 14px 18px; |
| 614 | 645 | display: flex; align-items: flex-start; gap: 14px; |
| 615 | 646 | background: #f0f4ff; border: 1px solid #d6deff; border-radius: 4px; |
| @@ -652,15 +683,10 @@ | ||
| 652 | 683 | background: transparent; color: #6b7280; |
| 653 | 684 | font-weight: 500; padding: 7px 10px; |
| 654 | 685 | } |
| 655 | 686 | .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 | - ?> | |
| 687 | + </style> | |
| 688 | + <script> | |
| 663 | 689 | (function () { |
| 664 | 690 | var D = <?php echo wp_json_encode( $payload ); ?>; |
| 665 | 691 | try { if (localStorage.getItem('meowapps-wpai-promo-dismissed') === '1') return; } catch (e) {} |
| 666 | 692 | |
| @@ -741,9 +767,9 @@ | ||
| 741 | 767 | if (app && 'MutationObserver' in window) { |
| 742 | 768 | new MutationObserver(ensure).observe(app, { childList: true, subtree: true }); |
| 743 | 769 | } |
| 744 | 770 | })(); |
| 771 | + </script> | |
| 745 | 772 | <?php |
| 746 | - wp_add_inline_script( 'meowapps-common-inline', ob_get_clean() ); | |
| 747 | 773 | } |
| 748 | 774 | } |
| 749 | 775 | } |