| @@ -4,9 +4,8 @@ | ||
| 4 | 4 | use Elementor\Api; |
| 5 | 5 | use Elementor\Core\Admin\UI\Components\Button; |
| 6 | 6 | use Elementor\Core\Base\Module; |
| 7 | 7 | use Elementor\Core\Upgrade\Manager; |
| 8 | -use Elementor\Core\Utils\Hints; | |
| 9 | 8 | use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; |
| 10 | 9 | use Elementor\Plugin; |
| 11 | 10 | use Elementor\Settings; |
| 12 | 11 | use Elementor\Tracker; |
| @@ -33,8 +32,9 @@ | ||
| 33 | 32 | 'tracker_last_update', |
| 34 | 33 | 'rate_us_feedback', |
| 35 | 34 | 'role_manager_promote', |
| 36 | 35 | 'experiment_promotion', |
| 36 | + 'send_app_promotion', | |
| 37 | 37 | 'site_mailer_promotion', |
| 38 | 38 | 'plugin_image_optimization', |
| 39 | 39 | 'ally_pages_promotion', |
| 40 | 40 | self::LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID, |
| @@ -469,8 +469,58 @@ | ||
| 469 | 469 | $detected_form_plugin = false; |
| 470 | 470 | return $detected_form_plugin; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | + private function notice_send_app_promotion() { | |
| 474 | + return self::EXIT_EARLY_FOR_BACKWARD_COMPATIBILITY; | |
| 475 | + | |
| 476 | + $notice_id = 'send_app_promotion'; | |
| 477 | + | |
| 478 | + if ( ! $this->is_elementor_page() && ! $this->is_elementor_admin_screen() ) { | |
| 479 | + return false; | |
| 480 | + } | |
| 481 | + | |
| 482 | + if ( time() < $this->get_install_time() + ( 60 * DAY_IN_SECONDS ) ) { | |
| 483 | + return false; | |
| 484 | + } | |
| 485 | + | |
| 486 | + if ( ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 487 | + return false; | |
| 488 | + } | |
| 489 | + | |
| 490 | + $plugin_file_path = 'send/send-app.php'; | |
| 491 | + $plugin_slug = 'send-app'; | |
| 492 | + | |
| 493 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 494 | + if ( empty( $cta_data ) ) { | |
| 495 | + return false; | |
| 496 | + } | |
| 497 | + | |
| 498 | + $title = sprintf( esc_html__( 'Turn leads into loyal shoppers', 'elementor' ) ); | |
| 499 | + | |
| 500 | + $options = [ | |
| 501 | + 'title' => $title, | |
| 502 | + 'description' => esc_html__( 'Collecting leads is just the beginning. With Send by Elementor, you can manage contacts, launch automations, and turn form submissions into sales.', 'elementor' ), | |
| 503 | + 'id' => $notice_id, | |
| 504 | + 'type' => 'cta', | |
| 505 | + 'button' => [ | |
| 506 | + 'text' => $cta_data['text'], | |
| 507 | + 'url' => $cta_data['url'], | |
| 508 | + 'type' => 'cta', | |
| 509 | + ], | |
| 510 | + 'button_secondary' => [ | |
| 511 | + 'text' => esc_html__( 'Learn more', 'elementor' ), | |
| 512 | + 'url' => 'https://go.elementor.com/Formslearnmore', | |
| 513 | + 'new_tab' => true, | |
| 514 | + 'type' => 'cta', | |
| 515 | + ], | |
| 516 | + ]; | |
| 517 | + | |
| 518 | + $this->print_admin_notice( $options ); | |
| 519 | + | |
| 520 | + return true; | |
| 521 | + } | |
| 522 | + | |
| 473 | 523 | private function notice_local_google_fonts_disabled() { |
| 474 | 524 | |
| 475 | 525 | if ( ! $this->is_elementor_page() && ! $this->is_elementor_admin_screen() ) { |
| 476 | 526 | return false; |
| @@ -521,89 +571,38 @@ | ||
| 521 | 571 | if ( 'edit.php' !== $pagenow || empty( $_GET['post_type'] ) || 'page' !== $_GET['post_type'] ) { |
| 522 | 572 | return false; |
| 523 | 573 | } |
| 524 | 574 | |
| 525 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 575 | + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 526 | 576 | return false; |
| 527 | 577 | } |
| 528 | 578 | |
| 529 | - if ( User::is_user_notice_viewed( $notice_id ) ) { | |
| 530 | - return false; | |
| 531 | - } | |
| 532 | - | |
| 579 | + $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php'; | |
| 533 | 580 | $plugin_slug = 'pojo-accessibility'; |
| 534 | - $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php'; | |
| 535 | 581 | |
| 536 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 537 | - $is_installed = Hints::is_plugin_installed( $plugin_slug ); | |
| 538 | - $is_active = Hints::is_plugin_active( $plugin_slug ); | |
| 539 | - | |
| 540 | - if ( $is_active ) { | |
| 582 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 583 | + if ( empty( $cta_data ) ) { | |
| 541 | 584 | return false; |
| 542 | 585 | } |
| 543 | 586 | |
| 544 | - if ( $one_subscription ) { | |
| 545 | - $learn_more_url = 'https://go.elementor.com/acc-plg-learn-more-one'; | |
| 546 | - | |
| 547 | - if ( ! $is_installed ) { | |
| 548 | - $description = esc_html__( 'Make sure your site has an accessibility statement page. Install Web Accessibility, included in ONE, to create it in a few clicks.', 'elementor' ); | |
| 549 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 550 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 551 | - $campaign_data = [ | |
| 552 | - 'name' => 'elementor_ea11y_campaign', | |
| 553 | - 'campaign' => 'acc-statement-plg-pages-one-install', | |
| 554 | - 'source' => 'wp-pages-one-install', | |
| 555 | - 'medium' => 'wp-dash-one', | |
| 556 | - ]; | |
| 557 | - } elseif ( ! $is_active ) { | |
| 558 | - $description = esc_html__( 'Your ONE subscription includes Web Accessibility. Activate it to create your accessibility statement page quickly.', 'elementor' ); | |
| 559 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 560 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 561 | - $campaign_data = [ | |
| 562 | - 'name' => 'elementor_ea11y_campaign', | |
| 563 | - 'campaign' => 'acc-statement-plg-pages-one-activate', | |
| 564 | - 'source' => 'wp-pages-one-activate', | |
| 565 | - 'medium' => 'wp-dash-one', | |
| 566 | - ]; | |
| 567 | - } | |
| 568 | - } else { | |
| 569 | - $description = esc_html__( "Create a more inclusive site experience for all your visitors. With Web Accessibility, it's easy to add your statement page in just a few clicks.", 'elementor' ); | |
| 570 | - $learn_more_url = 'https://go.elementor.com/acc-plg-learn-more'; | |
| 571 | - | |
| 572 | - if ( ! $is_installed ) { | |
| 573 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 574 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 575 | - $campaign_data = [ | |
| 576 | - 'name' => 'elementor_ea11y_campaign', | |
| 577 | - 'campaign' => 'acc-statement-plg-pages-install', | |
| 578 | - 'source' => 'wp-pages-install', | |
| 579 | - 'medium' => 'wp-dash', | |
| 580 | - ]; | |
| 581 | - } elseif ( ! $is_active ) { | |
| 582 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 583 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 584 | - $campaign_data = [ | |
| 585 | - 'name' => 'elementor_ea11y_campaign', | |
| 586 | - 'campaign' => 'acc-statement-plg-pages-activate', | |
| 587 | - 'source' => 'wp-pages-activate', | |
| 588 | - 'medium' => 'wp-dash', | |
| 589 | - ]; | |
| 590 | - } | |
| 591 | - } | |
| 592 | - | |
| 593 | 587 | $options = [ |
| 594 | 588 | 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ), |
| 595 | - 'description' => $description, | |
| 589 | + 'description' => esc_html__( 'Create a more inclusive site experience for all your visitors. With Ally, it\'s easy to add your statement page in just a few clicks.', 'elementor' ), | |
| 596 | 590 | 'id' => $notice_id, |
| 597 | 591 | 'type' => 'cta', |
| 598 | 592 | 'button' => [ |
| 599 | - 'text' => $button_text, | |
| 600 | - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ), | |
| 593 | + 'text' => $cta_data['text'], | |
| 594 | + 'url' => self::add_plg_campaign_data( $cta_data['url'], [ | |
| 595 | + 'name' => 'elementor_ea11y_campaign', | |
| 596 | + 'campaign' => 'acc-statement-plg-pages', | |
| 597 | + 'source' => 'wp-pages', | |
| 598 | + 'medium' => 'wp-dash', | |
| 599 | + ] ), | |
| 601 | 600 | 'type' => 'cta', |
| 602 | 601 | ], |
| 603 | 602 | 'button_secondary' => [ |
| 604 | 603 | 'text' => esc_html__( 'Learn more', 'elementor' ), |
| 605 | - 'url' => $learn_more_url, | |
| 604 | + 'url' => 'https://go.elementor.com/acc-plg-learn-more', | |
| 606 | 605 | 'new_tab' => true, |
| 607 | 606 | 'type' => 'cta', |
| 608 | 607 | ], |
| 609 | 608 | ]; |
| @@ -629,152 +628,40 @@ | ||
| 629 | 628 | if ( ( Utils::has_pro() && ! $has_woocommerce ) || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) { |
| 630 | 629 | return false; |
| 631 | 630 | } |
| 632 | 631 | |
| 632 | + $plugin_file_path = 'site-mailer/site-mailer.php'; | |
| 633 | 633 | $plugin_slug = 'site-mailer'; |
| 634 | - $plugin_file_path = 'site-mailer/site-mailer.php'; | |
| 635 | 634 | |
| 636 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 637 | - $is_woocommerce = $this->should_render_woocommerce_hint( $has_forms, $has_woocommerce ); | |
| 638 | - $is_installed = Hints::is_plugin_installed( $plugin_slug ); | |
| 639 | - $is_active = Hints::is_plugin_active( $plugin_slug ); | |
| 640 | - | |
| 641 | - if ( $is_active ) { | |
| 635 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 636 | + if ( empty( $cta_data ) ) { | |
| 642 | 637 | return false; |
| 643 | 638 | } |
| 644 | 639 | |
| 645 | - if ( $one_subscription ) { | |
| 646 | - if ( $is_woocommerce ) { | |
| 647 | - $title = esc_html__( 'Improve transactional email deliverability', 'elementor' ); | |
| 648 | - | |
| 649 | - if ( ! $is_installed ) { | |
| 650 | - $description = esc_html__( 'Use Email Deliverability to ensure store emails like purchase confirmations and shipping updates reach the inbox every time. Included in your ONE subscription.', 'elementor' ); | |
| 651 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 652 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 653 | - $campaign_data = [ | |
| 654 | - 'name' => 'elementor_site_mailer_campaign', | |
| 655 | - 'campaign' => 'sm-plg-one', | |
| 656 | - 'source' => 'sm-core-woo-one-install', | |
| 657 | - 'medium' => 'wp-dash', | |
| 658 | - ]; | |
| 659 | - } elseif ( ! $is_active ) { | |
| 660 | - $description = esc_html__( 'Email Deliverability is installed and included in your ONE subscription. Activate it to ensure store emails like purchase confirmations and shipping updates reach the inbox every time.', 'elementor' ); | |
| 661 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 662 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 663 | - $campaign_data = [ | |
| 664 | - 'name' => 'elementor_site_mailer_campaign', | |
| 665 | - 'campaign' => 'sm-plg-one', | |
| 666 | - 'source' => 'sm-core-woo-one-activate', | |
| 667 | - 'medium' => 'wp-dash', | |
| 668 | - ]; | |
| 669 | - } | |
| 670 | - } else { | |
| 671 | - $title = esc_html__( 'Keep your form emails out of the spam folder', 'elementor' ); | |
| 672 | - | |
| 673 | - if ( ! $is_installed ) { | |
| 674 | - $description = esc_html__( 'Use Email Deliverability to ensure emails reach the inbox and track delivery with built-in logs. Included in your ONE subscription.', 'elementor' ); | |
| 675 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 676 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 677 | - $campaign_data = [ | |
| 678 | - 'name' => 'elementor_site_mailer_campaign', | |
| 679 | - 'campaign' => 'sm-plg-one', | |
| 680 | - 'source' => 'sm-core-form-one-install', | |
| 681 | - 'medium' => 'wp-dash', | |
| 682 | - ]; | |
| 683 | - } elseif ( ! $is_active ) { | |
| 684 | - $description = esc_html__( 'Use Email Deliverability to ensure emails reach the inbox and track delivery with built-in logs. Email Deliverability is included in your ONE subscription. Activate it to continue.', 'elementor' ); | |
| 685 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 686 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 687 | - $campaign_data = [ | |
| 688 | - 'name' => 'elementor_site_mailer_campaign', | |
| 689 | - 'campaign' => 'sm-plg-one', | |
| 690 | - 'source' => 'sm-core-form-one-activate', | |
| 691 | - 'medium' => 'wp-dash', | |
| 692 | - ]; | |
| 693 | - } | |
| 694 | - } | |
| 695 | - // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found | |
| 696 | - } else { | |
| 697 | - if ( $is_woocommerce ) { | |
| 698 | - $title = esc_html__( 'Improve Transactional Email Deliverability', 'elementor' ); | |
| 699 | - $description = esc_html__( "Use Elementor's Email Deliverability to ensure your store emails like purchase confirmations, shipping updates and more are reliably delivered.", 'elementor' ); | |
| 700 | - | |
| 701 | - if ( ! $is_installed ) { | |
| 702 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 703 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 704 | - $campaign_data = [ | |
| 705 | - 'name' => 'elementor_site_mailer_campaign', | |
| 706 | - 'campaign' => 'sm-plg', | |
| 707 | - 'source' => 'sm-core-woo-install', | |
| 708 | - 'medium' => 'wp-dash', | |
| 709 | - ]; | |
| 710 | - } elseif ( ! $is_active ) { | |
| 711 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 712 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 713 | - $campaign_data = [ | |
| 714 | - 'name' => 'elementor_site_mailer_campaign', | |
| 715 | - 'campaign' => 'sm-plg', | |
| 716 | - 'source' => 'sm-core-woo-activate', | |
| 717 | - 'medium' => 'wp-dash', | |
| 718 | - ]; | |
| 719 | - } | |
| 720 | - } else { | |
| 721 | - $title = esc_html__( 'Ensure your form emails avoid the spam folder!', 'elementor' ); | |
| 722 | - $description = esc_html__( 'Use Email Deliverability for improved email deliverability, detailed email logs, and an easy setup.', 'elementor' ); | |
| 723 | - | |
| 724 | - if ( ! $is_installed ) { | |
| 725 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 726 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 727 | - $campaign_data = [ | |
| 728 | - 'name' => 'elementor_site_mailer_campaign', | |
| 729 | - 'campaign' => 'sm-plg', | |
| 730 | - 'source' => 'sm-core-form-install', | |
| 731 | - 'medium' => 'wp-dash', | |
| 732 | - ]; | |
| 733 | - } elseif ( ! $is_active ) { | |
| 734 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 735 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 736 | - $campaign_data = [ | |
| 737 | - 'name' => 'elementor_site_mailer_campaign', | |
| 738 | - 'campaign' => 'sm-plg', | |
| 739 | - 'source' => 'sm-core-form-activate', | |
| 740 | - 'medium' => 'wp-dash', | |
| 741 | - ]; | |
| 742 | - } | |
| 743 | - } | |
| 744 | - } | |
| 745 | - | |
| 746 | - $learn_more_url = $one_subscription && $is_woocommerce | |
| 747 | - ? 'https://go.elementor.com/sm-woo-learn-more-one' | |
| 748 | - : 'https://go.elementor.com/sm-core-form/'; | |
| 749 | - | |
| 750 | 640 | $options = [ |
| 751 | - 'title' => $title, | |
| 752 | - 'description' => $description, | |
| 641 | + 'title' => esc_html__( 'Ensure your form emails avoid the spam folder!', 'elementor' ), | |
| 642 | + 'description' => esc_html__( 'Use Site Mailer for improved email deliverability, detailed email logs, and an easy setup.', 'elementor' ), | |
| 753 | 643 | 'id' => $notice_id, |
| 754 | 644 | 'type' => 'cta', |
| 755 | 645 | 'button' => [ |
| 756 | - 'text' => $button_text, | |
| 757 | - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ), | |
| 646 | + 'text' => $cta_data['text'], | |
| 647 | + 'url' => $cta_data['url'], | |
| 758 | 648 | 'type' => 'cta', |
| 759 | - 'data' => [ | |
| 760 | - 'campaign' => $campaign_data['campaign'], | |
| 761 | - 'source' => $campaign_data['source'], | |
| 762 | - 'medium' => $campaign_data['medium'], | |
| 763 | - ], | |
| 764 | 649 | ], |
| 765 | 650 | 'button_secondary' => [ |
| 766 | 651 | 'text' => esc_html__( 'Learn more', 'elementor' ), |
| 767 | - 'url' => $learn_more_url, | |
| 652 | + 'url' => 'https://go.elementor.com/sm-core-form/', | |
| 768 | 653 | 'new_tab' => true, |
| 769 | 654 | 'type' => 'cta', |
| 770 | 655 | ], |
| 771 | 656 | ]; |
| 772 | 657 | |
| 773 | - if ( $is_woocommerce ) { | |
| 658 | + if ( $this->should_render_woocommerce_hint( $has_forms, $has_woocommerce ) ) { | |
| 774 | 659 | // We include WP's default notice class so it will be properly handled by WP's js handler |
| 775 | 660 | // And add a new one to distinguish between the two types of notices |
| 776 | 661 | $options['classes'] = [ 'notice', 'e-notice', 'sm-notice-wc' ]; |
| 662 | + $options['title'] = esc_html__( 'Improve Transactional Email Deliverability', 'elementor' ); | |
| 663 | + $options['description'] = esc_html__( 'Use Elementor\'s Site Mailer to ensure your store emails like purchase confirmations, shipping updates and more are reliably delivered.', 'elementor' ); | |
| 777 | 664 | } |
| 778 | 665 | |
| 779 | 666 | $this->print_admin_notice( $options ); |
| 780 | 667 | |
| @@ -811,31 +698,20 @@ | ||
| 811 | 698 | |
| 812 | 699 | private function is_elementor_admin_screen_with_system_info(): bool { |
| 813 | 700 | return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ); |
| 814 | 701 | } |
| 815 | - private function get_plugin_button_install_url( $plugin_slug ) { | |
| 816 | - return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug ); | |
| 817 | - } | |
| 818 | 702 | |
| 819 | - private function get_plugin_button_activate_url( $plugin_file_path ) { | |
| 820 | - return wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file_path . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin_file_path ); | |
| 821 | - } | |
| 822 | - | |
| 823 | - private function get_plugin_button_connect_url( $plugin_settings_page ) { | |
| 824 | - return self_admin_url( $plugin_settings_page ); | |
| 825 | - } | |
| 826 | - | |
| 827 | 703 | private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) { |
| 828 | - if ( Hints::is_plugin_active( $plugin_slug ) ) { | |
| 704 | + if ( is_plugin_active( $plugin_file_path ) ) { | |
| 829 | 705 | return false; |
| 830 | 706 | } |
| 831 | 707 | |
| 832 | - if ( Hints::is_plugin_installed( $plugin_slug ) ) { | |
| 833 | - $url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 834 | - $cta_text = esc_html__( 'Activate now', 'elementor' ); | |
| 708 | + if ( $this->is_plugin_installed( $plugin_file_path ) ) { | |
| 709 | + $url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file_path . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin_file_path ); | |
| 710 | + $cta_text = esc_html__( 'Activate Plugin', 'elementor' ); | |
| 835 | 711 | } else { |
| 836 | - $url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 837 | - $cta_text = esc_html__( 'Install now', 'elementor' ); | |
| 712 | + $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug ); | |
| 713 | + $cta_text = esc_html__( 'Install Plugin', 'elementor' ); | |
| 838 | 714 | } |
| 839 | 715 | |
| 840 | 716 | return [ |
| 841 | 717 | 'url' => $url, |
| @@ -856,16 +732,12 @@ | ||
| 856 | 732 | if ( 'upload' !== $this->current_screen_id ) { |
| 857 | 733 | return false; |
| 858 | 734 | } |
| 859 | 735 | |
| 860 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 736 | + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 861 | 737 | return false; |
| 862 | 738 | } |
| 863 | 739 | |
| 864 | - if ( User::is_user_notice_viewed( $notice_id ) ) { | |
| 865 | - return false; | |
| 866 | - } | |
| 867 | - | |
| 868 | 740 | $attachments = new \WP_Query( [ |
| 869 | 741 | 'post_type' => 'attachment', |
| 870 | 742 | 'post_status' => 'any', |
| 871 | 743 | 'fields' => 'ids', |
| @@ -874,79 +746,26 @@ | ||
| 874 | 746 | if ( 1 > $attachments->found_posts ) { |
| 875 | 747 | return false; |
| 876 | 748 | } |
| 877 | 749 | |
| 750 | + $plugin_file_path = 'image-optimization/image-optimization.php'; | |
| 878 | 751 | $plugin_slug = 'image-optimization'; |
| 879 | - $plugin_file_path = 'image-optimization/image-optimization.php'; | |
| 880 | 752 | |
| 881 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 882 | - $is_installed = Hints::is_plugin_installed( $plugin_slug ); | |
| 883 | - $is_active = Hints::is_plugin_active( $plugin_slug ); | |
| 753 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 884 | 754 | |
| 885 | - if ( $is_active ) { | |
| 755 | + if ( empty( $cta_data ) ) { | |
| 886 | 756 | return false; |
| 887 | 757 | } |
| 888 | 758 | |
| 889 | - if ( $one_subscription ) { | |
| 890 | - if ( ! $is_installed ) { | |
| 891 | - $description = esc_html__( 'Automatically optimize images to improve site speed and performance. Included with your ONE subscription.', 'elementor' ); | |
| 892 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 893 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 894 | - $campaign_data = [ | |
| 895 | - 'name' => 'elementor_image_optimization_campaign', | |
| 896 | - 'campaign' => 'io-plg-one', | |
| 897 | - 'source' => 'io-wp-media-library-one-install', | |
| 898 | - 'medium' => 'wp-dash-one', | |
| 899 | - ]; | |
| 900 | - } elseif ( ! $is_active ) { | |
| 901 | - $description = esc_html__( 'Your ONE subscription includes Image Optimization. Activate it to optimize images and improve site performance.', 'elementor' ); | |
| 902 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 903 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 904 | - $campaign_data = [ | |
| 905 | - 'name' => 'elementor_image_optimization_campaign', | |
| 906 | - 'campaign' => 'io-plg-one', | |
| 907 | - 'source' => 'io-wp-media-library-one-activate', | |
| 908 | - 'medium' => 'wp-dash-one', | |
| 909 | - ]; | |
| 910 | - } | |
| 911 | - } else { | |
| 912 | - $description = esc_html__( 'Automatically compress and optimize images, resize larger files, or convert to WebP. Optimize images individually, in bulk, or on upload.', 'elementor' ); | |
| 913 | - | |
| 914 | - if ( ! $is_installed ) { | |
| 915 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 916 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 917 | - $campaign_data = [ | |
| 918 | - 'name' => 'elementor_image_optimization_campaign', | |
| 919 | - 'campaign' => 'io-plg', | |
| 920 | - 'source' => 'io-wp-media-library-install', | |
| 921 | - 'medium' => 'wp-dash', | |
| 922 | - ]; | |
| 923 | - } elseif ( ! $is_active ) { | |
| 924 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 925 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 926 | - $campaign_data = [ | |
| 927 | - 'name' => 'elementor_image_optimization_campaign', | |
| 928 | - 'campaign' => 'io-plg', | |
| 929 | - 'source' => 'io-wp-media-library-activate', | |
| 930 | - 'medium' => 'wp-dash', | |
| 931 | - ]; | |
| 932 | - } | |
| 933 | - } | |
| 934 | - | |
| 935 | 759 | $options = [ |
| 936 | - 'title' => esc_html__( 'Speed up your website with Image Optimization', 'elementor' ), | |
| 937 | - 'description' => $description, | |
| 760 | + 'title' => esc_html__( 'Speed up your website with Image Optimizer by Elementor', 'elementor' ), | |
| 761 | + 'description' => esc_html__( 'Automatically compress and optimize images, resize larger files, or convert to WebP. Optimize images individually, in bulk, or on upload.', 'elementor' ), | |
| 938 | 762 | 'id' => $notice_id, |
| 939 | 763 | 'type' => 'cta', |
| 940 | - 'button' => [ | |
| 941 | - 'text' => $button_text, | |
| 942 | - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ), | |
| 764 | + 'button_secondary' => [ | |
| 765 | + 'text' => $cta_data['text'], | |
| 766 | + 'url' => $cta_data['url'], | |
| 943 | 767 | 'type' => 'cta', |
| 944 | - 'data' => [ | |
| 945 | - 'campaign' => $campaign_data['campaign'], | |
| 946 | - 'source' => $campaign_data['source'], | |
| 947 | - 'medium' => $campaign_data['medium'], | |
| 948 | - ], | |
| 949 | 768 | ], |
| 950 | 769 | ]; |
| 951 | 770 | |
| 952 | 771 | $this->print_admin_notice( $options ); |
| @@ -953,8 +772,14 @@ | ||
| 953 | 772 | |
| 954 | 773 | return true; |
| 955 | 774 | } |
| 956 | 775 | |
| 776 | + private function is_plugin_installed( $file_path ): bool { | |
| 777 | + $installed_plugins = get_plugins(); | |
| 778 | + | |
| 779 | + return isset( $installed_plugins[ $file_path ] ); | |
| 780 | + } | |
| 781 | + | |
| 957 | 782 | public function print_admin_notice( array $options, $exclude_pages = self::DEFAULT_EXCLUDED_PAGES ) { |
| 958 | 783 | global $pagenow; |
| 959 | 784 | |
| 960 | 785 | if ( in_array( $pagenow, $exclude_pages, true ) ) { |
| @@ -967,9 +792,9 @@ | ||
| 967 | 792 | 'description' => '', |
| 968 | 793 | 'classes' => [ 'notice', 'e-notice' ], // We include WP's default notice class so it will be properly handled by WP's js handler |
| 969 | 794 | 'type' => '', |
| 970 | 795 | 'dismissible' => true, |
| 971 | - 'icon' => 'eicon-elementor-circle', | |
| 796 | + 'icon' => 'eicon-elementor', | |
| 972 | 797 | 'button' => [], |
| 973 | 798 | 'button_secondary' => [], |
| 974 | 799 | ]; |
| 975 | 800 | |
| @@ -982,12 +807,9 @@ | ||
| 982 | 807 | if ( $options['type'] ) { |
| 983 | 808 | $notice_classes[] = 'e-notice--' . $options['type']; |
| 984 | 809 | } |
| 985 | 810 | |
| 986 | - $wrapper_attributes = [ | |
| 987 | - 'role' => 'region', | |
| 988 | - 'aria-label' => esc_html__( 'Elementor notice', 'elementor' ), | |
| 989 | - ]; | |
| 811 | + $wrapper_attributes = []; | |
| 990 | 812 | |
| 991 | 813 | if ( $options['dismissible'] ) { |
| 992 | 814 | $label = esc_html__( 'Dismiss this notice.', 'elementor' ); |
| 993 | 815 | $notice_classes[] = 'e-notice--dismissible'; |
| @@ -1005,12 +827,8 @@ | ||
| 1005 | 827 | |
| 1006 | 828 | if ( $options['id'] ) { |
| 1007 | 829 | $wrapper_attributes['data-notice_id'] = $options['id']; |
| 1008 | 830 | } |
| 1009 | - | |
| 1010 | - if ( ! empty( $options['source'] ) ) { | |
| 1011 | - $wrapper_attributes['data-source'] = $options['source']; | |
| 1012 | - } | |
| 1013 | 831 | ?> |
| 1014 | 832 | <div <?php Utils::print_html_attributes( $wrapper_attributes ); ?>> |
| 1015 | 833 | <?php echo $dismiss_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 1016 | 834 | <div class="e-notice__aside"> |
| @@ -1027,9 +845,8 @@ | ||
| 1027 | 845 | |
| 1028 | 846 | <?php if ( ! empty( $options['button']['text'] ) || ! empty( $options['button_secondary']['text'] ) ) { ?> |
| 1029 | 847 | <div class="e-notice__actions"> |
| 1030 | 848 | <?php |
| 1031 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 1032 | 849 | foreach ( [ $options['button'], $options['button_secondary'] ] as $index => $button_settings ) { |
| 1033 | 850 | if ( empty( $button_settings['variant'] ) && $index ) { |
| 1034 | 851 | $button_settings['variant'] = 'outline'; |
| 1035 | 852 | } |
| @@ -1037,20 +854,8 @@ | ||
| 1037 | 854 | if ( empty( $button_settings['text'] ) ) { |
| 1038 | 855 | continue; |
| 1039 | 856 | } |
| 1040 | 857 | |
| 1041 | - if ( $one_subscription ) { | |
| 1042 | - if ( ! isset( $button_settings['classes'] ) ) { | |
| 1043 | - $button_settings['classes'] = []; | |
| 1044 | - } | |
| 1045 | - if ( ! is_array( $button_settings['classes'] ) ) { | |
| 1046 | - $button_settings['classes'] = [ $button_settings['classes'] ]; | |
| 1047 | - } | |
| 1048 | - // index 0 = button, index 1 = button_secondary | |
| 1049 | - $button_class = ( 0 === $index ) ? 'button-primary' : 'button-secondary'; | |
| 1050 | - $button_settings['classes'][] = $button_class; | |
| 1051 | - } | |
| 1052 | - | |
| 1053 | 858 | $button = new Button( $button_settings ); |
| 1054 | 859 | $button->print_button(); |
| 1055 | 860 | } ?> |
| 1056 | 861 | </div> |
| @@ -1142,9 +947,8 @@ | ||
| 1142 | 947 | */ |
| 1143 | 948 | public function __construct() { |
| 1144 | 949 | add_action( 'admin_notices', [ $this, 'admin_notices' ], 20 ); |
| 1145 | 950 | add_action( 'admin_action_install-plugin', [ $this, 'maybe_log_campaign' ] ); |
| 1146 | - add_action( 'admin_action_activate', [ $this, 'maybe_log_campaign' ] ); | |
| 1147 | 951 | } |
| 1148 | 952 | |
| 1149 | 953 | /** |
| 1150 | 954 | * Get module name. |