PluginProbe
Boxzilla – WordPress Popup Builder / 3.4.6
Boxzilla – WordPress Popup Builder v3.4.6
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.6, at src/admin/class-review-notice.php

96 lines 2.7 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 /**
38 * @return bool
39 */
40 public function show()
41 {
42 $screen = get_current_screen();
43 if (! $screen instanceof WP_Screen) {
44 return false;
45 }
46
47 // on some boxzilla screen?
48 if ($screen->post_type !== 'boxzilla-box') {
49 return false;
50 }
51
52 // authorized?
53 if (! current_user_can('edit_posts')) {
54 return false;
55 }
56
57 // only show if 2 weeks have passed since first use.
58 $two_weeks_in_seconds = ( 60 * 60 * 24 * 14 );
59 if ($this->time_since_first_use() <= $two_weeks_in_seconds) {
60 return false;
61 }
62
63 // only show if user did not dismiss before
64 $user = wp_get_current_user();
65 if (get_user_meta($user->ID, $this->meta_key_dismissed, true)) {
66 return false;
67 }
68
69 echo '<div class="notice notice-info boxzilla-is-dismissible">';
70 echo '<p>';
71 echo esc_html__('You\'ve been using Boxzilla for some time now; we hope you love it!', 'boxzilla'), ' <br />';
72 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>';
73 echo esc_html__('It would be of great help to us.', 'boxzilla');
74 echo '</p>';
75 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>';
76 echo '</div>';
77 return true;
78 }
79
80 /**
81 * @return int
82 */
83 private function time_since_first_use()
84 {
85 $options = get_option('boxzilla_settings');
86
87 // option was never added before, do it now.
88 if (empty($options['first_activated_on'])) {
89 $options['first_activated_on'] = time();
90 update_option('boxzilla_settings', $options);
91 }
92
93 return time() - $options['first_activated_on'];
94 }
95 }
96