PluginProbe
Boxzilla – WordPress Popup Builder / 3.4.7
Boxzilla – WordPress Popup Builder v3.4.7
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
boxzilla / src / admin / class-review-notice.php

class-review-notice.php in Boxzilla – WordPress Popup Builder 3.4.7, at src/admin/class-review-notice.php

92 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Boxzilla\Admin;
4
5 use WP_Screen;
6
7 /**
8 * Class ReviewNotice
9 *
10 * @ignore
11 */
12 class ReviewNotice
13 {
14 /**
15 * @var string
16 */
17 protected $meta_key_dismissed = '_boxzilla_review_notice_dismissed';
18
19 /**
20 * Add action & filter hooks.
21 */
22 public function init()
23 {
24 add_action('admin_notices', [ $this, 'show' ]);
25 add_action('boxzilla_admin_dismiss_review_notice', [ $this, 'dismiss' ]);
26 }
27
28 /**
29 * Set flag in user meta so notice won't be shown.
30 */
31 public function dismiss()
32 {
33 $user = wp_get_current_user();
34 update_user_meta($user->ID, $this->meta_key_dismissed, 1);
35 }
36
37 public function show()
38 {
39 $screen = get_current_screen();
40 if (! $screen instanceof WP_Screen) {
41 return;
42 }
43
44 // on some boxzilla screen?
45 if ($screen->post_type !== 'boxzilla-box') {
46 return;
47 }
48
49 // authorized?
50 if (! current_user_can('edit_posts')) {
51 return;
52 }
53
54 // only show if 2 weeks have passed since first use.
55 $two_weeks_in_seconds = ( 60 * 60 * 24 * 14 );
56 if ($this->time_since_first_use() <= $two_weeks_in_seconds) {
57 return;
58 }
59
60 // only show if user did not dismiss before
61 $user = wp_get_current_user();
62 if (get_user_meta($user->ID, $this->meta_key_dismissed, true)) {
63 return;
64 }
65
66 echo '<div class="notice notice-info boxzilla-is-dismissible">';
67 echo '<p>';
68 echo esc_html__('You\'ve been using Boxzilla for some time now; we hope you love it!', 'boxzilla'), ' <br />';
69 echo '<a href="https://wordpress.org/support/view/plugin-reviews/boxzilla?rate=5#new-post">', esc_html__('If you do, please leave us a nice plugin review on WordPress.org.', 'boxzilla'), '</a>';
70 echo esc_html__('It would be of great help to us.', 'boxzilla');
71 echo '</p>';
72 echo '<form method="POST"><button type="submit" class="notice-dismiss"><span class="screen-reader-text">', esc_html__('Dismiss this notice.', 'boxzilla'), '</span></button><input type="hidden" name="_boxzilla_admin_action" value="dismiss_review_notice"/></form>';
73 echo '</div>';
74 }
75
76 /**
77 * @return int
78 */
79 private function time_since_first_use()
80 {
81 $options = get_option('boxzilla_settings');
82
83 // option was never added before, do it now.
84 if (empty($options['first_activated_on'])) {
85 $options['first_activated_on'] = time();
86 update_option('boxzilla_settings', $options);
87 }
88
89 return time() - $options['first_activated_on'];
90 }
91 }
92