PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 1.0.13
Check & Log Email – Easy Email Testing & Mail logging v1.0.13
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_Export_Log.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
167 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 ( ! current_user_can('manage_options') ) {
95 return false;
96 }
97
98 if ( ! isset( $_POST['check'] ) ) {
99 wp_die( 'ok' );
100 }
101
102 $time = get_option( 'check-email-rate-time' );
103
104 if ( 'epsilon-rate' == $_POST['check'] ) {
105 $time = time() + YEAR_IN_SECONDS * 5;
106 }elseif ( 'epsilon-later' == $_POST['check'] ) {
107 $time = time() + WEEK_IN_SECONDS;
108 }elseif ( 'epsilon-no-rate' == $_POST['check'] ) {
109 $time = time() + YEAR_IN_SECONDS * 5;
110 }
111
112 update_option( 'check-email-rate-time', $time );
113 wp_die( 'ok' );
114
115 }
116
117 public function enqueue() {
118 wp_enqueue_script( 'jquery' );
119 }
120
121 public function ajax_script() {
122
123 $ajax_nonce = wp_create_nonce( "epsilon-check-email-review" );
124
125 ?>
126
127 <script type="text/javascript">
128 jQuery( document ).ready( function( $ ){
129
130 $( '#check-email-epsilon-review-notice button' ).on( 'click', function(){
131 $( '#epsilon-no-rate' ).trigger( 'click' );
132 });
133
134 $( '.epsilon-review-button' ).on( 'click', function( evt ){
135 var href = $(this).attr('href'),
136 id = $(this).attr('id');
137
138 if ( 'epsilon-rate' != id ) {
139 evt.preventDefault();
140 }
141
142 var data = {
143 action: 'epsilon_check-email_review',
144 security: '<?php echo esc_js($ajax_nonce); ?>',
145 check: id
146 };
147
148 if ( 'epsilon-rated' === id ) {
149 data['epsilon-review'] = 1;
150 }
151
152 $.post( '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ) ?>', data, function( response ) {
153 $( '#<?php echo esc_html( $this->slug ) ?>-epsilon-review-notice' ).slideUp( 'fast', function() {
154 $( this ).remove();
155 } );
156 });
157
158 } );
159
160 });
161 </script>
162
163 <?php
164 }
165 }
166
167