PluginProbe
WPIDE – File Manager & Code Editor / 3.4.1
WPIDE – File Manager & Code Editor v3.4.1
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
← All changes | App/Classes/ReviewNotice.php +46 -40 3.5.93.4.1 View file →
@@ -15,35 +15,48 @@
15 15 class ReviewNotice {
16 16
17 17 /**
18 18 * Interval in days between reminder notice
19 + *
20 + * @since 1.0.0
21 + * @access public
22 + * @const int days_interval
19 23 */
20 24 public const days_interval = 7;
21 25
22 26 /**
23 27 * Max days before stopping the reminder notice
28 + *
29 + * @since 1.0.0
30 + * @access public
31 + * @const int max_days
24 32 */
25 33 public const max_days = 120;
26 34
27 35 /**
28 36 * Check if a notice is currently active
37 + *
38 + * @since 1.0.0
39 + * @access public
40 + * @var bool $active_notice
29 41 */
30 42 public static $active_notice = false;
31 43
32 44 /**
33 45 * Review url
46 + *
47 + * @since 1.0.0
48 + * @access public
49 + * @var string review_url
34 50 */
35 51 public static $review_url = '';
36 52
37 - /**
38 - * @throws \Exception
39 - */
40 53 public static function init() {
41 54
42 55 self::$review_url = 'https://wordpress.org/support/plugin/'. SLUG .'/reviews/?rate=5&filter=5/#new-post';
43 56
44 57 // Add Ajax Events
45 - add_action("wp_ajax_".SLUG."_plugin_rate_action", [__CLASS__, 'ajaxPluginRateAction']);
58 + add_action("wp_ajax_".SLUG."_plugin_rate_action", [__CLASS__, 'ajax_plugin_rate_action']);
46 59 add_action('admin_enqueue_scripts', [__CLASS__, 'enqueue_admin_assets'], 1);
47 60
48 61 if(!self::enabled()) {
49 62 return;
@@ -54,21 +67,18 @@
54 67 // Init Review Notice
55 68 add_action( 'admin_notices', [ __CLASS__, 'add_review_notice' ] );
56 69 }
57 70
58 - /**
59 - * @throws \Exception
60 - */
61 71 public static function enabled(): bool
62 72 {
63 73
64 - $min_days_trigger = self::getMinDaysTrigger();
65 - $days_passed = self::getDaysPassed();
74 + $min_days_trigger = self::get_min_days_trigger();
75 + $days_passed = self::get_days_passed();
66 76
67 77 return $min_days_trigger !== -1 && $days_passed >= $min_days_trigger && !self::$active_notice;
68 78 }
69 79
70 - public static function getMinDaysTrigger(): int
80 + public static function get_min_days_trigger(): int
71 81 {
72 82
73 83 $option_key = App::instance()->prefix('review_notice_min_days');
74 84 return intval(get_option($option_key, self::days_interval));
@@ -73,16 +83,15 @@
73 83 $option_key = App::instance()->prefix('review_notice_min_days');
74 84 return intval(get_option($option_key, self::days_interval));
75 85 }
76 86
77 - public static function setMinDaysTrigger($value): bool
78 - {
87 + public static function set_min_days_trigger($value) {
79 88
80 89 $option_key = App::instance()->prefix('review_notice_min_days');
81 90 return update_option($option_key, $value);
82 91 }
83 92
84 - public static function getDaysPassed(): int
93 + public static function get_days_passed(): int
85 94 {
86 95
87 96 $install_timestamp = Migrations::$installed_time;
88 97 $current_time = time();
@@ -91,10 +100,9 @@
91 100
92 101 return intval(round($date_diff / (60 * 60 * 24)));
93 102 }
94 103
95 - public static function getReadableDaysPassed(): string
96 - {
104 + public static function get_readable_days_passed() {
97 105
98 106 $install_timestamp = Migrations::$installed_time;
99 107 $current_time = time();
100 108
@@ -100,28 +108,28 @@
100 108
101 109 return human_time_diff($install_timestamp, $current_time);
102 110 }
103 111
104 - public static function ajaxPluginRateAction() {
112 + public static function ajax_plugin_rate_action() {
105 113
106 114 // Continue only if the nonce is correct
107 115 $nonce = sanitize_text_field($_REQUEST['_nonce']);
108 116
109 - if ( ! wp_verify_nonce( $nonce, App::instance()->prefix('wp_notice_action_nonce') ) ) {
117 + if ( ! wp_verify_nonce( $nonce, App::instance()->prefix('wp_rate_action_nonce') ) ) {
110 118 wp_send_json_error();
111 119 }
112 120
113 - $notice_action = sanitize_text_field($_POST['notice_action']);
121 + $rate_action = sanitize_text_field($_POST['rate_action']);
114 122
115 - self::ratePlugin($notice_action);
123 + self::rate_plugin($rate_action);
116 124
117 125 wp_send_json_success();
118 126 }
119 127
120 - public static function ratePlugin($notice_action, $days_interval = null) {
128 + public static function rate_plugin($rate_action, $days_interval = null) {
121 129
122 - $min_days_trigger = self::getMinDaysTrigger();
123 - $days_passed = self::getDaysPassed();
130 + $min_days_trigger = self::get_min_days_trigger();
131 + $days_passed = self::get_days_passed();
124 132 $days_interval = !empty($days_interval) ? $days_interval : self::days_interval;
125 133
126 134 if ( -1 === $min_days_trigger ) {
127 135 return;
@@ -126,9 +134,9 @@
126 134 if ( -1 === $min_days_trigger ) {
127 135 return;
128 136 }
129 137
130 - if ('done-rating' === $notice_action) {
138 + if ('done-rating' === $rate_action) {
131 139
132 140 $min_days_trigger = -1;
133 141
134 142 } else {
@@ -139,9 +147,9 @@
139 147 $min_days_trigger = $days_passed + $days_interval;
140 148 }
141 149 }
142 150
143 - self::setMinDaysTrigger($min_days_trigger);
151 + self::set_min_days_trigger($min_days_trigger);
144 152 }
145 153
146 154 public static function add_review_notice() {
147 155
@@ -147,25 +155,23 @@
147 155
148 156 $current_user = wp_get_current_user();
149 157 $first_name = ucfirst(strtolower(!empty($current_user->user_firstname) ? $current_user->user_firstname : $current_user->display_name));
150 158
151 - $time_passed = self::getReadableDaysPassed();
159 + $time_passed = self::get_readable_days_passed();
152 160 $action = SLUG."_plugin_rate_action";
153 161 ?>
154 - <div class="notice notice-info wpide-notice" data-slug="<?php echo esc_attr(SLUG); ?>">
155 - <p>
156 - <?php
157 - echo sprintf(esc_html__("Hey %s, I noticed you've been using %s for the past %s – that’s awesome!", "wpide"), $first_name, '<strong>' . NAME . '</strong>', '<strong>'.$time_passed.'</strong>');
158 - echo '&nbsp;';
159 - echo sprintf(esc_html__('Could you please do me a %1$sBIG favor%2$s and give it a %1$s5-star rating%2$s on WordPress? Just to %1$s help us%2$s spread the word and boost our motivation. Many thanks!', "wpide"), "<strong>", "</strong>");
160 - ?>
161 - <br><br>
162 - <em>~ Georges H</em>
163 - </p>
164 - <ul class="wpide-notice-action" data-action="<?php echo esc_attr($action);?>" data-nonce="<?php echo wp_create_nonce( App::instance()->prefix('wp_notice_action_nonce') ) ?>">
162 + <div class="notice notice-info wpide-rating-notice" data-slug="<?php echo esc_attr(SLUG); ?>">
163 + <?php
164 + echo sprintf(esc_html__("Hey %s, I noticed you've been using %s for the past %s – that’s awesome!", "wpide"), $first_name, '<strong>' . NAME . '</strong>', '<strong>'.$time_passed.'</strong>');
165 + echo '&nbsp;';
166 + echo sprintf(esc_html__('Could you please do me a %1$sBIG favor%2$s and give it a %1$s5-star rating%2$s on WordPress? Just to %1$s help us%2$s spread the word and boost our motivation. Many thanks!', "wpide"), "<strong>", "</strong>");
167 + ?>
168 + <br><br><em>~ Georges H</em>
169 + <br><br>
170 + <ul class="wpide-wp-rate-notice" data-action="<?php echo esc_attr($action);?>" data-nonce="<?php echo wp_create_nonce( App::instance()->prefix('wp_rate_action_nonce') ) ?>">
165 171 <li><span class="dashicons dashicons-thumbs-up"></span> <a target="_blank" href="<?php echo esc_url(self::$review_url);?>"><?php echo esc_html__( 'Ok, you deserve it', 'wpide' ) ?></a></li>
166 - <li><span class="dashicons dashicons-thumbs-down"></span> <a data-action="not-enough" href="#"><?php echo esc_html__( 'Nope, maybe later', 'wpide' ) ?></a></li>
167 - <li><span class="dashicons dashicons-yes"></span> <a data-action="done-rating" href="#"><?php echo esc_html__( 'I already did', 'wpide' ) ?></a></li>
172 + <li><span class="dashicons dashicons-thumbs-down"></span> <a data-rate-action="not-enough" href="#"><?php echo esc_html__( 'Nope, maybe later', 'wpide' ) ?></a></li>
173 + <li><span class="dashicons dashicons-yes"></span> <a data-rate-action="done-rating" href="#"><?php echo esc_html__( 'I already did', 'wpide' ) ?></a></li>
168 174 <li><span class="dashicons dashicons-sos"></span> <a target="_blank" href="https://xplodedthemes.com/support/"><?php echo esc_html__( 'Help me first', 'wpide' ) ?></a></li>
169 175 </ul>
170 176 </div>
171 177 <?php
@@ -173,9 +179,9 @@
173 179
174 180 public static function enqueue_admin_assets()
175 181 {
176 182
177 - wp_enqueue_script(SLUG.'-notice', ASSETS_URL.'global/js/notice-min.js', [], VERSION);
178 - wp_enqueue_style(SLUG.'-notice', ASSETS_URL.'global/css/notice.css', [], VERSION);
183 + wp_enqueue_script(SLUG.'-rating-notice', ASSETS_URL.'global/js/rating-notice-min.js', [], VERSION);
184 + wp_enqueue_style(SLUG.'-rating-notice', ASSETS_URL.'global/css/rating-notice.css', [], VERSION);
179 185 }
180 186
181 187 }