@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @since 1.0.15 |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Discount class. |
@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int|array|string|WPInv_Discount|WP_Post $discount discount data, object, ID or code. |
82 | 82 | */ |
83 | - public function __construct( $discount = 0 ) { |
|
84 | - parent::__construct( $discount ); |
|
83 | + public function __construct($discount = 0) { |
|
84 | + parent::__construct($discount); |
|
85 | 85 | |
86 | - if ( is_numeric( $discount ) && 'wpi_discount' === get_post_type( $discount ) ) { |
|
87 | - $this->set_id( $discount ); |
|
88 | - } elseif ( $discount instanceof self ) { |
|
89 | - $this->set_id( $discount->get_id() ); |
|
90 | - } elseif ( ! empty( $discount->ID ) ) { |
|
91 | - $this->set_id( $discount->ID ); |
|
92 | - } elseif ( is_array( $discount ) ) { |
|
93 | - $this->set_props( $discount ); |
|
86 | + if (is_numeric($discount) && 'wpi_discount' === get_post_type($discount)) { |
|
87 | + $this->set_id($discount); |
|
88 | + } elseif ($discount instanceof self) { |
|
89 | + $this->set_id($discount->get_id()); |
|
90 | + } elseif (!empty($discount->ID)) { |
|
91 | + $this->set_id($discount->ID); |
|
92 | + } elseif (is_array($discount)) { |
|
93 | + $this->set_props($discount); |
|
94 | 94 | |
95 | - if ( isset( $discount['ID'] ) ) { |
|
96 | - $this->set_id( $discount['ID'] ); |
|
95 | + if (isset($discount['ID'])) { |
|
96 | + $this->set_id($discount['ID']); |
|
97 | 97 | } |
98 | -} elseif ( is_scalar( $discount ) && $discount = self::get_discount_id_by_code( $discount ) ) { |
|
99 | - $this->set_id( $discount ); |
|
98 | +} elseif (is_scalar($discount) && $discount = self::get_discount_id_by_code($discount)) { |
|
99 | + $this->set_id($discount); |
|
100 | 100 | } else { |
101 | - $this->set_object_read( true ); |
|
101 | + $this->set_object_read(true); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // Load the datastore. |
105 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
105 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
106 | 106 | |
107 | - if ( $this->get_id() > 0 ) { |
|
108 | - $this->post = get_post( $this->get_id() ); |
|
107 | + if ($this->get_id() > 0) { |
|
108 | + $this->post = get_post($this->get_id()); |
|
109 | 109 | $this->ID = $this->get_id(); |
110 | - $this->data_store->read( $this ); |
|
110 | + $this->data_store->read($this); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -123,36 +123,36 @@ discard block |
||
123 | 123 | * @since 1.0.15 |
124 | 124 | * @return array|bool array of discount details on success. False otherwise. |
125 | 125 | */ |
126 | - public static function get_data_by( $field, $value ) { |
|
126 | + public static function get_data_by($field, $value) { |
|
127 | 127 | |
128 | - if ( 'id' == strtolower( $field ) ) { |
|
128 | + if ('id' == strtolower($field)) { |
|
129 | 129 | // Make sure the value is numeric to avoid casting objects, for example, |
130 | 130 | // to int 1. |
131 | - if ( ! is_numeric( $value ) ) { |
|
131 | + if (!is_numeric($value)) { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | - $value = intval( $value ); |
|
135 | - if ( $value < 1 ) { |
|
134 | + $value = intval($value); |
|
135 | + if ($value < 1) { |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - if ( ! $value || ! is_string( $field ) ) { |
|
140 | + if (!$value || !is_string($field)) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | - $field = trim( $field ); |
|
144 | + $field = trim($field); |
|
145 | 145 | |
146 | 146 | // prepare query args |
147 | - switch ( strtolower( $field ) ) { |
|
147 | + switch (strtolower($field)) { |
|
148 | 148 | case 'id': |
149 | 149 | $discount_id = $value; |
150 | - $args = array( 'include' => array( $value ) ); |
|
150 | + $args = array('include' => array($value)); |
|
151 | 151 | break; |
152 | 152 | case 'discount_code': |
153 | 153 | case 'code': |
154 | - $value = trim( $value ); |
|
155 | - $discount_id = wp_cache_get( $value, 'WPInv_Discount_Codes' ); |
|
154 | + $value = trim($value); |
|
155 | + $discount_id = wp_cache_get($value, 'WPInv_Discount_Codes'); |
|
156 | 156 | $args = array( |
157 | 157 | 'meta_key' => '_wpi_discount_code', |
158 | 158 | 'meta_value' => $value, |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | break; |
161 | 161 | case 'name': |
162 | 162 | $discount_id = 0; |
163 | - $args = array( 'name' => trim( $value ) ); |
|
163 | + $args = array('name' => trim($value)); |
|
164 | 164 | break; |
165 | 165 | default: |
166 | - $args = apply_filters( "wpinv_discount_get_data_by_{$field}_args", null, $value ); |
|
167 | - if ( ! is_array( $args ) ) { |
|
168 | - return apply_filters( "wpinv_discount_get_data_by_$field", false, $value ); |
|
166 | + $args = apply_filters("wpinv_discount_get_data_by_{$field}_args", null, $value); |
|
167 | + if (!is_array($args)) { |
|
168 | + return apply_filters("wpinv_discount_get_data_by_$field", false, $value); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Check if there is a cached value. |
173 | - if ( ! empty( $discount_id ) && $discount = wp_cache_get( (int) $discount_id, 'WPInv_Discounts' ) ) { |
|
173 | + if (!empty($discount_id) && $discount = wp_cache_get((int) $discount_id, 'WPInv_Discounts')) { |
|
174 | 174 | return $discount; |
175 | 175 | } |
176 | 176 | |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | array( |
180 | 180 | 'post_type' => 'wpi_discount', |
181 | 181 | 'posts_per_page' => 1, |
182 | - 'post_status' => array( 'publish', 'pending', 'draft', 'expired' ), |
|
182 | + 'post_status' => array('publish', 'pending', 'draft', 'expired'), |
|
183 | 183 | ) |
184 | 184 | ); |
185 | 185 | |
186 | - $discount = get_posts( $args ); |
|
186 | + $discount = get_posts($args); |
|
187 | 187 | |
188 | - if ( empty( $discount ) ) { |
|
188 | + if (empty($discount)) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
@@ -194,31 +194,31 @@ discard block |
||
194 | 194 | // Prepare the return data. |
195 | 195 | $return = array( |
196 | 196 | 'ID' => $discount->ID, |
197 | - 'code' => get_post_meta( $discount->ID, '_wpi_discount_code', true ), |
|
198 | - 'amount' => get_post_meta( $discount->ID, '_wpi_discount_amount', true ), |
|
197 | + 'code' => get_post_meta($discount->ID, '_wpi_discount_code', true), |
|
198 | + 'amount' => get_post_meta($discount->ID, '_wpi_discount_amount', true), |
|
199 | 199 | 'date_created' => $discount->post_date, |
200 | 200 | 'date_modified' => $discount->post_modified, |
201 | 201 | 'status' => $discount->post_status, |
202 | - 'start' => get_post_meta( $discount->ID, '_wpi_discount_start', true ), |
|
203 | - 'expiration' => get_post_meta( $discount->ID, '_wpi_discount_expiration', true ), |
|
204 | - 'type' => get_post_meta( $discount->ID, '_wpi_discount_type', true ), |
|
202 | + 'start' => get_post_meta($discount->ID, '_wpi_discount_start', true), |
|
203 | + 'expiration' => get_post_meta($discount->ID, '_wpi_discount_expiration', true), |
|
204 | + 'type' => get_post_meta($discount->ID, '_wpi_discount_type', true), |
|
205 | 205 | 'description' => $discount->post_excerpt, |
206 | - 'uses' => get_post_meta( $discount->ID, '_wpi_discount_uses', true ), |
|
207 | - 'is_single_use' => get_post_meta( $discount->ID, '_wpi_discount_is_single_use', true ), |
|
208 | - 'items' => get_post_meta( $discount->ID, '_wpi_discount_items', true ), |
|
209 | - 'excluded_items' => get_post_meta( $discount->ID, '_wpi_discount_excluded_items', true ), |
|
210 | - 'required_items' => get_post_meta( $discount->ID, '_wpi_discount_required_items', true ), |
|
211 | - 'max_uses' => get_post_meta( $discount->ID, '_wpi_discount_max_uses', true ), |
|
212 | - 'is_recurring' => get_post_meta( $discount->ID, '_wpi_discount_is_recurring', true ), |
|
213 | - 'min_total' => get_post_meta( $discount->ID, '_wpi_discount_min_total', true ), |
|
214 | - 'max_total' => get_post_meta( $discount->ID, '_wpi_discount_max_total', true ), |
|
206 | + 'uses' => get_post_meta($discount->ID, '_wpi_discount_uses', true), |
|
207 | + 'is_single_use' => get_post_meta($discount->ID, '_wpi_discount_is_single_use', true), |
|
208 | + 'items' => get_post_meta($discount->ID, '_wpi_discount_items', true), |
|
209 | + 'excluded_items' => get_post_meta($discount->ID, '_wpi_discount_excluded_items', true), |
|
210 | + 'required_items' => get_post_meta($discount->ID, '_wpi_discount_required_items', true), |
|
211 | + 'max_uses' => get_post_meta($discount->ID, '_wpi_discount_max_uses', true), |
|
212 | + 'is_recurring' => get_post_meta($discount->ID, '_wpi_discount_is_recurring', true), |
|
213 | + 'min_total' => get_post_meta($discount->ID, '_wpi_discount_min_total', true), |
|
214 | + 'max_total' => get_post_meta($discount->ID, '_wpi_discount_max_total', true), |
|
215 | 215 | ); |
216 | 216 | |
217 | - $return = apply_filters( 'wpinv_discount_properties', $return ); |
|
217 | + $return = apply_filters('wpinv_discount_properties', $return); |
|
218 | 218 | |
219 | 219 | // Update the cache with our data |
220 | - wp_cache_add( $discount->ID, $return, 'WPInv_Discounts' ); |
|
221 | - wp_cache_add( $return['code'], $discount->ID, 'WPInv_Discount_Codes' ); |
|
220 | + wp_cache_add($discount->ID, $return, 'WPInv_Discounts'); |
|
221 | + wp_cache_add($return['code'], $discount->ID, 'WPInv_Discount_Codes'); |
|
222 | 222 | |
223 | 223 | return $return; |
224 | 224 | } |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | * @since 1.0.15 |
233 | 233 | * @return int |
234 | 234 | */ |
235 | - public static function get_discount_id_by_code( $discount_code ) { |
|
235 | + public static function get_discount_id_by_code($discount_code) { |
|
236 | 236 | |
237 | 237 | // Trim the code. |
238 | - $discount_code = trim( $discount_code ); |
|
238 | + $discount_code = trim($discount_code); |
|
239 | 239 | |
240 | 240 | // Ensure a value has been passed. |
241 | - if ( empty( $discount_code ) ) { |
|
241 | + if (empty($discount_code)) { |
|
242 | 242 | return 0; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Maybe retrieve from the cache. |
246 | - $discount_id = wp_cache_get( $discount_code, 'getpaid_discount_codes' ); |
|
247 | - if ( ! empty( $discount_id ) ) { |
|
246 | + $discount_id = wp_cache_get($discount_code, 'getpaid_discount_codes'); |
|
247 | + if (!empty($discount_id)) { |
|
248 | 248 | return $discount_id; |
249 | 249 | } |
250 | 250 | |
@@ -255,19 +255,19 @@ discard block |
||
255 | 255 | 'meta_value' => $discount_code, |
256 | 256 | 'post_type' => 'wpi_discount', |
257 | 257 | 'posts_per_page' => 1, |
258 | - 'post_status' => array( 'publish', 'pending', 'draft', 'expired' ), |
|
258 | + 'post_status' => array('publish', 'pending', 'draft', 'expired'), |
|
259 | 259 | 'fields' => 'ids', |
260 | 260 | ) |
261 | 261 | ); |
262 | 262 | |
263 | - if ( empty( $discounts ) ) { |
|
263 | + if (empty($discounts)) { |
|
264 | 264 | return 0; |
265 | 265 | } |
266 | 266 | |
267 | 267 | $discount_id = $discounts[0]; |
268 | 268 | |
269 | 269 | // Update the cache with our data |
270 | - wp_cache_add( get_post_meta( $discount_id, '_wpi_discount_code', true ), $discount_id, 'getpaid_discount_codes' ); |
|
270 | + wp_cache_add(get_post_meta($discount_id, '_wpi_discount_code', true), $discount_id, 'getpaid_discount_codes'); |
|
271 | 271 | |
272 | 272 | return $discount_id; |
273 | 273 | } |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return bool Whether the given discount field is set. |
282 | 282 | */ |
283 | - public function __isset( $key ) { |
|
284 | - return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" ); |
|
283 | + public function __isset($key) { |
|
284 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /* |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @param string $context View or edit context. |
307 | 307 | * @return string |
308 | 308 | */ |
309 | - public function get_status( $context = 'view' ) { |
|
310 | - return $this->get_prop( 'status', $context ); |
|
309 | + public function get_status($context = 'view') { |
|
310 | + return $this->get_prop('status', $context); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | * @param string $context View or edit context. |
318 | 318 | * @return string |
319 | 319 | */ |
320 | - public function get_version( $context = 'view' ) { |
|
321 | - return $this->get_prop( 'version', $context ); |
|
320 | + public function get_version($context = 'view') { |
|
321 | + return $this->get_prop('version', $context); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * @param string $context View or edit context. |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public function get_date_created( $context = 'view' ) { |
|
332 | - return $this->get_prop( 'date_created', $context ); |
|
331 | + public function get_date_created($context = 'view') { |
|
332 | + return $this->get_prop('date_created', $context); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @param string $context View or edit context. |
340 | 340 | * @return string |
341 | 341 | */ |
342 | - public function get_date_created_gmt( $context = 'view' ) { |
|
343 | - $date = $this->get_date_created( $context ); |
|
342 | + public function get_date_created_gmt($context = 'view') { |
|
343 | + $date = $this->get_date_created($context); |
|
344 | 344 | |
345 | - if ( $date ) { |
|
346 | - $date = get_gmt_from_date( $date ); |
|
345 | + if ($date) { |
|
346 | + $date = get_gmt_from_date($date); |
|
347 | 347 | } |
348 | 348 | return $date; |
349 | 349 | } |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string $context View or edit context. |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public function get_date_modified( $context = 'view' ) { |
|
359 | - return $this->get_prop( 'date_modified', $context ); |
|
358 | + public function get_date_modified($context = 'view') { |
|
359 | + return $this->get_prop('date_modified', $context); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | * @param string $context View or edit context. |
367 | 367 | * @return string |
368 | 368 | */ |
369 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
370 | - $date = $this->get_date_modified( $context ); |
|
369 | + public function get_date_modified_gmt($context = 'view') { |
|
370 | + $date = $this->get_date_modified($context); |
|
371 | 371 | |
372 | - if ( $date ) { |
|
373 | - $date = get_gmt_from_date( $date ); |
|
372 | + if ($date) { |
|
373 | + $date = get_gmt_from_date($date); |
|
374 | 374 | } |
375 | 375 | return $date; |
376 | 376 | } |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param string $context View or edit context. |
383 | 383 | * @return string |
384 | 384 | */ |
385 | - public function get_name( $context = 'view' ) { |
|
386 | - return $this->get_prop( 'name', $context ); |
|
385 | + public function get_name($context = 'view') { |
|
386 | + return $this->get_prop('name', $context); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param string $context View or edit context. |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - public function get_title( $context = 'view' ) { |
|
397 | - return $this->get_name( $context ); |
|
396 | + public function get_title($context = 'view') { |
|
397 | + return $this->get_name($context); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @param string $context View or edit context. |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - public function get_description( $context = 'view' ) { |
|
408 | - return $this->get_prop( 'description', $context ); |
|
407 | + public function get_description($context = 'view') { |
|
408 | + return $this->get_prop('description', $context); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $context View or edit context. |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - public function get_excerpt( $context = 'view' ) { |
|
419 | - return $this->get_description( $context ); |
|
418 | + public function get_excerpt($context = 'view') { |
|
419 | + return $this->get_description($context); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * @param string $context View or edit context. |
427 | 427 | * @return string |
428 | 428 | */ |
429 | - public function get_summary( $context = 'view' ) { |
|
430 | - return $this->get_description( $context ); |
|
429 | + public function get_summary($context = 'view') { |
|
430 | + return $this->get_description($context); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | * @param string $context View or edit context. |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - public function get_author( $context = 'view' ) { |
|
441 | - return (int) $this->get_prop( 'author', $context ); |
|
440 | + public function get_author($context = 'view') { |
|
441 | + return (int) $this->get_prop('author', $context); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | * @param string $context View or edit context. |
449 | 449 | * @return string |
450 | 450 | */ |
451 | - public function get_code( $context = 'view' ) { |
|
452 | - return $this->get_prop( 'code', $context ); |
|
451 | + public function get_code($context = 'view') { |
|
452 | + return $this->get_prop('code', $context); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * @param string $context View or edit context. |
460 | 460 | * @return string |
461 | 461 | */ |
462 | - public function get_coupon_code( $context = 'view' ) { |
|
463 | - return $this->get_code( $context ); |
|
462 | + public function get_coupon_code($context = 'view') { |
|
463 | + return $this->get_code($context); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | * @param string $context View or edit context. |
471 | 471 | * @return string |
472 | 472 | */ |
473 | - public function get_discount_code( $context = 'view' ) { |
|
474 | - return $this->get_code( $context ); |
|
473 | + public function get_discount_code($context = 'view') { |
|
474 | + return $this->get_code($context); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * @param string $context View or edit context. |
482 | 482 | * @return float |
483 | 483 | */ |
484 | - public function get_amount( $context = 'view' ) { |
|
485 | - return $context == 'view' ? floatval( $this->get_prop( 'amount', $context ) ) : $this->get_prop( 'amount', $context ); |
|
484 | + public function get_amount($context = 'view') { |
|
485 | + return $context == 'view' ? floatval($this->get_prop('amount', $context)) : $this->get_prop('amount', $context); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -493,13 +493,13 @@ discard block |
||
493 | 493 | */ |
494 | 494 | public function get_formatted_amount() { |
495 | 495 | |
496 | - if ( $this->is_type( 'flat' ) ) { |
|
497 | - $rate = wpinv_price( $this->get_amount() ); |
|
496 | + if ($this->is_type('flat')) { |
|
497 | + $rate = wpinv_price($this->get_amount()); |
|
498 | 498 | } else { |
499 | 499 | $rate = $this->get_amount() . '%'; |
500 | 500 | } |
501 | 501 | |
502 | - return apply_filters( 'wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount() ); |
|
502 | + return apply_filters('wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount()); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @param string $context View or edit context. |
510 | 510 | * @return string |
511 | 511 | */ |
512 | - public function get_start( $context = 'view' ) { |
|
513 | - return $this->get_prop( 'start', $context ); |
|
512 | + public function get_start($context = 'view') { |
|
513 | + return $this->get_prop('start', $context); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * @param string $context View or edit context. |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - public function get_start_date( $context = 'view' ) { |
|
524 | - return $this->get_start( $context ); |
|
523 | + public function get_start_date($context = 'view') { |
|
524 | + return $this->get_start($context); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | * @param string $context View or edit context. |
532 | 532 | * @return string |
533 | 533 | */ |
534 | - public function get_expiration( $context = 'view' ) { |
|
535 | - return $this->get_prop( 'expiration', $context ); |
|
534 | + public function get_expiration($context = 'view') { |
|
535 | + return $this->get_prop('expiration', $context); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -542,8 +542,8 @@ discard block |
||
542 | 542 | * @param string $context View or edit context. |
543 | 543 | * @return string |
544 | 544 | */ |
545 | - public function get_expiration_date( $context = 'view' ) { |
|
546 | - return $this->get_expiration( $context ); |
|
545 | + public function get_expiration_date($context = 'view') { |
|
546 | + return $this->get_expiration($context); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * @param string $context View or edit context. |
554 | 554 | * @return string |
555 | 555 | */ |
556 | - public function get_end_date( $context = 'view' ) { |
|
557 | - return $this->get_expiration( $context ); |
|
556 | + public function get_end_date($context = 'view') { |
|
557 | + return $this->get_expiration($context); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | * @param string $context View or edit context. |
565 | 565 | * @return string |
566 | 566 | */ |
567 | - public function get_type( $context = 'view' ) { |
|
568 | - return $this->get_prop( 'type', $context ); |
|
567 | + public function get_type($context = 'view') { |
|
568 | + return $this->get_prop('type', $context); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -575,8 +575,8 @@ discard block |
||
575 | 575 | * @param string $context View or edit context. |
576 | 576 | * @return int |
577 | 577 | */ |
578 | - public function get_uses( $context = 'view' ) { |
|
579 | - return (int) $this->get_prop( 'uses', $context ); |
|
578 | + public function get_uses($context = 'view') { |
|
579 | + return (int) $this->get_prop('uses', $context); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function get_usage() { |
589 | 589 | |
590 | - if ( ! $this->has_limit() ) { |
|
590 | + if (!$this->has_limit()) { |
|
591 | 591 | return $this->get_uses() . ' / ' . ' ∞'; |
592 | 592 | } |
593 | 593 | |
@@ -602,9 +602,9 @@ discard block |
||
602 | 602 | * @param string $context View or edit context. |
603 | 603 | * @return int |
604 | 604 | */ |
605 | - public function get_max_uses( $context = 'view' ) { |
|
606 | - $max_uses = $this->get_prop( 'max_uses', $context ); |
|
607 | - return empty( $max_uses ) ? null : $max_uses; |
|
605 | + public function get_max_uses($context = 'view') { |
|
606 | + $max_uses = $this->get_prop('max_uses', $context); |
|
607 | + return empty($max_uses) ? null : $max_uses; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | * @param string $context View or edit context. |
615 | 615 | * @return bool |
616 | 616 | */ |
617 | - public function get_is_single_use( $context = 'view' ) { |
|
618 | - return $this->get_prop( 'is_single_use', $context ); |
|
617 | + public function get_is_single_use($context = 'view') { |
|
618 | + return $this->get_prop('is_single_use', $context); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -625,8 +625,8 @@ discard block |
||
625 | 625 | * @param string $context View or edit context. |
626 | 626 | * @return array |
627 | 627 | */ |
628 | - public function get_items( $context = 'view' ) { |
|
629 | - return array_filter( wp_parse_id_list( $this->get_prop( 'items', $context ) ) ); |
|
628 | + public function get_items($context = 'view') { |
|
629 | + return array_filter(wp_parse_id_list($this->get_prop('items', $context))); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
@@ -636,8 +636,8 @@ discard block |
||
636 | 636 | * @param string $context View or edit context. |
637 | 637 | * @return array |
638 | 638 | */ |
639 | - public function get_allowed_items( $context = 'view' ) { |
|
640 | - return $this->get_items( $context ); |
|
639 | + public function get_allowed_items($context = 'view') { |
|
640 | + return $this->get_items($context); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * @param string $context View or edit context. |
648 | 648 | * @return array |
649 | 649 | */ |
650 | - public function get_excluded_items( $context = 'view' ) { |
|
651 | - return array_filter( wp_parse_id_list( $this->get_prop( 'excluded_items', $context ) ) ); |
|
650 | + public function get_excluded_items($context = 'view') { |
|
651 | + return array_filter(wp_parse_id_list($this->get_prop('excluded_items', $context))); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -658,8 +658,8 @@ discard block |
||
658 | 658 | * @param string $context View or edit context. |
659 | 659 | * @return array |
660 | 660 | */ |
661 | - public function get_required_items( $context = 'view' ) { |
|
662 | - return array_filter( wp_parse_id_list( $this->get_prop( 'required_items', $context ) ) ); |
|
661 | + public function get_required_items($context = 'view') { |
|
662 | + return array_filter(wp_parse_id_list($this->get_prop('required_items', $context))); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
@@ -669,8 +669,8 @@ discard block |
||
669 | 669 | * @param string $context View or edit context. |
670 | 670 | * @return int|string|bool |
671 | 671 | */ |
672 | - public function get_is_recurring( $context = 'view' ) { |
|
673 | - return $this->get_prop( 'is_recurring', $context ); |
|
672 | + public function get_is_recurring($context = 'view') { |
|
673 | + return $this->get_prop('is_recurring', $context); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -680,9 +680,9 @@ discard block |
||
680 | 680 | * @param string $context View or edit context. |
681 | 681 | * @return float |
682 | 682 | */ |
683 | - public function get_min_total( $context = 'view' ) { |
|
684 | - $minimum = $this->get_prop( 'min_total', $context ); |
|
685 | - return empty( $minimum ) ? null : $minimum; |
|
683 | + public function get_min_total($context = 'view') { |
|
684 | + $minimum = $this->get_prop('min_total', $context); |
|
685 | + return empty($minimum) ? null : $minimum; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | * @param string $context View or edit context. |
693 | 693 | * @return float |
694 | 694 | */ |
695 | - public function get_minimum_total( $context = 'view' ) { |
|
696 | - return $this->get_min_total( $context ); |
|
695 | + public function get_minimum_total($context = 'view') { |
|
696 | + return $this->get_min_total($context); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | * @param string $context View or edit context. |
704 | 704 | * @return float |
705 | 705 | */ |
706 | - public function get_max_total( $context = 'view' ) { |
|
707 | - $maximum = $this->get_prop( 'max_total', $context ); |
|
708 | - return empty( $maximum ) ? null : $maximum; |
|
706 | + public function get_max_total($context = 'view') { |
|
707 | + $maximum = $this->get_prop('max_total', $context); |
|
708 | + return empty($maximum) ? null : $maximum; |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | * @param string $context View or edit context. |
716 | 716 | * @return float |
717 | 717 | */ |
718 | - public function get_maximum_total( $context = 'view' ) { |
|
719 | - return $this->get_max_total( $context ); |
|
718 | + public function get_maximum_total($context = 'view') { |
|
719 | + return $this->get_max_total($context); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | /** |
@@ -729,8 +729,8 @@ discard block |
||
729 | 729 | * @param string $context View or edit context. |
730 | 730 | * @return mixed Value of the given discount property (if set). |
731 | 731 | */ |
732 | - public function get( $key, $context = 'view' ) { |
|
733 | - return $this->get_prop( $key, $context ); |
|
732 | + public function get($key, $context = 'view') { |
|
733 | + return $this->get_prop($key, $context); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /* |
@@ -750,10 +750,10 @@ discard block |
||
750 | 750 | * @param string $status New status. |
751 | 751 | * @return array details of change. |
752 | 752 | */ |
753 | - public function set_status( $status ) { |
|
753 | + public function set_status($status) { |
|
754 | 754 | $old_status = $this->get_status(); |
755 | 755 | |
756 | - $this->set_prop( 'status', $status ); |
|
756 | + $this->set_prop('status', $status); |
|
757 | 757 | |
758 | 758 | return array( |
759 | 759 | 'from' => $old_status, |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | * |
767 | 767 | * @since 1.0.19 |
768 | 768 | */ |
769 | - public function set_version( $value ) { |
|
770 | - $this->set_prop( 'version', $value ); |
|
769 | + public function set_version($value) { |
|
770 | + $this->set_prop('version', $value); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | /** |
@@ -777,11 +777,11 @@ discard block |
||
777 | 777 | * @param string $value Value to set. |
778 | 778 | * @return bool Whether or not the date was set. |
779 | 779 | */ |
780 | - public function set_date_created( $value ) { |
|
781 | - $date = strtotime( $value ); |
|
780 | + public function set_date_created($value) { |
|
781 | + $date = strtotime($value); |
|
782 | 782 | |
783 | - if ( $date ) { |
|
784 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
783 | + if ($date) { |
|
784 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
785 | 785 | return true; |
786 | 786 | } |
787 | 787 | |
@@ -796,11 +796,11 @@ discard block |
||
796 | 796 | * @param string $value Value to set. |
797 | 797 | * @return bool Whether or not the date was set. |
798 | 798 | */ |
799 | - public function set_date_modified( $value ) { |
|
800 | - $date = strtotime( $value ); |
|
799 | + public function set_date_modified($value) { |
|
800 | + $date = strtotime($value); |
|
801 | 801 | |
802 | - if ( $date ) { |
|
803 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
802 | + if ($date) { |
|
803 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
804 | 804 | return true; |
805 | 805 | } |
806 | 806 | |
@@ -814,9 +814,9 @@ discard block |
||
814 | 814 | * @since 1.0.19 |
815 | 815 | * @param string $value New name. |
816 | 816 | */ |
817 | - public function set_name( $value ) { |
|
818 | - $name = sanitize_text_field( $value ); |
|
819 | - $this->set_prop( 'name', $name ); |
|
817 | + public function set_name($value) { |
|
818 | + $name = sanitize_text_field($value); |
|
819 | + $this->set_prop('name', $name); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -825,8 +825,8 @@ discard block |
||
825 | 825 | * @since 1.0.19 |
826 | 826 | * @param string $value New name. |
827 | 827 | */ |
828 | - public function set_title( $value ) { |
|
829 | - $this->set_name( $value ); |
|
828 | + public function set_title($value) { |
|
829 | + $this->set_name($value); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
@@ -835,9 +835,9 @@ discard block |
||
835 | 835 | * @since 1.0.19 |
836 | 836 | * @param string $value New description. |
837 | 837 | */ |
838 | - public function set_description( $value ) { |
|
839 | - $description = wp_kses_post( $value ); |
|
840 | - return $this->set_prop( 'description', $description ); |
|
838 | + public function set_description($value) { |
|
839 | + $description = wp_kses_post($value); |
|
840 | + return $this->set_prop('description', $description); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -846,8 +846,8 @@ discard block |
||
846 | 846 | * @since 1.0.19 |
847 | 847 | * @param string $value New description. |
848 | 848 | */ |
849 | - public function set_excerpt( $value ) { |
|
850 | - $this->set_description( $value ); |
|
849 | + public function set_excerpt($value) { |
|
850 | + $this->set_description($value); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | /** |
@@ -856,8 +856,8 @@ discard block |
||
856 | 856 | * @since 1.0.19 |
857 | 857 | * @param string $value New description. |
858 | 858 | */ |
859 | - public function set_summary( $value ) { |
|
860 | - $this->set_description( $value ); |
|
859 | + public function set_summary($value) { |
|
860 | + $this->set_description($value); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | /** |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | * @since 1.0.19 |
867 | 867 | * @param int $value New author. |
868 | 868 | */ |
869 | - public function set_author( $value ) { |
|
870 | - $this->set_prop( 'author', (int) $value ); |
|
869 | + public function set_author($value) { |
|
870 | + $this->set_prop('author', (int) $value); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
@@ -876,9 +876,9 @@ discard block |
||
876 | 876 | * @since 1.0.19 |
877 | 877 | * @param string $value New discount code. |
878 | 878 | */ |
879 | - public function set_code( $value ) { |
|
880 | - $code = sanitize_text_field( $value ); |
|
881 | - $this->set_prop( 'code', $code ); |
|
879 | + public function set_code($value) { |
|
880 | + $code = sanitize_text_field($value); |
|
881 | + $this->set_prop('code', $code); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | * @since 1.0.19 |
888 | 888 | * @param string $value New discount code. |
889 | 889 | */ |
890 | - public function set_coupon_code( $value ) { |
|
891 | - $this->set_code( $value ); |
|
890 | + public function set_coupon_code($value) { |
|
891 | + $this->set_code($value); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
@@ -897,8 +897,8 @@ discard block |
||
897 | 897 | * @since 1.0.19 |
898 | 898 | * @param string $value New discount code. |
899 | 899 | */ |
900 | - public function set_discount_code( $value ) { |
|
901 | - $this->set_code( $value ); |
|
900 | + public function set_discount_code($value) { |
|
901 | + $this->set_code($value); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | /** |
@@ -907,9 +907,9 @@ discard block |
||
907 | 907 | * @since 1.0.19 |
908 | 908 | * @param float $value New discount code. |
909 | 909 | */ |
910 | - public function set_amount( $value ) { |
|
911 | - $amount = floatval( wpinv_sanitize_amount( $value ) ); |
|
912 | - $this->set_prop( 'amount', $amount ); |
|
910 | + public function set_amount($value) { |
|
911 | + $amount = floatval(wpinv_sanitize_amount($value)); |
|
912 | + $this->set_prop('amount', $amount); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | /** |
@@ -918,15 +918,15 @@ discard block |
||
918 | 918 | * @since 1.0.19 |
919 | 919 | * @param float $value New start date. |
920 | 920 | */ |
921 | - public function set_start( $value ) { |
|
922 | - $date = strtotime( $value ); |
|
921 | + public function set_start($value) { |
|
922 | + $date = strtotime($value); |
|
923 | 923 | |
924 | - if ( $date ) { |
|
925 | - $this->set_prop( 'start', date( 'Y-m-d H:i', $date ) ); |
|
924 | + if ($date) { |
|
925 | + $this->set_prop('start', date('Y-m-d H:i', $date)); |
|
926 | 926 | return true; |
927 | 927 | } |
928 | 928 | |
929 | - $this->set_prop( 'start', '' ); |
|
929 | + $this->set_prop('start', ''); |
|
930 | 930 | |
931 | 931 | return false; |
932 | 932 | } |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | * @since 1.0.19 |
938 | 938 | * @param string $value New start date. |
939 | 939 | */ |
940 | - public function set_start_date( $value ) { |
|
941 | - $this->set_start( $value ); |
|
940 | + public function set_start_date($value) { |
|
941 | + $this->set_start($value); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | /** |
@@ -947,15 +947,15 @@ discard block |
||
947 | 947 | * @since 1.0.19 |
948 | 948 | * @param float $value New expiration date. |
949 | 949 | */ |
950 | - public function set_expiration( $value ) { |
|
951 | - $date = strtotime( $value ); |
|
950 | + public function set_expiration($value) { |
|
951 | + $date = strtotime($value); |
|
952 | 952 | |
953 | - if ( $date ) { |
|
954 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i', $date ) ); |
|
953 | + if ($date) { |
|
954 | + $this->set_prop('expiration', date('Y-m-d H:i', $date)); |
|
955 | 955 | return true; |
956 | 956 | } |
957 | 957 | |
958 | - $this->set_prop( 'expiration', '' ); |
|
958 | + $this->set_prop('expiration', ''); |
|
959 | 959 | return false; |
960 | 960 | } |
961 | 961 | |
@@ -965,8 +965,8 @@ discard block |
||
965 | 965 | * @since 1.0.19 |
966 | 966 | * @param string $value New expiration date. |
967 | 967 | */ |
968 | - public function set_expiration_date( $value ) { |
|
969 | - $this->set_expiration( $value ); |
|
968 | + public function set_expiration_date($value) { |
|
969 | + $this->set_expiration($value); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | /** |
@@ -975,8 +975,8 @@ discard block |
||
975 | 975 | * @since 1.0.19 |
976 | 976 | * @param string $value New expiration date. |
977 | 977 | */ |
978 | - public function set_end_date( $value ) { |
|
979 | - $this->set_expiration( $value ); |
|
978 | + public function set_end_date($value) { |
|
979 | + $this->set_expiration($value); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | /** |
@@ -985,9 +985,9 @@ discard block |
||
985 | 985 | * @since 1.0.19 |
986 | 986 | * @param string $value New discount type. |
987 | 987 | */ |
988 | - public function set_type( $value ) { |
|
989 | - if ( $value && array_key_exists( sanitize_text_field( $value ), wpinv_get_discount_types() ) ) { |
|
990 | - $this->set_prop( 'type', sanitize_text_field( $value ) ); |
|
988 | + public function set_type($value) { |
|
989 | + if ($value && array_key_exists(sanitize_text_field($value), wpinv_get_discount_types())) { |
|
990 | + $this->set_prop('type', sanitize_text_field($value)); |
|
991 | 991 | } |
992 | 992 | } |
993 | 993 | |
@@ -997,15 +997,15 @@ discard block |
||
997 | 997 | * @since 1.0.19 |
998 | 998 | * @param int $value usage count. |
999 | 999 | */ |
1000 | - public function set_uses( $value ) { |
|
1000 | + public function set_uses($value) { |
|
1001 | 1001 | |
1002 | 1002 | $value = (int) $value; |
1003 | 1003 | |
1004 | - if ( $value < 0 ) { |
|
1004 | + if ($value < 0) { |
|
1005 | 1005 | $value = 0; |
1006 | 1006 | } |
1007 | 1007 | |
1008 | - $this->set_prop( 'uses', (int) $value ); |
|
1008 | + $this->set_prop('uses', (int) $value); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | /** |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | * @since 1.0.19 |
1015 | 1015 | * @param int $value maximum usage count. |
1016 | 1016 | */ |
1017 | - public function set_max_uses( $value ) { |
|
1018 | - $this->set_prop( 'max_uses', absint( $value ) ); |
|
1017 | + public function set_max_uses($value) { |
|
1018 | + $this->set_prop('max_uses', absint($value)); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | /** |
@@ -1024,8 +1024,8 @@ discard block |
||
1024 | 1024 | * @since 1.0.19 |
1025 | 1025 | * @param int|bool $value is single use. |
1026 | 1026 | */ |
1027 | - public function set_is_single_use( $value ) { |
|
1028 | - $this->set_prop( 'is_single_use', (bool) $value ); |
|
1027 | + public function set_is_single_use($value) { |
|
1028 | + $this->set_prop('is_single_use', (bool) $value); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | /** |
@@ -1034,8 +1034,8 @@ discard block |
||
1034 | 1034 | * @since 1.0.19 |
1035 | 1035 | * @param array $value items. |
1036 | 1036 | */ |
1037 | - public function set_items( $value ) { |
|
1038 | - $this->set_prop( 'items', array_filter( wp_parse_id_list( $value ) ) ); |
|
1037 | + public function set_items($value) { |
|
1038 | + $this->set_prop('items', array_filter(wp_parse_id_list($value))); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | /** |
@@ -1044,8 +1044,8 @@ discard block |
||
1044 | 1044 | * @since 1.0.19 |
1045 | 1045 | * @param array $value items. |
1046 | 1046 | */ |
1047 | - public function set_allowed_items( $value ) { |
|
1048 | - $this->set_items( $value ); |
|
1047 | + public function set_allowed_items($value) { |
|
1048 | + $this->set_items($value); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | /** |
@@ -1054,8 +1054,8 @@ discard block |
||
1054 | 1054 | * @since 1.0.19 |
1055 | 1055 | * @param array $value items. |
1056 | 1056 | */ |
1057 | - public function set_excluded_items( $value ) { |
|
1058 | - $this->set_prop( 'excluded_items', array_filter( wp_parse_id_list( $value ) ) ); |
|
1057 | + public function set_excluded_items($value) { |
|
1058 | + $this->set_prop('excluded_items', array_filter(wp_parse_id_list($value))); |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | /** |
@@ -1064,8 +1064,8 @@ discard block |
||
1064 | 1064 | * @since 1.0.19 |
1065 | 1065 | * @param array $value items. |
1066 | 1066 | */ |
1067 | - public function set_required_items( $value ) { |
|
1068 | - $this->set_prop( 'required_items', array_filter( wp_parse_id_list( $value ) ) ); |
|
1067 | + public function set_required_items($value) { |
|
1068 | + $this->set_prop('required_items', array_filter(wp_parse_id_list($value))); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | /** |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * @since 1.0.19 |
1075 | 1075 | * @param int|bool $value is recurring. |
1076 | 1076 | */ |
1077 | - public function set_is_recurring( $value ) { |
|
1078 | - $this->set_prop( 'is_recurring', (bool) $value ); |
|
1077 | + public function set_is_recurring($value) { |
|
1078 | + $this->set_prop('is_recurring', (bool) $value); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | /** |
@@ -1084,8 +1084,8 @@ discard block |
||
1084 | 1084 | * @since 1.0.19 |
1085 | 1085 | * @param float $value minimum total. |
1086 | 1086 | */ |
1087 | - public function set_min_total( $value ) { |
|
1088 | - $this->set_prop( 'min_total', (float) wpinv_sanitize_amount( $value ) ); |
|
1087 | + public function set_min_total($value) { |
|
1088 | + $this->set_prop('min_total', (float) wpinv_sanitize_amount($value)); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | /** |
@@ -1094,8 +1094,8 @@ discard block |
||
1094 | 1094 | * @since 1.0.19 |
1095 | 1095 | * @param float $value minimum total. |
1096 | 1096 | */ |
1097 | - public function set_minimum_total( $value ) { |
|
1098 | - $this->set_min_total( $value ); |
|
1097 | + public function set_minimum_total($value) { |
|
1098 | + $this->set_min_total($value); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | /** |
@@ -1104,8 +1104,8 @@ discard block |
||
1104 | 1104 | * @since 1.0.19 |
1105 | 1105 | * @param float $value maximum total. |
1106 | 1106 | */ |
1107 | - public function set_max_total( $value ) { |
|
1108 | - $this->set_prop( 'max_total', (float) wpinv_sanitize_amount( $value ) ); |
|
1107 | + public function set_max_total($value) { |
|
1108 | + $this->set_prop('max_total', (float) wpinv_sanitize_amount($value)); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | /** |
@@ -1114,23 +1114,23 @@ discard block |
||
1114 | 1114 | * @since 1.0.19 |
1115 | 1115 | * @param float $value maximum total. |
1116 | 1116 | */ |
1117 | - public function set_maximum_total( $value ) { |
|
1118 | - $this->set_max_total( $value ); |
|
1117 | + public function set_maximum_total($value) { |
|
1118 | + $this->set_max_total($value); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | /** |
1122 | 1122 | * @deprecated |
1123 | 1123 | */ |
1124 | - public function refresh(){} |
|
1124 | + public function refresh() {} |
|
1125 | 1125 | |
1126 | 1126 | /** |
1127 | 1127 | * @deprecated |
1128 | 1128 | * |
1129 | 1129 | */ |
1130 | - public function update_status( $status = 'publish' ) { |
|
1130 | + public function update_status($status = 'publish') { |
|
1131 | 1131 | |
1132 | - if ( $this->exists() && $this->get_status() != $status ) { |
|
1133 | - $this->set_status( $status ); |
|
1132 | + if ($this->exists() && $this->get_status() != $status) { |
|
1133 | + $this->set_status($status); |
|
1134 | 1134 | $this->save(); |
1135 | 1135 | } |
1136 | 1136 | |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | public function exists() { |
1154 | 1154 | $id = $this->get_id(); |
1155 | - return ! empty( $id ); |
|
1155 | + return !empty($id); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | /** |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | * @since 1.0.15 |
1164 | 1164 | * @return bool |
1165 | 1165 | */ |
1166 | - public function is_type( $type ) { |
|
1166 | + public function is_type($type) { |
|
1167 | 1167 | return $this->get_type() == $type; |
1168 | 1168 | } |
1169 | 1169 | |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | */ |
1186 | 1186 | public function has_limit() { |
1187 | 1187 | $limit = $this->get_max_uses(); |
1188 | - return ! empty( $limit ); |
|
1188 | + return !empty($limit); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | /** |
@@ -1206,13 +1206,13 @@ discard block |
||
1206 | 1206 | */ |
1207 | 1207 | public function has_exceeded_limit() { |
1208 | 1208 | |
1209 | - if ( ! $this->has_limit() || ! $this->has_uses() ) { |
|
1209 | + if (!$this->has_limit() || !$this->has_uses()) { |
|
1210 | 1210 | $exceeded = false; |
1211 | 1211 | } else { |
1212 | 1212 | $exceeded = (int) $this->get_max_uses() <= $this->get_uses(); |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - return apply_filters( 'wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code() ); |
|
1215 | + return apply_filters('wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code()); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | /** |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | */ |
1224 | 1224 | public function has_expiration_date() { |
1225 | 1225 | $date = $this->get_expiration_date(); |
1226 | - return ! empty( $date ); |
|
1226 | + return !empty($date); |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | /** |
@@ -1233,8 +1233,8 @@ discard block |
||
1233 | 1233 | * @return bool |
1234 | 1234 | */ |
1235 | 1235 | public function is_expired() { |
1236 | - $expired = $this->has_expiration_date() ? current_time( 'timestamp' ) > strtotime( $this->get_expiration_date() ) : false; |
|
1237 | - return apply_filters( 'wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code() ); |
|
1236 | + $expired = $this->has_expiration_date() ? current_time('timestamp') > strtotime($this->get_expiration_date()) : false; |
|
1237 | + return apply_filters('wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code()); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | */ |
1246 | 1246 | public function has_start_date() { |
1247 | 1247 | $date = $this->get_start_date(); |
1248 | - return ! empty( $date ); |
|
1248 | + return !empty($date); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | /** |
@@ -1255,8 +1255,8 @@ discard block |
||
1255 | 1255 | * @return bool |
1256 | 1256 | */ |
1257 | 1257 | public function has_started() { |
1258 | - $started = $this->has_start_date() ? true : current_time( 'timestamp' ) > strtotime( $this->get_start_date() ); |
|
1259 | - return apply_filters( 'wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code() ); |
|
1258 | + $started = $this->has_start_date() ? true : current_time('timestamp') > strtotime($this->get_start_date()); |
|
1259 | + return apply_filters('wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code()); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | /** |
@@ -1267,7 +1267,7 @@ discard block |
||
1267 | 1267 | */ |
1268 | 1268 | public function has_allowed_items() { |
1269 | 1269 | $allowed_items = $this->get_allowed_items(); |
1270 | - return ! empty( $allowed_items ); |
|
1270 | + return !empty($allowed_items); |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | /** |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | */ |
1279 | 1279 | public function has_excluded_items() { |
1280 | 1280 | $excluded_items = $this->get_excluded_items(); |
1281 | - return ! empty( $excluded_items ); |
|
1281 | + return !empty($excluded_items); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | /** |
@@ -1288,17 +1288,17 @@ discard block |
||
1288 | 1288 | * @since 1.0.15 |
1289 | 1289 | * @return boolean |
1290 | 1290 | */ |
1291 | - public function is_valid_for_items( $item_ids ) { |
|
1291 | + public function is_valid_for_items($item_ids) { |
|
1292 | 1292 | |
1293 | - $item_ids = array_filter( wp_parse_id_list( $item_ids ) ); |
|
1294 | - $included = array_intersect( $item_ids, $this->get_allowed_items() ); |
|
1295 | - $excluded = array_intersect( $item_ids, $this->get_excluded_items() ); |
|
1293 | + $item_ids = array_filter(wp_parse_id_list($item_ids)); |
|
1294 | + $included = array_intersect($item_ids, $this->get_allowed_items()); |
|
1295 | + $excluded = array_intersect($item_ids, $this->get_excluded_items()); |
|
1296 | 1296 | |
1297 | - if ( $this->has_excluded_items() && ! empty( $excluded ) ) { |
|
1297 | + if ($this->has_excluded_items() && !empty($excluded)) { |
|
1298 | 1298 | return false; |
1299 | 1299 | } |
1300 | 1300 | |
1301 | - if ( $this->has_allowed_items() && empty( $included ) ) { |
|
1301 | + if ($this->has_allowed_items() && empty($included)) { |
|
1302 | 1302 | return false; |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | */ |
1314 | 1314 | public function has_required_items() { |
1315 | 1315 | $required_items = $this->get_required_items(); |
1316 | - return ! empty( $required_items ); |
|
1316 | + return !empty($required_items); |
|
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | /** |
@@ -1323,13 +1323,13 @@ discard block |
||
1323 | 1323 | * @since 1.0.15 |
1324 | 1324 | * @return boolean |
1325 | 1325 | */ |
1326 | - public function is_required_items_met( $item_ids ) { |
|
1326 | + public function is_required_items_met($item_ids) { |
|
1327 | 1327 | |
1328 | - if ( ! $this->has_required_items() ) { |
|
1328 | + if (!$this->has_required_items()) { |
|
1329 | 1329 | return true; |
1330 | 1330 | } |
1331 | 1331 | |
1332 | - return ! array_diff( $this->get_required_items(), array_filter( wp_parse_id_list( $item_ids ) ) ); |
|
1332 | + return !array_diff($this->get_required_items(), array_filter(wp_parse_id_list($item_ids))); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | /** |
@@ -1339,8 +1339,8 @@ discard block |
||
1339 | 1339 | * @since 1.0.15 |
1340 | 1340 | * @return boolean |
1341 | 1341 | */ |
1342 | - public function is_valid_for_amount( $amount ) { |
|
1343 | - return $this->is_minimum_amount_met( $amount ) && $this->is_maximum_amount_met( $amount ); |
|
1342 | + public function is_valid_for_amount($amount) { |
|
1343 | + return $this->is_minimum_amount_met($amount) && $this->is_maximum_amount_met($amount); |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | /** |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | */ |
1352 | 1352 | public function has_minimum_amount() { |
1353 | 1353 | $minimum = $this->get_minimum_total(); |
1354 | - return ! empty( $minimum ); |
|
1354 | + return !empty($minimum); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | /** |
@@ -1361,10 +1361,10 @@ discard block |
||
1361 | 1361 | * @since 1.0.15 |
1362 | 1362 | * @return boolean |
1363 | 1363 | */ |
1364 | - public function is_minimum_amount_met( $amount ) { |
|
1365 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
1366 | - $min_met = ! ( $this->has_minimum_amount() && $amount < floatval( wpinv_sanitize_amount( $this->get_minimum_total() ) ) ); |
|
1367 | - return apply_filters( 'wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount ); |
|
1364 | + public function is_minimum_amount_met($amount) { |
|
1365 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
1366 | + $min_met = !($this->has_minimum_amount() && $amount < floatval(wpinv_sanitize_amount($this->get_minimum_total()))); |
|
1367 | + return apply_filters('wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | /** |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | */ |
1376 | 1376 | public function has_maximum_amount() { |
1377 | 1377 | $maximum = $this->get_maximum_total(); |
1378 | - return ! empty( $maximum ); |
|
1378 | + return !empty($maximum); |
|
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | /** |
@@ -1385,10 +1385,10 @@ discard block |
||
1385 | 1385 | * @since 1.0.15 |
1386 | 1386 | * @return boolean |
1387 | 1387 | */ |
1388 | - public function is_maximum_amount_met( $amount ) { |
|
1389 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
1390 | - $max_met = ! ( $this->has_maximum_amount() && $amount > floatval( wpinv_sanitize_amount( $this->get_maximum_total() ) ) ); |
|
1391 | - return apply_filters( 'wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount ); |
|
1388 | + public function is_maximum_amount_met($amount) { |
|
1389 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
1390 | + $max_met = !($this->has_maximum_amount() && $amount > floatval(wpinv_sanitize_amount($this->get_maximum_total()))); |
|
1391 | + return apply_filters('wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount); |
|
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | /** |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | */ |
1400 | 1400 | public function is_recurring() { |
1401 | 1401 | $recurring = $this->get_is_recurring(); |
1402 | - return ! empty( $recurring ); |
|
1402 | + return !empty($recurring); |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | /** |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | */ |
1411 | 1411 | public function is_single_use() { |
1412 | 1412 | $usage = $this->get_is_single_use(); |
1413 | - return ! empty( $usage ); |
|
1413 | + return !empty($usage); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | /** |
@@ -1420,25 +1420,25 @@ discard block |
||
1420 | 1420 | * @since 1.0.15 |
1421 | 1421 | * @return boolean |
1422 | 1422 | */ |
1423 | - public function is_valid_for_user( $user ) { |
|
1423 | + public function is_valid_for_user($user) { |
|
1424 | 1424 | |
1425 | 1425 | // Ensure that the discount is single use. |
1426 | - if ( empty( $user ) || ! $this->is_single_use() ) { |
|
1426 | + if (empty($user) || !$this->is_single_use()) { |
|
1427 | 1427 | return true; |
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | // Prepare the user id. |
1431 | 1431 | $user_id = 0; |
1432 | - if ( is_numeric( $user ) ) { |
|
1433 | - $user_id = absint( $user ); |
|
1434 | - } elseif ( is_email( $user ) && $user_data = get_user_by( 'email', $user ) ) { |
|
1432 | + if (is_numeric($user)) { |
|
1433 | + $user_id = absint($user); |
|
1434 | + } elseif (is_email($user) && $user_data = get_user_by('email', $user)) { |
|
1435 | 1435 | $user_id = $user_data->ID; |
1436 | - } elseif ( $user_data = get_user_by( 'login', $user ) ) { |
|
1436 | + } elseif ($user_data = get_user_by('login', $user)) { |
|
1437 | 1437 | $user_id = $user_data->ID; |
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | // Ensure that we have a user. |
1441 | - if ( empty( $user_id ) ) { |
|
1441 | + if (empty($user_id)) { |
|
1442 | 1442 | return true; |
1443 | 1443 | } |
1444 | 1444 | |
@@ -1450,13 +1450,13 @@ discard block |
||
1450 | 1450 | 'paginate' => false, |
1451 | 1451 | ) |
1452 | 1452 | ); |
1453 | - $code = strtolower( $this->get_code() ); |
|
1453 | + $code = strtolower($this->get_code()); |
|
1454 | 1454 | |
1455 | 1455 | // For each payment... |
1456 | - foreach ( $payments as $payment ) { |
|
1456 | + foreach ($payments as $payment) { |
|
1457 | 1457 | |
1458 | 1458 | // Only check for paid invoices. |
1459 | - if ( $payment->is_paid() && strtolower( $payment->get_discount_code() ) == $code ) { |
|
1459 | + if ($payment->is_paid() && strtolower($payment->get_discount_code()) == $code) { |
|
1460 | 1460 | return false; |
1461 | 1461 | } |
1462 | 1462 | } |
@@ -1481,24 +1481,24 @@ discard block |
||
1481 | 1481 | * @param int $by The number of usages to increas by. |
1482 | 1482 | * @return int |
1483 | 1483 | */ |
1484 | - public function increase_usage( $by = 1 ) { |
|
1484 | + public function increase_usage($by = 1) { |
|
1485 | 1485 | |
1486 | 1486 | // Abort if zero. |
1487 | - if ( empty( $by ) ) { |
|
1487 | + if (empty($by)) { |
|
1488 | 1488 | return; |
1489 | 1489 | } |
1490 | 1490 | |
1491 | 1491 | // Increase the usage. |
1492 | - $this->set_uses( $this->get_uses() + (int) $by ); |
|
1492 | + $this->set_uses($this->get_uses() + (int) $by); |
|
1493 | 1493 | |
1494 | 1494 | // Save the discount. |
1495 | 1495 | $this->save(); |
1496 | 1496 | |
1497 | 1497 | // Fire relevant hooks. |
1498 | - if ( (int) $by > 0 ) { |
|
1499 | - do_action( 'wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) ); |
|
1498 | + if ((int) $by > 0) { |
|
1499 | + do_action('wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint($by)); |
|
1500 | 1500 | } else { |
1501 | - do_action( 'wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) ); |
|
1501 | + do_action('wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint($by)); |
|
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | // Return the number of times the discount has been used. |
@@ -1522,7 +1522,7 @@ discard block |
||
1522 | 1522 | * @param float $amount |
1523 | 1523 | * @return float |
1524 | 1524 | */ |
1525 | - public function get_discounted_amount( $amount ) { |
|
1525 | + public function get_discounted_amount($amount) { |
|
1526 | 1526 | |
1527 | 1527 | // Convert amount to float. |
1528 | 1528 | $amount = (float) $amount; |
@@ -1530,29 +1530,29 @@ discard block |
||
1530 | 1530 | // Get discount amount. |
1531 | 1531 | $discount_amount = $this->get_amount(); |
1532 | 1532 | |
1533 | - if ( empty( $discount_amount ) ) { |
|
1533 | + if (empty($discount_amount)) { |
|
1534 | 1534 | return 0; |
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | // Format the amount. |
1538 | - $discount_amount = floatval( wpinv_sanitize_amount( $discount_amount ) ); |
|
1538 | + $discount_amount = floatval(wpinv_sanitize_amount($discount_amount)); |
|
1539 | 1539 | |
1540 | 1540 | // If this is a percentage discount. |
1541 | - if ( $this->is_type( 'percent' ) ) { |
|
1542 | - $discount_amount = $amount * ( $discount_amount / 100 ); |
|
1541 | + if ($this->is_type('percent')) { |
|
1542 | + $discount_amount = $amount * ($discount_amount / 100); |
|
1543 | 1543 | } |
1544 | 1544 | |
1545 | 1545 | // Discount can not be less than zero... |
1546 | - if ( $discount_amount < 0 ) { |
|
1546 | + if ($discount_amount < 0) { |
|
1547 | 1547 | $discount_amount = 0; |
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | // ... or more than the amount. |
1551 | - if ( $discount_amount > $amount ) { |
|
1551 | + if ($discount_amount > $amount) { |
|
1552 | 1552 | $discount_amount = $amount; |
1553 | 1553 | } |
1554 | 1554 | |
1555 | - return apply_filters( 'wpinv_discount_total_discount_amount', $discount_amount, $amount, $this ); |
|
1555 | + return apply_filters('wpinv_discount_total_discount_amount', $discount_amount, $amount, $this); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | ?> |
12 | 12 | |
13 | 13 | <hr class="featurette-divider" /> |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | <p> |
4 | 4 | <?php |
5 | 5 | echo wp_sprintf( |
6 | - wp_kses_post( __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ) ), |
|
7 | - esc_url_raw( remove_query_arg( 'payment-confirm' ) ) |
|
6 | + wp_kses_post(__('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing')), |
|
7 | + esc_url_raw(remove_query_arg('payment-confirm')) |
|
8 | 8 | ); |
9 | 9 | ?> |
10 | 10 | <i class="fa fa-spin fa-refresh"></i> |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | <script type="text/javascript"> |
14 | 14 | setTimeout( |
15 | 15 | function(){ |
16 | - window.location.href = '<?php echo esc_url_raw( remove_query_arg( 'payment-confirm' ) ); ?>'; |
|
16 | + window.location.href = '<?php echo esc_url_raw(remove_query_arg('payment-confirm')); ?>'; |
|
17 | 17 | }, |
18 | 18 | 10000 |
19 | 19 | ); |
@@ -7,14 +7,14 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div v-if='!is_default'> |
15 | - <div class='alert alert-info' role='alert'><?php esc_html_e( 'Item totals will appear here. Click to set items.', 'invoicing' ); ?></div> |
|
15 | + <div class='alert alert-info' role='alert'><?php esc_html_e('Item totals will appear here. Click to set items.', 'invoicing'); ?></div> |
|
16 | 16 | </div> |
17 | 17 | |
18 | 18 | <div v-if='is_default'> |
19 | - <div class='alert alert-info' role='alert'><?php esc_html_e( 'Item totals will appear here.', 'invoicing' ); ?></div> |
|
19 | + <div class='alert alert-info' role='alert'><?php esc_html_e('Item totals will appear here.', 'invoicing'); ?></div> |
|
20 | 20 | </div> |
@@ -7,15 +7,15 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <label><span v-html="form_element.label"></span></label> |
15 | 15 | <div class="d-flex w-100 flex-column align-items-center justify-content-center p-2" style="height: 200px; border: 3px dashed rgb(136, 136, 136); cursor: pointer;"> |
16 | 16 | <div class="h5 text-dark"> |
17 | - <span v-if="form_element.max_file_num > 1"><?php esc_html_e( 'Drag files to this area or click to upload', 'invoicing' ); ?></span> |
|
18 | - <span v-if="form_element.max_file_num < 2"><?php esc_html_e( 'Drag your file to this area or click to upload', 'invoicing' ); ?></span> |
|
17 | + <span v-if="form_element.max_file_num > 1"><?php esc_html_e('Drag files to this area or click to upload', 'invoicing'); ?></span> |
|
18 | + <span v-if="form_element.max_file_num < 2"><?php esc_html_e('Drag your file to this area or click to upload', 'invoicing'); ?></span> |
|
19 | 19 | </div> |
20 | 20 | <small v-if='form_element.description' class='form-text text-muted' v-html='form_element.description'></small> |
21 | 21 | </div> |
@@ -8,25 +8,25 @@ |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="getpaid-header-left-actions"> |
16 | 16 | |
17 | - <?php if ( $invoice->is_type( 'invoice' ) && $invoice->needs_payment() && ! $invoice->is_held() ) : ?> |
|
18 | - <a class="btn btn-sm btn-primary m-1 d-inline-block invoice-action-pay" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"> |
|
19 | - <?php esc_html_e( 'Pay For Invoice', 'invoicing' ); ?> |
|
17 | + <?php if ($invoice->is_type('invoice') && $invoice->needs_payment() && !$invoice->is_held()) : ?> |
|
18 | + <a class="btn btn-sm btn-primary m-1 d-inline-block invoice-action-pay" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"> |
|
19 | + <?php esc_html_e('Pay For Invoice', 'invoicing'); ?> |
|
20 | 20 | </a> |
21 | 21 | <?php endif; ?> |
22 | 22 | |
23 | - <?php if ( $invoice->is_type( 'invoice' ) && $invoice->is_paid() ) : ?> |
|
24 | - <a class="btn btn-sm btn-info m-1 d-inline-block invoice-action-receipt" href="<?php echo esc_url( $invoice->get_receipt_url() ); ?>"> |
|
25 | - <?php esc_html_e( 'View Receipt', 'invoicing' ); ?> |
|
23 | + <?php if ($invoice->is_type('invoice') && $invoice->is_paid()) : ?> |
|
24 | + <a class="btn btn-sm btn-info m-1 d-inline-block invoice-action-receipt" href="<?php echo esc_url($invoice->get_receipt_url()); ?>"> |
|
25 | + <?php esc_html_e('View Receipt', 'invoicing'); ?> |
|
26 | 26 | </a> |
27 | 27 | <?php endif; ?> |
28 | 28 | |
29 | - <?php do_action( 'wpinv_invoice_display_left_actions', $invoice ); ?> |
|
29 | + <?php do_action('wpinv_invoice_display_left_actions', $invoice); ?> |
|
30 | 30 | |
31 | 31 | </div> |
32 | 32 |
@@ -7,11 +7,11 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Fetch the invoice. |
13 | -if ( empty( $invoice ) ) { |
|
14 | - $invoice = new WPInv_Invoice( $GLOBALS['post'] ); |
|
13 | +if (empty($invoice)) { |
|
14 | + $invoice = new WPInv_Invoice($GLOBALS['post']); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | ?><!DOCTYPE html> |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | |
22 | 22 | <head> |
23 | 23 | |
24 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
24 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
25 | 25 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
26 | 26 | |
27 | 27 | <meta name="robots" content="noindex,nofollow"> |
28 | 28 | |
29 | 29 | <link rel="profile" href="https://gmpg.org/xfn/11"> |
30 | 30 | |
31 | - <title><?php esc_html_e( 'Invalid Access', 'invoicing' ); ?></title> |
|
31 | + <title><?php esc_html_e('Invalid Access', 'invoicing'); ?></title> |
|
32 | 32 | |
33 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
33 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
34 | 34 | |
35 | 35 | </head> |
36 | 36 | |
@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | |
40 | 40 | <?php |
41 | 41 | |
42 | - if ( ! $invoice->exists() || $invoice->is_draft() ) { |
|
43 | - $error = __( 'This invoice was deleted or is not visible.', 'invoicing' ); |
|
42 | + if (!$invoice->exists() || $invoice->is_draft()) { |
|
43 | + $error = __('This invoice was deleted or is not visible.', 'invoicing'); |
|
44 | 44 | } else { |
45 | 45 | |
46 | 46 | $user_id = get_current_user_id(); |
47 | - if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) { |
|
48 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
47 | + if (wpinv_require_login_to_checkout() && empty($user_id)) { |
|
48 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
49 | 49 | $error .= sprintf( |
50 | 50 | ' <a href="%s">%s</a>', |
51 | - wp_login_url( $invoice->get_view_url() ), |
|
52 | - __( 'Login.', 'invoicing' ) |
|
51 | + wp_login_url($invoice->get_view_url()), |
|
52 | + __('Login.', 'invoicing') |
|
53 | 53 | ); |
54 | 54 | } else { |
55 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
55 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | <div class="container"> |
62 | 62 | <div class="alert alert-danger m-5" role="alert"> |
63 | - <h4 class="alert-heading"><?php esc_html_e( 'Access Denied', 'invoicing' ); ?></h4> |
|
64 | - <p><?php echo wp_kses_post( $error ); ?></p> |
|
63 | + <h4 class="alert-heading"><?php esc_html_e('Access Denied', 'invoicing'); ?></h4> |
|
64 | + <p><?php echo wp_kses_post($error); ?></p> |
|
65 | 65 | </div> |
66 | 66 | </div> |
67 | 67 |
@@ -9,45 +9,45 @@ |
||
9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) : |
|
14 | +foreach (array_keys($widget->get_subscriptions_table_columns()) as $column) : |
|
15 | 15 | |
16 | - $class = sanitize_html_class( $column ); |
|
17 | - echo "<td class='getpaid-subscriptions-table-column-" . esc_attr( $class ) . "'>"; |
|
16 | + $class = sanitize_html_class($column); |
|
17 | + echo "<td class='getpaid-subscriptions-table-column-" . esc_attr($class) . "'>"; |
|
18 | 18 | |
19 | - do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
19 | + do_action("getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription); |
|
20 | 20 | |
21 | - switch ( $column ) : |
|
21 | + switch ($column) : |
|
22 | 22 | |
23 | 23 | case 'subscription': |
24 | 24 | $subscription_id = (int) $subscription->get_id(); |
25 | - $url = esc_url( $subscription->get_view_url() ); |
|
25 | + $url = esc_url($subscription->get_view_url()); |
|
26 | 26 | $id_label = sprintf( |
27 | - esc_attr_x( '#%s', 'subscription id', 'invoicing' ), |
|
27 | + esc_attr_x('#%s', 'subscription id', 'invoicing'), |
|
28 | 28 | (int) $subscription->get_id() |
29 | 29 | ); |
30 | - echo wp_kses_post( $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ) ); |
|
30 | + echo wp_kses_post($widget->add_row_actions("<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription)); |
|
31 | 31 | break; |
32 | 32 | |
33 | 33 | case 'status': |
34 | - echo esc_html( $subscription->get_status_label() ); |
|
34 | + echo esc_html($subscription->get_status_label()); |
|
35 | 35 | break; |
36 | 36 | |
37 | 37 | case 'renewal-date': |
38 | - $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
39 | - echo $subscription->is_active() ? esc_html( $renewal ) : '—'; |
|
38 | + $renewal = getpaid_format_date_value($subscription->get_next_renewal_date()); |
|
39 | + echo $subscription->is_active() ? esc_html($renewal) : '—'; |
|
40 | 40 | break; |
41 | 41 | |
42 | 42 | case 'amount': |
43 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
44 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
45 | - echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
43 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
44 | + $amount = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
45 | + echo wp_kses_post("<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>"); |
|
46 | 46 | break; |
47 | 47 | |
48 | 48 | endswitch; |
49 | 49 | |
50 | - do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
50 | + do_action("getpaid_subscriptions_frontend_subscription_table_$column", $subscription); |
|
51 | 51 | |
52 | 52 | echo '</td>'; |
53 | 53 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | function __construct($name, $slug) { |
61 | 61 | $this->name = $name; |
62 | 62 | $this->slug = $slug; |
63 | - if (!empty($_GET['id'])){ |
|
63 | + if (!empty($_GET['id'])) { |
|
64 | 64 | $this->isWizard = false; |
65 | 65 | } |
66 | 66 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | function is_active_addon($post_type = null) { |
77 | 77 | |
78 | - if ( ! class_exists( 'PMXI_Plugin' ) ) { |
|
78 | + if (!class_exists('PMXI_Plugin')) { |
|
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - if ($addon_active){ |
|
90 | + if ($addon_active) { |
|
91 | 91 | |
92 | 92 | $current_theme = wp_get_theme(); |
93 | 93 | |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | |
98 | 98 | $addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false; |
99 | 99 | |
100 | - if ( ! $addon_active and $parent_theme ){ |
|
100 | + if (!$addon_active and $parent_theme) { |
|
101 | 101 | $parent_theme_name = $parent_theme->get('Name'); |
102 | 102 | $addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false; |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - if ( $addon_active and ! empty($this->active_plugins) ){ |
|
106 | + if ($addon_active and !empty($this->active_plugins)) { |
|
107 | 107 | |
108 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
108 | + include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
109 | 109 | |
110 | 110 | foreach ($this->active_plugins as $plugin) { |
111 | - if ( ! is_plugin_active($plugin) ) { |
|
111 | + if (!is_plugin_active($plugin)) { |
|
112 | 112 | $addon_active = false; |
113 | 113 | break; |
114 | 114 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | $this->when_to_run = "always"; |
138 | 138 | } |
139 | 139 | |
140 | - @$this->active_post_types = ( ! empty($conditions['post_types'])) ? $conditions['post_types'] : array(); |
|
141 | - @$this->active_themes = ( ! empty($conditions['themes'])) ? $conditions['themes'] : array(); |
|
142 | - @$this->active_plugins = ( ! empty($conditions['plugins'])) ? $conditions['plugins'] : array(); |
|
140 | + @$this->active_post_types = (!empty($conditions['post_types'])) ? $conditions['post_types'] : array(); |
|
141 | + @$this->active_themes = (!empty($conditions['themes'])) ? $conditions['themes'] : array(); |
|
142 | + @$this->active_plugins = (!empty($conditions['plugins'])) ? $conditions['plugins'] : array(); |
|
143 | 143 | |
144 | 144 | add_filter('pmxi_addons', array($this, 'wpai_api_register')); |
145 | 145 | add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse')); |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | add_filter('pmxi_options_options', array($this, 'wpai_api_options')); |
149 | 149 | add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1); |
150 | 150 | add_filter('pmxi_custom_types', array($this, 'filter_post_types'), 10, 2); |
151 | - add_filter('pmxi_post_list_order', array($this,'sort_post_types'), 10, 1); |
|
152 | - add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1 ); |
|
153 | - add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2); |
|
151 | + add_filter('pmxi_post_list_order', array($this, 'sort_post_types'), 10, 1); |
|
152 | + add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1); |
|
153 | + add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2); |
|
154 | 154 | add_action('admin_init', array($this, 'admin_notice_ignore')); |
155 | 155 | } |
156 | 156 | |
157 | 157 | function parse($data) { |
158 | 158 | |
159 | - if ( ! $this->is_active_addon($data['import']->options['custom_type'])) return false; |
|
159 | + if (!$this->is_active_addon($data['import']->options['custom_type'])) return false; |
|
160 | 160 | |
161 | 161 | $parsedData = $this->helper_parse($data, $this->options_array()); |
162 | 162 | return $parsedData; |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | |
167 | 167 | function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') { |
168 | 168 | |
169 | - $field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text); |
|
169 | + $field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text); |
|
170 | 170 | |
171 | 171 | $this->fields[$field_slug] = $field; |
172 | 172 | |
173 | - if ( ! empty($enum_values) ){ |
|
173 | + if (!empty($enum_values)) { |
|
174 | 174 | foreach ($enum_values as $key => $value) { |
175 | 175 | if (is_array($value)) |
176 | 176 | { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | else |
182 | 182 | { |
183 | 183 | foreach ($value as $n => $param) { |
184 | - if (is_array($param) and ! empty($this->fields[$param['slug']])){ |
|
184 | + if (is_array($param) and !empty($this->fields[$param['slug']])) { |
|
185 | 185 | $this->fields[$param['slug']]['is_sub_field'] = true; |
186 | 186 | } |
187 | 187 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | } |
196 | 196 | |
197 | - function add_acf_field($field){ |
|
197 | + function add_acf_field($field) { |
|
198 | 198 | $this->fields[$field->post_name] = array( |
199 | 199 | 'type' => 'acf', |
200 | 200 | 'field_obj' => $field |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | |
204 | 204 | private $acfGroups = array(); |
205 | 205 | |
206 | - function use_acf_group($acf_group){ |
|
206 | + function use_acf_group($acf_group) { |
|
207 | 207 | $this->add_text( |
208 | 208 | '<div class="postbox acf_postbox default acf_signle_group rad4"> |
209 | - <h3 class="hndle" style="margin-top:0;"><span>'.$acf_group['title'].'</span></h3> |
|
209 | + <h3 class="hndle" style="margin-top:0;"><span>'.$acf_group['title'] . '</span></h3> |
|
210 | 210 | <div class="inside">'); |
211 | 211 | $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC')); |
212 | - if (!empty($acf_fields)){ |
|
212 | + if (!empty($acf_fields)) { |
|
213 | 213 | foreach ($acf_fields as $field) { |
214 | 214 | $this->add_acf_field($field); |
215 | 215 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2); |
220 | 220 | } |
221 | 221 | |
222 | - function acf_is_show_group($is_show, $acf_group){ |
|
222 | + function acf_is_show_group($is_show, $acf_group) { |
|
223 | 223 | return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true; |
224 | 224 | } |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param string $default_value - default option value |
232 | 232 | * |
233 | 233 | */ |
234 | - function add_option($slug, $default_value = ''){ |
|
234 | + function add_option($slug, $default_value = '') { |
|
235 | 235 | $this->options[$slug] = $default_value; |
236 | 236 | } |
237 | 237 | |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | |
240 | 240 | $options_list = array(); |
241 | 241 | |
242 | - if ( ! empty( $this->fields ) ) { |
|
242 | + if (!empty($this->fields)) { |
|
243 | 243 | |
244 | 244 | foreach ($this->fields as $field_slug => $field_params) { |
245 | 245 | if (in_array($field_params['type'], array('title', 'plain_text', 'acf'))) continue; |
246 | 246 | $default_value = ''; |
247 | - if (!empty($field_params['enum_values'])){ |
|
247 | + if (!empty($field_params['enum_values'])) { |
|
248 | 248 | foreach ($field_params['enum_values'] as $key => $value) { |
249 | 249 | $default_value = $key; |
250 | 250 | break; |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | |
256 | 256 | } |
257 | 257 | |
258 | - if ( ! empty($this->options) ){ |
|
258 | + if (!empty($this->options)) { |
|
259 | 259 | foreach ($this->options as $slug => $value) { |
260 | 260 | $options_arr[$slug] = $value; |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | 264 | $options_arr[$this->slug] = $options_list; |
265 | - $options_arr['rapid_addon'] = plugin_basename( __FILE__ ); |
|
265 | + $options_arr['rapid_addon'] = plugin_basename(__FILE__); |
|
266 | 266 | |
267 | 267 | return $options_arr; |
268 | 268 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | } |
297 | 297 | |
298 | - function wpai_api_post_saved($functions){ |
|
298 | + function wpai_api_post_saved($functions) { |
|
299 | 299 | $functions[$this->slug] = array($this, 'post_saved'); |
300 | 300 | return $functions; |
301 | 301 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | } |
310 | 310 | |
311 | - function post_saved( $importData ){ |
|
311 | + function post_saved($importData) { |
|
312 | 312 | |
313 | 313 | if (is_callable($this->post_saved_function)) |
314 | 314 | call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']); |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | // print_r($import_options); |
328 | 328 | // echo "</pre>"; |
329 | 329 | |
330 | - if ( ! empty($parsedData) ) { |
|
330 | + if (!empty($parsedData)) { |
|
331 | 331 | |
332 | 332 | $this->logger = $importData['logger']; |
333 | 333 | |
334 | 334 | $post_id = $importData['pid']; |
335 | 335 | $index = $importData['i']; |
336 | 336 | $data = array(); |
337 | - if (!empty($this->fields)){ |
|
337 | + if (!empty($this->fields)) { |
|
338 | 338 | foreach ($this->fields as $field_slug => $field_params) { |
339 | 339 | if (in_array($field_params['type'], array('title', 'plain_text'))) continue; |
340 | 340 | switch ($field_params['type']) { |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | $image_url_or_path = $parsedData[$field_slug][$index]; |
347 | 347 | |
348 | - if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) { |
|
348 | + if (!array_key_exists($field_slug, $import_options['download_image'])) { |
|
349 | 349 | continue 2; |
350 | 350 | } |
351 | 351 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | |
366 | 366 | $image_url_or_path = $parsedData[$field_slug][$index]; |
367 | 367 | |
368 | - if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) { |
|
368 | + if (!array_key_exists($field_slug, $import_options['download_image'])) { |
|
369 | 369 | continue 2; |
370 | 370 | } |
371 | 371 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | if (!empty($mapping_rules) and is_array($mapping_rules)) { |
395 | 395 | foreach ($mapping_rules as $rule_number => $map_to) { |
396 | - if (isset($map_to[trim($data[$field_slug])])){ |
|
396 | + if (isset($map_to[trim($data[$field_slug])])) { |
|
397 | 397 | $data[$field_slug] = trim($map_to[trim($data[$field_slug])]); |
398 | 398 | break; |
399 | 399 | } |
@@ -442,14 +442,14 @@ discard block |
||
442 | 442 | |
443 | 443 | echo $this->helper_metabox_bottom(); |
444 | 444 | |
445 | - if ( ! empty($this->image_sections) ){ |
|
445 | + if (!empty($this->image_sections)) { |
|
446 | 446 | $is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type); |
447 | 447 | foreach ($this->image_sections as $k => $section) { |
448 | 448 | $section_options = array(); |
449 | 449 | foreach ($this->image_options as $slug => $value) { |
450 | 450 | $section_options[$section['slug'] . $slug] = $value; |
451 | 451 | } |
452 | - if ( ! $is_images_section_enabled and ! $k ){ |
|
452 | + if (!$is_images_section_enabled and !$k) { |
|
453 | 453 | $section_options[$section['slug'] . 'is_featured'] = 1; |
454 | 454 | } |
455 | 455 | PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | |
459 | 459 | } |
460 | 460 | |
461 | - function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){ |
|
461 | + function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false) { |
|
462 | 462 | |
463 | 463 | if (!isset($current_values[$this->slug][$field_slug])) { |
464 | 464 | $current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : ''; |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | $field_params['name'], |
472 | 472 | array( |
473 | 473 | 'tooltip' => $field_params['tooltip'], |
474 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
475 | - 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
474 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
475 | + 'field_value' => ($current_values[$this->slug][$field_slug] == '' && $this->isWizard) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
476 | 476 | ) |
477 | 477 | ); |
478 | 478 | |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | $field_params['name'], |
484 | 484 | array( |
485 | 485 | 'tooltip' => $field_params['tooltip'], |
486 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
487 | - 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
486 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
487 | + 'field_value' => ($current_values[$this->slug][$field_slug] == '' && $this->isWizard) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
488 | 488 | ) |
489 | 489 | ); |
490 | 490 | |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | $field_params['name'], |
496 | 496 | array( |
497 | 497 | 'tooltip' => $field_params['tooltip'], |
498 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
499 | - 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
498 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
499 | + 'field_value' => ($current_values[$this->slug][$field_slug] == '' && $this->isWizard) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
500 | 500 | ) |
501 | 501 | ); |
502 | 502 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $field_params['name'], |
510 | 510 | array( |
511 | 511 | 'tooltip' => $field_params['tooltip'], |
512 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
512 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
513 | 513 | 'field_value' => $current_values[$this->slug][$field_slug], |
514 | 514 | 'download_image' => $current_values[$this->slug]['download_image'][$field_slug], |
515 | 515 | 'field_key' => $field_slug, |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | $field_params['name'], |
529 | 529 | array( |
530 | 530 | 'tooltip' => $field_params['tooltip'], |
531 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
531 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
532 | 532 | 'field_value' => $current_values[$this->slug][$field_slug], |
533 | 533 | 'enum_values' => $field_params['enum_values'], |
534 | 534 | 'mapping' => true, |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | ) |
541 | 541 | ); |
542 | 542 | |
543 | - } else if($field_params['type'] == 'accordion') { |
|
543 | + } else if ($field_params['type'] == 'accordion') { |
|
544 | 544 | |
545 | 545 | PMXI_API::add_field( |
546 | 546 | 'accordion', |
547 | 547 | $field_params['name'], |
548 | 548 | array( |
549 | 549 | 'tooltip' => $field_params['tooltip'], |
550 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
550 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
551 | 551 | 'field_key' => $field_slug, |
552 | 552 | 'addon_prefix' => $this->slug, |
553 | 553 | 'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values), |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | ) |
556 | 556 | ); |
557 | 557 | |
558 | - } else if($field_params['type'] == 'acf') { |
|
558 | + } else if ($field_params['type'] == 'acf') { |
|
559 | 559 | $fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array(); |
560 | 560 | $fieldData['ID'] = $field_params['field_obj']->ID; |
561 | 561 | $fieldData['id'] = $field_params['field_obj']->ID; |
@@ -563,19 +563,19 @@ discard block |
||
563 | 563 | $fieldData['key'] = $field_params['field_obj']->post_name; |
564 | 564 | if (empty($fieldData['name'])) $fieldData['name'] = $field_params['field_obj']->post_excerpt; |
565 | 565 | if (function_exists('pmai_render_field')) { |
566 | - echo pmai_render_field($fieldData, ( ! empty($current_values) ) ? $current_values : array() ); |
|
566 | + echo pmai_render_field($fieldData, (!empty($current_values)) ? $current_values : array()); |
|
567 | 567 | } |
568 | - } else if($field_params['type'] == 'title'){ |
|
568 | + } else if ($field_params['type'] == 'title') { |
|
569 | 569 | ?> |
570 | - <h4 class="wpallimport-add-on-options-title"><?php esc_html_e($field_params['name'], 'wp_all_import_plugin'); ?><?php if ( ! empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4> |
|
570 | + <h4 class="wpallimport-add-on-options-title"><?php esc_html_e($field_params['name'], 'wp_all_import_plugin'); ?><?php if (!empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4> |
|
571 | 571 | <?php |
572 | 572 | |
573 | - } else if($field_params['type'] == 'plain_text'){ |
|
573 | + } else if ($field_params['type'] == 'plain_text') { |
|
574 | 574 | if ($field_params['is_html']): |
575 | 575 | echo $field_params['name']; |
576 | 576 | else: |
577 | 577 | ?> |
578 | - <p style="margin: 0 0 12px 0;"><?php echo $field_params['name'];?></p> |
|
578 | + <p style="margin: 0 0 12px 0;"><?php echo $field_params['name']; ?></p> |
|
579 | 579 | <?php |
580 | 580 | endif; |
581 | 581 | } |
@@ -587,19 +587,19 @@ discard block |
||
587 | 587 | * Helper function for nested radio fields |
588 | 588 | * |
589 | 589 | */ |
590 | - function get_sub_fields($field_params, $field_slug, $current_values){ |
|
590 | + function get_sub_fields($field_params, $field_slug, $current_values) { |
|
591 | 591 | $sub_fields = array(); |
592 | - if ( ! empty($field_params['enum_values']) ){ |
|
592 | + if (!empty($field_params['enum_values'])) { |
|
593 | 593 | foreach ($field_params['enum_values'] as $key => $value) { |
594 | 594 | $sub_fields[$key] = array(); |
595 | - if (is_array($value)){ |
|
596 | - if ($field_params['type'] == 'accordion'){ |
|
595 | + if (is_array($value)) { |
|
596 | + if ($field_params['type'] == 'accordion') { |
|
597 | 597 | $sub_fields[$key][] = $this->convert_field($value, $current_values); |
598 | 598 | } |
599 | 599 | else |
600 | 600 | { |
601 | 601 | foreach ($value as $k => $sub_field) { |
602 | - if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']])) |
|
602 | + if (is_array($sub_field) and !empty($this->fields[$sub_field['slug']])) |
|
603 | 603 | { |
604 | 604 | $sub_fields[$key][] = $this->convert_field($sub_field, $current_values); |
605 | 605 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | return $sub_fields; |
612 | 612 | } |
613 | 613 | |
614 | - function convert_field($sub_field, $current_values){ |
|
614 | + function convert_field($sub_field, $current_values) { |
|
615 | 615 | $field = array(); |
616 | 616 | if (!isset($current_values[$this->slug][$sub_field['slug']])) { |
617 | 617 | $current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : ''; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | 'label' => $this->fields[$sub_field['slug']]['name'], |
624 | 624 | 'params' => array( |
625 | 625 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
626 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
626 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
627 | 627 | 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']], |
628 | 628 | 'is_main_field' => $sub_field['is_main_field'] |
629 | 629 | ) |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | 'label' => $this->fields[$sub_field['slug']]['name'], |
636 | 636 | 'params' => array( |
637 | 637 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
638 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
638 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
639 | 639 | 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']], |
640 | 640 | 'is_main_field' => $sub_field['is_main_field'] |
641 | 641 | ) |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | 'label' => $this->fields[$sub_field['slug']]['name'], |
648 | 648 | 'params' => array( |
649 | 649 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
650 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
650 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
651 | 651 | 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']], |
652 | 652 | 'is_main_field' => $sub_field['is_main_field'] |
653 | 653 | ) |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | 'label' => $this->fields[$sub_field['slug']]['name'], |
660 | 660 | 'params' => array( |
661 | 661 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
662 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
662 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
663 | 663 | 'field_value' => $current_values[$this->slug][$sub_field['slug']], |
664 | 664 | 'download_image' => null, |
665 | 665 | 'field_key' => $sub_field['slug'], |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | ) |
669 | 669 | ); |
670 | 670 | |
671 | - if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) { |
|
671 | + if (array_key_exists('download_image', $current_values[$this->slug]) && array_key_exists($sub_field['slug'], $current_values[$this->slug]['download_image'])) { |
|
672 | 672 | $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']]; |
673 | 673 | } |
674 | 674 | break; |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | 'label' => $this->fields[$sub_field['slug']]['name'], |
679 | 679 | 'params' => array( |
680 | 680 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
681 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
681 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
682 | 682 | 'field_value' => $current_values[$this->slug][$sub_field['slug']], |
683 | 683 | 'download_image' => null, |
684 | 684 | 'field_key' => $sub_field['slug'], |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | ) |
688 | 688 | ); |
689 | 689 | |
690 | - if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) { |
|
690 | + if (array_key_exists('download_image', $current_values[$this->slug]) && array_key_exists($sub_field['slug'], $current_values[$this->slug]['download_image'])) { |
|
691 | 691 | $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']]; |
692 | 692 | } |
693 | 693 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'label' => $this->fields[$sub_field['slug']]['name'], |
699 | 699 | 'params' => array( |
700 | 700 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
701 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
701 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
702 | 702 | 'field_value' => $current_values[$this->slug][$sub_field['slug']], |
703 | 703 | 'enum_values' => $this->fields[$sub_field['slug']]['enum_values'], |
704 | 704 | 'mapping' => true, |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | 'label' => $this->fields[$sub_field['slug']]['name'], |
718 | 718 | 'params' => array( |
719 | 719 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
720 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
720 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
721 | 721 | 'field_key' => $sub_field['slug'], |
722 | 722 | 'addon_prefix' => $this->slug, |
723 | 723 | 'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values), |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | * |
739 | 739 | * |
740 | 740 | */ |
741 | - function add_options( $main_field = false, $title = '', $fields = array() ){ |
|
741 | + function add_options($main_field = false, $title = '', $fields = array()) { |
|
742 | 742 | |
743 | - if ( ! empty($fields) ) |
|
743 | + if (!empty($fields)) |
|
744 | 744 | { |
745 | 745 | |
746 | - if ($main_field){ |
|
746 | + if ($main_field) { |
|
747 | 747 | |
748 | 748 | $main_field['is_main_field'] = true; |
749 | 749 | $fields[] = $main_field; |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | |
757 | 757 | } |
758 | 758 | |
759 | - function add_title($title = '', $tooltip = ''){ |
|
759 | + function add_title($title = '', $tooltip = '') { |
|
760 | 760 | |
761 | 761 | if (empty($title)) return; |
762 | 762 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | } |
766 | 766 | |
767 | - function add_text($text = '', $is_html = false){ |
|
767 | + function add_text($text = '', $is_html = false) { |
|
768 | 768 | |
769 | 769 | if (empty($text)) return; |
770 | 770 | |
@@ -862,10 +862,10 @@ discard block |
||
862 | 862 | margin: 45px 0 15px 0; |
863 | 863 | } |
864 | 864 | </style> |
865 | - <div class="wpallimport-collapsed wpallimport-section wpallimport-addon '.$this->slug.' closed"> |
|
865 | + <div class="wpallimport-collapsed wpallimport-section wpallimport-addon '.$this->slug . ' closed"> |
|
866 | 866 | <div class="wpallimport-content-section"> |
867 | 867 | <div class="wpallimport-collapsed-header"> |
868 | - <h3>'.__($name,'pmxi_plugin').'</h3> |
|
868 | + <h3>'.__($name, 'pmxi_plugin') . '</h3> |
|
869 | 869 | </div> |
870 | 870 | <div class="wpallimport-collapsed-content" style="padding: 0;"> |
871 | 871 | <div class="wpallimport-collapsed-content-inner"> |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * simply add an additional section for attachments |
892 | 892 | * |
893 | 893 | */ |
894 | - function import_files( $slug, $title, $callback = NULL ){ |
|
895 | - $this->import_images( $slug, $title, 'files', $callback); |
|
894 | + function import_files($slug, $title, $callback = NULL) { |
|
895 | + $this->import_images($slug, $title, 'files', $callback); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -900,9 +900,9 @@ discard block |
||
900 | 900 | * simply add an additional section |
901 | 901 | * |
902 | 902 | */ |
903 | - function import_images( $slug, $title, $type = 'images', $callback = NULL ){ |
|
903 | + function import_images($slug, $title, $type = 'images', $callback = NULL) { |
|
904 | 904 | |
905 | - if ( empty($title) or empty($slug) ) return; |
|
905 | + if (empty($title) or empty($slug)) return; |
|
906 | 906 | |
907 | 907 | if (is_array($slug)) { |
908 | 908 | $section_slug = 'pmxi_' . md5(serialize($slug)); |
@@ -920,17 +920,17 @@ discard block |
||
920 | 920 | $this->add_option($section_slug . $option_slug, $value); |
921 | 921 | } |
922 | 922 | |
923 | - if (count($this->image_sections) > 1){ |
|
923 | + if (count($this->image_sections) > 1) { |
|
924 | 924 | add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2); |
925 | 925 | } |
926 | 926 | |
927 | 927 | add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2); |
928 | 928 | |
929 | 929 | if ($callback && is_callable($callback)) { |
930 | - add_action( $section_slug, $callback, 10, 4); |
|
930 | + add_action($section_slug, $callback, 10, 4); |
|
931 | 931 | } else { |
932 | 932 | if (function_exists($slug)) { |
933 | - add_action( $section_slug, $slug, 10, 4); |
|
933 | + add_action($section_slug, $slug, 10, 4); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | } |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | * filter to allow import images for free edition of WP All Import |
940 | 940 | * |
941 | 941 | */ |
942 | - function is_allow_import_images($is_allow, $post_type){ |
|
942 | + function is_allow_import_images($is_allow, $post_type) { |
|
943 | 943 | return ($this->is_active_addon($post_type)) ? true : $is_allow; |
944 | 944 | } |
945 | 945 | |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | * filter to control additional images sections |
949 | 949 | * |
950 | 950 | */ |
951 | - function additional_sections($sections){ |
|
952 | - if ( ! empty($this->image_sections) ){ |
|
951 | + function additional_sections($sections) { |
|
952 | + if (!empty($this->image_sections)) { |
|
953 | 953 | foreach ($this->image_sections as $add_section) { |
954 | 954 | $sections[] = $add_section; |
955 | 955 | } |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * remove the 'Don't touch existing images, append new images' when more than one image section is in use. |
963 | 963 | * |
964 | 964 | */ |
965 | - function filter_is_show_add_new_images($is_show, $post_type){ |
|
965 | + function filter_is_show_add_new_images($is_show, $post_type) { |
|
966 | 966 | return ($this->is_active_addon($post_type)) ? false : $is_show; |
967 | 967 | } |
968 | 968 | |
@@ -971,12 +971,12 @@ discard block |
||
971 | 971 | * disable the default images section |
972 | 972 | * |
973 | 973 | */ |
974 | - function disable_default_images($post_type = false){ |
|
974 | + function disable_default_images($post_type = false) { |
|
975 | 975 | |
976 | 976 | add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2); |
977 | 977 | |
978 | 978 | } |
979 | - function is_enable_default_images_section($is_enabled, $post_type){ |
|
979 | + function is_enable_default_images_section($is_enabled, $post_type) { |
|
980 | 980 | |
981 | 981 | return ($this->is_active_addon($post_type)) ? false : true; |
982 | 982 | |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | |
989 | 989 | $data = array(); // parsed data |
990 | 990 | |
991 | - if ( ! empty($import->options[$this->slug])){ |
|
991 | + if (!empty($import->options[$this->slug])) { |
|
992 | 992 | |
993 | 993 | $this->logger = $parsingData['logger']; |
994 | 994 | |
@@ -997,9 +997,9 @@ discard block |
||
997 | 997 | $tmp_files = array(); |
998 | 998 | |
999 | 999 | foreach ($options[$this->slug] as $option_name => $option_value) { |
1000 | - if ( isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') { |
|
1000 | + if (isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') { |
|
1001 | 1001 | if ($import->options[$this->slug][$option_name] == "xpath") { |
1002 | - if ($import->options[$this->slug]['xpaths'][$option_name] == ""){ |
|
1002 | + if ($import->options[$this->slug]['xpaths'][$option_name] == "") { |
|
1003 | 1003 | $count and $data[$option_name] = array_fill(0, $count, ""); |
1004 | 1004 | } else { |
1005 | 1005 | $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse(); |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | if ($import_options['update_all_data'] == 'yes') return true; |
1040 | 1040 | |
1041 | - if ( ! $import_options['is_update_custom_fields'] ) return false; |
|
1041 | + if (!$import_options['is_update_custom_fields']) return false; |
|
1042 | 1042 | |
1043 | 1043 | if ($import_options['update_custom_fields_logic'] == "full_update") return true; |
1044 | - if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']) ) return true; |
|
1045 | - if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) )) return true; |
|
1044 | + if ($import_options['update_custom_fields_logic'] == "only" and !empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list'])) return true; |
|
1045 | + if ($import_options['update_custom_fields_logic'] == "all_except" and (empty($import_options['custom_fields_list']) or !in_array($meta_key, $import_options['custom_fields_list']))) return true; |
|
1046 | 1046 | |
1047 | 1047 | return false; |
1048 | 1048 | |
@@ -1058,11 +1058,11 @@ discard block |
||
1058 | 1058 | |
1059 | 1059 | if ($import_options['update_all_data'] == 'yes') return true; |
1060 | 1060 | |
1061 | - if ( ! $import_options['is_update_categories'] ) return false; |
|
1061 | + if (!$import_options['is_update_categories']) return false; |
|
1062 | 1062 | |
1063 | 1063 | if ($import_options['update_categories_logic'] == "full_update") return true; |
1064 | - if ($import_options['update_categories_logic'] == "only" and ! empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list']) ) return true; |
|
1065 | - if ($import_options['update_categories_logic'] == "all_except" and ( empty($import_options['taxonomies_list']) or ! in_array($tax_name, $import_options['taxonomies_list']) )) return true; |
|
1064 | + if ($import_options['update_categories_logic'] == "only" and !empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list'])) return true; |
|
1065 | + if ($import_options['update_categories_logic'] == "all_except" and (empty($import_options['taxonomies_list']) or !in_array($tax_name, $import_options['taxonomies_list']))) return true; |
|
1066 | 1066 | |
1067 | 1067 | return false; |
1068 | 1068 | |
@@ -1083,8 +1083,8 @@ discard block |
||
1083 | 1083 | |
1084 | 1084 | |
1085 | 1085 | function admin_notice_ignore() { |
1086 | - if (isset($_GET[$this->slug.'_ignore']) && '0' == $_GET[$this->slug.'_ignore'] ) { |
|
1087 | - update_option($this->slug.'_ignore', 'true'); |
|
1086 | + if (isset($_GET[$this->slug . '_ignore']) && '0' == $_GET[$this->slug . '_ignore']) { |
|
1087 | + update_option($this->slug . '_ignore', 'true'); |
|
1088 | 1088 | } |
1089 | 1089 | } |
1090 | 1090 | |
@@ -1094,10 +1094,10 @@ discard block |
||
1094 | 1094 | if ($this->notice_text) { |
1095 | 1095 | $notice_text = $this->notice_text; |
1096 | 1096 | } else { |
1097 | - $notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.'; |
|
1097 | + $notice_text = $this->name . ' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.'; |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | - if (!get_option(sanitize_key($this->slug).'_notice_ignore')) { |
|
1100 | + if (!get_option(sanitize_key($this->slug) . '_notice_ignore')) { |
|
1101 | 1101 | |
1102 | 1102 | ?> |
1103 | 1103 | |
@@ -1105,9 +1105,9 @@ discard block |
||
1105 | 1105 | <p><?php echo wp_kses_post(__( |
1106 | 1106 | sprintf( |
1107 | 1107 | $notice_text, |
1108 | - '?'.$this->slug.'_ignore=0' |
|
1108 | + '?' . $this->slug . '_ignore=0' |
|
1109 | 1109 | ), |
1110 | - 'rapid_addon_'.$this->slug |
|
1110 | + 'rapid_addon_' . $this->slug |
|
1111 | 1111 | )); ?></p> |
1112 | 1112 | </div> |
1113 | 1113 | |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | $is_show_notice = false; |
1128 | 1128 | |
1129 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
1129 | + include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
1130 | 1130 | |
1131 | - if ( ! class_exists( 'PMXI_Plugin' ) ) { |
|
1131 | + if (!class_exists('PMXI_Plugin')) { |
|
1132 | 1132 | $is_show_notice = true; |
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | // Supported Themes |
1136 | - if ( ! $is_show_notice and ! empty($conditions['themes']) ){ |
|
1136 | + if (!$is_show_notice and !empty($conditions['themes'])) { |
|
1137 | 1137 | |
1138 | 1138 | $themeInfo = wp_get_theme(); |
1139 | 1139 | $parentInfo = $themeInfo->parent(); |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | $is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true; |
1143 | 1143 | |
1144 | - if ( $is_show_notice and $parentInfo ){ |
|
1144 | + if ($is_show_notice and $parentInfo) { |
|
1145 | 1145 | $parent_theme = $parentInfo->get('Name'); |
1146 | 1146 | $is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true; |
1147 | 1147 | } |
@@ -1149,22 +1149,22 @@ discard block |
||
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | // Required Plugins |
1152 | - if ( ! $is_show_notice and ! empty($conditions['plugins']) ){ |
|
1152 | + if (!$is_show_notice and !empty($conditions['plugins'])) { |
|
1153 | 1153 | |
1154 | 1154 | $requires_counter = 0; |
1155 | 1155 | foreach ($conditions['plugins'] as $plugin) { |
1156 | - if ( is_plugin_active($plugin) ) $requires_counter++; |
|
1156 | + if (is_plugin_active($plugin)) $requires_counter++; |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | - if ($requires_counter != count($conditions['plugins'])){ |
|
1159 | + if ($requires_counter != count($conditions['plugins'])) { |
|
1160 | 1160 | $is_show_notice = true; |
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | } |
1164 | 1164 | |
1165 | - if ( $is_show_notice ){ |
|
1165 | + if ($is_show_notice) { |
|
1166 | 1166 | |
1167 | - if ( $notice_text != '' ) { |
|
1167 | + if ($notice_text != '') { |
|
1168 | 1168 | $this->notice_text = $notice_text; |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1173,34 +1173,34 @@ discard block |
||
1173 | 1173 | |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - function log( $m = false){ |
|
1176 | + function log($m = false) { |
|
1177 | 1177 | |
1178 | 1178 | $m and $this->logger and call_user_func($this->logger, $m); |
1179 | 1179 | |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - public function remove_post_type( $type = '' ) { |
|
1183 | - if ( ! empty( $type ) ) { |
|
1184 | - $this->add_option( 'post_types_to_remove', $type ); |
|
1182 | + public function remove_post_type($type = '') { |
|
1183 | + if (!empty($type)) { |
|
1184 | + $this->add_option('post_types_to_remove', $type); |
|
1185 | 1185 | } |
1186 | 1186 | } |
1187 | 1187 | |
1188 | - public function filter_post_types( $custom_types = array(), $custom_type = '' ) { |
|
1188 | + public function filter_post_types($custom_types = array(), $custom_type = '') { |
|
1189 | 1189 | $options = $this->options_array(); |
1190 | 1190 | $option_key = 'post_types_to_remove'; |
1191 | 1191 | |
1192 | - if ( array_key_exists( $option_key, $options ) ) { |
|
1193 | - $type = $options[ $option_key ]; |
|
1192 | + if (array_key_exists($option_key, $options)) { |
|
1193 | + $type = $options[$option_key]; |
|
1194 | 1194 | |
1195 | - if ( ! empty( $type ) ) { |
|
1196 | - if ( ! is_array( $type ) ) { |
|
1197 | - if ( array_key_exists( $type, $custom_types ) ) { |
|
1198 | - unset( $custom_types[ $type ] ); |
|
1195 | + if (!empty($type)) { |
|
1196 | + if (!is_array($type)) { |
|
1197 | + if (array_key_exists($type, $custom_types)) { |
|
1198 | + unset($custom_types[$type]); |
|
1199 | 1199 | } |
1200 | 1200 | } else { |
1201 | - foreach ( $type as $key => $post_type ) { |
|
1202 | - if ( array_key_exists( $post_type, $custom_types ) ) { |
|
1203 | - unset( $custom_types[ $post_type ] ); |
|
1201 | + foreach ($type as $key => $post_type) { |
|
1202 | + if (array_key_exists($post_type, $custom_types)) { |
|
1203 | + unset($custom_types[$post_type]); |
|
1204 | 1204 | } |
1205 | 1205 | } |
1206 | 1206 | } |
@@ -1209,26 +1209,26 @@ discard block |
||
1209 | 1209 | return $custom_types; |
1210 | 1210 | } |
1211 | 1211 | |
1212 | - public function sort_post_types( array $order ) { |
|
1212 | + public function sort_post_types(array $order) { |
|
1213 | 1213 | $options = $this->options_array(); |
1214 | 1214 | $option_key = 'post_type_move'; |
1215 | 1215 | |
1216 | - if ( array_key_exists( $option_key, $options ) ) { |
|
1217 | - $move_rules = maybe_unserialize( $options[ $option_key ] ); |
|
1216 | + if (array_key_exists($option_key, $options)) { |
|
1217 | + $move_rules = maybe_unserialize($options[$option_key]); |
|
1218 | 1218 | |
1219 | - foreach ( $move_rules as $rule ) { |
|
1219 | + foreach ($move_rules as $rule) { |
|
1220 | 1220 | $move_this = $rule['move_this']; |
1221 | 1221 | $move_to = $rule['move_to']; |
1222 | - if ( $move_to > count( $order ) ) { |
|
1223 | - if ( ( $rm_key = array_search( $move_this, $order ) ) !== false ) { |
|
1224 | - unset( $order[ $rm_key ] ); |
|
1222 | + if ($move_to > count($order)) { |
|
1223 | + if (($rm_key = array_search($move_this, $order)) !== false) { |
|
1224 | + unset($order[$rm_key]); |
|
1225 | 1225 | } |
1226 | - array_push( $order, $move_this ); |
|
1226 | + array_push($order, $move_this); |
|
1227 | 1227 | } else { |
1228 | - if ( ( $rm_key = array_search( $move_this, $order ) ) !== false ) { |
|
1229 | - unset( $order[ $rm_key ] ); |
|
1228 | + if (($rm_key = array_search($move_this, $order)) !== false) { |
|
1229 | + unset($order[$rm_key]); |
|
1230 | 1230 | } |
1231 | - array_splice( $order, $move_to, 0, $move_this ); |
|
1231 | + array_splice($order, $move_to, 0, $move_this); |
|
1232 | 1232 | } |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1238,57 +1238,57 @@ discard block |
||
1238 | 1238 | return $order; |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - public function move_post_type( $move_this = null, $move_to = null ) { |
|
1241 | + public function move_post_type($move_this = null, $move_to = null) { |
|
1242 | 1242 | $move_rules = array(); |
1243 | 1243 | |
1244 | - if ( ! is_array( $move_this ) && ! is_array( $move_to ) ) { |
|
1244 | + if (!is_array($move_this) && !is_array($move_to)) { |
|
1245 | 1245 | $move_rules[] = array( |
1246 | 1246 | 'move_this' => $move_this, |
1247 | 1247 | 'move_to' => $move_to |
1248 | 1248 | ); |
1249 | 1249 | } else { |
1250 | - foreach ( $move_this as $key => $move_post ) { |
|
1250 | + foreach ($move_this as $key => $move_post) { |
|
1251 | 1251 | $move_rules[] = array( |
1252 | 1252 | 'move_this' => $move_post, |
1253 | - 'move_to' => $move_to[ $key ] |
|
1253 | + 'move_to' => $move_to[$key] |
|
1254 | 1254 | ); |
1255 | 1255 | } |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - $this->add_option( 'post_type_move', $move_rules ); |
|
1258 | + $this->add_option('post_type_move', $move_rules); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | - public function set_post_type_image( $post_type = null, $image = null ) { |
|
1261 | + public function set_post_type_image($post_type = null, $image = null) { |
|
1262 | 1262 | $post_type_image_rules = array(); |
1263 | 1263 | |
1264 | - if ( ! is_array( $post_type ) ) { |
|
1264 | + if (!is_array($post_type)) { |
|
1265 | 1265 | |
1266 | - $post_type_image_rules[ $post_type ] = array( |
|
1266 | + $post_type_image_rules[$post_type] = array( |
|
1267 | 1267 | 'post_type' => $post_type, |
1268 | 1268 | 'image' => $image |
1269 | 1269 | ); |
1270 | 1270 | |
1271 | 1271 | } else { |
1272 | 1272 | |
1273 | - if ( count( $post_type ) == count( $image ) ) { |
|
1273 | + if (count($post_type) == count($image)) { |
|
1274 | 1274 | |
1275 | - foreach ( $post_type as $key => $post_name ) { |
|
1276 | - $post_type_image_rules[ $post_name ] = array( |
|
1275 | + foreach ($post_type as $key => $post_name) { |
|
1276 | + $post_type_image_rules[$post_name] = array( |
|
1277 | 1277 | 'post_type' => $post_name, |
1278 | - 'image' => $image[ $key ] |
|
1278 | + 'image' => $image[$key] |
|
1279 | 1279 | ); |
1280 | 1280 | } |
1281 | 1281 | } |
1282 | 1282 | } |
1283 | 1283 | |
1284 | - $this->add_option( 'post_type_image', $post_type_image_rules ); |
|
1284 | + $this->add_option('post_type_image', $post_type_image_rules); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | - public function post_type_image( $image ) { |
|
1287 | + public function post_type_image($image) { |
|
1288 | 1288 | $options = $this->options_array(); |
1289 | 1289 | $option_key = 'post_type_image'; |
1290 | - if ( array_key_exists( $option_key, $options ) ) { |
|
1291 | - $post_type_image_rules = maybe_unserialize( $options[ $option_key ] ); |
|
1290 | + if (array_key_exists($option_key, $options)) { |
|
1291 | + $post_type_image_rules = maybe_unserialize($options[$option_key]); |
|
1292 | 1292 | return $post_type_image_rules; |
1293 | 1293 | } |
1294 | 1294 | return $image; |