PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 0.6.1
Check & Log Email – Easy Email Testing & Mail logging v0.6.1
1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.13.1 2.0.13.2 2.0.14 2.0.2 2.0.3 2.0.4 2.0.5 2.0.5.1 2.0.6 2.0.7 2.0.8 2.0.9 trunk 0.5.7 0.6.0 0.6.1 0.6.2 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.12.1 1.0.13 1.0.13.1 1.0.2 1.0.3
check-email / class-check-email-review.php
check-email Last commit date
check-email.php 5 years ago class-check-email-review.php 5 years ago readme.txt 5 years ago
class-check-email-review.php
156 lines
1 <?php
2
3 class Check_Email_Review {
4
5 private $value;
6 private $messages;
7 private $link = 'https://wordpress.org/support/plugin/%s/reviews/#new-post';
8 private $slug = 'check-email';
9
10 function __construct() {
11
12 $this->messages = array(
13 'notice' => esc_html__( "Hi there! Stoked to see you're using Check Email for a few days now - hope you like it! And if you do, please consider rating it. It would mean the world to us. Keep on rocking!", 'check-email' ),
14 'rate' => esc_html__( 'Rate the plugin', 'check-email' ),
15 'rated' => esc_html__( 'Remind me later', 'check-email' ),
16 'no_rate' => esc_html__( 'Don\'t show again', 'check-email' ),
17 );
18
19 if ( isset( $args['messages'] ) ) {
20 $this->messages = wp_parse_args( $args['messages'], $this->messages );
21 }
22
23 add_action( 'init', array( $this, 'init' ) );
24
25 }
26
27 public function init() {
28 if ( ! is_admin() ) {
29 return;
30 }
31
32 $this->value = $this->value();
33
34 if ( $this->check() ) {
35 add_action( 'admin_notices', array( $this, 'five_star_wp_rate_notice' ) );
36 add_action( 'wp_ajax_epsilon_check-email_review', array( $this, 'ajax' ) );
37 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
38 add_action( 'admin_print_footer_scripts', array( $this, 'ajax_script' ) );
39 }
40
41 }
42
43 private function check() {
44
45 if ( ! current_user_can('manage_options') ) {
46 return false;
47 }
48
49 return( time() > $this->value );
50
51 }
52
53 private function value() {
54
55 $value = get_option( 'check-email-rate-time', false );
56
57 if ( $value ) {
58 return $value;
59 }
60
61 $value = time() + DAY_IN_SECONDS;
62 update_option( 'check-email-rate-time', $value );
63
64 return $value;
65
66 }
67
68 public function five_star_wp_rate_notice() {
69 $url = sprintf( $this->link, $this->slug );
70
71 ?>
72 <div id="<?php echo esc_attr($this->slug) ?>-epsilon-review-notice" class="notice notice-success is-dismissible" style="margin-top:30px;">
73 <p><?php echo sprintf( esc_html( $this->messages['notice'] ), $this->value ) ; ?></p>
74 <p class="actions">
75 <a id="epsilon-rate" href="<?php echo esc_url( $url ) ?>" target="_blank" class="button button-primary epsilon-review-button">
76 <?php echo esc_html( $this->messages['rate'] ); ?>
77 </a>
78 <a id="epsilon-later" href="#" style="margin-left:10px" class="epsilon-review-button"><?php echo esc_html( $this->messages['rated'] ); ?></a>
79 <a id="epsilon-no-rate" href="#" style="margin-left:10px" class="epsilon-review-button"><?php echo esc_html( $this->messages['no_rate'] ); ?></a>
80 </p>
81 </div>
82 <?php
83 }
84
85 public function ajax() {
86
87 check_ajax_referer( 'epsilon-check-email-review', 'security' );
88
89 if ( ! isset( $_POST['check'] ) ) {
90 wp_die( 'ok' );
91 }
92
93 $time = get_option( 'check-email-rate-time' );
94
95 if ( 'epsilon-rate' == $_POST['check'] ) {
96 $time = time() + YEAR_IN_SECONDS * 5;
97 }elseif ( 'epsilon-later' == $_POST['check'] ) {
98 $time = time() + WEEK_IN_SECONDS;
99 }elseif ( 'epsilon-no-rate' == $_POST['check'] ) {
100 $time = time() + YEAR_IN_SECONDS * 5;
101 }
102
103 update_option( 'check-email-rate-time', $time );
104 wp_die( 'ok' );
105
106 }
107
108 public function enqueue() {
109 wp_enqueue_script( 'jquery' );
110 }
111
112 public function ajax_script() {
113
114 $ajax_nonce = wp_create_nonce( "epsilon-check-email-review" );
115
116 ?>
117
118 <script type="text/javascript">
119 jQuery( document ).ready( function( $ ){
120
121 $( '.epsilon-review-button' ).click( function( evt ){
122 var href = $(this).attr('href'),
123 id = $(this).attr('id');
124
125 if ( 'epsilon-rate' != id ) {
126 evt.preventDefault();
127 }
128
129 var data = {
130 action: 'epsilon_check-email_review',
131 security: '<?php echo $ajax_nonce; ?>',
132 check: id
133 };
134
135 if ( 'epsilon-rated' === id ) {
136 data['epsilon-review'] = 1;
137 }
138
139 $.post( '<?php echo admin_url( 'admin-ajax.php' ) ?>', data, function( response ) {
140 $( '#<?php echo $this->slug ?>-epsilon-review-notice' ).slideUp( 'fast', function() {
141 $( this ).remove();
142 } );
143 });
144
145 } );
146
147 });
148 </script>
149
150 <?php
151 }
152 }
153
154 new Check_Email_Review();
155
156