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

92 lines 2.4 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 add_action( 'admin_notices', array( $this, 'show' ) );
24 add_action( 'boxzilla_admin_dismiss_review_notice', array( $this, 'dismiss' ) );
25 }
26
27 /**
28 * Set flag in user meta so notice won't be shown.
29 */
30 public function dismiss() {
31 $user = wp_get_current_user();
32 update_user_meta( $user->ID, $this->meta_key_dismissed, 1 );
33 }
34
35 /**
36 * @return bool
37 */
38 public function show() {
39 $screen = get_current_screen();
40 if ( ! $screen instanceof WP_Screen ) {
41 return false;
42 }
43
44 // on some boxzilla screen?
45 if ( $screen->post_type !== 'boxzilla-box' ) {
46 return false;
47 }
48
49 // authorized?
50 if ( ! current_user_can( 'edit_posts' ) ) {
51 return false;
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 false;
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 false;
64 }
65
66 echo '<div class="notice notice-info boxzilla-is-dismissible">';
67 echo '<p>';
68 echo __( 'You\'ve been using Boxzilla for some time now; we hope you love it!', 'boxzilla' ) . ' <br />';
69 echo sprintf( __( 'If you do, please <a href="%s">leave us a 5�
70 rating on WordPress.org</a>. It would be of great help to us.', 'boxzilla' ), 'https://wordpress.org/support/view/plugin-reviews/boxzilla?rate=5#new-post' );
71 echo '</p>';
72 echo '<form method="POST"><button type="submit" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'boxzilla' ) . '</span></button><input type="hidden" name="_boxzilla_admin_action" value="dismiss_review_notice"/></form>';
73 echo '</div>';
74 return true;
75 }
76
77 /**
78 * @return int
79 */
80 private function time_since_first_use() {
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