@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Invoice class. |
@@ -143,40 +143,40 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
145 | 145 | */ |
146 | - public function __construct( $invoice = 0 ) { |
|
146 | + public function __construct($invoice = 0) { |
|
147 | 147 | |
148 | - parent::__construct( $invoice ); |
|
148 | + parent::__construct($invoice); |
|
149 | 149 | |
150 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
151 | - $this->set_id( (int) $invoice ); |
|
152 | - } elseif ( $invoice instanceof self ) { |
|
153 | - $this->set_id( $invoice->get_id() ); |
|
154 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
155 | - $this->set_id( $invoice->ID ); |
|
156 | - } elseif ( is_array( $invoice ) ) { |
|
157 | - $this->set_props( $invoice ); |
|
150 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
151 | + $this->set_id((int) $invoice); |
|
152 | + } elseif ($invoice instanceof self) { |
|
153 | + $this->set_id($invoice->get_id()); |
|
154 | + } elseif (!empty($invoice->ID)) { |
|
155 | + $this->set_id($invoice->ID); |
|
156 | + } elseif (is_array($invoice)) { |
|
157 | + $this->set_props($invoice); |
|
158 | 158 | |
159 | - if ( isset( $invoice['ID'] ) ) { |
|
160 | - $this->set_id( $invoice['ID'] ); |
|
159 | + if (isset($invoice['ID'])) { |
|
160 | + $this->set_id($invoice['ID']); |
|
161 | 161 | } |
162 | 162 | |
163 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
164 | - $this->set_id( $invoice_id ); |
|
165 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
166 | - $this->set_id( $invoice_id ); |
|
167 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
168 | - $this->set_id( $invoice_id ); |
|
163 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
164 | + $this->set_id($invoice_id); |
|
165 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
166 | + $this->set_id($invoice_id); |
|
167 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
168 | + $this->set_id($invoice_id); |
|
169 | 169 | } else { |
170 | - $this->set_object_read( true ); |
|
170 | + $this->set_object_read(true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // Load the datastore. |
174 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
174 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
175 | 175 | |
176 | - if ( $this->get_id() > 0 ) { |
|
177 | - $this->post = get_post( $this->get_id() ); |
|
176 | + if ($this->get_id() > 0) { |
|
177 | + $this->post = get_post($this->get_id()); |
|
178 | 178 | $this->ID = $this->get_id(); |
179 | - $this->data_store->read( $this ); |
|
179 | + $this->data_store->read($this); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | } |
@@ -191,38 +191,38 @@ discard block |
||
191 | 191 | * @since 1.0.15 |
192 | 192 | * @return int |
193 | 193 | */ |
194 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
194 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
195 | 195 | global $wpdb; |
196 | 196 | |
197 | 197 | // Trim the value. |
198 | - $value = trim( $value ); |
|
198 | + $value = trim($value); |
|
199 | 199 | |
200 | - if ( empty( $value ) ) { |
|
200 | + if (empty($value)) { |
|
201 | 201 | return 0; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // Valid fields. |
205 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
205 | + $fields = array('key', 'number', 'transaction_id'); |
|
206 | 206 | |
207 | 207 | // Ensure a field has been passed. |
208 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
208 | + if (empty($field) || !in_array($field, $fields)) { |
|
209 | 209 | return 0; |
210 | 210 | } |
211 | 211 | |
212 | 212 | // Maybe retrieve from the cache. |
213 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
214 | - if ( false !== $invoice_id ) { |
|
213 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
214 | + if (false !== $invoice_id) { |
|
215 | 215 | return $invoice_id; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Fetch from the db. |
219 | 219 | $table = $wpdb->prefix . 'getpaid_invoices'; |
220 | 220 | $invoice_id = (int) $wpdb->get_var( |
221 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
221 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
222 | 222 | ); |
223 | 223 | |
224 | 224 | // Update the cache with our data |
225 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
225 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
226 | 226 | |
227 | 227 | return $invoice_id; |
228 | 228 | } |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | /** |
231 | 231 | * Checks if an invoice key is set. |
232 | 232 | */ |
233 | - public function _isset( $key ) { |
|
234 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
233 | + public function _isset($key) { |
|
234 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /* |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | * @param string $context View or edit context. |
257 | 257 | * @return int |
258 | 258 | */ |
259 | - public function get_parent_id( $context = 'view' ) { |
|
260 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
259 | + public function get_parent_id($context = 'view') { |
|
260 | + return (int) $this->get_prop('parent_id', $context); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return WPInv_Invoice |
268 | 268 | */ |
269 | 269 | public function get_parent_payment() { |
270 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
270 | + return new WPInv_Invoice($this->get_parent_id()); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | * @param string $context View or edit context. |
288 | 288 | * @return string |
289 | 289 | */ |
290 | - public function get_status( $context = 'view' ) { |
|
291 | - return $this->get_prop( 'status', $context ); |
|
290 | + public function get_status($context = 'view') { |
|
291 | + return $this->get_prop('status', $context); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return array |
299 | 299 | */ |
300 | 300 | public function get_all_statuses() { |
301 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
301 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | public function get_status_nicename() { |
311 | 311 | $statuses = $this->get_all_statuses(); |
312 | 312 | |
313 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
313 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
314 | 314 | |
315 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
315 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public function get_status_class() { |
325 | 325 | $statuses = getpaid_get_invoice_status_classes(); |
326 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
326 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public function get_status_label_html() { |
336 | 336 | |
337 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
338 | - $status = sanitize_html_class( $this->get_status() ); |
|
339 | - $class = esc_attr( $this->get_status_class() ); |
|
337 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
338 | + $status = sanitize_html_class($this->get_status()); |
|
339 | + $class = esc_attr($this->get_status_class()); |
|
340 | 340 | |
341 | 341 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
342 | 342 | } |
@@ -348,23 +348,23 @@ discard block |
||
348 | 348 | * @param string $context View or edit context. |
349 | 349 | * @return string |
350 | 350 | */ |
351 | - public function get_version( $context = 'view' ) { |
|
352 | - return $this->get_prop( 'version', $context ); |
|
351 | + public function get_version($context = 'view') { |
|
352 | + return $this->get_prop('version', $context); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
356 | 356 | * @deprecated |
357 | 357 | */ |
358 | - public function get_invoice_date( $format = true ) { |
|
359 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
360 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
361 | - $formatted = getpaid_format_date( $date ); |
|
358 | + public function get_invoice_date($format = true) { |
|
359 | + $date = getpaid_format_date($this->get_date_completed()); |
|
360 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
361 | + $formatted = getpaid_format_date($date); |
|
362 | 362 | |
363 | - if ( $format ) { |
|
363 | + if ($format) { |
|
364 | 364 | return $formatted; |
365 | 365 | } |
366 | 366 | |
367 | - return empty( $formatted ) ? '' : $date; |
|
367 | + return empty($formatted) ? '' : $date; |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | * @param string $context View or edit context. |
376 | 376 | * @return string |
377 | 377 | */ |
378 | - public function get_date_created( $context = 'view' ) { |
|
379 | - return $this->get_prop( 'date_created', $context ); |
|
378 | + public function get_date_created($context = 'view') { |
|
379 | + return $this->get_prop('date_created', $context); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | * @param string $context View or edit context. |
387 | 387 | * @return string |
388 | 388 | */ |
389 | - public function get_created_date( $context = 'view' ) { |
|
390 | - return $this->get_date_created( $context ); |
|
389 | + public function get_created_date($context = 'view') { |
|
390 | + return $this->get_date_created($context); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @param string $context View or edit context. |
398 | 398 | * @return string |
399 | 399 | */ |
400 | - public function get_date_created_gmt( $context = 'view' ) { |
|
401 | - $date = $this->get_date_created( $context ); |
|
400 | + public function get_date_created_gmt($context = 'view') { |
|
401 | + $date = $this->get_date_created($context); |
|
402 | 402 | |
403 | - if ( $date ) { |
|
404 | - $date = get_gmt_from_date( $date ); |
|
403 | + if ($date) { |
|
404 | + $date = get_gmt_from_date($date); |
|
405 | 405 | } |
406 | 406 | return $date; |
407 | 407 | } |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * @param string $context View or edit context. |
414 | 414 | * @return string |
415 | 415 | */ |
416 | - public function get_date_modified( $context = 'view' ) { |
|
417 | - return $this->get_prop( 'date_modified', $context ); |
|
416 | + public function get_date_modified($context = 'view') { |
|
417 | + return $this->get_prop('date_modified', $context); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | * @param string $context View or edit context. |
425 | 425 | * @return string |
426 | 426 | */ |
427 | - public function get_modified_date( $context = 'view' ) { |
|
428 | - return $this->get_date_modified( $context ); |
|
427 | + public function get_modified_date($context = 'view') { |
|
428 | + return $this->get_date_modified($context); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -435,11 +435,11 @@ discard block |
||
435 | 435 | * @param string $context View or edit context. |
436 | 436 | * @return string |
437 | 437 | */ |
438 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
439 | - $date = $this->get_date_modified( $context ); |
|
438 | + public function get_date_modified_gmt($context = 'view') { |
|
439 | + $date = $this->get_date_modified($context); |
|
440 | 440 | |
441 | - if ( $date ) { |
|
442 | - $date = get_gmt_from_date( $date ); |
|
441 | + if ($date) { |
|
442 | + $date = get_gmt_from_date($date); |
|
443 | 443 | } |
444 | 444 | return $date; |
445 | 445 | } |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * @param string $context View or edit context. |
452 | 452 | * @return string |
453 | 453 | */ |
454 | - public function get_due_date( $context = 'view' ) { |
|
455 | - return $this->get_prop( 'due_date', $context ); |
|
454 | + public function get_due_date($context = 'view') { |
|
455 | + return $this->get_prop('due_date', $context); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | * @param string $context View or edit context. |
463 | 463 | * @return string |
464 | 464 | */ |
465 | - public function get_date_due( $context = 'view' ) { |
|
466 | - return $this->get_due_date( $context ); |
|
465 | + public function get_date_due($context = 'view') { |
|
466 | + return $this->get_due_date($context); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | * @param string $context View or edit context. |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function get_due_date_gmt( $context = 'view' ) { |
|
477 | - $date = $this->get_due_date( $context ); |
|
476 | + public function get_due_date_gmt($context = 'view') { |
|
477 | + $date = $this->get_due_date($context); |
|
478 | 478 | |
479 | - if ( $date ) { |
|
480 | - $date = get_gmt_from_date( $date ); |
|
479 | + if ($date) { |
|
480 | + $date = get_gmt_from_date($date); |
|
481 | 481 | } |
482 | 482 | return $date; |
483 | 483 | } |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | * @param string $context View or edit context. |
490 | 490 | * @return string |
491 | 491 | */ |
492 | - public function get_gmt_date_due( $context = 'view' ) { |
|
493 | - return $this->get_due_date_gmt( $context ); |
|
492 | + public function get_gmt_date_due($context = 'view') { |
|
493 | + return $this->get_due_date_gmt($context); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @param string $context View or edit context. |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public function get_completed_date( $context = 'view' ) { |
|
504 | - return $this->get_prop( 'completed_date', $context ); |
|
503 | + public function get_completed_date($context = 'view') { |
|
504 | + return $this->get_prop('completed_date', $context); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | * @param string $context View or edit context. |
512 | 512 | * @return string |
513 | 513 | */ |
514 | - public function get_date_completed( $context = 'view' ) { |
|
515 | - return $this->get_completed_date( $context ); |
|
514 | + public function get_date_completed($context = 'view') { |
|
515 | + return $this->get_completed_date($context); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -522,11 +522,11 @@ discard block |
||
522 | 522 | * @param string $context View or edit context. |
523 | 523 | * @return string |
524 | 524 | */ |
525 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
526 | - $date = $this->get_completed_date( $context ); |
|
525 | + public function get_completed_date_gmt($context = 'view') { |
|
526 | + $date = $this->get_completed_date($context); |
|
527 | 527 | |
528 | - if ( $date ) { |
|
529 | - $date = get_gmt_from_date( $date ); |
|
528 | + if ($date) { |
|
529 | + $date = get_gmt_from_date($date); |
|
530 | 530 | } |
531 | 531 | return $date; |
532 | 532 | } |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | * @param string $context View or edit context. |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
542 | - return $this->get_completed_date_gmt( $context ); |
|
541 | + public function get_gmt_completed_date($context = 'view') { |
|
542 | + return $this->get_completed_date_gmt($context); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -549,12 +549,12 @@ discard block |
||
549 | 549 | * @param string $context View or edit context. |
550 | 550 | * @return string |
551 | 551 | */ |
552 | - public function get_number( $context = 'view' ) { |
|
553 | - $number = $this->get_prop( 'number', $context ); |
|
552 | + public function get_number($context = 'view') { |
|
553 | + $number = $this->get_prop('number', $context); |
|
554 | 554 | |
555 | - if ( empty( $number ) ) { |
|
555 | + if (empty($number)) { |
|
556 | 556 | $number = $this->generate_number(); |
557 | - $this->set_number( $this->generate_number() ); |
|
557 | + $this->set_number($this->generate_number()); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | return $number; |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | public function maybe_set_number() { |
569 | 569 | $number = $this->get_number(); |
570 | 570 | |
571 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
572 | - $this->set_number( $this->generate_number() ); |
|
571 | + if (empty($number) || $this->get_id() == $number) { |
|
572 | + $this->set_number($this->generate_number()); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | } |
@@ -581,8 +581,8 @@ discard block |
||
581 | 581 | * @param string $context View or edit context. |
582 | 582 | * @return string |
583 | 583 | */ |
584 | - public function get_key( $context = 'view' ) { |
|
585 | - return $this->get_prop( 'key', $context ); |
|
584 | + public function get_key($context = 'view') { |
|
585 | + return $this->get_prop('key', $context); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -593,9 +593,9 @@ discard block |
||
593 | 593 | public function maybe_set_key() { |
594 | 594 | $key = $this->get_key(); |
595 | 595 | |
596 | - if ( empty( $key ) ) { |
|
597 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
598 | - $this->set_key( $key ); |
|
596 | + if (empty($key)) { |
|
597 | + $key = $this->generate_key($this->get_type() . '_'); |
|
598 | + $this->set_key($key); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | } |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | * @param string $context View or edit context. |
608 | 608 | * @return string |
609 | 609 | */ |
610 | - public function get_type( $context = 'view' ) { |
|
611 | - return $this->get_prop( 'type', $context ); |
|
610 | + public function get_type($context = 'view') { |
|
611 | + return $this->get_prop('type', $context); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * @return string |
619 | 619 | */ |
620 | 620 | public function get_invoice_quote_type() { |
621 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
621 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -628,8 +628,8 @@ discard block |
||
628 | 628 | * @param string $context View or edit context. |
629 | 629 | * @return string |
630 | 630 | */ |
631 | - public function get_label( $context = 'view' ) { |
|
632 | - return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
|
631 | + public function get_label($context = 'view') { |
|
632 | + return getpaid_get_post_type_label($this->get_post_type($context), false); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -639,8 +639,8 @@ discard block |
||
639 | 639 | * @param string $context View or edit context. |
640 | 640 | * @return string |
641 | 641 | */ |
642 | - public function get_post_type( $context = 'view' ) { |
|
643 | - return $this->get_prop( 'post_type', $context ); |
|
642 | + public function get_post_type($context = 'view') { |
|
643 | + return $this->get_prop('post_type', $context); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | * @param string $context View or edit context. |
651 | 651 | * @return string |
652 | 652 | */ |
653 | - public function get_mode( $context = 'view' ) { |
|
654 | - return $this->get_prop( 'mode', $context ); |
|
653 | + public function get_mode($context = 'view') { |
|
654 | + return $this->get_prop('mode', $context); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | /** |
@@ -661,13 +661,13 @@ discard block |
||
661 | 661 | * @param string $context View or edit context. |
662 | 662 | * @return string |
663 | 663 | */ |
664 | - public function get_path( $context = 'view' ) { |
|
665 | - $path = $this->get_prop( 'path', $context ); |
|
664 | + public function get_path($context = 'view') { |
|
665 | + $path = $this->get_prop('path', $context); |
|
666 | 666 | $prefix = $this->get_type(); |
667 | 667 | |
668 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
669 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
670 | - $this->set_path( $path ); |
|
668 | + if (0 !== strpos($path, $prefix)) { |
|
669 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
670 | + $this->set_path($path); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | return $path; |
@@ -680,8 +680,8 @@ discard block |
||
680 | 680 | * @param string $context View or edit context. |
681 | 681 | * @return string |
682 | 682 | */ |
683 | - public function get_name( $context = 'view' ) { |
|
684 | - return $this->get_prop( 'title', $context ); |
|
683 | + public function get_name($context = 'view') { |
|
684 | + return $this->get_prop('title', $context); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /** |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | * @param string $context View or edit context. |
692 | 692 | * @return string |
693 | 693 | */ |
694 | - public function get_title( $context = 'view' ) { |
|
695 | - return $this->get_name( $context ); |
|
694 | + public function get_title($context = 'view') { |
|
695 | + return $this->get_name($context); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | * @param string $context View or edit context. |
703 | 703 | * @return string |
704 | 704 | */ |
705 | - public function get_description( $context = 'view' ) { |
|
706 | - return $this->get_prop( 'description', $context ); |
|
705 | + public function get_description($context = 'view') { |
|
706 | + return $this->get_prop('description', $context); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | * @param string $context View or edit context. |
714 | 714 | * @return string |
715 | 715 | */ |
716 | - public function get_excerpt( $context = 'view' ) { |
|
717 | - return $this->get_description( $context ); |
|
716 | + public function get_excerpt($context = 'view') { |
|
717 | + return $this->get_description($context); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -724,8 +724,8 @@ discard block |
||
724 | 724 | * @param string $context View or edit context. |
725 | 725 | * @return string |
726 | 726 | */ |
727 | - public function get_summary( $context = 'view' ) { |
|
728 | - return $this->get_description( $context ); |
|
727 | + public function get_summary($context = 'view') { |
|
728 | + return $this->get_description($context); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
@@ -735,25 +735,25 @@ discard block |
||
735 | 735 | * @param string $context View or edit context. |
736 | 736 | * @return array |
737 | 737 | */ |
738 | - public function get_user_info( $context = 'view' ) { |
|
738 | + public function get_user_info($context = 'view') { |
|
739 | 739 | |
740 | 740 | $user_info = array( |
741 | - 'user_id' => $this->get_user_id( $context ), |
|
742 | - 'email' => $this->get_email( $context ), |
|
743 | - 'first_name' => $this->get_first_name( $context ), |
|
744 | - 'last_name' => $this->get_last_name( $context ), |
|
745 | - 'address' => $this->get_address( $context ), |
|
746 | - 'phone' => $this->get_phone( $context ), |
|
747 | - 'city' => $this->get_city( $context ), |
|
748 | - 'country' => $this->get_country( $context ), |
|
749 | - 'state' => $this->get_state( $context ), |
|
750 | - 'zip' => $this->get_zip( $context ), |
|
751 | - 'company' => $this->get_company( $context ), |
|
752 | - 'vat_number' => $this->get_vat_number( $context ), |
|
753 | - 'discount' => $this->get_discount_code( $context ), |
|
741 | + 'user_id' => $this->get_user_id($context), |
|
742 | + 'email' => $this->get_email($context), |
|
743 | + 'first_name' => $this->get_first_name($context), |
|
744 | + 'last_name' => $this->get_last_name($context), |
|
745 | + 'address' => $this->get_address($context), |
|
746 | + 'phone' => $this->get_phone($context), |
|
747 | + 'city' => $this->get_city($context), |
|
748 | + 'country' => $this->get_country($context), |
|
749 | + 'state' => $this->get_state($context), |
|
750 | + 'zip' => $this->get_zip($context), |
|
751 | + 'company' => $this->get_company($context), |
|
752 | + 'vat_number' => $this->get_vat_number($context), |
|
753 | + 'discount' => $this->get_discount_code($context), |
|
754 | 754 | ); |
755 | 755 | |
756 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
756 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
757 | 757 | |
758 | 758 | } |
759 | 759 | |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | * @param string $context View or edit context. |
765 | 765 | * @return int |
766 | 766 | */ |
767 | - public function get_author( $context = 'view' ) { |
|
768 | - return (int) $this->get_prop( 'author', $context ); |
|
767 | + public function get_author($context = 'view') { |
|
768 | + return (int) $this->get_prop('author', $context); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -775,8 +775,8 @@ discard block |
||
775 | 775 | * @param string $context View or edit context. |
776 | 776 | * @return int |
777 | 777 | */ |
778 | - public function get_user_id( $context = 'view' ) { |
|
779 | - return $this->get_author( $context ); |
|
778 | + public function get_user_id($context = 'view') { |
|
779 | + return $this->get_author($context); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @param string $context View or edit context. |
787 | 787 | * @return int |
788 | 788 | */ |
789 | - public function get_customer_id( $context = 'view' ) { |
|
790 | - return $this->get_author( $context ); |
|
789 | + public function get_customer_id($context = 'view') { |
|
790 | + return $this->get_author($context); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | /** |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | * @param string $context View or edit context. |
798 | 798 | * @return string |
799 | 799 | */ |
800 | - public function get_ip( $context = 'view' ) { |
|
801 | - return $this->get_prop( 'user_ip', $context ); |
|
800 | + public function get_ip($context = 'view') { |
|
801 | + return $this->get_prop('user_ip', $context); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | /** |
@@ -808,8 +808,8 @@ discard block |
||
808 | 808 | * @param string $context View or edit context. |
809 | 809 | * @return string |
810 | 810 | */ |
811 | - public function get_user_ip( $context = 'view' ) { |
|
812 | - return $this->get_ip( $context ); |
|
811 | + public function get_user_ip($context = 'view') { |
|
812 | + return $this->get_ip($context); |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
@@ -819,8 +819,8 @@ discard block |
||
819 | 819 | * @param string $context View or edit context. |
820 | 820 | * @return string |
821 | 821 | */ |
822 | - public function get_customer_ip( $context = 'view' ) { |
|
823 | - return $this->get_ip( $context ); |
|
822 | + public function get_customer_ip($context = 'view') { |
|
823 | + return $this->get_ip($context); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
@@ -830,8 +830,8 @@ discard block |
||
830 | 830 | * @param string $context View or edit context. |
831 | 831 | * @return string |
832 | 832 | */ |
833 | - public function get_first_name( $context = 'view' ) { |
|
834 | - return $this->get_prop( 'first_name', $context ); |
|
833 | + public function get_first_name($context = 'view') { |
|
834 | + return $this->get_prop('first_name', $context); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -841,8 +841,8 @@ discard block |
||
841 | 841 | * @param string $context View or edit context. |
842 | 842 | * @return string |
843 | 843 | */ |
844 | - public function get_user_first_name( $context = 'view' ) { |
|
845 | - return $this->get_first_name( $context ); |
|
844 | + public function get_user_first_name($context = 'view') { |
|
845 | + return $this->get_first_name($context); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | * @param string $context View or edit context. |
853 | 853 | * @return string |
854 | 854 | */ |
855 | - public function get_customer_first_name( $context = 'view' ) { |
|
856 | - return $this->get_first_name( $context ); |
|
855 | + public function get_customer_first_name($context = 'view') { |
|
856 | + return $this->get_first_name($context); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | * @param string $context View or edit context. |
864 | 864 | * @return string |
865 | 865 | */ |
866 | - public function get_last_name( $context = 'view' ) { |
|
867 | - return $this->get_prop( 'last_name', $context ); |
|
866 | + public function get_last_name($context = 'view') { |
|
867 | + return $this->get_prop('last_name', $context); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -874,8 +874,8 @@ discard block |
||
874 | 874 | * @param string $context View or edit context. |
875 | 875 | * @return string |
876 | 876 | */ |
877 | - public function get_user_last_name( $context = 'view' ) { |
|
878 | - return $this->get_last_name( $context ); |
|
877 | + public function get_user_last_name($context = 'view') { |
|
878 | + return $this->get_last_name($context); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
@@ -885,8 +885,8 @@ discard block |
||
885 | 885 | * @param string $context View or edit context. |
886 | 886 | * @return string |
887 | 887 | */ |
888 | - public function get_customer_last_name( $context = 'view' ) { |
|
889 | - return $this->get_last_name( $context ); |
|
888 | + public function get_customer_last_name($context = 'view') { |
|
889 | + return $this->get_last_name($context); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | /** |
@@ -896,8 +896,8 @@ discard block |
||
896 | 896 | * @param string $context View or edit context. |
897 | 897 | * @return string |
898 | 898 | */ |
899 | - public function get_full_name( $context = 'view' ) { |
|
900 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
899 | + public function get_full_name($context = 'view') { |
|
900 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | /** |
@@ -907,8 +907,8 @@ discard block |
||
907 | 907 | * @param string $context View or edit context. |
908 | 908 | * @return string |
909 | 909 | */ |
910 | - public function get_user_full_name( $context = 'view' ) { |
|
911 | - return $this->get_full_name( $context ); |
|
910 | + public function get_user_full_name($context = 'view') { |
|
911 | + return $this->get_full_name($context); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | /** |
@@ -918,8 +918,8 @@ discard block |
||
918 | 918 | * @param string $context View or edit context. |
919 | 919 | * @return string |
920 | 920 | */ |
921 | - public function get_customer_full_name( $context = 'view' ) { |
|
922 | - return $this->get_full_name( $context ); |
|
921 | + public function get_customer_full_name($context = 'view') { |
|
922 | + return $this->get_full_name($context); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | /** |
@@ -929,8 +929,8 @@ discard block |
||
929 | 929 | * @param string $context View or edit context. |
930 | 930 | * @return string |
931 | 931 | */ |
932 | - public function get_phone( $context = 'view' ) { |
|
933 | - return $this->get_prop( 'phone', $context ); |
|
932 | + public function get_phone($context = 'view') { |
|
933 | + return $this->get_prop('phone', $context); |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -940,8 +940,8 @@ discard block |
||
940 | 940 | * @param string $context View or edit context. |
941 | 941 | * @return string |
942 | 942 | */ |
943 | - public function get_phone_number( $context = 'view' ) { |
|
944 | - return $this->get_phone( $context ); |
|
943 | + public function get_phone_number($context = 'view') { |
|
944 | + return $this->get_phone($context); |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | /** |
@@ -951,8 +951,8 @@ discard block |
||
951 | 951 | * @param string $context View or edit context. |
952 | 952 | * @return string |
953 | 953 | */ |
954 | - public function get_user_phone( $context = 'view' ) { |
|
955 | - return $this->get_phone( $context ); |
|
954 | + public function get_user_phone($context = 'view') { |
|
955 | + return $this->get_phone($context); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | /** |
@@ -962,8 +962,8 @@ discard block |
||
962 | 962 | * @param string $context View or edit context. |
963 | 963 | * @return string |
964 | 964 | */ |
965 | - public function get_customer_phone( $context = 'view' ) { |
|
966 | - return $this->get_phone( $context ); |
|
965 | + public function get_customer_phone($context = 'view') { |
|
966 | + return $this->get_phone($context); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
@@ -973,8 +973,8 @@ discard block |
||
973 | 973 | * @param string $context View or edit context. |
974 | 974 | * @return string |
975 | 975 | */ |
976 | - public function get_email( $context = 'view' ) { |
|
977 | - return $this->get_prop( 'email', $context ); |
|
976 | + public function get_email($context = 'view') { |
|
977 | + return $this->get_prop('email', $context); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | /** |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | * @param string $context View or edit context. |
985 | 985 | * @return string |
986 | 986 | */ |
987 | - public function get_email_address( $context = 'view' ) { |
|
988 | - return $this->get_email( $context ); |
|
987 | + public function get_email_address($context = 'view') { |
|
988 | + return $this->get_email($context); |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | * @param string $context View or edit context. |
996 | 996 | * @return string |
997 | 997 | */ |
998 | - public function get_user_email( $context = 'view' ) { |
|
999 | - return $this->get_email( $context ); |
|
998 | + public function get_user_email($context = 'view') { |
|
999 | + return $this->get_email($context); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | /** |
@@ -1006,8 +1006,8 @@ discard block |
||
1006 | 1006 | * @param string $context View or edit context. |
1007 | 1007 | * @return string |
1008 | 1008 | */ |
1009 | - public function get_customer_email( $context = 'view' ) { |
|
1010 | - return $this->get_email( $context ); |
|
1009 | + public function get_customer_email($context = 'view') { |
|
1010 | + return $this->get_email($context); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | /** |
@@ -1017,9 +1017,9 @@ discard block |
||
1017 | 1017 | * @param string $context View or edit context. |
1018 | 1018 | * @return string |
1019 | 1019 | */ |
1020 | - public function get_country( $context = 'view' ) { |
|
1021 | - $country = $this->get_prop( 'country', $context ); |
|
1022 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
1020 | + public function get_country($context = 'view') { |
|
1021 | + $country = $this->get_prop('country', $context); |
|
1022 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @param string $context View or edit context. |
1030 | 1030 | * @return string |
1031 | 1031 | */ |
1032 | - public function get_user_country( $context = 'view' ) { |
|
1033 | - return $this->get_country( $context ); |
|
1032 | + public function get_user_country($context = 'view') { |
|
1033 | + return $this->get_country($context); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | * @param string $context View or edit context. |
1041 | 1041 | * @return string |
1042 | 1042 | */ |
1043 | - public function get_customer_country( $context = 'view' ) { |
|
1044 | - return $this->get_country( $context ); |
|
1043 | + public function get_customer_country($context = 'view') { |
|
1044 | + return $this->get_country($context); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | /** |
@@ -1051,9 +1051,9 @@ discard block |
||
1051 | 1051 | * @param string $context View or edit context. |
1052 | 1052 | * @return string |
1053 | 1053 | */ |
1054 | - public function get_state( $context = 'view' ) { |
|
1055 | - $state = $this->get_prop( 'state', $context ); |
|
1056 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1054 | + public function get_state($context = 'view') { |
|
1055 | + $state = $this->get_prop('state', $context); |
|
1056 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | /** |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | * @param string $context View or edit context. |
1064 | 1064 | * @return string |
1065 | 1065 | */ |
1066 | - public function get_user_state( $context = 'view' ) { |
|
1067 | - return $this->get_state( $context ); |
|
1066 | + public function get_user_state($context = 'view') { |
|
1067 | + return $this->get_state($context); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * @param string $context View or edit context. |
1075 | 1075 | * @return string |
1076 | 1076 | */ |
1077 | - public function get_customer_state( $context = 'view' ) { |
|
1078 | - return $this->get_state( $context ); |
|
1077 | + public function get_customer_state($context = 'view') { |
|
1078 | + return $this->get_state($context); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | /** |
@@ -1085,8 +1085,8 @@ discard block |
||
1085 | 1085 | * @param string $context View or edit context. |
1086 | 1086 | * @return string |
1087 | 1087 | */ |
1088 | - public function get_city( $context = 'view' ) { |
|
1089 | - return $this->get_prop( 'city', $context ); |
|
1088 | + public function get_city($context = 'view') { |
|
1089 | + return $this->get_prop('city', $context); |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | /** |
@@ -1096,8 +1096,8 @@ discard block |
||
1096 | 1096 | * @param string $context View or edit context. |
1097 | 1097 | * @return string |
1098 | 1098 | */ |
1099 | - public function get_user_city( $context = 'view' ) { |
|
1100 | - return $this->get_city( $context ); |
|
1099 | + public function get_user_city($context = 'view') { |
|
1100 | + return $this->get_city($context); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | /** |
@@ -1107,8 +1107,8 @@ discard block |
||
1107 | 1107 | * @param string $context View or edit context. |
1108 | 1108 | * @return string |
1109 | 1109 | */ |
1110 | - public function get_customer_city( $context = 'view' ) { |
|
1111 | - return $this->get_city( $context ); |
|
1110 | + public function get_customer_city($context = 'view') { |
|
1111 | + return $this->get_city($context); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | /** |
@@ -1118,8 +1118,8 @@ discard block |
||
1118 | 1118 | * @param string $context View or edit context. |
1119 | 1119 | * @return string |
1120 | 1120 | */ |
1121 | - public function get_zip( $context = 'view' ) { |
|
1122 | - return $this->get_prop( 'zip', $context ); |
|
1121 | + public function get_zip($context = 'view') { |
|
1122 | + return $this->get_prop('zip', $context); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | /** |
@@ -1129,8 +1129,8 @@ discard block |
||
1129 | 1129 | * @param string $context View or edit context. |
1130 | 1130 | * @return string |
1131 | 1131 | */ |
1132 | - public function get_user_zip( $context = 'view' ) { |
|
1133 | - return $this->get_zip( $context ); |
|
1132 | + public function get_user_zip($context = 'view') { |
|
1133 | + return $this->get_zip($context); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | /** |
@@ -1140,8 +1140,8 @@ discard block |
||
1140 | 1140 | * @param string $context View or edit context. |
1141 | 1141 | * @return string |
1142 | 1142 | */ |
1143 | - public function get_customer_zip( $context = 'view' ) { |
|
1144 | - return $this->get_zip( $context ); |
|
1143 | + public function get_customer_zip($context = 'view') { |
|
1144 | + return $this->get_zip($context); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1151,8 +1151,8 @@ discard block |
||
1151 | 1151 | * @param string $context View or edit context. |
1152 | 1152 | * @return string |
1153 | 1153 | */ |
1154 | - public function get_company( $context = 'view' ) { |
|
1155 | - return $this->get_prop( 'company', $context ); |
|
1154 | + public function get_company($context = 'view') { |
|
1155 | + return $this->get_prop('company', $context); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | /** |
@@ -1162,8 +1162,8 @@ discard block |
||
1162 | 1162 | * @param string $context View or edit context. |
1163 | 1163 | * @return string |
1164 | 1164 | */ |
1165 | - public function get_user_company( $context = 'view' ) { |
|
1166 | - return $this->get_company( $context ); |
|
1165 | + public function get_user_company($context = 'view') { |
|
1166 | + return $this->get_company($context); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | * @param string $context View or edit context. |
1174 | 1174 | * @return string |
1175 | 1175 | */ |
1176 | - public function get_customer_company( $context = 'view' ) { |
|
1177 | - return $this->get_company( $context ); |
|
1176 | + public function get_customer_company($context = 'view') { |
|
1177 | + return $this->get_company($context); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | /** |
@@ -1184,8 +1184,8 @@ discard block |
||
1184 | 1184 | * @param string $context View or edit context. |
1185 | 1185 | * @return string |
1186 | 1186 | */ |
1187 | - public function get_vat_number( $context = 'view' ) { |
|
1188 | - return $this->get_prop( 'vat_number', $context ); |
|
1187 | + public function get_vat_number($context = 'view') { |
|
1188 | + return $this->get_prop('vat_number', $context); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | /** |
@@ -1195,8 +1195,8 @@ discard block |
||
1195 | 1195 | * @param string $context View or edit context. |
1196 | 1196 | * @return string |
1197 | 1197 | */ |
1198 | - public function get_user_vat_number( $context = 'view' ) { |
|
1199 | - return $this->get_vat_number( $context ); |
|
1198 | + public function get_user_vat_number($context = 'view') { |
|
1199 | + return $this->get_vat_number($context); |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | /** |
@@ -1206,8 +1206,8 @@ discard block |
||
1206 | 1206 | * @param string $context View or edit context. |
1207 | 1207 | * @return string |
1208 | 1208 | */ |
1209 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1210 | - return $this->get_vat_number( $context ); |
|
1209 | + public function get_customer_vat_number($context = 'view') { |
|
1210 | + return $this->get_vat_number($context); |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | /** |
@@ -1217,8 +1217,8 @@ discard block |
||
1217 | 1217 | * @param string $context View or edit context. |
1218 | 1218 | * @return string |
1219 | 1219 | */ |
1220 | - public function get_vat_rate( $context = 'view' ) { |
|
1221 | - return $this->get_prop( 'vat_rate', $context ); |
|
1220 | + public function get_vat_rate($context = 'view') { |
|
1221 | + return $this->get_prop('vat_rate', $context); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | /** |
@@ -1228,8 +1228,8 @@ discard block |
||
1228 | 1228 | * @param string $context View or edit context. |
1229 | 1229 | * @return string |
1230 | 1230 | */ |
1231 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1232 | - return $this->get_vat_rate( $context ); |
|
1231 | + public function get_user_vat_rate($context = 'view') { |
|
1232 | + return $this->get_vat_rate($context); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | /** |
@@ -1239,8 +1239,8 @@ discard block |
||
1239 | 1239 | * @param string $context View or edit context. |
1240 | 1240 | * @return string |
1241 | 1241 | */ |
1242 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1243 | - return $this->get_vat_rate( $context ); |
|
1242 | + public function get_customer_vat_rate($context = 'view') { |
|
1243 | + return $this->get_vat_rate($context); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | /** |
@@ -1250,8 +1250,8 @@ discard block |
||
1250 | 1250 | * @param string $context View or edit context. |
1251 | 1251 | * @return string |
1252 | 1252 | */ |
1253 | - public function get_address( $context = 'view' ) { |
|
1254 | - return $this->get_prop( 'address', $context ); |
|
1253 | + public function get_address($context = 'view') { |
|
1254 | + return $this->get_prop('address', $context); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | /** |
@@ -1261,8 +1261,8 @@ discard block |
||
1261 | 1261 | * @param string $context View or edit context. |
1262 | 1262 | * @return string |
1263 | 1263 | */ |
1264 | - public function get_user_address( $context = 'view' ) { |
|
1265 | - return $this->get_address( $context ); |
|
1264 | + public function get_user_address($context = 'view') { |
|
1265 | + return $this->get_address($context); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | /** |
@@ -1272,8 +1272,8 @@ discard block |
||
1272 | 1272 | * @param string $context View or edit context. |
1273 | 1273 | * @return string |
1274 | 1274 | */ |
1275 | - public function get_customer_address( $context = 'view' ) { |
|
1276 | - return $this->get_address( $context ); |
|
1275 | + public function get_customer_address($context = 'view') { |
|
1276 | + return $this->get_address($context); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | /** |
@@ -1283,8 +1283,8 @@ discard block |
||
1283 | 1283 | * @param string $context View or edit context. |
1284 | 1284 | * @return bool |
1285 | 1285 | */ |
1286 | - public function get_is_viewed( $context = 'view' ) { |
|
1287 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1286 | + public function get_is_viewed($context = 'view') { |
|
1287 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | /** |
@@ -1294,8 +1294,8 @@ discard block |
||
1294 | 1294 | * @param string $context View or edit context. |
1295 | 1295 | * @return bool |
1296 | 1296 | */ |
1297 | - public function get_email_cc( $context = 'view' ) { |
|
1298 | - return $this->get_prop( 'email_cc', $context ); |
|
1297 | + public function get_email_cc($context = 'view') { |
|
1298 | + return $this->get_prop('email_cc', $context); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 | /** |
@@ -1305,8 +1305,8 @@ discard block |
||
1305 | 1305 | * @param string $context View or edit context. |
1306 | 1306 | * @return bool |
1307 | 1307 | */ |
1308 | - public function get_template( $context = 'view' ) { |
|
1309 | - return $this->get_prop( 'template', $context ); |
|
1308 | + public function get_template($context = 'view') { |
|
1309 | + return $this->get_prop('template', $context); |
|
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | /** |
@@ -1316,8 +1316,8 @@ discard block |
||
1316 | 1316 | * @param string $context View or edit context. |
1317 | 1317 | * @return bool |
1318 | 1318 | */ |
1319 | - public function get_created_via( $context = 'view' ) { |
|
1320 | - return $this->get_prop( 'created_via', $context ); |
|
1319 | + public function get_created_via($context = 'view') { |
|
1320 | + return $this->get_prop('created_via', $context); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | /** |
@@ -1327,8 +1327,8 @@ discard block |
||
1327 | 1327 | * @param string $context View or edit context. |
1328 | 1328 | * @return bool |
1329 | 1329 | */ |
1330 | - public function get_address_confirmed( $context = 'view' ) { |
|
1331 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1330 | + public function get_address_confirmed($context = 'view') { |
|
1331 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | /** |
@@ -1338,8 +1338,8 @@ discard block |
||
1338 | 1338 | * @param string $context View or edit context. |
1339 | 1339 | * @return bool |
1340 | 1340 | */ |
1341 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1342 | - return $this->get_address_confirmed( $context ); |
|
1341 | + public function get_user_address_confirmed($context = 'view') { |
|
1342 | + return $this->get_address_confirmed($context); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | /** |
@@ -1349,8 +1349,8 @@ discard block |
||
1349 | 1349 | * @param string $context View or edit context. |
1350 | 1350 | * @return bool |
1351 | 1351 | */ |
1352 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1353 | - return $this->get_address_confirmed( $context ); |
|
1352 | + public function get_customer_address_confirmed($context = 'view') { |
|
1353 | + return $this->get_address_confirmed($context); |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | /** |
@@ -1360,12 +1360,12 @@ discard block |
||
1360 | 1360 | * @param string $context View or edit context. |
1361 | 1361 | * @return float |
1362 | 1362 | */ |
1363 | - public function get_subtotal( $context = 'view' ) { |
|
1364 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1363 | + public function get_subtotal($context = 'view') { |
|
1364 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1365 | 1365 | |
1366 | 1366 | // Backwards compatibility. |
1367 | - if ( is_bool( $context ) && $context ) { |
|
1368 | - return wpinv_price( $subtotal, $this->get_currency() ); |
|
1367 | + if (is_bool($context) && $context) { |
|
1368 | + return wpinv_price($subtotal, $this->get_currency()); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | return $subtotal; |
@@ -1378,8 +1378,8 @@ discard block |
||
1378 | 1378 | * @param string $context View or edit context. |
1379 | 1379 | * @return float |
1380 | 1380 | */ |
1381 | - public function get_total_discount( $context = 'view' ) { |
|
1382 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
1381 | + public function get_total_discount($context = 'view') { |
|
1382 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context))); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | /** |
@@ -1389,18 +1389,18 @@ discard block |
||
1389 | 1389 | * @param string $context View or edit context. |
1390 | 1390 | * @return float |
1391 | 1391 | */ |
1392 | - public function get_total_tax( $context = 'view' ) { |
|
1393 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
1392 | + public function get_total_tax($context = 'view') { |
|
1393 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context))); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | /** |
1397 | 1397 | * @deprecated |
1398 | 1398 | */ |
1399 | - public function get_final_tax( $currency = false ) { |
|
1399 | + public function get_final_tax($currency = false) { |
|
1400 | 1400 | $tax = $this->get_total_tax(); |
1401 | 1401 | |
1402 | - if ( $currency ) { |
|
1403 | - return wpinv_price( $tax, $this->get_currency() ); |
|
1402 | + if ($currency) { |
|
1403 | + return wpinv_price($tax, $this->get_currency()); |
|
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | return $tax; |
@@ -1413,8 +1413,8 @@ discard block |
||
1413 | 1413 | * @param string $context View or edit context. |
1414 | 1414 | * @return float |
1415 | 1415 | */ |
1416 | - public function get_total_fees( $context = 'view' ) { |
|
1417 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
1416 | + public function get_total_fees($context = 'view') { |
|
1417 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context))); |
|
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | /** |
@@ -1424,8 +1424,8 @@ discard block |
||
1424 | 1424 | * @param string $context View or edit context. |
1425 | 1425 | * @return float |
1426 | 1426 | */ |
1427 | - public function get_fees_total( $context = 'view' ) { |
|
1428 | - return $this->get_total_fees( $context ); |
|
1427 | + public function get_fees_total($context = 'view') { |
|
1428 | + return $this->get_total_fees($context); |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | 1431 | /** |
@@ -1434,8 +1434,8 @@ discard block |
||
1434 | 1434 | * @since 1.0.19 |
1435 | 1435 | * @return float |
1436 | 1436 | */ |
1437 | - public function get_total( $context = 'view' ) { |
|
1438 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) ); |
|
1437 | + public function get_total($context = 'view') { |
|
1438 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total', $context))); |
|
1439 | 1439 | } |
1440 | 1440 | |
1441 | 1441 | /** |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | */ |
1458 | 1458 | public function get_initial_total() { |
1459 | 1459 | |
1460 | - if ( empty( $this->totals ) ) { |
|
1460 | + if (empty($this->totals)) { |
|
1461 | 1461 | $this->recalculate_total(); |
1462 | 1462 | } |
1463 | 1463 | |
@@ -1467,12 +1467,12 @@ discard block |
||
1467 | 1467 | $subtotal = $this->totals['subtotal']['initial']; |
1468 | 1468 | $total = $tax + $fee - $discount + $subtotal; |
1469 | 1469 | |
1470 | - if ( 0 > $total ) { |
|
1470 | + if (0 > $total) { |
|
1471 | 1471 | $total = 0; |
1472 | 1472 | } |
1473 | 1473 | |
1474 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1475 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1474 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1475 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | 1478 | /** |
@@ -1484,7 +1484,7 @@ discard block |
||
1484 | 1484 | */ |
1485 | 1485 | public function get_recurring_total() { |
1486 | 1486 | |
1487 | - if ( empty( $this->totals ) ) { |
|
1487 | + if (empty($this->totals)) { |
|
1488 | 1488 | $this->recalculate_total(); |
1489 | 1489 | } |
1490 | 1490 | |
@@ -1494,12 +1494,12 @@ discard block |
||
1494 | 1494 | $subtotal = $this->totals['subtotal']['recurring']; |
1495 | 1495 | $total = $tax + $fee - $discount + $subtotal; |
1496 | 1496 | |
1497 | - if ( 0 > $total ) { |
|
1497 | + if (0 > $total) { |
|
1498 | 1498 | $total = 0; |
1499 | 1499 | } |
1500 | 1500 | |
1501 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1502 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1501 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1502 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | /** |
@@ -1510,10 +1510,10 @@ discard block |
||
1510 | 1510 | * @param string $currency Whether to include the currency. |
1511 | 1511 | * @return float|string |
1512 | 1512 | */ |
1513 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1513 | + public function get_recurring_details($field = '', $currency = false) { |
|
1514 | 1514 | |
1515 | 1515 | // Maybe recalculate totals. |
1516 | - if ( empty( $this->totals ) ) { |
|
1516 | + if (empty($this->totals)) { |
|
1517 | 1517 | $this->recalculate_total(); |
1518 | 1518 | } |
1519 | 1519 | |
@@ -1533,8 +1533,8 @@ discard block |
||
1533 | 1533 | $currency |
1534 | 1534 | ); |
1535 | 1535 | |
1536 | - if ( isset( $data[$field] ) ) { |
|
1537 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1536 | + if (isset($data[$field])) { |
|
1537 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | return $data; |
@@ -1547,8 +1547,8 @@ discard block |
||
1547 | 1547 | * @param string $context View or edit context. |
1548 | 1548 | * @return array |
1549 | 1549 | */ |
1550 | - public function get_fees( $context = 'view' ) { |
|
1551 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1550 | + public function get_fees($context = 'view') { |
|
1551 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1552 | 1552 | } |
1553 | 1553 | |
1554 | 1554 | /** |
@@ -1558,8 +1558,8 @@ discard block |
||
1558 | 1558 | * @param string $context View or edit context. |
1559 | 1559 | * @return array |
1560 | 1560 | */ |
1561 | - public function get_discounts( $context = 'view' ) { |
|
1562 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1561 | + public function get_discounts($context = 'view') { |
|
1562 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1563 | 1563 | } |
1564 | 1564 | |
1565 | 1565 | /** |
@@ -1569,8 +1569,8 @@ discard block |
||
1569 | 1569 | * @param string $context View or edit context. |
1570 | 1570 | * @return array |
1571 | 1571 | */ |
1572 | - public function get_taxes( $context = 'view' ) { |
|
1573 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1572 | + public function get_taxes($context = 'view') { |
|
1573 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | /** |
@@ -1580,8 +1580,8 @@ discard block |
||
1580 | 1580 | * @param string $context View or edit context. |
1581 | 1581 | * @return GetPaid_Form_Item[] |
1582 | 1582 | */ |
1583 | - public function get_items( $context = 'view' ) { |
|
1584 | - return $this->get_prop( 'items', $context ); |
|
1583 | + public function get_items($context = 'view') { |
|
1584 | + return $this->get_prop('items', $context); |
|
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | /** |
@@ -1591,7 +1591,7 @@ discard block |
||
1591 | 1591 | * @return string |
1592 | 1592 | */ |
1593 | 1593 | public function get_item_ids() { |
1594 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
1594 | + return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id')); |
|
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | /** |
@@ -1601,8 +1601,8 @@ discard block |
||
1601 | 1601 | * @param string $context View or edit context. |
1602 | 1602 | * @return int |
1603 | 1603 | */ |
1604 | - public function get_payment_form( $context = 'view' ) { |
|
1605 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1604 | + public function get_payment_form($context = 'view') { |
|
1605 | + return intval($this->get_prop('payment_form', $context)); |
|
1606 | 1606 | } |
1607 | 1607 | |
1608 | 1608 | /** |
@@ -1612,8 +1612,8 @@ discard block |
||
1612 | 1612 | * @param string $context View or edit context. |
1613 | 1613 | * @return string |
1614 | 1614 | */ |
1615 | - public function get_submission_id( $context = 'view' ) { |
|
1616 | - return $this->get_prop( 'submission_id', $context ); |
|
1615 | + public function get_submission_id($context = 'view') { |
|
1616 | + return $this->get_prop('submission_id', $context); |
|
1617 | 1617 | } |
1618 | 1618 | |
1619 | 1619 | /** |
@@ -1623,8 +1623,8 @@ discard block |
||
1623 | 1623 | * @param string $context View or edit context. |
1624 | 1624 | * @return string |
1625 | 1625 | */ |
1626 | - public function get_discount_code( $context = 'view' ) { |
|
1627 | - return $this->get_prop( 'discount_code', $context ); |
|
1626 | + public function get_discount_code($context = 'view') { |
|
1627 | + return $this->get_prop('discount_code', $context); |
|
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | /** |
@@ -1634,8 +1634,8 @@ discard block |
||
1634 | 1634 | * @param string $context View or edit context. |
1635 | 1635 | * @return string |
1636 | 1636 | */ |
1637 | - public function get_gateway( $context = 'view' ) { |
|
1638 | - return $this->get_prop( 'gateway', $context ); |
|
1637 | + public function get_gateway($context = 'view') { |
|
1638 | + return $this->get_prop('gateway', $context); |
|
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | /** |
@@ -1645,8 +1645,8 @@ discard block |
||
1645 | 1645 | * @return string |
1646 | 1646 | */ |
1647 | 1647 | public function get_gateway_title() { |
1648 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1649 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1648 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1649 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | /** |
@@ -1656,8 +1656,8 @@ discard block |
||
1656 | 1656 | * @param string $context View or edit context. |
1657 | 1657 | * @return string |
1658 | 1658 | */ |
1659 | - public function get_transaction_id( $context = 'view' ) { |
|
1660 | - return $this->get_prop( 'transaction_id', $context ); |
|
1659 | + public function get_transaction_id($context = 'view') { |
|
1660 | + return $this->get_prop('transaction_id', $context); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | /** |
@@ -1667,9 +1667,9 @@ discard block |
||
1667 | 1667 | * @param string $context View or edit context. |
1668 | 1668 | * @return string |
1669 | 1669 | */ |
1670 | - public function get_currency( $context = 'view' ) { |
|
1671 | - $currency = $this->get_prop( 'currency', $context ); |
|
1672 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1670 | + public function get_currency($context = 'view') { |
|
1671 | + $currency = $this->get_prop('currency', $context); |
|
1672 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | /** |
@@ -1679,8 +1679,8 @@ discard block |
||
1679 | 1679 | * @param string $context View or edit context. |
1680 | 1680 | * @return bool |
1681 | 1681 | */ |
1682 | - public function get_disable_taxes( $context = 'view' ) { |
|
1683 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1682 | + public function get_disable_taxes($context = 'view') { |
|
1683 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1684 | 1684 | } |
1685 | 1685 | |
1686 | 1686 | /** |
@@ -1690,8 +1690,8 @@ discard block |
||
1690 | 1690 | * @param string $context View or edit context. |
1691 | 1691 | * @return int |
1692 | 1692 | */ |
1693 | - public function get_subscription_id( $context = 'view' ) { |
|
1694 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1693 | + public function get_subscription_id($context = 'view') { |
|
1694 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1695 | 1695 | } |
1696 | 1696 | |
1697 | 1697 | /** |
@@ -1701,12 +1701,12 @@ discard block |
||
1701 | 1701 | * @param string $context View or edit context. |
1702 | 1702 | * @return int |
1703 | 1703 | */ |
1704 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1705 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1704 | + public function get_remote_subscription_id($context = 'view') { |
|
1705 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1706 | 1706 | |
1707 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1707 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1708 | 1708 | $parent = $this->get_parent(); |
1709 | - return $parent->get_remote_subscription_id( $context ); |
|
1709 | + return $parent->get_remote_subscription_id($context); |
|
1710 | 1710 | } |
1711 | 1711 | |
1712 | 1712 | return $subscription_id; |
@@ -1719,20 +1719,20 @@ discard block |
||
1719 | 1719 | * @param string $context View or edit context. |
1720 | 1720 | * @return array |
1721 | 1721 | */ |
1722 | - public function get_payment_meta( $context = 'view' ) { |
|
1722 | + public function get_payment_meta($context = 'view') { |
|
1723 | 1723 | |
1724 | 1724 | return array( |
1725 | - 'price' => $this->get_total( $context ), |
|
1726 | - 'date' => $this->get_date_created( $context ), |
|
1727 | - 'user_email' => $this->get_email( $context ), |
|
1728 | - 'invoice_key' => $this->get_key( $context ), |
|
1729 | - 'currency' => $this->get_currency( $context ), |
|
1730 | - 'items' => $this->get_items( $context ), |
|
1731 | - 'user_info' => $this->get_user_info( $context ), |
|
1725 | + 'price' => $this->get_total($context), |
|
1726 | + 'date' => $this->get_date_created($context), |
|
1727 | + 'user_email' => $this->get_email($context), |
|
1728 | + 'invoice_key' => $this->get_key($context), |
|
1729 | + 'currency' => $this->get_currency($context), |
|
1730 | + 'items' => $this->get_items($context), |
|
1731 | + 'user_info' => $this->get_user_info($context), |
|
1732 | 1732 | 'cart_details' => $this->get_cart_details(), |
1733 | - 'status' => $this->get_status( $context ), |
|
1734 | - 'fees' => $this->get_fees( $context ), |
|
1735 | - 'taxes' => $this->get_taxes( $context ), |
|
1733 | + 'status' => $this->get_status($context), |
|
1734 | + 'fees' => $this->get_fees($context), |
|
1735 | + 'taxes' => $this->get_taxes($context), |
|
1736 | 1736 | ); |
1737 | 1737 | |
1738 | 1738 | } |
@@ -1747,9 +1747,9 @@ discard block |
||
1747 | 1747 | $items = $this->get_items(); |
1748 | 1748 | $cart_details = array(); |
1749 | 1749 | |
1750 | - foreach ( $items as $item ) { |
|
1750 | + foreach ($items as $item) { |
|
1751 | 1751 | $item->invoice_id = $this->get_id(); |
1752 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1752 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1753 | 1753 | } |
1754 | 1754 | |
1755 | 1755 | return $cart_details; |
@@ -1760,11 +1760,11 @@ discard block |
||
1760 | 1760 | * |
1761 | 1761 | * @return null|GetPaid_Form_Item|int |
1762 | 1762 | */ |
1763 | - public function get_recurring( $object = false ) { |
|
1763 | + public function get_recurring($object = false) { |
|
1764 | 1764 | |
1765 | 1765 | // Are we returning an object? |
1766 | - if ( $object ) { |
|
1767 | - return $this->get_item( $this->recurring_item ); |
|
1766 | + if ($object) { |
|
1767 | + return $this->get_item($this->recurring_item); |
|
1768 | 1768 | } |
1769 | 1769 | |
1770 | 1770 | return $this->recurring_item; |
@@ -1779,15 +1779,15 @@ discard block |
||
1779 | 1779 | public function get_subscription_name() { |
1780 | 1780 | |
1781 | 1781 | // Retrieve the recurring name |
1782 | - $item = $this->get_recurring( true ); |
|
1782 | + $item = $this->get_recurring(true); |
|
1783 | 1783 | |
1784 | 1784 | // Abort if it does not exist. |
1785 | - if ( empty( $item ) ) { |
|
1785 | + if (empty($item)) { |
|
1786 | 1786 | return ''; |
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | // Return the item name. |
1790 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1790 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1791 | 1791 | } |
1792 | 1792 | |
1793 | 1793 | /** |
@@ -1797,9 +1797,9 @@ discard block |
||
1797 | 1797 | * @return string |
1798 | 1798 | */ |
1799 | 1799 | public function get_view_url() { |
1800 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1801 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1802 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1800 | + $invoice_url = get_permalink($this->get_id()); |
|
1801 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1802 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1803 | 1803 | } |
1804 | 1804 | |
1805 | 1805 | /** |
@@ -1808,25 +1808,25 @@ discard block |
||
1808 | 1808 | * @since 1.0.19 |
1809 | 1809 | * @return string |
1810 | 1810 | */ |
1811 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1811 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1812 | 1812 | |
1813 | 1813 | // Retrieve the checkout url. |
1814 | 1814 | $pay_url = wpinv_get_checkout_uri(); |
1815 | 1815 | |
1816 | 1816 | // Maybe force ssl. |
1817 | - if ( is_ssl() ) { |
|
1818 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1817 | + if (is_ssl()) { |
|
1818 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1819 | 1819 | } |
1820 | 1820 | |
1821 | 1821 | // Add the invoice key. |
1822 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1822 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1823 | 1823 | |
1824 | 1824 | // (Maybe?) add a secret |
1825 | - if ( $secret ) { |
|
1826 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1825 | + if ($secret) { |
|
1826 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1827 | 1827 | } |
1828 | 1828 | |
1829 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1829 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | /** |
@@ -1841,14 +1841,14 @@ discard block |
||
1841 | 1841 | $receipt_url = wpinv_get_success_page_uri(); |
1842 | 1842 | |
1843 | 1843 | // Maybe force ssl. |
1844 | - if ( is_ssl() ) { |
|
1845 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1844 | + if (is_ssl()) { |
|
1845 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1846 | 1846 | } |
1847 | 1847 | |
1848 | 1848 | // Add the invoice key. |
1849 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1849 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1850 | 1850 | |
1851 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1851 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1852 | 1852 | } |
1853 | 1853 | |
1854 | 1854 | /** |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | |
1862 | 1862 | $type = $this->get_type(); |
1863 | 1863 | $status = "wpi-$type-pending"; |
1864 | - return str_replace( '-invoice', '', $status ); |
|
1864 | + return str_replace('-invoice', '', $status); |
|
1865 | 1865 | |
1866 | 1866 | } |
1867 | 1867 | |
@@ -1875,8 +1875,8 @@ discard block |
||
1875 | 1875 | * @param string $context View or edit context. |
1876 | 1876 | * @return mixed Value of the given invoice property (if set). |
1877 | 1877 | */ |
1878 | - public function get( $key, $context = 'view' ) { |
|
1879 | - return $this->get_prop( $key, $context ); |
|
1878 | + public function get($key, $context = 'view') { |
|
1879 | + return $this->get_prop($key, $context); |
|
1880 | 1880 | } |
1881 | 1881 | |
1882 | 1882 | /* |
@@ -1899,11 +1899,11 @@ discard block |
||
1899 | 1899 | * @param mixed $value new value. |
1900 | 1900 | * @return mixed Value of the given invoice property (if set). |
1901 | 1901 | */ |
1902 | - public function set( $key, $value ) { |
|
1902 | + public function set($key, $value) { |
|
1903 | 1903 | |
1904 | 1904 | $setter = "set_$key"; |
1905 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1906 | - $this->{$setter}( $value ); |
|
1905 | + if (is_callable(array($this, $setter))) { |
|
1906 | + $this->{$setter}($value); |
|
1907 | 1907 | } |
1908 | 1908 | |
1909 | 1909 | } |
@@ -1917,45 +1917,45 @@ discard block |
||
1917 | 1917 | * @param bool $manual_update Is this a manual status change?. |
1918 | 1918 | * @return array details of change. |
1919 | 1919 | */ |
1920 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1920 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1921 | 1921 | $old_status = $this->get_status(); |
1922 | 1922 | |
1923 | 1923 | $statuses = $this->get_all_statuses(); |
1924 | 1924 | |
1925 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1926 | - unset( $statuses[ 'draft' ] ); |
|
1925 | + if (isset($statuses['draft'])) { |
|
1926 | + unset($statuses['draft']); |
|
1927 | 1927 | } |
1928 | 1928 | |
1929 | - $this->set_prop( 'status', $new_status ); |
|
1929 | + $this->set_prop('status', $new_status); |
|
1930 | 1930 | |
1931 | 1931 | // If setting the status, ensure it's set to a valid status. |
1932 | - if ( true === $this->object_read ) { |
|
1932 | + if (true === $this->object_read) { |
|
1933 | 1933 | |
1934 | 1934 | // Only allow valid new status. |
1935 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1935 | + if (!array_key_exists($new_status, $statuses)) { |
|
1936 | 1936 | $new_status = $this->get_default_status(); |
1937 | 1937 | } |
1938 | 1938 | |
1939 | 1939 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1940 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1940 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1941 | 1941 | $old_status = $this->get_default_status(); |
1942 | 1942 | } |
1943 | 1943 | |
1944 | 1944 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1945 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1945 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1946 | 1946 | $old_status = 'wpi-pending'; |
1947 | 1947 | } |
1948 | 1948 | |
1949 | - if ( $old_status !== $new_status ) { |
|
1949 | + if ($old_status !== $new_status) { |
|
1950 | 1950 | $this->status_transition = array( |
1951 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1951 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1952 | 1952 | 'to' => $new_status, |
1953 | 1953 | 'note' => $note, |
1954 | 1954 | 'manual' => (bool) $manual_update, |
1955 | 1955 | ); |
1956 | 1956 | |
1957 | - if ( $manual_update ) { |
|
1958 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1957 | + if ($manual_update) { |
|
1958 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1959 | 1959 | } |
1960 | 1960 | |
1961 | 1961 | $this->maybe_set_date_paid(); |
@@ -1980,8 +1980,8 @@ discard block |
||
1980 | 1980 | */ |
1981 | 1981 | public function maybe_set_date_paid() { |
1982 | 1982 | |
1983 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1984 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1983 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1984 | + $this->set_date_completed(current_time('mysql')); |
|
1985 | 1985 | } |
1986 | 1986 | } |
1987 | 1987 | |
@@ -1990,11 +1990,11 @@ discard block |
||
1990 | 1990 | * |
1991 | 1991 | * @since 1.0.19 |
1992 | 1992 | */ |
1993 | - public function set_parent_id( $value ) { |
|
1994 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1993 | + public function set_parent_id($value) { |
|
1994 | + if ($value && ($value === $this->get_id())) { |
|
1995 | 1995 | return; |
1996 | 1996 | } |
1997 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1997 | + $this->set_prop('parent_id', absint($value)); |
|
1998 | 1998 | } |
1999 | 1999 | |
2000 | 2000 | /** |
@@ -2002,8 +2002,8 @@ discard block |
||
2002 | 2002 | * |
2003 | 2003 | * @since 1.0.19 |
2004 | 2004 | */ |
2005 | - public function set_version( $value ) { |
|
2006 | - $this->set_prop( 'version', $value ); |
|
2005 | + public function set_version($value) { |
|
2006 | + $this->set_prop('version', $value); |
|
2007 | 2007 | } |
2008 | 2008 | |
2009 | 2009 | /** |
@@ -2013,15 +2013,15 @@ discard block |
||
2013 | 2013 | * @param string $value Value to set. |
2014 | 2014 | * @return bool Whether or not the date was set. |
2015 | 2015 | */ |
2016 | - public function set_date_created( $value ) { |
|
2017 | - $date = strtotime( $value ); |
|
2016 | + public function set_date_created($value) { |
|
2017 | + $date = strtotime($value); |
|
2018 | 2018 | |
2019 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2020 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
2019 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2020 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
2021 | 2021 | return true; |
2022 | 2022 | } |
2023 | 2023 | |
2024 | - $this->set_prop( 'date_created', '' ); |
|
2024 | + $this->set_prop('date_created', ''); |
|
2025 | 2025 | return false; |
2026 | 2026 | |
2027 | 2027 | } |
@@ -2033,15 +2033,15 @@ discard block |
||
2033 | 2033 | * @param string $value Value to set. |
2034 | 2034 | * @return bool Whether or not the date was set. |
2035 | 2035 | */ |
2036 | - public function set_due_date( $value ) { |
|
2037 | - $date = strtotime( $value ); |
|
2036 | + public function set_due_date($value) { |
|
2037 | + $date = strtotime($value); |
|
2038 | 2038 | |
2039 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2040 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2039 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2040 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
2041 | 2041 | return true; |
2042 | 2042 | } |
2043 | 2043 | |
2044 | - $this->set_prop( 'due_date', '' ); |
|
2044 | + $this->set_prop('due_date', ''); |
|
2045 | 2045 | return false; |
2046 | 2046 | |
2047 | 2047 | } |
@@ -2052,8 +2052,8 @@ discard block |
||
2052 | 2052 | * @since 1.0.19 |
2053 | 2053 | * @param string $value New name. |
2054 | 2054 | */ |
2055 | - public function set_date_due( $value ) { |
|
2056 | - $this->set_due_date( $value ); |
|
2055 | + public function set_date_due($value) { |
|
2056 | + $this->set_due_date($value); |
|
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | /** |
@@ -2063,15 +2063,15 @@ discard block |
||
2063 | 2063 | * @param string $value Value to set. |
2064 | 2064 | * @return bool Whether or not the date was set. |
2065 | 2065 | */ |
2066 | - public function set_completed_date( $value ) { |
|
2067 | - $date = strtotime( $value ); |
|
2066 | + public function set_completed_date($value) { |
|
2067 | + $date = strtotime($value); |
|
2068 | 2068 | |
2069 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2070 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2069 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2070 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2071 | 2071 | return true; |
2072 | 2072 | } |
2073 | 2073 | |
2074 | - $this->set_prop( 'completed_date', '' ); |
|
2074 | + $this->set_prop('completed_date', ''); |
|
2075 | 2075 | return false; |
2076 | 2076 | |
2077 | 2077 | } |
@@ -2082,8 +2082,8 @@ discard block |
||
2082 | 2082 | * @since 1.0.19 |
2083 | 2083 | * @param string $value New name. |
2084 | 2084 | */ |
2085 | - public function set_date_completed( $value ) { |
|
2086 | - $this->set_completed_date( $value ); |
|
2085 | + public function set_date_completed($value) { |
|
2086 | + $this->set_completed_date($value); |
|
2087 | 2087 | } |
2088 | 2088 | |
2089 | 2089 | /** |
@@ -2093,15 +2093,15 @@ discard block |
||
2093 | 2093 | * @param string $value Value to set. |
2094 | 2094 | * @return bool Whether or not the date was set. |
2095 | 2095 | */ |
2096 | - public function set_date_modified( $value ) { |
|
2097 | - $date = strtotime( $value ); |
|
2096 | + public function set_date_modified($value) { |
|
2097 | + $date = strtotime($value); |
|
2098 | 2098 | |
2099 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2100 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2099 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2100 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2101 | 2101 | return true; |
2102 | 2102 | } |
2103 | 2103 | |
2104 | - $this->set_prop( 'date_modified', '' ); |
|
2104 | + $this->set_prop('date_modified', ''); |
|
2105 | 2105 | return false; |
2106 | 2106 | |
2107 | 2107 | } |
@@ -2112,9 +2112,9 @@ discard block |
||
2112 | 2112 | * @since 1.0.19 |
2113 | 2113 | * @param string $value New number. |
2114 | 2114 | */ |
2115 | - public function set_number( $value ) { |
|
2116 | - $number = sanitize_text_field( $value ); |
|
2117 | - $this->set_prop( 'number', $number ); |
|
2115 | + public function set_number($value) { |
|
2116 | + $number = sanitize_text_field($value); |
|
2117 | + $this->set_prop('number', $number); |
|
2118 | 2118 | } |
2119 | 2119 | |
2120 | 2120 | /** |
@@ -2123,9 +2123,9 @@ discard block |
||
2123 | 2123 | * @since 1.0.19 |
2124 | 2124 | * @param string $value Type. |
2125 | 2125 | */ |
2126 | - public function set_type( $value ) { |
|
2127 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2128 | - $this->set_prop( 'type', $type ); |
|
2126 | + public function set_type($value) { |
|
2127 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2128 | + $this->set_prop('type', $type); |
|
2129 | 2129 | } |
2130 | 2130 | |
2131 | 2131 | /** |
@@ -2134,10 +2134,10 @@ discard block |
||
2134 | 2134 | * @since 1.0.19 |
2135 | 2135 | * @param string $value Post type. |
2136 | 2136 | */ |
2137 | - public function set_post_type( $value ) { |
|
2138 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2139 | - $this->set_type( $value ); |
|
2140 | - $this->set_prop( 'post_type', $value ); |
|
2137 | + public function set_post_type($value) { |
|
2138 | + if (getpaid_is_invoice_post_type($value)) { |
|
2139 | + $this->set_type($value); |
|
2140 | + $this->set_prop('post_type', $value); |
|
2141 | 2141 | } |
2142 | 2142 | } |
2143 | 2143 | |
@@ -2147,9 +2147,9 @@ discard block |
||
2147 | 2147 | * @since 1.0.19 |
2148 | 2148 | * @param string $value New key. |
2149 | 2149 | */ |
2150 | - public function set_key( $value ) { |
|
2151 | - $key = sanitize_text_field( $value ); |
|
2152 | - $this->set_prop( 'key', $key ); |
|
2150 | + public function set_key($value) { |
|
2151 | + $key = sanitize_text_field($value); |
|
2152 | + $this->set_prop('key', $key); |
|
2153 | 2153 | } |
2154 | 2154 | |
2155 | 2155 | /** |
@@ -2158,9 +2158,9 @@ discard block |
||
2158 | 2158 | * @since 1.0.19 |
2159 | 2159 | * @param string $value mode. |
2160 | 2160 | */ |
2161 | - public function set_mode( $value ) { |
|
2162 | - if ( in_array( $value, array( 'live', 'test' ) ) ) { |
|
2163 | - $this->set_prop( 'mode', $value ); |
|
2161 | + public function set_mode($value) { |
|
2162 | + if (in_array($value, array('live', 'test'))) { |
|
2163 | + $this->set_prop('mode', $value); |
|
2164 | 2164 | } |
2165 | 2165 | } |
2166 | 2166 | |
@@ -2170,8 +2170,8 @@ discard block |
||
2170 | 2170 | * @since 1.0.19 |
2171 | 2171 | * @param string $value path. |
2172 | 2172 | */ |
2173 | - public function set_path( $value ) { |
|
2174 | - $this->set_prop( 'path', $value ); |
|
2173 | + public function set_path($value) { |
|
2174 | + $this->set_prop('path', $value); |
|
2175 | 2175 | } |
2176 | 2176 | |
2177 | 2177 | /** |
@@ -2180,9 +2180,9 @@ discard block |
||
2180 | 2180 | * @since 1.0.19 |
2181 | 2181 | * @param string $value New name. |
2182 | 2182 | */ |
2183 | - public function set_name( $value ) { |
|
2184 | - $name = sanitize_text_field( $value ); |
|
2185 | - $this->set_prop( 'name', $name ); |
|
2183 | + public function set_name($value) { |
|
2184 | + $name = sanitize_text_field($value); |
|
2185 | + $this->set_prop('name', $name); |
|
2186 | 2186 | } |
2187 | 2187 | |
2188 | 2188 | /** |
@@ -2191,8 +2191,8 @@ discard block |
||
2191 | 2191 | * @since 1.0.19 |
2192 | 2192 | * @param string $value New name. |
2193 | 2193 | */ |
2194 | - public function set_title( $value ) { |
|
2195 | - $this->set_name( $value ); |
|
2194 | + public function set_title($value) { |
|
2195 | + $this->set_name($value); |
|
2196 | 2196 | } |
2197 | 2197 | |
2198 | 2198 | /** |
@@ -2201,9 +2201,9 @@ discard block |
||
2201 | 2201 | * @since 1.0.19 |
2202 | 2202 | * @param string $value New description. |
2203 | 2203 | */ |
2204 | - public function set_description( $value ) { |
|
2205 | - $description = wp_kses_post( $value ); |
|
2206 | - $this->set_prop( 'description', $description ); |
|
2204 | + public function set_description($value) { |
|
2205 | + $description = wp_kses_post($value); |
|
2206 | + $this->set_prop('description', $description); |
|
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | /** |
@@ -2212,8 +2212,8 @@ discard block |
||
2212 | 2212 | * @since 1.0.19 |
2213 | 2213 | * @param string $value New description. |
2214 | 2214 | */ |
2215 | - public function set_excerpt( $value ) { |
|
2216 | - $this->set_description( $value ); |
|
2215 | + public function set_excerpt($value) { |
|
2216 | + $this->set_description($value); |
|
2217 | 2217 | } |
2218 | 2218 | |
2219 | 2219 | /** |
@@ -2222,8 +2222,8 @@ discard block |
||
2222 | 2222 | * @since 1.0.19 |
2223 | 2223 | * @param string $value New description. |
2224 | 2224 | */ |
2225 | - public function set_summary( $value ) { |
|
2226 | - $this->set_description( $value ); |
|
2225 | + public function set_summary($value) { |
|
2226 | + $this->set_description($value); |
|
2227 | 2227 | } |
2228 | 2228 | |
2229 | 2229 | /** |
@@ -2232,12 +2232,12 @@ discard block |
||
2232 | 2232 | * @since 1.0.19 |
2233 | 2233 | * @param int $value New author. |
2234 | 2234 | */ |
2235 | - public function set_author( $value ) { |
|
2236 | - $user = get_user_by( 'id', (int) $value ); |
|
2235 | + public function set_author($value) { |
|
2236 | + $user = get_user_by('id', (int) $value); |
|
2237 | 2237 | |
2238 | - if ( $user && $user->ID ) { |
|
2239 | - $this->set_prop( 'author', $user->ID ); |
|
2240 | - $this->set_prop( 'email', $user->user_email ); |
|
2238 | + if ($user && $user->ID) { |
|
2239 | + $this->set_prop('author', $user->ID); |
|
2240 | + $this->set_prop('email', $user->user_email); |
|
2241 | 2241 | } |
2242 | 2242 | |
2243 | 2243 | } |
@@ -2248,8 +2248,8 @@ discard block |
||
2248 | 2248 | * @since 1.0.19 |
2249 | 2249 | * @param int $value New user id. |
2250 | 2250 | */ |
2251 | - public function set_user_id( $value ) { |
|
2252 | - $this->set_author( $value ); |
|
2251 | + public function set_user_id($value) { |
|
2252 | + $this->set_author($value); |
|
2253 | 2253 | } |
2254 | 2254 | |
2255 | 2255 | /** |
@@ -2258,8 +2258,8 @@ discard block |
||
2258 | 2258 | * @since 1.0.19 |
2259 | 2259 | * @param int $value New user id. |
2260 | 2260 | */ |
2261 | - public function set_customer_id( $value ) { |
|
2262 | - $this->set_author( $value ); |
|
2261 | + public function set_customer_id($value) { |
|
2262 | + $this->set_author($value); |
|
2263 | 2263 | } |
2264 | 2264 | |
2265 | 2265 | /** |
@@ -2268,8 +2268,8 @@ discard block |
||
2268 | 2268 | * @since 1.0.19 |
2269 | 2269 | * @param string $value ip address. |
2270 | 2270 | */ |
2271 | - public function set_ip( $value ) { |
|
2272 | - $this->set_prop( 'ip', $value ); |
|
2271 | + public function set_ip($value) { |
|
2272 | + $this->set_prop('ip', $value); |
|
2273 | 2273 | } |
2274 | 2274 | |
2275 | 2275 | /** |
@@ -2278,8 +2278,8 @@ discard block |
||
2278 | 2278 | * @since 1.0.19 |
2279 | 2279 | * @param string $value ip address. |
2280 | 2280 | */ |
2281 | - public function set_user_ip( $value ) { |
|
2282 | - $this->set_ip( $value ); |
|
2281 | + public function set_user_ip($value) { |
|
2282 | + $this->set_ip($value); |
|
2283 | 2283 | } |
2284 | 2284 | |
2285 | 2285 | /** |
@@ -2288,8 +2288,8 @@ discard block |
||
2288 | 2288 | * @since 1.0.19 |
2289 | 2289 | * @param string $value first name. |
2290 | 2290 | */ |
2291 | - public function set_first_name( $value ) { |
|
2292 | - $this->set_prop( 'first_name', $value ); |
|
2291 | + public function set_first_name($value) { |
|
2292 | + $this->set_prop('first_name', $value); |
|
2293 | 2293 | } |
2294 | 2294 | |
2295 | 2295 | /** |
@@ -2298,8 +2298,8 @@ discard block |
||
2298 | 2298 | * @since 1.0.19 |
2299 | 2299 | * @param string $value first name. |
2300 | 2300 | */ |
2301 | - public function set_user_first_name( $value ) { |
|
2302 | - $this->set_first_name( $value ); |
|
2301 | + public function set_user_first_name($value) { |
|
2302 | + $this->set_first_name($value); |
|
2303 | 2303 | } |
2304 | 2304 | |
2305 | 2305 | /** |
@@ -2308,8 +2308,8 @@ discard block |
||
2308 | 2308 | * @since 1.0.19 |
2309 | 2309 | * @param string $value first name. |
2310 | 2310 | */ |
2311 | - public function set_customer_first_name( $value ) { |
|
2312 | - $this->set_first_name( $value ); |
|
2311 | + public function set_customer_first_name($value) { |
|
2312 | + $this->set_first_name($value); |
|
2313 | 2313 | } |
2314 | 2314 | |
2315 | 2315 | /** |
@@ -2318,8 +2318,8 @@ discard block |
||
2318 | 2318 | * @since 1.0.19 |
2319 | 2319 | * @param string $value last name. |
2320 | 2320 | */ |
2321 | - public function set_last_name( $value ) { |
|
2322 | - $this->set_prop( 'last_name', $value ); |
|
2321 | + public function set_last_name($value) { |
|
2322 | + $this->set_prop('last_name', $value); |
|
2323 | 2323 | } |
2324 | 2324 | |
2325 | 2325 | /** |
@@ -2328,8 +2328,8 @@ discard block |
||
2328 | 2328 | * @since 1.0.19 |
2329 | 2329 | * @param string $value last name. |
2330 | 2330 | */ |
2331 | - public function set_user_last_name( $value ) { |
|
2332 | - $this->set_last_name( $value ); |
|
2331 | + public function set_user_last_name($value) { |
|
2332 | + $this->set_last_name($value); |
|
2333 | 2333 | } |
2334 | 2334 | |
2335 | 2335 | /** |
@@ -2338,8 +2338,8 @@ discard block |
||
2338 | 2338 | * @since 1.0.19 |
2339 | 2339 | * @param string $value last name. |
2340 | 2340 | */ |
2341 | - public function set_customer_last_name( $value ) { |
|
2342 | - $this->set_last_name( $value ); |
|
2341 | + public function set_customer_last_name($value) { |
|
2342 | + $this->set_last_name($value); |
|
2343 | 2343 | } |
2344 | 2344 | |
2345 | 2345 | /** |
@@ -2348,8 +2348,8 @@ discard block |
||
2348 | 2348 | * @since 1.0.19 |
2349 | 2349 | * @param string $value phone. |
2350 | 2350 | */ |
2351 | - public function set_phone( $value ) { |
|
2352 | - $this->set_prop( 'phone', $value ); |
|
2351 | + public function set_phone($value) { |
|
2352 | + $this->set_prop('phone', $value); |
|
2353 | 2353 | } |
2354 | 2354 | |
2355 | 2355 | /** |
@@ -2358,8 +2358,8 @@ discard block |
||
2358 | 2358 | * @since 1.0.19 |
2359 | 2359 | * @param string $value phone. |
2360 | 2360 | */ |
2361 | - public function set_user_phone( $value ) { |
|
2362 | - $this->set_phone( $value ); |
|
2361 | + public function set_user_phone($value) { |
|
2362 | + $this->set_phone($value); |
|
2363 | 2363 | } |
2364 | 2364 | |
2365 | 2365 | /** |
@@ -2368,8 +2368,8 @@ discard block |
||
2368 | 2368 | * @since 1.0.19 |
2369 | 2369 | * @param string $value phone. |
2370 | 2370 | */ |
2371 | - public function set_customer_phone( $value ) { |
|
2372 | - $this->set_phone( $value ); |
|
2371 | + public function set_customer_phone($value) { |
|
2372 | + $this->set_phone($value); |
|
2373 | 2373 | } |
2374 | 2374 | |
2375 | 2375 | /** |
@@ -2378,8 +2378,8 @@ discard block |
||
2378 | 2378 | * @since 1.0.19 |
2379 | 2379 | * @param string $value phone. |
2380 | 2380 | */ |
2381 | - public function set_phone_number( $value ) { |
|
2382 | - $this->set_phone( $value ); |
|
2381 | + public function set_phone_number($value) { |
|
2382 | + $this->set_phone($value); |
|
2383 | 2383 | } |
2384 | 2384 | |
2385 | 2385 | /** |
@@ -2388,8 +2388,8 @@ discard block |
||
2388 | 2388 | * @since 1.0.19 |
2389 | 2389 | * @param string $value email address. |
2390 | 2390 | */ |
2391 | - public function set_email( $value ) { |
|
2392 | - $this->set_prop( 'email', $value ); |
|
2391 | + public function set_email($value) { |
|
2392 | + $this->set_prop('email', $value); |
|
2393 | 2393 | } |
2394 | 2394 | |
2395 | 2395 | /** |
@@ -2398,8 +2398,8 @@ discard block |
||
2398 | 2398 | * @since 1.0.19 |
2399 | 2399 | * @param string $value email address. |
2400 | 2400 | */ |
2401 | - public function set_user_email( $value ) { |
|
2402 | - $this->set_email( $value ); |
|
2401 | + public function set_user_email($value) { |
|
2402 | + $this->set_email($value); |
|
2403 | 2403 | } |
2404 | 2404 | |
2405 | 2405 | /** |
@@ -2408,8 +2408,8 @@ discard block |
||
2408 | 2408 | * @since 1.0.19 |
2409 | 2409 | * @param string $value email address. |
2410 | 2410 | */ |
2411 | - public function set_email_address( $value ) { |
|
2412 | - $this->set_email( $value ); |
|
2411 | + public function set_email_address($value) { |
|
2412 | + $this->set_email($value); |
|
2413 | 2413 | } |
2414 | 2414 | |
2415 | 2415 | /** |
@@ -2418,8 +2418,8 @@ discard block |
||
2418 | 2418 | * @since 1.0.19 |
2419 | 2419 | * @param string $value email address. |
2420 | 2420 | */ |
2421 | - public function set_customer_email( $value ) { |
|
2422 | - $this->set_email( $value ); |
|
2421 | + public function set_customer_email($value) { |
|
2422 | + $this->set_email($value); |
|
2423 | 2423 | } |
2424 | 2424 | |
2425 | 2425 | /** |
@@ -2428,8 +2428,8 @@ discard block |
||
2428 | 2428 | * @since 1.0.19 |
2429 | 2429 | * @param string $value country. |
2430 | 2430 | */ |
2431 | - public function set_country( $value ) { |
|
2432 | - $this->set_prop( 'country', $value ); |
|
2431 | + public function set_country($value) { |
|
2432 | + $this->set_prop('country', $value); |
|
2433 | 2433 | } |
2434 | 2434 | |
2435 | 2435 | /** |
@@ -2438,8 +2438,8 @@ discard block |
||
2438 | 2438 | * @since 1.0.19 |
2439 | 2439 | * @param string $value country. |
2440 | 2440 | */ |
2441 | - public function set_user_country( $value ) { |
|
2442 | - $this->set_country( $value ); |
|
2441 | + public function set_user_country($value) { |
|
2442 | + $this->set_country($value); |
|
2443 | 2443 | } |
2444 | 2444 | |
2445 | 2445 | /** |
@@ -2448,8 +2448,8 @@ discard block |
||
2448 | 2448 | * @since 1.0.19 |
2449 | 2449 | * @param string $value country. |
2450 | 2450 | */ |
2451 | - public function set_customer_country( $value ) { |
|
2452 | - $this->set_country( $value ); |
|
2451 | + public function set_customer_country($value) { |
|
2452 | + $this->set_country($value); |
|
2453 | 2453 | } |
2454 | 2454 | |
2455 | 2455 | /** |
@@ -2458,8 +2458,8 @@ discard block |
||
2458 | 2458 | * @since 1.0.19 |
2459 | 2459 | * @param string $value state. |
2460 | 2460 | */ |
2461 | - public function set_state( $value ) { |
|
2462 | - $this->set_prop( 'state', $value ); |
|
2461 | + public function set_state($value) { |
|
2462 | + $this->set_prop('state', $value); |
|
2463 | 2463 | } |
2464 | 2464 | |
2465 | 2465 | /** |
@@ -2468,8 +2468,8 @@ discard block |
||
2468 | 2468 | * @since 1.0.19 |
2469 | 2469 | * @param string $value state. |
2470 | 2470 | */ |
2471 | - public function set_user_state( $value ) { |
|
2472 | - $this->set_state( $value ); |
|
2471 | + public function set_user_state($value) { |
|
2472 | + $this->set_state($value); |
|
2473 | 2473 | } |
2474 | 2474 | |
2475 | 2475 | /** |
@@ -2478,8 +2478,8 @@ discard block |
||
2478 | 2478 | * @since 1.0.19 |
2479 | 2479 | * @param string $value state. |
2480 | 2480 | */ |
2481 | - public function set_customer_state( $value ) { |
|
2482 | - $this->set_state( $value ); |
|
2481 | + public function set_customer_state($value) { |
|
2482 | + $this->set_state($value); |
|
2483 | 2483 | } |
2484 | 2484 | |
2485 | 2485 | /** |
@@ -2488,8 +2488,8 @@ discard block |
||
2488 | 2488 | * @since 1.0.19 |
2489 | 2489 | * @param string $value city. |
2490 | 2490 | */ |
2491 | - public function set_city( $value ) { |
|
2492 | - $this->set_prop( 'city', $value ); |
|
2491 | + public function set_city($value) { |
|
2492 | + $this->set_prop('city', $value); |
|
2493 | 2493 | } |
2494 | 2494 | |
2495 | 2495 | /** |
@@ -2498,8 +2498,8 @@ discard block |
||
2498 | 2498 | * @since 1.0.19 |
2499 | 2499 | * @param string $value city. |
2500 | 2500 | */ |
2501 | - public function set_user_city( $value ) { |
|
2502 | - $this->set_city( $value ); |
|
2501 | + public function set_user_city($value) { |
|
2502 | + $this->set_city($value); |
|
2503 | 2503 | } |
2504 | 2504 | |
2505 | 2505 | /** |
@@ -2508,8 +2508,8 @@ discard block |
||
2508 | 2508 | * @since 1.0.19 |
2509 | 2509 | * @param string $value city. |
2510 | 2510 | */ |
2511 | - public function set_customer_city( $value ) { |
|
2512 | - $this->set_city( $value ); |
|
2511 | + public function set_customer_city($value) { |
|
2512 | + $this->set_city($value); |
|
2513 | 2513 | } |
2514 | 2514 | |
2515 | 2515 | /** |
@@ -2518,8 +2518,8 @@ discard block |
||
2518 | 2518 | * @since 1.0.19 |
2519 | 2519 | * @param string $value zip. |
2520 | 2520 | */ |
2521 | - public function set_zip( $value ) { |
|
2522 | - $this->set_prop( 'zip', $value ); |
|
2521 | + public function set_zip($value) { |
|
2522 | + $this->set_prop('zip', $value); |
|
2523 | 2523 | } |
2524 | 2524 | |
2525 | 2525 | /** |
@@ -2528,8 +2528,8 @@ discard block |
||
2528 | 2528 | * @since 1.0.19 |
2529 | 2529 | * @param string $value zip. |
2530 | 2530 | */ |
2531 | - public function set_user_zip( $value ) { |
|
2532 | - $this->set_zip( $value ); |
|
2531 | + public function set_user_zip($value) { |
|
2532 | + $this->set_zip($value); |
|
2533 | 2533 | } |
2534 | 2534 | |
2535 | 2535 | /** |
@@ -2538,8 +2538,8 @@ discard block |
||
2538 | 2538 | * @since 1.0.19 |
2539 | 2539 | * @param string $value zip. |
2540 | 2540 | */ |
2541 | - public function set_customer_zip( $value ) { |
|
2542 | - $this->set_zip( $value ); |
|
2541 | + public function set_customer_zip($value) { |
|
2542 | + $this->set_zip($value); |
|
2543 | 2543 | } |
2544 | 2544 | |
2545 | 2545 | /** |
@@ -2548,8 +2548,8 @@ discard block |
||
2548 | 2548 | * @since 1.0.19 |
2549 | 2549 | * @param string $value company. |
2550 | 2550 | */ |
2551 | - public function set_company( $value ) { |
|
2552 | - $this->set_prop( 'company', $value ); |
|
2551 | + public function set_company($value) { |
|
2552 | + $this->set_prop('company', $value); |
|
2553 | 2553 | } |
2554 | 2554 | |
2555 | 2555 | /** |
@@ -2558,8 +2558,8 @@ discard block |
||
2558 | 2558 | * @since 1.0.19 |
2559 | 2559 | * @param string $value company. |
2560 | 2560 | */ |
2561 | - public function set_user_company( $value ) { |
|
2562 | - $this->set_company( $value ); |
|
2561 | + public function set_user_company($value) { |
|
2562 | + $this->set_company($value); |
|
2563 | 2563 | } |
2564 | 2564 | |
2565 | 2565 | /** |
@@ -2568,8 +2568,8 @@ discard block |
||
2568 | 2568 | * @since 1.0.19 |
2569 | 2569 | * @param string $value company. |
2570 | 2570 | */ |
2571 | - public function set_customer_company( $value ) { |
|
2572 | - $this->set_company( $value ); |
|
2571 | + public function set_customer_company($value) { |
|
2572 | + $this->set_company($value); |
|
2573 | 2573 | } |
2574 | 2574 | |
2575 | 2575 | /** |
@@ -2578,8 +2578,8 @@ discard block |
||
2578 | 2578 | * @since 1.0.19 |
2579 | 2579 | * @param string $value var number. |
2580 | 2580 | */ |
2581 | - public function set_vat_number( $value ) { |
|
2582 | - $this->set_prop( 'vat_number', $value ); |
|
2581 | + public function set_vat_number($value) { |
|
2582 | + $this->set_prop('vat_number', $value); |
|
2583 | 2583 | } |
2584 | 2584 | |
2585 | 2585 | /** |
@@ -2588,8 +2588,8 @@ discard block |
||
2588 | 2588 | * @since 1.0.19 |
2589 | 2589 | * @param string $value var number. |
2590 | 2590 | */ |
2591 | - public function set_user_vat_number( $value ) { |
|
2592 | - $this->set_vat_number( $value ); |
|
2591 | + public function set_user_vat_number($value) { |
|
2592 | + $this->set_vat_number($value); |
|
2593 | 2593 | } |
2594 | 2594 | |
2595 | 2595 | /** |
@@ -2598,8 +2598,8 @@ discard block |
||
2598 | 2598 | * @since 1.0.19 |
2599 | 2599 | * @param string $value var number. |
2600 | 2600 | */ |
2601 | - public function set_customer_vat_number( $value ) { |
|
2602 | - $this->set_vat_number( $value ); |
|
2601 | + public function set_customer_vat_number($value) { |
|
2602 | + $this->set_vat_number($value); |
|
2603 | 2603 | } |
2604 | 2604 | |
2605 | 2605 | /** |
@@ -2608,8 +2608,8 @@ discard block |
||
2608 | 2608 | * @since 1.0.19 |
2609 | 2609 | * @param string $value var rate. |
2610 | 2610 | */ |
2611 | - public function set_vat_rate( $value ) { |
|
2612 | - $this->set_prop( 'vat_rate', $value ); |
|
2611 | + public function set_vat_rate($value) { |
|
2612 | + $this->set_prop('vat_rate', $value); |
|
2613 | 2613 | } |
2614 | 2614 | |
2615 | 2615 | /** |
@@ -2618,8 +2618,8 @@ discard block |
||
2618 | 2618 | * @since 1.0.19 |
2619 | 2619 | * @param string $value var number. |
2620 | 2620 | */ |
2621 | - public function set_user_vat_rate( $value ) { |
|
2622 | - $this->set_vat_rate( $value ); |
|
2621 | + public function set_user_vat_rate($value) { |
|
2622 | + $this->set_vat_rate($value); |
|
2623 | 2623 | } |
2624 | 2624 | |
2625 | 2625 | /** |
@@ -2628,8 +2628,8 @@ discard block |
||
2628 | 2628 | * @since 1.0.19 |
2629 | 2629 | * @param string $value var number. |
2630 | 2630 | */ |
2631 | - public function set_customer_vat_rate( $value ) { |
|
2632 | - $this->set_vat_rate( $value ); |
|
2631 | + public function set_customer_vat_rate($value) { |
|
2632 | + $this->set_vat_rate($value); |
|
2633 | 2633 | } |
2634 | 2634 | |
2635 | 2635 | /** |
@@ -2638,8 +2638,8 @@ discard block |
||
2638 | 2638 | * @since 1.0.19 |
2639 | 2639 | * @param string $value address. |
2640 | 2640 | */ |
2641 | - public function set_address( $value ) { |
|
2642 | - $this->set_prop( 'address', $value ); |
|
2641 | + public function set_address($value) { |
|
2642 | + $this->set_prop('address', $value); |
|
2643 | 2643 | } |
2644 | 2644 | |
2645 | 2645 | /** |
@@ -2648,8 +2648,8 @@ discard block |
||
2648 | 2648 | * @since 1.0.19 |
2649 | 2649 | * @param string $value address. |
2650 | 2650 | */ |
2651 | - public function set_user_address( $value ) { |
|
2652 | - $this->set_address( $value ); |
|
2651 | + public function set_user_address($value) { |
|
2652 | + $this->set_address($value); |
|
2653 | 2653 | } |
2654 | 2654 | |
2655 | 2655 | /** |
@@ -2658,8 +2658,8 @@ discard block |
||
2658 | 2658 | * @since 1.0.19 |
2659 | 2659 | * @param string $value address. |
2660 | 2660 | */ |
2661 | - public function set_customer_address( $value ) { |
|
2662 | - $this->set_address( $value ); |
|
2661 | + public function set_customer_address($value) { |
|
2662 | + $this->set_address($value); |
|
2663 | 2663 | } |
2664 | 2664 | |
2665 | 2665 | /** |
@@ -2668,8 +2668,8 @@ discard block |
||
2668 | 2668 | * @since 1.0.19 |
2669 | 2669 | * @param int|bool $value confirmed. |
2670 | 2670 | */ |
2671 | - public function set_is_viewed( $value ) { |
|
2672 | - $this->set_prop( 'is_viewed', $value ); |
|
2671 | + public function set_is_viewed($value) { |
|
2672 | + $this->set_prop('is_viewed', $value); |
|
2673 | 2673 | } |
2674 | 2674 | |
2675 | 2675 | /** |
@@ -2678,8 +2678,8 @@ discard block |
||
2678 | 2678 | * @since 1.0.19 |
2679 | 2679 | * @param string $value email recipients. |
2680 | 2680 | */ |
2681 | - public function set_email_cc( $value ) { |
|
2682 | - $this->set_prop( 'email_cc', $value ); |
|
2681 | + public function set_email_cc($value) { |
|
2682 | + $this->set_prop('email_cc', $value); |
|
2683 | 2683 | } |
2684 | 2684 | |
2685 | 2685 | /** |
@@ -2688,9 +2688,9 @@ discard block |
||
2688 | 2688 | * @since 1.0.19 |
2689 | 2689 | * @param string $value template. |
2690 | 2690 | */ |
2691 | - public function set_template( $value ) { |
|
2692 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2693 | - $this->set_prop( 'template', $value ); |
|
2691 | + public function set_template($value) { |
|
2692 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2693 | + $this->set_prop('template', $value); |
|
2694 | 2694 | } |
2695 | 2695 | } |
2696 | 2696 | |
@@ -2701,8 +2701,8 @@ discard block |
||
2701 | 2701 | * @param string $value source. |
2702 | 2702 | * @deprecated |
2703 | 2703 | */ |
2704 | - public function created_via( $value ) { |
|
2705 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
2704 | + public function created_via($value) { |
|
2705 | + $this->set_created_via(sanitize_text_field($value)); |
|
2706 | 2706 | } |
2707 | 2707 | |
2708 | 2708 | /** |
@@ -2711,8 +2711,8 @@ discard block |
||
2711 | 2711 | * @since 1.0.19 |
2712 | 2712 | * @param string $value source. |
2713 | 2713 | */ |
2714 | - public function set_created_via( $value ) { |
|
2715 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2714 | + public function set_created_via($value) { |
|
2715 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2716 | 2716 | } |
2717 | 2717 | |
2718 | 2718 | /** |
@@ -2721,8 +2721,8 @@ discard block |
||
2721 | 2721 | * @since 1.0.19 |
2722 | 2722 | * @param int|bool $value confirmed. |
2723 | 2723 | */ |
2724 | - public function set_address_confirmed( $value ) { |
|
2725 | - $this->set_prop( 'address_confirmed', $value ); |
|
2724 | + public function set_address_confirmed($value) { |
|
2725 | + $this->set_prop('address_confirmed', $value); |
|
2726 | 2726 | } |
2727 | 2727 | |
2728 | 2728 | /** |
@@ -2731,8 +2731,8 @@ discard block |
||
2731 | 2731 | * @since 1.0.19 |
2732 | 2732 | * @param int|bool $value confirmed. |
2733 | 2733 | */ |
2734 | - public function set_user_address_confirmed( $value ) { |
|
2735 | - $this->set_address_confirmed( $value ); |
|
2734 | + public function set_user_address_confirmed($value) { |
|
2735 | + $this->set_address_confirmed($value); |
|
2736 | 2736 | } |
2737 | 2737 | |
2738 | 2738 | /** |
@@ -2741,8 +2741,8 @@ discard block |
||
2741 | 2741 | * @since 1.0.19 |
2742 | 2742 | * @param int|bool $value confirmed. |
2743 | 2743 | */ |
2744 | - public function set_customer_address_confirmed( $value ) { |
|
2745 | - $this->set_address_confirmed( $value ); |
|
2744 | + public function set_customer_address_confirmed($value) { |
|
2745 | + $this->set_address_confirmed($value); |
|
2746 | 2746 | } |
2747 | 2747 | |
2748 | 2748 | /** |
@@ -2751,8 +2751,8 @@ discard block |
||
2751 | 2751 | * @since 1.0.19 |
2752 | 2752 | * @param float $value sub total. |
2753 | 2753 | */ |
2754 | - public function set_subtotal( $value ) { |
|
2755 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
2754 | + public function set_subtotal($value) { |
|
2755 | + $this->set_prop('subtotal', max(0, $value)); |
|
2756 | 2756 | } |
2757 | 2757 | |
2758 | 2758 | /** |
@@ -2761,8 +2761,8 @@ discard block |
||
2761 | 2761 | * @since 1.0.19 |
2762 | 2762 | * @param float $value sub total. |
2763 | 2763 | */ |
2764 | - public function set_total( $value ) { |
|
2765 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
2764 | + public function set_total($value) { |
|
2765 | + $this->set_prop('total', max(0, $value)); |
|
2766 | 2766 | } |
2767 | 2767 | |
2768 | 2768 | /** |
@@ -2771,8 +2771,8 @@ discard block |
||
2771 | 2771 | * @since 1.0.19 |
2772 | 2772 | * @param float $value discount total. |
2773 | 2773 | */ |
2774 | - public function set_total_discount( $value ) { |
|
2775 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
2774 | + public function set_total_discount($value) { |
|
2775 | + $this->set_prop('total_discount', max(0, $value)); |
|
2776 | 2776 | } |
2777 | 2777 | |
2778 | 2778 | /** |
@@ -2781,8 +2781,8 @@ discard block |
||
2781 | 2781 | * @since 1.0.19 |
2782 | 2782 | * @param float $value discount total. |
2783 | 2783 | */ |
2784 | - public function set_discount( $value ) { |
|
2785 | - $this->set_total_discount( $value ); |
|
2784 | + public function set_discount($value) { |
|
2785 | + $this->set_total_discount($value); |
|
2786 | 2786 | } |
2787 | 2787 | |
2788 | 2788 | /** |
@@ -2791,8 +2791,8 @@ discard block |
||
2791 | 2791 | * @since 1.0.19 |
2792 | 2792 | * @param float $value tax total. |
2793 | 2793 | */ |
2794 | - public function set_total_tax( $value ) { |
|
2795 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
2794 | + public function set_total_tax($value) { |
|
2795 | + $this->set_prop('total_tax', max(0, $value)); |
|
2796 | 2796 | } |
2797 | 2797 | |
2798 | 2798 | /** |
@@ -2801,8 +2801,8 @@ discard block |
||
2801 | 2801 | * @since 1.0.19 |
2802 | 2802 | * @param float $value tax total. |
2803 | 2803 | */ |
2804 | - public function set_tax_total( $value ) { |
|
2805 | - $this->set_total_tax( $value ); |
|
2804 | + public function set_tax_total($value) { |
|
2805 | + $this->set_total_tax($value); |
|
2806 | 2806 | } |
2807 | 2807 | |
2808 | 2808 | /** |
@@ -2811,8 +2811,8 @@ discard block |
||
2811 | 2811 | * @since 1.0.19 |
2812 | 2812 | * @param float $value fees total. |
2813 | 2813 | */ |
2814 | - public function set_total_fees( $value ) { |
|
2815 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
2814 | + public function set_total_fees($value) { |
|
2815 | + $this->set_prop('total_fees', max(0, $value)); |
|
2816 | 2816 | } |
2817 | 2817 | |
2818 | 2818 | /** |
@@ -2821,8 +2821,8 @@ discard block |
||
2821 | 2821 | * @since 1.0.19 |
2822 | 2822 | * @param float $value fees total. |
2823 | 2823 | */ |
2824 | - public function set_fees_total( $value ) { |
|
2825 | - $this->set_total_fees( $value ); |
|
2824 | + public function set_fees_total($value) { |
|
2825 | + $this->set_total_fees($value); |
|
2826 | 2826 | } |
2827 | 2827 | |
2828 | 2828 | /** |
@@ -2831,13 +2831,13 @@ discard block |
||
2831 | 2831 | * @since 1.0.19 |
2832 | 2832 | * @param array $value fees. |
2833 | 2833 | */ |
2834 | - public function set_fees( $value ) { |
|
2834 | + public function set_fees($value) { |
|
2835 | 2835 | |
2836 | - if ( ! is_array( $value ) ) { |
|
2836 | + if (!is_array($value)) { |
|
2837 | 2837 | $value = array(); |
2838 | 2838 | } |
2839 | 2839 | |
2840 | - $this->set_prop( 'fees', $value ); |
|
2840 | + $this->set_prop('fees', $value); |
|
2841 | 2841 | |
2842 | 2842 | } |
2843 | 2843 | |
@@ -2847,13 +2847,13 @@ discard block |
||
2847 | 2847 | * @since 1.0.19 |
2848 | 2848 | * @param array $value taxes. |
2849 | 2849 | */ |
2850 | - public function set_taxes( $value ) { |
|
2850 | + public function set_taxes($value) { |
|
2851 | 2851 | |
2852 | - if ( ! is_array( $value ) ) { |
|
2852 | + if (!is_array($value)) { |
|
2853 | 2853 | $value = array(); |
2854 | 2854 | } |
2855 | 2855 | |
2856 | - $this->set_prop( 'taxes', $value ); |
|
2856 | + $this->set_prop('taxes', $value); |
|
2857 | 2857 | |
2858 | 2858 | } |
2859 | 2859 | |
@@ -2863,13 +2863,13 @@ discard block |
||
2863 | 2863 | * @since 1.0.19 |
2864 | 2864 | * @param array $value discounts. |
2865 | 2865 | */ |
2866 | - public function set_discounts( $value ) { |
|
2866 | + public function set_discounts($value) { |
|
2867 | 2867 | |
2868 | - if ( ! is_array( $value ) ) { |
|
2868 | + if (!is_array($value)) { |
|
2869 | 2869 | $value = array(); |
2870 | 2870 | } |
2871 | 2871 | |
2872 | - $this->set_prop( 'discounts', $value ); |
|
2872 | + $this->set_prop('discounts', $value); |
|
2873 | 2873 | } |
2874 | 2874 | |
2875 | 2875 | /** |
@@ -2878,19 +2878,19 @@ discard block |
||
2878 | 2878 | * @since 1.0.19 |
2879 | 2879 | * @param GetPaid_Form_Item[] $value items. |
2880 | 2880 | */ |
2881 | - public function set_items( $value ) { |
|
2881 | + public function set_items($value) { |
|
2882 | 2882 | |
2883 | 2883 | // Remove existing items. |
2884 | - $this->set_prop( 'items', array() ); |
|
2884 | + $this->set_prop('items', array()); |
|
2885 | 2885 | $this->recurring_item = null; |
2886 | 2886 | |
2887 | 2887 | // Ensure that we have an array. |
2888 | - if ( ! is_array( $value ) ) { |
|
2888 | + if (!is_array($value)) { |
|
2889 | 2889 | return; |
2890 | 2890 | } |
2891 | 2891 | |
2892 | - foreach ( $value as $item ) { |
|
2893 | - $this->add_item( $item ); |
|
2892 | + foreach ($value as $item) { |
|
2893 | + $this->add_item($item); |
|
2894 | 2894 | } |
2895 | 2895 | |
2896 | 2896 | } |
@@ -2901,8 +2901,8 @@ discard block |
||
2901 | 2901 | * @since 1.0.19 |
2902 | 2902 | * @param int $value payment form. |
2903 | 2903 | */ |
2904 | - public function set_payment_form( $value ) { |
|
2905 | - $this->set_prop( 'payment_form', $value ); |
|
2904 | + public function set_payment_form($value) { |
|
2905 | + $this->set_prop('payment_form', $value); |
|
2906 | 2906 | } |
2907 | 2907 | |
2908 | 2908 | /** |
@@ -2911,8 +2911,8 @@ discard block |
||
2911 | 2911 | * @since 1.0.19 |
2912 | 2912 | * @param string $value submission id. |
2913 | 2913 | */ |
2914 | - public function set_submission_id( $value ) { |
|
2915 | - $this->set_prop( 'submission_id', $value ); |
|
2914 | + public function set_submission_id($value) { |
|
2915 | + $this->set_prop('submission_id', $value); |
|
2916 | 2916 | } |
2917 | 2917 | |
2918 | 2918 | /** |
@@ -2921,8 +2921,8 @@ discard block |
||
2921 | 2921 | * @since 1.0.19 |
2922 | 2922 | * @param string $value discount code. |
2923 | 2923 | */ |
2924 | - public function set_discount_code( $value ) { |
|
2925 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
2924 | + public function set_discount_code($value) { |
|
2925 | + $this->set_prop('discount_code', sanitize_text_field($value)); |
|
2926 | 2926 | } |
2927 | 2927 | |
2928 | 2928 | /** |
@@ -2931,8 +2931,8 @@ discard block |
||
2931 | 2931 | * @since 1.0.19 |
2932 | 2932 | * @param string $value gateway. |
2933 | 2933 | */ |
2934 | - public function set_gateway( $value ) { |
|
2935 | - $this->set_prop( 'gateway', $value ); |
|
2934 | + public function set_gateway($value) { |
|
2935 | + $this->set_prop('gateway', $value); |
|
2936 | 2936 | } |
2937 | 2937 | |
2938 | 2938 | /** |
@@ -2941,9 +2941,9 @@ discard block |
||
2941 | 2941 | * @since 1.0.19 |
2942 | 2942 | * @param string $value transaction id. |
2943 | 2943 | */ |
2944 | - public function set_transaction_id( $value ) { |
|
2945 | - if ( ! empty( $value ) ) { |
|
2946 | - $this->set_prop( 'transaction_id', $value ); |
|
2944 | + public function set_transaction_id($value) { |
|
2945 | + if (!empty($value)) { |
|
2946 | + $this->set_prop('transaction_id', $value); |
|
2947 | 2947 | } |
2948 | 2948 | } |
2949 | 2949 | |
@@ -2953,8 +2953,8 @@ discard block |
||
2953 | 2953 | * @since 1.0.19 |
2954 | 2954 | * @param string $value currency id. |
2955 | 2955 | */ |
2956 | - public function set_currency( $value ) { |
|
2957 | - $this->set_prop( 'currency', $value ); |
|
2956 | + public function set_currency($value) { |
|
2957 | + $this->set_prop('currency', $value); |
|
2958 | 2958 | } |
2959 | 2959 | |
2960 | 2960 | /** |
@@ -2963,8 +2963,8 @@ discard block |
||
2963 | 2963 | * @since 1.0.19 |
2964 | 2964 | * @param bool $value value. |
2965 | 2965 | */ |
2966 | - public function set_disable_taxes( $value ) { |
|
2967 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2966 | + public function set_disable_taxes($value) { |
|
2967 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2968 | 2968 | } |
2969 | 2969 | |
2970 | 2970 | /** |
@@ -2973,8 +2973,8 @@ discard block |
||
2973 | 2973 | * @since 1.0.19 |
2974 | 2974 | * @param string $value subscription id. |
2975 | 2975 | */ |
2976 | - public function set_subscription_id( $value ) { |
|
2977 | - $this->set_prop( 'subscription_id', $value ); |
|
2976 | + public function set_subscription_id($value) { |
|
2977 | + $this->set_prop('subscription_id', $value); |
|
2978 | 2978 | } |
2979 | 2979 | |
2980 | 2980 | /** |
@@ -2983,8 +2983,8 @@ discard block |
||
2983 | 2983 | * @since 1.0.19 |
2984 | 2984 | * @param string $value subscription id. |
2985 | 2985 | */ |
2986 | - public function set_remote_subscription_id( $value ) { |
|
2987 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
2986 | + public function set_remote_subscription_id($value) { |
|
2987 | + $this->set_prop('remote_subscription_id', $value); |
|
2988 | 2988 | } |
2989 | 2989 | |
2990 | 2990 | /* |
@@ -3001,28 +3001,28 @@ discard block |
||
3001 | 3001 | */ |
3002 | 3002 | public function is_parent() { |
3003 | 3003 | $parent = $this->get_parent_id(); |
3004 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
3004 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
3005 | 3005 | } |
3006 | 3006 | |
3007 | 3007 | /** |
3008 | 3008 | * Checks if this is a renewal invoice. |
3009 | 3009 | */ |
3010 | 3010 | public function is_renewal() { |
3011 | - return ! $this->is_parent(); |
|
3011 | + return !$this->is_parent(); |
|
3012 | 3012 | } |
3013 | 3013 | |
3014 | 3014 | /** |
3015 | 3015 | * Checks if this is a recurring invoice. |
3016 | 3016 | */ |
3017 | 3017 | public function is_recurring() { |
3018 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
3018 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
3019 | 3019 | } |
3020 | 3020 | |
3021 | 3021 | /** |
3022 | 3022 | * Checks if this is a taxable invoice. |
3023 | 3023 | */ |
3024 | 3024 | public function is_taxable() { |
3025 | - return ! $this->get_disable_taxes(); |
|
3025 | + return !$this->get_disable_taxes(); |
|
3026 | 3026 | } |
3027 | 3027 | |
3028 | 3028 | /** |
@@ -3036,45 +3036,45 @@ discard block |
||
3036 | 3036 | * Checks to see if the invoice requires payment. |
3037 | 3037 | */ |
3038 | 3038 | public function is_free() { |
3039 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
3039 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
3040 | 3040 | |
3041 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
3041 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
3042 | 3042 | $is_free = false; |
3043 | 3043 | } |
3044 | 3044 | |
3045 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
3045 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
3046 | 3046 | } |
3047 | 3047 | |
3048 | 3048 | /** |
3049 | 3049 | * Checks if the invoice is paid. |
3050 | 3050 | */ |
3051 | 3051 | public function is_paid() { |
3052 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
3053 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
3052 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
3053 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
3054 | 3054 | } |
3055 | 3055 | |
3056 | 3056 | /** |
3057 | 3057 | * Checks if the invoice needs payment. |
3058 | 3058 | */ |
3059 | 3059 | public function needs_payment() { |
3060 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
3061 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
3060 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
3061 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
3062 | 3062 | } |
3063 | 3063 | |
3064 | 3064 | /** |
3065 | 3065 | * Checks if the invoice is refunded. |
3066 | 3066 | */ |
3067 | 3067 | public function is_refunded() { |
3068 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3069 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3068 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3069 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3070 | 3070 | } |
3071 | 3071 | |
3072 | 3072 | /** |
3073 | 3073 | * Checks if the invoice is held. |
3074 | 3074 | */ |
3075 | 3075 | public function is_held() { |
3076 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3077 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3076 | + $is_held = $this->has_status('wpi-onhold'); |
|
3077 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3078 | 3078 | } |
3079 | 3079 | |
3080 | 3080 | /** |
@@ -3082,30 +3082,30 @@ discard block |
||
3082 | 3082 | */ |
3083 | 3083 | public function is_due() { |
3084 | 3084 | $due_date = $this->get_due_date(); |
3085 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3085 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3086 | 3086 | } |
3087 | 3087 | |
3088 | 3088 | /** |
3089 | 3089 | * Checks if the invoice is draft. |
3090 | 3090 | */ |
3091 | 3091 | public function is_draft() { |
3092 | - return $this->has_status( 'draft, auto-draft' ); |
|
3092 | + return $this->has_status('draft, auto-draft'); |
|
3093 | 3093 | } |
3094 | 3094 | |
3095 | 3095 | /** |
3096 | 3096 | * Checks if the invoice has a given status. |
3097 | 3097 | */ |
3098 | - public function has_status( $status ) { |
|
3099 | - $status = wpinv_parse_list( $status ); |
|
3100 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3098 | + public function has_status($status) { |
|
3099 | + $status = wpinv_parse_list($status); |
|
3100 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3101 | 3101 | } |
3102 | 3102 | |
3103 | 3103 | /** |
3104 | 3104 | * Checks if the invoice is of a given type. |
3105 | 3105 | */ |
3106 | - public function is_type( $type ) { |
|
3107 | - $type = wpinv_parse_list( $type ); |
|
3108 | - return in_array( $this->get_type(), $type ); |
|
3106 | + public function is_type($type) { |
|
3107 | + $type = wpinv_parse_list($type); |
|
3108 | + return in_array($this->get_type(), $type); |
|
3109 | 3109 | } |
3110 | 3110 | |
3111 | 3111 | /** |
@@ -3137,8 +3137,8 @@ discard block |
||
3137 | 3137 | * |
3138 | 3138 | */ |
3139 | 3139 | public function is_initial_free() { |
3140 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3141 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3140 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3141 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3142 | 3142 | } |
3143 | 3143 | |
3144 | 3144 | /** |
@@ -3148,11 +3148,11 @@ discard block |
||
3148 | 3148 | public function item_has_free_trial() { |
3149 | 3149 | |
3150 | 3150 | // Ensure we have a recurring item. |
3151 | - if ( ! $this->is_recurring() ) { |
|
3151 | + if (!$this->is_recurring()) { |
|
3152 | 3152 | return false; |
3153 | 3153 | } |
3154 | 3154 | |
3155 | - $item = $this->get_recurring( true ); |
|
3155 | + $item = $this->get_recurring(true); |
|
3156 | 3156 | return $item->has_free_trial(); |
3157 | 3157 | } |
3158 | 3158 | |
@@ -3160,7 +3160,7 @@ discard block |
||
3160 | 3160 | * Check if the free trial is a result of a discount. |
3161 | 3161 | */ |
3162 | 3162 | public function is_free_trial_from_discount() { |
3163 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3163 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3164 | 3164 | } |
3165 | 3165 | |
3166 | 3166 | /** |
@@ -3168,12 +3168,12 @@ discard block |
||
3168 | 3168 | */ |
3169 | 3169 | public function discount_first_payment_only() { |
3170 | 3170 | |
3171 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
3172 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
3171 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
3172 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
3173 | 3173 | return true; |
3174 | 3174 | } |
3175 | 3175 | |
3176 | - return ! $discount->get_is_recurring(); |
|
3176 | + return !$discount->get_is_recurring(); |
|
3177 | 3177 | } |
3178 | 3178 | |
3179 | 3179 | /* |
@@ -3191,23 +3191,23 @@ discard block |
||
3191 | 3191 | * @param GetPaid_Form_Item|array $item |
3192 | 3192 | * @return WP_Error|Bool |
3193 | 3193 | */ |
3194 | - public function add_item( $item ) { |
|
3194 | + public function add_item($item) { |
|
3195 | 3195 | |
3196 | - if ( is_array( $item ) ) { |
|
3197 | - $item = $this->process_array_item( $item ); |
|
3196 | + if (is_array($item)) { |
|
3197 | + $item = $this->process_array_item($item); |
|
3198 | 3198 | } |
3199 | 3199 | |
3200 | - if ( is_numeric( $item ) ) { |
|
3201 | - $item = new GetPaid_Form_Item( $item ); |
|
3200 | + if (is_numeric($item)) { |
|
3201 | + $item = new GetPaid_Form_Item($item); |
|
3202 | 3202 | } |
3203 | 3203 | |
3204 | 3204 | // Make sure that it is available for purchase. |
3205 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3206 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3205 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3206 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3207 | 3207 | } |
3208 | 3208 | |
3209 | 3209 | // Do we have a recurring item? |
3210 | - if ( $item->is_recurring() ) { |
|
3210 | + if ($item->is_recurring()) { |
|
3211 | 3211 | $this->recurring_item = $item->get_id(); |
3212 | 3212 | } |
3213 | 3213 | |
@@ -3215,7 +3215,7 @@ discard block |
||
3215 | 3215 | $item->invoice_id = (int) $this->get_id(); |
3216 | 3216 | |
3217 | 3217 | // Remove duplicates. |
3218 | - $this->remove_item( $item->get_id() ); |
|
3218 | + $this->remove_item($item->get_id()); |
|
3219 | 3219 | |
3220 | 3220 | // Retrieve all items. |
3221 | 3221 | $items = $this->get_items(); |
@@ -3223,7 +3223,7 @@ discard block |
||
3223 | 3223 | // Add new item. |
3224 | 3224 | $items[] = $item; |
3225 | 3225 | |
3226 | - $this->set_prop( 'items', $items ); |
|
3226 | + $this->set_prop('items', $items); |
|
3227 | 3227 | |
3228 | 3228 | return true; |
3229 | 3229 | } |
@@ -3234,26 +3234,26 @@ discard block |
||
3234 | 3234 | * @since 1.0.19 |
3235 | 3235 | * @return GetPaid_Form_Item |
3236 | 3236 | */ |
3237 | - protected function process_array_item( $array ) { |
|
3237 | + protected function process_array_item($array) { |
|
3238 | 3238 | |
3239 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3240 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3239 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3240 | + $item = new GetPaid_Form_Item($item_id); |
|
3241 | 3241 | |
3242 | 3242 | // Set item data. |
3243 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3244 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3243 | + foreach (array('name', 'price', 'description') as $key) { |
|
3244 | + if (isset($array["item_$key"])) { |
|
3245 | 3245 | $method = "set_$key"; |
3246 | - $item->$method( $array[ "item_$key" ] ); |
|
3246 | + $item->$method($array["item_$key"]); |
|
3247 | 3247 | } |
3248 | 3248 | } |
3249 | 3249 | |
3250 | - if ( isset( $array['quantity'] ) ) { |
|
3251 | - $item->set_quantity( $array['quantity'] ); |
|
3250 | + if (isset($array['quantity'])) { |
|
3251 | + $item->set_quantity($array['quantity']); |
|
3252 | 3252 | } |
3253 | 3253 | |
3254 | 3254 | // Set item meta. |
3255 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3256 | - $item->set_item_meta( $array['meta'] ); |
|
3255 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3256 | + $item->set_item_meta($array['meta']); |
|
3257 | 3257 | } |
3258 | 3258 | |
3259 | 3259 | return $item; |
@@ -3266,10 +3266,10 @@ discard block |
||
3266 | 3266 | * @since 1.0.19 |
3267 | 3267 | * @return GetPaid_Form_Item|null |
3268 | 3268 | */ |
3269 | - public function get_item( $item_id ) { |
|
3269 | + public function get_item($item_id) { |
|
3270 | 3270 | |
3271 | - foreach ( $this->get_items() as $item ) { |
|
3272 | - if ( (int) $item_id == $item->get_id() ) { |
|
3271 | + foreach ($this->get_items() as $item) { |
|
3272 | + if ((int) $item_id == $item->get_id()) { |
|
3273 | 3273 | return $item; |
3274 | 3274 | } |
3275 | 3275 | } |
@@ -3282,16 +3282,16 @@ discard block |
||
3282 | 3282 | * |
3283 | 3283 | * @since 1.0.19 |
3284 | 3284 | */ |
3285 | - public function remove_item( $item_id ) { |
|
3285 | + public function remove_item($item_id) { |
|
3286 | 3286 | $items = $this->get_items(); |
3287 | 3287 | $item_id = (int) $item_id; |
3288 | 3288 | |
3289 | - foreach ( $items as $index => $item ) { |
|
3290 | - if ( (int) $item_id == $item->get_id() ) { |
|
3291 | - unset( $items[ $index ] ); |
|
3292 | - $this->set_prop( 'items', $items ); |
|
3289 | + foreach ($items as $index => $item) { |
|
3290 | + if ((int) $item_id == $item->get_id()) { |
|
3291 | + unset($items[$index]); |
|
3292 | + $this->set_prop('items', $items); |
|
3293 | 3293 | |
3294 | - if ( $item_id == $this->recurring_item ) { |
|
3294 | + if ($item_id == $this->recurring_item) { |
|
3295 | 3295 | $this->recurring_item = null; |
3296 | 3296 | } |
3297 | 3297 | |
@@ -3306,11 +3306,11 @@ discard block |
||
3306 | 3306 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3307 | 3307 | * @since 1.0.19 |
3308 | 3308 | */ |
3309 | - public function add_fee( $fee ) { |
|
3309 | + public function add_fee($fee) { |
|
3310 | 3310 | |
3311 | 3311 | $fees = $this->get_fees(); |
3312 | - $fees[ $fee['name'] ] = $fee; |
|
3313 | - $this->set_prop( 'fees', $fees ); |
|
3312 | + $fees[$fee['name']] = $fee; |
|
3313 | + $this->set_prop('fees', $fees); |
|
3314 | 3314 | |
3315 | 3315 | } |
3316 | 3316 | |
@@ -3319,9 +3319,9 @@ discard block |
||
3319 | 3319 | * |
3320 | 3320 | * @since 1.0.19 |
3321 | 3321 | */ |
3322 | - public function get_fee( $fee ) { |
|
3322 | + public function get_fee($fee) { |
|
3323 | 3323 | $fees = $this->get_fees(); |
3324 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3324 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3325 | 3325 | } |
3326 | 3326 | |
3327 | 3327 | /** |
@@ -3329,11 +3329,11 @@ discard block |
||
3329 | 3329 | * |
3330 | 3330 | * @since 1.0.19 |
3331 | 3331 | */ |
3332 | - public function remove_fee( $fee ) { |
|
3332 | + public function remove_fee($fee) { |
|
3333 | 3333 | $fees = $this->get_fees(); |
3334 | - if ( isset( $fees[ $fee ] ) ) { |
|
3335 | - unset( $fees[ $fee ] ); |
|
3336 | - $this->set_prop( 'fees', $fees ); |
|
3334 | + if (isset($fees[$fee])) { |
|
3335 | + unset($fees[$fee]); |
|
3336 | + $this->set_prop('fees', $fees); |
|
3337 | 3337 | } |
3338 | 3338 | } |
3339 | 3339 | |
@@ -3343,11 +3343,11 @@ discard block |
||
3343 | 3343 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3344 | 3344 | * @since 1.0.19 |
3345 | 3345 | */ |
3346 | - public function add_discount( $discount ) { |
|
3346 | + public function add_discount($discount) { |
|
3347 | 3347 | |
3348 | 3348 | $discounts = $this->get_discounts(); |
3349 | - $discounts[ $discount['name'] ] = $discount; |
|
3350 | - $this->set_prop( 'discounts', $discounts ); |
|
3349 | + $discounts[$discount['name']] = $discount; |
|
3350 | + $this->set_prop('discounts', $discounts); |
|
3351 | 3351 | |
3352 | 3352 | } |
3353 | 3353 | |
@@ -3357,15 +3357,15 @@ discard block |
||
3357 | 3357 | * @since 1.0.19 |
3358 | 3358 | * @return float |
3359 | 3359 | */ |
3360 | - public function get_discount( $discount = false ) { |
|
3360 | + public function get_discount($discount = false) { |
|
3361 | 3361 | |
3362 | 3362 | // Backwards compatibilty. |
3363 | - if ( empty( $discount ) ) { |
|
3363 | + if (empty($discount)) { |
|
3364 | 3364 | return $this->get_total_discount(); |
3365 | 3365 | } |
3366 | 3366 | |
3367 | 3367 | $discounts = $this->get_discounts(); |
3368 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3368 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3369 | 3369 | } |
3370 | 3370 | |
3371 | 3371 | /** |
@@ -3373,15 +3373,15 @@ discard block |
||
3373 | 3373 | * |
3374 | 3374 | * @since 1.0.19 |
3375 | 3375 | */ |
3376 | - public function remove_discount( $discount ) { |
|
3376 | + public function remove_discount($discount) { |
|
3377 | 3377 | $discounts = $this->get_discounts(); |
3378 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3379 | - unset( $discounts[ $discount ] ); |
|
3380 | - $this->set_prop( 'discounts', $discounts ); |
|
3378 | + if (isset($discounts[$discount])) { |
|
3379 | + unset($discounts[$discount]); |
|
3380 | + $this->set_prop('discounts', $discounts); |
|
3381 | 3381 | } |
3382 | 3382 | |
3383 | - if ( 'discount_code' == $discount ) { |
|
3384 | - foreach ( $this->get_items() as $item ) { |
|
3383 | + if ('discount_code' == $discount) { |
|
3384 | + foreach ($this->get_items() as $item) { |
|
3385 | 3385 | $item->item_discount = 0; |
3386 | 3386 | $item->recurring_item_discount = 0; |
3387 | 3387 | } |
@@ -3394,12 +3394,12 @@ discard block |
||
3394 | 3394 | * |
3395 | 3395 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3396 | 3396 | */ |
3397 | - public function add_tax( $tax ) { |
|
3398 | - if ( $this->is_taxable() ) { |
|
3397 | + public function add_tax($tax) { |
|
3398 | + if ($this->is_taxable()) { |
|
3399 | 3399 | |
3400 | - $taxes = $this->get_taxes(); |
|
3401 | - $taxes[ $tax['name'] ] = $tax; |
|
3402 | - $this->set_prop( 'taxes', $tax ); |
|
3400 | + $taxes = $this->get_taxes(); |
|
3401 | + $taxes[$tax['name']] = $tax; |
|
3402 | + $this->set_prop('taxes', $tax); |
|
3403 | 3403 | |
3404 | 3404 | } |
3405 | 3405 | } |
@@ -3409,15 +3409,15 @@ discard block |
||
3409 | 3409 | * |
3410 | 3410 | * @since 1.0.19 |
3411 | 3411 | */ |
3412 | - public function get_tax( $tax = null ) { |
|
3412 | + public function get_tax($tax = null) { |
|
3413 | 3413 | |
3414 | 3414 | // Backwards compatility. |
3415 | - if ( empty( $tax ) ) { |
|
3415 | + if (empty($tax)) { |
|
3416 | 3416 | return $this->get_total_tax(); |
3417 | 3417 | } |
3418 | 3418 | |
3419 | 3419 | $taxes = $this->get_taxes(); |
3420 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3420 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3421 | 3421 | } |
3422 | 3422 | |
3423 | 3423 | /** |
@@ -3425,11 +3425,11 @@ discard block |
||
3425 | 3425 | * |
3426 | 3426 | * @since 1.0.19 |
3427 | 3427 | */ |
3428 | - public function remove_tax( $tax ) { |
|
3428 | + public function remove_tax($tax) { |
|
3429 | 3429 | $taxes = $this->get_taxes(); |
3430 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3431 | - unset( $taxes[ $tax ] ); |
|
3432 | - $this->set_prop( 'taxes', $taxes ); |
|
3430 | + if (isset($taxes[$tax])) { |
|
3431 | + unset($taxes[$tax]); |
|
3432 | + $this->set_prop('taxes', $taxes); |
|
3433 | 3433 | } |
3434 | 3434 | } |
3435 | 3435 | |
@@ -3440,22 +3440,22 @@ discard block |
||
3440 | 3440 | * @return float The recalculated subtotal |
3441 | 3441 | */ |
3442 | 3442 | public function recalculate_subtotal() { |
3443 | - $items = $this->get_items(); |
|
3443 | + $items = $this->get_items(); |
|
3444 | 3444 | $subtotal = 0; |
3445 | 3445 | $recurring = 0; |
3446 | 3446 | |
3447 | - foreach ( $items as $item ) { |
|
3447 | + foreach ($items as $item) { |
|
3448 | 3448 | $subtotal += $item->get_sub_total(); |
3449 | 3449 | $recurring += $item->get_recurring_sub_total(); |
3450 | 3450 | } |
3451 | 3451 | |
3452 | - if ( wpinv_prices_include_tax() ) { |
|
3453 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
3454 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
3452 | + if (wpinv_prices_include_tax()) { |
|
3453 | + $subtotal = max(0, $subtotal - $this->totals['tax']['initial']); |
|
3454 | + $recurring = max(0, $recurring - $this->totals['tax']['recurring']); |
|
3455 | 3455 | } |
3456 | 3456 | |
3457 | 3457 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3458 | - $this->set_subtotal( $current ); |
|
3458 | + $this->set_subtotal($current); |
|
3459 | 3459 | |
3460 | 3460 | $this->totals['subtotal'] = array( |
3461 | 3461 | 'initial' => $subtotal, |
@@ -3476,14 +3476,14 @@ discard block |
||
3476 | 3476 | $discount = 0; |
3477 | 3477 | $recurring = 0; |
3478 | 3478 | |
3479 | - foreach ( $discounts as $data ) { |
|
3480 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3481 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3479 | + foreach ($discounts as $data) { |
|
3480 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3481 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3482 | 3482 | } |
3483 | 3483 | |
3484 | 3484 | $current = $this->is_renewal() ? $recurring : $discount; |
3485 | 3485 | |
3486 | - $this->set_total_discount( $current ); |
|
3486 | + $this->set_total_discount($current); |
|
3487 | 3487 | |
3488 | 3488 | $this->totals['discount'] = array( |
3489 | 3489 | 'initial' => $discount, |
@@ -3504,13 +3504,13 @@ discard block |
||
3504 | 3504 | |
3505 | 3505 | // Maybe disable taxes. |
3506 | 3506 | $vat_number = $this->get_vat_number(); |
3507 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
3507 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number); |
|
3508 | 3508 | |
3509 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
3509 | + if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
3510 | 3510 | $skip_tax = false; |
3511 | 3511 | } |
3512 | 3512 | |
3513 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
3513 | + if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) { |
|
3514 | 3514 | |
3515 | 3515 | $this->totals['tax'] = array( |
3516 | 3516 | 'initial' => 0, |
@@ -3519,38 +3519,38 @@ discard block |
||
3519 | 3519 | |
3520 | 3520 | $this->tax_rate = 0; |
3521 | 3521 | |
3522 | - $this->set_taxes( array() ); |
|
3522 | + $this->set_taxes(array()); |
|
3523 | 3523 | $current = 0; |
3524 | 3524 | } else { |
3525 | 3525 | |
3526 | 3526 | $item_taxes = array(); |
3527 | 3527 | |
3528 | - foreach ( $this->get_items() as $item ) { |
|
3529 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
3530 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
3531 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
3532 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
3533 | - foreach ( $taxes as $name => $amount ) { |
|
3534 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
3535 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
3536 | - |
|
3537 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
3538 | - $item_taxes[ $name ] = $tax; |
|
3528 | + foreach ($this->get_items() as $item) { |
|
3529 | + $rates = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state()); |
|
3530 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
3531 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
3532 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
3533 | + foreach ($taxes as $name => $amount) { |
|
3534 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
3535 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
3536 | + |
|
3537 | + if (!isset($item_taxes[$name])) { |
|
3538 | + $item_taxes[$name] = $tax; |
|
3539 | 3539 | continue; |
3540 | 3540 | } |
3541 | 3541 | |
3542 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
3543 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
3542 | + $item_taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
3543 | + $item_taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
3544 | 3544 | |
3545 | 3545 | } |
3546 | 3546 | |
3547 | 3547 | } |
3548 | 3548 | |
3549 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
3550 | - $this->set_taxes( $item_taxes ); |
|
3549 | + $item_taxes = array_replace($this->get_taxes(), $item_taxes); |
|
3550 | + $this->set_taxes($item_taxes); |
|
3551 | 3551 | |
3552 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
3553 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
3552 | + $initial_tax = array_sum(wp_list_pluck($item_taxes, 'initial_tax')); |
|
3553 | + $recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax')); |
|
3554 | 3554 | |
3555 | 3555 | $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
3556 | 3556 | |
@@ -3561,7 +3561,7 @@ discard block |
||
3561 | 3561 | |
3562 | 3562 | } |
3563 | 3563 | |
3564 | - $this->set_total_tax( $current ); |
|
3564 | + $this->set_total_tax($current); |
|
3565 | 3565 | |
3566 | 3566 | return $current; |
3567 | 3567 | |
@@ -3578,20 +3578,20 @@ discard block |
||
3578 | 3578 | $fee = 0; |
3579 | 3579 | $recurring = 0; |
3580 | 3580 | |
3581 | - foreach ( $fees as $data ) { |
|
3582 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3583 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3581 | + foreach ($fees as $data) { |
|
3582 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3583 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3584 | 3584 | } |
3585 | 3585 | |
3586 | 3586 | $current = $this->is_renewal() ? $recurring : $fee; |
3587 | - $this->set_total_fees( $current ); |
|
3587 | + $this->set_total_fees($current); |
|
3588 | 3588 | |
3589 | 3589 | $this->totals['fee'] = array( |
3590 | 3590 | 'initial' => $fee, |
3591 | 3591 | 'recurring' => $recurring, |
3592 | 3592 | ); |
3593 | 3593 | |
3594 | - $this->set_total_fees( $fee ); |
|
3594 | + $this->set_total_fees($fee); |
|
3595 | 3595 | return $current; |
3596 | 3596 | } |
3597 | 3597 | |
@@ -3606,7 +3606,7 @@ discard block |
||
3606 | 3606 | $this->recalculate_total_discount(); |
3607 | 3607 | $this->recalculate_total_tax(); |
3608 | 3608 | $this->recalculate_subtotal(); |
3609 | - $this->set_total( $this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount() ); |
|
3609 | + $this->set_total($this->get_total_tax() + $this->get_total_fees() + $this->get_subtotal() - $this->get_total_discount()); |
|
3610 | 3610 | return $this->get_total(); |
3611 | 3611 | } |
3612 | 3612 | |
@@ -3615,7 +3615,7 @@ discard block |
||
3615 | 3615 | */ |
3616 | 3616 | public function recalculate_totals() { |
3617 | 3617 | $this->recalculate_total(); |
3618 | - $this->save( true ); |
|
3618 | + $this->save(true); |
|
3619 | 3619 | return $this; |
3620 | 3620 | } |
3621 | 3621 | |
@@ -3633,10 +3633,10 @@ discard block |
||
3633 | 3633 | * @return int|false The new note's ID on success, false on failure. |
3634 | 3634 | * |
3635 | 3635 | */ |
3636 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3636 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3637 | 3637 | |
3638 | 3638 | // Bail if no note specified or this invoice is not yet saved. |
3639 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3639 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3640 | 3640 | return false; |
3641 | 3641 | } |
3642 | 3642 | |
@@ -3644,23 +3644,23 @@ discard block |
||
3644 | 3644 | $author_email = '[email protected]'; |
3645 | 3645 | |
3646 | 3646 | // If this is an admin comment or it has been added by the user. |
3647 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3648 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3647 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3648 | + $user = get_user_by('id', get_current_user_id()); |
|
3649 | 3649 | $author = $user->display_name; |
3650 | 3650 | $author_email = $user->user_email; |
3651 | 3651 | } |
3652 | 3652 | |
3653 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3653 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3654 | 3654 | |
3655 | 3655 | } |
3656 | 3656 | |
3657 | 3657 | /** |
3658 | 3658 | * Generates a unique key for the invoice. |
3659 | 3659 | */ |
3660 | - public function generate_key( $string = '' ) { |
|
3661 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3660 | + public function generate_key($string = '') { |
|
3661 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3662 | 3662 | return strtolower( |
3663 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3663 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3664 | 3664 | ); |
3665 | 3665 | } |
3666 | 3666 | |
@@ -3670,11 +3670,11 @@ discard block |
||
3670 | 3670 | public function generate_number() { |
3671 | 3671 | $number = $this->get_id(); |
3672 | 3672 | |
3673 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3674 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3673 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3674 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3675 | 3675 | } |
3676 | 3676 | |
3677 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3677 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3678 | 3678 | |
3679 | 3679 | } |
3680 | 3680 | |
@@ -3687,55 +3687,55 @@ discard block |
||
3687 | 3687 | // Reset status transition variable. |
3688 | 3688 | $this->status_transition = false; |
3689 | 3689 | |
3690 | - if ( $status_transition ) { |
|
3690 | + if ($status_transition) { |
|
3691 | 3691 | try { |
3692 | 3692 | |
3693 | 3693 | // Fire a hook for the status change. |
3694 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3694 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3695 | 3695 | |
3696 | 3696 | // @deprecated this is deprecated and will be removed in the future. |
3697 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3697 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3698 | 3698 | |
3699 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3699 | + if (!empty($status_transition['from'])) { |
|
3700 | 3700 | |
3701 | 3701 | /* translators: 1: old invoice status 2: new invoice status */ |
3702 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3702 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
3703 | 3703 | |
3704 | 3704 | // Fire another hook. |
3705 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3706 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3705 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3706 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3707 | 3707 | |
3708 | 3708 | // @deprecated this is deprecated and will be removed in the future. |
3709 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3709 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3710 | 3710 | |
3711 | 3711 | // Note the transition occurred. |
3712 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3712 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3713 | 3713 | |
3714 | 3714 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3715 | 3715 | if ( |
3716 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3717 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3716 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3717 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3718 | 3718 | ) { |
3719 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3719 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3720 | 3720 | } |
3721 | 3721 | |
3722 | 3722 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3723 | 3723 | if ( |
3724 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3725 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3724 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3725 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3726 | 3726 | ) { |
3727 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3727 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3728 | 3728 | } |
3729 | 3729 | } else { |
3730 | 3730 | /* translators: %s: new invoice status */ |
3731 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3731 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
3732 | 3732 | |
3733 | 3733 | // Note the transition occurred. |
3734 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3734 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3735 | 3735 | |
3736 | 3736 | } |
3737 | - } catch ( Exception $e ) { |
|
3738 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3737 | + } catch (Exception $e) { |
|
3738 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3739 | 3739 | } |
3740 | 3740 | } |
3741 | 3741 | } |
@@ -3743,13 +3743,13 @@ discard block |
||
3743 | 3743 | /** |
3744 | 3744 | * Updates an invoice status. |
3745 | 3745 | */ |
3746 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3746 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3747 | 3747 | |
3748 | 3748 | // Fires before updating a status. |
3749 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3749 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3750 | 3750 | |
3751 | 3751 | // Update the status. |
3752 | - $this->set_status( $new_status, $note, $manual ); |
|
3752 | + $this->set_status($new_status, $note, $manual); |
|
3753 | 3753 | |
3754 | 3754 | // Save the order. |
3755 | 3755 | return $this->save(); |
@@ -3760,18 +3760,18 @@ discard block |
||
3760 | 3760 | * @deprecated |
3761 | 3761 | */ |
3762 | 3762 | public function refresh_item_ids() { |
3763 | - $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
|
3764 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3763 | + $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id'))); |
|
3764 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3765 | 3765 | } |
3766 | 3766 | |
3767 | 3767 | /** |
3768 | 3768 | * @deprecated |
3769 | 3769 | */ |
3770 | - public function update_items( $temp = false ) { |
|
3770 | + public function update_items($temp = false) { |
|
3771 | 3771 | |
3772 | - $this->set_items( $this->get_items() ); |
|
3772 | + $this->set_items($this->get_items()); |
|
3773 | 3773 | |
3774 | - if ( ! $temp ) { |
|
3774 | + if (!$temp) { |
|
3775 | 3775 | $this->save(); |
3776 | 3776 | } |
3777 | 3777 | |
@@ -3785,11 +3785,11 @@ discard block |
||
3785 | 3785 | |
3786 | 3786 | $discount_code = $this->get_discount_code(); |
3787 | 3787 | |
3788 | - if ( empty( $discount_code ) ) { |
|
3788 | + if (empty($discount_code)) { |
|
3789 | 3789 | return false; |
3790 | 3790 | } |
3791 | 3791 | |
3792 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3792 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3793 | 3793 | |
3794 | 3794 | // Ensure it is active. |
3795 | 3795 | return $discount->exists(); |
@@ -3800,7 +3800,7 @@ discard block |
||
3800 | 3800 | * Refunds an invoice. |
3801 | 3801 | */ |
3802 | 3802 | public function refund() { |
3803 | - $this->set_status( 'wpi-refunded' ); |
|
3803 | + $this->set_status('wpi-refunded'); |
|
3804 | 3804 | $this->save(); |
3805 | 3805 | } |
3806 | 3806 | |
@@ -3809,53 +3809,53 @@ discard block |
||
3809 | 3809 | * |
3810 | 3810 | * @param string $transaction_id |
3811 | 3811 | */ |
3812 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3812 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3813 | 3813 | |
3814 | 3814 | // Set the transaction id. |
3815 | - if ( empty( $transaction_id ) ) { |
|
3815 | + if (empty($transaction_id)) { |
|
3816 | 3816 | $transaction_id = $this->generate_key('trans_'); |
3817 | 3817 | } |
3818 | 3818 | |
3819 | - if ( ! $this->get_transaction_id() ) { |
|
3820 | - $this->set_transaction_id( $transaction_id ); |
|
3819 | + if (!$this->get_transaction_id()) { |
|
3820 | + $this->set_transaction_id($transaction_id); |
|
3821 | 3821 | } |
3822 | 3822 | |
3823 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3823 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3824 | 3824 | return $this->save(); |
3825 | 3825 | } |
3826 | 3826 | |
3827 | 3827 | // Set the completed date. |
3828 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3828 | + $this->set_date_completed(current_time('mysql')); |
|
3829 | 3829 | |
3830 | 3830 | // Set the new status. |
3831 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
3832 | - if ( $this->is_renewal() ) { |
|
3831 | + $gateway = sanitize_text_field($this->get_gateway_title()); |
|
3832 | + if ($this->is_renewal()) { |
|
3833 | 3833 | |
3834 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
3835 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3834 | + $_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway); |
|
3835 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3836 | 3836 | |
3837 | - if ( 'none' == $this->get_gateway() ) { |
|
3837 | + if ('none' == $this->get_gateway()) { |
|
3838 | 3838 | $_note = $note; |
3839 | 3839 | } |
3840 | 3840 | |
3841 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3841 | + $this->set_status('wpi-renewal', $_note); |
|
3842 | 3842 | |
3843 | 3843 | } else { |
3844 | 3844 | |
3845 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
3846 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3845 | + $_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway); |
|
3846 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3847 | 3847 | |
3848 | - if ( 'none' == $this->get_gateway() ) { |
|
3848 | + if ('none' == $this->get_gateway()) { |
|
3849 | 3849 | $_note = $note; |
3850 | 3850 | } |
3851 | 3851 | |
3852 | - $this->set_status( 'publish', $_note ); |
|
3852 | + $this->set_status('publish', $_note); |
|
3853 | 3853 | |
3854 | 3854 | } |
3855 | 3855 | |
3856 | 3856 | // Set checkout mode. |
3857 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3858 | - $this->set_mode( $mode ); |
|
3857 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3858 | + $this->set_mode($mode); |
|
3859 | 3859 | |
3860 | 3860 | // Save the invoice. |
3861 | 3861 | $this->save(); |
@@ -3880,9 +3880,9 @@ discard block |
||
3880 | 3880 | * Clears the subscription's cache. |
3881 | 3881 | */ |
3882 | 3882 | public function clear_cache() { |
3883 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
3884 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
3885 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
3883 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
3884 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
3885 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
3886 | 3886 | } |
3887 | 3887 | |
3888 | 3888 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | * @return WPInv_Subscription[]|WPInv_Subscription|false |
14 | 14 | * @since 2.3.0 |
15 | 15 | */ |
16 | -function getpaid_get_invoice_subscriptions( $invoice ) { |
|
16 | +function getpaid_get_invoice_subscriptions($invoice) { |
|
17 | 17 | |
18 | 18 | // Retrieve subscription groups. |
19 | - $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice ), 'subscription_id' ); |
|
19 | + $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice), 'subscription_id'); |
|
20 | 20 | |
21 | 21 | // No subscription groups, normal subscription. |
22 | - if ( empty( $subscription_ids ) ) { |
|
23 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
22 | + if (empty($subscription_ids)) { |
|
23 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // Subscription groups. |
27 | - return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) ); |
|
27 | + return array_filter(array_map('getpaid_get_subscription', $subscription_ids)); |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @return array |
36 | 36 | * @since 2.3.0 |
37 | 37 | */ |
38 | -function getpaid_get_invoice_subscription_groups( $invoice ) { |
|
39 | - $subscription_groups = get_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', true ); |
|
40 | - return empty( $subscription_groups ) ? array() : $subscription_groups; |
|
38 | +function getpaid_get_invoice_subscription_groups($invoice) { |
|
39 | + $subscription_groups = get_post_meta($invoice->get_id(), 'getpaid_subscription_groups', true); |
|
40 | + return empty($subscription_groups) ? array() : $subscription_groups; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @since 2.3.0 |
48 | 48 | * @return WPInv_Subscription|false |
49 | 49 | */ |
50 | -function getpaid_get_subscription( $subscription ) { |
|
51 | - $subscription = new WPInv_Subscription( $subscription ); |
|
50 | +function getpaid_get_subscription($subscription) { |
|
51 | + $subscription = new WPInv_Subscription($subscription); |
|
52 | 52 | return $subscription->exists() ? $subscription : false; |
53 | 53 | } |
54 | 54 | |
@@ -61,26 +61,26 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
63 | 63 | */ |
64 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
64 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
65 | 65 | |
66 | 66 | // Do not retrieve all fields if we just want the count. |
67 | - if ( 'count' == $return ) { |
|
67 | + if ('count' == $return) { |
|
68 | 68 | $args['fields'] = 'id'; |
69 | 69 | $args['number'] = 1; |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Do not count all matches if we just want the results. |
73 | - if ( 'results' == $return ) { |
|
73 | + if ('results' == $return) { |
|
74 | 74 | $args['count_total'] = false; |
75 | 75 | } |
76 | 76 | |
77 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
77 | + $query = new GetPaid_Subscriptions_Query($args); |
|
78 | 78 | |
79 | - if ( 'results' == $return ) { |
|
79 | + if ('results' == $return) { |
|
80 | 80 | return $query->get_results(); |
81 | 81 | } |
82 | 82 | |
83 | - if ( 'count' == $return ) { |
|
83 | + if ('count' == $return) { |
|
84 | 84 | return $query->get_total(); |
85 | 85 | } |
86 | 86 | |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | return apply_filters( |
98 | 98 | 'getpaid_get_subscription_statuses', |
99 | 99 | array( |
100 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
101 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
102 | - 'active' => __( 'Active', 'invoicing' ), |
|
103 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
104 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
105 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
106 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
100 | + 'pending' => __('Pending', 'invoicing'), |
|
101 | + 'trialling' => __('Trialing', 'invoicing'), |
|
102 | + 'active' => __('Active', 'invoicing'), |
|
103 | + 'failing' => __('Failing', 'invoicing'), |
|
104 | + 'expired' => __('Expired', 'invoicing'), |
|
105 | + 'completed' => __('Complete', 'invoicing'), |
|
106 | + 'cancelled' => __('Cancelled', 'invoicing'), |
|
107 | 107 | ) |
108 | 108 | ); |
109 | 109 | |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string |
116 | 116 | */ |
117 | -function getpaid_get_subscription_status_label( $status ) { |
|
117 | +function getpaid_get_subscription_status_label($status) { |
|
118 | 118 | $statuses = getpaid_get_subscription_statuses(); |
119 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
119 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status)); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return array |
148 | 148 | */ |
149 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
149 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
150 | 150 | |
151 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
151 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
152 | 152 | $counts = array(); |
153 | 153 | |
154 | - foreach ( $statuses as $status ) { |
|
155 | - $_args = wp_parse_args( "status=$status", $args ); |
|
156 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
154 | + foreach ($statuses as $status) { |
|
155 | + $_args = wp_parse_args("status=$status", $args); |
|
156 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $counts; |
@@ -172,23 +172,23 @@ discard block |
||
172 | 172 | array( |
173 | 173 | |
174 | 174 | 'day' => array( |
175 | - 'singular' => __( '%s day', 'invoicing' ), |
|
176 | - 'plural' => __( '%d days', 'invoicing' ), |
|
175 | + 'singular' => __('%s day', 'invoicing'), |
|
176 | + 'plural' => __('%d days', 'invoicing'), |
|
177 | 177 | ), |
178 | 178 | |
179 | 179 | 'week' => array( |
180 | - 'singular' => __( '%s week', 'invoicing' ), |
|
181 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
180 | + 'singular' => __('%s week', 'invoicing'), |
|
181 | + 'plural' => __('%d weeks', 'invoicing'), |
|
182 | 182 | ), |
183 | 183 | |
184 | 184 | 'month' => array( |
185 | - 'singular' => __( '%s month', 'invoicing' ), |
|
186 | - 'plural' => __( '%d months', 'invoicing' ), |
|
185 | + 'singular' => __('%s month', 'invoicing'), |
|
186 | + 'plural' => __('%d months', 'invoicing'), |
|
187 | 187 | ), |
188 | 188 | |
189 | 189 | 'year' => array( |
190 | - 'singular' => __( '%s year', 'invoicing' ), |
|
191 | - 'plural' => __( '%d years', 'invoicing' ), |
|
190 | + 'singular' => __('%s year', 'invoicing'), |
|
191 | + 'plural' => __('%d years', 'invoicing'), |
|
192 | 192 | ), |
193 | 193 | |
194 | 194 | ) |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | * @param string $trial_period |
203 | 203 | * @return int |
204 | 204 | */ |
205 | -function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
|
206 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
205 | +function getpaid_get_subscription_trial_period_interval($trial_period) { |
|
206 | + return (int) preg_replace('/[^0-9]/', '', $trial_period); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $trial_period |
213 | 213 | * @return string |
214 | 214 | */ |
215 | -function getpaid_get_subscription_trial_period_period( $trial_period ) { |
|
216 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
215 | +function getpaid_get_subscription_trial_period_period($trial_period) { |
|
216 | + return preg_replace('/[^a-z]/', '', strtolower($trial_period)); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @param int $interval |
224 | 224 | * @return string |
225 | 225 | */ |
226 | -function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
|
227 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
228 | - return strtolower( sanitize_text_field( $label ) ); |
|
226 | +function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') { |
|
227 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix); |
|
228 | + return strtolower(sanitize_text_field($label)); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -234,19 +234,19 @@ discard block |
||
234 | 234 | * @param string $period |
235 | 235 | * @return string |
236 | 236 | */ |
237 | -function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
|
237 | +function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') { |
|
238 | 238 | |
239 | 239 | $periods = getpaid_get_subscription_periods(); |
240 | - $period = strtolower( $period ); |
|
240 | + $period = strtolower($period); |
|
241 | 241 | |
242 | - if ( isset( $periods[ $period ] ) ) { |
|
243 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
242 | + if (isset($periods[$period])) { |
|
243 | + return sprintf($periods[$period]['singular'], $singular_prefix); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Backwards compatibility. |
247 | - foreach ( $periods as $key => $data ) { |
|
248 | - if ( strpos( $key, $period ) === 0 ) { |
|
249 | - return sprintf( $data['singular'], $singular_prefix ); |
|
247 | + foreach ($periods as $key => $data) { |
|
248 | + if (strpos($key, $period) === 0) { |
|
249 | + return sprintf($data['singular'], $singular_prefix); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -261,19 +261,19 @@ discard block |
||
261 | 261 | * @param int $interval |
262 | 262 | * @return string |
263 | 263 | */ |
264 | -function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
|
264 | +function getpaid_get_plural_subscription_period_label($period, $interval) { |
|
265 | 265 | |
266 | 266 | $periods = getpaid_get_subscription_periods(); |
267 | - $period = strtolower( $period ); |
|
267 | + $period = strtolower($period); |
|
268 | 268 | |
269 | - if ( isset( $periods[ $period ] ) ) { |
|
270 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
269 | + if (isset($periods[$period])) { |
|
270 | + return sprintf($periods[$period]['plural'], $interval); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Backwards compatibility. |
274 | - foreach ( $periods as $key => $data ) { |
|
275 | - if ( strpos( $key, $period ) === 0 ) { |
|
276 | - return sprintf( $data['plural'], $interval ); |
|
274 | + foreach ($periods as $key => $data) { |
|
275 | + if (strpos($key, $period) === 0) { |
|
276 | + return sprintf($data['plural'], $interval); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -287,32 +287,32 @@ discard block |
||
287 | 287 | * @param WPInv_Subscription $subscription |
288 | 288 | * @return string |
289 | 289 | */ |
290 | -function getpaid_get_formatted_subscription_amount( $subscription ) { |
|
290 | +function getpaid_get_formatted_subscription_amount($subscription) { |
|
291 | 291 | |
292 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
293 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
294 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
292 | + $initial = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
293 | + $recurring = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
294 | + $period = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
295 | 295 | $bill_times = $subscription->get_bill_times(); |
296 | 296 | |
297 | - if ( ! empty( $bill_times ) ) { |
|
297 | + if (!empty($bill_times)) { |
|
298 | 298 | $bill_times = $subscription->get_frequency() * $bill_times; |
299 | - $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times ); |
|
299 | + $bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Trial periods. |
303 | - if ( $subscription->has_trial_period() ) { |
|
303 | + if ($subscription->has_trial_period()) { |
|
304 | 304 | |
305 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
306 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
305 | + $trial_period = getpaid_get_subscription_trial_period_period($subscription->get_trial_period()); |
|
306 | + $trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period()); |
|
307 | 307 | |
308 | - if ( empty( $bill_times ) ) { |
|
308 | + if (empty($bill_times)) { |
|
309 | 309 | |
310 | 310 | return sprintf( |
311 | 311 | |
312 | 312 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
313 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
313 | + _x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
314 | 314 | $initial, |
315 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
315 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
316 | 316 | $recurring, |
317 | 317 | $period |
318 | 318 | |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | return sprintf( |
324 | 324 | |
325 | 325 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times |
326 | - _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
326 | + _x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
327 | 327 | $initial, |
328 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
328 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
329 | 329 | $recurring, |
330 | 330 | $period, |
331 | 331 | $bill_times |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | - if ( $initial != $recurring ) { |
|
336 | + if ($initial != $recurring) { |
|
337 | 337 | |
338 | - if ( empty( $bill_times ) ) { |
|
338 | + if (empty($bill_times)) { |
|
339 | 339 | |
340 | 340 | return sprintf( |
341 | 341 | |
342 | 342 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
343 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
343 | + _x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'), |
|
344 | 344 | $initial, |
345 | 345 | $recurring, |
346 | 346 | $period |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | return sprintf( |
353 | 353 | |
354 | 354 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times |
355 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ), |
|
355 | + _x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'), |
|
356 | 356 | $initial, |
357 | 357 | $recurring, |
358 | 358 | $period, |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | - if ( empty( $bill_times ) ) { |
|
365 | + if (empty($bill_times)) { |
|
366 | 366 | |
367 | 367 | return sprintf( |
368 | 368 | |
369 | 369 | // translators: $1: is the recurring amount, $2: is the recurring period |
370 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
370 | + _x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
371 | 371 | $initial, |
372 | 372 | $period |
373 | 373 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | return sprintf( |
379 | 379 | |
380 | 380 | // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period |
381 | - _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
381 | + _x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
382 | 382 | $bill_times, |
383 | 383 | $initial, |
384 | 384 | $period |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param WPInv_Invoice $invoice |
394 | 394 | * @return WPInv_Subscription|bool |
395 | 395 | */ |
396 | -function getpaid_get_invoice_subscription( $invoice ) { |
|
397 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
396 | +function getpaid_get_invoice_subscription($invoice) { |
|
397 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @param WPInv_Invoice $invoice |
404 | 404 | */ |
405 | -function getpaid_activate_invoice_subscription( $invoice ) { |
|
406 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
407 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
405 | +function getpaid_activate_invoice_subscription($invoice) { |
|
406 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
407 | + if (is_a($subscription, 'WPInv_Subscription')) { |
|
408 | 408 | $subscription->activate(); |
409 | 409 | } |
410 | 410 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @return WPInv_Subscriptions |
416 | 416 | */ |
417 | 417 | function getpaid_subscriptions() { |
418 | - return getpaid()->get( 'subscriptions' ); |
|
418 | + return getpaid()->get('subscriptions'); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | * @since 2.3.0 |
425 | 425 | * @return WPInv_Subscription|bool |
426 | 426 | */ |
427 | -function wpinv_get_invoice_subscription( $invoice ) { |
|
427 | +function wpinv_get_invoice_subscription($invoice) { |
|
428 | 428 | |
429 | 429 | // Retrieve the invoice. |
430 | - $invoice = new WPInv_Invoice( $invoice ); |
|
430 | + $invoice = new WPInv_Invoice($invoice); |
|
431 | 431 | |
432 | 432 | // Ensure it is a recurring invoice. |
433 | - if ( ! $invoice->is_recurring() ) { |
|
433 | + if (!$invoice->is_recurring()) { |
|
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | ) |
443 | 443 | ); |
444 | 444 | |
445 | - return empty( $subscription ) ? false : $subscription[0]; |
|
445 | + return empty($subscription) ? false : $subscription[0]; |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -457,50 +457,50 @@ discard block |
||
457 | 457 | * @param GetPaid_Form_Item|WPInv_Item $cart_item |
458 | 458 | * @return string |
459 | 459 | */ |
460 | -function getpaid_get_recurring_item_key( $cart_item ) { |
|
460 | +function getpaid_get_recurring_item_key($cart_item) { |
|
461 | 461 | |
462 | 462 | $cart_key = 'renews_'; |
463 | 463 | $interval = $cart_item->get_recurring_interval(); |
464 | - $period = $cart_item->get_recurring_period( true ); |
|
464 | + $period = $cart_item->get_recurring_period(true); |
|
465 | 465 | $length = $cart_item->get_recurring_limit() * $interval; |
466 | - $trial_period = $cart_item->get_trial_period( true ); |
|
466 | + $trial_period = $cart_item->get_trial_period(true); |
|
467 | 467 | $trial_length = $cart_item->get_trial_interval(); |
468 | 468 | |
469 | 469 | // First start with the billing interval and period |
470 | - switch ( $interval ) { |
|
470 | + switch ($interval) { |
|
471 | 471 | case 1 : |
472 | - if ( 'day' == $period ) { |
|
472 | + if ('day' == $period) { |
|
473 | 473 | $cart_key .= 'daily'; |
474 | 474 | } else { |
475 | - $cart_key .= sprintf( '%sly', $period ); |
|
475 | + $cart_key .= sprintf('%sly', $period); |
|
476 | 476 | } |
477 | 477 | break; |
478 | 478 | case 2 : |
479 | - $cart_key .= sprintf( 'every_2nd_%s', $period ); |
|
479 | + $cart_key .= sprintf('every_2nd_%s', $period); |
|
480 | 480 | break; |
481 | 481 | case 3 : |
482 | - $cart_key .= sprintf( 'every_3rd_%s', $period ); |
|
482 | + $cart_key .= sprintf('every_3rd_%s', $period); |
|
483 | 483 | break; |
484 | 484 | default: |
485 | - $cart_key .= sprintf( 'every_%dth_%s', $interval, $period ); |
|
485 | + $cart_key .= sprintf('every_%dth_%s', $interval, $period); |
|
486 | 486 | break; |
487 | 487 | } |
488 | 488 | |
489 | 489 | // Maybe add the optional maximum billing periods... |
490 | - if ( $length > 0 ) { |
|
490 | + if ($length > 0) { |
|
491 | 491 | $cart_key .= '_for_'; |
492 | - $cart_key .= sprintf( '%d_%s', $length, $period ); |
|
493 | - if ( $length > 1 ) { |
|
492 | + $cart_key .= sprintf('%d_%s', $length, $period); |
|
493 | + if ($length > 1) { |
|
494 | 494 | $cart_key .= 's'; |
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
498 | 498 | // And an optional free trial. |
499 | - if ( $cart_item->has_free_trial() ) { |
|
500 | - $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period ); |
|
499 | + if ($cart_item->has_free_trial()) { |
|
500 | + $cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period); |
|
501 | 501 | } |
502 | 502 | |
503 | - return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item ); |
|
503 | + return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -509,14 +509,14 @@ discard block |
||
509 | 509 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
510 | 510 | * @return array |
511 | 511 | */ |
512 | -function getpaid_get_subscription_groups( $invoice ) { |
|
512 | +function getpaid_get_subscription_groups($invoice) { |
|
513 | 513 | |
514 | 514 | // Generate subscription groups. |
515 | 515 | $subscription_groups = array(); |
516 | - foreach ( $invoice->get_items() as $item ) { |
|
516 | + foreach ($invoice->get_items() as $item) { |
|
517 | 517 | |
518 | - if ( $item->is_recurring() ) { |
|
519 | - $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item; |
|
518 | + if ($item->is_recurring()) { |
|
519 | + $subscription_groups[getpaid_get_recurring_item_key($item)][] = $item; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | } |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
534 | 534 | * @return array |
535 | 535 | */ |
536 | -function getpaid_calculate_subscription_totals( $invoice ) { |
|
536 | +function getpaid_calculate_subscription_totals($invoice) { |
|
537 | 537 | |
538 | 538 | // Generate subscription groups. |
539 | - $subscription_groups = getpaid_get_subscription_groups( $invoice ); |
|
539 | + $subscription_groups = getpaid_get_subscription_groups($invoice); |
|
540 | 540 | |
541 | 541 | // Now let's calculate the totals for each group of subscriptions |
542 | 542 | $subscription_totals = array(); |
543 | 543 | |
544 | - foreach ( $subscription_groups as $subscription_key => $items ) { |
|
544 | + foreach ($subscription_groups as $subscription_key => $items) { |
|
545 | 545 | |
546 | - if ( empty( $subscription_totals[ $subscription_key ] ) ) { |
|
546 | + if (empty($subscription_totals[$subscription_key])) { |
|
547 | 547 | |
548 | - $subscription_totals[ $subscription_key ] = array( |
|
548 | + $subscription_totals[$subscription_key] = array( |
|
549 | 549 | 'initial_total' => 0, |
550 | 550 | 'recurring_total' => 0, |
551 | 551 | 'items' => array(), |
@@ -555,34 +555,34 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | // Get the totals of the group. |
558 | - foreach ( $items as $item ) { |
|
558 | + foreach ($items as $item) { |
|
559 | 559 | |
560 | - $subscription_totals[ $subscription_key ]['items'][] = $item->get_id(); |
|
561 | - $subscription_totals[ $subscription_key ]['item_id'] = $item->get_id(); |
|
562 | - $subscription_totals[ $subscription_key ]['period'] = $item->get_recurring_period( true ); |
|
563 | - $subscription_totals[ $subscription_key ]['interval'] = $item->get_recurring_interval(); |
|
564 | - $subscription_totals[ $subscription_key ]['initial_total'] += $item->get_sub_total(); |
|
565 | - $subscription_totals[ $subscription_key ]['recurring_total'] += $item->get_recurring_sub_total(); |
|
566 | - $subscription_totals[ $subscription_key ]['recurring_limit'] = $item->get_recurring_limit(); |
|
560 | + $subscription_totals[$subscription_key]['items'][] = $item->get_id(); |
|
561 | + $subscription_totals[$subscription_key]['item_id'] = $item->get_id(); |
|
562 | + $subscription_totals[$subscription_key]['period'] = $item->get_recurring_period(true); |
|
563 | + $subscription_totals[$subscription_key]['interval'] = $item->get_recurring_interval(); |
|
564 | + $subscription_totals[$subscription_key]['initial_total'] += $item->get_sub_total(); |
|
565 | + $subscription_totals[$subscription_key]['recurring_total'] += $item->get_recurring_sub_total(); |
|
566 | + $subscription_totals[$subscription_key]['recurring_limit'] = $item->get_recurring_limit(); |
|
567 | 567 | |
568 | 568 | // Calculate the next renewal date. |
569 | - $period = $item->get_recurring_period( true ); |
|
569 | + $period = $item->get_recurring_period(true); |
|
570 | 570 | $interval = $item->get_recurring_interval(); |
571 | 571 | |
572 | 572 | // If the subscription item has a trial period... |
573 | - if ( $item->has_free_trial() ) { |
|
574 | - $period = $item->get_trial_period( true ); |
|
573 | + if ($item->has_free_trial()) { |
|
574 | + $period = $item->get_trial_period(true); |
|
575 | 575 | $interval = $item->get_trial_interval(); |
576 | - $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period; |
|
576 | + $subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period; |
|
577 | 577 | } |
578 | 578 | |
579 | - $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) ); |
|
579 | + $subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp'))); |
|
580 | 580 | |
581 | 581 | } |
582 | 582 | |
583 | 583 | } |
584 | 584 | |
585 | - return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice ); |
|
585 | + return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -591,17 +591,17 @@ discard block |
||
591 | 591 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
592 | 592 | * @return array |
593 | 593 | */ |
594 | -function getpaid_should_group_subscriptions( $invoice ) { |
|
594 | +function getpaid_should_group_subscriptions($invoice) { |
|
595 | 595 | |
596 | 596 | $recurring_items = 0; |
597 | 597 | |
598 | - foreach ( $invoice->get_items() as $item ) { |
|
598 | + foreach ($invoice->get_items() as $item) { |
|
599 | 599 | |
600 | - if ( $item->is_recurring() ) { |
|
601 | - $recurring_items ++; |
|
600 | + if ($item->is_recurring()) { |
|
601 | + $recurring_items++; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | } |
605 | 605 | |
606 | - return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice ); |
|
606 | + return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice); |
|
607 | 607 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | /** |
9 | 9 | * Main Subscriptions class. |
10 | 10 | * |
@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Class constructor. |
16 | 16 | */ |
17 | - public function __construct(){ |
|
17 | + public function __construct() { |
|
18 | 18 | |
19 | 19 | // Fire gateway specific hooks when a subscription changes. |
20 | - add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 ); |
|
20 | + add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3); |
|
21 | 21 | |
22 | 22 | // De-activate a subscription whenever the invoice changes payment statuses. |
23 | - add_action( 'getpaid_invoice_status_wpi-refunded', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
24 | - add_action( 'getpaid_invoice_status_wpi-failed', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
25 | - add_action( 'getpaid_invoice_status_wpi-cancelled', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
26 | - add_action( 'getpaid_invoice_status_wpi-pending', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
23 | + add_action('getpaid_invoice_status_wpi-refunded', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
24 | + add_action('getpaid_invoice_status_wpi-failed', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
25 | + add_action('getpaid_invoice_status_wpi-cancelled', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
26 | + add_action('getpaid_invoice_status_wpi-pending', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
27 | 27 | |
28 | 28 | // Handles subscription cancelations. |
29 | - add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) ); |
|
29 | + add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription')); |
|
30 | 30 | |
31 | 31 | // Create a subscription whenever an invoice is created, (and update it when it is updated). |
32 | - add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ), 5 ); |
|
33 | - add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
32 | + add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription'), 5); |
|
33 | + add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription'), 5); |
|
34 | 34 | |
35 | 35 | // Handles admin subscription update actions. |
36 | - add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) ); |
|
37 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) ); |
|
38 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) ); |
|
36 | + add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription')); |
|
37 | + add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription')); |
|
38 | + add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription')); |
|
39 | 39 | |
40 | 40 | // Filter invoice item row actions. |
41 | - add_action( 'getpaid-invoice-page-line-item-actions', array( $this, 'filter_invoice_line_item_actions' ), 10, 3 ); |
|
41 | + add_action('getpaid-invoice-page-line-item-actions', array($this, 'filter_invoice_line_item_actions'), 10, 3); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | * @param WPInv_Invoice $invoice |
48 | 48 | * @return WPInv_Subscription|bool |
49 | 49 | */ |
50 | - public function get_invoice_subscription( $invoice ) { |
|
50 | + public function get_invoice_subscription($invoice) { |
|
51 | 51 | $subscription_id = $invoice->get_subscription_id(); |
52 | 52 | |
53 | 53 | // Fallback to the parent invoice if the child invoice has no subscription id. |
54 | - if ( empty( $subscription_id ) && $invoice->is_renewal() ) { |
|
54 | + if (empty($subscription_id) && $invoice->is_renewal()) { |
|
55 | 55 | $subscription_id = $invoice->get_parent_payment()->get_subscription_id(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Fetch the subscription. |
59 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
59 | + $subscription = new WPInv_Subscription($subscription_id); |
|
60 | 60 | |
61 | 61 | // Return subscription or use a fallback for backwards compatibility. |
62 | - return $subscription->exists() ? $subscription : wpinv_get_invoice_subscription( $invoice ); |
|
62 | + return $subscription->exists() ? $subscription : wpinv_get_invoice_subscription($invoice); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param WPInv_Invoice $invoice |
69 | 69 | */ |
70 | - public function maybe_deactivate_invoice_subscription( $invoice ) { |
|
70 | + public function maybe_deactivate_invoice_subscription($invoice) { |
|
71 | 71 | |
72 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
72 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
73 | 73 | |
74 | - if ( empty( $subscriptions ) ) { |
|
74 | + if (empty($subscriptions)) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | - if ( ! is_array( $subscriptions ) ) { |
|
79 | - $subscriptions = array( $subscriptions ); |
|
78 | + if (!is_array($subscriptions)) { |
|
79 | + $subscriptions = array($subscriptions); |
|
80 | 80 | } |
81 | 81 | |
82 | - foreach ( $subscriptions as $subscription ) { |
|
83 | - if ( $subscription->is_active() ) { |
|
84 | - $subscription->set_status( 'pending' ); |
|
82 | + foreach ($subscriptions as $subscription) { |
|
83 | + if ($subscription->is_active()) { |
|
84 | + $subscription->set_status('pending'); |
|
85 | 85 | $subscription->save(); |
86 | 86 | } |
87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | * @param string $from |
96 | 96 | * @param string $to |
97 | 97 | */ |
98 | - public function process_subscription_status_change( $subscription, $from, $to ) { |
|
98 | + public function process_subscription_status_change($subscription, $from, $to) { |
|
99 | 99 | |
100 | 100 | $gateway = $subscription->get_gateway(); |
101 | 101 | |
102 | - if ( ! empty( $gateway ) ) { |
|
103 | - $gateway = sanitize_key( $gateway ); |
|
104 | - $from = sanitize_key( $from ); |
|
105 | - $to = sanitize_key( $to ); |
|
106 | - do_action( "getpaid_{$gateway}_subscription_$to", $subscription, $from ); |
|
102 | + if (!empty($gateway)) { |
|
103 | + $gateway = sanitize_key($gateway); |
|
104 | + $from = sanitize_key($from); |
|
105 | + $to = sanitize_key($to); |
|
106 | + do_action("getpaid_{$gateway}_subscription_$to", $subscription, $from); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | } |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @deprecated |
117 | 117 | * @return mixed|string|void |
118 | 118 | */ |
119 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1 ) { |
|
120 | - return getpaid_get_subscription_period_label( $period, $frequency_count ); |
|
119 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
120 | + return getpaid_get_subscription_period_label($period, $frequency_count); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,33 +127,33 @@ discard block |
||
127 | 127 | * @since 1.0.0 |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function user_cancel_single_subscription( $data ) { |
|
130 | + public function user_cancel_single_subscription($data) { |
|
131 | 131 | |
132 | 132 | // Ensure there is a subscription to cancel. |
133 | - if ( empty( $data['subscription'] ) ) { |
|
133 | + if (empty($data['subscription'])) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - $subscription = new WPInv_Subscription( (int) $data['subscription'] ); |
|
137 | + $subscription = new WPInv_Subscription((int) $data['subscription']); |
|
138 | 138 | |
139 | 139 | // Ensure that it exists and that it belongs to the current user. |
140 | - if ( ! $subscription->exists() || $subscription->get_customer_id() != get_current_user_id() ) { |
|
141 | - wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) ); |
|
140 | + if (!$subscription->exists() || $subscription->get_customer_id() != get_current_user_id()) { |
|
141 | + wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing')); |
|
142 | 142 | |
143 | 143 | // Can it be cancelled. |
144 | - } else if ( ! $subscription->can_cancel() ) { |
|
145 | - wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) ); |
|
144 | + } else if (!$subscription->can_cancel()) { |
|
145 | + wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing')); |
|
146 | 146 | |
147 | 147 | // Cancel it. |
148 | 148 | } else { |
149 | 149 | |
150 | 150 | $subscription->cancel(); |
151 | - wpinv_set_error( 'cancelled', __( 'This subscription has been cancelled.', 'invoicing' ), 'info' ); |
|
151 | + wpinv_set_error('cancelled', __('This subscription has been cancelled.', 'invoicing'), 'info'); |
|
152 | 152 | } |
153 | 153 | |
154 | - $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce' ) ); |
|
154 | + $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce')); |
|
155 | 155 | |
156 | - wp_safe_redirect( $redirect ); |
|
156 | + wp_safe_redirect($redirect); |
|
157 | 157 | exit; |
158 | 158 | |
159 | 159 | } |
@@ -165,41 +165,41 @@ discard block |
||
165 | 165 | * @param WPInv_Invoice $invoice |
166 | 166 | * @since 1.0.0 |
167 | 167 | */ |
168 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
168 | + public function maybe_create_invoice_subscription($invoice) { |
|
169 | 169 | global $getpaid_subscriptions_skip_invoice_update; |
170 | 170 | |
171 | 171 | // Abort if it is not recurring. |
172 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
172 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Either group the subscriptions or only process a single suscription. |
177 | - if ( getpaid_should_group_subscriptions( $invoice ) ) { |
|
177 | + if (getpaid_should_group_subscriptions($invoice)) { |
|
178 | 178 | |
179 | 179 | $subscription_groups = array(); |
180 | 180 | $is_first = true; |
181 | 181 | |
182 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
183 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, 0, $is_first ); |
|
182 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
183 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, 0, $is_first); |
|
184 | 184 | |
185 | - if ( $is_first ) { |
|
185 | + if ($is_first) { |
|
186 | 186 | $getpaid_subscriptions_skip_invoice_update = true; |
187 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
187 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
188 | 188 | $invoice->save(); |
189 | 189 | $getpaid_subscriptions_skip_invoice_update = false; |
190 | 190 | } |
191 | 191 | |
192 | - $is_first = false; |
|
192 | + $is_first = false; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | // Cache subscription groups. |
196 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
196 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
197 | 197 | return true; |
198 | 198 | |
199 | 199 | } |
200 | 200 | |
201 | 201 | $subscription = new WPInv_Subscription(); |
202 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
202 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
@@ -214,41 +214,41 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @since 2.3.0 |
216 | 216 | */ |
217 | - public function create_invoice_subscription_group( $totals, $invoice, $subscription_id = 0, $is_first = false ) { |
|
217 | + public function create_invoice_subscription_group($totals, $invoice, $subscription_id = 0, $is_first = false) { |
|
218 | 218 | |
219 | - $subscription = new WPInv_Subscription( (int) $subscription_id ); |
|
219 | + $subscription = new WPInv_Subscription((int) $subscription_id); |
|
220 | 220 | $initial_amt = $totals['initial_total']; |
221 | 221 | |
222 | 222 | // Maybe add non-recurring items. |
223 | - if ( $is_first ) { |
|
224 | - foreach ( $invoice->get_items() as $item ) { |
|
225 | - if ( ! $item->is_recurring() ) { |
|
223 | + if ($is_first) { |
|
224 | + foreach ($invoice->get_items() as $item) { |
|
225 | + if (!$item->is_recurring()) { |
|
226 | 226 | $initial_amt += $item->get_sub_total(); |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
232 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
233 | - $subscription->set_initial_amount( $initial_amt ); |
|
234 | - $subscription->set_recurring_amount( $totals['recurring_total'] ); |
|
235 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
236 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
237 | - $subscription->set_product_id( $totals['item_id'] ); |
|
238 | - $subscription->set_period( $totals['period'] ); |
|
239 | - $subscription->set_frequency( $totals['interval'] ); |
|
240 | - $subscription->set_bill_times( $totals['recurring_limit'] ); |
|
241 | - $subscription->set_next_renewal_date( $totals['renews_on'] ); |
|
231 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
232 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
233 | + $subscription->set_initial_amount($initial_amt); |
|
234 | + $subscription->set_recurring_amount($totals['recurring_total']); |
|
235 | + $subscription->set_date_created(current_time('mysql')); |
|
236 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
237 | + $subscription->set_product_id($totals['item_id']); |
|
238 | + $subscription->set_period($totals['period']); |
|
239 | + $subscription->set_frequency($totals['interval']); |
|
240 | + $subscription->set_bill_times($totals['recurring_limit']); |
|
241 | + $subscription->set_next_renewal_date($totals['renews_on']); |
|
242 | 242 | |
243 | 243 | // Trial periods. |
244 | - if ( ! empty( $totals['trialling'] ) ) { |
|
245 | - $subscription->set_trial_period( $totals['trialling'] ); |
|
246 | - $subscription->set_status( 'trialling' ); |
|
244 | + if (!empty($totals['trialling'])) { |
|
245 | + $subscription->set_trial_period($totals['trialling']); |
|
246 | + $subscription->set_status('trialling'); |
|
247 | 247 | |
248 | 248 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
249 | - } else if ( empty( $totals['initial_total'] ) ) { |
|
250 | - $subscription->set_trial_period( $totals['interval'] . ' ' . $totals['period'] ); |
|
251 | - $subscription->set_status( 'trialling' ); |
|
249 | + } else if (empty($totals['initial_total'])) { |
|
250 | + $subscription->set_trial_period($totals['interval'] . ' ' . $totals['period']); |
|
251 | + $subscription->set_status('trialling'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | $subscription->save(); |
@@ -265,87 +265,87 @@ discard block |
||
265 | 265 | * @param WPInv_Invoice $invoice |
266 | 266 | * @since 1.0.19 |
267 | 267 | */ |
268 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
268 | + public function maybe_update_invoice_subscription($invoice) { |
|
269 | 269 | global $getpaid_subscriptions_skip_invoice_update; |
270 | 270 | |
271 | 271 | // Avoid infinite loops. |
272 | - if ( ! empty( $getpaid_subscriptions_skip_invoice_update ) ) { |
|
272 | + if (!empty($getpaid_subscriptions_skip_invoice_update)) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Do not process renewals. |
277 | - if ( $invoice->is_renewal() ) { |
|
277 | + if ($invoice->is_renewal()) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | // Delete existing subscriptions if available and the invoice is not recurring. |
282 | - if ( ! $invoice->is_recurring() ) { |
|
283 | - $this->delete_invoice_subscriptions( $invoice ); |
|
282 | + if (!$invoice->is_recurring()) { |
|
283 | + $this->delete_invoice_subscriptions($invoice); |
|
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | 287 | // Fetch existing subscriptions. |
288 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
288 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
289 | 289 | |
290 | 290 | // Create new ones if no existing subscriptions. |
291 | - if ( empty( $subscriptions ) ) { |
|
292 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
291 | + if (empty($subscriptions)) { |
|
292 | + return $this->maybe_create_invoice_subscription($invoice); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // Abort if an invoice is paid and already has a subscription. |
296 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
296 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
297 | 297 | return; |
298 | 298 | } |
299 | 299 | |
300 | - $is_grouped = is_array( $subscriptions ); |
|
301 | - $should_group = getpaid_should_group_subscriptions( $invoice ); |
|
300 | + $is_grouped = is_array($subscriptions); |
|
301 | + $should_group = getpaid_should_group_subscriptions($invoice); |
|
302 | 302 | |
303 | 303 | // Ensure that the subscriptions are only grouped if there are more than 1 recurring items. |
304 | - if ( $is_grouped != $should_group ) { |
|
305 | - $this->delete_invoice_subscriptions( $invoice ); |
|
306 | - delete_post_meta( $invoice->get_id(), 'getpaid_subscription_groups' ); |
|
307 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
304 | + if ($is_grouped != $should_group) { |
|
305 | + $this->delete_invoice_subscriptions($invoice); |
|
306 | + delete_post_meta($invoice->get_id(), 'getpaid_subscription_groups'); |
|
307 | + return $this->maybe_create_invoice_subscription($invoice); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // If there is only one recurring item... |
311 | - if ( ! $is_grouped ) { |
|
312 | - return $this->update_invoice_subscription( $subscriptions, $invoice ); |
|
311 | + if (!$is_grouped) { |
|
312 | + return $this->update_invoice_subscription($subscriptions, $invoice); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Process subscription groups. |
316 | - $current_groups = getpaid_get_invoice_subscription_groups( $invoice ); |
|
316 | + $current_groups = getpaid_get_invoice_subscription_groups($invoice); |
|
317 | 317 | $subscription_groups = array(); |
318 | 318 | $is_first = true; |
319 | 319 | |
320 | 320 | // Create new subscription groups. |
321 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
322 | - $subscription_id = isset( $current_groups[ $group_key ] ) ? $current_groups[ $group_key ]['subscription_id'] : 0; |
|
323 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, $subscription_id, $is_first ); |
|
321 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
322 | + $subscription_id = isset($current_groups[$group_key]) ? $current_groups[$group_key]['subscription_id'] : 0; |
|
323 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, $subscription_id, $is_first); |
|
324 | 324 | |
325 | - if ( $is_first && $invoice->get_subscription_id() !== $subscription_groups[ $group_key ]['subscription_id'] ) { |
|
325 | + if ($is_first && $invoice->get_subscription_id() !== $subscription_groups[$group_key]['subscription_id']) { |
|
326 | 326 | $getpaid_subscriptions_skip_invoice_update = true; |
327 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
327 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
328 | 328 | $invoice->save(); |
329 | 329 | $getpaid_subscriptions_skip_invoice_update = false; |
330 | 330 | } |
331 | 331 | |
332 | - $is_first = false; |
|
332 | + $is_first = false; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // Delete non-existent subscription groups. |
336 | - foreach ( $current_groups as $group_key => $data ) { |
|
337 | - if ( ! isset( $subscription_groups[ $group_key ] ) ) { |
|
338 | - $subscription = new WPInv_Subscription( (int) $data['subscription_id'] ); |
|
336 | + foreach ($current_groups as $group_key => $data) { |
|
337 | + if (!isset($subscription_groups[$group_key])) { |
|
338 | + $subscription = new WPInv_Subscription((int) $data['subscription_id']); |
|
339 | 339 | |
340 | - if ( $subscription->exists() ) { |
|
341 | - $subscription->delete( true ); |
|
340 | + if ($subscription->exists()) { |
|
341 | + $subscription->delete(true); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Cache subscription groups. |
348 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
348 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
349 | 349 | return true; |
350 | 350 | |
351 | 351 | } |
@@ -355,20 +355,20 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @param WPInv_Invoice $invoice |
357 | 357 | */ |
358 | - public function delete_invoice_subscriptions( $invoice ) { |
|
358 | + public function delete_invoice_subscriptions($invoice) { |
|
359 | 359 | |
360 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
360 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
361 | 361 | |
362 | - if ( empty( $subscriptions ) ) { |
|
362 | + if (empty($subscriptions)) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | - if ( ! is_array( $subscriptions ) ) { |
|
367 | - $subscriptions = array( $subscriptions ); |
|
366 | + if (!is_array($subscriptions)) { |
|
367 | + $subscriptions = array($subscriptions); |
|
368 | 368 | } |
369 | 369 | |
370 | - foreach ( $subscriptions as $subscription ) { |
|
371 | - $subscription->delete( true ); |
|
370 | + foreach ($subscriptions as $subscription) { |
|
371 | + $subscription->delete(true); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | } |
@@ -381,57 +381,57 @@ discard block |
||
381 | 381 | * @param WPInv_Invoice $invoice |
382 | 382 | * @since 1.0.19 |
383 | 383 | */ |
384 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
384 | + public function update_invoice_subscription($subscription, $invoice) { |
|
385 | 385 | |
386 | 386 | // Delete the subscription if an invoice is free or nolonger recurring. |
387 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
387 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
388 | 388 | return $subscription->delete(); |
389 | 389 | } |
390 | 390 | |
391 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
392 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
393 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
394 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
395 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
396 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
391 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
392 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
393 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
394 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
395 | + $subscription->set_date_created(current_time('mysql')); |
|
396 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
397 | 397 | |
398 | 398 | // Get the recurring item and abort if it does not exist. |
399 | - $subscription_item = $invoice->get_recurring( true ); |
|
400 | - if ( ! $subscription_item->get_id() ) { |
|
399 | + $subscription_item = $invoice->get_recurring(true); |
|
400 | + if (!$subscription_item->get_id()) { |
|
401 | 401 | $invoice->set_subscription_id(0); |
402 | 402 | $invoice->save(); |
403 | 403 | return $subscription->delete(); |
404 | 404 | } |
405 | 405 | |
406 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
407 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
408 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
409 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
406 | + $subscription->set_product_id($subscription_item->get_id()); |
|
407 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
408 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
409 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
410 | 410 | |
411 | 411 | // Calculate the next renewal date. |
412 | - $period = $subscription_item->get_recurring_period( true ); |
|
412 | + $period = $subscription_item->get_recurring_period(true); |
|
413 | 413 | $interval = $subscription_item->get_recurring_interval(); |
414 | 414 | |
415 | 415 | // If the subscription item has a trial period... |
416 | - if ( $subscription_item->has_free_trial() ) { |
|
417 | - $period = $subscription_item->get_trial_period( true ); |
|
416 | + if ($subscription_item->has_free_trial()) { |
|
417 | + $period = $subscription_item->get_trial_period(true); |
|
418 | 418 | $interval = $subscription_item->get_trial_interval(); |
419 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
420 | - $subscription->set_status( 'trialling' ); |
|
419 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
420 | + $subscription->set_status('trialling'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
424 | - if ( $invoice->has_free_trial() ) { |
|
425 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
426 | - $subscription->set_status( 'trialling' ); |
|
424 | + if ($invoice->has_free_trial()) { |
|
425 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
426 | + $subscription->set_status('trialling'); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | // Calculate the next renewal date. |
430 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
430 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
431 | 431 | |
432 | - $subscription->set_next_renewal_date( $expiration ); |
|
432 | + $subscription->set_next_renewal_date($expiration); |
|
433 | 433 | $subscription->save(); |
434 | - $invoice->set_subscription_id( $subscription->get_id() ); |
|
434 | + $invoice->set_subscription_id($subscription->get_id()); |
|
435 | 435 | return $subscription->get_id(); |
436 | 436 | |
437 | 437 | } |
@@ -442,27 +442,27 @@ discard block |
||
442 | 442 | * @param array $data |
443 | 443 | * @since 1.0.19 |
444 | 444 | */ |
445 | - public function admin_update_single_subscription( $args ) { |
|
445 | + public function admin_update_single_subscription($args) { |
|
446 | 446 | |
447 | 447 | // Ensure the subscription exists and that a status has been given. |
448 | - if ( empty( $args['subscription_id'] ) ) { |
|
448 | + if (empty($args['subscription_id'])) { |
|
449 | 449 | return; |
450 | 450 | } |
451 | 451 | |
452 | 452 | // Retrieve the subscriptions. |
453 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
453 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
454 | 454 | |
455 | - if ( $subscription->get_id() ) { |
|
455 | + if ($subscription->get_id()) { |
|
456 | 456 | |
457 | 457 | $subscription->set_props( |
458 | 458 | array( |
459 | - 'status' => isset( $args['subscription_status'] ) ? $args['subscription_status'] : null, |
|
460 | - 'profile_id' => isset( $args['wpinv_subscription_profile_id'] ) ? $args['wpinv_subscription_profile_id'] : null, |
|
459 | + 'status' => isset($args['subscription_status']) ? $args['subscription_status'] : null, |
|
460 | + 'profile_id' => isset($args['wpinv_subscription_profile_id']) ? $args['wpinv_subscription_profile_id'] : null, |
|
461 | 461 | ) |
462 | 462 | ); |
463 | 463 | |
464 | 464 | $subscription->save(); |
465 | - getpaid_admin()->show_info( __( 'Subscription updated', 'invoicing' ) ); |
|
465 | + getpaid_admin()->show_info(__('Subscription updated', 'invoicing')); |
|
466 | 466 | |
467 | 467 | } |
468 | 468 | |
@@ -474,27 +474,27 @@ discard block |
||
474 | 474 | * @param array $data |
475 | 475 | * @since 1.0.19 |
476 | 476 | */ |
477 | - public function admin_renew_single_subscription( $args ) { |
|
477 | + public function admin_renew_single_subscription($args) { |
|
478 | 478 | |
479 | 479 | // Ensure the subscription exists and that a status has been given. |
480 | - if ( empty( $args['id'] ) ) { |
|
480 | + if (empty($args['id'])) { |
|
481 | 481 | return; |
482 | 482 | } |
483 | 483 | |
484 | 484 | // Retrieve the subscriptions. |
485 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
485 | + $subscription = new WPInv_Subscription($args['id']); |
|
486 | 486 | |
487 | - if ( $subscription->get_id() ) { |
|
487 | + if ($subscription->get_id()) { |
|
488 | 488 | |
489 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
489 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
490 | 490 | |
491 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
491 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
492 | 492 | |
493 | - if ( ! $subscription->add_payment( $args ) ) { |
|
494 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
493 | + if (!$subscription->add_payment($args)) { |
|
494 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
495 | 495 | } else { |
496 | 496 | $subscription->renew(); |
497 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
497 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | wp_safe_redirect( |
@@ -517,20 +517,20 @@ discard block |
||
517 | 517 | * @param array $data |
518 | 518 | * @since 1.0.19 |
519 | 519 | */ |
520 | - public function admin_delete_single_subscription( $args ) { |
|
520 | + public function admin_delete_single_subscription($args) { |
|
521 | 521 | |
522 | 522 | // Ensure the subscription exists and that a status has been given. |
523 | - if ( empty( $args['id'] ) ) { |
|
523 | + if (empty($args['id'])) { |
|
524 | 524 | return; |
525 | 525 | } |
526 | 526 | |
527 | 527 | // Retrieve the subscriptions. |
528 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
528 | + $subscription = new WPInv_Subscription($args['id']); |
|
529 | 529 | |
530 | - if ( $subscription->delete() ) { |
|
531 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
530 | + if ($subscription->delete()) { |
|
531 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
532 | 532 | } else { |
533 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
533 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | $redirected = wp_safe_redirect( |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | ) |
544 | 544 | ); |
545 | 545 | |
546 | - if ( $redirected ) { |
|
546 | + if ($redirected) { |
|
547 | 547 | exit; |
548 | 548 | } |
549 | 549 | |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | * @param WPInv_Item $item |
557 | 557 | * @param WPInv_Invoice $invoice |
558 | 558 | */ |
559 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
559 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
560 | 560 | |
561 | 561 | // Fetch item subscription. |
562 | - $args = array( |
|
562 | + $args = array( |
|
563 | 563 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
564 | 564 | 'product_in' => $item->get_id(), |
565 | 565 | 'number' => 1, |
@@ -567,13 +567,13 @@ discard block |
||
567 | 567 | 'fields' => 'id', |
568 | 568 | ); |
569 | 569 | |
570 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
570 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
571 | 571 | $subscription = $subscription->get_results(); |
572 | 572 | |
573 | 573 | // In case we found a match... |
574 | - if ( ! empty( $subscription ) ) { |
|
575 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
576 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
574 | + if (!empty($subscription)) { |
|
575 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
576 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | return $actions; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * The Subscription Class |
@@ -68,27 +68,27 @@ discard block |
||
68 | 68 | * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
69 | 69 | * @param bool $deprecated |
70 | 70 | */ |
71 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
71 | + function __construct($subscription = 0, $deprecated = false) { |
|
72 | 72 | |
73 | - parent::__construct( $subscription ); |
|
73 | + parent::__construct($subscription); |
|
74 | 74 | |
75 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | - $this->set_id( $subscription ); |
|
77 | - } elseif ( $subscription instanceof self ) { |
|
78 | - $this->set_id( $subscription->get_id() ); |
|
79 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
80 | - $this->set_id( $subscription_id ); |
|
81 | - } elseif ( ! empty( $subscription->id ) ) { |
|
82 | - $this->set_id( $subscription->id ); |
|
75 | + if (!$deprecated && !empty($subscription) && is_numeric($subscription)) { |
|
76 | + $this->set_id($subscription); |
|
77 | + } elseif ($subscription instanceof self) { |
|
78 | + $this->set_id($subscription->get_id()); |
|
79 | + } elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) { |
|
80 | + $this->set_id($subscription_id); |
|
81 | + } elseif (!empty($subscription->id)) { |
|
82 | + $this->set_id($subscription->id); |
|
83 | 83 | } else { |
84 | - $this->set_object_read( true ); |
|
84 | + $this->set_object_read(true); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Load the datastore. |
88 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
88 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
89 | 89 | |
90 | - if ( $this->get_id() > 0 ) { |
|
91 | - $this->data_store->read( $this ); |
|
90 | + if ($this->get_id() > 0) { |
|
91 | + $this->data_store->read($this); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @since 1.0.19 |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
106 | + public static function get_subscription_id_by_field($value, $field = 'profile_id') { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | 109 | // Trim the value. |
110 | - $value = trim( $value ); |
|
110 | + $value = trim($value); |
|
111 | 111 | |
112 | - if ( empty( $value ) ) { |
|
112 | + if (empty($value)) { |
|
113 | 113 | return 0; |
114 | 114 | } |
115 | 115 | |
116 | - if ( 'invoice_id' == $field ) { |
|
116 | + if ('invoice_id' == $field) { |
|
117 | 117 | $field = 'parent_payment_id'; |
118 | 118 | } |
119 | 119 | |
@@ -125,28 +125,28 @@ discard block |
||
125 | 125 | ); |
126 | 126 | |
127 | 127 | // Ensure a field has been passed. |
128 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
128 | + if (empty($field) || !in_array($field, $fields)) { |
|
129 | 129 | return 0; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Maybe retrieve from the cache. |
133 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | - if ( ! empty( $subscription_id ) ) { |
|
133 | + $subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
134 | + if (!empty($subscription_id)) { |
|
135 | 135 | return $subscription_id; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Fetch from the db. |
139 | 139 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
140 | 140 | $subscription_id = (int) $wpdb->get_var( |
141 | - $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
141 | + $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
142 | 142 | ); |
143 | 143 | |
144 | - if ( empty( $subscription_id ) ) { |
|
144 | + if (empty($subscription_id)) { |
|
145 | 145 | return 0; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Update the cache with our data. |
149 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
149 | + wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
150 | 150 | |
151 | 151 | return $subscription_id; |
152 | 152 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | * Clears the subscription's cache. |
156 | 156 | */ |
157 | 157 | public function clear_cache() { |
158 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
158 | + wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids'); |
|
159 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
160 | + wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
161 | + wp_cache_delete($this->get_id(), 'getpaid_subscriptions'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Checks if a subscription key is set. |
166 | 166 | */ |
167 | - public function _isset( $key ) { |
|
168 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
167 | + public function _isset($key) { |
|
168 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /* |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param string $context View or edit context. |
191 | 191 | * @return int |
192 | 192 | */ |
193 | - public function get_customer_id( $context = 'view' ) { |
|
194 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
193 | + public function get_customer_id($context = 'view') { |
|
194 | + return (int) $this->get_prop('customer_id', $context); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $context View or edit context. |
202 | 202 | * @return WP_User|false WP_User object on success, false on failure. |
203 | 203 | */ |
204 | - public function get_customer( $context = 'view' ) { |
|
205 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
204 | + public function get_customer($context = 'view') { |
|
205 | + return get_userdata($this->get_customer_id($context)); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $context View or edit context. |
213 | 213 | * @return int |
214 | 214 | */ |
215 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
215 | + public function get_parent_invoice_id($context = 'view') { |
|
216 | + return (int) $this->get_prop('parent_payment_id', $context); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param string $context View or edit context. |
224 | 224 | * @return int |
225 | 225 | */ |
226 | - public function get_parent_payment_id( $context = 'view' ) { |
|
227 | - return $this->get_parent_invoice_id( $context ); |
|
226 | + public function get_parent_payment_id($context = 'view') { |
|
227 | + return $this->get_parent_invoice_id($context); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @since 1.0.0 |
234 | 234 | * @return int |
235 | 235 | */ |
236 | - public function get_original_payment_id( $context = 'view' ) { |
|
237 | - return $this->get_parent_invoice_id( $context ); |
|
236 | + public function get_original_payment_id($context = 'view') { |
|
237 | + return $this->get_parent_invoice_id($context); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param string $context View or edit context. |
245 | 245 | * @return WPInv_Invoice |
246 | 246 | */ |
247 | - public function get_parent_invoice( $context = 'view' ) { |
|
248 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
247 | + public function get_parent_invoice($context = 'view') { |
|
248 | + return new WPInv_Invoice($this->get_parent_invoice_id($context)); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | * @param string $context View or edit context. |
256 | 256 | * @return WPInv_Invoice |
257 | 257 | */ |
258 | - public function get_parent_payment( $context = 'view' ) { |
|
259 | - return $this->get_parent_invoice( $context ); |
|
258 | + public function get_parent_payment($context = 'view') { |
|
259 | + return $this->get_parent_invoice($context); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param string $context View or edit context. |
267 | 267 | * @return int |
268 | 268 | */ |
269 | - public function get_product_id( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'product_id', $context ); |
|
269 | + public function get_product_id($context = 'view') { |
|
270 | + return (int) $this->get_prop('product_id', $context); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $context View or edit context. |
278 | 278 | * @return WPInv_Item |
279 | 279 | */ |
280 | - public function get_product( $context = 'view' ) { |
|
281 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
280 | + public function get_product($context = 'view') { |
|
281 | + return new WPInv_Item($this->get_product_id($context)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param string $context View or edit context. |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - public function get_gateway( $context = 'view' ) { |
|
294 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
293 | + public function get_gateway($context = 'view') { |
|
294 | + return $this->get_parent_invoice($context)->get_gateway(); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $context View or edit context. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function get_period( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'period', $context ); |
|
304 | + public function get_period($context = 'view') { |
|
305 | + return $this->get_prop('period', $context); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param string $context View or edit context. |
313 | 313 | * @return int |
314 | 314 | */ |
315 | - public function get_frequency( $context = 'view' ) { |
|
316 | - return (int) $this->get_prop( 'frequency', $context ); |
|
315 | + public function get_frequency($context = 'view') { |
|
316 | + return (int) $this->get_prop('frequency', $context); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string $context View or edit context. |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - public function get_initial_amount( $context = 'view' ) { |
|
327 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
326 | + public function get_initial_amount($context = 'view') { |
|
327 | + return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return float |
336 | 336 | */ |
337 | - public function get_recurring_amount( $context = 'view' ) { |
|
338 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
337 | + public function get_recurring_amount($context = 'view') { |
|
338 | + return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context)); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $context View or edit context. |
346 | 346 | * @return int |
347 | 347 | */ |
348 | - public function get_bill_times( $context = 'view' ) { |
|
349 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
348 | + public function get_bill_times($context = 'view') { |
|
349 | + return (int) $this->get_prop('bill_times', $context); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * @param string $context View or edit context. |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_transaction_id( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'transaction_id', $context ); |
|
359 | + public function get_transaction_id($context = 'view') { |
|
360 | + return $this->get_prop('transaction_id', $context); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string $context View or edit context. |
368 | 368 | * @return string |
369 | 369 | */ |
370 | - public function get_created( $context = 'view' ) { |
|
371 | - return $this->get_prop( 'created', $context ); |
|
370 | + public function get_created($context = 'view') { |
|
371 | + return $this->get_prop('created', $context); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $context View or edit context. |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public function get_date_created( $context = 'view' ) { |
|
382 | - return $this->get_created( $context ); |
|
381 | + public function get_date_created($context = 'view') { |
|
382 | + return $this->get_created($context); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function get_time_created() { |
392 | 392 | $created = $this->get_date_created(); |
393 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
393 | + return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,11 +400,11 @@ discard block |
||
400 | 400 | * @param string $context View or edit context. |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - public function get_date_created_gmt( $context = 'view' ) { |
|
404 | - $date = $this->get_date_created( $context ); |
|
403 | + public function get_date_created_gmt($context = 'view') { |
|
404 | + $date = $this->get_date_created($context); |
|
405 | 405 | |
406 | - if ( $date ) { |
|
407 | - $date = get_gmt_from_date( $date ); |
|
406 | + if ($date) { |
|
407 | + $date = get_gmt_from_date($date); |
|
408 | 408 | } |
409 | 409 | return $date; |
410 | 410 | } |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param string $context View or edit context. |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public function get_next_renewal_date( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'expiration', $context ); |
|
419 | + public function get_next_renewal_date($context = 'view') { |
|
420 | + return $this->get_prop('expiration', $context); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param string $context View or edit context. |
428 | 428 | * @return string |
429 | 429 | */ |
430 | - public function get_expiration( $context = 'view' ) { |
|
431 | - return $this->get_next_renewal_date( $context ); |
|
430 | + public function get_expiration($context = 'view') { |
|
431 | + return $this->get_next_renewal_date($context); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | public function get_expiration_time() { |
441 | 441 | $expiration = $this->get_expiration(); |
442 | 442 | |
443 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | - return current_time( 'timestamp' ); |
|
443 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
444 | + return current_time('timestamp'); |
|
445 | 445 | } |
446 | 446 | |
447 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
447 | + $expiration = strtotime($expiration, current_time('timestamp')); |
|
448 | + return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | * @param string $context View or edit context. |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | - $date = $this->get_next_renewal_date( $context ); |
|
458 | + public function get_next_renewal_date_gmt($context = 'view') { |
|
459 | + $date = $this->get_next_renewal_date($context); |
|
460 | 460 | |
461 | - if ( $date ) { |
|
462 | - $date = get_gmt_from_date( $date ); |
|
461 | + if ($date) { |
|
462 | + $date = get_gmt_from_date($date); |
|
463 | 463 | } |
464 | 464 | return $date; |
465 | 465 | } |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param string $context View or edit context. |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function get_trial_period( $context = 'view' ) { |
|
475 | - return $this->get_prop( 'trial_period', $context ); |
|
474 | + public function get_trial_period($context = 'view') { |
|
475 | + return $this->get_prop('trial_period', $context); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $context View or edit context. |
483 | 483 | * @return string |
484 | 484 | */ |
485 | - public function get_status( $context = 'view' ) { |
|
486 | - return $this->get_prop( 'status', $context ); |
|
485 | + public function get_status($context = 'view') { |
|
486 | + return $this->get_prop('status', $context); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * @param string $context View or edit context. |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - public function get_profile_id( $context = 'view' ) { |
|
497 | - return $this->get_prop( 'profile_id', $context ); |
|
496 | + public function get_profile_id($context = 'view') { |
|
497 | + return $this->get_prop('profile_id', $context); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /* |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @since 1.0.19 |
510 | 510 | * @param int $value The customer's id. |
511 | 511 | */ |
512 | - public function set_customer_id( $value ) { |
|
513 | - $this->set_prop( 'customer_id', (int) $value ); |
|
512 | + public function set_customer_id($value) { |
|
513 | + $this->set_prop('customer_id', (int) $value); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * @since 1.0.19 |
520 | 520 | * @param int $value The parent invoice id. |
521 | 521 | */ |
522 | - public function set_parent_invoice_id( $value ) { |
|
523 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
522 | + public function set_parent_invoice_id($value) { |
|
523 | + $this->set_prop('parent_payment_id', (int) $value); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | * @since 1.0.19 |
530 | 530 | * @param int $value The parent invoice id. |
531 | 531 | */ |
532 | - public function set_parent_payment_id( $value ) { |
|
533 | - $this->set_parent_invoice_id( $value ); |
|
532 | + public function set_parent_payment_id($value) { |
|
533 | + $this->set_parent_invoice_id($value); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @since 1.0.19 |
540 | 540 | * @param int $value The parent invoice id. |
541 | 541 | */ |
542 | - public function set_original_payment_id( $value ) { |
|
543 | - $this->set_parent_invoice_id( $value ); |
|
542 | + public function set_original_payment_id($value) { |
|
543 | + $this->set_parent_invoice_id($value); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @since 1.0.19 |
550 | 550 | * @param int $value The subscription product id. |
551 | 551 | */ |
552 | - public function set_product_id( $value ) { |
|
553 | - $this->set_prop( 'product_id', (int) $value ); |
|
552 | + public function set_product_id($value) { |
|
553 | + $this->set_prop('product_id', (int) $value); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @since 1.0.19 |
560 | 560 | * @param string $value The renewal period. |
561 | 561 | */ |
562 | - public function set_period( $value ) { |
|
563 | - $this->set_prop( 'period', $value ); |
|
562 | + public function set_period($value) { |
|
563 | + $this->set_prop('period', $value); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | * @since 1.0.19 |
570 | 570 | * @param int $value The subscription frequency. |
571 | 571 | */ |
572 | - public function set_frequency( $value ) { |
|
573 | - $value = empty( $value ) ? 1 : (int) $value; |
|
574 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
572 | + public function set_frequency($value) { |
|
573 | + $value = empty($value) ? 1 : (int) $value; |
|
574 | + $this->set_prop('frequency', absint($value)); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @since 1.0.19 |
581 | 581 | * @param float $value The initial subcription amount. |
582 | 582 | */ |
583 | - public function set_initial_amount( $value ) { |
|
584 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
583 | + public function set_initial_amount($value) { |
|
584 | + $this->set_prop('initial_amount', wpinv_sanitize_amount($value)); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @since 1.0.19 |
591 | 591 | * @param float $value The recurring subcription amount. |
592 | 592 | */ |
593 | - public function set_recurring_amount( $value ) { |
|
594 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
593 | + public function set_recurring_amount($value) { |
|
594 | + $this->set_prop('recurring_amount', wpinv_sanitize_amount($value)); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @since 1.0.19 |
601 | 601 | * @param int $value Bill times. |
602 | 602 | */ |
603 | - public function set_bill_times( $value ) { |
|
604 | - $this->set_prop( 'bill_times', (int) $value ); |
|
603 | + public function set_bill_times($value) { |
|
604 | + $this->set_prop('bill_times', (int) $value); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | * @since 1.0.19 |
611 | 611 | * @param string $value Bill times. |
612 | 612 | */ |
613 | - public function set_transaction_id( $value ) { |
|
614 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
613 | + public function set_transaction_id($value) { |
|
614 | + $this->set_prop('transaction_id', sanitize_text_field($value)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -620,15 +620,15 @@ discard block |
||
620 | 620 | * @since 1.0.19 |
621 | 621 | * @param string $value strtotime compliant date. |
622 | 622 | */ |
623 | - public function set_created( $value ) { |
|
624 | - $date = strtotime( $value ); |
|
623 | + public function set_created($value) { |
|
624 | + $date = strtotime($value); |
|
625 | 625 | |
626 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
626 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
627 | + $this->set_prop('created', date('Y-m-d H:i:s', $date)); |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - $this->set_prop( 'created', '' ); |
|
631 | + $this->set_prop('created', ''); |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @since 1.0.19 |
639 | 639 | * @param string $value strtotime compliant date. |
640 | 640 | */ |
641 | - public function set_date_created( $value ) { |
|
642 | - $this->set_created( $value ); |
|
641 | + public function set_date_created($value) { |
|
642 | + $this->set_created($value); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -648,15 +648,15 @@ discard block |
||
648 | 648 | * @since 1.0.19 |
649 | 649 | * @param string $value strtotime compliant date. |
650 | 650 | */ |
651 | - public function set_next_renewal_date( $value ) { |
|
652 | - $date = strtotime( $value ); |
|
651 | + public function set_next_renewal_date($value) { |
|
652 | + $date = strtotime($value); |
|
653 | 653 | |
654 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
654 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
655 | + $this->set_prop('expiration', date('Y-m-d H:i:s', $date)); |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | - $this->set_prop( 'expiration', '' ); |
|
659 | + $this->set_prop('expiration', ''); |
|
660 | 660 | |
661 | 661 | } |
662 | 662 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @since 1.0.19 |
667 | 667 | * @param string $value strtotime compliant date. |
668 | 668 | */ |
669 | - public function set_expiration( $value ) { |
|
670 | - $this->set_next_renewal_date( $value ); |
|
669 | + public function set_expiration($value) { |
|
670 | + $this->set_next_renewal_date($value); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @since 1.0.19 |
677 | 677 | * @param string $value trial period e.g 1 year. |
678 | 678 | */ |
679 | - public function set_trial_period( $value ) { |
|
680 | - $this->set_prop( 'trial_period', $value ); |
|
679 | + public function set_trial_period($value) { |
|
680 | + $this->set_prop('trial_period', $value); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -686,19 +686,19 @@ discard block |
||
686 | 686 | * @since 1.0.19 |
687 | 687 | * @param string $new_status New subscription status. |
688 | 688 | */ |
689 | - public function set_status( $new_status ) { |
|
689 | + public function set_status($new_status) { |
|
690 | 690 | |
691 | 691 | // Abort if this is not a valid status; |
692 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
692 | + if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) { |
|
693 | 693 | return; |
694 | 694 | } |
695 | 695 | |
696 | 696 | $old_status = $this->get_status(); |
697 | - $this->set_prop( 'status', $new_status ); |
|
697 | + $this->set_prop('status', $new_status); |
|
698 | 698 | |
699 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
699 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
700 | 700 | $this->status_transition = array( |
701 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
701 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
702 | 702 | 'to' => $new_status, |
703 | 703 | ); |
704 | 704 | } |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | * @since 1.0.19 |
712 | 712 | * @param string $value the remote profile id. |
713 | 713 | */ |
714 | - public function set_profile_id( $value ) { |
|
715 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
714 | + public function set_profile_id($value) { |
|
715 | + $this->set_prop('profile_id', sanitize_text_field($value)); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /* |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @param string|array String or array of strings to check for. |
731 | 731 | * @return bool |
732 | 732 | */ |
733 | - public function has_status( $status ) { |
|
734 | - return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
|
733 | + public function has_status($status) { |
|
734 | + return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status))); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | */ |
742 | 742 | public function has_trial_period() { |
743 | 743 | $period = $this->get_trial_period(); |
744 | - return ! empty( $period ); |
|
744 | + return !empty($period); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | * @return bool |
751 | 751 | */ |
752 | 752 | public function is_active() { |
753 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
753 | + return $this->has_status('active trialling') && !$this->is_expired(); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @return bool |
760 | 760 | */ |
761 | 761 | public function is_expired() { |
762 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
762 | + return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql')); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | public function is_last_renewal() { |
771 | 771 | $max_bills = $this->get_bill_times(); |
772 | - return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed(); |
|
772 | + return !empty($max_bills) && $max_bills <= $this->get_times_billed(); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /* |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | /** |
785 | 785 | * Backwards compatibilty. |
786 | 786 | */ |
787 | - public function create( $data = array() ) { |
|
787 | + public function create($data = array()) { |
|
788 | 788 | |
789 | 789 | // Set the properties. |
790 | - if ( is_array( $data ) ) { |
|
791 | - $this->set_props( $data ); |
|
790 | + if (is_array($data)) { |
|
791 | + $this->set_props($data); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | // Save the item. |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | /** |
800 | 800 | * Backwards compatibilty. |
801 | 801 | */ |
802 | - public function update( $args = array() ) { |
|
803 | - return $this->create( $args ); |
|
802 | + public function update($args = array()) { |
|
803 | + return $this->create($args); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -809,12 +809,12 @@ discard block |
||
809 | 809 | * @since 1.0.0 |
810 | 810 | * @return WP_Post[] |
811 | 811 | */ |
812 | - public function get_child_payments( $hide_pending = true ) { |
|
812 | + public function get_child_payments($hide_pending = true) { |
|
813 | 813 | |
814 | - $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' ); |
|
814 | + $statuses = array('publish', 'wpi-processing', 'wpi-renewal'); |
|
815 | 815 | |
816 | - if ( ! $hide_pending ) { |
|
817 | - $statuses = array_keys( wpinv_get_invoice_statuses() ); |
|
816 | + if (!$hide_pending) { |
|
817 | + $statuses = array_keys(wpinv_get_invoice_statuses()); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | return get_posts( |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | ); |
847 | 847 | |
848 | 848 | // Maybe include parent invoice. |
849 | - if ( $this->get_parent_payment()->is_paid() ) { |
|
849 | + if ($this->get_parent_payment()->is_paid()) { |
|
850 | 850 | $count++; |
851 | 851 | } |
852 | 852 | |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | public function get_times_billed() { |
863 | 863 | $times_billed = $this->get_total_payments(); |
864 | 864 | |
865 | - if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) { |
|
865 | + if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) { |
|
866 | 866 | $times_billed--; |
867 | 867 | } |
868 | 868 | |
@@ -877,49 +877,49 @@ discard block |
||
877 | 877 | * @param WPInv_Invoice $invoice If adding an existing invoice. |
878 | 878 | * @return bool |
879 | 879 | */ |
880 | - public function add_payment( $args = array(), $invoice = false ) { |
|
880 | + public function add_payment($args = array(), $invoice = false) { |
|
881 | 881 | |
882 | 882 | // Process each payment once. |
883 | - if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
|
883 | + if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) { |
|
884 | 884 | return false; |
885 | 885 | } |
886 | 886 | |
887 | 887 | // Are we creating a new invoice? |
888 | - if ( empty( $invoice ) ) { |
|
888 | + if (empty($invoice)) { |
|
889 | 889 | $invoice = $this->create_payment(); |
890 | 890 | |
891 | - if ( empty( $invoice ) ) { |
|
891 | + if (empty($invoice)) { |
|
892 | 892 | return false; |
893 | 893 | } |
894 | 894 | |
895 | 895 | } |
896 | 896 | |
897 | - $invoice->set_status( 'wpi-renewal' ); |
|
897 | + $invoice->set_status('wpi-renewal'); |
|
898 | 898 | |
899 | 899 | // Maybe set a transaction id. |
900 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
901 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
900 | + if (!empty($args['transaction_id'])) { |
|
901 | + $invoice->set_transaction_id($args['transaction_id']); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | // Set the completed date. |
905 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
905 | + $invoice->set_completed_date(current_time('mysql')); |
|
906 | 906 | |
907 | 907 | // And the gateway. |
908 | - if ( ! empty( $args['gateway'] ) ) { |
|
909 | - $invoice->set_gateway( $args['gateway'] ); |
|
908 | + if (!empty($args['gateway'])) { |
|
909 | + $invoice->set_gateway($args['gateway']); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | $invoice->save(); |
913 | 913 | |
914 | - if ( ! $invoice->exists() ) { |
|
914 | + if (!$invoice->exists()) { |
|
915 | 915 | return false; |
916 | 916 | } |
917 | 917 | |
918 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
919 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
920 | - do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
|
918 | + do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this); |
|
919 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
920 | + do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id()); |
|
921 | 921 | |
922 | - update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
|
922 | + update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id); |
|
923 | 923 | |
924 | 924 | return $invoice->get_id(); |
925 | 925 | } |
@@ -934,22 +934,22 @@ discard block |
||
934 | 934 | |
935 | 935 | $parent_invoice = $this->get_parent_payment(); |
936 | 936 | |
937 | - if ( ! $parent_invoice->exists() ) { |
|
937 | + if (!$parent_invoice->exists()) { |
|
938 | 938 | return false; |
939 | 939 | } |
940 | 940 | |
941 | 941 | // Duplicate the parent invoice. |
942 | - $invoice = getpaid_duplicate_invoice( $parent_invoice ); |
|
943 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
942 | + $invoice = getpaid_duplicate_invoice($parent_invoice); |
|
943 | + $invoice->set_parent_id($parent_invoice->get_id()); |
|
944 | 944 | |
945 | 945 | // Maybe recalculate discount (Pre-GetPaid Fix). |
946 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
947 | - if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) { |
|
948 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
946 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
947 | + if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) { |
|
948 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | $invoice->recalculate_total(); |
952 | - $invoice->set_status( 'wpi-pending' ); |
|
952 | + $invoice->set_status('wpi-pending'); |
|
953 | 953 | $invoice->save(); |
954 | 954 | |
955 | 955 | return $invoice->exists() ? $invoice : false; |
@@ -964,20 +964,20 @@ discard block |
||
964 | 964 | public function renew() { |
965 | 965 | |
966 | 966 | // Complete subscription if applicable |
967 | - if ( $this->is_last_renewal() ) { |
|
967 | + if ($this->is_last_renewal()) { |
|
968 | 968 | return $this->complete(); |
969 | 969 | } |
970 | 970 | |
971 | 971 | // Calculate new expiration |
972 | 972 | $frequency = $this->get_frequency(); |
973 | 973 | $period = $this->get_period(); |
974 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
974 | + $new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time()); |
|
975 | 975 | |
976 | - $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
977 | - $this->set_status( 'active' ); |
|
976 | + $this->set_expiration(date('Y-m-d H:i:s', $new_expiration)); |
|
977 | + $this->set_status('active'); |
|
978 | 978 | $this->save(); |
979 | 979 | |
980 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
980 | + do_action('getpaid_subscription_renewed', $this); |
|
981 | 981 | |
982 | 982 | return $this->get_id(); |
983 | 983 | } |
@@ -993,11 +993,11 @@ discard block |
||
993 | 993 | public function complete() { |
994 | 994 | |
995 | 995 | // Only mark a subscription as complete if it's not already cancelled. |
996 | - if ( $this->has_status( 'cancelled' ) ) { |
|
996 | + if ($this->has_status('cancelled')) { |
|
997 | 997 | return false; |
998 | 998 | } |
999 | 999 | |
1000 | - $this->set_status( 'completed' ); |
|
1000 | + $this->set_status('completed'); |
|
1001 | 1001 | return $this->save(); |
1002 | 1002 | |
1003 | 1003 | } |
@@ -1009,14 +1009,14 @@ discard block |
||
1009 | 1009 | * @param bool $check_expiration |
1010 | 1010 | * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
1011 | 1011 | */ |
1012 | - public function expire( $check_expiration = false ) { |
|
1012 | + public function expire($check_expiration = false) { |
|
1013 | 1013 | |
1014 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1014 | + if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) { |
|
1015 | 1015 | // Do not mark as expired since real expiration date is in the future |
1016 | 1016 | return false; |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - $this->set_status( 'expired' ); |
|
1019 | + $this->set_status('expired'); |
|
1020 | 1020 | return $this->save(); |
1021 | 1021 | |
1022 | 1022 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | * @return int Subscription id. |
1029 | 1029 | */ |
1030 | 1030 | public function failing() { |
1031 | - $this->set_status( 'failing' ); |
|
1031 | + $this->set_status('failing'); |
|
1032 | 1032 | return $this->save(); |
1033 | 1033 | } |
1034 | 1034 | |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | * @return int Subscription id. |
1040 | 1040 | */ |
1041 | 1041 | public function cancel() { |
1042 | - $this->set_status( 'cancelled' ); |
|
1042 | + $this->set_status('cancelled'); |
|
1043 | 1043 | return $this->save(); |
1044 | 1044 | } |
1045 | 1045 | |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | * @return bool |
1051 | 1051 | */ |
1052 | 1052 | public function can_cancel() { |
1053 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1053 | + return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this); |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | /** |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * @return array |
1062 | 1062 | */ |
1063 | 1063 | public function get_cancellable_statuses() { |
1064 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
1064 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | /** |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * @return string |
1072 | 1072 | */ |
1073 | 1073 | public function get_cancel_url() { |
1074 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1075 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1074 | + $url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url()); |
|
1075 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | /** |
@@ -1083,10 +1083,10 @@ discard block |
||
1083 | 1083 | */ |
1084 | 1084 | public function get_view_url() { |
1085 | 1085 | |
1086 | - $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1087 | - $url = add_query_arg( 'subscription', $this->get_id(), $url ); |
|
1086 | + $url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
1087 | + $url = add_query_arg('subscription', $this->get_id(), $url); |
|
1088 | 1088 | |
1089 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1089 | + return apply_filters('getpaid_get_subscription_view_url', $url, $this); |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | /** |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | * @return bool |
1100 | 1100 | */ |
1101 | 1101 | public function can_renew() { |
1102 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1102 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | /** |
@@ -1109,8 +1109,8 @@ discard block |
||
1109 | 1109 | * @return string |
1110 | 1110 | */ |
1111 | 1111 | public function get_renew_url() { |
1112 | - $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1113 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1112 | + $url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce'); |
|
1113 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | /** |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | * @return bool |
1121 | 1121 | */ |
1122 | 1122 | public function can_update() { |
1123 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1123 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | /** |
@@ -1130,8 +1130,8 @@ discard block |
||
1130 | 1130 | * @return string |
1131 | 1131 | */ |
1132 | 1132 | public function get_update_url() { |
1133 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1134 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1133 | + $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id())); |
|
1134 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | /** |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | * @return string |
1142 | 1142 | */ |
1143 | 1143 | public function get_status_label() { |
1144 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1144 | + return getpaid_get_subscription_status_label($this->get_status()); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | public function get_status_class() { |
1154 | 1154 | $statuses = getpaid_get_subscription_status_classes(); |
1155 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
1155 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | /** |
@@ -1163,9 +1163,9 @@ discard block |
||
1163 | 1163 | */ |
1164 | 1164 | public function get_status_label_html() { |
1165 | 1165 | |
1166 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1167 | - $class = esc_attr( $this->get_status_class() ); |
|
1168 | - $status = sanitize_html_class( $this->get_status() ); |
|
1166 | + $status_label = sanitize_text_field($this->get_status_label()); |
|
1167 | + $class = esc_attr($this->get_status_class()); |
|
1168 | + $status = sanitize_html_class($this->get_status()); |
|
1169 | 1169 | |
1170 | 1170 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
1171 | 1171 | } |
@@ -1177,9 +1177,9 @@ discard block |
||
1177 | 1177 | * @param string $txn_id The transaction ID from the merchant processor |
1178 | 1178 | * @return bool |
1179 | 1179 | */ |
1180 | - public function payment_exists( $txn_id = '' ) { |
|
1181 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1182 | - return ! empty( $invoice_id ); |
|
1180 | + public function payment_exists($txn_id = '') { |
|
1181 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id'); |
|
1182 | + return !empty($invoice_id); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /** |
@@ -1191,35 +1191,35 @@ discard block |
||
1191 | 1191 | // Reset status transition variable. |
1192 | 1192 | $this->status_transition = false; |
1193 | 1193 | |
1194 | - if ( $status_transition ) { |
|
1194 | + if ($status_transition) { |
|
1195 | 1195 | try { |
1196 | 1196 | |
1197 | 1197 | // Fire a hook for the status change. |
1198 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1199 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1198 | + do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
1199 | + do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition); |
|
1200 | 1200 | |
1201 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1201 | + if (!empty($status_transition['from'])) { |
|
1202 | 1202 | |
1203 | 1203 | /* translators: 1: old subscription status 2: new subscription status */ |
1204 | - $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1204 | + $transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1205 | 1205 | |
1206 | 1206 | // Note the transition occurred. |
1207 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1207 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1208 | 1208 | |
1209 | 1209 | // Fire another hook. |
1210 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1211 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1210 | + do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
1211 | + do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
1212 | 1212 | |
1213 | 1213 | } else { |
1214 | 1214 | /* translators: %s: new invoice status */ |
1215 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1215 | + $transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1216 | 1216 | |
1217 | 1217 | // Note the transition occurred. |
1218 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1218 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1219 | 1219 | |
1220 | 1220 | } |
1221 | - } catch ( Exception $e ) { |
|
1222 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1221 | + } catch (Exception $e) { |
|
1222 | + $this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
1223 | 1223 | } |
1224 | 1224 | } |
1225 | 1225 | |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | */ |
1246 | 1246 | public function activate() { |
1247 | 1247 | $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
1248 | - $this->set_status( $status ); |
|
1248 | + $this->set_status($status); |
|
1249 | 1249 | return $this->save(); |
1250 | 1250 | } |
1251 | 1251 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | * @deprecated |
20 | 20 | */ |
21 | 21 | function wpinv_get_invoice_cart() { |
22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @deprecated |
27 | 27 | */ |
28 | -function wpinv_get_invoice_description( $invoice ) { |
|
29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
28 | +function wpinv_get_invoice_description($invoice) { |
|
29 | + $invoice = new WPInv_Invoice($invoice); |
|
30 | 30 | return $invoice->get_description(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @deprecated |
35 | 35 | */ |
36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
37 | + $invoice = new WPInv_Invoice($invoice); |
|
38 | 38 | return $invoice->get_currency(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @deprecated |
43 | 43 | */ |
44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
44 | +function wpinv_get_payment_user_email($invoice) { |
|
45 | + $invoice = new WPInv_Invoice($invoice); |
|
46 | 46 | return $invoice->get_email(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @deprecated |
51 | 51 | */ |
52 | -function wpinv_get_user_id( $invoice ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
52 | +function wpinv_get_user_id($invoice) { |
|
53 | + $invoice = new WPInv_Invoice($invoice); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @deprecated |
59 | 59 | */ |
60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
61 | + $invoice = new WPInv_Invoice($invoice); |
|
62 | 62 | |
63 | - if ( $return_label ) { |
|
63 | + if ($return_label) { |
|
64 | 64 | return $invoice->get_status_nicename(); |
65 | 65 | } |
66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @deprecated |
72 | 72 | */ |
73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
74 | + $invoice = new WPInv_Invoice($invoice); |
|
75 | 75 | |
76 | - if ( $return_label ) { |
|
76 | + if ($return_label) { |
|
77 | 77 | return $invoice->get_gateway_title(); |
78 | 78 | } |
79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @deprecated |
85 | 85 | */ |
86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
87 | + return wpinv_get_payment_gateway($invoice, true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @deprecated |
92 | 92 | */ |
93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
94 | + $invoice = new WPInv_Invoice($invoice); |
|
95 | 95 | return $invoice->get_transaction_id(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @deprecated |
100 | 100 | */ |
101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
103 | - return $invoice->get_meta( $meta_key, $single ); |
|
101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
103 | + return $invoice->get_meta($meta_key, $single); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @deprecated |
108 | 108 | */ |
109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @deprecated |
116 | 116 | */ |
117 | -function wpinv_get_items( $invoice = 0 ) { |
|
118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
117 | +function wpinv_get_items($invoice = 0) { |
|
118 | + $invoice = new WPInv_Invoice($invoice); |
|
119 | 119 | return $invoice->get_items(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @deprecated |
124 | 124 | */ |
125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
125 | +function wpinv_get_fees($invoice = 0) { |
|
126 | + $invoice = new WPInv_Invoice($invoice); |
|
127 | 127 | return $invoice->get_fees(); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @deprecated |
132 | 132 | */ |
133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
133 | +function wpinv_get_invoice_ip($invoice) { |
|
134 | + $invoice = new WPInv_Invoice($invoice); |
|
135 | 135 | return $invoice->get_ip(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated |
140 | 140 | */ |
141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
141 | +function wpinv_get_invoice_user_info($invoice) { |
|
142 | + $invoice = new WPInv_Invoice($invoice); |
|
143 | 143 | return $invoice->get_user_info(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @deprecated |
148 | 148 | */ |
149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
150 | + $invoice = new WPInv_Invoice($invoice); |
|
151 | 151 | $subtotal = $invoice->get_subtotal(); |
152 | 152 | |
153 | - if ( $currency ) { |
|
154 | - return wpinv_price( $subtotal, $invoice->get_currency() ); |
|
153 | + if ($currency) { |
|
154 | + return wpinv_price($subtotal, $invoice->get_currency()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * @deprecated |
162 | 162 | */ |
163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
164 | + $invoice = new WPInv_Invoice($invoice); |
|
165 | 165 | $tax = $invoice->get_total_tax(); |
166 | 166 | |
167 | - if ( $currency ) { |
|
168 | - return wpinv_price( $tax, $invoice->get_currency() ); |
|
167 | + if ($currency) { |
|
168 | + return wpinv_price($tax, $invoice->get_currency()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @deprecated |
176 | 176 | */ |
177 | -function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) { |
|
178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
177 | +function wpinv_discount($invoice = 0, $currency = false, $deprecated) { |
|
178 | + $invoice = new WPInv_Invoice($invoice); |
|
179 | 179 | $discount = $invoice->get_total_discount(); |
180 | 180 | |
181 | - if ( $currency ) { |
|
182 | - return wpinv_price( $discount, $invoice->get_currency() ); |
|
181 | + if ($currency) { |
|
182 | + return wpinv_price($discount, $invoice->get_currency()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @deprecated |
190 | 190 | */ |
191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
191 | +function wpinv_discount_code($invoice = 0) { |
|
192 | + $invoice = new WPInv_Invoice($invoice); |
|
193 | 193 | return $invoice->get_discount_code(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @deprecated |
198 | 198 | */ |
199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice); |
|
201 | 201 | $total = $invoice->get_total(); |
202 | 202 | |
203 | - if ( $currency ) { |
|
204 | - return wpinv_price( $total, $invoice->get_currency() ); |
|
203 | + if ($currency) { |
|
204 | + return wpinv_price($total, $invoice->get_currency()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @deprecated |
212 | 212 | */ |
213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
214 | + $invoice = new WPInv_Invoice($invoice); |
|
215 | 215 | |
216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
217 | 217 | $date_created = $invoice->get_created_date(); |
218 | 218 | |
219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @deprecated |
224 | 224 | */ |
225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
226 | - wpinv_get_date_created( $invoice, $format ); |
|
225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
226 | + wpinv_get_date_created($invoice, $format); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @deprecated |
231 | 231 | */ |
232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
233 | + $invoice = new WPInv_Invoice($invoice); |
|
234 | 234 | return $invoice->get_vat_number(); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
241 | + $invoice = new WPInv_Invoice($invoice); |
|
242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
248 | +function wpinv_get_payment_key($invoice = 0) { |
|
249 | + $invoice = new WPInv_Invoice($invoice); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @deprecated |
255 | 255 | */ |
256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
257 | + $invoice = new WPInv_Invoice($invoice); |
|
258 | 258 | return $invoice->get_number(); |
259 | 259 | } |
260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @deprecated |
403 | 403 | */ |
404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | - return $invoice->update_status( $new_status ); |
|
404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
405 | + $invoice = new WPInv_Invoice($invoice); |
|
406 | + return $invoice->update_status($new_status); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @deprecated |
458 | 458 | */ |
459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
460 | 460 | |
461 | 461 | // Fetch the invoice. |
462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
463 | 463 | |
464 | - if ( 0 == $invoice->get_id() ) { |
|
464 | + if (0 == $invoice->get_id()) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Prepare the transaction id. |
469 | - if ( empty( $transaction_id ) ) { |
|
469 | + if (empty($transaction_id)) { |
|
470 | 470 | $transaction_id = $invoice_id; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Set the transaction id; |
474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
475 | 475 | |
476 | 476 | // Save the invoice. |
477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | * @param WPInv_Invoice $invoice |
485 | 485 | * @param string $gateway |
486 | 486 | */ |
487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
488 | 488 | |
489 | 489 | $payment_data = array( |
490 | 490 | 'invoice_id' => $invoice->get_id(), |
491 | 491 | 'items' => $invoice->get_cart_details(), |
492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
493 | 493 | 'fees' => $invoice->get_total_fees(), |
494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | 'price' => $invoice->get_total(), |
498 | 498 | 'invoice_key' => $invoice->get_key(), |
499 | 499 | 'user_email' => $invoice->get_email(), |
500 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
500 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
501 | 501 | 'user_info' => $invoice->get_user_info(), |
502 | - 'post_data' => stripslashes_deep( $_POST ), |
|
502 | + 'post_data' => stripslashes_deep($_POST), |
|
503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
504 | 504 | 'gateway' => $gateway, |
505 | 505 | 'card_info' => array(), |
506 | 506 | 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
507 | 507 | ); |
508 | 508 | |
509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @deprecated |
521 | 521 | */ |
522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
525 | - wp_die( $message, $title, array( 'response' => $status )); |
|
522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
525 | + wp_die($message, $title, array('response' => $status)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * @deprecated |
642 | 642 | */ |
643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * @deprecated |
649 | 649 | */ |
650 | -function wpinv_clean_invoice_number( $number ) { |
|
650 | +function wpinv_clean_invoice_number($number) { |
|
651 | 651 | return $number; |
652 | 652 | } |
653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
852 | 852 | /** |
853 | 853 | * @deprecated |
854 | 854 | */ |
855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
856 | 856 | |
857 | - if ( $echo ) { |
|
858 | - echo wpinv_item_price( $item_id ); |
|
857 | + if ($echo) { |
|
858 | + echo wpinv_item_price($item_id); |
|
859 | 859 | } else { |
860 | - return wpinv_item_price( $item_id ); |
|
860 | + return wpinv_item_price($item_id); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
@@ -1272,6 +1272,6 @@ discard block |
||
1272 | 1272 | * @return WPInv_Subscription|bool |
1273 | 1273 | * @deprecated |
1274 | 1274 | */ |
1275 | -function wpinv_get_subscription( $invoice ) { |
|
1276 | - return wpinv_get_invoice_subscription( $invoice ); |
|
1275 | +function wpinv_get_subscription($invoice) { |
|
1276 | + return wpinv_get_invoice_subscription($invoice); |
|
1277 | 1277 | } |