PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 1.0.9
Check & Log Email – Easy Email Testing & Mail logging v1.0.9
2.0.15 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 / include / Core / Check_Email_Review.php
check-email / include / Core Last commit date
DB 2 years ago Request 2 years ago UI 2 years ago Check_Email_Admin_Capability_Giver.php 2 years ago Check_Email_From_Handler.php 2 years ago Check_Email_Log.php 2 years ago Check_Email_Logger.php 2 years ago Check_Email_Review.php 2 years ago Loadie.php 2 years ago
Check_Email_Review.php
163 lines
1 <?php namespace CheckEmail\Core;
2
3 defined( 'ABSPATH' ) || exit; // Exit if accessed directly
4
5 /**
6 * Class Check Email Review.
7 */
8 class Check_Email_Review {
9
10 private $value;
11 private $messages;
12 private $link = 'https://wordpress.org/support/plugin/%s/reviews/#new-post';
13 private $slug = 'check-email';
14
15 function __construct() {
16
17 $this->messages = array(
18 'notice' => esc_html__( "Hi there! Stoked to see you're using Check & Log 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' ),
19 'rate' => esc_html__( 'Rate the plugin', 'check-email' ),
20 'rated' => esc_html__( 'Remind me later', 'check-email' ),
21 'no_rate' => esc_html__( 'Don\'t show again', 'check-email' ),
22 );
23
24 if ( isset( $args['messages'] ) ) {
25 $this->messages = wp_parse_args( $args['messages'], $this->messages );
26 }
27
28 add_action( 'init', array( $this, 'init' ) );
29
30 }
31
32 public function init() {
33 if ( ! is_admin() ) {
34 return;
35 }
36
37 $this->value = $this->value();
38
39 if ( $this->check() ) {
40 add_action( 'admin_notices', array( $this, 'five_star_wp_rate_notice' ) );
41 add_action( 'wp_ajax_epsilon_check-email_review', array( $this, 'ajax' ) );
42 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
43 add_action( 'admin_print_footer_scripts', array( $this, 'ajax_script' ) );
44 }
45
46 }
47
48 private function check() {
49
50 if ( ! current_user_can('manage_options') ) {
51 return false;
52 }
53
54 return( time() > $this->value );
55
56 }
57
58 private function value() {
59
60 $value = get_option( 'check-email-rate-time', false );
61
62 if ( $value ) {
63 return $value;
64 }
65
66 $value = time() + DAY_IN_SECONDS;
67 update_option( 'check-email-rate-time', $value );
68
69 return $value;
70
71 }
72
73 public function five_star_wp_rate_notice() {
74 $url = sprintf( $this->link, $this->slug );
75
76 ?>
77 <div id="<?php echo esc_attr($this->slug) ?>-epsilon-review-notice" class="notice notice-success is-dismissible" style="margin-top:30px;">
78 <p><?php echo sprintf( esc_html( $this->messages['notice'] ), esc_html( $this->value ) ) ; ?></p>
79 <p class="actions">
80 <a id="epsilon-rate" href="<?php echo esc_url( $url ) ?>" target="_blank" class="button button-primary epsilon-review-button">
81 <?php echo esc_html( $this->messages['rate'] ); ?>
82 </a>
83 <a id="epsilon-later" href="#" style="margin-left:10px" class="epsilon-review-button"><?php echo esc_html( $this->messages['rated'] ); ?></a>
84 <a id="epsilon-no-rate" href="#" style="margin-left:10px" class="epsilon-review-button"><?php echo esc_html( $this->messages['no_rate'] ); ?></a>
85 </p>
86 </div>
87 <?php
88 }
89
90 public function ajax() {
91
92 check_ajax_referer( 'epsilon-check-email-review', 'security' );
93
94 if ( ! isset( $_POST['check'] ) ) {
95 wp_die( 'ok' );
96 }
97
98 $time = get_option( 'check-email-rate-time' );
99
100 if ( 'epsilon-rate' == $_POST['check'] ) {
101 $time = time() + YEAR_IN_SECONDS * 5;
102 }elseif ( 'epsilon-later' == $_POST['check'] ) {
103 $time = time() + WEEK_IN_SECONDS;
104 }elseif ( 'epsilon-no-rate' == $_POST['check'] ) {
105 $time = time() + YEAR_IN_SECONDS * 5;
106 }
107
108 update_option( 'check-email-rate-time', $time );
109 wp_die( 'ok' );
110
111 }
112
113 public function enqueue() {
114 wp_enqueue_script( 'jquery' );
115 }
116
117 public function ajax_script() {
118
119 $ajax_nonce = wp_create_nonce( "epsilon-check-email-review" );
120
121 ?>
122
123 <script type="text/javascript">
124 jQuery( document ).ready( function( $ ){
125
126 $( '#check-email-epsilon-review-notice button' ).on( 'click', function(){
127 $( '#epsilon-no-rate' ).trigger( 'click' );
128 });
129
130 $( '.epsilon-review-button' ).on( 'click', function( evt ){
131 var href = $(this).attr('href'),
132 id = $(this).attr('id');
133
134 if ( 'epsilon-rate' != id ) {
135 evt.preventDefault();
136 }
137
138 var data = {
139 action: 'epsilon_check-email_review',
140 security: '<?php echo esc_js($ajax_nonce); ?>',
141 check: id
142 };
143
144 if ( 'epsilon-rated' === id ) {
145 data['epsilon-review'] = 1;
146 }
147
148 $.post( '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ) ?>', data, function( response ) {
149 $( '#<?php echo esc_html( $this->slug ) ?>-epsilon-review-notice' ).slideUp( 'fast', function() {
150 $( this ).remove();
151 } );
152 });
153
154 } );
155
156 });
157 </script>
158
159 <?php
160 }
161 }
162
163