@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // If this file is called directly, abort. |
| 14 | -if ( ! defined( 'WPINC' ) ) { |
|
| 14 | +if ( ! defined('WPINC')) { |
|
| 15 | 15 | die; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -49,17 +49,17 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | protected $email; |
| 51 | 51 | |
| 52 | - public function __construct( $args, $email = array() ) { |
|
| 52 | + public function __construct($args, $email = array()) { |
|
| 53 | 53 | |
| 54 | - $this->edd_url = isset( $args['edd_url'] ) ? esc_url( $args['edd_url'] ) : ''; |
|
| 55 | - $this->discount = isset( $args['edd_discount'] ) && is_array( $args['edd_discount'] ) ? wp_parse_args( $args['edd_discount'], $this->discount_defaults() ) : $this->discount_defaults(); |
|
| 54 | + $this->edd_url = isset($args['edd_url']) ? esc_url($args['edd_url']) : ''; |
|
| 55 | + $this->discount = isset($args['edd_discount']) && is_array($args['edd_discount']) ? wp_parse_args($args['edd_discount'], $this->discount_defaults()) : $this->discount_defaults(); |
|
| 56 | 56 | $this->email = $email; |
| 57 | 57 | |
| 58 | 58 | // Call parent constructor |
| 59 | - parent::__construct( $args ); |
|
| 59 | + parent::__construct($args); |
|
| 60 | 60 | |
| 61 | 61 | // Register our discount action |
| 62 | - add_action( 'wrm_after_notice_dismissed', array( $this, 'query_discount_ajax' ), 10, 2 ); |
|
| 62 | + add_action('wrm_after_notice_dismissed', array($this, 'query_discount_ajax'), 10, 2); |
|
| 63 | 63 | |
| 64 | 64 | } |
| 65 | 65 | |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | - public function query_discount_ajax( $link_id ) { |
|
| 93 | + public function query_discount_ajax($link_id) { |
|
| 94 | 94 | |
| 95 | 95 | // Not this notice. Abort. |
| 96 | - if ( $link_id !== $this->link_id ) { |
|
| 96 | + if ($link_id !== $this->link_id) { |
|
| 97 | 97 | echo 'not this instance job'; |
| 98 | 98 | |
| 99 | 99 | return; |
@@ -111,35 +111,35 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | protected function query_discount() { |
| 113 | 113 | |
| 114 | - $endpoint = esc_url( add_query_arg( 'wrm_action', 'discount', $this->edd_url ) ); |
|
| 115 | - $data = array( 'wrm_email' => get_bloginfo( 'admin_email' ), 'wrm_discount' => $this->discount ); // Wrap our vars to avoid post names issues |
|
| 114 | + $endpoint = esc_url(add_query_arg('wrm_action', 'discount', $this->edd_url)); |
|
| 115 | + $data = array('wrm_email' => get_bloginfo('admin_email'), 'wrm_discount' => $this->discount); // Wrap our vars to avoid post names issues |
|
| 116 | 116 | |
| 117 | - $response = wp_remote_post( $endpoint, array( |
|
| 117 | + $response = wp_remote_post($endpoint, array( |
|
| 118 | 118 | 'method' => 'POST', |
| 119 | 119 | 'timeout' => 20, |
| 120 | 120 | 'redirection' => 5, |
| 121 | 121 | 'httpversion' => '1.1', |
| 122 | 122 | 'blocking' => true, |
| 123 | 123 | 'body' => $data, |
| 124 | - 'user-agent' => 'WRM/' . $this->version . '; ' . get_bloginfo( 'url' ) |
|
| 125 | - ) ); |
|
| 124 | + 'user-agent' => 'WRM/' . $this->version . '; ' . get_bloginfo('url') |
|
| 125 | + )); |
|
| 126 | 126 | |
| 127 | - if ( is_wp_error( $response ) ) { |
|
| 127 | + if (is_wp_error($response)) { |
|
| 128 | 128 | return $response->get_error_message(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
| 132 | - return wp_remote_retrieve_response_message( $response ); |
|
| 131 | + if (200 != wp_remote_retrieve_response_code($response)) { |
|
| 132 | + return wp_remote_retrieve_response_message($response); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $body = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 135 | + $body = json_decode(wp_remote_retrieve_body($response)); |
|
| 136 | 136 | |
| 137 | - if ( false === $body ) { |
|
| 138 | - return __( 'Unknown error', 'wp-review-me' ); |
|
| 137 | + if (false === $body) { |
|
| 138 | + return __('Unknown error', 'wp-review-me'); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( 'success' === $body->result ) { |
|
| 142 | - $this->code = trim( $body->message ); |
|
| 141 | + if ('success' === $body->result) { |
|
| 142 | + $this->code = trim($body->message); |
|
| 143 | 143 | $this->email_code(); |
| 144 | 144 | return $this->code; |
| 145 | 145 | } |
@@ -158,36 +158,36 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $body = '<p>Hi,</p><p>From our entire team, many thanks for your review.</p><p>While you just spent a few minutes writing it, your testimonial will be a big help to us.</p><p>Many users don\'t realize it but reviews are a key part of the promotion work for our product. This allows us to increase our user base, and thus get more support for improving our product.</p><p>As a thank you from us, please find hereafter your discount code for a {{amount}} discount valid until {{expiration}}:</p><p>Your discount code: <strong>{{code}}</strong></p><p>Enjoy the product!</p>'; |
| 160 | 160 | |
| 161 | - if ( isset( $this->email['body'] ) ) { |
|
| 161 | + if (isset($this->email['body'])) { |
|
| 162 | 162 | $body = $this->email['body']; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $tags = array( 'code', 'amount', 'expiration' ); |
|
| 165 | + $tags = array('code', 'amount', 'expiration'); |
|
| 166 | 166 | |
| 167 | - foreach ( $tags as $tag ) { |
|
| 167 | + foreach ($tags as $tag) { |
|
| 168 | 168 | |
| 169 | 169 | $find = '{{' . $tag . '}}'; |
| 170 | 170 | |
| 171 | - switch ( $tag ) { |
|
| 171 | + switch ($tag) { |
|
| 172 | 172 | |
| 173 | 173 | case 'code': |
| 174 | - $body = str_replace( $find, $this->code, $body ); |
|
| 174 | + $body = str_replace($find, $this->code, $body); |
|
| 175 | 175 | break; |
| 176 | 176 | |
| 177 | 177 | case 'amount': |
| 178 | 178 | |
| 179 | 179 | $amount = $this->discount['amount']; |
| 180 | 180 | |
| 181 | - if ( 'percentage' === $this->discount['type'] ) { |
|
| 181 | + if ('percentage' === $this->discount['type']) { |
|
| 182 | 182 | $amount = $amount . '%'; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $body = str_replace( $find, $amount, $body ); |
|
| 185 | + $body = str_replace($find, $amount, $body); |
|
| 186 | 186 | break; |
| 187 | 187 | |
| 188 | 188 | case 'expiration': |
| 189 | - $expiration = date( get_option( 'date_format' ), time() + ( (int) $this->discount['validity'] * 86400 ) ); |
|
| 190 | - $body = str_replace( $find, $expiration, $body ); |
|
| 189 | + $expiration = date(get_option('date_format'), time() + ((int) $this->discount['validity'] * 86400)); |
|
| 190 | + $body = str_replace($find, $expiration, $body); |
|
| 191 | 191 | break; |
| 192 | 192 | |
| 193 | 193 | } |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $email['body'] = $body; |
| 198 | - $email['subject'] = isset( $this->email['subject'] ) ? sanitize_text_field( $this->email['subject'] ) : esc_html__( 'Your discount code', 'wp-review-me' ); |
|
| 199 | - $email['from_name'] = isset( $this->email['from_name'] ) ? sanitize_text_field( $this->email['from_name'] ) : get_bloginfo( 'name' ); |
|
| 200 | - $email['from_email'] = isset( $this->email['from_email'] ) ? sanitize_text_field( $this->email['from_email'] ) : get_bloginfo( 'admin_email' ); |
|
| 198 | + $email['subject'] = isset($this->email['subject']) ? sanitize_text_field($this->email['subject']) : esc_html__('Your discount code', 'wp-review-me'); |
|
| 199 | + $email['from_name'] = isset($this->email['from_name']) ? sanitize_text_field($this->email['from_name']) : get_bloginfo('name'); |
|
| 200 | + $email['from_email'] = isset($this->email['from_email']) ? sanitize_text_field($this->email['from_email']) : get_bloginfo('admin_email'); |
|
| 201 | 201 | |
| 202 | - return apply_filters( 'wrm_edd_email', $email ); |
|
| 202 | + return apply_filters('wrm_edd_email', $email); |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | "From: $from_name <$from_email>", |
| 221 | 221 | ); |
| 222 | 222 | |
| 223 | - return wp_mail( get_bloginfo( 'admin_email' ), $email['subject'], $email['body'], $headers ); |
|
| 223 | + return wp_mail(get_bloginfo('admin_email'), $email['subject'], $email['body'], $headers); |
|
| 224 | 224 | |
| 225 | 225 | } |
| 226 | 226 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $link = $this->get_review_link_tag(); |
| 237 | 237 | $message = $message . ' ' . $link; |
| 238 | 238 | |
| 239 | - return wp_kses_post( $message ); |
|
| 239 | + return wp_kses_post($message); |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // If this file is called directly, abort. |
| 14 | -if ( ! defined( 'WPINC' ) ) { |
|
| 14 | +if ( ! defined('WPINC')) { |
|
| 15 | 15 | die; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param array $args |
| 26 | 26 | */ |
| 27 | - public function __construct( $args ) { |
|
| 28 | - parent::__construct( $args ); |
|
| 27 | + public function __construct($args) { |
|
| 28 | + parent::__construct($args); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $link = $this->get_review_link_tag(); |
| 41 | 41 | $message = $message . ' ' . $link; |
| 42 | 42 | |
| 43 | - return wp_kses_post( $message ); |
|
| 43 | + return wp_kses_post($message); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | // If this file is called directly, abort. |
| 32 | -if ( ! defined( 'WPINC' ) ) { |
|
| 32 | +if ( ! defined('WPINC')) { |
|
| 33 | 33 | die; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | -if ( ! class_exists( 'WRM_EDD_Bridge' ) ): |
|
| 36 | +if ( ! class_exists('WRM_EDD_Bridge')): |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Main WRM EDD class |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function __clone() { |
| 93 | 93 | // Cloning instances of the class is forbidden |
| 94 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'awesome-support' ), '3.2.5' ); |
|
| 94 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'awesome-support'), '3.2.5'); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function __wakeup() { |
| 104 | 104 | // Unserializing instances of the class is forbidden |
| 105 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'awesome-support' ), '3.2.5' ); |
|
| 105 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'awesome-support'), '3.2.5'); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function __construct() { |
| 109 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 109 | + add_action('init', array($this, 'init')); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | public function init() { |
| 119 | 119 | |
| 120 | 120 | // Some work to do? |
| 121 | - if ( ! empty( $_GET ) && isset( $_GET['wrm_action'] ) ) { |
|
| 121 | + if ( ! empty($_GET) && isset($_GET['wrm_action'])) { |
|
| 122 | 122 | |
| 123 | - switch ( $_GET['wrm_action'] ) { |
|
| 123 | + switch ($_GET['wrm_action']) { |
|
| 124 | 124 | |
| 125 | 125 | case 'discount': |
| 126 | 126 | $this->discount(); |
@@ -139,42 +139,42 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function discount() { |
| 141 | 141 | |
| 142 | - $result = array( 'result' => 'error' ); |
|
| 142 | + $result = array('result' => 'error'); |
|
| 143 | 143 | |
| 144 | 144 | // Make sure the WordPress version is recent enough |
| 145 | - if ( ! $this->is_version_compatible() ) { |
|
| 145 | + if ( ! $this->is_version_compatible()) { |
|
| 146 | 146 | $result['message'] = 'WordPress version incompatible'; |
| 147 | - echo json_encode( $result ); |
|
| 147 | + echo json_encode($result); |
|
| 148 | 148 | die(); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Make sure we have a version of PHP that's not too old |
| 152 | - if ( ! $this->is_php_version_enough() ) { |
|
| 152 | + if ( ! $this->is_php_version_enough()) { |
|
| 153 | 153 | $result['message'] = 'PHP version incompatible'; |
| 154 | - echo json_encode( $result ); |
|
| 154 | + echo json_encode($result); |
|
| 155 | 155 | die(); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Check if EDD is here |
| 159 | - if ( ! function_exists( 'edd_store_discount' ) ) { |
|
| 159 | + if ( ! function_exists('edd_store_discount')) { |
|
| 160 | 160 | $result['message'] = 'EDD not active'; |
| 161 | - echo json_encode( $result ); |
|
| 161 | + echo json_encode($result); |
|
| 162 | 162 | die(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Make sure we have an e-mail |
| 166 | - if ( ! isset( $_POST['wrm_email'] ) ) { |
|
| 166 | + if ( ! isset($_POST['wrm_email'])) { |
|
| 167 | 167 | $result['message'] = 'Email missing'; |
| 168 | - echo json_encode( $result ); |
|
| 168 | + echo json_encode($result); |
|
| 169 | 169 | die(); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $this->email = $_POST['wrm_email']; |
| 173 | - $this->code = md5( $this->email ); |
|
| 173 | + $this->code = md5($this->email); |
|
| 174 | 174 | |
| 175 | - if ( ! $this->is_code_unique() ) { |
|
| 175 | + if ( ! $this->is_code_unique()) { |
|
| 176 | 176 | $result['message'] = 'Code already claimed'; |
| 177 | - echo json_encode( $result ); |
|
| 177 | + echo json_encode($result); |
|
| 178 | 178 | die(); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $result['result'] = $message ? 'success' : 'error'; |
| 183 | 183 | $result['message'] = $message ? $this->code : 'unknown error'; |
| 184 | 184 | |
| 185 | - echo json_encode( $result ); |
|
| 185 | + echo json_encode($result); |
|
| 186 | 186 | die(); |
| 187 | 187 | |
| 188 | 188 | } |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | private function is_version_compatible() { |
| 197 | 197 | |
| 198 | - if ( empty( $this->wordpress_version_required ) ) { |
|
| 198 | + if (empty($this->wordpress_version_required)) { |
|
| 199 | 199 | return true; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if ( version_compare( get_bloginfo( 'version' ), $this->wordpress_version_required, '<' ) ) { |
|
| 202 | + if (version_compare(get_bloginfo('version'), $this->wordpress_version_required, '<')) { |
|
| 203 | 203 | return false; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * No version set, we assume everything is fine. |
| 220 | 220 | */ |
| 221 | - if ( empty( $this->php_version_required ) ) { |
|
| 221 | + if (empty($this->php_version_required)) { |
|
| 222 | 222 | return true; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( version_compare( phpversion(), $this->php_version_required, '<' ) ) { |
|
| 225 | + if (version_compare(phpversion(), $this->php_version_required, '<')) { |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | protected function is_code_unique() { |
| 234 | - return ! is_null( $this->code ) && edd_get_discount_by_code( $this->code ) ? false : true; |
|
| 234 | + return ! is_null($this->code) && edd_get_discount_by_code($this->code) ? false : true; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -260,27 +260,27 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | protected function insert_discount() { |
| 262 | 262 | |
| 263 | - $discount = isset( $_POST['wrm_discount'] ) ? wp_parse_args( $_POST['wrm_discount'], $this->discount_defaults() ) : $this->discount_defaults(); |
|
| 263 | + $discount = isset($_POST['wrm_discount']) ? wp_parse_args($_POST['wrm_discount'], $this->discount_defaults()) : $this->discount_defaults(); |
|
| 264 | 264 | |
| 265 | 265 | // Make sure the discount type exists |
| 266 | - if ( ! in_array( $discount['type'], array( 'percent', 'flat' ) ) ) { |
|
| 266 | + if ( ! in_array($discount['type'], array('percent', 'flat'))) { |
|
| 267 | 267 | $discount['type'] = 'percent'; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Make sure the discount is not over 100% (for percentage discounts) |
| 271 | - if ( 'percent' === $discount['type'] && (int) $discount['amount'] > 100 ) { |
|
| 271 | + if ('percent' === $discount['type'] && (int) $discount['amount'] > 100) { |
|
| 272 | 272 | $discount['amount'] = 100; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | $details = array( |
| 276 | 276 | 'code' => $this->code, |
| 277 | - 'name' => sprintf( 'Discount for a review %s', $this->email ), |
|
| 277 | + 'name' => sprintf('Discount for a review %s', $this->email), |
|
| 278 | 278 | 'status' => 'active', |
| 279 | 279 | 'uses' => 0, |
| 280 | 280 | 'max' => 1, |
| 281 | 281 | 'amount' => $discount['amount'], |
| 282 | - 'start' => date( 'Y-m-d' ), |
|
| 283 | - 'expiration' => date( 'Y-m-d', strtotime( date( 'Y-m-d' ) . "+ {$discount['validity']} days" ) ), |
|
| 282 | + 'start' => date('Y-m-d'), |
|
| 283 | + 'expiration' => date('Y-m-d', strtotime(date('Y-m-d') . "+ {$discount['validity']} days")), |
|
| 284 | 284 | 'type' => $discount['type'], |
| 285 | 285 | 'min_price' => 0, |
| 286 | 286 | 'products' => array(), |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | 'use_once' => true, |
| 291 | 291 | ); |
| 292 | 292 | |
| 293 | - return edd_store_discount( $details ); |
|
| 293 | + return edd_store_discount($details); |
|
| 294 | 294 | |
| 295 | 295 | } |
| 296 | 296 | |
@@ -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 | abstract 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 = get_option( $this->key, false ); |
|
| 241 | + $installed = 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/view/'; |
| 275 | 275 | |
| 276 | - switch ( $this->type ) { |
|
| 276 | + switch ($this->type) { |
|
| 277 | 277 | |
| 278 | 278 | case 'theme': |
| 279 | 279 | $link .= 'theme-reviews/'; |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $link .= $this->slug; |
| 289 | - $link = add_query_arg( 'rate', $this->rating, $link ); |
|
| 290 | - $link = esc_url( $link . '#postform' ); |
|
| 289 | + $link = add_query_arg('rate', $this->rating, $link); |
|
| 290 | + $link = esc_url($link . '#postform'); |
|
| 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(); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Load integrations |
| 419 | - require_once( dirname( __FILE__ ) . '/includes/integrations/class-wordpress.php' ); |
|
| 420 | - require_once( dirname( __FILE__ ) . '/includes/integrations/class-edd.php' ); |
|
| 419 | + require_once(dirname(__FILE__) . '/includes/integrations/class-wordpress.php'); |
|
| 420 | + require_once(dirname(__FILE__) . '/includes/integrations/class-edd.php'); |
|
| 421 | 421 | |
| 422 | 422 | } |
| 423 | 423 | \ No newline at end of file |