@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( ! defined( 'WPINC' ) ) { |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * Invoice id. |
| 21 | 21 | */ |
| 22 | - public $ID = 0; |
|
| 22 | + public $ID = 0; |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * The title of the invoice. Usually the invoice number. |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | /** |
| 136 | 136 | * The invoice status. |
| 137 | 137 | */ |
| 138 | - public $status = 'wpi-pending'; |
|
| 138 | + public $status = 'wpi-pending'; |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Same as self::$status. |
@@ -262,17 +262,17 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | public $parent_invoice = 0; |
| 264 | 264 | |
| 265 | - public function __construct( $invoice_id = false ) { |
|
| 266 | - if ( empty( $invoice_id ) ) { |
|
| 265 | + public function __construct($invoice_id = false) { |
|
| 266 | + if (empty($invoice_id)) { |
|
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $this->setup_invoice( $invoice_id ); |
|
| 270 | + $this->setup_invoice($invoice_id); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - public function get( $key ) { |
|
| 274 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 275 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
| 273 | + public function get($key) { |
|
| 274 | + if (method_exists($this, 'get_' . $key)) { |
|
| 275 | + $value = call_user_func(array($this, 'get_' . $key)); |
|
| 276 | 276 | } else { |
| 277 | 277 | $value = $this->$key; |
| 278 | 278 | } |
@@ -280,43 +280,43 @@ discard block |
||
| 280 | 280 | return $value; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - public function set( $key, $value ) { |
|
| 284 | - $ignore = array( 'items', 'cart_details', 'fees', '_ID' ); |
|
| 283 | + public function set($key, $value) { |
|
| 284 | + $ignore = array('items', 'cart_details', 'fees', '_ID'); |
|
| 285 | 285 | |
| 286 | - if ( $key === 'status' ) { |
|
| 286 | + if ($key === 'status') { |
|
| 287 | 287 | $this->old_status = $this->status; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if ( ! in_array( $key, $ignore ) ) { |
|
| 291 | - $this->pending[ $key ] = $value; |
|
| 290 | + if (!in_array($key, $ignore)) { |
|
| 291 | + $this->pending[$key] = $value; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - if ( '_ID' !== $key ) { |
|
| 294 | + if ('_ID' !== $key) { |
|
| 295 | 295 | $this->$key = $value; |
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - public function _isset( $name ) { |
|
| 300 | - if ( property_exists( $this, $name ) ) { |
|
| 301 | - return false === empty( $this->$name ); |
|
| 299 | + public function _isset($name) { |
|
| 300 | + if (property_exists($this, $name)) { |
|
| 301 | + return false === empty($this->$name); |
|
| 302 | 302 | } else { |
| 303 | 303 | return null; |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - private function setup_invoice( $invoice_id ) { |
|
| 307 | + private function setup_invoice($invoice_id) { |
|
| 308 | 308 | $this->pending = array(); |
| 309 | 309 | |
| 310 | - $invoice = get_post( $invoice_id ); |
|
| 310 | + $invoice = get_post($invoice_id); |
|
| 311 | 311 | |
| 312 | - if ( ! $invoice || is_wp_error( $invoice ) ) { |
|
| 312 | + if (!$invoice || is_wp_error($invoice)) { |
|
| 313 | 313 | return false; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id ); |
|
| 316 | + do_action('wpinv_pre_setup_invoice', $this, $invoice_id); |
|
| 317 | 317 | |
| 318 | 318 | // Primary Identifier |
| 319 | - $this->ID = absint( $invoice_id ); |
|
| 319 | + $this->ID = absint($invoice_id); |
|
| 320 | 320 | $this->post_type = $invoice->post_type; |
| 321 | 321 | |
| 322 | 322 | // We have a payment, get the generic payment_meta item to reduce calls to it |
@@ -326,15 +326,15 @@ discard block |
||
| 326 | 326 | $this->completed_date = $this->setup_completed_date(); |
| 327 | 327 | $this->status = $invoice->post_status; |
| 328 | 328 | |
| 329 | - if ( 'future' == $this->status ) { |
|
| 329 | + if ('future' == $this->status) { |
|
| 330 | 330 | $this->status = 'publish'; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | $this->post_status = $this->status; |
| 334 | 334 | $this->mode = $this->setup_mode(); |
| 335 | 335 | $this->parent_invoice = $invoice->post_parent; |
| 336 | - $this->post_name = $this->setup_post_name( $invoice ); |
|
| 337 | - $this->status_nicename = $this->setup_status_nicename( $invoice->post_status ); |
|
| 336 | + $this->post_name = $this->setup_post_name($invoice); |
|
| 337 | + $this->status_nicename = $this->setup_status_nicename($invoice->post_status); |
|
| 338 | 338 | |
| 339 | 339 | // Items |
| 340 | 340 | $this->fees = $this->setup_fees(); |
@@ -356,8 +356,8 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | // User based |
| 358 | 358 | $this->ip = $this->setup_ip(); |
| 359 | - $this->user_id = ! empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id(); |
|
| 360 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
| 359 | + $this->user_id = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id(); |
|
| 360 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
| 361 | 361 | |
| 362 | 362 | $this->user_info = $this->setup_user_info(); |
| 363 | 363 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | $this->company = $this->user_info['company']; |
| 367 | 367 | $this->vat_number = $this->user_info['vat_number']; |
| 368 | 368 | $this->vat_rate = $this->user_info['vat_rate']; |
| 369 | - $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
| 369 | + $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
| 370 | 370 | $this->address = $this->user_info['address']; |
| 371 | 371 | $this->city = $this->user_info['city']; |
| 372 | 372 | $this->country = $this->user_info['country']; |
@@ -381,31 +381,31 @@ discard block |
||
| 381 | 381 | // Other Identifiers |
| 382 | 382 | $this->key = $this->setup_invoice_key(); |
| 383 | 383 | $this->number = $this->setup_invoice_number(); |
| 384 | - $this->title = ! empty( $invoice->post_title ) ? $invoice->post_title : $this->number; |
|
| 384 | + $this->title = !empty($invoice->post_title) ? $invoice->post_title : $this->number; |
|
| 385 | 385 | |
| 386 | - $this->full_name = trim( $this->first_name . ' ' . $this->last_name ); |
|
| 386 | + $this->full_name = trim($this->first_name . ' ' . $this->last_name); |
|
| 387 | 387 | |
| 388 | 388 | // Allow extensions to add items to this object via hook |
| 389 | - do_action( 'wpinv_setup_invoice', $this, $invoice_id ); |
|
| 389 | + do_action('wpinv_setup_invoice', $this, $invoice_id); |
|
| 390 | 390 | |
| 391 | 391 | return true; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - private function setup_status_nicename( $status ) { |
|
| 394 | + private function setup_status_nicename($status) { |
|
| 395 | 395 | return $status; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - private function setup_post_name( $post ) { |
|
| 398 | + private function setup_post_name($post) { |
|
| 399 | 399 | $this->post_name = $post->post_name; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | private function setup_due_date() { |
| 403 | - $due_date = $this->get_meta( '_wpinv_due_date' ); |
|
| 403 | + $due_date = $this->get_meta('_wpinv_due_date'); |
|
| 404 | 404 | |
| 405 | - if ( empty( $due_date ) ) { |
|
| 406 | - $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days', 0 ) ) ); |
|
| 407 | - $due_date = date_i18n( 'Y-m-d', $overdue_time ); |
|
| 408 | - } elseif ( $due_date == 'none' ) { |
|
| 405 | + if (empty($due_date)) { |
|
| 406 | + $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days', 0))); |
|
| 407 | + $due_date = date_i18n('Y-m-d', $overdue_time); |
|
| 408 | + } elseif ($due_date == 'none') { |
|
| 409 | 409 | $due_date = ''; |
| 410 | 410 | } |
| 411 | 411 | |
@@ -413,67 +413,67 @@ discard block |
||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | private function setup_completed_date() { |
| 416 | - $invoice = get_post( $this->ID ); |
|
| 416 | + $invoice = get_post($this->ID); |
|
| 417 | 417 | |
| 418 | - if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) { |
|
| 418 | + if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) { |
|
| 419 | 419 | return false; // This invoice was never paid |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date; |
|
| 422 | + $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date; |
|
| 423 | 423 | |
| 424 | 424 | return $date; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | private function setup_cart_details() { |
| 428 | - $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array(); |
|
| 428 | + $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array(); |
|
| 429 | 429 | return $cart_details; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | public function array_convert() { |
| 433 | - return get_object_vars( $this ); |
|
| 433 | + return get_object_vars($this); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | private function setup_items() { |
| 437 | - $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array(); |
|
| 437 | + $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array(); |
|
| 438 | 438 | return $items; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | private function setup_fees() { |
| 442 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 442 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 443 | 443 | return $payment_fees; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | private function setup_currency() { |
| 447 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this ); |
|
| 447 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this); |
|
| 448 | 448 | return $currency; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | private function setup_discount() { |
| 452 | 452 | //$discount = $this->get_meta( '_wpinv_discount', true ); |
| 453 | - $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total ); |
|
| 454 | - if ( $discount < 0 ) { |
|
| 453 | + $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total); |
|
| 454 | + if ($discount < 0) { |
|
| 455 | 455 | $discount = 0; |
| 456 | 456 | } |
| 457 | - $discount = wpinv_round_amount( $discount ); |
|
| 457 | + $discount = wpinv_round_amount($discount); |
|
| 458 | 458 | |
| 459 | 459 | return $discount; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | private function setup_discount_code() { |
| 463 | - $discount_code = ! empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true ); |
|
| 463 | + $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true); |
|
| 464 | 464 | return $discount_code; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | private function setup_tax() { |
| 468 | 468 | |
| 469 | - $tax = $this->get_meta( '_wpinv_tax', true ); |
|
| 469 | + $tax = $this->get_meta('_wpinv_tax', true); |
|
| 470 | 470 | |
| 471 | 471 | // We don't have tax as it's own meta and no meta was passed |
| 472 | - if ( '' === $tax ) { |
|
| 473 | - $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0; |
|
| 472 | + if ('' === $tax) { |
|
| 473 | + $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0; |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - if ( $tax < 0 || ! $this->is_taxable() ) { |
|
| 476 | + if ($tax < 0 || !$this->is_taxable()) { |
|
| 477 | 477 | $tax = 0; |
| 478 | 478 | } |
| 479 | 479 | |
@@ -484,16 +484,16 @@ discard block |
||
| 484 | 484 | * If taxes are enabled, allow users to enable/disable taxes per invoice. |
| 485 | 485 | */ |
| 486 | 486 | private function setup_is_taxable() { |
| 487 | - return (int) $this->get_meta( '_wpinv_disable_taxes', true ); |
|
| 487 | + return (int) $this->get_meta('_wpinv_disable_taxes', true); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | private function setup_subtotal() { |
| 491 | 491 | $subtotal = 0; |
| 492 | 492 | $cart_details = $this->cart_details; |
| 493 | 493 | |
| 494 | - if ( is_array( $cart_details ) ) { |
|
| 495 | - foreach ( $cart_details as $item ) { |
|
| 496 | - if ( isset( $item['subtotal'] ) ) { |
|
| 494 | + if (is_array($cart_details)) { |
|
| 495 | + foreach ($cart_details as $item) { |
|
| 496 | + if (isset($item['subtotal'])) { |
|
| 497 | 497 | $subtotal += $item['subtotal']; |
| 498 | 498 | } |
| 499 | 499 | } |
@@ -507,23 +507,23 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | private function setup_discounts() { |
| 510 | - $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array(); |
|
| 510 | + $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array(); |
|
| 511 | 511 | return $discounts; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | private function setup_total() { |
| 515 | - $amount = $this->get_meta( '_wpinv_total', true ); |
|
| 515 | + $amount = $this->get_meta('_wpinv_total', true); |
|
| 516 | 516 | |
| 517 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
| 518 | - $meta = $this->get_meta( '_wpinv_payment_meta', true ); |
|
| 519 | - $meta = maybe_unserialize( $meta ); |
|
| 517 | + if (empty($amount) && '0.00' != $amount) { |
|
| 518 | + $meta = $this->get_meta('_wpinv_payment_meta', true); |
|
| 519 | + $meta = maybe_unserialize($meta); |
|
| 520 | 520 | |
| 521 | - if ( isset( $meta['amount'] ) ) { |
|
| 521 | + if (isset($meta['amount'])) { |
|
| 522 | 522 | $amount = $meta['amount']; |
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - if ( $amount < 0 ) { |
|
| 526 | + if ($amount < 0) { |
|
| 527 | 527 | $amount = 0; |
| 528 | 528 | } |
| 529 | 529 | |
@@ -531,13 +531,13 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | private function setup_mode() { |
| 534 | - return $this->get_meta( '_wpinv_mode' ); |
|
| 534 | + return $this->get_meta('_wpinv_mode'); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | private function setup_gateway() { |
| 538 | - $gateway = $this->get_meta( '_wpinv_gateway' ); |
|
| 538 | + $gateway = $this->get_meta('_wpinv_gateway'); |
|
| 539 | 539 | |
| 540 | - if ( empty( $gateway ) && 'publish' === $this->status ) { |
|
| 540 | + if (empty($gateway) && 'publish' === $this->status) { |
|
| 541 | 541 | $gateway = 'manual'; |
| 542 | 542 | } |
| 543 | 543 | |
@@ -545,23 +545,23 @@ discard block |
||
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | private function setup_gateway_title() { |
| 548 | - $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway ); |
|
| 548 | + $gateway_title = wpinv_get_gateway_checkout_label($this->gateway); |
|
| 549 | 549 | return $gateway_title; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | private function setup_transaction_id() { |
| 553 | - $transaction_id = $this->get_meta( '_wpinv_transaction_id' ); |
|
| 553 | + $transaction_id = $this->get_meta('_wpinv_transaction_id'); |
|
| 554 | 554 | |
| 555 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
| 555 | + if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) { |
|
| 556 | 556 | $gateway = $this->gateway; |
| 557 | - $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID ); |
|
| 557 | + $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | return $transaction_id; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | private function setup_ip() { |
| 564 | - $ip = $this->get_meta( '_wpinv_user_ip' ); |
|
| 564 | + $ip = $this->get_meta('_wpinv_user_ip'); |
|
| 565 | 565 | return $ip; |
| 566 | 566 | } |
| 567 | 567 | |
@@ -571,62 +571,62 @@ discard block |
||
| 571 | 571 | ///} |
| 572 | 572 | |
| 573 | 573 | private function setup_first_name() { |
| 574 | - $first_name = $this->get_meta( '_wpinv_first_name' ); |
|
| 574 | + $first_name = $this->get_meta('_wpinv_first_name'); |
|
| 575 | 575 | return $first_name; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | private function setup_last_name() { |
| 579 | - $last_name = $this->get_meta( '_wpinv_last_name' ); |
|
| 579 | + $last_name = $this->get_meta('_wpinv_last_name'); |
|
| 580 | 580 | return $last_name; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | private function setup_company() { |
| 584 | - $company = $this->get_meta( '_wpinv_company' ); |
|
| 584 | + $company = $this->get_meta('_wpinv_company'); |
|
| 585 | 585 | return $company; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | private function setup_vat_number() { |
| 589 | - $vat_number = $this->get_meta( '_wpinv_vat_number' ); |
|
| 589 | + $vat_number = $this->get_meta('_wpinv_vat_number'); |
|
| 590 | 590 | return $vat_number; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | private function setup_vat_rate() { |
| 594 | - $vat_rate = $this->get_meta( '_wpinv_vat_rate' ); |
|
| 594 | + $vat_rate = $this->get_meta('_wpinv_vat_rate'); |
|
| 595 | 595 | return $vat_rate; |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | private function setup_adddress_confirmed() { |
| 599 | - $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' ); |
|
| 599 | + $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed'); |
|
| 600 | 600 | return $adddress_confirmed; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | private function setup_phone() { |
| 604 | - $phone = $this->get_meta( '_wpinv_phone' ); |
|
| 604 | + $phone = $this->get_meta('_wpinv_phone'); |
|
| 605 | 605 | return $phone; |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | private function setup_address() { |
| 609 | - $address = $this->get_meta( '_wpinv_address', true ); |
|
| 609 | + $address = $this->get_meta('_wpinv_address', true); |
|
| 610 | 610 | return $address; |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | private function setup_city() { |
| 614 | - $city = $this->get_meta( '_wpinv_city', true ); |
|
| 614 | + $city = $this->get_meta('_wpinv_city', true); |
|
| 615 | 615 | return $city; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | private function setup_country() { |
| 619 | - $country = $this->get_meta( '_wpinv_country', true ); |
|
| 619 | + $country = $this->get_meta('_wpinv_country', true); |
|
| 620 | 620 | return $country; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | private function setup_state() { |
| 624 | - $state = $this->get_meta( '_wpinv_state', true ); |
|
| 624 | + $state = $this->get_meta('_wpinv_state', true); |
|
| 625 | 625 | return $state; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | private function setup_zip() { |
| 629 | - $zip = $this->get_meta( '_wpinv_zip', true ); |
|
| 629 | + $zip = $this->get_meta('_wpinv_zip', true); |
|
| 630 | 630 | return $zip; |
| 631 | 631 | } |
| 632 | 632 | |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | 'user_id' => $this->user_id, |
| 636 | 636 | 'first_name' => $this->first_name, |
| 637 | 637 | 'last_name' => $this->last_name, |
| 638 | - 'email' => get_the_author_meta( 'email', $this->user_id ), |
|
| 638 | + 'email' => get_the_author_meta('email', $this->user_id), |
|
| 639 | 639 | 'phone' => $this->phone, |
| 640 | 640 | 'address' => $this->address, |
| 641 | 641 | 'city' => $this->city, |
@@ -650,12 +650,12 @@ discard block |
||
| 650 | 650 | ); |
| 651 | 651 | |
| 652 | 652 | $user_info = array(); |
| 653 | - if ( isset( $this->payment_meta['user_info'] ) ) { |
|
| 654 | - $user_info = maybe_unserialize( $this->payment_meta['user_info'] ); |
|
| 653 | + if (isset($this->payment_meta['user_info'])) { |
|
| 654 | + $user_info = maybe_unserialize($this->payment_meta['user_info']); |
|
| 655 | 655 | |
| 656 | - if ( ! empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) { |
|
| 656 | + if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) { |
|
| 657 | 657 | $this->user_id = $post->post_author; |
| 658 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
| 658 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
| 659 | 659 | |
| 660 | 660 | $user_info['user_id'] = $this->user_id; |
| 661 | 661 | $user_info['email'] = $this->email; |
@@ -664,13 +664,13 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
| 667 | + $user_info = wp_parse_args($user_info, $defaults); |
|
| 668 | 668 | |
| 669 | 669 | // Get the user, but only if it's been created |
| 670 | - $user = get_userdata( $this->user_id ); |
|
| 670 | + $user = get_userdata($this->user_id); |
|
| 671 | 671 | |
| 672 | - if ( ! empty( $user ) && $user->ID > 0 ) { |
|
| 673 | - if ( empty( $user_info ) ) { |
|
| 672 | + if (!empty($user) && $user->ID > 0) { |
|
| 673 | + if (empty($user_info)) { |
|
| 674 | 674 | $user_info = array( |
| 675 | 675 | 'user_id' => $user->ID, |
| 676 | 676 | 'first_name' => $user->first_name, |
@@ -679,23 +679,23 @@ discard block |
||
| 679 | 679 | 'discount' => '', |
| 680 | 680 | ); |
| 681 | 681 | } else { |
| 682 | - foreach ( $user_info as $key => $value ) { |
|
| 683 | - if ( ! empty( $value ) ) { |
|
| 682 | + foreach ($user_info as $key => $value) { |
|
| 683 | + if (!empty($value)) { |
|
| 684 | 684 | continue; |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - switch ( $key ) { |
|
| 687 | + switch ($key) { |
|
| 688 | 688 | case 'user_id': |
| 689 | - $user_info[ $key ] = $user->ID; |
|
| 689 | + $user_info[$key] = $user->ID; |
|
| 690 | 690 | break; |
| 691 | 691 | case 'first_name': |
| 692 | - $user_info[ $key ] = $user->first_name; |
|
| 692 | + $user_info[$key] = $user->first_name; |
|
| 693 | 693 | break; |
| 694 | 694 | case 'last_name': |
| 695 | - $user_info[ $key ] = $user->last_name; |
|
| 695 | + $user_info[$key] = $user->last_name; |
|
| 696 | 696 | break; |
| 697 | 697 | case 'email': |
| 698 | - $user_info[ $key ] = $user->user_email; |
|
| 698 | + $user_info[$key] = $user->user_email; |
|
| 699 | 699 | break; |
| 700 | 700 | } |
| 701 | 701 | } |
@@ -706,25 +706,25 @@ discard block |
||
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | private function setup_invoice_key() { |
| 709 | - $key = $this->get_meta( '_wpinv_key', true ); |
|
| 709 | + $key = $this->get_meta('_wpinv_key', true); |
|
| 710 | 710 | |
| 711 | 711 | return $key; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | private function setup_invoice_number() { |
| 715 | - $number = $this->get_meta( '_wpinv_number', true ); |
|
| 715 | + $number = $this->get_meta('_wpinv_number', true); |
|
| 716 | 716 | |
| 717 | - if ( ! $number ) { |
|
| 717 | + if (!$number) { |
|
| 718 | 718 | $number = $this->ID; |
| 719 | 719 | |
| 720 | - if ( $this->status == 'auto-draft' ) { |
|
| 721 | - if ( wpinv_sequential_number_active( $this->post_type ) ) { |
|
| 722 | - $next_number = wpinv_get_next_invoice_number( $this->post_type ); |
|
| 720 | + if ($this->status == 'auto-draft') { |
|
| 721 | + if (wpinv_sequential_number_active($this->post_type)) { |
|
| 722 | + $next_number = wpinv_get_next_invoice_number($this->post_type); |
|
| 723 | 723 | $number = $next_number; |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
| 727 | + $number = wpinv_format_invoice_number($number, $this->post_type); |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | return $number; |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | public function save() {} |
| 734 | 734 | |
| 735 | - public function add_fee( $args ) { |
|
| 735 | + public function add_fee($args) { |
|
| 736 | 736 | $default_args = array( |
| 737 | 737 | 'label' => '', |
| 738 | 738 | 'amount' => 0, |
@@ -742,36 +742,36 @@ discard block |
||
| 742 | 742 | 'item_id' => 0, |
| 743 | 743 | ); |
| 744 | 744 | |
| 745 | - $fee = wp_parse_args( $args, $default_args ); |
|
| 745 | + $fee = wp_parse_args($args, $default_args); |
|
| 746 | 746 | |
| 747 | - if ( empty( $fee['label'] ) ) { |
|
| 747 | + if (empty($fee['label'])) { |
|
| 748 | 748 | return false; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - $fee['id'] = sanitize_title( $fee['label'] ); |
|
| 751 | + $fee['id'] = sanitize_title($fee['label']); |
|
| 752 | 752 | |
| 753 | - $this->fees[] = $fee; |
|
| 753 | + $this->fees[] = $fee; |
|
| 754 | 754 | |
| 755 | 755 | $added_fee = $fee; |
| 756 | 756 | $added_fee['action'] = 'add'; |
| 757 | 757 | $this->pending['fees'][] = $added_fee; |
| 758 | - reset( $this->fees ); |
|
| 758 | + reset($this->fees); |
|
| 759 | 759 | |
| 760 | - $this->increase_fees( $fee['amount'] ); |
|
| 760 | + $this->increase_fees($fee['amount']); |
|
| 761 | 761 | return true; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - public function remove_fee( $key ) { |
|
| 764 | + public function remove_fee($key) { |
|
| 765 | 765 | $removed = false; |
| 766 | 766 | |
| 767 | - if ( is_numeric( $key ) ) { |
|
| 768 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
| 767 | + if (is_numeric($key)) { |
|
| 768 | + $removed = $this->remove_fee_by('index', $key); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | return $removed; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
| 774 | + public function remove_fee_by($key, $value, $global = false) { |
|
| 775 | 775 | $allowed_fee_keys = apply_filters( |
| 776 | 776 | 'wpinv_fee_keys', |
| 777 | 777 | array( |
@@ -782,41 +782,41 @@ discard block |
||
| 782 | 782 | ) |
| 783 | 783 | ); |
| 784 | 784 | |
| 785 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
| 785 | + if (!in_array($key, $allowed_fee_keys)) { |
|
| 786 | 786 | return false; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | $removed = false; |
| 790 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
| 791 | - $removed_fee = $this->fees[ $value ]; |
|
| 790 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
| 791 | + $removed_fee = $this->fees[$value]; |
|
| 792 | 792 | $removed_fee['action'] = 'remove'; |
| 793 | 793 | $this->pending['fees'][] = $removed_fee; |
| 794 | 794 | |
| 795 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 795 | + $this->decrease_fees($removed_fee['amount']); |
|
| 796 | 796 | |
| 797 | - unset( $this->fees[ $value ] ); |
|
| 797 | + unset($this->fees[$value]); |
|
| 798 | 798 | $removed = true; |
| 799 | - } elseif ( 'index' !== $key ) { |
|
| 800 | - foreach ( $this->fees as $index => $fee ) { |
|
| 801 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
| 799 | + } elseif ('index' !== $key) { |
|
| 800 | + foreach ($this->fees as $index => $fee) { |
|
| 801 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
| 802 | 802 | $removed_fee = $fee; |
| 803 | 803 | $removed_fee['action'] = 'remove'; |
| 804 | 804 | $this->pending['fees'][] = $removed_fee; |
| 805 | 805 | |
| 806 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 806 | + $this->decrease_fees($removed_fee['amount']); |
|
| 807 | 807 | |
| 808 | - unset( $this->fees[ $index ] ); |
|
| 808 | + unset($this->fees[$index]); |
|
| 809 | 809 | $removed = true; |
| 810 | 810 | |
| 811 | - if ( false === $global ) { |
|
| 811 | + if (false === $global) { |
|
| 812 | 812 | break; |
| 813 | 813 | } |
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - if ( true === $removed ) { |
|
| 819 | - $this->fees = array_values( $this->fees ); |
|
| 818 | + if (true === $removed) { |
|
| 819 | + $this->fees = array_values($this->fees); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | return $removed; |
@@ -824,28 +824,28 @@ discard block |
||
| 824 | 824 | |
| 825 | 825 | |
| 826 | 826 | |
| 827 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 827 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 828 | 828 | // Bail if no note specified |
| 829 | - if ( ! $note ) { |
|
| 829 | + if (!$note) { |
|
| 830 | 830 | return false; |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - if ( empty( $this->ID ) ) { |
|
| 833 | + if (empty($this->ID)) { |
|
| 834 | 834 | return false; |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && ! $system ) { |
|
| 838 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 837 | + if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) { |
|
| 838 | + $user = get_user_by('id', get_current_user_id()); |
|
| 839 | 839 | $comment_author = $user->display_name; |
| 840 | 840 | $comment_author_email = $user->user_email; |
| 841 | 841 | } else { |
| 842 | 842 | $comment_author = 'System'; |
| 843 | 843 | $comment_author_email = 'system@'; |
| 844 | - $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com'; |
|
| 845 | - $comment_author_email = sanitize_email( $comment_author_email ); |
|
| 844 | + $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com'; |
|
| 845 | + $comment_author_email = sanitize_email($comment_author_email); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type ); |
|
| 848 | + do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type); |
|
| 849 | 849 | |
| 850 | 850 | $note_id = wp_insert_comment( |
| 851 | 851 | wp_filter_comment( |
@@ -854,8 +854,8 @@ discard block |
||
| 854 | 854 | 'comment_content' => $note, |
| 855 | 855 | 'comment_agent' => 'WPInvoicing', |
| 856 | 856 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 857 | - 'comment_date' => current_time( 'mysql' ), |
|
| 858 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 857 | + 'comment_date' => current_time('mysql'), |
|
| 858 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 859 | 859 | 'comment_approved' => 1, |
| 860 | 860 | 'comment_parent' => 0, |
| 861 | 861 | 'comment_author' => $comment_author, |
@@ -867,10 +867,10 @@ discard block |
||
| 867 | 867 | ) |
| 868 | 868 | ); |
| 869 | 869 | |
| 870 | - do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note ); |
|
| 870 | + do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note); |
|
| 871 | 871 | |
| 872 | - if ( $customer_type ) { |
|
| 873 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 872 | + if ($customer_type) { |
|
| 873 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
| 874 | 874 | |
| 875 | 875 | do_action( |
| 876 | 876 | 'wpinv_new_customer_note', |
@@ -884,40 +884,40 @@ discard block |
||
| 884 | 884 | return $note_id; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - private function increase_subtotal( $amount = 0.00 ) { |
|
| 887 | + private function increase_subtotal($amount = 0.00) { |
|
| 888 | 888 | $amount = (float) $amount; |
| 889 | 889 | $this->subtotal += $amount; |
| 890 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
| 890 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
| 891 | 891 | |
| 892 | 892 | $this->recalculate_total(); |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
| 895 | + private function decrease_subtotal($amount = 0.00) { |
|
| 896 | 896 | $amount = (float) $amount; |
| 897 | 897 | $this->subtotal -= $amount; |
| 898 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
| 898 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
| 899 | 899 | |
| 900 | - if ( $this->subtotal < 0 ) { |
|
| 900 | + if ($this->subtotal < 0) { |
|
| 901 | 901 | $this->subtotal = 0; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | $this->recalculate_total(); |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - private function increase_fees( $amount = 0.00 ) { |
|
| 908 | - $amount = (float)$amount; |
|
| 907 | + private function increase_fees($amount = 0.00) { |
|
| 908 | + $amount = (float) $amount; |
|
| 909 | 909 | $this->fees_total += $amount; |
| 910 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
| 910 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
| 911 | 911 | |
| 912 | 912 | $this->recalculate_total(); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - private function decrease_fees( $amount = 0.00 ) { |
|
| 915 | + private function decrease_fees($amount = 0.00) { |
|
| 916 | 916 | $amount = (float) $amount; |
| 917 | 917 | $this->fees_total -= $amount; |
| 918 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
| 918 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
| 919 | 919 | |
| 920 | - if ( $this->fees_total < 0 ) { |
|
| 920 | + if ($this->fees_total < 0) { |
|
| 921 | 921 | $this->fees_total = 0; |
| 922 | 922 | } |
| 923 | 923 | |
@@ -928,56 +928,56 @@ discard block |
||
| 928 | 928 | global $wpi_nosave; |
| 929 | 929 | |
| 930 | 930 | $this->total = $this->subtotal + $this->tax + $this->fees_total; |
| 931 | - $this->total = wpinv_round_amount( $this->total ); |
|
| 931 | + $this->total = wpinv_round_amount($this->total); |
|
| 932 | 932 | |
| 933 | - do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave ); |
|
| 933 | + do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | - public function increase_tax( $amount = 0.00 ) { |
|
| 936 | + public function increase_tax($amount = 0.00) { |
|
| 937 | 937 | $amount = (float) $amount; |
| 938 | 938 | $this->tax += $amount; |
| 939 | 939 | |
| 940 | 940 | $this->recalculate_total(); |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - public function decrease_tax( $amount = 0.00 ) { |
|
| 943 | + public function decrease_tax($amount = 0.00) { |
|
| 944 | 944 | $amount = (float) $amount; |
| 945 | 945 | $this->tax -= $amount; |
| 946 | 946 | |
| 947 | - if ( $this->tax < 0 ) { |
|
| 947 | + if ($this->tax < 0) { |
|
| 948 | 948 | $this->tax = 0; |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | $this->recalculate_total(); |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 955 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID ); |
|
| 954 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 955 | + $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID); |
|
| 956 | 956 | |
| 957 | - if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) { |
|
| 957 | + if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) { |
|
| 958 | 958 | return false; // Don't permit status changes that aren't changes |
| 959 | 959 | } |
| 960 | 960 | |
| 961 | - $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status ); |
|
| 961 | + $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status); |
|
| 962 | 962 | $updated = false; |
| 963 | 963 | |
| 964 | - if ( $do_change ) { |
|
| 965 | - do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status ); |
|
| 964 | + if ($do_change) { |
|
| 965 | + do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status); |
|
| 966 | 966 | |
| 967 | 967 | $update_post_data = array(); |
| 968 | 968 | $update_post_data['ID'] = $this->ID; |
| 969 | 969 | $update_post_data['post_status'] = $new_status; |
| 970 | - $update_post_data['edit_date'] = current_time( 'mysql', 0 ); |
|
| 971 | - $update_post_data['edit_date_gmt'] = current_time( 'mysql', 1 ); |
|
| 970 | + $update_post_data['edit_date'] = current_time('mysql', 0); |
|
| 971 | + $update_post_data['edit_date_gmt'] = current_time('mysql', 1); |
|
| 972 | 972 | |
| 973 | - $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID ); |
|
| 973 | + $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID); |
|
| 974 | 974 | |
| 975 | - $updated = wp_update_post( $update_post_data ); |
|
| 975 | + $updated = wp_update_post($update_post_data); |
|
| 976 | 976 | |
| 977 | 977 | // Status was changed. |
| 978 | - do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status ); |
|
| 979 | - do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status ); |
|
| 980 | - do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status ); |
|
| 978 | + do_action('wpinv_status_' . $new_status, $this->ID, $old_status); |
|
| 979 | + do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status); |
|
| 980 | + do_action('wpinv_update_status', $this->ID, $new_status, $old_status); |
|
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | return $updated; |
@@ -994,114 +994,114 @@ discard block |
||
| 994 | 994 | public function update_meta() {} |
| 995 | 995 | |
| 996 | 996 | // get data |
| 997 | - public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
| 998 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
| 997 | + public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) { |
|
| 998 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
| 999 | 999 | |
| 1000 | - if ( $meta_key === '_wpinv_payment_meta' ) { |
|
| 1000 | + if ($meta_key === '_wpinv_payment_meta') { |
|
| 1001 | 1001 | |
| 1002 | - if ( ! is_array( $meta ) ) { |
|
| 1003 | -$meta = array();} // we need this to be an array so make sure it is. |
|
| 1002 | + if (!is_array($meta)) { |
|
| 1003 | +$meta = array(); } // we need this to be an array so make sure it is. |
|
| 1004 | 1004 | |
| 1005 | - if ( empty( $meta['key'] ) ) { |
|
| 1005 | + if (empty($meta['key'])) { |
|
| 1006 | 1006 | $meta['key'] = $this->setup_invoice_key(); |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - if ( empty( $meta['date'] ) ) { |
|
| 1010 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
| 1009 | + if (empty($meta['date'])) { |
|
| 1010 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | - $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID ); |
|
| 1014 | + $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID); |
|
| 1015 | 1015 | |
| 1016 | - return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key ); |
|
| 1016 | + return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | public function get_description() { |
| 1020 | - $post = get_post( $this->ID ); |
|
| 1020 | + $post = get_post($this->ID); |
|
| 1021 | 1021 | |
| 1022 | - $description = ! empty( $post ) ? $post->post_content : ''; |
|
| 1023 | - return apply_filters( 'wpinv_get_description', $description, $this->ID, $this ); |
|
| 1022 | + $description = !empty($post) ? $post->post_content : ''; |
|
| 1023 | + return apply_filters('wpinv_get_description', $description, $this->ID, $this); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | - public function get_status( $nicename = false ) { |
|
| 1027 | - if ( ! $nicename ) { |
|
| 1026 | + public function get_status($nicename = false) { |
|
| 1027 | + if (!$nicename) { |
|
| 1028 | 1028 | $status = $this->status; |
| 1029 | 1029 | } else { |
| 1030 | 1030 | $status = $this->status_nicename; |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this ); |
|
| 1033 | + return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | public function get_cart_details() { |
| 1037 | - return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this ); |
|
| 1037 | + return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this); |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | - public function get_subtotal( $currency = false ) { |
|
| 1041 | - $subtotal = wpinv_round_amount( $this->subtotal ); |
|
| 1040 | + public function get_subtotal($currency = false) { |
|
| 1041 | + $subtotal = wpinv_round_amount($this->subtotal); |
|
| 1042 | 1042 | |
| 1043 | - if ( $currency ) { |
|
| 1044 | - $subtotal = wpinv_price( wpinv_format_amount( $subtotal, null, ! $currency ), $this->get_currency() ); |
|
| 1043 | + if ($currency) { |
|
| 1044 | + $subtotal = wpinv_price(wpinv_format_amount($subtotal, null, !$currency), $this->get_currency()); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | - return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency ); |
|
| 1047 | + return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - public function get_total( $currency = false ) { |
|
| 1051 | - if ( $this->is_free_trial() ) { |
|
| 1052 | - $total = wpinv_round_amount( 0 ); |
|
| 1050 | + public function get_total($currency = false) { |
|
| 1051 | + if ($this->is_free_trial()) { |
|
| 1052 | + $total = wpinv_round_amount(0); |
|
| 1053 | 1053 | } else { |
| 1054 | - $total = wpinv_round_amount( $this->total ); |
|
| 1054 | + $total = wpinv_round_amount($this->total); |
|
| 1055 | 1055 | } |
| 1056 | - if ( $currency ) { |
|
| 1057 | - $total = wpinv_price( wpinv_format_amount( $total, null, ! $currency ), $this->get_currency() ); |
|
| 1056 | + if ($currency) { |
|
| 1057 | + $total = wpinv_price(wpinv_format_amount($total, null, !$currency), $this->get_currency()); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency ); |
|
| 1060 | + return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency); |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | public function get_recurring_details() {} |
| 1064 | 1064 | |
| 1065 | - public function get_final_tax( $currency = false ) { |
|
| 1066 | - $final_total = wpinv_round_amount( $this->tax ); |
|
| 1067 | - if ( $currency ) { |
|
| 1068 | - $final_total = wpinv_price( wpinv_format_amount( $final_total, null, ! $currency ), $this->get_currency() ); |
|
| 1065 | + public function get_final_tax($currency = false) { |
|
| 1066 | + $final_total = wpinv_round_amount($this->tax); |
|
| 1067 | + if ($currency) { |
|
| 1068 | + $final_total = wpinv_price(wpinv_format_amount($final_total, null, !$currency), $this->get_currency()); |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | - return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency ); |
|
| 1071 | + return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | - public function get_discounts( $array = false ) { |
|
| 1074 | + public function get_discounts($array = false) { |
|
| 1075 | 1075 | $discounts = $this->discounts; |
| 1076 | - if ( $array && $discounts ) { |
|
| 1077 | - $discounts = explode( ',', $discounts ); |
|
| 1076 | + if ($array && $discounts) { |
|
| 1077 | + $discounts = explode(',', $discounts); |
|
| 1078 | 1078 | } |
| 1079 | - return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array ); |
|
| 1079 | + return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array); |
|
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - public function get_discount( $currency = false, $dash = false ) { |
|
| 1083 | - if ( ! empty( $this->discounts ) ) { |
|
| 1082 | + public function get_discount($currency = false, $dash = false) { |
|
| 1083 | + if (!empty($this->discounts)) { |
|
| 1084 | 1084 | global $ajax_cart_details; |
| 1085 | 1085 | $ajax_cart_details = $this->get_cart_details(); |
| 1086 | 1086 | |
| 1087 | - if ( ! empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) { |
|
| 1087 | + if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) { |
|
| 1088 | 1088 | $cart_items = $ajax_cart_details; |
| 1089 | 1089 | } else { |
| 1090 | 1090 | $cart_items = $this->items; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | - $this->discount = wpinv_get_cart_items_discount_amount( $cart_items, $this->discounts ); |
|
| 1093 | + $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts); |
|
| 1094 | 1094 | } |
| 1095 | - $discount = wpinv_round_amount( $this->discount ); |
|
| 1095 | + $discount = wpinv_round_amount($this->discount); |
|
| 1096 | 1096 | $dash = $dash && $discount > 0 ? '–' : ''; |
| 1097 | 1097 | |
| 1098 | - if ( $currency ) { |
|
| 1099 | - $discount = wpinv_price( wpinv_format_amount( $discount, null, ! $currency ), $this->get_currency() ); |
|
| 1098 | + if ($currency) { |
|
| 1099 | + $discount = wpinv_price(wpinv_format_amount($discount, null, !$currency), $this->get_currency()); |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | - $discount = $dash . $discount; |
|
| 1102 | + $discount = $dash . $discount; |
|
| 1103 | 1103 | |
| 1104 | - return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash ); |
|
| 1104 | + return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash); |
|
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | public function get_discount_code() { |
@@ -1113,150 +1113,150 @@ discard block |
||
| 1113 | 1113 | return (int) $this->disable_taxes === 0; |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - public function get_tax( $currency = false ) { |
|
| 1117 | - $tax = wpinv_round_amount( $this->tax ); |
|
| 1116 | + public function get_tax($currency = false) { |
|
| 1117 | + $tax = wpinv_round_amount($this->tax); |
|
| 1118 | 1118 | |
| 1119 | - if ( $currency ) { |
|
| 1120 | - $tax = wpinv_price( wpinv_format_amount( $tax, null, ! $currency ), $this->get_currency() ); |
|
| 1119 | + if ($currency) { |
|
| 1120 | + $tax = wpinv_price(wpinv_format_amount($tax, null, !$currency), $this->get_currency()); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | - if ( ! $this->is_taxable() ) { |
|
| 1124 | - $tax = wpinv_round_amount( 0.00 ); |
|
| 1123 | + if (!$this->is_taxable()) { |
|
| 1124 | + $tax = wpinv_round_amount(0.00); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | - return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency ); |
|
| 1127 | + return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | - public function get_fees( $type = 'all' ) { |
|
| 1131 | - $fees = array(); |
|
| 1130 | + public function get_fees($type = 'all') { |
|
| 1131 | + $fees = array(); |
|
| 1132 | 1132 | |
| 1133 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
| 1134 | - foreach ( $this->fees as $fee ) { |
|
| 1135 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 1133 | + if (!empty($this->fees) && is_array($this->fees)) { |
|
| 1134 | + foreach ($this->fees as $fee) { |
|
| 1135 | + if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) { |
|
| 1136 | 1136 | continue; |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | - $fee['label'] = stripslashes( $fee['label'] ); |
|
| 1140 | - $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() ); |
|
| 1141 | - $fees[] = $fee; |
|
| 1139 | + $fee['label'] = stripslashes($fee['label']); |
|
| 1140 | + $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency()); |
|
| 1141 | + $fees[] = $fee; |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | - return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this ); |
|
| 1145 | + return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this); |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | public function get_fees_total() { |
| 1149 | 1149 | $fees_total = (float) 0.00; |
| 1150 | 1150 | |
| 1151 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1152 | - if ( ! empty( $payment_fees ) ) { |
|
| 1153 | - foreach ( $payment_fees as $fee ) { |
|
| 1151 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1152 | + if (!empty($payment_fees)) { |
|
| 1153 | + foreach ($payment_fees as $fee) { |
|
| 1154 | 1154 | $fees_total += (float) $fee['amount']; |
| 1155 | 1155 | } |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | - return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this ); |
|
| 1158 | + return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this); |
|
| 1159 | 1159 | |
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | 1162 | public function get_user_id() { |
| 1163 | - return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this ); |
|
| 1163 | + return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | public function get_first_name() { |
| 1167 | - return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this ); |
|
| 1167 | + return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | 1170 | public function get_last_name() { |
| 1171 | - return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this ); |
|
| 1171 | + return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | public function get_user_full_name() { |
| 1175 | - return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this ); |
|
| 1175 | + return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | public function get_user_info() { |
| 1179 | - return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this ); |
|
| 1179 | + return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | public function get_email() { |
| 1183 | - return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this ); |
|
| 1183 | + return apply_filters('wpinv_user_email', $this->email, $this->ID, $this); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | public function get_address() { |
| 1187 | - return apply_filters( 'wpinv_address', $this->address, $this->ID, $this ); |
|
| 1187 | + return apply_filters('wpinv_address', $this->address, $this->ID, $this); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | public function get_phone() { |
| 1191 | - return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this ); |
|
| 1191 | + return apply_filters('wpinv_phone', $this->phone, $this->ID, $this); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | 1194 | public function get_number() { |
| 1195 | - return apply_filters( 'wpinv_number', $this->number, $this->ID, $this ); |
|
| 1195 | + return apply_filters('wpinv_number', $this->number, $this->ID, $this); |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | public function get_items() { |
| 1199 | - return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this ); |
|
| 1199 | + return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | public function get_key() { |
| 1203 | - return apply_filters( 'wpinv_key', $this->key, $this->ID, $this ); |
|
| 1203 | + return apply_filters('wpinv_key', $this->key, $this->ID, $this); |
|
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | public function get_transaction_id() { |
| 1207 | - return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
| 1207 | + return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | public function get_gateway() { |
| 1211 | - return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this ); |
|
| 1211 | + return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | public function get_gateway_title() {} |
| 1215 | 1215 | |
| 1216 | 1216 | public function get_currency() { |
| 1217 | - return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this ); |
|
| 1217 | + return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | public function get_created_date() { |
| 1221 | - return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this ); |
|
| 1221 | + return apply_filters('wpinv_created_date', $this->date, $this->ID, $this); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - public function get_due_date( $display = false ) { |
|
| 1225 | - $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this ); |
|
| 1224 | + public function get_due_date($display = false) { |
|
| 1225 | + $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this); |
|
| 1226 | 1226 | |
| 1227 | - if ( ! $display ) { |
|
| 1227 | + if (!$display) { |
|
| 1228 | 1228 | return $due_date; |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | - return getpaid_format_date( $this->due_date ); |
|
| 1231 | + return getpaid_format_date($this->due_date); |
|
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | 1234 | public function get_completed_date() { |
| 1235 | - return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this ); |
|
| 1235 | + return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | - public function get_invoice_date( $formatted = true ) { |
|
| 1238 | + public function get_invoice_date($formatted = true) { |
|
| 1239 | 1239 | $date_completed = $this->completed_date; |
| 1240 | 1240 | $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 1241 | 1241 | |
| 1242 | - if ( $invoice_date == '' ) { |
|
| 1242 | + if ($invoice_date == '') { |
|
| 1243 | 1243 | $date_created = $this->date; |
| 1244 | 1244 | $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | - if ( $formatted && $invoice_date ) { |
|
| 1248 | - $invoice_date = getpaid_format_date( $invoice_date ); |
|
| 1247 | + if ($formatted && $invoice_date) { |
|
| 1248 | + $invoice_date = getpaid_format_date($invoice_date); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this ); |
|
| 1251 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | public function get_ip() { |
| 1255 | - return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this ); |
|
| 1255 | + return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - public function has_status( $status ) { |
|
| 1259 | - return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status ); |
|
| 1258 | + public function has_status($status) { |
|
| 1259 | + return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | public function add_item() {} |
@@ -1273,66 +1273,66 @@ discard block |
||
| 1273 | 1273 | |
| 1274 | 1274 | public function get_view_url() {} |
| 1275 | 1275 | |
| 1276 | - public function generate_key( $string = '' ) { |
|
| 1277 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 1278 | - return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) ); // Unique key |
|
| 1276 | + public function generate_key($string = '') { |
|
| 1277 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 1278 | + return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | public function is_recurring() { |
| 1282 | - if ( empty( $this->cart_details ) ) { |
|
| 1282 | + if (empty($this->cart_details)) { |
|
| 1283 | 1283 | return false; |
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | 1286 | $has_subscription = false; |
| 1287 | - foreach ( $this->cart_details as $cart_item ) { |
|
| 1288 | - if ( ! empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
| 1287 | + foreach ($this->cart_details as $cart_item) { |
|
| 1288 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
| 1289 | 1289 | $has_subscription = true; |
| 1290 | 1290 | break; |
| 1291 | 1291 | } |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - if ( count( $this->cart_details ) > 1 ) { |
|
| 1294 | + if (count($this->cart_details) > 1) { |
|
| 1295 | 1295 | $has_subscription = false; |
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | - return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details ); |
|
| 1298 | + return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details); |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | public function is_free_trial() { |
| 1302 | 1302 | $is_free_trial = false; |
| 1303 | 1303 | |
| 1304 | - if ( $this->is_parent() && $item = $this->get_recurring( true ) ) { |
|
| 1305 | - if ( ! empty( $item ) && $item->has_free_trial() ) { |
|
| 1304 | + if ($this->is_parent() && $item = $this->get_recurring(true)) { |
|
| 1305 | + if (!empty($item) && $item->has_free_trial()) { |
|
| 1306 | 1306 | $is_free_trial = true; |
| 1307 | 1307 | } |
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | - return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this ); |
|
| 1310 | + return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this); |
|
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | 1313 | public function is_initial_free() {} |
| 1314 | 1314 | |
| 1315 | - public function get_recurring( $object = false ) { |
|
| 1315 | + public function get_recurring($object = false) { |
|
| 1316 | 1316 | $item = null; |
| 1317 | 1317 | |
| 1318 | - if ( empty( $this->cart_details ) ) { |
|
| 1318 | + if (empty($this->cart_details)) { |
|
| 1319 | 1319 | return $item; |
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | - foreach ( $this->cart_details as $cart_item ) { |
|
| 1323 | - if ( ! empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
| 1322 | + foreach ($this->cart_details as $cart_item) { |
|
| 1323 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
| 1324 | 1324 | $item = $cart_item['id']; |
| 1325 | 1325 | break; |
| 1326 | 1326 | } |
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | - if ( $object ) { |
|
| 1330 | - $item = $item ? new WPInv_Item( $item ) : null; |
|
| 1329 | + if ($object) { |
|
| 1330 | + $item = $item ? new WPInv_Item($item) : null; |
|
| 1331 | 1331 | |
| 1332 | - apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this ); |
|
| 1332 | + apply_filters('wpinv_invoice_get_recurring_item', $item, $this); |
|
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | - return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this ); |
|
| 1335 | + return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | public function get_subscription_name() {} |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | public function get_subscription_id() {} |
| 1341 | 1341 | |
| 1342 | 1342 | public function is_parent() { |
| 1343 | - return ! empty( $this->parent_invoice ); |
|
| 1343 | + return !empty($this->parent_invoice); |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | public function is_renewal() {} |
@@ -1354,8 +1354,8 @@ discard block |
||
| 1354 | 1354 | public function is_refunded() {} |
| 1355 | 1355 | |
| 1356 | 1356 | public function is_free() { |
| 1357 | - $total = (float) wpinv_round_amount( $this->get_total() ); |
|
| 1358 | - return $total > 0 && ! $this->is_recurring(); |
|
| 1357 | + $total = (float) wpinv_round_amount($this->get_total()); |
|
| 1358 | + return $total > 0 && !$this->is_recurring(); |
|
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | public function has_vat() {} |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | <h2 class="h3 text-dark"> |
| 14 | - <?php echo esc_html( apply_filters( 'getpaid_invoice_type_label', esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ), $invoice ) ); ?> |
|
| 14 | + <?php echo esc_html(apply_filters('getpaid_invoice_type_label', esc_html(ucfirst($invoice->get_invoice_quote_type())), $invoice)); ?> |
|
| 15 | 15 | </h2> |
| 16 | 16 | |
| 17 | 17 | <?php |
@@ -7,8 +7,8 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -if ( ! empty( $element['text'] ) ) { |
|
| 13 | - echo '<p>' . wp_kses_post( trim( $element['text'] ) ) . '</p>'; |
|
| 12 | +if (!empty($element['text'])) { |
|
| 13 | + echo '<p>' . wp_kses_post(trim($element['text'])) . '</p>'; |
|
| 14 | 14 | } |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$heading_tag = isset( $element['level'] ) ? trim( sanitize_key( $element['level'] ) ) : 'h3'; |
|
| 13 | -$text = isset( $element['text'] ) ? trim( $element['text'] ) : ''; |
|
| 12 | +$heading_tag = isset($element['level']) ? trim(sanitize_key($element['level'])) : 'h3'; |
|
| 13 | +$text = isset($element['text']) ? trim($element['text']) : ''; |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $text ) ) { |
|
| 16 | - echo wp_kses_post( "<$heading_tag>$text</$heading_tag>" ); |
|
| 15 | +if (!empty($text)) { |
|
| 16 | + echo wp_kses_post("<$heading_tag>$text</$heading_tag>"); |
|
| 17 | 17 | } |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | - die( '-1' ); |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | + die('-1'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text', get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ) ) ); |
|
| 8 | -$email_footer = $email_footer ? wp_kses_post( wpautop( wptexturize( $email_footer ) ) ) : ''; |
|
| 7 | +$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text', get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'))); |
|
| 8 | +$email_footer = $email_footer ? wp_kses_post(wpautop(wptexturize($email_footer))) : ''; |
|
| 9 | 9 | ?> |
| 10 | 10 | </div> |
| 11 | 11 | </td> |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | <table border="0" cellpadding="10" cellspacing="0" width="100%"> |
| 28 | 28 | <tr> |
| 29 | 29 | <td colspan="2" valign="middle" id="credit"> |
| 30 | - <?php echo wp_kses_post( $email_footer ); ?> |
|
| 30 | + <?php echo wp_kses_post($email_footer); ?> |
|
| 31 | 31 | </td> |
| 32 | 32 | </tr> |
| 33 | 33 | </table> |
@@ -7,21 +7,21 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
| 14 | +do_action('wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
| 15 | 15 | |
| 16 | 16 | // Generate the custom message body. |
| 17 | -echo wp_kses_post( wptexturize( str_replace( '{customer_note}', $customer_note, $message_body ) ) ); |
|
| 17 | +echo wp_kses_post(wptexturize(str_replace('{customer_note}', $customer_note, $message_body))); |
|
| 18 | 18 | |
| 19 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | |
| 21 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 21 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 22 | 22 | |
| 23 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 23 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 24 | 24 | |
| 25 | -do_action( 'wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
| 25 | +do_action('wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
| 26 | 26 | |
| 27 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 27 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -7,64 +7,64 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Fetch the invoice. |
| 13 | -$invoice = new WPInv_Invoice( $invoice ); |
|
| 13 | +$invoice = new WPInv_Invoice($invoice); |
|
| 14 | 14 | |
| 15 | 15 | // @deprecated |
| 16 | -do_action( 'wpinv_success_content_before', $invoice ); |
|
| 17 | -do_action( 'wpinv_before_receipt', $invoice ); |
|
| 16 | +do_action('wpinv_success_content_before', $invoice); |
|
| 17 | +do_action('wpinv_before_receipt', $invoice); |
|
| 18 | 18 | |
| 19 | 19 | wpinv_print_errors(); |
| 20 | 20 | |
| 21 | 21 | // Prepare header text. |
| 22 | -if ( $invoice->is_paid() ) { |
|
| 22 | +if ($invoice->is_paid()) { |
|
| 23 | 23 | |
| 24 | 24 | $alert = aui()->alert( |
| 25 | 25 | array( |
| 26 | 26 | 'type' => 'success', |
| 27 | - 'content' => __( 'Thank you for your payment!', 'invoicing' ), |
|
| 27 | + 'content' => __('Thank you for your payment!', 'invoicing'), |
|
| 28 | 28 | ) |
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | -} elseif ( $invoice->is_refunded() ) { |
|
| 31 | +} elseif ($invoice->is_refunded()) { |
|
| 32 | 32 | |
| 33 | 33 | $alert = aui()->alert( |
| 34 | 34 | array( |
| 35 | 35 | 'type' => 'info', |
| 36 | - 'content' => __( 'This invoice was refunded.', 'invoicing' ), |
|
| 36 | + 'content' => __('This invoice was refunded.', 'invoicing'), |
|
| 37 | 37 | ) |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | -} elseif ( $invoice->is_held() ) { |
|
| 40 | +} elseif ($invoice->is_held()) { |
|
| 41 | 41 | |
| 42 | 42 | $alert = aui()->alert( |
| 43 | 43 | array( |
| 44 | 44 | 'type' => 'info', |
| 45 | - 'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ), |
|
| 45 | + 'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'), |
|
| 46 | 46 | ) |
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | -} elseif ( $invoice->needs_payment() ) { |
|
| 49 | +} elseif ($invoice->needs_payment()) { |
|
| 50 | 50 | |
| 51 | - if ( ! empty( $_GET['token'] ) ) { |
|
| 51 | + if (!empty($_GET['token'])) { |
|
| 52 | 52 | |
| 53 | 53 | $alert = aui()->alert( |
| 54 | 54 | array( |
| 55 | 55 | 'type' => 'info', |
| 56 | - 'content' => __( "Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing' ), |
|
| 56 | + 'content' => __("Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing'), |
|
| 57 | 57 | ) |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - } elseif ( $invoice->is_due() ) { |
|
| 60 | + } elseif ($invoice->is_due()) { |
|
| 61 | 61 | |
| 62 | 62 | $alert = aui()->alert( |
| 63 | 63 | array( |
| 64 | 64 | 'type' => 'danger', |
| 65 | 65 | 'content' => sprintf( |
| 66 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
| 67 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
| 66 | + __('This invoice was due on %.', 'invoicing'), |
|
| 67 | + getpaid_format_date_value($invoice->get_due_date()) |
|
| 68 | 68 | ), |
| 69 | 69 | ) |
| 70 | 70 | ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $alert = aui()->alert( |
| 75 | 75 | array( |
| 76 | 76 | 'type' => 'warning', |
| 77 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
| 77 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
| 78 | 78 | ) |
| 79 | 79 | ); |
| 80 | 80 | |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | 'pay' => array( |
| 90 | 90 | 'url' => $invoice->get_checkout_payment_url(), |
| 91 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
| 91 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
| 92 | 92 | 'class' => 'btn-success', |
| 93 | 93 | ), |
| 94 | 94 | |
| 95 | 95 | 'view' => array( |
| 96 | 96 | 'url' => $invoice->get_view_url(), |
| 97 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
| 97 | + 'name' => __('View Invoice', 'invoicing'), |
|
| 98 | 98 | 'class' => 'btn-primary', |
| 99 | 99 | ), |
| 100 | 100 | |
| 101 | 101 | 'history' => array( |
| 102 | 102 | 'url' => wpinv_get_history_page_uri(), |
| 103 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 103 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 104 | 104 | 'class' => 'btn-warning', |
| 105 | 105 | ), |
| 106 | 106 | |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | $invoice |
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $invoice_actions['pay'] ) ) { |
|
| 112 | - unset( $invoice_actions['pay'] ); |
|
| 111 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($invoice_actions['pay'])) { |
|
| 112 | + unset($invoice_actions['pay']); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | -if ( ! is_user_logged_in() && isset( $invoice_actions['history'] ) ) { |
|
| 116 | - unset( $invoice_actions['history'] ); |
|
| 115 | +if (!is_user_logged_in() && isset($invoice_actions['history'])) { |
|
| 116 | + unset($invoice_actions['history']); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | ?> |
@@ -122,29 +122,29 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | <?php |
| 124 | 124 | |
| 125 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
| 125 | + do_action('wpinv_receipt_start', $invoice); |
|
| 126 | 126 | |
| 127 | - if ( ! empty( $invoice_actions ) ) { |
|
| 127 | + if (!empty($invoice_actions)) { |
|
| 128 | 128 | |
| 129 | 129 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
| 130 | 130 | |
| 131 | - foreach ( $invoice_actions as $key => $invoice_action ) { |
|
| 131 | + foreach ($invoice_actions as $key => $invoice_action) { |
|
| 132 | 132 | |
| 133 | - $key = sanitize_html_class( $key ); |
|
| 134 | - $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
| 135 | - $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
| 136 | - $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
| 137 | - $anchor = esc_html( $invoice_action['name'] ); |
|
| 133 | + $key = sanitize_html_class($key); |
|
| 134 | + $class = empty($invoice_action['class']) ? 'btn-dark' : sanitize_html_class($invoice_action['class']); |
|
| 135 | + $url = empty($invoice_action['url']) ? '#' : esc_url($invoice_action['url']); |
|
| 136 | + $attrs = empty($invoice_action['attrs']) ? '' : $invoice_action['attrs']; |
|
| 137 | + $anchor = esc_html($invoice_action['name']); |
|
| 138 | 138 | |
| 139 | - echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
| 139 | + echo wp_kses_post("<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | echo '</div>'; |
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( ! empty( $alert ) ) { |
|
| 147 | - echo wp_kses_post( $alert ); |
|
| 146 | + if (!empty($alert)) { |
|
| 147 | + echo wp_kses_post($alert); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | ?> |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | <div class="wpinv-receipt-details"> |
| 153 | 153 | |
| 154 | 154 | <h4 class="wpinv-details-t mb-3 mt-3"> |
| 155 | - <?php echo esc_html( apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ) ); ?> |
|
| 155 | + <?php echo esc_html(apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice)); ?> |
|
| 156 | 156 | </h4> |
| 157 | 157 | |
| 158 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
| 158 | + <?php getpaid_invoice_meta($invoice); ?> |
|
| 159 | 159 | |
| 160 | 160 | </div> |
| 161 | 161 | |
| 162 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
| 162 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
| 163 | 163 | |
| 164 | 164 | </div> |
| 165 | 165 | |
| 166 | 166 | <?php |
| 167 | 167 | |
| 168 | 168 | // @deprecated |
| 169 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
| 170 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
| 169 | +do_action('wpinv_success_content_after', $invoice); |
|
| 170 | +do_action('wpinv_after_receipt', $invoice); |
|
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( ! defined( 'WPINC' ) ) { |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPInv_Admin_Users ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) { |
|
| 19 | 19 | self::$instance = new WPInv_Admin_Users(); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function __construct() { |
| 26 | - add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column' ) ); |
|
| 27 | - add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content' ), 10, 3 ); |
|
| 26 | + add_filter('manage_users_columns', array($this, 'wpinv_add_user_column')); |
|
| 27 | + add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return mixed |
| 36 | 36 | */ |
| 37 | - public function wpinv_add_user_column( $column ) { |
|
| 38 | - $column['wpinvoicing'] = __( 'Invoicing', 'invoicing' ); |
|
| 37 | + public function wpinv_add_user_column($column) { |
|
| 38 | + $column['wpinvoicing'] = __('Invoicing', 'invoicing'); |
|
| 39 | 39 | return $column; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - public function wpinv_user_column_content( $val, $column_name, $user_id ) { |
|
| 52 | - switch ( $column_name ) { |
|
| 51 | + public function wpinv_user_column_content($val, $column_name, $user_id) { |
|
| 52 | + switch ($column_name) { |
|
| 53 | 53 | case 'wpinvoicing': |
| 54 | - return $this->get_user_invoices( $user_id ); |
|
| 54 | + return $this->get_user_invoices($user_id); |
|
| 55 | 55 | break; |
| 56 | 56 | default: |
| 57 | 57 | } |
@@ -65,30 +65,30 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function get_user_invoices( $user_id ) { |
|
| 68 | + public function get_user_invoices($user_id) { |
|
| 69 | 69 | $output = ''; |
| 70 | 70 | $wp_query_args = array( |
| 71 | 71 | 'post_type' => 'wpi_invoice', |
| 72 | - 'post_status' => array( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal' ), |
|
| 72 | + 'post_status' => array('wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal'), |
|
| 73 | 73 | 'posts_per_page' => -1, |
| 74 | 74 | 'fields' => 'ids', |
| 75 | 75 | 'author' => $user_id, |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $wp_query_args = apply_filters( 'wpinv_get_user_invoices_args', $wp_query_args, $user_id ); |
|
| 78 | + $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id); |
|
| 79 | 79 | |
| 80 | - $invoices = new WP_Query( $wp_query_args ); |
|
| 81 | - $count = absint( $invoices->found_posts ); |
|
| 80 | + $invoices = new WP_Query($wp_query_args); |
|
| 81 | + $count = absint($invoices->found_posts); |
|
| 82 | 82 | |
| 83 | - if ( empty( $count ) ) { |
|
| 84 | - $output .= __( 'No Invoice(s)', 'invoicing' ); |
|
| 83 | + if (empty($count)) { |
|
| 84 | + $output .= __('No Invoice(s)', 'invoicing'); |
|
| 85 | 85 | } else { |
| 86 | - $link_url = admin_url( 'edit.php?post_type=wpi_invoice&author=' . absint( $user_id ) ); |
|
| 87 | - $link_text = sprintf( __( 'Invoices ( %d )', 'invoicing' ), $count ); |
|
| 86 | + $link_url = admin_url('edit.php?post_type=wpi_invoice&author=' . absint($user_id)); |
|
| 87 | + $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count); |
|
| 88 | 88 | $output .= "<a href='$link_url' >$link_text</a>"; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - return apply_filters( 'wpinv_user_invoice_content', $output, $user_id ); |
|
| 91 | + return apply_filters('wpinv_user_invoice_content', $output, $user_id); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | } |
@@ -7,81 +7,81 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( ! defined( 'WPINC' ) ) { |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_bulk_actions( $actions ) { |
|
| 15 | - if ( isset( $actions['edit'] ) ) { |
|
| 16 | - unset( $actions['edit'] ); |
|
| 14 | +function wpinv_bulk_actions($actions) { |
|
| 15 | + if (isset($actions['edit'])) { |
|
| 16 | + unset($actions['edit']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | return $actions; |
| 20 | 20 | } |
| 21 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 22 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
| 21 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 22 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
| 23 | 23 | |
| 24 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 24 | +function wpinv_admin_post_id($id = 0) { |
|
| 25 | 25 | global $post; |
| 26 | 26 | |
| 27 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 28 | - return (int)$id; |
|
| 29 | - } elseif ( get_the_ID() ) { |
|
| 27 | + if (isset($id) && !empty($id)) { |
|
| 28 | + return (int) $id; |
|
| 29 | + } elseif (get_the_ID()) { |
|
| 30 | 30 | return (int) get_the_ID(); |
| 31 | - } elseif ( isset( $post->ID ) && ! empty( $post->ID ) ) { |
|
| 31 | + } elseif (isset($post->ID) && !empty($post->ID)) { |
|
| 32 | 32 | return (int) $post->ID; |
| 33 | - } elseif ( isset( $_GET['post'] ) && ! empty( $_GET['post'] ) ) { |
|
| 33 | + } elseif (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 34 | 34 | return (int) $_GET['post']; |
| 35 | - } elseif ( isset( $_GET['id'] ) && ! empty( $_GET['id'] ) ) { |
|
| 35 | + } elseif (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 36 | 36 | return (int) $_GET['id']; |
| 37 | - } elseif ( isset( $_POST['id'] ) && ! empty( $_POST['id'] ) ) { |
|
| 37 | + } elseif (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 38 | 38 | return (int) $_POST['id']; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return null; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 45 | - if ( ! $id ) { |
|
| 44 | +function wpinv_admin_post_type($id = 0) { |
|
| 45 | + if (!$id) { |
|
| 46 | 46 | $id = wpinv_admin_post_id(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $type = get_post_type( $id ); |
|
| 49 | + $type = get_post_type($id); |
|
| 50 | 50 | |
| 51 | - if ( ! $type ) { |
|
| 52 | - $type = isset( $_GET['post_type'] ) && ! empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : null; |
|
| 51 | + if (!$type) { |
|
| 52 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : null; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 55 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function wpinv_admin_messages() { |
| 59 | - settings_errors( 'wpinv-notices' ); |
|
| 59 | + settings_errors('wpinv-notices'); |
|
| 60 | 60 | } |
| 61 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 61 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 62 | 62 | |
| 63 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
| 63 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
| 64 | 64 | function wpinv_show_test_payment_gateway_notice() { |
| 65 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
| 65 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function wpinv_test_payment_gateway_messages() { |
| 69 | 69 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 70 | 70 | $name = array(); $test_gateways = ''; |
| 71 | - if ( $gateways ) { |
|
| 72 | - foreach ( $gateways as $id => $gateway ) { |
|
| 73 | - if ( wpinv_is_test_mode( $id ) ) { |
|
| 71 | + if ($gateways) { |
|
| 72 | + foreach ($gateways as $id => $gateway) { |
|
| 73 | + if (wpinv_is_test_mode($id)) { |
|
| 74 | 74 | $name[] = $gateway['checkout_label']; |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | - $test_gateways = implode( ', ', $name ); |
|
| 77 | + $test_gateways = implode(', ', $name); |
|
| 78 | 78 | } |
| 79 | - if ( isset( $test_gateways ) && ! empty( $test_gateways ) && wpinv_current_user_can_manage_invoicing() ) { |
|
| 80 | - $link = admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
| 81 | - $notice = wp_sprintf( __( '<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing' ), $test_gateways, $link ); |
|
| 79 | + if (isset($test_gateways) && !empty($test_gateways) && wpinv_current_user_can_manage_invoicing()) { |
|
| 80 | + $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
| 81 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
| 82 | 82 | ?> |
| 83 | 83 | <div class="notice notice-warning is-dismissible"> |
| 84 | - <p><?php echo wp_kses_post( $notice ); ?></p> |
|
| 84 | + <p><?php echo wp_kses_post($notice); ?></p> |
|
| 85 | 85 | </div> |
| 86 | 86 | <?php |
| 87 | 87 | } |
@@ -95,37 +95,37 @@ discard block |
||
| 95 | 95 | global $wpdb; |
| 96 | 96 | |
| 97 | 97 | // Only do this on our settings page. |
| 98 | - if ( empty( $_GET['page'] ) || 'wpinv-settings' !== $_GET['page'] ) { |
|
| 98 | + if (empty($_GET['page']) || 'wpinv-settings' !== $_GET['page']) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Check tables. |
| 103 | - $tables = array( |
|
| 103 | + $tables = array( |
|
| 104 | 104 | "{$wpdb->prefix}wpinv_subscriptions", |
| 105 | 105 | "{$wpdb->prefix}getpaid_invoices", |
| 106 | 106 | "{$wpdb->prefix}getpaid_invoice_items", |
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | - foreach ( $tables as $table ) { |
|
| 110 | - if ( $table != $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) ) { |
|
| 109 | + foreach ($tables as $table) { |
|
| 110 | + if ($table != $wpdb->get_var("SHOW TABLES LIKE '$table'")) { |
|
| 111 | 111 | |
| 112 | - $url = wp_nonce_url( |
|
| 113 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 112 | + $url = wp_nonce_url( |
|
| 113 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
| 114 | 114 | 'getpaid-nonce', |
| 115 | 115 | 'getpaid-nonce' |
| 116 | 116 | ); |
| 117 | - $message = __( 'Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing' ); |
|
| 118 | - $message2 = __( 'Create Tables', 'invoicing' ); |
|
| 119 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
| 117 | + $message = __('Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing'); |
|
| 118 | + $message2 = __('Create Tables', 'invoicing'); |
|
| 119 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
| 120 | 120 | break; |
| 121 | 121 | |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | } |
| 126 | -add_action( 'admin_notices', 'wpinv_check_for_missing_tables' ); |
|
| 126 | +add_action('admin_notices', 'wpinv_check_for_missing_tables'); |
|
| 127 | 127 | |
| 128 | -add_action( 'admin_init', 'wpinv_admin_search_by_invoice' ); |
|
| 128 | +add_action('admin_init', 'wpinv_admin_search_by_invoice'); |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * hook the posts search if we're on the admin page for our type |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | function wpinv_admin_search_by_invoice() { |
| 134 | 134 | global $typenow; |
| 135 | 135 | |
| 136 | - if ( $typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
| 137 | - add_filter( 'posts_search', 'wpinv_posts_search_example_type', 10, 2 ); |
|
| 136 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
| 137 | + add_filter('posts_search', 'wpinv_posts_search_example_type', 10, 2); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | * @param WP_Query $query |
| 145 | 145 | * @return string |
| 146 | 146 | */ |
| 147 | -function wpinv_posts_search_example_type( $search, $query ) { |
|
| 147 | +function wpinv_posts_search_example_type($search, $query) { |
|
| 148 | 148 | global $wpdb; |
| 149 | 149 | |
| 150 | - if ( $query->is_main_query() && ! empty( $query->query['s'] ) ) { |
|
| 151 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
| 152 | - if ( ! empty( $search ) ) { |
|
| 153 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
| 150 | + if ($query->is_main_query() && !empty($query->query['s'])) { |
|
| 151 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
| 152 | + if (!empty($search)) { |
|
| 153 | + $search = preg_replace('/^ AND /', '', $search); |
|
| 154 | 154 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
| 155 | 155 | } else { |
| 156 | 156 | $search = " AND ( {$conditions_str} )"; |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | * Resets invoice counts. |
| 165 | 165 | */ |
| 166 | 166 | function wpinv_reset_invoice_count() { |
| 167 | - if ( ! empty( $_GET['reset_invoice_count'] ) && isset( $_GET['_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_GET['_nonce'] ), 'reset_invoice_count' ) ) { |
|
| 168 | - wpinv_update_option( 'invoice_sequence_start', 1 ); |
|
| 169 | - delete_option( 'wpinv_last_invoice_number' ); |
|
| 170 | - getpaid_admin()->show_success( __( 'Invoice number sequence reset successfully.', 'invoicing' ) ); |
|
| 171 | - $url = remove_query_arg( array( 'reset_invoice_count', '_nonce' ) ); |
|
| 172 | - wp_redirect( $url ); |
|
| 167 | + if (!empty($_GET['reset_invoice_count']) && isset($_GET['_nonce']) && wp_verify_nonce(sanitize_text_field($_GET['_nonce']), 'reset_invoice_count')) { |
|
| 168 | + wpinv_update_option('invoice_sequence_start', 1); |
|
| 169 | + delete_option('wpinv_last_invoice_number'); |
|
| 170 | + getpaid_admin()->show_success(__('Invoice number sequence reset successfully.', 'invoicing')); |
|
| 171 | + $url = remove_query_arg(array('reset_invoice_count', '_nonce')); |
|
| 172 | + wp_redirect($url); |
|
| 173 | 173 | exit(); |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
| 176 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | 179 | * Displays line items on the invoice edit page. |
@@ -182,29 +182,29 @@ discard block |
||
| 182 | 182 | * @param array $columns |
| 183 | 183 | * @return string |
| 184 | 184 | */ |
| 185 | -function wpinv_admin_get_line_items( $invoice, $columns ) { |
|
| 185 | +function wpinv_admin_get_line_items($invoice, $columns) { |
|
| 186 | 186 | |
| 187 | 187 | ob_start(); |
| 188 | 188 | |
| 189 | - do_action( 'getpaid_admin_before_line_items', $invoice ); |
|
| 189 | + do_action('getpaid_admin_before_line_items', $invoice); |
|
| 190 | 190 | |
| 191 | 191 | $count = 0; |
| 192 | - foreach ( $invoice->get_items() as $item ) { |
|
| 192 | + foreach ($invoice->get_items() as $item) { |
|
| 193 | 193 | |
| 194 | - $item_price = wpinv_price( $item->get_price(), $invoice->get_currency() ); |
|
| 194 | + $item_price = wpinv_price($item->get_price(), $invoice->get_currency()); |
|
| 195 | 195 | $quantity = (int) $item->get_quantity(); |
| 196 | - $item_subtotal = wpinv_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
| 197 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
| 196 | + $item_subtotal = wpinv_price($item->get_sub_total(), $invoice->get_currency()); |
|
| 197 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
| 198 | 198 | $item_tax = $item->item_tax; |
| 199 | - $tax_rate = wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2, true ) . '%'; |
|
| 200 | - $tax_rate = empty( $tax_rate ) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
| 199 | + $tax_rate = wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2, true) . '%'; |
|
| 200 | + $tax_rate = empty($tax_rate) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
|
| 201 | 201 | $line_item_tax = $item_tax . $tax_rate; |
| 202 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . esc_attr( $item->get_id() ) . '">'; |
|
| 202 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . esc_attr($item->get_id()) . '">'; |
|
| 203 | 203 | $line_item .= '<td class="id">' . (int) $item->get_id() . '</td>'; |
| 204 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item->get_id() ) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
| 204 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item->get_id()) . '" target="_blank">' . $item->get_name() . '</a>'; |
|
| 205 | 205 | |
| 206 | - if ( $summary !== '' ) { |
|
| 207 | - $line_item .= '<span class="meta">' . wp_kses_post( wpautop( $summary ) ) . '</span>'; |
|
| 206 | + if ($summary !== '') { |
|
| 207 | + $line_item .= '<span class="meta">' . wp_kses_post(wpautop($summary)) . '</span>'; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $line_item .= '</td>'; |
@@ -212,23 +212,23 @@ discard block |
||
| 212 | 212 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 213 | 213 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 214 | 214 | |
| 215 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
| 215 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
| 216 | 216 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $line_item .= '<td class="action">'; |
| 220 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 220 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 221 | 221 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 222 | 222 | } |
| 223 | 223 | $line_item .= '</td>'; |
| 224 | 224 | $line_item .= '</tr>'; |
| 225 | 225 | |
| 226 | - echo wp_kses_post( apply_filters( 'getpaid_admin_line_item', $line_item, $item, $invoice ) ); |
|
| 226 | + echo wp_kses_post(apply_filters('getpaid_admin_line_item', $line_item, $item, $invoice)); |
|
| 227 | 227 | |
| 228 | 228 | $count++; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - do_action( 'getpaid_admin_after_line_items', $invoice ); |
|
| 231 | + do_action('getpaid_admin_after_line_items', $invoice); |
|
| 232 | 232 | |
| 233 | 233 | return ob_get_clean(); |
| 234 | 234 | } |