PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.0-beta4
Elementor Website Builder – more than just a page builder v3.29.0-beta4
4.3.2 4.3.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 All 455 releases
← All changes | core/admin/admin-notices.php +148 -247 4.3.2 → 3.29.0-beta4 View file →
@@ -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,17 +19,16 @@
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',
29 - 'tracker_last_update',
30 27 'rate_us_feedback',
31 28 'role_manager_promote',
29 + 'experiment_promotion',
30 + 'site_mailer_promotion',
32 31 'plugin_image_optimization',
33 32 'ally_pages_promotion',
34 33 ];
35 34
@@ -91,9 +90,9 @@
91 90 if ( ! current_user_can( 'update_plugins' ) ) {
92 91 return false;
93 92 }
94 93
95 - 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 ) ) {
96 95 return false;
97 96 }
98 97
99 98 // Check for upgrades.
@@ -131,16 +130,16 @@
131 130 $message = sprintf(
132 131 /* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text. */
133 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' ),
134 133 esc_url( $details_url ),
135 - sprintf(
134 + esc_attr( sprintf(
136 135 /* translators: %s: Elementor version. */
137 - esc_attr__( 'View Elementor version %s details', 'elementor' ),
136 + __( 'View Elementor version %s details', 'elementor' ),
138 137 $new_version
139 - ),
138 + ) ),
140 139 $new_version,
141 140 esc_url( $upgrade_url ),
142 - esc_attr__( 'Update Now', 'elementor' )
141 + esc_attr( esc_html__( 'Update Now', 'elementor' ) )
143 142 );
144 143
145 144 $options = [
146 145 'title' => esc_html__( 'Update Notification', 'elementor' ),
@@ -167,9 +166,9 @@
167 166 if ( ! current_user_can( 'manage_options' ) ) {
168 167 return false;
169 168 }
170 169
171 - 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 ) ) {
172 171 return false;
173 172 }
174 173
175 174 $notice_id = 'admin_notice_api_' . $admin_notice['notice_id'];
@@ -213,9 +212,9 @@
213 212 // TODO: Skip for development env.
214 213 $optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
215 214 $optout_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_out' ), 'opt_out' );
216 215
217 - $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' );
218 217
219 218 /**
220 219 * Tracker admin description text.
221 220 *
@@ -229,9 +228,9 @@
229 228
230 229 $message = esc_html( $tracker_description_text ) . ' <a href="https://go.elementor.com/usage-data-tracking/" target="_blank">' . esc_html__( 'Learn more.', 'elementor' ) . '</a>';
231 230
232 231 $options = [
233 - 'title' => esc_html__( 'Want to shape the future of web creation?', 'elementor' ),
232 + 'title' => esc_html__( 'Love using Elementor?', 'elementor' ),
234 233 'description' => $message,
235 234 'dismissible' => false,
236 235 'button' => [
237 236 'text' => esc_html__( 'Sure! I\'d love to help', 'elementor' ),
@@ -250,49 +249,8 @@
250 249
251 250 return true;
252 251 }
253 252
254 - private function notice_tracker_last_update() {
255 - if ( ! current_user_can( 'manage_options' ) ) {
256 - return false;
257 - }
258 -
259 - if ( ! Tracker::has_terms_changed() ) {
260 - return false;
261 - }
262 -
263 - $notice_id = 'tracker_last_update_' . Tracker::LAST_TERMS_UPDATED;
264 -
265 - if ( User::is_user_notice_viewed( $notice_id ) ) {
266 - return false;
267 - }
268 -
269 - $optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
270 -
271 - $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' );
272 -
273 - $options = [
274 - 'id' => $notice_id,
275 - 'title' => esc_html__( 'Update regarding usage data collection', 'elementor' ),
276 - 'description' => $message,
277 - 'button' => [
278 - 'text' => esc_html__( 'Opt in', 'elementor' ),
279 - 'url' => $optin_url,
280 - 'type' => 'cta',
281 - ],
282 - 'button_secondary' => [
283 - 'text' => esc_html__( 'Learn more', 'elementor' ),
284 - 'url' => 'https://go.elementor.com/wp-dash-update-usage-notice/',
285 - 'new_tab' => true,
286 - 'type' => 'cta',
287 - ],
288 - ];
289 -
290 - $this->print_admin_notice( $options );
291 -
292 - return true;
293 - }
294 -
295 253 private function notice_rate_us_feedback() {
296 254 $notice_id = 'rate_us_feedback';
297 255
298 256 if ( ! current_user_can( 'manage_options' ) ) {
@@ -380,43 +338,55 @@
380 338
381 339 return true;
382 340 }
383 341
384 - private function get_installed_form_plugin_name() {
385 - static $detected_form_plugin = null;
342 + private function notice_experiment_promotion() {
343 + $notice_id = 'experiment_promotion';
386 344
387 - if ( null !== $detected_form_plugin ) {
388 - return $detected_form_plugin;
345 + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
346 + return false;
389 347 }
390 348
391 - $form_plugins_constants_to_name_mapper = [
392 - 'WPFORMS_VERSION' => 'WPForms',
393 - 'WPCF7_VERSION' => 'Contact Form 7',
394 - ];
349 + $experiments = Plugin::$instance->experiments;
350 + $is_all_performance_features_active = (
351 + $experiments->is_feature_active( 'e_element_cache' ) &&
352 + $experiments->is_feature_active( 'e_font_icon_svg' )
353 + );
395 354
396 - foreach ( $form_plugins_constants_to_name_mapper as $constant => $name ) {
397 - if ( defined( $constant ) ) {
398 - $detected_form_plugin = $name;
399 - return $detected_form_plugin;
400 - }
355 + if ( $is_all_performance_features_active ) {
356 + return false;
401 357 }
402 358
403 - $form_plugins_classes_to_name_mapper = [
404 - '\GFCommon' => 'Gravity Forms',
405 - '\Ninja_Forms' => 'Ninja Forms',
359 + $options = [
360 + 'title' => esc_html__( 'Improve your site’s performance score.', 'elementor' ),
361 + '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' ),
362 + 'id' => $notice_id,
363 + 'button' => [
364 + 'text' => esc_html__( 'Try it out', 'elementor' ),
365 + 'url' => Settings::get_settings_tab_url( 'experiments' ),
366 + 'type' => 'cta',
367 + ],
368 + 'button_secondary' => [
369 + 'text' => esc_html__( 'Learn more', 'elementor' ),
370 + 'url' => 'https://go.elementor.com/wp-dash-experiment-promotion/',
371 + 'new_tab' => true,
372 + 'type' => 'cta',
373 + ],
406 374 ];
407 375
408 - foreach ( $form_plugins_classes_to_name_mapper as $class => $name ) {
409 - if ( class_exists( $class ) ) {
410 - $detected_form_plugin = $name;
411 - return $detected_form_plugin;
412 - }
413 - }
376 + $this->print_admin_notice( $options );
414 377
415 - $detected_form_plugin = false;
416 - return $detected_form_plugin;
378 + return true;
417 379 }
418 380
381 + private function site_has_forms_plugins() {
382 + return defined( 'WPFORMS_VERSION' ) || defined( 'WPCF7_VERSION' ) || defined( 'FLUENTFORM_VERSION' ) || class_exists( '\GFCommon' ) || class_exists( '\Ninja_Forms' ) || function_exists( 'load_formidable_forms' );
383 + }
384 +
385 + private function site_has_woocommerce() {
386 + return class_exists( 'WooCommerce' );
387 + }
388 +
419 389 private function notice_ally_pages_promotion() {
420 390 global $pagenow;
421 391 $notice_id = 'ally_pages_promotion';
422 392
@@ -423,133 +393,135 @@
423 393 if ( 'edit.php' !== $pagenow || empty( $_GET['post_type'] ) || 'page' !== $_GET['post_type'] ) {
424 394 return false;
425 395 }
426 396
427 - if ( ! current_user_can( 'manage_options' ) ) {
397 + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
428 398 return false;
429 399 }
430 400
431 - if ( User::is_user_notice_viewed( $notice_id ) ) {
401 + $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php';
402 + $plugin_slug = 'pojo-accessibility';
403 +
404 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
405 + if ( empty( $cta_data ) ) {
432 406 return false;
433 407 }
434 408
435 - $plugin_slug = 'pojo-accessibility';
436 - $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php';
409 + $options = [
410 + 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ),
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' ),
412 + 'id' => $notice_id,
413 + 'type' => 'cta',
414 + 'button' => [
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 + ] ),
422 + 'type' => 'cta',
423 + ],
424 + 'button_secondary' => [
425 + 'text' => esc_html__( 'Learn more', 'elementor' ),
426 + 'url' => 'https://go.elementor.com/acc-plg-learn-more',
427 + 'new_tab' => true,
428 + 'type' => 'cta',
429 + ],
430 + ];
437 431
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 );
432 + $this->print_admin_notice( $options );
441 433
442 - if ( $is_active ) {
434 + return true;
435 + }
436 +
437 + private function notice_site_mailer_promotion() {
438 + $notice_id = 'site_mailer_promotion';
439 + $has_forms = $this->site_has_forms_plugins();
440 + $has_woocommerce = $this->site_has_woocommerce();
441 +
442 + if ( ! $has_forms && ! $has_woocommerce ) {
443 443 return false;
444 444 }
445 445
446 - if ( $one_subscription ) {
447 - $learn_more_url = 'https://go.elementor.com/acc-plg-learn-more-one';
446 + if ( ! $this->is_elementor_page() && ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'dashboard' ], true ) ) {
447 + return false;
448 + }
448 449
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';
450 + if ( ( Utils::has_pro() && ! $has_woocommerce ) || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) {
451 + return false;
452 + }
473 453
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 - }
454 + $plugin_file_path = 'site-mailer/site-mailer.php';
455 + $plugin_slug = 'site-mailer';
456 +
457 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
458 + if ( empty( $cta_data ) ) {
459 + return false;
493 460 }
494 461
495 462 $options = [
496 - 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ),
497 - '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' ),
498 465 'id' => $notice_id,
499 466 'type' => 'cta',
500 467 'button' => [
501 - 'text' => $button_text,
502 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
468 + 'text' => $cta_data['text'],
469 + 'url' => $cta_data['url'],
503 470 'type' => 'cta',
504 471 ],
505 472 'button_secondary' => [
506 473 'text' => esc_html__( 'Learn more', 'elementor' ),
507 - 'url' => $learn_more_url,
474 + 'url' => 'https://go.elementor.com/sm-core-form/',
508 475 'new_tab' => true,
509 476 'type' => 'cta',
510 477 ],
511 478 ];
512 479
480 + if ( $this->should_render_woocommerce_hint( $has_forms, $has_woocommerce ) ) {
481 + // We include WP's default notice class so it will be properly handled by WP's js handler
482 + // And add a new one to distinguish between the two types of notices
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' );
486 + }
487 +
513 488 $this->print_admin_notice( $options );
514 489
515 490 return true;
516 491 }
517 492
518 - private function is_elementor_page(): bool {
519 - return 0 === strpos( $this->current_screen_id, 'elementor_page' );
520 - }
493 + private function should_render_woocommerce_hint( $has_forms, $has_woocommerce ): bool {
494 + if ( ! $has_forms && ! $has_woocommerce ) {
495 + return false;
496 + }
521 497
522 - private function is_elementor_admin_screen(): bool {
523 - return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library' ], true );
524 - }
498 + if ( ! $has_forms && $has_woocommerce ) {
499 + return true;
500 + }
525 501
526 - private function is_elementor_admin_screen_with_system_info(): bool {
527 - return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true );
528 - }
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 - }
502 + if ( $has_forms && $has_woocommerce && Utils::has_pro() ) {
503 + return true;
504 + }
532 505
533 - private function get_plugin_button_activate_url( $plugin_file_path ) {
534 - 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 );
506 + return (bool) wp_rand( 0, 1 );
535 507 }
536 508
537 - private function get_plugin_button_connect_url( $plugin_settings_page ) {
538 - return self_admin_url( $plugin_settings_page );
509 + private function is_elementor_page(): bool {
510 + return 0 === strpos( $this->current_screen_id, 'elementor_page' );
539 511 }
540 512
541 513 private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) {
542 - if ( Hints::is_plugin_active( $plugin_slug ) ) {
514 + if ( is_plugin_active( $plugin_file_path ) ) {
543 515 return false;
544 516 }
545 517
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' );
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' );
549 521 } else {
550 - $url = $this->get_plugin_button_install_url( $plugin_slug );
551 - $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' );
552 524 }
553 525
554 526 return [
555 527 'url' => $url,
@@ -570,16 +542,12 @@
570 542 if ( 'upload' !== $this->current_screen_id ) {
571 543 return false;
572 544 }
573 545
574 - if ( ! current_user_can( 'manage_options' ) ) {
546 + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
575 547 return false;
576 548 }
577 549
578 - if ( User::is_user_notice_viewed( $notice_id ) ) {
579 - return false;
580 - }
581 -
582 550 $attachments = new \WP_Query( [
583 551 'post_type' => 'attachment',
584 552 'post_status' => 'any',
585 553 'fields' => 'ids',
@@ -588,79 +556,26 @@
588 556 if ( 1 > $attachments->found_posts ) {
589 557 return false;
590 558 }
591 559
560 + $plugin_file_path = 'image-optimization/image-optimization.php';
592 561 $plugin_slug = 'image-optimization';
593 - $plugin_file_path = 'image-optimization/image-optimization.php';
594 562
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 );
563 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
598 564
599 - if ( $is_active ) {
565 + if ( empty( $cta_data ) ) {
600 566 return false;
601 567 }
602 568
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 569 $options = [
650 - 'title' => esc_html__( 'Speed up your website with Image Optimization', 'elementor' ),
651 - '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' ),
652 572 'id' => $notice_id,
653 573 'type' => 'cta',
654 - 'button' => [
655 - 'text' => $button_text,
656 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
574 + 'button_secondary' => [
575 + 'text' => $cta_data['text'],
576 + 'url' => $cta_data['url'],
657 577 'type' => 'cta',
658 - 'data' => [
659 - 'campaign' => $campaign_data['campaign'],
660 - 'source' => $campaign_data['source'],
661 - 'medium' => $campaign_data['medium'],
662 - ],
663 578 ],
664 579 ];
665 580
666 581 $this->print_admin_notice( $options );
@@ -667,8 +582,14 @@
667 582
668 583 return true;
669 584 }
670 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 +
671 592 public function print_admin_notice( array $options, $exclude_pages = self::DEFAULT_EXCLUDED_PAGES ) {
672 593 global $pagenow;
673 594
674 595 if ( in_array( $pagenow, $exclude_pages, true ) ) {
@@ -681,9 +602,9 @@
681 602 'description' => '',
682 603 'classes' => [ 'notice', 'e-notice' ], // We include WP's default notice class so it will be properly handled by WP's js handler
683 604 'type' => '',
684 605 'dismissible' => true,
685 - 'icon' => 'eicon-elementor-circle',
606 + 'icon' => 'eicon-elementor',
686 607 'button' => [],
687 608 'button_secondary' => [],
688 609 ];
689 610
@@ -696,12 +617,9 @@
696 617 if ( $options['type'] ) {
697 618 $notice_classes[] = 'e-notice--' . $options['type'];
698 619 }
699 620
700 - $wrapper_attributes = [
701 - 'role' => 'region',
702 - 'aria-label' => esc_html__( 'Elementor notice', 'elementor' ),
703 - ];
621 + $wrapper_attributes = [];
704 622
705 623 if ( $options['dismissible'] ) {
706 624 $label = esc_html__( 'Dismiss this notice.', 'elementor' );
707 625 $notice_classes[] = 'e-notice--dismissible';
@@ -719,12 +637,8 @@
719 637
720 638 if ( $options['id'] ) {
721 639 $wrapper_attributes['data-notice_id'] = $options['id'];
722 640 }
723 -
724 - if ( ! empty( $options['source'] ) ) {
725 - $wrapper_attributes['data-source'] = $options['source'];
726 - }
727 641 ?>
728 642 <div <?php Utils::print_html_attributes( $wrapper_attributes ); ?>>
729 643 <?php echo $dismiss_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
730 644 <div class="e-notice__aside">
@@ -741,9 +655,8 @@
741 655
742 656 <?php if ( ! empty( $options['button']['text'] ) || ! empty( $options['button_secondary']['text'] ) ) { ?>
743 657 <div class="e-notice__actions">
744 658 <?php
745 - $one_subscription = Hints::is_plugin_connected_to_one_subscription();
746 659 foreach ( [ $options['button'], $options['button_secondary'] ] as $index => $button_settings ) {
747 660 if ( empty( $button_settings['variant'] ) && $index ) {
748 661 $button_settings['variant'] = 'outline';
749 662 }
@@ -751,20 +664,8 @@
751 664 if ( empty( $button_settings['text'] ) ) {
752 665 continue;
753 666 }
754 667
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 668 $button = new Button( $button_settings );
768 669 $button->print_button();
769 670 } ?>
770 671 </div>
@@ -804,8 +705,9 @@
804 705
805 706 $allowed_plgs = [
806 707 'elementor_image_optimization_campaign',
807 708 'elementor_ea11y_campaign',
709 + 'elementor_site_mailer_campaign',
808 710 ];
809 711
810 712 if ( ! in_array( $_GET['plg_campaign_name'], $allowed_plgs, true ) ) {
811 713 return;
@@ -831,9 +733,9 @@
831 733
832 734 set_transient( sanitize_key( $_GET['plg_campaign_name'] ), $campaign_data, 30 * DAY_IN_SECONDS );
833 735 }
834 736
835 - public static function add_plg_campaign_data( $url, $campaign_data ) {
737 + private static function add_plg_campaign_data( $url, $campaign_data ) {
836 738
837 739 foreach ( [ 'name', 'campaign' ] as $key ) {
838 740 if ( empty( $campaign_data[ $key ] ) ) {
839 741 return $url;
@@ -855,9 +757,8 @@
855 757 */
856 758 public function __construct() {
857 759 add_action( 'admin_notices', [ $this, 'admin_notices' ], 20 );
858 760 add_action( 'admin_action_install-plugin', [ $this, 'maybe_log_campaign' ] );
859 - add_action( 'admin_action_activate', [ $this, 'maybe_log_campaign' ] );
860 761 }
861 762
862 763 /**
863 764 * Get module name.