| @@ -3,11 +3,11 @@ | ||
| 3 | 3 | |
| 4 | 4 | use Elementor\Api; |
| 5 | 5 | use Elementor\Core\Admin\UI\Components\Button; |
| 6 | 6 | use Elementor\Core\Base\Module; |
| 7 | -use Elementor\Core\Utils\Hints; | |
| 8 | 7 | use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; |
| 9 | 8 | use Elementor\Plugin; |
| 9 | +use Elementor\Settings; | |
| 10 | 10 | use Elementor\Tracker; |
| 11 | 11 | use Elementor\User; |
| 12 | 12 | use Elementor\Utils; |
| 13 | 13 | use Elementor\Core\Admin\Notices\Base_Notice; |
| @@ -19,10 +19,8 @@ | ||
| 19 | 19 | class Admin_Notices extends Module { |
| 20 | 20 | |
| 21 | 21 | const DEFAULT_EXCLUDED_PAGES = [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ]; |
| 22 | 22 | |
| 23 | - const EXIT_EARLY_FOR_BACKWARD_COMPATIBILITY = false; | |
| 24 | - | |
| 25 | 23 | private $plain_notices = [ |
| 26 | 24 | 'api_notice', |
| 27 | 25 | 'api_upgrade_plugin', |
| 28 | 26 | 'tracker', |
| @@ -28,8 +26,11 @@ | ||
| 28 | 26 | 'tracker', |
| 29 | 27 | 'tracker_last_update', |
| 30 | 28 | 'rate_us_feedback', |
| 31 | 29 | 'role_manager_promote', |
| 30 | + 'experiment_promotion', | |
| 31 | + 'send_app_promotion', | |
| 32 | + 'site_mailer_promotion', | |
| 32 | 33 | 'plugin_image_optimization', |
| 33 | 34 | 'ally_pages_promotion', |
| 34 | 35 | ]; |
| 35 | 36 | |
| @@ -131,16 +132,16 @@ | ||
| 131 | 132 | $message = sprintf( |
| 132 | 133 | /* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text. */ |
| 133 | 134 | __( 'There is a new version of Elementor Page Builder available. <a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">View version %3$s details</a> or <a href="%4$s" class="update-link" aria-label="%5$s">update now</a>.', 'elementor' ), |
| 134 | 135 | esc_url( $details_url ), |
| 135 | - sprintf( | |
| 136 | + esc_attr( sprintf( | |
| 136 | 137 | /* translators: %s: Elementor version. */ |
| 137 | - esc_attr__( 'View Elementor version %s details', 'elementor' ), | |
| 138 | + __( 'View Elementor version %s details', 'elementor' ), | |
| 138 | 139 | $new_version |
| 139 | - ), | |
| 140 | + ) ), | |
| 140 | 141 | $new_version, |
| 141 | 142 | esc_url( $upgrade_url ), |
| 142 | - esc_attr__( 'Update Now', 'elementor' ) | |
| 143 | + esc_attr( esc_html__( 'Update Now', 'elementor' ) ) | |
| 143 | 144 | ); |
| 144 | 145 | |
| 145 | 146 | $options = [ |
| 146 | 147 | 'title' => esc_html__( 'Update Notification', 'elementor' ), |
| @@ -380,8 +381,55 @@ | ||
| 380 | 381 | |
| 381 | 382 | return true; |
| 382 | 383 | } |
| 383 | 384 | |
| 385 | + private function notice_experiment_promotion() { | |
| 386 | + $notice_id = 'experiment_promotion'; | |
| 387 | + | |
| 388 | + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 389 | + return false; | |
| 390 | + } | |
| 391 | + | |
| 392 | + $experiments = Plugin::$instance->experiments; | |
| 393 | + $is_all_performance_features_active = ( | |
| 394 | + $experiments->is_feature_active( 'e_font_icon_svg' ) && | |
| 395 | + $experiments->is_feature_active( 'e_optimized_markup' ) | |
| 396 | + ); | |
| 397 | + | |
| 398 | + if ( $is_all_performance_features_active ) { | |
| 399 | + return false; | |
| 400 | + } | |
| 401 | + | |
| 402 | + $options = [ | |
| 403 | + 'title' => esc_html__( 'Improve your site’s performance score.', 'elementor' ), | |
| 404 | + 'description' => esc_html__( 'With our experimental speed boosting features you can go faster than ever before. Look for the Performance label on our Experiments page and activate those experiments to improve your site loading speed.', 'elementor' ), | |
| 405 | + 'id' => $notice_id, | |
| 406 | + 'button' => [ | |
| 407 | + 'text' => esc_html__( 'Try it out', 'elementor' ), | |
| 408 | + 'url' => Settings::get_settings_tab_url( 'experiments' ), | |
| 409 | + 'type' => 'cta', | |
| 410 | + ], | |
| 411 | + 'button_secondary' => [ | |
| 412 | + 'text' => esc_html__( 'Learn more', 'elementor' ), | |
| 413 | + 'url' => 'https://go.elementor.com/wp-dash-experiment-promotion/', | |
| 414 | + 'new_tab' => true, | |
| 415 | + 'type' => 'cta', | |
| 416 | + ], | |
| 417 | + ]; | |
| 418 | + | |
| 419 | + $this->print_admin_notice( $options ); | |
| 420 | + | |
| 421 | + return true; | |
| 422 | + } | |
| 423 | + | |
| 424 | + private function site_has_forms_plugins() { | |
| 425 | + return defined( 'WPFORMS_VERSION' ) || defined( 'WPCF7_VERSION' ) || defined( 'FLUENTFORM_VERSION' ) || class_exists( '\GFCommon' ) || class_exists( '\Ninja_Forms' ) || function_exists( 'load_formidable_forms' ) || did_action( 'metform/after_load' ) || defined( 'FORMINATOR_PLUGIN_BASENAME' ); | |
| 426 | + } | |
| 427 | + | |
| 428 | + private function site_has_woocommerce() { | |
| 429 | + return class_exists( 'WooCommerce' ); | |
| 430 | + } | |
| 431 | + | |
| 384 | 432 | private function get_installed_form_plugin_name() { |
| 385 | 433 | static $detected_form_plugin = null; |
| 386 | 434 | |
| 387 | 435 | if ( null !== $detected_form_plugin ) { |
| @@ -415,8 +463,56 @@ | ||
| 415 | 463 | $detected_form_plugin = false; |
| 416 | 464 | return $detected_form_plugin; |
| 417 | 465 | } |
| 418 | 466 | |
| 467 | + private function notice_send_app_promotion() { | |
| 468 | + $notice_id = 'send_app_promotion'; | |
| 469 | + | |
| 470 | + if ( ! $this->is_elementor_page() && ! $this->is_elementor_admin_screen() ) { | |
| 471 | + return false; | |
| 472 | + } | |
| 473 | + | |
| 474 | + if ( time() < $this->get_install_time() + ( 60 * DAY_IN_SECONDS ) ) { | |
| 475 | + return false; | |
| 476 | + } | |
| 477 | + | |
| 478 | + if ( ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 479 | + return false; | |
| 480 | + } | |
| 481 | + | |
| 482 | + $plugin_file_path = 'send/send-app.php'; | |
| 483 | + $plugin_slug = 'send-app'; | |
| 484 | + | |
| 485 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 486 | + if ( empty( $cta_data ) ) { | |
| 487 | + return false; | |
| 488 | + } | |
| 489 | + | |
| 490 | + $title = sprintf( esc_html__( 'Turn leads into loyal shoppers', 'elementor' ) ); | |
| 491 | + | |
| 492 | + $options = [ | |
| 493 | + 'title' => $title, | |
| 494 | + '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' ), | |
| 495 | + 'id' => $notice_id, | |
| 496 | + 'type' => 'cta', | |
| 497 | + 'button' => [ | |
| 498 | + 'text' => $cta_data['text'], | |
| 499 | + 'url' => $cta_data['url'], | |
| 500 | + 'type' => 'cta', | |
| 501 | + ], | |
| 502 | + 'button_secondary' => [ | |
| 503 | + 'text' => esc_html__( 'Learn more', 'elementor' ), | |
| 504 | + 'url' => 'https://go.elementor.com/Formslearnmore', | |
| 505 | + 'new_tab' => true, | |
| 506 | + 'type' => 'cta', | |
| 507 | + ], | |
| 508 | + ]; | |
| 509 | + | |
| 510 | + $this->print_admin_notice( $options ); | |
| 511 | + | |
| 512 | + return true; | |
| 513 | + } | |
| 514 | + | |
| 419 | 515 | private function notice_ally_pages_promotion() { |
| 420 | 516 | global $pagenow; |
| 421 | 517 | $notice_id = 'ally_pages_promotion'; |
| 422 | 518 | |
| @@ -423,99 +519,124 @@ | ||
| 423 | 519 | if ( 'edit.php' !== $pagenow || empty( $_GET['post_type'] ) || 'page' !== $_GET['post_type'] ) { |
| 424 | 520 | return false; |
| 425 | 521 | } |
| 426 | 522 | |
| 427 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 523 | + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 428 | 524 | return false; |
| 429 | 525 | } |
| 430 | 526 | |
| 431 | - if ( User::is_user_notice_viewed( $notice_id ) ) { | |
| 527 | + $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php'; | |
| 528 | + $plugin_slug = 'pojo-accessibility'; | |
| 529 | + | |
| 530 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 531 | + if ( empty( $cta_data ) ) { | |
| 432 | 532 | return false; |
| 433 | 533 | } |
| 434 | 534 | |
| 435 | - $plugin_slug = 'pojo-accessibility'; | |
| 436 | - $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php'; | |
| 535 | + $options = [ | |
| 536 | + 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ), | |
| 537 | + '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' ), | |
| 538 | + 'id' => $notice_id, | |
| 539 | + 'type' => 'cta', | |
| 540 | + 'button' => [ | |
| 541 | + 'text' => $cta_data['text'], | |
| 542 | + 'url' => self::add_plg_campaign_data( $cta_data['url'], [ | |
| 543 | + 'name' => 'elementor_ea11y_campaign', | |
| 544 | + 'campaign' => 'acc-statement-plg-pages', | |
| 545 | + 'source' => 'wp-pages', | |
| 546 | + 'medium' => 'wp-dash', | |
| 547 | + ] ), | |
| 548 | + 'type' => 'cta', | |
| 549 | + ], | |
| 550 | + 'button_secondary' => [ | |
| 551 | + 'text' => esc_html__( 'Learn more', 'elementor' ), | |
| 552 | + 'url' => 'https://go.elementor.com/acc-plg-learn-more', | |
| 553 | + 'new_tab' => true, | |
| 554 | + 'type' => 'cta', | |
| 555 | + ], | |
| 556 | + ]; | |
| 437 | 557 | |
| 438 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 439 | - $is_installed = Hints::is_plugin_installed( $plugin_slug ); | |
| 440 | - $is_active = Hints::is_plugin_active( $plugin_slug ); | |
| 558 | + $this->print_admin_notice( $options ); | |
| 441 | 559 | |
| 442 | - if ( $is_active ) { | |
| 560 | + return true; | |
| 561 | + } | |
| 562 | + | |
| 563 | + private function notice_site_mailer_promotion() { | |
| 564 | + $notice_id = 'site_mailer_promotion'; | |
| 565 | + $has_forms = $this->site_has_forms_plugins(); | |
| 566 | + $has_woocommerce = $this->site_has_woocommerce(); | |
| 567 | + | |
| 568 | + if ( ! $has_forms && ! $has_woocommerce ) { | |
| 443 | 569 | return false; |
| 444 | 570 | } |
| 445 | 571 | |
| 446 | - if ( $one_subscription ) { | |
| 447 | - $learn_more_url = 'https://go.elementor.com/acc-plg-learn-more-one'; | |
| 572 | + if ( ! $this->is_elementor_page() && ! $this->is_elementor_admin_screen() ) { | |
| 573 | + return false; | |
| 574 | + } | |
| 448 | 575 | |
| 449 | - if ( ! $is_installed ) { | |
| 450 | - $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' ); | |
| 451 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 452 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 453 | - $campaign_data = [ | |
| 454 | - 'name' => 'elementor_ea11y_campaign', | |
| 455 | - 'campaign' => 'acc-statement-plg-pages-one-install', | |
| 456 | - 'source' => 'wp-pages-one-install', | |
| 457 | - 'medium' => 'wp-dash-one', | |
| 458 | - ]; | |
| 459 | - } elseif ( ! $is_active ) { | |
| 460 | - $description = esc_html__( 'Your ONE subscription includes Web Accessibility. Activate it to create your accessibility statement page quickly.', 'elementor' ); | |
| 461 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 462 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 463 | - $campaign_data = [ | |
| 464 | - 'name' => 'elementor_ea11y_campaign', | |
| 465 | - 'campaign' => 'acc-statement-plg-pages-one-activate', | |
| 466 | - 'source' => 'wp-pages-one-activate', | |
| 467 | - 'medium' => 'wp-dash-one', | |
| 468 | - ]; | |
| 469 | - } | |
| 470 | - } else { | |
| 471 | - $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' ); | |
| 472 | - $learn_more_url = 'https://go.elementor.com/acc-plg-learn-more'; | |
| 576 | + if ( ( Utils::has_pro() && ! $has_woocommerce ) || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 577 | + return false; | |
| 578 | + } | |
| 473 | 579 | |
| 474 | - if ( ! $is_installed ) { | |
| 475 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 476 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 477 | - $campaign_data = [ | |
| 478 | - 'name' => 'elementor_ea11y_campaign', | |
| 479 | - 'campaign' => 'acc-statement-plg-pages-install', | |
| 480 | - 'source' => 'wp-pages-install', | |
| 481 | - 'medium' => 'wp-dash', | |
| 482 | - ]; | |
| 483 | - } elseif ( ! $is_active ) { | |
| 484 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 485 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 486 | - $campaign_data = [ | |
| 487 | - 'name' => 'elementor_ea11y_campaign', | |
| 488 | - 'campaign' => 'acc-statement-plg-pages-activate', | |
| 489 | - 'source' => 'wp-pages-activate', | |
| 490 | - 'medium' => 'wp-dash', | |
| 491 | - ]; | |
| 492 | - } | |
| 580 | + $plugin_file_path = 'site-mailer/site-mailer.php'; | |
| 581 | + $plugin_slug = 'site-mailer'; | |
| 582 | + | |
| 583 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 584 | + if ( empty( $cta_data ) ) { | |
| 585 | + return false; | |
| 493 | 586 | } |
| 494 | 587 | |
| 495 | 588 | $options = [ |
| 496 | - 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ), | |
| 497 | - 'description' => $description, | |
| 589 | + 'title' => esc_html__( 'Ensure your form emails avoid the spam folder!', 'elementor' ), | |
| 590 | + 'description' => esc_html__( 'Use Site Mailer for improved email deliverability, detailed email logs, and an easy setup.', 'elementor' ), | |
| 498 | 591 | 'id' => $notice_id, |
| 499 | 592 | 'type' => 'cta', |
| 500 | 593 | 'button' => [ |
| 501 | - 'text' => $button_text, | |
| 502 | - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ), | |
| 594 | + 'text' => $cta_data['text'], | |
| 595 | + 'url' => $cta_data['url'], | |
| 503 | 596 | 'type' => 'cta', |
| 504 | 597 | ], |
| 505 | 598 | 'button_secondary' => [ |
| 506 | 599 | 'text' => esc_html__( 'Learn more', 'elementor' ), |
| 507 | - 'url' => $learn_more_url, | |
| 600 | + 'url' => 'https://go.elementor.com/sm-core-form/', | |
| 508 | 601 | 'new_tab' => true, |
| 509 | 602 | 'type' => 'cta', |
| 510 | 603 | ], |
| 511 | 604 | ]; |
| 512 | 605 | |
| 606 | + if ( $this->should_render_woocommerce_hint( $has_forms, $has_woocommerce ) ) { | |
| 607 | + // We include WP's default notice class so it will be properly handled by WP's js handler | |
| 608 | + // And add a new one to distinguish between the two types of notices | |
| 609 | + $options['classes'] = [ 'notice', 'e-notice', 'sm-notice-wc' ]; | |
| 610 | + $options['title'] = esc_html__( 'Improve Transactional Email Deliverability', 'elementor' ); | |
| 611 | + $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' ); | |
| 612 | + } | |
| 613 | + | |
| 513 | 614 | $this->print_admin_notice( $options ); |
| 514 | 615 | |
| 515 | 616 | return true; |
| 516 | 617 | } |
| 517 | 618 | |
| 619 | + private function should_render_woocommerce_hint( $has_forms, $has_woocommerce ): bool { | |
| 620 | + if ( ! $has_forms && ! $has_woocommerce ) { | |
| 621 | + return false; | |
| 622 | + } | |
| 623 | + | |
| 624 | + if ( ! $has_forms && $has_woocommerce ) { | |
| 625 | + return true; | |
| 626 | + } | |
| 627 | + | |
| 628 | + if ( $has_forms && $has_woocommerce && Utils::has_pro() ) { | |
| 629 | + return true; | |
| 630 | + } | |
| 631 | + | |
| 632 | + if ( ! $has_woocommerce ) { | |
| 633 | + return false; | |
| 634 | + } | |
| 635 | + | |
| 636 | + return (bool) wp_rand( 0, 1 ); | |
| 637 | + } | |
| 638 | + | |
| 518 | 639 | private function is_elementor_page(): bool { |
| 519 | 640 | return 0 === strpos( $this->current_screen_id, 'elementor_page' ); |
| 520 | 641 | } |
| 521 | 642 | |
| @@ -525,31 +646,20 @@ | ||
| 525 | 646 | |
| 526 | 647 | private function is_elementor_admin_screen_with_system_info(): bool { |
| 527 | 648 | return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ); |
| 528 | 649 | } |
| 529 | - private function get_plugin_button_install_url( $plugin_slug ) { | |
| 530 | - return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug ); | |
| 531 | - } | |
| 532 | 650 | |
| 533 | - private function get_plugin_button_activate_url( $plugin_file_path ) { | |
| 534 | - return wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file_path . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin_file_path ); | |
| 535 | - } | |
| 536 | - | |
| 537 | - private function get_plugin_button_connect_url( $plugin_settings_page ) { | |
| 538 | - return self_admin_url( $plugin_settings_page ); | |
| 539 | - } | |
| 540 | - | |
| 541 | 651 | private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) { |
| 542 | - if ( Hints::is_plugin_active( $plugin_slug ) ) { | |
| 652 | + if ( is_plugin_active( $plugin_file_path ) ) { | |
| 543 | 653 | return false; |
| 544 | 654 | } |
| 545 | 655 | |
| 546 | - if ( Hints::is_plugin_installed( $plugin_slug ) ) { | |
| 547 | - $url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 548 | - $cta_text = esc_html__( 'Activate now', 'elementor' ); | |
| 656 | + if ( $this->is_plugin_installed( $plugin_file_path ) ) { | |
| 657 | + $url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file_path . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin_file_path ); | |
| 658 | + $cta_text = esc_html__( 'Activate Plugin', 'elementor' ); | |
| 549 | 659 | } else { |
| 550 | - $url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 551 | - $cta_text = esc_html__( 'Install now', 'elementor' ); | |
| 660 | + $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug ); | |
| 661 | + $cta_text = esc_html__( 'Install Plugin', 'elementor' ); | |
| 552 | 662 | } |
| 553 | 663 | |
| 554 | 664 | return [ |
| 555 | 665 | 'url' => $url, |
| @@ -570,16 +680,12 @@ | ||
| 570 | 680 | if ( 'upload' !== $this->current_screen_id ) { |
| 571 | 681 | return false; |
| 572 | 682 | } |
| 573 | 683 | |
| 574 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 684 | + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) { | |
| 575 | 685 | return false; |
| 576 | 686 | } |
| 577 | 687 | |
| 578 | - if ( User::is_user_notice_viewed( $notice_id ) ) { | |
| 579 | - return false; | |
| 580 | - } | |
| 581 | - | |
| 582 | 688 | $attachments = new \WP_Query( [ |
| 583 | 689 | 'post_type' => 'attachment', |
| 584 | 690 | 'post_status' => 'any', |
| 585 | 691 | 'fields' => 'ids', |
| @@ -588,79 +694,26 @@ | ||
| 588 | 694 | if ( 1 > $attachments->found_posts ) { |
| 589 | 695 | return false; |
| 590 | 696 | } |
| 591 | 697 | |
| 698 | + $plugin_file_path = 'image-optimization/image-optimization.php'; | |
| 592 | 699 | $plugin_slug = 'image-optimization'; |
| 593 | - $plugin_file_path = 'image-optimization/image-optimization.php'; | |
| 594 | 700 | |
| 595 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 596 | - $is_installed = Hints::is_plugin_installed( $plugin_slug ); | |
| 597 | - $is_active = Hints::is_plugin_active( $plugin_slug ); | |
| 701 | + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path ); | |
| 598 | 702 | |
| 599 | - if ( $is_active ) { | |
| 703 | + if ( empty( $cta_data ) ) { | |
| 600 | 704 | return false; |
| 601 | 705 | } |
| 602 | 706 | |
| 603 | - if ( $one_subscription ) { | |
| 604 | - if ( ! $is_installed ) { | |
| 605 | - $description = esc_html__( 'Automatically optimize images to improve site speed and performance. Included with your ONE subscription.', 'elementor' ); | |
| 606 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 607 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 608 | - $campaign_data = [ | |
| 609 | - 'name' => 'elementor_image_optimization_campaign', | |
| 610 | - 'campaign' => 'io-plg-one', | |
| 611 | - 'source' => 'io-wp-media-library-one-install', | |
| 612 | - 'medium' => 'wp-dash-one', | |
| 613 | - ]; | |
| 614 | - } elseif ( ! $is_active ) { | |
| 615 | - $description = esc_html__( 'Your ONE subscription includes Image Optimization. Activate it to optimize images and improve site performance.', 'elementor' ); | |
| 616 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 617 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 618 | - $campaign_data = [ | |
| 619 | - 'name' => 'elementor_image_optimization_campaign', | |
| 620 | - 'campaign' => 'io-plg-one', | |
| 621 | - 'source' => 'io-wp-media-library-one-activate', | |
| 622 | - 'medium' => 'wp-dash-one', | |
| 623 | - ]; | |
| 624 | - } | |
| 625 | - } else { | |
| 626 | - $description = esc_html__( 'Automatically compress and optimize images, resize larger files, or convert to WebP. Optimize images individually, in bulk, or on upload.', 'elementor' ); | |
| 627 | - | |
| 628 | - if ( ! $is_installed ) { | |
| 629 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 630 | - $button_url = $this->get_plugin_button_install_url( $plugin_slug ); | |
| 631 | - $campaign_data = [ | |
| 632 | - 'name' => 'elementor_image_optimization_campaign', | |
| 633 | - 'campaign' => 'io-plg', | |
| 634 | - 'source' => 'io-wp-media-library-install', | |
| 635 | - 'medium' => 'wp-dash', | |
| 636 | - ]; | |
| 637 | - } elseif ( ! $is_active ) { | |
| 638 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 639 | - $button_url = $this->get_plugin_button_activate_url( $plugin_file_path ); | |
| 640 | - $campaign_data = [ | |
| 641 | - 'name' => 'elementor_image_optimization_campaign', | |
| 642 | - 'campaign' => 'io-plg', | |
| 643 | - 'source' => 'io-wp-media-library-activate', | |
| 644 | - 'medium' => 'wp-dash', | |
| 645 | - ]; | |
| 646 | - } | |
| 647 | - } | |
| 648 | - | |
| 649 | 707 | $options = [ |
| 650 | - 'title' => esc_html__( 'Speed up your website with Image Optimization', 'elementor' ), | |
| 651 | - 'description' => $description, | |
| 708 | + 'title' => esc_html__( 'Speed up your website with Image Optimizer by Elementor', 'elementor' ), | |
| 709 | + 'description' => esc_html__( 'Automatically compress and optimize images, resize larger files, or convert to WebP. Optimize images individually, in bulk, or on upload.', 'elementor' ), | |
| 652 | 710 | 'id' => $notice_id, |
| 653 | 711 | 'type' => 'cta', |
| 654 | - 'button' => [ | |
| 655 | - 'text' => $button_text, | |
| 656 | - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ), | |
| 712 | + 'button_secondary' => [ | |
| 713 | + 'text' => $cta_data['text'], | |
| 714 | + 'url' => $cta_data['url'], | |
| 657 | 715 | 'type' => 'cta', |
| 658 | - 'data' => [ | |
| 659 | - 'campaign' => $campaign_data['campaign'], | |
| 660 | - 'source' => $campaign_data['source'], | |
| 661 | - 'medium' => $campaign_data['medium'], | |
| 662 | - ], | |
| 663 | 716 | ], |
| 664 | 717 | ]; |
| 665 | 718 | |
| 666 | 719 | $this->print_admin_notice( $options ); |
| @@ -667,8 +720,14 @@ | ||
| 667 | 720 | |
| 668 | 721 | return true; |
| 669 | 722 | } |
| 670 | 723 | |
| 724 | + private function is_plugin_installed( $file_path ): bool { | |
| 725 | + $installed_plugins = get_plugins(); | |
| 726 | + | |
| 727 | + return isset( $installed_plugins[ $file_path ] ); | |
| 728 | + } | |
| 729 | + | |
| 671 | 730 | public function print_admin_notice( array $options, $exclude_pages = self::DEFAULT_EXCLUDED_PAGES ) { |
| 672 | 731 | global $pagenow; |
| 673 | 732 | |
| 674 | 733 | if ( in_array( $pagenow, $exclude_pages, true ) ) { |
| @@ -681,9 +740,9 @@ | ||
| 681 | 740 | 'description' => '', |
| 682 | 741 | 'classes' => [ 'notice', 'e-notice' ], // We include WP's default notice class so it will be properly handled by WP's js handler |
| 683 | 742 | 'type' => '', |
| 684 | 743 | 'dismissible' => true, |
| 685 | - 'icon' => 'eicon-elementor-circle', | |
| 744 | + 'icon' => 'eicon-elementor', | |
| 686 | 745 | 'button' => [], |
| 687 | 746 | 'button_secondary' => [], |
| 688 | 747 | ]; |
| 689 | 748 | |
| @@ -696,12 +755,9 @@ | ||
| 696 | 755 | if ( $options['type'] ) { |
| 697 | 756 | $notice_classes[] = 'e-notice--' . $options['type']; |
| 698 | 757 | } |
| 699 | 758 | |
| 700 | - $wrapper_attributes = [ | |
| 701 | - 'role' => 'region', | |
| 702 | - 'aria-label' => esc_html__( 'Elementor notice', 'elementor' ), | |
| 703 | - ]; | |
| 759 | + $wrapper_attributes = []; | |
| 704 | 760 | |
| 705 | 761 | if ( $options['dismissible'] ) { |
| 706 | 762 | $label = esc_html__( 'Dismiss this notice.', 'elementor' ); |
| 707 | 763 | $notice_classes[] = 'e-notice--dismissible'; |
| @@ -719,12 +775,8 @@ | ||
| 719 | 775 | |
| 720 | 776 | if ( $options['id'] ) { |
| 721 | 777 | $wrapper_attributes['data-notice_id'] = $options['id']; |
| 722 | 778 | } |
| 723 | - | |
| 724 | - if ( ! empty( $options['source'] ) ) { | |
| 725 | - $wrapper_attributes['data-source'] = $options['source']; | |
| 726 | - } | |
| 727 | 779 | ?> |
| 728 | 780 | <div <?php Utils::print_html_attributes( $wrapper_attributes ); ?>> |
| 729 | 781 | <?php echo $dismiss_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 730 | 782 | <div class="e-notice__aside"> |
| @@ -741,9 +793,8 @@ | ||
| 741 | 793 | |
| 742 | 794 | <?php if ( ! empty( $options['button']['text'] ) || ! empty( $options['button_secondary']['text'] ) ) { ?> |
| 743 | 795 | <div class="e-notice__actions"> |
| 744 | 796 | <?php |
| 745 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 746 | 797 | foreach ( [ $options['button'], $options['button_secondary'] ] as $index => $button_settings ) { |
| 747 | 798 | if ( empty( $button_settings['variant'] ) && $index ) { |
| 748 | 799 | $button_settings['variant'] = 'outline'; |
| 749 | 800 | } |
| @@ -751,20 +802,8 @@ | ||
| 751 | 802 | if ( empty( $button_settings['text'] ) ) { |
| 752 | 803 | continue; |
| 753 | 804 | } |
| 754 | 805 | |
| 755 | - if ( $one_subscription ) { | |
| 756 | - if ( ! isset( $button_settings['classes'] ) ) { | |
| 757 | - $button_settings['classes'] = []; | |
| 758 | - } | |
| 759 | - if ( ! is_array( $button_settings['classes'] ) ) { | |
| 760 | - $button_settings['classes'] = [ $button_settings['classes'] ]; | |
| 761 | - } | |
| 762 | - // index 0 = button, index 1 = button_secondary | |
| 763 | - $button_class = ( 0 === $index ) ? 'button-primary' : 'button-secondary'; | |
| 764 | - $button_settings['classes'][] = $button_class; | |
| 765 | - } | |
| 766 | - | |
| 767 | 806 | $button = new Button( $button_settings ); |
| 768 | 807 | $button->print_button(); |
| 769 | 808 | } ?> |
| 770 | 809 | </div> |
| @@ -804,8 +843,9 @@ | ||
| 804 | 843 | |
| 805 | 844 | $allowed_plgs = [ |
| 806 | 845 | 'elementor_image_optimization_campaign', |
| 807 | 846 | 'elementor_ea11y_campaign', |
| 847 | + 'elementor_site_mailer_campaign', | |
| 808 | 848 | ]; |
| 809 | 849 | |
| 810 | 850 | if ( ! in_array( $_GET['plg_campaign_name'], $allowed_plgs, true ) ) { |
| 811 | 851 | return; |
| @@ -855,9 +895,8 @@ | ||
| 855 | 895 | */ |
| 856 | 896 | public function __construct() { |
| 857 | 897 | add_action( 'admin_notices', [ $this, 'admin_notices' ], 20 ); |
| 858 | 898 | add_action( 'admin_action_install-plugin', [ $this, 'maybe_log_campaign' ] ); |
| 859 | - add_action( 'admin_action_activate', [ $this, 'maybe_log_campaign' ] ); | |
| 860 | 899 | } |
| 861 | 900 | |
| 862 | 901 | /** |
| 863 | 902 | * Get module name. |