PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.4
Elementor Website Builder – more than just a page builder v3.25.4
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 4.1.0-dev1 All 452 releases
← All changes | core/admin/admin-notices.php +134 -322 4.3.0-beta33.25.4 View file →
@@ -3,15 +3,16 @@
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;
14 +use Elementor\Core\Admin\Notices\Elementor_Dev_Notice;
14 15
15 16 if ( ! defined( 'ABSPATH' ) ) {
16 17 exit; // Exit if accessed directly.
17 18 }
@@ -19,19 +20,18 @@
19 20 class Admin_Notices extends Module {
20 21
21 22 const DEFAULT_EXCLUDED_PAGES = [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ];
22 23
23 - const EXIT_EARLY_FOR_BACKWARD_COMPATIBILITY = false;
24 -
25 24 private $plain_notices = [
26 25 'api_notice',
27 26 'api_upgrade_plugin',
28 27 'tracker',
29 - 'tracker_last_update',
30 28 'rate_us_feedback',
31 29 'role_manager_promote',
30 + 'experiment_promotion',
31 + 'site_mailer_promotion',
32 + 'design_not_appearing',
32 33 'plugin_image_optimization',
33 - 'ally_pages_promotion',
34 34 ];
35 35
36 36 private $elementor_pages_count = null;
37 37
@@ -39,8 +39,12 @@
39 39
40 40 private $current_screen_id = null;
41 41
42 42 private function get_notices() {
43 + $notices = [
44 + new Elementor_Dev_Notice(),
45 + ];
46 +
43 47 /**
44 48 * Admin notices.
45 49 *
46 50 * Filters Elementor admin notices.
@@ -49,9 +53,9 @@
49 53 * admin notice or to add new notices for Elementor add-ons.
50 54 *
51 55 * @param array $notices A list of notice classes.
52 56 */
53 - $notices = apply_filters( 'elementor/core/admin/notices', [] );
57 + $notices = apply_filters( 'elementor/core/admin/notices', $notices );
54 58
55 59 return $notices;
56 60 }
57 61
@@ -91,9 +95,9 @@
91 95 if ( ! current_user_can( 'update_plugins' ) ) {
92 96 return false;
93 97 }
94 98
95 - if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
99 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
96 100 return false;
97 101 }
98 102
99 103 // Check for upgrades.
@@ -131,16 +135,16 @@
131 135 $message = sprintf(
132 136 /* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text. */
133 137 __( '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 138 esc_url( $details_url ),
135 - sprintf(
139 + esc_attr( sprintf(
136 140 /* translators: %s: Elementor version. */
137 - esc_attr__( 'View Elementor version %s details', 'elementor' ),
141 + __( 'View Elementor version %s details', 'elementor' ),
138 142 $new_version
139 - ),
143 + ) ),
140 144 $new_version,
141 145 esc_url( $upgrade_url ),
142 - esc_attr__( 'Update Now', 'elementor' )
146 + esc_attr( esc_html__( 'Update Now', 'elementor' ) )
143 147 );
144 148
145 149 $options = [
146 150 'title' => esc_html__( 'Update Notification', 'elementor' ),
@@ -167,9 +171,9 @@
167 171 if ( ! current_user_can( 'manage_options' ) ) {
168 172 return false;
169 173 }
170 174
171 - if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
175 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
172 176 return false;
173 177 }
174 178
175 179 $notice_id = 'admin_notice_api_' . $admin_notice['notice_id'];
@@ -213,9 +217,9 @@
213 217 // TODO: Skip for development env.
214 218 $optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
215 219 $optout_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_out' ), 'opt_out' );
216 220
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' );
221 + $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 222
219 223 /**
220 224 * Tracker admin description text.
221 225 *
@@ -229,11 +233,10 @@
229 233
230 234 $message = esc_html( $tracker_description_text ) . ' <a href="https://go.elementor.com/usage-data-tracking/" target="_blank">' . esc_html__( 'Learn more.', 'elementor' ) . '</a>';
231 235
232 236 $options = [
233 - 'title' => esc_html__( 'Want to shape the future of web creation?', 'elementor' ),
237 + 'title' => esc_html__( 'Love using Elementor?', 'elementor' ),
234 238 'description' => $message,
235 - 'dismissible' => false,
236 239 'button' => [
237 240 'text' => esc_html__( 'Sure! I\'d love to help', 'elementor' ),
238 241 'url' => $optin_url,
239 242 'type' => 'cta',
@@ -250,49 +253,8 @@
250 253
251 254 return true;
252 255 }
253 256
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 257 private function notice_rate_us_feedback() {
296 258 $notice_id = 'rate_us_feedback';
297 259
298 260 if ( ! current_user_can( 'manage_options' ) ) {
@@ -309,9 +271,8 @@
309 271
310 272 $dismiss_url = add_query_arg( [
311 273 'action' => 'elementor_set_admin_notice_viewed',
312 274 'notice_id' => esc_attr( $notice_id ),
313 - '_wpnonce' => wp_create_nonce( 'elementor_set_admin_notice_viewed' ),
314 275 ], admin_url( 'admin-post.php' ) );
315 276
316 277 $options = [
317 278 'title' => esc_html__( 'Congrats!', 'elementor' ),
@@ -380,132 +341,90 @@
380 341
381 342 return true;
382 343 }
383 344
384 - private function get_installed_form_plugin_name() {
385 - static $detected_form_plugin = null;
345 + private function notice_experiment_promotion() {
346 + $notice_id = 'experiment_promotion';
386 347
387 - if ( null !== $detected_form_plugin ) {
388 - return $detected_form_plugin;
348 + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
349 + return false;
389 350 }
390 351
391 - $form_plugins_constants_to_name_mapper = [
392 - 'WPFORMS_VERSION' => 'WPForms',
393 - 'WPCF7_VERSION' => 'Contact Form 7',
394 - ];
352 + $experiments = Plugin::$instance->experiments;
353 + $is_all_performance_features_active = (
354 + $experiments->is_feature_active( 'e_element_cache' ) &&
355 + $experiments->is_feature_active( 'e_font_icon_svg' )
356 + );
395 357
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 - }
358 + if ( $is_all_performance_features_active ) {
359 + return false;
401 360 }
402 361
403 - $form_plugins_classes_to_name_mapper = [
404 - '\GFCommon' => 'Gravity Forms',
405 - '\Ninja_Forms' => 'Ninja Forms',
362 + $options = [
363 + 'title' => esc_html__( 'Improve your site’s performance score.', 'elementor' ),
364 + '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' ),
365 + 'id' => $notice_id,
366 + 'button' => [
367 + 'text' => esc_html__( 'Try it out', 'elementor' ),
368 + 'url' => Settings::get_settings_tab_url( 'experiments' ),
369 + 'type' => 'cta',
370 + ],
371 + 'button_secondary' => [
372 + 'text' => esc_html__( 'Learn more', 'elementor' ),
373 + 'url' => 'https://go.elementor.com/wp-dash-experiment-promotion/',
374 + 'new_tab' => true,
375 + 'type' => 'cta',
376 + ],
406 377 ];
407 378
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 - }
379 + $this->print_admin_notice( $options );
414 380
415 - $detected_form_plugin = false;
416 - return $detected_form_plugin;
381 + return true;
417 382 }
418 383
419 - private function notice_ally_pages_promotion() {
420 - global $pagenow;
421 - $notice_id = 'ally_pages_promotion';
384 + private function notice_site_mailer_promotion() {
385 + $notice_id = 'site_mailer_promotion';
422 386
423 - if ( 'edit.php' !== $pagenow || empty( $_GET['post_type'] ) || 'page' !== $_GET['post_type'] ) {
387 + if (
388 + ! defined( 'WPFORMS_VERSION' )
389 + && ! defined( 'WPCF7_VERSION' )
390 + && ! defined( 'FLUENTFORM_VERSION' )
391 + && ! class_exists( '\GFCommon' )
392 + && ! class_exists( '\Ninja_Forms' )
393 + && ! function_exists( 'load_formidable_forms' )
394 + ) {
424 395 return false;
425 396 }
426 397
427 - if ( ! current_user_can( 'manage_options' ) ) {
398 + if ( ! $this->is_elementor_page() && ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'dashboard' ], true ) ) {
428 399 return false;
429 400 }
430 401
431 - if ( User::is_user_notice_viewed( $notice_id ) ) {
402 + if ( Utils::has_pro() || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) {
432 403 return false;
433 404 }
434 405
435 - $plugin_slug = 'pojo-accessibility';
436 - $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php';
406 + $plugin_file_path = 'site-mailer/site-mailer.php';
407 + $plugin_slug = 'site-mailer';
437 408
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 );
441 -
442 - if ( $is_active ) {
409 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
410 + if ( empty( $cta_data ) ) {
443 411 return false;
444 412 }
445 413
446 - if ( $one_subscription ) {
447 - $learn_more_url = 'https://go.elementor.com/acc-plg-learn-more-one';
448 -
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';
473 -
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 - }
493 - }
494 -
495 414 $options = [
496 - 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ),
497 - 'description' => $description,
415 + 'title' => esc_html__( 'Ensure your form emails avoid the spam folder!', 'elementor' ),
416 + 'description' => esc_html__( 'Use Site Mailer for improved email deliverability, detailed email logs, and an easy setup.', 'elementor' ),
498 417 'id' => $notice_id,
499 418 'type' => 'cta',
500 419 'button' => [
501 - 'text' => $button_text,
502 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
420 + 'text' => $cta_data['text'],
421 + 'url' => $cta_data['url'],
503 422 'type' => 'cta',
504 423 ],
505 424 'button_secondary' => [
506 425 'text' => esc_html__( 'Learn more', 'elementor' ),
507 - 'url' => $learn_more_url,
426 + 'url' => 'https://go.elementor.com/sm-core-form/',
508 427 'new_tab' => true,
509 428 'type' => 'cta',
510 429 ],
511 430 ];
@@ -518,49 +437,69 @@
518 437 private function is_elementor_page(): bool {
519 438 return 0 === strpos( $this->current_screen_id, 'elementor_page' );
520 439 }
521 440
522 - private function is_elementor_admin_screen(): bool {
523 - return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library' ], true );
441 + private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) {
442 + if ( is_plugin_active( $plugin_file_path ) ) {
443 + return false;
444 + }
445 +
446 + if ( $this->is_plugin_installed( $plugin_file_path ) ) {
447 + $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 );
448 + $cta_text = esc_html__( 'Activate Plugin', 'elementor' );
449 + } else {
450 + $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug );
451 + $cta_text = esc_html__( 'Install Plugin', 'elementor' );
452 + }
453 +
454 + return [
455 + 'url' => $url,
456 + 'text' => $cta_text,
457 + ];
524 458 }
525 459
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 - }
460 + private function notice_design_not_appearing() {
461 + $installs_history = get_option( 'elementor_install_history', [] );
462 + $is_first_install = 1 === count( $installs_history );
532 463
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 );
535 - }
464 + if ( $is_first_install || ! current_user_can( 'update_plugins' ) ) {
465 + return false;
466 + }
536 467
537 - private function get_plugin_button_connect_url( $plugin_settings_page ) {
538 - return self_admin_url( $plugin_settings_page );
539 - }
468 + $notice_id = 'design_not_appearing';
469 + $notice = User::get_user_notices()[ $notice_id ] ?? [];
470 + $notice_version = $notice['meta']['version'] ?? null;
471 + $is_version_changed = $this->get_elementor_version() !== $notice_version;
540 472
541 - private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) {
542 - if ( Hints::is_plugin_active( $plugin_slug ) ) {
473 + if ( $is_version_changed ) {
474 + User::set_user_notice( $notice_id, false, [ 'version' => $this->get_elementor_version() ] );
475 + }
476 +
477 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard', 'update-core', 'plugins' ], true ) ) {
543 478 return false;
544 479 }
545 480
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' );
549 - } else {
550 - $url = $this->get_plugin_button_install_url( $plugin_slug );
551 - $cta_text = esc_html__( 'Install now', 'elementor' );
481 + if ( User::is_user_notice_viewed( $notice_id ) ) {
482 + return false;
552 483 }
553 484
554 - return [
555 - 'url' => $url,
556 - 'text' => $cta_text,
485 + $options = [
486 + 'title' => esc_html__( 'The version was updated successfully!', 'elementor' ),
487 + 'description' => sprintf(
488 + esc_html__( 'Encountering issues after updating the version? Don’t worry - we’ve collected all the fixes for troubleshooting common issues. %1$sFind a solution%2$s', 'elementor' ),
489 + '<a href="https://go.elementor.com/wp-dash-changes-do-not-appear-online/" target="_blank">',
490 + '</a>'
491 + ),
492 + 'id' => $notice_id,
557 493 ];
494 +
495 + $excluded_pages = [];
496 + $this->print_admin_notice( $options, $excluded_pages );
497 +
498 + return true;
558 499 }
559 500
560 - /**
561 - * For testing purposes
562 - */
501 + // For testing purposes
563 502 public function get_elementor_version() {
564 503 return ELEMENTOR_VERSION;
565 504 }
566 505
@@ -570,16 +509,12 @@
570 509 if ( 'upload' !== $this->current_screen_id ) {
571 510 return false;
572 511 }
573 512
574 - if ( ! current_user_can( 'manage_options' ) ) {
513 + if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
575 514 return false;
576 515 }
577 516
578 - if ( User::is_user_notice_viewed( $notice_id ) ) {
579 - return false;
580 - }
581 -
582 517 $attachments = new \WP_Query( [
583 518 'post_type' => 'attachment',
584 519 'post_status' => 'any',
585 520 'fields' => 'ids',
@@ -588,79 +523,26 @@
588 523 if ( 1 > $attachments->found_posts ) {
589 524 return false;
590 525 }
591 526
527 + $plugin_file_path = 'image-optimization/image-optimization.php';
592 528 $plugin_slug = 'image-optimization';
593 - $plugin_file_path = 'image-optimization/image-optimization.php';
594 529
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 );
530 + $cta_data = $this->get_plugin_cta_data( $plugin_slug, $plugin_file_path );
598 531
599 - if ( $is_active ) {
532 + if ( empty( $cta_data ) ) {
600 533 return false;
601 534 }
602 535
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 536 $options = [
650 - 'title' => esc_html__( 'Speed up your website with Image Optimization', 'elementor' ),
651 - 'description' => $description,
537 + 'title' => esc_html__( 'Speed up your website with Image Optimizer by Elementor', 'elementor' ),
538 + '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 539 'id' => $notice_id,
653 540 'type' => 'cta',
654 - 'button' => [
655 - 'text' => $button_text,
656 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
541 + 'button_secondary' => [
542 + 'text' => $cta_data['text'],
543 + 'url' => $cta_data['url'],
657 544 'type' => 'cta',
658 - 'data' => [
659 - 'campaign' => $campaign_data['campaign'],
660 - 'source' => $campaign_data['source'],
661 - 'medium' => $campaign_data['medium'],
662 - ],
663 545 ],
664 546 ];
665 547
666 548 $this->print_admin_notice( $options );
@@ -667,8 +549,14 @@
667 549
668 550 return true;
669 551 }
670 552
553 + private function is_plugin_installed( $file_path ): bool {
554 + $installed_plugins = get_plugins();
555 +
556 + return isset( $installed_plugins[ $file_path ] );
557 + }
558 +
671 559 public function print_admin_notice( array $options, $exclude_pages = self::DEFAULT_EXCLUDED_PAGES ) {
672 560 global $pagenow;
673 561
674 562 if ( in_array( $pagenow, $exclude_pages, true ) ) {
@@ -681,9 +569,9 @@
681 569 'description' => '',
682 570 'classes' => [ 'notice', 'e-notice' ], // We include WP's default notice class so it will be properly handled by WP's js handler
683 571 'type' => '',
684 572 'dismissible' => true,
685 - 'icon' => 'eicon-elementor-circle',
573 + 'icon' => 'eicon-elementor',
686 574 'button' => [],
687 575 'button_secondary' => [],
688 576 ];
689 577
@@ -696,19 +584,12 @@
696 584 if ( $options['type'] ) {
697 585 $notice_classes[] = 'e-notice--' . $options['type'];
698 586 }
699 587
700 - $wrapper_attributes = [
701 - 'role' => 'region',
702 - 'aria-label' => esc_html__( 'Elementor notice', 'elementor' ),
703 - ];
704 -
705 588 if ( $options['dismissible'] ) {
706 589 $label = esc_html__( 'Dismiss this notice.', 'elementor' );
707 590 $notice_classes[] = 'e-notice--dismissible';
708 591 $dismiss_button = '<i class="e-notice__dismiss" role="button" aria-label="' . $label . '" tabindex="0"></i>';
709 -
710 - $wrapper_attributes['data-nonce'] = wp_create_nonce( 'elementor_set_admin_notice_viewed' );
711 592 }
712 593
713 594 if ( $options['icon'] ) {
714 595 $notice_classes[] = 'e-notice--extended';
@@ -714,17 +595,15 @@
714 595 $notice_classes[] = 'e-notice--extended';
715 596 $icon = '<div class="e-notice__icon-wrapper"><i class="' . esc_attr( $options['icon'] ) . '" aria-hidden="true"></i></div>';
716 597 }
717 598
718 - $wrapper_attributes['class'] = $notice_classes;
599 + $wrapper_attributes = [
600 + 'class' => $notice_classes,
601 + ];
719 602
720 603 if ( $options['id'] ) {
721 604 $wrapper_attributes['data-notice_id'] = $options['id'];
722 605 }
723 -
724 - if ( ! empty( $options['source'] ) ) {
725 - $wrapper_attributes['data-source'] = $options['source'];
726 - }
727 606 ?>
728 607 <div <?php Utils::print_html_attributes( $wrapper_attributes ); ?>>
729 608 <?php echo $dismiss_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
730 609 <div class="e-notice__aside">
@@ -741,9 +620,8 @@
741 620
742 621 <?php if ( ! empty( $options['button']['text'] ) || ! empty( $options['button_secondary']['text'] ) ) { ?>
743 622 <div class="e-notice__actions">
744 623 <?php
745 - $one_subscription = Hints::is_plugin_connected_to_one_subscription();
746 624 foreach ( [ $options['button'], $options['button_secondary'] ] as $index => $button_settings ) {
747 625 if ( empty( $button_settings['variant'] ) && $index ) {
748 626 $button_settings['variant'] = 'outline';
749 627 }
@@ -751,20 +629,8 @@
751 629 if ( empty( $button_settings['text'] ) ) {
752 630 continue;
753 631 }
754 632
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 633 $button = new Button( $button_settings );
768 634 $button->print_button();
769 635 } ?>
770 636 </div>
@@ -796,60 +662,8 @@
796 662 return;
797 663 }
798 664 }
799 665
800 - public function maybe_log_campaign() {
801 - if ( empty( $_GET['plg_campaign'] ) || empty( $_GET['plg_campaign_name'] ) ) {
802 - return;
803 - }
804 -
805 - $allowed_plgs = [
806 - 'elementor_image_optimization_campaign',
807 - 'elementor_ea11y_campaign',
808 - ];
809 -
810 - if ( ! in_array( $_GET['plg_campaign_name'], $allowed_plgs, true ) ) {
811 - return;
812 - }
813 -
814 - if ( ! isset( $_GET['plg_campaign_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['plg_campaign_nonce'] ), sanitize_key( $_GET['plg_campaign_name'] ) ) ) {
815 - return;
816 - }
817 -
818 - if ( ! current_user_can( 'manage_options' ) ) {
819 - return;
820 - }
821 -
822 - if ( empty( $_GET['plg_source'] ) || empty( $_GET['plg_medium'] ) ) {
823 - return;
824 - }
825 -
826 - $campaign_data = [
827 - 'source' => sanitize_key( $_GET['plg_source'] ),
828 - 'campaign' => sanitize_key( $_GET['plg_campaign'] ),
829 - 'medium' => sanitize_key( $_GET['plg_medium'] ),
830 - ];
831 -
832 - set_transient( sanitize_key( $_GET['plg_campaign_name'] ), $campaign_data, 30 * DAY_IN_SECONDS );
833 - }
834 -
835 - public static function add_plg_campaign_data( $url, $campaign_data ) {
836 -
837 - foreach ( [ 'name', 'campaign' ] as $key ) {
838 - if ( empty( $campaign_data[ $key ] ) ) {
839 - return $url;
840 - }
841 - }
842 -
843 - return add_query_arg( [
844 - 'plg_campaign_name' => $campaign_data['name'],
845 - 'plg_campaign' => $campaign_data['campaign'],
846 - 'plg_source' => empty( $campaign_data['source'] ) ? '' : $campaign_data['source'],
847 - 'plg_medium' => empty( $campaign_data['medium'] ) ? '' : $campaign_data['medium'],
848 - 'plg_campaign_nonce' => wp_create_nonce( $campaign_data['name'] ),
849 - ], $url );
850 - }
851 -
852 666 /**
853 667 * @since 2.9.0
854 668 * @access public
855 669 */
@@ -854,10 +668,8 @@
854 668 * @access public
855 669 */
856 670 public function __construct() {
857 671 add_action( 'admin_notices', [ $this, 'admin_notices' ], 20 );
858 - add_action( 'admin_action_install-plugin', [ $this, 'maybe_log_campaign' ] );
859 - add_action( 'admin_action_activate', [ $this, 'maybe_log_campaign' ] );
860 672 }
861 673
862 674 /**
863 675 * Get module name.