PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.8
Elementor Website Builder – more than just a page builder v3.0.8
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 4.0.7 All 451 releases
elementor / core / admin / admin-notices.php

admin-notices.php in Elementor Website Builder – more than just a page builder 3.0.8, at core/admin/admin-notices.php

571 lines 17.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Admin;
3
4 use Elementor\Api;
5 use Elementor\Core\Base\Module;
6 use Elementor\Plugin;
7 use Elementor\Tracker;
8 use Elementor\User;
9 use Elementor\Utils;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 class Admin_Notices extends Module {
16
17 private $notices = [
18 'api_notice',
19 'api_upgrade_plugin',
20 'tracker',
21 'rate_us_feedback',
22 'woocommerce_promote',
23 'cf7_promote',
24 'mc4wp_promote',
25 'popup_maker_promote',
26 'role_manager_promote',
27 ];
28
29 private $elementor_pages_count = null;
30
31 private $install_time = null;
32
33 private $current_screen_id = null;
34
35 private function get_install_time() {
36 if ( null === $this->install_time ) {
37 $this->install_time = Plugin::$instance->get_install_time();
38 }
39
40 return $this->install_time;
41 }
42
43 private function get_elementor_pages_count() {
44 if ( null === $this->elementor_pages_count ) {
45 $elementor_pages = new \WP_Query( [
46 'post_type' => 'any',
47 'post_status' => 'publish',
48 'fields' => 'ids',
49 'update_post_meta_cache' => false,
50 'update_post_term_cache' => false,
51 'meta_key' => '_elementor_edit_mode',
52 'meta_value' => 'builder',
53 ] );
54
55 $this->elementor_pages_count = $elementor_pages->post_count;
56 }
57
58 return $this->elementor_pages_count;
59 }
60
61 private function notice_api_upgrade_plugin() {
62 $upgrade_notice = Api::get_upgrade_notice();
63 if ( empty( $upgrade_notice ) ) {
64 return false;
65 }
66
67 if ( ! current_user_can( 'update_plugins' ) ) {
68 return false;
69 }
70
71 if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
72 return false;
73 }
74
75 // Check if have any upgrades.
76 $update_plugins = get_site_transient( 'update_plugins' );
77
78 $has_remote_update_package = ! ( empty( $update_plugins ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ] ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]->package ) );
79
80 if ( ! $has_remote_update_package && empty( $upgrade_notice['update_link'] ) ) {
81 return false;
82 }
83
84 if ( $has_remote_update_package ) {
85 $product = $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ];
86
87 $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $product->slug . '&section=changelog&TB_iframe=true&width=600&height=800' );
88 $upgrade_url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . ELEMENTOR_PLUGIN_BASE ), 'upgrade-plugin_' . ELEMENTOR_PLUGIN_BASE );
89 $new_version = $product->new_version;
90 } else {
91 $upgrade_url = $upgrade_notice['update_link'];
92 $details_url = $upgrade_url;
93
94 $new_version = $upgrade_notice['version'];
95 }
96
97 // Check if have upgrade notices to show.
98 if ( version_compare( ELEMENTOR_VERSION, $upgrade_notice['version'], '>=' ) ) {
99 return false;
100 }
101
102 $notice_id = 'upgrade_notice_' . $upgrade_notice['version'];
103 if ( User::is_user_notice_viewed( $notice_id ) ) {
104 return false;
105 }
106 ?>
107 <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
108 <div class="elementor-message-inner">
109 <div class="elementor-message-icon">
110 <div class="e-logo-wrapper">
111 <i class="eicon-elementor" aria-hidden="true"></i>
112 </div>
113 </div>
114 <div class="elementor-message-content">
115 <strong><?php echo __( 'Update Notification', 'elementor' ); ?></strong>
116 <p>
117 <?php
118 printf(
119 /* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text */
120 __( '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' ),
121 esc_url( $details_url ),
122 esc_attr( sprintf(
123 /* translators: %s: Elementor version */
124 __( 'View Elementor version %s details', 'elementor' ),
125 $new_version
126 ) ),
127 $new_version,
128 esc_url( $upgrade_url ),
129 esc_attr( __( 'Update Elementor Now', 'elementor' ) )
130 );
131 ?>
132 </p>
133 </div>
134 <div class="elementor-message-action">
135 <a class="button elementor-button" href="<?php echo $upgrade_url; ?>">
136 <i class="dashicons dashicons-update" aria-hidden="true"></i>
137 <?php echo __( 'Update Now', 'elementor' ); ?>
138 </a>
139 </div>
140 </div>
141 </div>
142 <?php
143
144 return true;
145 }
146
147 private function notice_api_notice() {
148 $admin_notice = Api::get_admin_notice();
149 if ( empty( $admin_notice ) ) {
150 return false;
151 }
152
153 if ( ! current_user_can( 'manage_options' ) ) {
154 return false;
155 }
156
157 if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) {
158 return false;
159 }
160
161 $notice_id = 'admin_notice_api_' . $admin_notice['notice_id'];
162 if ( User::is_user_notice_viewed( $notice_id ) ) {
163 return false;
164 }
165 ?>
166 <div class="notice is-dismissible updated elementor-message-dismissed elementor-message-announcement" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
167 <p><?php echo $admin_notice['notice_text']; ?></p>
168 </div>
169 <?php
170
171 return true;
172 }
173
174 private function notice_tracker() {
175 if ( ! current_user_can( 'manage_options' ) ) {
176 return false;
177 }
178
179 // Show tracker notice after 24 hours from installed time.
180 if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
181 return false;
182 }
183
184 if ( '1' === get_option( 'elementor_tracker_notice' ) ) {
185 return false;
186 }
187
188 if ( Tracker::is_allow_track() ) {
189 return false;
190 }
191
192 if ( 2 > $this->get_elementor_pages_count() ) {
193 return false;
194 }
195
196 // TODO: Skip for development env.
197 $optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
198 $optout_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_out' ), 'opt_out' );
199
200 $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' );
201
202 /**
203 * Tracker admin description text.
204 *
205 * Filters the admin notice text for non-sensitive data collection.
206 *
207 * @since 1.0.0
208 *
209 * @param string $tracker_description_text Description text displayed in admin notice.
210 */
211 $tracker_description_text = apply_filters( 'elementor/tracker/admin_description_text', $tracker_description_text );
212 ?>
213 <div class="notice updated elementor-message">
214 <div class="elementor-message-inner">
215 <div class="elementor-message-icon">
216 <div class="e-logo-wrapper">
217 <i class="eicon-elementor" aria-hidden="true"></i>
218 </div>
219 </div>
220 <div class="elementor-message-content">
221 <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>
222 <p class="elementor-message-actions">
223 <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>
224 </p>
225 </div>
226 </div>
227 </div>
228 <?php
229
230 return true;
231 }
232
233 private function notice_rate_us_feedback() {
234 $notice_id = 'rate_us_feedback';
235
236 if ( ! current_user_can( 'manage_options' ) ) {
237 return false;
238 }
239
240 if ( 'dashboard' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
241 return false;
242 }
243
244 if ( 10 >= $this->get_elementor_pages_count() ) {
245 return false;
246 }
247
248 $dismiss_url = add_query_arg( [
249 'action' => 'elementor_set_admin_notice_viewed',
250 'notice_id' => esc_attr( $notice_id ),
251 ], admin_url( 'admin-post.php' ) );
252
253 ?>
254 <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
255 <div class="elementor-message-inner">
256 <div class="elementor-message-icon">
257 <div class="e-logo-wrapper">
258 <i class="eicon-elementor" aria-hidden="true"></i>
259 </div>
260 </div>
261 <div class="elementor-message-content">
262 <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>
263 <p class="elementor-message-actions">
264 <a href="https://go.elementor.com/admin-review/" target="_blank" class="button button-primary"><?php _e( 'Happy To Help', 'elementor' ); ?></a>
265 <a href="<?php echo esc_url_raw( $dismiss_url ); ?>" class="button elementor-button-notice-dismiss"><?php _e( 'Hide Notification', 'elementor' ); ?></a>
266 </p>
267 </div>
268 </div>
269 </div>
270 <?php
271
272 return true;
273 }
274
275 private function notice_woocommerce_promote() {
276 $notice_id = 'woocommerce_promote';
277
278 if ( Utils::has_pro() || ! function_exists( 'WC' ) ) {
279 return false;
280 }
281
282 if ( ! current_user_can( 'install_plugins' ) ) {
283 return false;
284 }
285
286 if ( ! in_array( $this->current_screen_id, [ 'edit-product', 'woocommerce_page_wc-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
287 return false;
288 }
289
290 if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
291 return false;
292 }
293
294 if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
295 return false;
296 }
297
298 ?>
299 <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
300 <div class="elementor-message-inner">
301 <div class="elementor-message-icon">
302 <div class="e-logo-wrapper">
303 <i class="eicon-elementor" aria-hidden="true"></i>
304 </div>
305 </div>
306 <div class="elementor-message-content">
307 <p><?php _e( 'Using WooCommerce? With Elementor Pro’s WooCommerce Builder, you’ll be able to design your store without coding!', 'elementor' ); ?></p>
308 <p class="elementor-message-actions">
309 <a href="https://go.elementor.com/plugin-promotion-woocommerce/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
310 </p>
311 </div>
312 </div>
313 </div>
314 <?php
315
316 return true;
317 }
318
319 private function notice_cf7_promote() {
320 $notice_id = 'cf7_promote';
321
322 if ( Utils::has_pro() || ! defined( 'WPCF7_VERSION' ) ) {
323 return false;
324 }
325
326 if ( ! current_user_can( 'install_plugins' ) ) {
327 return false;
328 }
329
330 if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_wpcf7', 'contact_page_wpcf7-integration' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
331 return false;
332 }
333
334 if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
335 return false;
336 }
337
338 if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
339 return false;
340 }
341
342 ?>
343 <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
344 <div class="elementor-message-inner">
345 <div class="elementor-message-icon">
346 <div class="e-logo-wrapper">
347 <i class="eicon-elementor" aria-hidden="true"></i>
348 </div>
349 </div>
350 <div class="elementor-message-content">
351 <p><?php _e( 'Using Elementor & Contact Form 7? Try out Elementor Pro and design your forms visually with one powerful tool.', 'elementor' ); ?></p>
352 <p class="elementor-message-actions">
353 <a href="https://go.elementor.com/plugin-promotion-contactform7/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
354 </p>
355 </div>
356 </div>
357 </div>
358 <?php
359
360 return true;
361 }
362
363 private function notice_mc4wp_promote() {
364 $notice_id = 'mc4wp_promote';
365
366 if ( Utils::has_pro() || ! defined( 'MC4WP_VERSION' ) ) {
367 return false;
368 }
369
370 if ( ! current_user_can( 'install_plugins' ) ) {
371 return false;
372 }
373
374 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 ) ) {
375 return false;
376 }
377
378 if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
379 return false;
380 }
381
382 if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
383 return false;
384 }
385
386 ?>
387 <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
388 <div class="elementor-message-inner">
389 <div class="elementor-message-icon">
390 <div class="e-logo-wrapper">
391 <i class="eicon-elementor" aria-hidden="true"></i>
392 </div>
393 </div>
394 <div class="elementor-message-content">
395 <p><?php _e( 'Want to design better MailChimp forms? Use Elementor Pro and enjoy unlimited integrations, visual design, templates and more.', 'elementor' ); ?></p>
396 <p class="elementor-message-actions">
397 <a href="https://go.elementor.com/plugin-promotion-mc4wp/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
398 </p>
399 </div>
400 </div>
401 </div>
402 <?php
403
404 return true;
405 }
406
407 private function notice_popup_maker_promote() {
408 $notice_id = 'popup_maker_promote';
409
410 if ( Utils::has_pro() || ! class_exists( 'Popup_Maker' ) ) {
411 return false;
412 }
413
414 if ( ! current_user_can( 'install_plugins' ) ) {
415 return false;
416 }
417
418 if ( ! in_array( $this->current_screen_id, [ 'edit-popup', 'popup_page_pum-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) {
419 return false;
420 }
421
422 if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) {
423 return false;
424 }
425
426 if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
427 return false;
428 }
429
430 ?>
431 <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
432 <div class="elementor-message-inner">
433 <div class="elementor-message-icon">
434 <div class="e-logo-wrapper">
435 <i class="eicon-elementor" aria-hidden="true"></i>
436 </div>
437 </div>
438 <div class="elementor-message-content">
439 <p><?php _e( 'Using popups on your site? Build outstanding popups using Elementor Pro and get more leads, sales and subscribers.', 'elementor' ); ?></p>
440 <p class="elementor-message-actions">
441 <a href="https://go.elementor.com/plugin-promotion-popupmaker/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
442 </p>
443 </div>
444 </div>
445 </div>
446 <?php
447
448 return true;
449 }
450
451 private function notice_role_manager_promote() {
452 $notice_id = 'role_manager_promote';
453
454 if ( Utils::has_pro() ) {
455 return false;
456 }
457
458 if ( ! current_user_can( 'manage_options' ) ) {
459 return false;
460 }
461
462 if ( 'elementor_page_elementor-role-manager' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
463 return false;
464 }
465
466 $users = new \WP_User_Query( [
467 'fields' => 'ID',
468 'number' => 10,
469 ] );
470
471 if ( 5 > $users->get_total() ) {
472 return false;
473 }
474
475 ?>
476 <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>">
477 <div class="elementor-message-inner">
478 <div class="elementor-message-icon">
479 <div class="e-logo-wrapper">
480 <i class="eicon-elementor" aria-hidden="true"></i>
481 </div>
482 </div>
483 <div class="elementor-message-content">
484 <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>
485 <p class="elementor-message-actions">
486 <a href="https://go.elementor.com/promotion-role-manager/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a>
487 </p>
488 </div>
489 </div>
490 </div>
491 <?php
492
493 return true;
494 }
495
496 /*
497 * @TODO: Rewrite this method markup and use it for every admin notice
498 */
499 public function print_admin_notice( array $options ) {
500 $default_options = [
501 'title' => '',
502 'description' => '',
503 'button' => [
504 'text' => '',
505 'url' => '',
506 'class' => 'elementor-button',
507 ],
508 ];
509
510 $options = array_replace_recursive( $default_options, $options );
511 ?>
512 <div class="notice elementor-message">
513 <div class="elementor-message-inner">
514 <div class="elementor-message-icon">
515 <div class="e-logo-wrapper">
516 <i class="eicon-elementor" aria-hidden="true"></i>
517 </div>
518 </div>
519 <div class="elementor-message-content">
520 <?php if ( $options['title'] ) { ?>
521 <strong><?php echo $options['title']; ?></strong>
522 <?php } ?>
523 <?php if ( $options['description'] ) { ?>
524 <p><?php echo $options['description']; ?></p>
525 <?php } ?>
526 </div>
527 <?php if ( $options['button']['text'] ) { ?>
528 <div class="elementor-message-action">
529 <a class="<?php echo $options['button']['class']; ?>" href="<?php echo esc_url( $options['button']['url'] ); ?>"><?php echo $options['button']['text']; ?></a>
530 </div>
531 <?php } ?>
532 </div>
533 </div>
534 <?php
535 }
536
537 public function admin_notices() {
538 $this->install_time = Plugin::$instance->get_install_time();
539 $this->current_screen_id = get_current_screen()->id;
540
541 foreach ( $this->notices as $notice ) {
542 $method_callback = "notice_{$notice}";
543 if ( $this->$method_callback() ) {
544 return;
545 }
546 }
547 }
548
549 /**
550 * @since 2.9.0
551 * @access public
552 */
553 public function __construct() {
554 add_action( 'admin_notices', [ $this, 'admin_notices' ], 20 );
555 }
556
557 /**
558 * Get module name.
559 *
560 * Retrieve the module name.
561 *
562 * @since 2.9.0
563 * @access public
564 *
565 * @return string Module name.
566 */
567 public function get_name() {
568 return 'admin-notices';
569 }
570 }
571