PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.3
Elementor Website Builder – more than just a page builder v3.1.3
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 4.0.8 All 454 releases
← All changes | core/admin/admin-notices.php +270 -537 4.3.0-beta13.1.3 View file →
@@ -1,17 +1,15 @@
1 1 <?php
2 2 namespace Elementor\Core\Admin;
3 3
4 4 use Elementor\Api;
5 -use Elementor\Core\Admin\UI\Components\Button;
6 5 use Elementor\Core\Base\Module;
7 -use Elementor\Core\Utils\Hints;
8 -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
9 6 use Elementor\Plugin;
10 7 use Elementor\Tracker;
11 8 use Elementor\User;
12 9 use Elementor\Utils;
13 10 use Elementor\Core\Admin\Notices\Base_Notice;
11 +use Elementor\Core\Admin\Notices\Elementor_Dev_Notice;
14 12
15 13 if ( ! defined( 'ABSPATH' ) ) {
16 14 exit; // Exit if accessed directly.
17 15 }
@@ -17,21 +15,18 @@
17 15 }
18 16
19 17 class Admin_Notices extends Module {
20 18
21 - const DEFAULT_EXCLUDED_PAGES = [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ];
22 -
23 - const EXIT_EARLY_FOR_BACKWARD_COMPATIBILITY = false;
24 -
25 19 private $plain_notices = [
26 20 'api_notice',
27 21 'api_upgrade_plugin',
28 22 'tracker',
29 - 'tracker_last_update',
30 23 'rate_us_feedback',
24 + 'woocommerce_promote',
25 + 'cf7_promote',
26 + 'mc4wp_promote',
27 + 'popup_maker_promote',
31 28 'role_manager_promote',
32 - 'plugin_image_optimization',
33 - 'ally_pages_promotion',
34 29 ];
35 30
36 31 private $elementor_pages_count = null;
37 32
@@ -39,21 +34,13 @@
39 34
40 35 private $current_screen_id = null;
41 36
42 37 private function get_notices() {
43 - /**
44 - * Admin notices.
45 - *
46 - * Filters Elementor admin notices.
47 - *
48 - * This hook can be used by external developers to manage existing
49 - * admin notice or to add new notices for Elementor add-ons.
50 - *
51 - * @param array $notices A list of notice classes.
52 - */
53 - $notices = apply_filters( 'elementor/core/admin/notices', [] );
38 + $notices = [
39 + new Elementor_Dev_Notice(),
40 + ];
54 41
55 - return $notices;
42 + return apply_filters( 'elementor/core/admin/notices', $notices );
56 43 }
57 44
58 45 private function get_install_time() {
59 46 if ( null === $this->install_time ) {
@@ -65,9 +52,8 @@
65 52
66 53 private function get_elementor_pages_count() {
67 54 if ( null === $this->elementor_pages_count ) {
68 55 $elementor_pages = new \WP_Query( [
69 - 'no_found_rows' => true,
70 56 'post_type' => 'any',
71 57 'post_status' => 'publish',
72 58 'fields' => 'ids',
73 59 'update_post_meta_cache' => false,
@@ -91,13 +77,13 @@
91 77 if ( ! current_user_can( 'update_plugins' ) ) {
92 78 return false;
93 79 }
94 80
95 - if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
81 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
96 82 return false;
97 83 }
98 84
99 - // Check for upgrades.
85 + // Check if have any upgrades.
100 86 $update_plugins = get_site_transient( 'update_plugins' );
101 87
102 88 $has_remote_update_package = ! ( empty( $update_plugins ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ] ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]->package ) );
103 89
@@ -117,9 +103,9 @@
117 103
118 104 $new_version = $upgrade_notice['version'];
119 105 }
120 106
121 - // Check if upgrade messages should be shown.
107 + // Check if have upgrade notices to show.
122 108 if ( version_compare( ELEMENTOR_VERSION, $upgrade_notice['version'], '>=' ) ) {
123 109 return false;
124 110 }
125 111
@@ -126,36 +112,46 @@
126 112 $notice_id = 'upgrade_notice_' . $upgrade_notice['version'];
127 113 if ( User::is_user_notice_viewed( $notice_id ) ) {
128 114 return false;
129 115 }
116 + ?>
117 + <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
118 + <div class="elementor-message-inner">
119 + <div class="elementor-message-icon">
120 + <div class="e-logo-wrapper">
121 + <i class="eicon-elementor" aria-hidden="true"></i>
122 + </div>
123 + </div>
124 + <div class="elementor-message-content">
125 + <strong><?php echo __( 'Update Notification', 'elementor' ); ?></strong>
126 + <p>
127 + <?php
128 + printf(
129 + /* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text */
130 + __( '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' ),
131 + esc_url( $details_url ),
132 + esc_attr( sprintf(
133 + /* translators: %s: Elementor version */
134 + __( 'View Elementor version %s details', 'elementor' ),
135 + $new_version
136 + ) ),
137 + $new_version,
138 + esc_url( $upgrade_url ),
139 + esc_attr( __( 'Update Elementor Now', 'elementor' ) )
140 + );
141 + ?>
142 + </p>
143 + </div>
144 + <div class="elementor-message-action">
145 + <a class="button elementor-button" href="<?php echo $upgrade_url; ?>">
146 + <i class="dashicons dashicons-update" aria-hidden="true"></i>
147 + <?php echo __( 'Update Now', 'elementor' ); ?>
148 + </a>
149 + </div>
150 + </div>
151 + </div>
152 + <?php
130 153
131 - $message = sprintf(
132 - /* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text. */
133 - __( '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 - esc_url( $details_url ),
135 - sprintf(
136 - /* translators: %s: Elementor version. */
137 - esc_attr__( 'View Elementor version %s details', 'elementor' ),
138 - $new_version
139 - ),
140 - $new_version,
141 - esc_url( $upgrade_url ),
142 - esc_attr__( 'Update Now', 'elementor' )
143 - );
144 -
145 - $options = [
146 - 'title' => esc_html__( 'Update Notification', 'elementor' ),
147 - 'description' => $message,
148 - 'button' => [
149 - 'icon_classes' => 'dashicons dashicons-update',
150 - 'text' => esc_html__( 'Update Now', 'elementor' ),
151 - 'url' => $upgrade_url,
152 - ],
153 - 'id' => $notice_id,
154 - ];
155 -
156 - $this->print_admin_notice( $options );
157 -
158 154 return true;
159 155 }
160 156
161 157 private function notice_api_notice() {
@@ -167,9 +163,9 @@
167 163 if ( ! current_user_can( 'manage_options' ) ) {
168 164 return false;
169 165 }
170 166
171 - if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
167 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
172 168 return false;
173 169 }
174 170
175 171 $notice_id = 'admin_notice_api_' . $admin_notice['notice_id'];
@@ -175,17 +171,14 @@
175 171 $notice_id = 'admin_notice_api_' . $admin_notice['notice_id'];
176 172 if ( User::is_user_notice_viewed( $notice_id ) ) {
177 173 return false;
178 174 }
175 + ?>
176 + <div class="notice is-dismissible updated elementor-message-dismissed elementor-message-announcement" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
177 + <p><?php echo $admin_notice['notice_text']; ?></p>
178 + </div>
179 + <?php
179 180
180 - $options = [
181 - 'title' => esc_html__( 'Update Notification', 'elementor' ),
182 - 'description' => $admin_notice['notice_text'],
183 - 'id' => $notice_id,
184 - ];
185 -
186 - $this->print_admin_notice( $options );
187 -
188 181 return true;
189 182 }
190 183
191 184 private function notice_tracker() {
@@ -213,9 +206,9 @@
213 206 // TODO: Skip for development env.
214 207 $optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
215 208 $optout_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_out' ), 'opt_out' );
216 209
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' );
210 + $tracker_description_text = __( 'Love using Elementor? Become a super contributor by opting in to share non-sensitive plugin data and to receive periodic email updates from us.', 'elementor' );
218 211
219 212 /**
220 213 * Tracker admin description text.
221 214 *
@@ -225,74 +218,29 @@
225 218 *
226 219 * @param string $tracker_description_text Description text displayed in admin notice.
227 220 */
228 221 $tracker_description_text = apply_filters( 'elementor/tracker/admin_description_text', $tracker_description_text );
222 + ?>
223 + <div class="notice updated elementor-message">
224 + <div class="elementor-message-inner">
225 + <div class="elementor-message-icon">
226 + <div class="e-logo-wrapper">
227 + <i class="eicon-elementor" aria-hidden="true"></i>
228 + </div>
229 + </div>
230 + <div class="elementor-message-content">
231 + <p><?php echo esc_html( $tracker_description_text ); ?> <a href="https://go.elementor.com/usage-data-tracking/" target="_blank"><?php echo __( 'Learn more.', 'elementor' ); ?></a></p>
232 + <p class="elementor-message-actions">
233 + <a href="<?php echo $optin_url; ?>" class="button button-primary"><?php echo __( 'Sure! I\'d love to help', 'elementor' ); ?></a>&nbsp;<a href="<?php echo $optout_url; ?>" class="button-secondary"><?php echo __( 'No thanks', 'elementor' ); ?></a>
234 + </p>
235 + </div>
236 + </div>
237 + </div>
238 + <?php
229 239
230 - $message = esc_html( $tracker_description_text ) . ' <a href="https://go.elementor.com/usage-data-tracking/" target="_blank">' . esc_html__( 'Learn more.', 'elementor' ) . '</a>';
231 -
232 - $options = [
233 - 'title' => esc_html__( 'Want to shape the future of web creation?', 'elementor' ),
234 - 'description' => $message,
235 - 'dismissible' => false,
236 - 'button' => [
237 - 'text' => esc_html__( 'Sure! I\'d love to help', 'elementor' ),
238 - 'url' => $optin_url,
239 - 'type' => 'cta',
240 - ],
241 - 'button_secondary' => [
242 - 'text' => esc_html__( 'No thanks', 'elementor' ),
243 - 'url' => $optout_url,
244 - 'variant' => 'outline',
245 - 'type' => 'cta',
246 - ],
247 - ];
248 -
249 - $this->print_admin_notice( $options );
250 -
251 240 return true;
252 241 }
253 242
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 243 private function notice_rate_us_feedback() {
296 244 $notice_id = 'rate_us_feedback';
297 245
298 246 if ( ! current_user_can( 'manage_options' ) ) {
@@ -309,266 +257,212 @@
309 257
310 258 $dismiss_url = add_query_arg( [
311 259 'action' => 'elementor_set_admin_notice_viewed',
312 260 'notice_id' => esc_attr( $notice_id ),
313 - '_wpnonce' => wp_create_nonce( 'elementor_set_admin_notice_viewed' ),
314 261 ], admin_url( 'admin-post.php' ) );
315 262
316 - $options = [
317 - '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' ),
319 - 'id' => $notice_id,
320 - 'button' => [
321 - 'text' => esc_html__( 'Happy To Help', 'elementor' ),
322 - 'url' => 'https://go.elementor.com/admin-review/',
323 - 'new_tab' => true,
324 - 'type' => 'cta',
325 - ],
326 - 'button_secondary' => [
327 - 'text' => esc_html__( 'Hide Notification', 'elementor' ),
328 - 'classes' => [ 'e-notice-dismiss' ],
329 - 'url' => esc_url_raw( $dismiss_url ),
330 - 'new_tab' => true,
331 - 'type' => 'cta',
332 - ],
333 - ];
263 + ?>
264 + <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
265 + <div class="elementor-message-inner">
266 + <div class="elementor-message-icon">
267 + <div class="e-logo-wrapper">
268 + <i class="eicon-elementor" aria-hidden="true"></i>
269 + </div>
270 + </div>
271 + <div class="elementor-message-content">
272 + <p><strong><?php echo __( 'Congrats!', 'elementor' ); ?></strong> <?php _e( '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' ); ?></p>
273 + <p class="elementor-message-actions">
274 + <a href="https://go.elementor.com/admin-review/" target="_blank" class="button button-primary"><?php _e( 'Happy To Help', 'elementor' ); ?></a>
275 + <a href="<?php echo esc_url_raw( $dismiss_url ); ?>" class="button elementor-button-notice-dismiss"><?php _e( 'Hide Notification', 'elementor' ); ?></a>
276 + </p>
277 + </div>
278 + </div>
279 + </div>
280 + <?php
334 281
335 - $this->print_admin_notice( $options );
336 -
337 282 return true;
338 283 }
339 284
340 - private function notice_role_manager_promote() {
341 - $notice_id = 'role_manager_promote';
285 + private function notice_woocommerce_promote() {
286 + $notice_id = 'woocommerce_promote';
342 287
343 - if ( Utils::has_pro() ) {
288 + if ( Utils::has_pro() || ! function_exists( 'WC' ) ) {
344 289 return false;
345 290 }
346 291
347 - if ( ! current_user_can( 'manage_options' ) ) {
292 + if ( ! current_user_can( 'install_plugins' ) ) {
348 293 return false;
349 294 }
350 295
351 - if ( 'elementor_page_elementor-role-manager' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
296 + if ( ! in_array( $this->current_screen_id, [ 'edit-product', 'woocommerce_page_wc-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
352 297 return false;
353 298 }
354 299
355 - $users = new \WP_User_Query( [
356 - 'fields' => 'ID',
357 - 'number' => 10,
358 - ] );
300 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
301 + return false;
302 + }
359 303
360 - if ( 5 > $users->get_total() ) {
304 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
361 305 return false;
362 306 }
363 307
364 - $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' ),
367 - 'id' => $notice_id,
308 + ?>
309 + <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
310 + <div class="elementor-message-inner">
311 + <div class="elementor-message-icon">
312 + <div class="e-logo-wrapper">
313 + <i class="eicon-elementor" aria-hidden="true"></i>
314 + </div>
315 + </div>
316 + <div class="elementor-message-content">
317 + <p><?php _e( 'Using WooCommerce? With Elementor Pro’s WooCommerce Builder, you’ll be able to design your store without coding!', 'elementor' ); ?></p>
318 + <p class="elementor-message-actions">
319 + <a href="https://go.elementor.com/plugin-promotion-woocommerce/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
320 + </p>
321 + </div>
322 + </div>
323 + </div>
324 + <?php
368 325
369 - 'button' => [
370 - 'text' => esc_html__( 'Learn More', 'elementor' ),
371 - 'url' => 'https://go.elementor.com/plugin-promotion-role-manager/',
372 - 'new_tab' => true,
373 - 'type' => 'cta',
374 - ],
375 - ];
376 -
377 - $options = Filtered_Promotions_Manager::get_filtered_promotion_data( $options, 'core/admin/notice_role_manager_promote', 'button', 'url' );
378 -
379 - $this->print_admin_notice( $options );
380 -
381 326 return true;
382 327 }
383 328
384 - private function get_installed_form_plugin_name() {
385 - static $detected_form_plugin = null;
329 + private function notice_cf7_promote() {
330 + $notice_id = 'cf7_promote';
386 331
387 - if ( null !== $detected_form_plugin ) {
388 - return $detected_form_plugin;
332 + if ( Utils::has_pro() || ! defined( 'WPCF7_VERSION' ) ) {
333 + return false;
389 334 }
390 335
391 - $form_plugins_constants_to_name_mapper = [
392 - 'WPFORMS_VERSION' => 'WPForms',
393 - 'WPCF7_VERSION' => 'Contact Form 7',
394 - ];
336 + if ( ! current_user_can( 'install_plugins' ) ) {
337 + return false;
338 + }
395 339
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 - }
340 + if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_wpcf7', 'contact_page_wpcf7-integration' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
341 + return false;
401 342 }
402 343
403 - $form_plugins_classes_to_name_mapper = [
404 - '\GFCommon' => 'Gravity Forms',
405 - '\Ninja_Forms' => 'Ninja Forms',
406 - ];
344 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
345 + return false;
346 + }
407 347
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 - }
348 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
349 + return false;
413 350 }
414 351
415 - $detected_form_plugin = false;
416 - return $detected_form_plugin;
352 + ?>
353 + <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
354 + <div class="elementor-message-inner">
355 + <div class="elementor-message-icon">
356 + <div class="e-logo-wrapper">
357 + <i class="eicon-elementor" aria-hidden="true"></i>
358 + </div>
359 + </div>
360 + <div class="elementor-message-content">
361 + <p><?php _e( 'Using Elementor & Contact Form 7? Try out Elementor Pro and design your forms visually with one powerful tool.', 'elementor' ); ?></p>
362 + <p class="elementor-message-actions">
363 + <a href="https://go.elementor.com/plugin-promotion-contactform7/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
364 + </p>
365 + </div>
366 + </div>
367 + </div>
368 + <?php
369 +
370 + return true;
417 371 }
418 372
419 - private function notice_ally_pages_promotion() {
420 - global $pagenow;
421 - $notice_id = 'ally_pages_promotion';
373 + private function notice_mc4wp_promote() {
374 + $notice_id = 'mc4wp_promote';
422 375
423 - if ( 'edit.php' !== $pagenow || empty( $_GET['post_type'] ) || 'page' !== $_GET['post_type'] ) {
376 + if ( Utils::has_pro() || ! defined( 'MC4WP_VERSION' ) ) {
424 377 return false;
425 378 }
426 379
427 - if ( ! current_user_can( 'manage_options' ) ) {
380 + if ( ! current_user_can( 'install_plugins' ) ) {
428 381 return false;
429 382 }
430 383
431 - if ( User::is_user_notice_viewed( $notice_id ) ) {
384 + 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 385 return false;
433 386 }
434 387
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 ) {
388 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
443 389 return false;
444 390 }
445 391
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 - }
392 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
393 + return false;
493 394 }
494 395
495 - $options = [
496 - 'title' => esc_html__( 'Make sure your site has an accessibility statement page', 'elementor' ),
497 - 'description' => $description,
498 - 'id' => $notice_id,
499 - 'type' => 'cta',
500 - '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,
508 - 'new_tab' => true,
509 - 'type' => 'cta',
510 - ],
511 - ];
396 + ?>
397 + <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
398 + <div class="elementor-message-inner">
399 + <div class="elementor-message-icon">
400 + <div class="e-logo-wrapper">
401 + <i class="eicon-elementor" aria-hidden="true"></i>
402 + </div>
403 + </div>
404 + <div class="elementor-message-content">
405 + <p><?php _e( 'Want to design better MailChimp forms? Use Elementor Pro and enjoy unlimited integrations, visual design, templates and more.', 'elementor' ); ?></p>
406 + <p class="elementor-message-actions">
407 + <a href="https://go.elementor.com/plugin-promotion-mc4wp/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
408 + </p>
409 + </div>
410 + </div>
411 + </div>
412 + <?php
512 413
513 - $this->print_admin_notice( $options );
514 -
515 414 return true;
516 415 }
517 416
518 - private function is_elementor_page(): bool {
519 - return 0 === strpos( $this->current_screen_id, 'elementor_page' );
520 - }
417 + private function notice_popup_maker_promote() {
418 + $notice_id = 'popup_maker_promote';
521 419
522 - private function is_elementor_admin_screen(): bool {
523 - return in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library' ], true );
524 - }
420 + if ( Utils::has_pro() || ! class_exists( 'Popup_Maker' ) ) {
421 + return false;
422 + }
525 423
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 - }
424 + if ( ! current_user_can( 'install_plugins' ) ) {
425 + return false;
426 + }
532 427
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 - }
428 + if ( ! in_array( $this->current_screen_id, [ 'edit-popup', 'popup_page_pum-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
429 + return false;
430 + }
536 431
537 - private function get_plugin_button_connect_url( $plugin_settings_page ) {
538 - return self_admin_url( $plugin_settings_page );
539 - }
540 -
541 - private function get_plugin_cta_data( $plugin_slug, $plugin_file_path ) {
542 - if ( Hints::is_plugin_active( $plugin_slug ) ) {
432 + if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
543 433 return false;
544 434 }
545 435
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' );
436 + if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
437 + return false;
552 438 }
553 439
554 - return [
555 - 'url' => $url,
556 - 'text' => $cta_text,
557 - ];
558 - }
440 + ?>
441 + <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
442 + <div class="elementor-message-inner">
443 + <div class="elementor-message-icon">
444 + <div class="e-logo-wrapper">
445 + <i class="eicon-elementor" aria-hidden="true"></i>
446 + </div>
447 + </div>
448 + <div class="elementor-message-content">
449 + <p><?php _e( 'Using popups on your site? Build outstanding popups using Elementor Pro and get more leads, sales and subscribers.', 'elementor' ); ?></p>
450 + <p class="elementor-message-actions">
451 + <a href="https://go.elementor.com/plugin-promotion-popupmaker/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
452 + </p>
453 + </div>
454 + </div>
455 + </div>
456 + <?php
559 457
560 - /**
561 - * For testing purposes
562 - */
563 - public function get_elementor_version() {
564 - return ELEMENTOR_VERSION;
458 + return true;
565 459 }
566 460
567 - private function notice_plugin_image_optimization() {
568 - $notice_id = 'plugin_image_optimization';
461 + private function notice_role_manager_promote() {
462 + $notice_id = 'role_manager_promote';
569 463
570 - if ( 'upload' !== $this->current_screen_id ) {
464 + if ( Utils::has_pro() ) {
571 465 return false;
572 466 }
573 467
574 468 if ( ! current_user_can( 'manage_options' ) ) {
@@ -574,205 +468,98 @@
574 468 if ( ! current_user_can( 'manage_options' ) ) {
575 469 return false;
576 470 }
577 471
578 - if ( User::is_user_notice_viewed( $notice_id ) ) {
472 + if ( 'elementor_page_elementor-role-manager' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
579 473 return false;
580 474 }
581 475
582 - $attachments = new \WP_Query( [
583 - 'post_type' => 'attachment',
584 - 'post_status' => 'any',
585 - 'fields' => 'ids',
476 + $users = new \WP_User_Query( [
477 + 'fields' => 'ID',
478 + 'number' => 10,
586 479 ] );
587 480
588 - if ( 1 > $attachments->found_posts ) {
481 + if ( 5 > $users->get_total() ) {
589 482 return false;
590 483 }
591 484
592 - $plugin_slug = 'image-optimization';
593 - $plugin_file_path = 'image-optimization/image-optimization.php';
485 + ?>
486 + <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
487 + <div class="elementor-message-inner">
488 + <div class="elementor-message-icon">
489 + <div class="e-logo-wrapper">
490 + <i class="eicon-elementor" aria-hidden="true"></i>
491 + </div>
492 + </div>
493 + <div class="elementor-message-content">
494 + <p><?php _e( 'Managing a multi-user site? With Elementor Pro, you can control user access and make sure no one messes up your design.', 'elementor' ); ?></p>
495 + <p class="elementor-message-actions">
496 + <a href="https://go.elementor.com/promotion-role-manager/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
497 + </p>
498 + </div>
499 + </div>
500 + </div>
501 + <?php
594 502
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 - $options = [
650 - 'title' => esc_html__( 'Speed up your website with Image Optimization', 'elementor' ),
651 - 'description' => $description,
652 - 'id' => $notice_id,
653 - 'type' => 'cta',
654 - 'button' => [
655 - 'text' => $button_text,
656 - 'url' => self::add_plg_campaign_data( $button_url, $campaign_data ),
657 - 'type' => 'cta',
658 - 'data' => [
659 - 'campaign' => $campaign_data['campaign'],
660 - 'source' => $campaign_data['source'],
661 - 'medium' => $campaign_data['medium'],
662 - ],
663 - ],
664 - ];
665 -
666 - $this->print_admin_notice( $options );
667 -
668 503 return true;
669 504 }
670 505
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 -
506 + /*
507 + * @TODO: Rewrite this method markup and use it for every admin notice
508 + */
509 + public function print_admin_notice( array $options ) {
678 510 $default_options = [
679 511 'id' => null,
680 512 'title' => '',
681 513 'description' => '',
682 - 'classes' => [ 'notice', 'e-notice' ], // We include WP's default notice class so it will be properly handled by WP's js handler
683 - 'type' => '',
684 - 'dismissible' => true,
685 - 'icon' => 'eicon-elementor-circle',
686 - 'button' => [],
687 - 'button_secondary' => [],
514 + 'dismissible' => false,
515 + 'button' => [
516 + 'text' => '',
517 + 'url' => '',
518 + 'class' => 'elementor-button',
519 + ],
688 520 ];
689 521
690 522 $options = array_replace_recursive( $default_options, $options );
691 523
692 - $notice_classes = $options['classes'];
693 - $dismiss_button = '';
694 - $icon = '';
524 + $id_attr = '';
525 + $dismissible_classes = '';
695 526
696 - if ( $options['type'] ) {
697 - $notice_classes[] = 'e-notice--' . $options['type'];
527 + if ( $options['id'] ) {
528 + $id_attr = sprintf( 'data-notice_id="%s"', $options['id'] );
698 529 }
699 530
700 - $wrapper_attributes = [
701 - 'role' => 'region',
702 - 'aria-label' => esc_html__( 'Elementor notice', 'elementor' ),
703 - ];
704 -
705 531 if ( $options['dismissible'] ) {
706 - $label = esc_html__( 'Dismiss this notice.', 'elementor' );
707 - $notice_classes[] = 'e-notice--dismissible';
708 - $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' );
532 + $dismissible_classes = 'is-dismissible elementor-message-dismissed';
711 533 }
712 -
713 - if ( $options['icon'] ) {
714 - $notice_classes[] = 'e-notice--extended';
715 - $icon = '<div class="e-notice__icon-wrapper"><i class="' . esc_attr( $options['icon'] ) . '" aria-hidden="true"></i></div>';
716 - }
717 -
718 - $wrapper_attributes['class'] = $notice_classes;
719 -
720 - if ( $options['id'] ) {
721 - $wrapper_attributes['data-notice_id'] = $options['id'];
722 - }
723 -
724 - if ( ! empty( $options['source'] ) ) {
725 - $wrapper_attributes['data-source'] = $options['source'];
726 - }
727 534 ?>
728 - <div <?php Utils::print_html_attributes( $wrapper_attributes ); ?>>
729 - <?php echo $dismiss_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
730 - <div class="e-notice__aside">
731 - <?php echo $icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
732 - </div>
733 - <div class="e-notice__content">
734 - <?php if ( $options['title'] ) { ?>
735 - <h3><?php echo wp_kses_post( $options['title'] ); ?></h3>
736 - <?php } ?>
737 -
738 - <?php if ( $options['description'] ) { ?>
739 - <p><?php echo wp_kses_post( $options['description'] ); ?></p>
740 - <?php } ?>
741 -
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 - }
750 -
751 - if ( empty( $button_settings['text'] ) ) {
752 - continue;
753 - }
754 -
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 - } ?>
535 + <div
536 + class="notice elementor-message <?php echo $dismissible_classes; ?>"
537 + <?php echo $id_attr; ?>
538 + >
539 + <div class="elementor-message-inner">
540 + <div class="elementor-message-icon">
541 + <div class="e-logo-wrapper">
542 + <i class="eicon-elementor" aria-hidden="true"></i>
770 543 </div>
544 + </div>
545 + <div class="elementor-message-content">
546 + <?php if ( $options['title'] ) { ?>
547 + <strong><?php echo $options['title']; ?></strong>
548 + <?php } ?>
549 + <?php if ( $options['description'] ) { ?>
550 + <p><?php echo $options['description']; ?></p>
551 + <?php } ?>
552 + </div>
553 + <?php if ( $options['button']['text'] ) { ?>
554 + <div class="elementor-message-action">
555 + <a class="<?php echo $options['button']['class']; ?>" href="<?php echo esc_url( $options['button']['url'] ); ?>"><?php echo $options['button']['text']; ?></a>
556 + </div>
771 557 <?php } ?>
772 558 </div>
773 559 </div>
774 - <?php }
560 + <?php
561 + }
775 562
776 563 public function admin_notices() {
777 564 $this->install_time = Plugin::$instance->get_install_time();
778 565 $this->current_screen_id = get_current_screen()->id;
@@ -796,60 +583,8 @@
796 583 return;
797 584 }
798 585 }
799 586
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 587 /**
853 588 * @since 2.9.0
854 589 * @access public
855 590 */
@@ -854,10 +589,8 @@
854 589 * @access public
855 590 */
856 591 public function __construct() {
857 592 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 593 }
861 594
862 595 /**
863 596 * Get module name.