PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.8
Elementor Website Builder – more than just a page builder v3.4.8
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 +150 -398 4.3.0-beta33.4.8 View file →
@@ -3,15 +3,14 @@
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 -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
9 7 use Elementor\Plugin;
10 8 use Elementor\Tracker;
11 9 use Elementor\User;
12 10 use Elementor\Utils;
13 11 use Elementor\Core\Admin\Notices\Base_Notice;
12 +use Elementor\Core\Admin\Notices\Elementor_Dev_Notice;
14 13
15 14 if ( ! defined( 'ABSPATH' ) ) {
16 15 exit; // Exit if accessed directly.
17 16 }
@@ -17,21 +16,18 @@
17 16 }
18 17
19 18 class Admin_Notices extends Module {
20 19
21 - const DEFAULT_EXCLUDED_PAGES = [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ];
22 -
23 - const EXIT_EARLY_FOR_BACKWARD_COMPATIBILITY = false;
24 -
25 20 private $plain_notices = [
26 21 'api_notice',
27 22 'api_upgrade_plugin',
28 23 'tracker',
29 - 'tracker_last_update',
30 24 'rate_us_feedback',
25 + 'woocommerce_promote',
26 + 'cf7_promote',
27 + 'mc4wp_promote',
28 + 'popup_maker_promote',
31 29 'role_manager_promote',
32 - 'plugin_image_optimization',
33 - 'ally_pages_promotion',
34 30 ];
35 31
36 32 private $elementor_pages_count = null;
37 33
@@ -39,8 +35,12 @@
39 35
40 36 private $current_screen_id = null;
41 37
42 38 private function get_notices() {
39 + $notices = [
40 + new Elementor_Dev_Notice(),
41 + ];
42 +
43 43 /**
44 44 * Admin notices.
45 45 *
46 46 * Filters Elementor admin notices.
@@ -45,13 +45,13 @@
45 45 *
46 46 * Filters Elementor admin notices.
47 47 *
48 48 * This hook can be used by external developers to manage existing
49 - * admin notice or to add new notices for Elementor add-ons.
49 + * admin notice or to add new notices for Elementor addons.
50 50 *
51 51 * @param array $notices A list of notice classes.
52 52 */
53 - $notices = apply_filters( 'elementor/core/admin/notices', [] );
53 + $notices = apply_filters( 'elementor/core/admin/notices', $notices );
54 54
55 55 return $notices;
56 56 }
57 57
@@ -65,9 +65,8 @@
65 65
66 66 private function get_elementor_pages_count() {
67 67 if ( null === $this->elementor_pages_count ) {
68 68 $elementor_pages = new \WP_Query( [
69 - 'no_found_rows' => true,
70 69 'post_type' => 'any',
71 70 'post_status' => 'publish',
72 71 'fields' => 'ids',
73 72 'update_post_meta_cache' => false,
@@ -91,13 +90,13 @@
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 - // Check for upgrades.
98 + // Check if have any upgrades.
100 99 $update_plugins = get_site_transient( 'update_plugins' );
101 100
102 101 $has_remote_update_package = ! ( empty( $update_plugins ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ] ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]->package ) );
103 102
@@ -117,9 +116,9 @@
117 116
118 117 $new_version = $upgrade_notice['version'];
119 118 }
120 119
121 - // Check if upgrade messages should be shown.
120 + // Check if have upgrade notices to show.
122 121 if ( version_compare( ELEMENTOR_VERSION, $upgrade_notice['version'], '>=' ) ) {
123 122 return false;
124 123 }
125 124
@@ -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 Elementor 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,11 +228,10 @@
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 - 'dismissible' => false,
236 234 'button' => [
237 235 'text' => esc_html__( 'Sure! I\'d love to help', 'elementor' ),
238 236 'url' => $optin_url,
239 237 'type' => 'cta',
@@ -250,49 +248,8 @@
250 248
251 249 return true;
252 250 }
253 251
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 252 private function notice_rate_us_feedback() {
296 253 $notice_id = 'rate_us_feedback';
297 254
298 255 if ( ! current_user_can( 'manage_options' ) ) {
@@ -309,14 +266,14 @@
309 266
310 267 $dismiss_url = add_query_arg( [
311 268 'action' => 'elementor_set_admin_notice_viewed',
312 269 'notice_id' => esc_attr( $notice_id ),
313 - '_wpnonce' => wp_create_nonce( 'elementor_set_admin_notice_viewed' ),
314 270 ], admin_url( 'admin-post.php' ) );
315 271
316 272 $options = [
317 273 'title' => esc_html__( 'Congrats!', 'elementor' ),
318 - 'description' => esc_html__( 'You created over 10 pages with Elementor. Great job! If you can spare a minute, please help us by leaving a five star review on WordPress.org.', 'elementor' ),
274 + 'description' => esc_html__( 'You created over 10 pages with Elementor. Great job! If you can spare a minute,
275 + please help us by leaving a five star review on WordPress.org.', 'elementor' ),
319 276 'id' => $notice_id,
320 277 'button' => [
321 278 'text' => esc_html__( 'Happy To Help', 'elementor' ),
322 279 'url' => 'https://go.elementor.com/admin-review/',
@@ -336,176 +293,122 @@
336 293
337 294 return true;
338 295 }
339 296
340 - private function notice_role_manager_promote() {
341 - $notice_id = 'role_manager_promote';
297 + private function notice_woocommerce_promote() {
298 + $notice_id = 'woocommerce_promote';
342 299
343 - if ( Utils::has_pro() ) {
300 + if ( Utils::has_pro() || ! function_exists( 'WC' ) ) {
344 301 return false;
345 302 }
346 303
347 - if ( ! current_user_can( 'manage_options' ) ) {
304 + if ( ! current_user_can( 'install_plugins' ) ) {
348 305 return false;
349 306 }
350 307
351 - if ( 'elementor_page_elementor-role-manager' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
308 + if ( ! in_array( $this->current_screen_id, [ 'edit-product', 'woocommerce_page_wc-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
352 309 return false;
353 310 }
354 311
355 - $users = new \WP_User_Query( [
356 - 'fields' => 'ID',
357 - 'number' => 10,
358 - ] );
312 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
313 + return false;
314 + }
359 315
360 - if ( 5 > $users->get_total() ) {
316 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
361 317 return false;
362 318 }
363 319
364 320 $options = [
365 - 'title' => esc_html__( 'Managing a multi-user site?', 'elementor' ),
366 - 'description' => esc_html__( 'With Elementor Pro, you can control user access and make sure no one messes up your design.', 'elementor' ),
321 + 'title' => esc_html__( 'Using WooCommerce?', 'elementor' ),
322 + 'description' => esc_html__( 'With Elementor Pro’s WooCommerce Builder, you’ll be able to design your store without coding!', 'elementor' ),
367 323 'id' => $notice_id,
368 324
369 325 'button' => [
370 326 'text' => esc_html__( 'Learn More', 'elementor' ),
371 - 'url' => 'https://go.elementor.com/plugin-promotion-role-manager/',
327 + 'url' => 'https://go.elementor.com/plugin-promotion-woocommerce/',
372 328 'new_tab' => true,
373 329 'type' => 'cta',
374 330 ],
375 331 ];
376 332
377 - $options = Filtered_Promotions_Manager::get_filtered_promotion_data( $options, 'core/admin/notice_role_manager_promote', 'button', 'url' );
378 -
379 333 $this->print_admin_notice( $options );
380 334
381 335 return true;
382 336 }
383 337
384 - private function get_installed_form_plugin_name() {
385 - static $detected_form_plugin = null;
338 + private function notice_cf7_promote() {
339 + $notice_id = 'cf7_promote';
386 340
387 - if ( null !== $detected_form_plugin ) {
388 - return $detected_form_plugin;
341 + if ( Utils::has_pro() || ! defined( 'WPCF7_VERSION' ) ) {
342 + return false;
389 343 }
390 344
391 - $form_plugins_constants_to_name_mapper = [
392 - 'WPFORMS_VERSION' => 'WPForms',
393 - 'WPCF7_VERSION' => 'Contact Form 7',
394 - ];
345 + if ( ! current_user_can( 'install_plugins' ) ) {
346 + return false;
347 + }
395 348
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 - }
349 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_wpcf7', 'contact_page_wpcf7-integration' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
350 + return false;
401 351 }
402 352
403 - $form_plugins_classes_to_name_mapper = [
404 - '\GFCommon' => 'Gravity Forms',
405 - '\Ninja_Forms' => 'Ninja Forms',
353 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
354 + return false;
355 + }
356 +
357 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
358 + return false;
359 + }
360 +
361 + $options = [
362 + 'title' => esc_html__( 'Using Elementor & Contact Form 7?', 'elementor' ),
363 + 'description' => esc_html__( 'Try out Elementor Pro and design your forms visually with one powerful tool.', 'elementor' ),
364 +
365 + 'id' => $notice_id,
366 + 'button' => [
367 + 'text' => esc_html__( 'Learn More', 'elementor' ),
368 + 'url' => 'https://go.elementor.com/plugin-promotion-contactform7/',
369 + 'new_tab' => true,
370 + 'type' => 'cta',
371 + ],
406 372 ];
407 373
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 - }
374 + $this->print_admin_notice( $options );
414 375
415 - $detected_form_plugin = false;
416 - return $detected_form_plugin;
376 + return true;
417 377 }
418 378
419 - private function notice_ally_pages_promotion() {
420 - global $pagenow;
421 - $notice_id = 'ally_pages_promotion';
379 + private function notice_mc4wp_promote() {
380 + $notice_id = 'mc4wp_promote';
422 381
423 - if ( 'edit.php' !== $pagenow || empty( $_GET['post_type'] ) || 'page' !== $_GET['post_type'] ) {
382 + if ( Utils::has_pro() || ! defined( 'MC4WP_VERSION' ) ) {
424 383 return false;
425 384 }
426 385
427 - if ( ! current_user_can( 'manage_options' ) ) {
386 + if ( ! current_user_can( 'install_plugins' ) ) {
428 387 return false;
429 388 }
430 389
431 - if ( User::is_user_notice_viewed( $notice_id ) ) {
390 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_mailchimp-for-wp', 'mc4wp_page_mailchimp-for-wp-forms', 'mc4wp_page_mailchimp-for-wp-integrations', 'mc4wp_page_mailchimp-for-wp-other', 'mc4wp_page_mailchimp-for-wp-extensions' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
432 391 return false;
433 392 }
434 393
435 - $plugin_slug = 'pojo-accessibility';
436 - $plugin_file_path = 'pojo-accessibility/pojo-accessibility.php';
437 -
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 ) {
394 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
443 395 return false;
444 396 }
445 397
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 - }
398 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
399 + return false;
493 400 }
494 401
495 402 $options = [
496 - 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ),
497 - 'description' => $description,
403 + 'title' => esc_html__( 'Want to design better MailChimp forms?', 'elementor' ),
404 + 'description' => esc_html__( 'Use Elementor Pro and enjoy unlimited integrations, visual design, templates and more.', 'elementor' ),
405 + 'dismissible' => true,
498 406 'id' => $notice_id,
499 - 'type' => 'cta',
407 +
500 408 'button' => [
501 - 'text' => $button_text,
502 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
503 - 'type' => 'cta',
504 - ],
505 - 'button_secondary' => [
506 - 'text' => esc_html__( 'Learn more', 'elementor' ),
507 - 'url' => $learn_more_url,
409 + 'text' => esc_html__( 'Learn More', 'elementor' ),
410 + 'url' => 'https://go.elementor.com/plugin-promotion-mc4wp/',
508 411 'new_tab' => true,
509 412 'type' => 'cta',
510 413 ],
511 414 ];
@@ -514,61 +417,54 @@
514 417
515 418 return true;
516 419 }
517 420
518 - private function is_elementor_page(): bool {
519 - return 0 === strpos( $this->current_screen_id, 'elementor_page' );
520 - }
421 + private function notice_popup_maker_promote() {
422 + $notice_id = 'popup_maker_promote';
521 423
522 - private function is_elementor_admin_screen(): bool {
523 - return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library' ], true );
524 - }
424 + if ( Utils::has_pro() || ! class_exists( 'Popup_Maker' ) ) {
425 + return false;
426 + }
525 427
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 - }
428 + if ( ! current_user_can( 'install_plugins' ) ) {
429 + return false;
430 + }
532 431
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 - }
432 + if ( ! in_array( $this->current_screen_id, [ 'edit-popup', 'popup_page_pum-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
433 + return false;
434 + }
536 435
537 - private function get_plugin_button_connect_url( $plugin_settings_page ) {
538 - return self_admin_url( $plugin_settings_page );
539 - }
436 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
437 + return false;
438 + }
540 439
541 - private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) {
542 - if ( Hints::is_plugin_active( $plugin_slug ) ) {
440 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
543 441 return false;
544 442 }
545 443
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' );
552 - }
444 + $options = [
445 + 'title' => esc_html__( 'Using popups on your site?', 'elementor' ),
446 + 'description' => esc_html__( 'Build outstanding popups using Elementor Pro and get more leads, sales and subscribers.', 'elementor' ),
447 + 'dismissible' => true,
448 + 'id' => $notice_id,
553 449
554 - return [
555 - 'url' => $url,
556 - 'text' => $cta_text,
450 + 'button' => [
451 + 'text' => esc_html__( 'Learn More', 'elementor' ),
452 + 'url' => 'https://go.elementor.com/plugin-promotion-popupmaker/',
453 + 'new_tab' => true,
454 + 'type' => 'cta',
455 + ],
557 456 ];
558 - }
559 457
560 - /**
561 - * For testing purposes
562 - */
563 - public function get_elementor_version() {
564 - return ELEMENTOR_VERSION;
458 + $this->print_admin_notice( $options );
459 +
460 + return true;
565 461 }
566 462
567 - private function notice_plugin_image_optimization() {
568 - $notice_id = 'plugin_image_optimization';
463 + private function notice_role_manager_promote() {
464 + $notice_id = 'role_manager_promote';
569 465
570 - if ( 'upload' !== $this->current_screen_id ) {
466 + if ( Utils::has_pro() ) {
571 467 return false;
572 468 }
573 469
574 470 if ( ! current_user_can( 'manage_options' ) ) {
@@ -574,93 +470,31 @@
574 470 if ( ! current_user_can( 'manage_options' ) ) {
575 471 return false;
576 472 }
577 473
578 - if ( User::is_user_notice_viewed( $notice_id ) ) {
474 + if ( 'elementor_page_elementor-role-manager' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
579 475 return false;
580 476 }
581 477
582 - $attachments = new \WP_Query( [
583 - 'post_type' => 'attachment',
584 - 'post_status' => 'any',
585 - 'fields' => 'ids',
478 + $users = new \WP_User_Query( [
479 + 'fields' => 'ID',
480 + 'number' => 10,
586 481 ] );
587 482
588 - if ( 1 > $attachments->found_posts ) {
483 + if ( 5 > $users->get_total() ) {
589 484 return false;
590 485 }
591 486
592 - $plugin_slug = 'image-optimization';
593 - $plugin_file_path = 'image-optimization/image-optimization.php';
594 -
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 );
598 -
599 - if ( $is_active ) {
600 - return false;
601 - }
602 -
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 487 $options = [
650 - 'title' => esc_html__( 'Speed up your website with Image Optimization', 'elementor' ),
651 - 'description' => $description,
488 + 'title' => esc_html__( 'Managing a multi-user site?', 'elementor' ),
489 + 'description' => esc_html__( 'With Elementor Pro, you can control user access and make sure no one messes up your design.', 'elementor' ),
652 490 'id' => $notice_id,
653 - 'type' => 'cta',
491 +
654 492 'button' => [
655 - 'text' => $button_text,
656 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
493 + 'text' => esc_html__( 'Learn More', 'elementor' ),
494 + 'url' => 'https://go.elementor.com/plugin-promotion-role-manager/',
495 + 'new_tab' => true,
657 496 'type' => 'cta',
658 - 'data' => [
659 - 'campaign' => $campaign_data['campaign'],
660 - 'source' => $campaign_data['source'],
661 - 'medium' => $campaign_data['medium'],
662 - ],
663 497 ],
664 498 ];
665 499
666 500 $this->print_admin_notice( $options );
@@ -667,15 +501,9 @@
667 501
668 502 return true;
669 503 }
670 504
671 - public function print_admin_notice( array $options, $exclude_pages = self::DEFAULT_EXCLUDED_PAGES ) {
672 - global $pagenow;
673 -
674 - if ( in_array( $pagenow, $exclude_pages, true ) ) {
675 - return;
676 - }
677 -
505 + public function print_admin_notice( array $options ) {
678 506 $default_options = [
679 507 'id' => null,
680 508 'title' => '',
681 509 'description' => '',
@@ -681,9 +509,9 @@
681 509 'description' => '',
682 510 'classes' => [ 'notice', 'e-notice' ], // We include WP's default notice class so it will be properly handled by WP's js handler
683 511 'type' => '',
684 512 'dismissible' => true,
685 - 'icon' => 'eicon-elementor-circle',
513 + 'icon' => 'eicon-elementor',
686 514 'button' => [],
687 515 'button_secondary' => [],
688 516 ];
689 517
@@ -696,19 +524,12 @@
696 524 if ( $options['type'] ) {
697 525 $notice_classes[] = 'e-notice--' . $options['type'];
698 526 }
699 527
700 - $wrapper_attributes = [
701 - 'role' => 'region',
702 - 'aria-label' => esc_html__( 'Elementor notice', 'elementor' ),
703 - ];
704 -
705 528 if ( $options['dismissible'] ) {
706 - $label = esc_html__( 'Dismiss this notice.', 'elementor' );
529 + $label = esc_html__( 'Dismiss', 'elementor' );
707 530 $notice_classes[] = 'e-notice--dismissible';
708 531 $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 532 }
712 533
713 534 if ( $options['icon'] ) {
714 535 $notice_classes[] = 'e-notice--extended';
@@ -714,17 +535,15 @@
714 535 $notice_classes[] = 'e-notice--extended';
715 536 $icon = '<div class="e-notice__icon-wrapper"><i class="' . esc_attr( $options['icon'] ) . '" aria-hidden="true"></i></div>';
716 537 }
717 538
718 - $wrapper_attributes['class'] = $notice_classes;
539 + $wrapper_attributes = [
540 + 'class' => $notice_classes,
541 + ];
719 542
720 543 if ( $options['id'] ) {
721 544 $wrapper_attributes['data-notice_id'] = $options['id'];
722 545 }
723 -
724 - if ( ! empty( $options['source'] ) ) {
725 - $wrapper_attributes['data-source'] = $options['source'];
726 - }
727 546 ?>
728 547 <div <?php Utils::print_html_attributes( $wrapper_attributes ); ?>>
729 548 <?php echo $dismiss_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
730 549 <div class="e-notice__aside">
@@ -730,49 +549,36 @@
730 549 <div class="e-notice__aside">
731 550 <?php echo $icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
732 551 </div>
733 552 <div class="e-notice__content">
734 - <?php if ( $options['title'] ) { ?>
735 - <h3><?php echo wp_kses_post( $options['title'] ); ?></h3>
736 - <?php } ?>
553 + <?php if ( $options['title'] ) { ?>
554 + <h3><?php echo wp_kses_post( $options['title'] ); ?></h3>
555 + <?php } ?>
737 556
738 - <?php if ( $options['description'] ) { ?>
739 - <p><?php echo wp_kses_post( $options['description'] ); ?></p>
740 - <?php } ?>
557 + <?php if ( $options['description'] ) { ?>
558 + <p><?php echo wp_kses_post( $options['description'] ); ?></p>
559 + <?php } ?>
741 560
742 - <?php if ( ! empty( $options['button']['text'] ) || ! empty( $options['button_secondary']['text'] ) ) { ?>
743 - <div class="e-notice__actions">
744 - <?php
745 - $one_subscription = Hints::is_plugin_connected_to_one_subscription();
746 - foreach ( [ $options['button'], $options['button_secondary'] ] as $index => $button_settings ) {
747 - if ( empty( $button_settings['variant'] ) && $index ) {
748 - $button_settings['variant'] = 'outline';
749 - }
561 + <?php if ( ! empty( $options['button']['text'] ) || ! empty( $options['button_secondary']['text'] ) ) { ?>
562 + <div class="e-notice__actions">
563 + <?php
564 + foreach ( [ $options['button'], $options['button_secondary'] ] as $index => $button_settings ) {
565 + if ( empty( $button_settings['variant'] ) && $index ) {
566 + $button_settings['variant'] = 'outline';
567 + }
750 568
751 - if ( empty( $button_settings['text'] ) ) {
752 - continue;
753 - }
569 + if ( empty( $button_settings['text'] ) ) {
570 + continue;
571 + }
754 572
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 - $button = new Button( $button_settings );
768 - $button->print_button();
769 - } ?>
770 - </div>
771 - <?php } ?>
573 + $button = new Button( $button_settings );
574 + $button->print_button();
575 + } ?>
576 + </div>
577 + <?php } ?>
772 578 </div>
773 579 </div>
774 - <?php }
580 + <?php }
775 581
776 582 public function admin_notices() {
777 583 $this->install_time = Plugin::$instance->get_install_time();
778 584 $this->current_screen_id = get_current_screen()->id;
@@ -796,60 +602,8 @@
796 602 return;
797 603 }
798 604 }
799 605
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 606 /**
853 607 * @since 2.9.0
854 608 * @access public
855 609 */
@@ -854,10 +608,8 @@
854 608 * @access public
855 609 */
856 610 public function __construct() {
857 611 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 612 }
861 613
862 614 /**
863 615 * Get module name.