PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / trunk
Check & Log Email – Easy Email Testing & Mail logging vtrunk
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 1 month ago Request 1 month ago UI 1 month ago Auth.php 1 month ago Check_Email_Admin_Capability_Giver.php 1 month ago Check_Email_Export_Log.php 1 month ago Check_Email_From_Handler.php 1 month ago Check_Email_Log.php 1 month ago Check_Email_Logger.php 1 month ago Check_Email_Multisite.php 1 month ago Check_Email_Review.php 1 month ago Loadie.php 1 month ago
Check_Email_Review.php
167 lines
1 <?php namespace CheckEmail\Core;
2
3 defined( 'ABSPATH' ) || exit; // Exit if accessed directly
4
5
6 /**
7 * Class Check Email Review.
8 */
9 class Check_Email_Review {
10
11 private $value;
12 private $messages;
13 private $link = 'https://wordpress.org/support/plugin/%s/reviews/#new-post';
14 private $slug = 'check-email';
15
16 function __construct() {
17 add_action( 'init', array( $this, 'init' ) );
18
19 }
20
21 public function init() {
22 if ( ! is_admin() ) {
23 return;
24 }
25
26 $this->value = $this->value();
27
28 if ( $this->check() ) {
29 add_action( 'admin_notices', array( $this, 'five_star_wp_rate_notice' ) );
30 add_action( 'wp_ajax_epsilon_check-email_review', array( $this, 'ajax' ) );
31 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
32 add_action( 'admin_print_footer_scripts', array( $this, 'ajax_script' ) );
33 }
34
35 }
36
37 private function check() {
38
39 if ( ! current_user_can('manage_options') ) {
40 return false;
41 }
42
43 return( time() > $this->value );
44
45 }
46
47 private function value() {
48
49 $value = get_option( 'check-email-rate-time', false );
50
51 if ( $value ) {
52 return $value;
53 }
54
55 $value = time() + DAY_IN_SECONDS;
56 update_option( 'check-email-rate-time', $value );
57
58 return $value;
59
60 }
61
62 public function five_star_wp_rate_notice() {
63 $url = sprintf( $this->link, $this->slug );
64
65 $this->messages = array(
66 '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' ),
67 'rate' => esc_html__( 'Rate the plugin', 'check-email' ),
68 'rated' => esc_html__( 'Remind me later', 'check-email' ),
69 'no_rate' => esc_html__( 'Don\'t show again', 'check-email' ),
70 );
71
72 if ( isset( $args['messages'] ) ) {
73 $this->messages = wp_parse_args( $args['messages'], $this->messages );
74 }
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