PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.1
Elementor Website Builder – more than just a page builder v3.29.1
4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 All 453 releases
← All changes | core/admin/admin-notices.php +60 -446 4.2.03.29.1 View file →
@@ -3,10 +3,8 @@
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\Upgrade\Manager;
8 -use Elementor\Core\Utils\Hints;
9 7 use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
10 8 use Elementor\Plugin;
11 9 use Elementor\Settings;
12 10 use Elementor\Tracker;
@@ -20,18 +18,13 @@
20 18
21 19 class Admin_Notices extends Module {
22 20
23 21 const DEFAULT_EXCLUDED_PAGES = [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ];
24 - const LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID = 'local_google_fonts_disabled';
25 - const LOCAL_GOOGLE_FONTS_NOTICE_MIN_VERSION = '3.33.3';
26 22
27 - const EXIT_EARLY_FOR_BACKWARD_COMPATIBILITY = false;
28 -
29 23 private $plain_notices = [
30 24 'api_notice',
31 25 'api_upgrade_plugin',
32 26 'tracker',
33 - 'tracker_last_update',
34 27 'rate_us_feedback',
35 28 'role_manager_promote',
36 29 'experiment_promotion',
37 30 'site_mailer_promotion',
@@ -36,9 +29,8 @@
36 29 'experiment_promotion',
37 30 'site_mailer_promotion',
38 31 'plugin_image_optimization',
39 32 'ally_pages_promotion',
40 - self::LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID,
41 33 ];
42 34
43 35 private $elementor_pages_count = null;
44 36
@@ -98,9 +90,9 @@
98 90 if ( ! current_user_can( 'update_plugins' ) ) {
99 91 return false;
100 92 }
101 93
102 - if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
94 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
103 95 return false;
104 96 }
105 97
106 98 // Check for upgrades.
@@ -138,16 +130,16 @@
138 130 $message = sprintf(
139 131 /* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text. */
140 132 __( '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' ),
141 133 esc_url( $details_url ),
142 - sprintf(
134 + esc_attr( sprintf(
143 135 /* translators: %s: Elementor version. */
144 - esc_attr__( 'View Elementor version %s details', 'elementor' ),
136 + __( 'View Elementor version %s details', 'elementor' ),
145 137 $new_version
146 - ),
138 + ) ),
147 139 $new_version,
148 140 esc_url( $upgrade_url ),
149 - esc_attr__( 'Update Now', 'elementor' )
141 + esc_attr( esc_html__( 'Update Now', 'elementor' ) )
150 142 );
151 143
152 144 $options = [
153 145 'title' => esc_html__( 'Update Notification', 'elementor' ),
@@ -174,9 +166,9 @@
174 166 if ( ! current_user_can( 'manage_options' ) ) {
175 167 return false;
176 168 }
177 169
178 - if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
170 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
179 171 return false;
180 172 }
181 173
182 174 $notice_id = 'admin_notice_api_' . $admin_notice['notice_id'];
@@ -220,9 +212,9 @@
220 212 // TODO: Skip for development env.
221 213 $optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
222 214 $optout_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_out' ), 'opt_out' );
223 215
224 - $tracker_description_text = esc_html__( 'Become a super contributor by helping us understand how you use our service to enhance your experience and improve our product.', 'elementor' );
216 + $tracker_description_text = esc_html__( 'Become a super contributor by opting in to share non-sensitive plugin data and to receive periodic email updates from us.', 'elementor' );
225 217
226 218 /**
227 219 * Tracker admin description text.
228 220 *
@@ -236,9 +228,9 @@
236 228
237 229 $message = esc_html( $tracker_description_text ) . ' <a href="https://go.elementor.com/usage-data-tracking/" target="_blank">' . esc_html__( 'Learn more.', 'elementor' ) . '</a>';
238 230
239 231 $options = [
240 - 'title' => esc_html__( 'Want to shape the future of web creation?', 'elementor' ),
232 + 'title' => esc_html__( 'Love using Elementor?', 'elementor' ),
241 233 'description' => $message,
242 234 'dismissible' => false,
243 235 'button' => [
244 236 'text' => esc_html__( 'Sure! I\'d love to help', 'elementor' ),
@@ -257,49 +249,8 @@
257 249
258 250 return true;
259 251 }
260 252
261 - private function notice_tracker_last_update() {
262 - if ( ! current_user_can( 'manage_options' ) ) {
263 - return false;
264 - }
265 -
266 - if ( ! Tracker::has_terms_changed() ) {
267 - return false;
268 - }
269 -
270 - $notice_id = 'tracker_last_update_' . Tracker::LAST_TERMS_UPDATED;
271 -
272 - if ( User::is_user_notice_viewed( $notice_id ) ) {
273 - return false;
274 - }
275 -
276 - $optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
277 -
278 - $message = esc_html__( 'We\'re updating our Terms and Conditions to include the collection of usage and behavioral data. This information helps us understand how you use Elementor so we can make informed improvements to the product.', 'elementor' );
279 -
280 - $options = [
281 - 'id' => $notice_id,
282 - 'title' => esc_html__( 'Update regarding usage data collection', 'elementor' ),
283 - 'description' => $message,
284 - 'button' => [
285 - 'text' => esc_html__( 'Opt in', 'elementor' ),
286 - 'url' => $optin_url,
287 - 'type' => 'cta',
288 - ],
289 - 'button_secondary' => [
290 - 'text' => esc_html__( 'Learn more', 'elementor' ),
291 - 'url' => 'https://go.elementor.com/wp-dash-update-usage-notice/',
292 - 'new_tab' => true,
293 - 'type' => 'cta',
294 - ],
295 - ];
296 -
297 - $this->print_admin_notice( $options );
298 -
299 - return true;
300 - }
301 -
302 253 private function notice_rate_us_feedback() {
303 254 $notice_id = 'rate_us_feedback';
304 255
305 256 if ( ! current_user_can( 'manage_options' ) ) {
@@ -396,10 +347,10 @@
396 347 }
397 348
398 349 $experiments = Plugin::$instance->experiments;
399 350 $is_all_performance_features_active = (
400 - $experiments->is_feature_active( 'e_font_icon_svg' ) &&
401 - $experiments->is_feature_active( 'e_optimized_markup' )
351 + $experiments->is_feature_active( 'e_element_cache' ) &&
352 + $experiments->is_feature_active( 'e_font_icon_svg' )
402 353 );
403 354
404 355 if ( $is_all_performance_features_active ) {
405 356 return false;
@@ -427,9 +378,9 @@
427 378 return true;
428 379 }
429 380
430 381 private function site_has_forms_plugins() {
431 - 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' );
382 + return defined( 'WPFORMS_VERSION' ) || defined( 'WPCF7_VERSION' ) || defined( 'FLUENTFORM_VERSION' ) || class_exists( '\GFCommon' ) || class_exists( '\Ninja_Forms' ) || function_exists( 'load_formidable_forms' );
432 383 }
433 384
434 385 private function site_has_woocommerce() {
435 386 return class_exists( 'WooCommerce' );
@@ -434,87 +385,8 @@
434 385 private function site_has_woocommerce() {
435 386 return class_exists( 'WooCommerce' );
436 387 }
437 388
438 - private function get_installed_form_plugin_name() {
439 - static $detected_form_plugin = null;
440 -
441 - if ( null !== $detected_form_plugin ) {
442 - return $detected_form_plugin;
443 - }
444 -
445 - $form_plugins_constants_to_name_mapper = [
446 - 'WPFORMS_VERSION' => 'WPForms',
447 - 'WPCF7_VERSION' => 'Contact Form 7',
448 - ];
449 -
450 - foreach ( $form_plugins_constants_to_name_mapper as $constant => $name ) {
451 - if ( defined( $constant ) ) {
452 - $detected_form_plugin = $name;
453 - return $detected_form_plugin;
454 - }
455 - }
456 -
457 - $form_plugins_classes_to_name_mapper = [
458 - '\GFCommon' => 'Gravity Forms',
459 - '\Ninja_Forms' => 'Ninja Forms',
460 - ];
461 -
462 - foreach ( $form_plugins_classes_to_name_mapper as $class => $name ) {
463 - if ( class_exists( $class ) ) {
464 - $detected_form_plugin = $name;
465 - return $detected_form_plugin;
466 - }
467 - }
468 -
469 - $detected_form_plugin = false;
470 - return $detected_form_plugin;
471 - }
472 -
473 - private function notice_local_google_fonts_disabled() {
474 -
475 - if ( ! $this->is_elementor_page() && ! $this->is_elementor_admin_screen() ) {
476 - return false;
477 - }
478 -
479 - if ( ! Manager::had_install_prior_to( self::LOCAL_GOOGLE_FONTS_NOTICE_MIN_VERSION ) ) {
480 - return false;
481 - }
482 -
483 - if ( User::is_user_notice_viewed( self::LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID ) ) {
484 - return false;
485 - }
486 -
487 - $is_local_gf_enabled = (bool) get_option( 'elementor_local_google_fonts', '0' );
488 -
489 - if ( $is_local_gf_enabled ) {
490 - return false;
491 - }
492 -
493 - $options = [
494 - 'title' => esc_html__( 'Important: Local Google Fonts Settings in Elementor', 'elementor' ),
495 - 'description' => esc_html__( 'Please note: The "Load Google Fonts Locally" feature has been disabled by default on all websites. To turn it back on, go to Elementor → Settings → Performance → Enable Load Google Fonts Locally.', 'elementor' ),
496 - 'id' => self::LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID,
497 - 'type' => '',
498 - 'button' => [
499 - 'text' => esc_html__( 'Take me there', 'elementor' ),
500 - 'url' => '../wp-admin/admin.php?page=elementor-settings#tab-performance',
501 - 'new_tab' => false,
502 - 'type' => 'cta',
503 - ],
504 - 'button_secondary' => [
505 - 'text' => esc_html__( 'Learn more', 'elementor' ),
506 - 'url' => 'https://go.elementor.com/wp-dash-google-fonts-locally-notice/',
507 - 'new_tab' => true,
508 - 'type' => 'cta',
509 - ],
510 - ];
511 -
512 - $this->print_admin_notice( $options );
513 -
514 - return true;
515 - }
516 -
517 389 private function notice_ally_pages_promotion() {
518 390 global $pagenow;
519 391 $notice_id = 'ally_pages_promotion';
520 392
@@ -521,89 +393,38 @@
521 393 if ( 'edit.php' !== $pagenow || empty( $_GET['post_type'] ) || 'page' !== $_GET['post_type'] ) {
522 394 return false;
523 395 }
524 396
525 - if ( ! current_user_can( 'manage_options' ) ) {
397 + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
526 398 return false;
527 399 }
528 400
529 - if ( User::is_user_notice_viewed( $notice_id ) ) {
530 - return false;
531 - }
532 -
401 + $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php';
533 402 $plugin_slug = 'pojo-accessibility';
534 - $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php';
535 403
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 ) {
404 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
405 + if ( empty( $cta_data ) ) {
541 406 return false;
542 407 }
543 408
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 409 $options = [
594 410 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ),
595 - 'description' => $description,
411 + '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 412 'id' => $notice_id,
597 413 'type' => 'cta',
598 414 'button' => [
599 - 'text' => $button_text,
600 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
415 + 'text' => $cta_data['text'],
416 + 'url' => self::add_plg_campaign_data( $cta_data['url'], [
417 + 'name' => 'elementor_ea11y_campaign',
418 + 'campaign' => 'acc-statement-plg-pages',
419 + 'source' => 'wp-pages',
420 + 'medium' => 'wp-dash',
421 + ] ),
601 422 'type' => 'cta',
602 423 ],
603 424 'button_secondary' => [
604 425 'text' => esc_html__( 'Learn more', 'elementor' ),
605 - 'url' => $learn_more_url,
426 + 'url' => 'https://go.elementor.com/acc-plg-learn-more',
606 427 'new_tab' => true,
607 428 'type' => 'cta',
608 429 ],
609 430 ];
@@ -621,9 +442,9 @@
621 442 if ( ! $has_forms && ! $has_woocommerce ) {
622 443 return false;
623 444 }
624 445
625 - if ( ! $this->is_elementor_page() && ! $this->is_elementor_admin_screen() ) {
446 + if ( ! $this->is_elementor_page() && ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'dashboard' ], true ) ) {
626 447 return false;
627 448 }
628 449
629 450 if ( ( Utils::has_pro() && ! $has_woocommerce ) || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) {
@@ -629,152 +450,40 @@
629 450 if ( ( Utils::has_pro() && ! $has_woocommerce ) || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) {
630 451 return false;
631 452 }
632 453
454 + $plugin_file_path = 'site-mailer/site-mailer.php';
633 455 $plugin_slug = 'site-mailer';
634 - $plugin_file_path = 'site-mailer/site-mailer.php';
635 456
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 ) {
457 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
458 + if ( empty( $cta_data ) ) {
642 459 return false;
643 460 }
644 461
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 462 $options = [
751 - 'title' => $title,
752 - 'description' => $description,
463 + 'title' => esc_html__( 'Ensure your form emails avoid the spam folder!', 'elementor' ),
464 + 'description' => esc_html__( 'Use Site Mailer for improved email deliverability, detailed email logs, and an easy setup.', 'elementor' ),
753 465 'id' => $notice_id,
754 466 'type' => 'cta',
755 467 'button' => [
756 - 'text' => $button_text,
757 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
468 + 'text' => $cta_data['text'],
469 + 'url' => $cta_data['url'],
758 470 'type' => 'cta',
759 - 'data' => [
760 - 'campaign' => $campaign_data['campaign'],
761 - 'source' => $campaign_data['source'],
762 - 'medium' => $campaign_data['medium'],
763 - ],
764 471 ],
765 472 'button_secondary' => [
766 473 'text' => esc_html__( 'Learn more', 'elementor' ),
767 - 'url' => $learn_more_url,
474 + 'url' => 'https://go.elementor.com/sm-core-form/',
768 475 'new_tab' => true,
769 476 'type' => 'cta',
770 477 ],
771 478 ];
772 479
773 - if ( $is_woocommerce ) {
480 + if ( $this->should_render_woocommerce_hint( $has_forms, $has_woocommerce ) ) {
774 481 // We include WP's default notice class so it will be properly handled by WP's js handler
775 482 // And add a new one to distinguish between the two types of notices
776 483 $options['classes'] = [ 'notice', 'e-notice', 'sm-notice-wc' ];
484 + $options['title'] = esc_html__( 'Improve Transactional Email Deliverability', 'elementor' );
485 + $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 486 }
778 487
779 488 $this->print_admin_notice( $options );
780 489
@@ -793,12 +502,8 @@
793 502 if ( $has_forms && $has_woocommerce && Utils::has_pro() ) {
794 503 return true;
795 504 }
796 505
797 - if ( ! $has_woocommerce ) {
798 - return false;
799 - }
800 -
801 506 return (bool) wp_rand( 0, 1 );
802 507 }
803 508
804 509 private function is_elementor_page(): bool {
@@ -804,38 +509,19 @@
804 509 private function is_elementor_page(): bool {
805 510 return 0 === strpos( $this->current_screen_id, 'elementor_page' );
806 511 }
807 512
808 - private function is_elementor_admin_screen(): bool {
809 - return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library' ], true );
810 - }
811 -
812 - private function is_elementor_admin_screen_with_system_info(): bool {
813 - return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true );
814 - }
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 -
819 - private function get_plugin_button_activate_url( $plugin_file_path ) {
820 - return wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin_file_path . '&amp;plugin_status=all&amp;paged=1&amp;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 513 private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) {
828 - if ( Hints::is_plugin_active( $plugin_slug ) ) {
514 + if ( is_plugin_active( $plugin_file_path ) ) {
829 515 return false;
830 516 }
831 517
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' );
518 + if ( $this->is_plugin_installed( $plugin_file_path ) ) {
519 + $url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin_file_path . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin_file_path );
520 + $cta_text = esc_html__( 'Activate Plugin', 'elementor' );
835 521 } else {
836 - $url = $this->get_plugin_button_install_url( $plugin_slug );
837 - $cta_text = esc_html__( 'Install now', 'elementor' );
522 + $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug );
523 + $cta_text = esc_html__( 'Install Plugin', 'elementor' );
838 524 }
839 525
840 526 return [
841 527 'url' => $url,
@@ -856,16 +542,12 @@
856 542 if ( 'upload' !== $this->current_screen_id ) {
857 543 return false;
858 544 }
859 545
860 - if ( ! current_user_can( 'manage_options' ) ) {
546 + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
861 547 return false;
862 548 }
863 549
864 - if ( User::is_user_notice_viewed( $notice_id ) ) {
865 - return false;
866 - }
867 -
868 550 $attachments = new \WP_Query( [
869 551 'post_type' => 'attachment',
870 552 'post_status' => 'any',
871 553 'fields' => 'ids',
@@ -874,79 +556,26 @@
874 556 if ( 1 > $attachments->found_posts ) {
875 557 return false;
876 558 }
877 559
560 + $plugin_file_path = 'image-optimization/image-optimization.php';
878 561 $plugin_slug = 'image-optimization';
879 - $plugin_file_path = 'image-optimization/image-optimization.php';
880 562
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 );
563 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
884 564
885 - if ( $is_active ) {
565 + if ( empty( $cta_data ) ) {
886 566 return false;
887 567 }
888 568
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 569 $options = [
936 - 'title' => esc_html__( 'Speed up your website with Image Optimization', 'elementor' ),
937 - 'description' => $description,
570 + 'title' => esc_html__( 'Speed up your website with Image Optimizer by Elementor', 'elementor' ),
571 + '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 572 'id' => $notice_id,
939 573 'type' => 'cta',
940 - 'button' => [
941 - 'text' => $button_text,
942 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
574 + 'button_secondary' => [
575 + 'text' => $cta_data['text'],
576 + 'url' => $cta_data['url'],
943 577 'type' => 'cta',
944 - 'data' => [
945 - 'campaign' => $campaign_data['campaign'],
946 - 'source' => $campaign_data['source'],
947 - 'medium' => $campaign_data['medium'],
948 - ],
949 578 ],
950 579 ];
951 580
952 581 $this->print_admin_notice( $options );
@@ -953,8 +582,14 @@
953 582
954 583 return true;
955 584 }
956 585
586 + private function is_plugin_installed( $file_path ): bool {
587 + $installed_plugins = get_plugins();
588 +
589 + return isset( $installed_plugins[ $file_path ] );
590 + }
591 +
957 592 public function print_admin_notice( array $options, $exclude_pages = self::DEFAULT_EXCLUDED_PAGES ) {
958 593 global $pagenow;
959 594
960 595 if ( in_array( $pagenow, $exclude_pages, true ) ) {
@@ -967,9 +602,9 @@
967 602 'description' => '',
968 603 'classes' => [ 'notice', 'e-notice' ], // We include WP's default notice class so it will be properly handled by WP's js handler
969 604 'type' => '',
970 605 'dismissible' => true,
971 - 'icon' => 'eicon-elementor-circle',
606 + 'icon' => 'eicon-elementor',
972 607 'button' => [],
973 608 'button_secondary' => [],
974 609 ];
975 610
@@ -982,12 +617,9 @@
982 617 if ( $options['type'] ) {
983 618 $notice_classes[] = 'e-notice--' . $options['type'];
984 619 }
985 620
986 - $wrapper_attributes = [
987 - 'role' => 'region',
988 - 'aria-label' => esc_html__( 'Elementor notice', 'elementor' ),
989 - ];
621 + $wrapper_attributes = [];
990 622
991 623 if ( $options['dismissible'] ) {
992 624 $label = esc_html__( 'Dismiss this notice.', 'elementor' );
993 625 $notice_classes[] = 'e-notice--dismissible';
@@ -1005,12 +637,8 @@
1005 637
1006 638 if ( $options['id'] ) {
1007 639 $wrapper_attributes['data-notice_id'] = $options['id'];
1008 640 }
1009 -
1010 - if ( ! empty( $options['source'] ) ) {
1011 - $wrapper_attributes['data-source'] = $options['source'];
1012 - }
1013 641 ?>
1014 642 <div <?php Utils::print_html_attributes( $wrapper_attributes ); ?>>
1015 643 <?php echo $dismiss_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1016 644 <div class="e-notice__aside">
@@ -1027,9 +655,8 @@
1027 655
1028 656 <?php if ( ! empty( $options['button']['text'] ) || ! empty( $options['button_secondary']['text'] ) ) { ?>
1029 657 <div class="e-notice__actions">
1030 658 <?php
1031 - $one_subscription = Hints::is_plugin_connected_to_one_subscription();
1032 659 foreach ( [ $options['button'], $options['button_secondary'] ] as $index => $button_settings ) {
1033 660 if ( empty( $button_settings['variant'] ) && $index ) {
1034 661 $button_settings['variant'] = 'outline';
1035 662 }
@@ -1037,20 +664,8 @@
1037 664 if ( empty( $button_settings['text'] ) ) {
1038 665 continue;
1039 666 }
1040 667
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 668 $button = new Button( $button_settings );
1054 669 $button->print_button();
1055 670 } ?>
1056 671 </div>
@@ -1118,9 +733,9 @@
1118 733
1119 734 set_transient( sanitize_key( $_GET['plg_campaign_name'] ), $campaign_data, 30 * DAY_IN_SECONDS );
1120 735 }
1121 736
1122 - public static function add_plg_campaign_data( $url, $campaign_data ) {
737 + private static function add_plg_campaign_data( $url, $campaign_data ) {
1123 738
1124 739 foreach ( [ 'name', 'campaign' ] as $key ) {
1125 740 if ( empty( $campaign_data[ $key ] ) ) {
1126 741 return $url;
@@ -1142,9 +757,8 @@
1142 757 */
1143 758 public function __construct() {
1144 759 add_action( 'admin_notices', [ $this, 'admin_notices' ], 20 );
1145 760 add_action( 'admin_action_install-plugin', [ $this, 'maybe_log_campaign' ] );
1146 - add_action( 'admin_action_activate', [ $this, 'maybe_log_campaign' ] );
1147 761 }
1148 762
1149 763 /**
1150 764 * Get module name.