@@ -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 | public $days; |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @param array $args Object settings |
| 80 | 80 | */ |
| 81 | - public function __construct( $args ) { |
|
| 81 | + public function __construct($args) { |
|
| 82 | 82 | |
| 83 | - $args = wp_parse_args( $args, $this->get_defaults() ); |
|
| 83 | + $args = wp_parse_args($args, $this->get_defaults()); |
|
| 84 | 84 | $this->days = $args['days_after']; |
| 85 | 85 | $this->type = $args['type']; |
| 86 | 86 | $this->slug = $args['slug']; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $this->scope = $args['scope']; |
| 92 | 92 | |
| 93 | 93 | // Set the unique identifying key for this instance |
| 94 | - $this->key = 'wrm_' . substr( md5( plugin_basename( __FILE__ ) ), 0, 20 ); |
|
| 94 | + $this->key = 'wrm_' . substr(md5(plugin_basename(__FILE__)), 0, 20); |
|
| 95 | 95 | $this->link_id = 'wrm-review-link-' . $this->key; |
| 96 | 96 | |
| 97 | 97 | // Instantiate |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | 'type' => '', |
| 113 | 113 | 'slug' => '', |
| 114 | 114 | 'rating' => 5, |
| 115 | - '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' ) ), |
|
| 116 | - 'link_label' => esc_html__( 'Click here to leave your review', 'wp-review-me' ), |
|
| 115 | + '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')), |
|
| 116 | + 'link_label' => esc_html__('Click here to leave your review', 'wp-review-me'), |
|
| 117 | 117 | // Parameters used in WP Dismissible Notices Handler |
| 118 | 118 | 'cap' => 'administrator', |
| 119 | 119 | 'scope' => 'global', |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | private function init() { |
| 133 | 133 | |
| 134 | 134 | // Make sure WordPress is compatible |
| 135 | - if ( ! $this->is_wp_compatible() ) { |
|
| 135 | + if ( ! $this->is_wp_compatible()) { |
|
| 136 | 136 | $this->spit_error( |
| 137 | 137 | sprintf( |
| 138 | - 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' ), |
|
| 138 | + 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'), |
|
| 139 | 139 | $this->wordpress_version_required |
| 140 | 140 | ) |
| 141 | 141 | ); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Make sure PHP is compatible |
| 147 | - if ( ! $this->is_php_compatible() ) { |
|
| 147 | + if ( ! $this->is_php_compatible()) { |
|
| 148 | 148 | $this->spit_error( |
| 149 | 149 | sprintf( |
| 150 | - 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' ), |
|
| 150 | + 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'), |
|
| 151 | 151 | $this->php_version_required |
| 152 | 152 | ) |
| 153 | 153 | ); |
@@ -156,18 +156,18 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Make sure the dependencies are loaded |
| 159 | - if ( ! function_exists( 'dnh_register_notice' ) ) { |
|
| 159 | + if ( ! function_exists('dnh_register_notice')) { |
|
| 160 | 160 | |
| 161 | - $dnh_file = trailingslashit( plugin_dir_path( __FILE__ ) ) . 'vendor/julien731/wp-dismissible-notices-handler/handler.php'; |
|
| 161 | + $dnh_file = trailingslashit(plugin_dir_path(__FILE__)) . 'vendor/julien731/wp-dismissible-notices-handler/handler.php'; |
|
| 162 | 162 | |
| 163 | - if ( file_exists( $dnh_file ) ) { |
|
| 164 | - require( $dnh_file ); |
|
| 163 | + if (file_exists($dnh_file)) { |
|
| 164 | + require($dnh_file); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( ! function_exists( 'dnh_register_notice' ) ) { |
|
| 167 | + if ( ! function_exists('dnh_register_notice')) { |
|
| 168 | 168 | $this->spit_error( |
| 169 | 169 | sprintf( |
| 170 | - esc_html__( 'Dependencies are missing. Please run a %s.', 'wp-review-me' ), |
|
| 170 | + esc_html__('Dependencies are missing. Please run a %s.', 'wp-review-me'), |
|
| 171 | 171 | '<code>composer install</code>' |
| 172 | 172 | ) |
| 173 | 173 | ); |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - add_action( 'admin_footer', array( $this, 'script' ) ); |
|
| 180 | - add_action( 'wp_ajax_wrm_clicked_review', array( $this, 'dismiss_notice' ) ); |
|
| 179 | + add_action('admin_footer', array($this, 'script')); |
|
| 180 | + add_action('wp_ajax_wrm_clicked_review', array($this, 'dismiss_notice')); |
|
| 181 | 181 | |
| 182 | 182 | // And let's roll... maybe. |
| 183 | 183 | $this->maybe_prompt(); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | private function is_wp_compatible() { |
| 194 | 194 | |
| 195 | - if ( version_compare( get_bloginfo( 'version' ), $this->wordpress_version_required, '<' ) ) { |
|
| 195 | + if (version_compare(get_bloginfo('version'), $this->wordpress_version_required, '<')) { |
|
| 196 | 196 | return false; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | private function is_php_compatible() { |
| 210 | 210 | |
| 211 | - if ( version_compare( phpversion(), $this->php_version_required, '<' ) ) { |
|
| 211 | + if (version_compare(phpversion(), $this->php_version_required, '<')) { |
|
| 212 | 212 | return false; |
| 213 | 213 | } |
| 214 | 214 | |
@@ -225,11 +225,11 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return void |
| 227 | 227 | */ |
| 228 | - protected function spit_error( $error ) { |
|
| 228 | + protected function spit_error($error) { |
|
| 229 | 229 | printf( |
| 230 | 230 | '<div style="margin: 20px; text-align: center;"><strong>%1$s</strong> %2$s</pre></div>', |
| 231 | - esc_html__( 'WP Review Me Error:', 'wp-review-me' ), |
|
| 232 | - wp_kses_post( $error ) |
|
| 231 | + esc_html__('WP Review Me Error:', 'wp-review-me'), |
|
| 232 | + wp_kses_post($error) |
|
| 233 | 233 | ); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function is_time() { |
| 243 | 243 | |
| 244 | - $installed = (int) get_option( $this->key, 0 ); |
|
| 244 | + $installed = (int) get_option($this->key, 0); |
|
| 245 | 245 | |
| 246 | - if ( 0 === $installed ) { |
|
| 246 | + if (0 === $installed) { |
|
| 247 | 247 | $this->setup_date(); |
| 248 | 248 | $installed = time(); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if ( $installed + ( $this->days * 86400 ) > time() ) { |
|
| 251 | + if ($installed + ($this->days * 86400) > time()) { |
|
| 252 | 252 | return false; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | protected function setup_date() { |
| 266 | - update_option( $this->key, time() ); |
|
| 266 | + update_option($this->key, time()); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | $link = 'https://wordpress.org/support/'; |
| 278 | 278 | |
| 279 | - switch ( $this->type ) { |
|
| 279 | + switch ($this->type) { |
|
| 280 | 280 | |
| 281 | 281 | case 'theme': |
| 282 | 282 | $link .= 'theme/'; |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $link .= $this->slug . '/reviews'; |
| 292 | - $link = add_query_arg( 'rate', $this->rating, $link ); |
|
| 293 | - $link = esc_url( $link . '#new-post' ); |
|
| 292 | + $link = add_query_arg('rate', $this->rating, $link); |
|
| 293 | + $link = esc_url($link . '#new-post'); |
|
| 294 | 294 | |
| 295 | 295 | return $link; |
| 296 | 296 | |
@@ -318,14 +318,14 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | protected function maybe_prompt() { |
| 320 | 320 | |
| 321 | - if ( ! $this->is_time() ) { |
|
| 321 | + if ( ! $this->is_time()) { |
|
| 322 | 322 | return; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - dnh_register_notice( $this->key, 'updated', $this->get_message(), array( |
|
| 325 | + dnh_register_notice($this->key, 'updated', $this->get_message(), array( |
|
| 326 | 326 | 'scope' => $this->scope, |
| 327 | 327 | 'cap' => $this->cap |
| 328 | - ) ); |
|
| 328 | + )); |
|
| 329 | 329 | |
| 330 | 330 | } |
| 331 | 331 | |
@@ -370,26 +370,26 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | public function dismiss_notice() { |
| 372 | 372 | |
| 373 | - if ( empty( $_POST ) ) { |
|
| 373 | + if (empty($_POST)) { |
|
| 374 | 374 | echo 'missing POST'; |
| 375 | 375 | die(); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ( ! isset( $_POST['id'] ) ) { |
|
| 378 | + if ( ! isset($_POST['id'])) { |
|
| 379 | 379 | echo 'missing ID'; |
| 380 | 380 | die(); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - $id = sanitize_text_field( $_POST['id'] ); |
|
| 383 | + $id = sanitize_text_field($_POST['id']); |
|
| 384 | 384 | |
| 385 | - if ( $id !== $this->link_id ) { |
|
| 385 | + if ($id !== $this->link_id) { |
|
| 386 | 386 | echo "not this instance's job"; |
| 387 | 387 | die(); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Get the DNH notice ID ready |
| 391 | - $notice_id = DNH()->get_id( str_replace( 'wrm-review-link-', '', $id ) ); |
|
| 392 | - $dismissed = DNH()->dismiss_notice( $notice_id ); |
|
| 391 | + $notice_id = DNH()->get_id(str_replace('wrm-review-link-', '', $id)); |
|
| 392 | + $dismissed = DNH()->dismiss_notice($notice_id); |
|
| 393 | 393 | |
| 394 | 394 | echo $dismissed; |
| 395 | 395 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @param string $id The notice ID |
| 402 | 402 | * @param string $notice_id The notice ID as defined by the DNH class |
| 403 | 403 | */ |
| 404 | - do_action( 'wrm_after_notice_dismissed', $id, $notice_id ); |
|
| 404 | + do_action('wrm_after_notice_dismissed', $id, $notice_id); |
|
| 405 | 405 | |
| 406 | 406 | // Stop execution here |
| 407 | 407 | die(); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $link = $this->get_review_link_tag(); |
| 421 | 421 | $message = $message . ' ' . $link; |
| 422 | 422 | |
| 423 | - return wp_kses_post( $message ); |
|
| 423 | + return wp_kses_post($message); |
|
| 424 | 424 | |
| 425 | 425 | } |
| 426 | 426 | |