| @@ -20,11 +20,11 @@ discard block | ||
| 20 | 20 | */ | 
| 21 | 21 | |
| 22 | 22 | // If this file is called directly, abort. | 
| 23 | -if ( ! defined( 'WPINC' ) ) { | |
| 23 | +if ( ! defined('WPINC')) { | |
| 24 | 24 | die; | 
| 25 | 25 | } | 
| 26 | 26 | |
| 27 | -if ( ! class_exists( 'WP_Review_Me' ) ) { | |
| 27 | +if ( ! class_exists('WP_Review_Me')) { | |
| 28 | 28 | |
| 29 | 29 |  	class WP_Review_Me { | 
| 30 | 30 | |
| @@ -75,9 +75,9 @@ discard block | ||
| 75 | 75 | * | 
| 76 | 76 | * @param array $args Object settings | 
| 77 | 77 | */ | 
| 78 | -		public function __construct( $args ) { | |
| 78 | +		public function __construct($args) { | |
| 79 | 79 | |
| 80 | - $args = wp_parse_args( $args, $this->get_defaults() ); | |
| 80 | + $args = wp_parse_args($args, $this->get_defaults()); | |
| 81 | 81 | $this->days = $args['days_after']; | 
| 82 | 82 | $this->type = $args['type']; | 
| 83 | 83 | $this->slug = $args['slug']; | 
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 | $this->scope = $args['scope']; | 
| 89 | 89 | |
| 90 | 90 | // Set the unique identifying key for this instance | 
| 91 | - $this->key = 'wrm_' . substr( md5( plugin_basename( __FILE__ ) ), 0, 20 ); | |
| 91 | + $this->key = 'wrm_' . substr(md5(plugin_basename(__FILE__)), 0, 20); | |
| 92 | 92 | $this->link_id = 'wrm-review-link-' . $this->key; | 
| 93 | 93 | |
| 94 | 94 | // Instantiate | 
| @@ -109,8 +109,8 @@ discard block | ||
| 109 | 109 | 'type' => '', | 
| 110 | 110 | 'slug' => '', | 
| 111 | 111 | 'rating' => 5, | 
| 112 | - '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' ) ), | |
| 113 | - 'link_label' => esc_html__( 'Click here to leave your review', 'wp-review-me' ), | |
| 112 | +				'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')), | |
| 113 | +				'link_label' => esc_html__('Click here to leave your review', 'wp-review-me'), | |
| 114 | 114 | // Parameters used in WP Dismissible Notices Handler | 
| 115 | 115 | 'cap' => 'administrator', | 
| 116 | 116 | 'scope' => 'global', | 
| @@ -129,10 +129,10 @@ discard block | ||
| 129 | 129 |  		private function init() { | 
| 130 | 130 | |
| 131 | 131 | // Make sure WordPress is compatible | 
| 132 | -			if ( ! $this->is_wp_compatible() ) { | |
| 132 | +			if ( ! $this->is_wp_compatible()) { | |
| 133 | 133 | $this->spit_error( | 
| 134 | 134 | sprintf( | 
| 135 | - 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' ), | |
| 135 | +						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'), | |
| 136 | 136 | $this->wordpress_version_required | 
| 137 | 137 | ) | 
| 138 | 138 | ); | 
| @@ -141,10 +141,10 @@ discard block | ||
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | 143 | // Make sure PHP is compatible | 
| 144 | -			if ( ! $this->is_php_compatible() ) { | |
| 144 | +			if ( ! $this->is_php_compatible()) { | |
| 145 | 145 | $this->spit_error( | 
| 146 | 146 | sprintf( | 
| 147 | - 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' ), | |
| 147 | +						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'), | |
| 148 | 148 | $this->php_version_required | 
| 149 | 149 | ) | 
| 150 | 150 | ); | 
| @@ -153,18 +153,18 @@ discard block | ||
| 153 | 153 | } | 
| 154 | 154 | |
| 155 | 155 | // Make sure the dependencies are loaded | 
| 156 | -			if ( ! function_exists( 'dnh_register_notice' ) ) { | |
| 156 | +			if ( ! function_exists('dnh_register_notice')) { | |
| 157 | 157 | |
| 158 | - $dnh_file = trailingslashit( plugin_dir_path( __FILE__ ) ) . 'vendor/julien731/wp-dismissible-notices-handler/handler.php'; | |
| 158 | + $dnh_file = trailingslashit(plugin_dir_path(__FILE__)) . 'vendor/julien731/wp-dismissible-notices-handler/handler.php'; | |
| 159 | 159 | |
| 160 | -				if ( file_exists( $dnh_file ) ) { | |
| 161 | - require( $dnh_file ); | |
| 160 | +				if (file_exists($dnh_file)) { | |
| 161 | + require($dnh_file); | |
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | -				if ( ! function_exists( 'dnh_register_notice' ) ) { | |
| 164 | +				if ( ! function_exists('dnh_register_notice')) { | |
| 165 | 165 | $this->spit_error( | 
| 166 | 166 | sprintf( | 
| 167 | - esc_html__( 'Dependencies are missing. Please run a %s.', 'wp-review-me' ), | |
| 167 | +							esc_html__('Dependencies are missing. Please run a %s.', 'wp-review-me'), | |
| 168 | 168 | '<code>composer install</code>' | 
| 169 | 169 | ) | 
| 170 | 170 | ); | 
| @@ -173,8 +173,8 @@ discard block | ||
| 173 | 173 | } | 
| 174 | 174 | } | 
| 175 | 175 | |
| 176 | - add_action( 'admin_footer', array( $this, 'script' ) ); | |
| 177 | - add_action( 'wp_ajax_wrm_clicked_review', array( $this, 'dismiss_notice' ) ); | |
| 176 | +			add_action('admin_footer', array($this, 'script')); | |
| 177 | +			add_action('wp_ajax_wrm_clicked_review', array($this, 'dismiss_notice')); | |
| 178 | 178 | |
| 179 | 179 | // And let's roll... maybe. | 
| 180 | 180 | $this->maybe_prompt(); | 
| @@ -189,7 +189,7 @@ discard block | ||
| 189 | 189 | */ | 
| 190 | 190 |  		private function is_wp_compatible() { | 
| 191 | 191 | |
| 192 | -			if ( version_compare( get_bloginfo( 'version' ), $this->wordpress_version_required, '<' ) ) { | |
| 192 | +			if (version_compare(get_bloginfo('version'), $this->wordpress_version_required, '<')) { | |
| 193 | 193 | return false; | 
| 194 | 194 | } | 
| 195 | 195 | |
| @@ -205,7 +205,7 @@ discard block | ||
| 205 | 205 | */ | 
| 206 | 206 |  		private function is_php_compatible() { | 
| 207 | 207 | |
| 208 | -			if ( version_compare( phpversion(), $this->php_version_required, '<' ) ) { | |
| 208 | +			if (version_compare(phpversion(), $this->php_version_required, '<')) { | |
| 209 | 209 | return false; | 
| 210 | 210 | } | 
| 211 | 211 | |
| @@ -222,11 +222,11 @@ discard block | ||
| 222 | 222 | * | 
| 223 | 223 | * @return void | 
| 224 | 224 | */ | 
| 225 | -		protected function spit_error( $error ) { | |
| 225 | +		protected function spit_error($error) { | |
| 226 | 226 | printf( | 
| 227 | 227 | '<div style="margin: 20px; text-align: center;"><strong>%1$s</strong> %2$s</pre></div>', | 
| 228 | - esc_html__( 'WP Review Me Error:', 'wp-review-me' ), | |
| 229 | - wp_kses_post( $error ) | |
| 228 | +				esc_html__('WP Review Me Error:', 'wp-review-me'), | |
| 229 | + wp_kses_post($error) | |
| 230 | 230 | ); | 
| 231 | 231 | } | 
| 232 | 232 | |
| @@ -238,14 +238,14 @@ discard block | ||
| 238 | 238 | */ | 
| 239 | 239 |  		public function is_time() { | 
| 240 | 240 | |
| 241 | - $installed = (int) get_option( $this->key, false ); | |
| 241 | + $installed = (int) get_option($this->key, false); | |
| 242 | 242 | |
| 243 | -			if ( false === $installed ) { | |
| 243 | +			if (false === $installed) { | |
| 244 | 244 | $this->setup_date(); | 
| 245 | 245 | $installed = time(); | 
| 246 | 246 | } | 
| 247 | 247 | |
| 248 | -			if ( $installed + ( $this->days * 86400 ) > time() ) { | |
| 248 | +			if ($installed + ($this->days * 86400) > time()) { | |
| 249 | 249 | return false; | 
| 250 | 250 | } | 
| 251 | 251 | |
| @@ -260,7 +260,7 @@ discard block | ||
| 260 | 260 | * @return void | 
| 261 | 261 | */ | 
| 262 | 262 |  		protected function setup_date() { | 
| 263 | - update_option( $this->key, time() ); | |
| 263 | + update_option($this->key, time()); | |
| 264 | 264 | } | 
| 265 | 265 | |
| 266 | 266 | /** | 
| @@ -273,7 +273,7 @@ discard block | ||
| 273 | 273 | |
| 274 | 274 | $link = 'https://wordpress.org/support/'; | 
| 275 | 275 | |
| 276 | -			switch ( $this->type ) { | |
| 276 | +			switch ($this->type) { | |
| 277 | 277 | |
| 278 | 278 | case 'theme': | 
| 279 | 279 | $link .= 'theme/'; | 
| @@ -286,8 +286,8 @@ discard block | ||
| 286 | 286 | } | 
| 287 | 287 | |
| 288 | 288 | $link .= $this->slug . '/reviews'; | 
| 289 | - $link = add_query_arg( 'rate', $this->rating, $link ); | |
| 290 | - $link = esc_url( $link . '#new-post' ); | |
| 289 | +			$link = add_query_arg('rate', $this->rating, $link); | |
| 290 | + $link = esc_url($link . '#new-post'); | |
| 291 | 291 | |
| 292 | 292 | return $link; | 
| 293 | 293 | |
| @@ -315,14 +315,14 @@ discard block | ||
| 315 | 315 | */ | 
| 316 | 316 |  		protected function maybe_prompt() { | 
| 317 | 317 | |
| 318 | -			if ( ! $this->is_time() ) { | |
| 318 | +			if ( ! $this->is_time()) { | |
| 319 | 319 | return; | 
| 320 | 320 | } | 
| 321 | 321 | |
| 322 | - dnh_register_notice( $this->key, 'updated', $this->get_message(), array( | |
| 322 | + dnh_register_notice($this->key, 'updated', $this->get_message(), array( | |
| 323 | 323 | 'scope' => $this->scope, | 
| 324 | 324 | 'cap' => $this->cap | 
| 325 | - ) ); | |
| 325 | + )); | |
| 326 | 326 | |
| 327 | 327 | } | 
| 328 | 328 | |
| @@ -367,26 +367,26 @@ discard block | ||
| 367 | 367 | */ | 
| 368 | 368 |  		public function dismiss_notice() { | 
| 369 | 369 | |
| 370 | -			if ( empty( $_POST ) ) { | |
| 370 | +			if (empty($_POST)) { | |
| 371 | 371 | echo 'missing POST'; | 
| 372 | 372 | die(); | 
| 373 | 373 | } | 
| 374 | 374 | |
| 375 | -			if ( ! isset( $_POST['id'] ) ) { | |
| 375 | +			if ( ! isset($_POST['id'])) { | |
| 376 | 376 | echo 'missing ID'; | 
| 377 | 377 | die(); | 
| 378 | 378 | } | 
| 379 | 379 | |
| 380 | - $id = sanitize_text_field( $_POST['id'] ); | |
| 380 | + $id = sanitize_text_field($_POST['id']); | |
| 381 | 381 | |
| 382 | -			if ( $id !== $this->link_id ) { | |
| 382 | +			if ($id !== $this->link_id) { | |
| 383 | 383 | echo "not this instance's job"; | 
| 384 | 384 | die(); | 
| 385 | 385 | } | 
| 386 | 386 | |
| 387 | 387 | // Get the DNH notice ID ready | 
| 388 | - $notice_id = DNH()->get_id( str_replace( 'wrm-review-link-', '', $id ) ); | |
| 389 | - $dismissed = DNH()->dismiss_notice( $notice_id ); | |
| 388 | +			$notice_id = DNH()->get_id(str_replace('wrm-review-link-', '', $id)); | |
| 389 | + $dismissed = DNH()->dismiss_notice($notice_id); | |
| 390 | 390 | |
| 391 | 391 | echo $dismissed; | 
| 392 | 392 | |
| @@ -398,7 +398,7 @@ discard block | ||
| 398 | 398 | * @param string $id The notice ID | 
| 399 | 399 | * @param string $notice_id The notice ID as defined by the DNH class | 
| 400 | 400 | */ | 
| 401 | - do_action( 'wrm_after_notice_dismissed', $id, $notice_id ); | |
| 401 | +			do_action('wrm_after_notice_dismissed', $id, $notice_id); | |
| 402 | 402 | |
| 403 | 403 | // Stop execution here | 
| 404 | 404 | die(); | 
| @@ -417,7 +417,7 @@ discard block | ||
| 417 | 417 | $link = $this->get_review_link_tag(); | 
| 418 | 418 | $message = $message . ' ' . $link; | 
| 419 | 419 | |
| 420 | - return wp_kses_post( $message ); | |
| 420 | + return wp_kses_post($message); | |
| 421 | 421 | |
| 422 | 422 | } | 
| 423 | 423 | |