@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @copyright 2016 Julien Liabeuf |
20 | 20 | */ |
21 | 21 | |
22 | -if ( ! class_exists( 'WP_Review_Me' ) ) { |
|
22 | +if ( ! class_exists('WP_Review_Me')) { |
|
23 | 23 | |
24 | 24 | class WP_Review_Me { |
25 | 25 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param array $args Object settings |
72 | 72 | */ |
73 | - public function __construct( $args ) { |
|
73 | + public function __construct($args) { |
|
74 | 74 | |
75 | - $args = wp_parse_args( $args, $this->get_defaults() ); |
|
75 | + $args = wp_parse_args($args, $this->get_defaults()); |
|
76 | 76 | $this->days = $args['days_after']; |
77 | 77 | $this->type = $args['type']; |
78 | 78 | $this->slug = $args['slug']; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->scope = $args['scope']; |
84 | 84 | |
85 | 85 | // Set the unique identifying key for this instance |
86 | - $this->key = 'wrm_' . substr( md5( plugin_basename( __FILE__ ) ), 0, 20 ); |
|
86 | + $this->key = 'wrm_' . substr(md5(plugin_basename(__FILE__)), 0, 20); |
|
87 | 87 | $this->link_id = 'wrm-review-link-' . $this->key; |
88 | 88 | |
89 | 89 | // Instantiate |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | 'type' => '', |
105 | 105 | 'slug' => '', |
106 | 106 | 'rating' => 5, |
107 | - 'message' => sprintf( esc_html__( 'Hey! It's been a little while that you've been using this product. You might not realize it, but user reviews are such a great help to us. We would be so grateful if you could take a minute to leave a review on WordPress.org. Many thanks in advance :)', 'wp-review-me' ) ), |
|
108 | - 'link_label' => esc_html__( 'Click here to leave your review', 'wp-review-me' ), |
|
107 | + 'message' => sprintf(esc_html__('Hey! It's been a little while that you've been using this product. You might not realize it, but user reviews are such a great help to us. We would be so grateful if you could take a minute to leave a review on WordPress.org. Many thanks in advance :)', 'wp-review-me')), |
|
108 | + 'link_label' => esc_html__('Click here to leave your review', 'wp-review-me'), |
|
109 | 109 | // Parameters used in WP Dismissible Notices Handler |
110 | 110 | 'cap' => 'administrator', |
111 | 111 | 'scope' => 'global', |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | private function init() { |
125 | 125 | |
126 | 126 | // Make sure WordPress is compatible |
127 | - if ( ! $this->is_wp_compatible() ) { |
|
127 | + if ( ! $this->is_wp_compatible()) { |
|
128 | 128 | $this->spit_error( |
129 | 129 | sprintf( |
130 | - esc_html__( 'The library can not be used because your version of WordPress is too old. You need version %s at least.', 'wp-review-me' ), |
|
130 | + esc_html__('The library can not be used because your version of WordPress is too old. You need version %s at least.', 'wp-review-me'), |
|
131 | 131 | $this->wordpress_version_required |
132 | 132 | ) |
133 | 133 | ); |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | // Make sure PHP is compatible |
139 | - if ( ! $this->is_php_compatible() ) { |
|
139 | + if ( ! $this->is_php_compatible()) { |
|
140 | 140 | $this->spit_error( |
141 | 141 | sprintf( |
142 | - esc_html__( 'The library can not be used because your version of PHP is too old. You need version %s at least.', 'wp-review-me' ), |
|
142 | + esc_html__('The library can not be used because your version of PHP is too old. You need version %s at least.', 'wp-review-me'), |
|
143 | 143 | $this->php_version_required |
144 | 144 | ) |
145 | 145 | ); |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // Make sure the dependencies are loaded |
151 | - if ( ! function_exists( 'dnh_register_notice' ) ) { |
|
151 | + if ( ! function_exists('dnh_register_notice')) { |
|
152 | 152 | |
153 | - $dnh_file = trailingslashit( plugin_dir_path( __FILE__ ) ) . 'vendor/julien731/wp-dismissible-notices-handler/handler.php'; |
|
153 | + $dnh_file = trailingslashit(plugin_dir_path(__FILE__)) . 'vendor/julien731/wp-dismissible-notices-handler/handler.php'; |
|
154 | 154 | |
155 | - if ( file_exists( $dnh_file ) ) { |
|
156 | - require( $dnh_file ); |
|
155 | + if (file_exists($dnh_file)) { |
|
156 | + require($dnh_file); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( ! function_exists( 'dnh_register_notice' ) ) { |
|
159 | + if ( ! function_exists('dnh_register_notice')) { |
|
160 | 160 | $this->spit_error( |
161 | 161 | sprintf( |
162 | - esc_html__( 'Dependencies are missing. Please run a %s.', 'wp-review-me' ), |
|
162 | + esc_html__('Dependencies are missing. Please run a %s.', 'wp-review-me'), |
|
163 | 163 | '<code>composer install</code>' |
164 | 164 | ) |
165 | 165 | ); |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - add_action( 'admin_footer', array( $this, 'script' ) ); |
|
172 | - add_action( 'wp_ajax_wrm_clicked_review', array( $this, 'dismiss_notice' ) ); |
|
171 | + add_action('admin_footer', array($this, 'script')); |
|
172 | + add_action('wp_ajax_wrm_clicked_review', array($this, 'dismiss_notice')); |
|
173 | 173 | |
174 | 174 | // And let's roll... maybe. |
175 | 175 | $this->maybe_prompt(); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | private function is_wp_compatible() { |
186 | 186 | |
187 | - if ( version_compare( get_bloginfo( 'version' ), $this->wordpress_version_required, '<' ) ) { |
|
187 | + if (version_compare(get_bloginfo('version'), $this->wordpress_version_required, '<')) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | private function is_php_compatible() { |
202 | 202 | |
203 | - if ( version_compare( phpversion(), $this->php_version_required, '<' ) ) { |
|
203 | + if (version_compare(phpversion(), $this->php_version_required, '<')) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return void |
219 | 219 | */ |
220 | - protected function spit_error( $error ) { |
|
220 | + protected function spit_error($error) { |
|
221 | 221 | printf( |
222 | 222 | '<div style="margin: 20px; text-align: center;"><strong>%1$s</strong> %2$s</pre></div>', |
223 | - esc_html__( 'WP Review Me Error:', 'wp-review-me' ), |
|
224 | - wp_kses_post( $error ) |
|
223 | + esc_html__('WP Review Me Error:', 'wp-review-me'), |
|
224 | + wp_kses_post($error) |
|
225 | 225 | ); |
226 | 226 | } |
227 | 227 | |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function is_time() { |
235 | 235 | |
236 | - $installed = (int) get_option( $this->key, 0 ); |
|
236 | + $installed = (int) get_option($this->key, 0); |
|
237 | 237 | |
238 | - if ( 0 === $installed ) { |
|
238 | + if (0 === $installed) { |
|
239 | 239 | $this->setup_date(); |
240 | 240 | $installed = time(); |
241 | 241 | } |
242 | 242 | |
243 | - if ( $installed + ( $this->days * 86400 ) > time() ) { |
|
243 | + if ($installed + ($this->days * 86400) > time()) { |
|
244 | 244 | return false; |
245 | 245 | } |
246 | 246 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return void |
256 | 256 | */ |
257 | 257 | protected function setup_date() { |
258 | - update_option( $this->key, time() ); |
|
258 | + update_option($this->key, time()); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | |
269 | 269 | $link = 'https://wordpress.org/support/'; |
270 | 270 | |
271 | - switch ( $this->type ) { |
|
271 | + switch ($this->type) { |
|
272 | 272 | |
273 | 273 | case 'theme': |
274 | 274 | $link .= 'theme/'; |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | $link .= $this->slug . '/reviews'; |
284 | - $link = add_query_arg( 'rate', $this->rating, $link ); |
|
285 | - $link = esc_url( $link . '#new-post' ); |
|
284 | + $link = add_query_arg('rate', $this->rating, $link); |
|
285 | + $link = esc_url($link . '#new-post'); |
|
286 | 286 | |
287 | 287 | return $link; |
288 | 288 | |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | */ |
311 | 311 | protected function maybe_prompt() { |
312 | 312 | |
313 | - if ( ! $this->is_time() ) { |
|
313 | + if ( ! $this->is_time()) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | - dnh_register_notice( $this->key, 'updated', $this->get_message(), array( |
|
317 | + dnh_register_notice($this->key, 'updated', $this->get_message(), array( |
|
318 | 318 | 'scope' => $this->scope, |
319 | 319 | 'cap' => $this->cap |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -362,26 +362,26 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function dismiss_notice() { |
364 | 364 | |
365 | - if ( empty( $_POST ) ) { |
|
365 | + if (empty($_POST)) { |
|
366 | 366 | echo 'missing POST'; |
367 | 367 | die(); |
368 | 368 | } |
369 | 369 | |
370 | - if ( ! isset( $_POST['id'] ) ) { |
|
370 | + if ( ! isset($_POST['id'])) { |
|
371 | 371 | echo 'missing ID'; |
372 | 372 | die(); |
373 | 373 | } |
374 | 374 | |
375 | - $id = sanitize_text_field( $_POST['id'] ); |
|
375 | + $id = sanitize_text_field($_POST['id']); |
|
376 | 376 | |
377 | - if ( $id !== $this->link_id ) { |
|
377 | + if ($id !== $this->link_id) { |
|
378 | 378 | echo "not this instance's job"; |
379 | 379 | die(); |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Get the DNH notice ID ready |
383 | - $notice_id = DNH()->get_id( str_replace( 'wrm-review-link-', '', $id ) ); |
|
384 | - $dismissed = DNH()->dismiss_notice( $notice_id ); |
|
383 | + $notice_id = DNH()->get_id(str_replace('wrm-review-link-', '', $id)); |
|
384 | + $dismissed = DNH()->dismiss_notice($notice_id); |
|
385 | 385 | |
386 | 386 | echo $dismissed; |
387 | 387 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param string $id The notice ID |
394 | 394 | * @param string $notice_id The notice ID as defined by the DNH class |
395 | 395 | */ |
396 | - do_action( 'wrm_after_notice_dismissed', $id, $notice_id ); |
|
396 | + do_action('wrm_after_notice_dismissed', $id, $notice_id); |
|
397 | 397 | |
398 | 398 | // Stop execution here |
399 | 399 | die(); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $link = $this->get_review_link_tag(); |
413 | 413 | $message = $message . ' ' . $link; |
414 | 414 | |
415 | - return wp_kses_post( $message ); |
|
415 | + return wp_kses_post($message); |
|
416 | 416 | |
417 | 417 | } |
418 | 418 |