@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @deprecated |
| 247 | 247 | */ |
| 248 | 248 | function wpinv_get_payment_key( $invoice = 0 ) { |
| 249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 249 | + $invoice = new WPInv_Invoice( $invoice ); |
|
| 250 | 250 | return $invoice->get_key(); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @deprecated |
| 425 | 425 | */ |
| 426 | 426 | function wpinv_get_checkout_session() { |
| 427 | - return false; |
|
| 427 | + return false; |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
| 19 | 19 | * @deprecated |
| 20 | 20 | */ |
| 21 | 21 | function wpinv_get_invoice_cart() { |
| 22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
| 22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @deprecated |
| 27 | 27 | */ |
| 28 | -function wpinv_get_invoice_description( $invoice ) { |
|
| 29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 28 | +function wpinv_get_invoice_description($invoice) { |
|
| 29 | + $invoice = new WPInv_Invoice($invoice); |
|
| 30 | 30 | return $invoice->get_description(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @deprecated |
| 35 | 35 | */ |
| 36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
| 37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
| 37 | + $invoice = new WPInv_Invoice($invoice); |
|
| 38 | 38 | return $invoice->get_currency(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @deprecated |
| 43 | 43 | */ |
| 44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
| 45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 44 | +function wpinv_get_payment_user_email($invoice) { |
|
| 45 | + $invoice = new WPInv_Invoice($invoice); |
|
| 46 | 46 | return $invoice->get_email(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @deprecated |
| 51 | 51 | */ |
| 52 | -function wpinv_get_user_id( $invoice ) { |
|
| 53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 52 | +function wpinv_get_user_id($invoice) { |
|
| 53 | + $invoice = new WPInv_Invoice($invoice); |
|
| 54 | 54 | return $invoice->get_user_id(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * @deprecated |
| 59 | 59 | */ |
| 60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
| 61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
| 61 | + $invoice = new WPInv_Invoice($invoice); |
|
| 62 | 62 | |
| 63 | - if ( $return_label ) { |
|
| 63 | + if ($return_label) { |
|
| 64 | 64 | return $invoice->get_status_nicename(); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * @deprecated |
| 72 | 72 | */ |
| 73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
| 74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
| 74 | + $invoice = new WPInv_Invoice($invoice); |
|
| 75 | 75 | |
| 76 | - if ( $return_label ) { |
|
| 76 | + if ($return_label) { |
|
| 77 | 77 | return $invoice->get_gateway_title(); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @deprecated |
| 85 | 85 | */ |
| 86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
| 87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
| 86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
| 87 | + return wpinv_get_payment_gateway($invoice, true); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @deprecated |
| 92 | 92 | */ |
| 93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
| 94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
| 94 | + $invoice = new WPInv_Invoice($invoice); |
|
| 95 | 95 | return $invoice->get_transaction_id(); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @deprecated |
| 100 | 100 | */ |
| 101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
| 102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 103 | - return $invoice->get_meta( $meta_key, $single ); |
|
| 101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
| 102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 103 | + return $invoice->get_meta($meta_key, $single); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @deprecated |
| 108 | 108 | */ |
| 109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
| 110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
| 109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
| 110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * @deprecated |
| 116 | 116 | */ |
| 117 | -function wpinv_get_items( $invoice = 0 ) { |
|
| 118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 117 | +function wpinv_get_items($invoice = 0) { |
|
| 118 | + $invoice = new WPInv_Invoice($invoice); |
|
| 119 | 119 | return $invoice->get_items(); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * @deprecated |
| 124 | 124 | */ |
| 125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
| 126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 125 | +function wpinv_get_fees($invoice = 0) { |
|
| 126 | + $invoice = new WPInv_Invoice($invoice); |
|
| 127 | 127 | return $invoice->get_fees(); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * @deprecated |
| 132 | 132 | */ |
| 133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
| 134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 133 | +function wpinv_get_invoice_ip($invoice) { |
|
| 134 | + $invoice = new WPInv_Invoice($invoice); |
|
| 135 | 135 | return $invoice->get_ip(); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * @deprecated |
| 140 | 140 | */ |
| 141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
| 142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 141 | +function wpinv_get_invoice_user_info($invoice) { |
|
| 142 | + $invoice = new WPInv_Invoice($invoice); |
|
| 143 | 143 | return $invoice->get_user_info(); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * @deprecated |
| 148 | 148 | */ |
| 149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
| 150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
| 150 | + $invoice = new WPInv_Invoice($invoice); |
|
| 151 | 151 | $subtotal = $invoice->get_subtotal(); |
| 152 | 152 | |
| 153 | - if ( $currency ) { |
|
| 154 | - return wpinv_price( wpinv_format_amount( $subtotal ), $invoice->get_currency() ); |
|
| 153 | + if ($currency) { |
|
| 154 | + return wpinv_price(wpinv_format_amount($subtotal), $invoice->get_currency()); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | /** |
| 161 | 161 | * @deprecated |
| 162 | 162 | */ |
| 163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
| 164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
| 164 | + $invoice = new WPInv_Invoice($invoice); |
|
| 165 | 165 | $tax = $invoice->get_total_tax(); |
| 166 | 166 | |
| 167 | - if ( $currency ) { |
|
| 168 | - return wpinv_price( wpinv_format_amount( $tax ), $invoice->get_currency() ); |
|
| 167 | + if ($currency) { |
|
| 168 | + return wpinv_price(wpinv_format_amount($tax), $invoice->get_currency()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * @deprecated |
| 176 | 176 | */ |
| 177 | -function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) { |
|
| 178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 177 | +function wpinv_discount($invoice = 0, $currency = false, $deprecated) { |
|
| 178 | + $invoice = new WPInv_Invoice($invoice); |
|
| 179 | 179 | $discount = $invoice->get_total_discount(); |
| 180 | 180 | |
| 181 | - if ( $currency ) { |
|
| 182 | - return wpinv_price( wpinv_format_amount( $discount ), $invoice->get_currency() ); |
|
| 181 | + if ($currency) { |
|
| 182 | + return wpinv_price(wpinv_format_amount($discount), $invoice->get_currency()); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | /** |
| 189 | 189 | * @deprecated |
| 190 | 190 | */ |
| 191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
| 192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 191 | +function wpinv_discount_code($invoice = 0) { |
|
| 192 | + $invoice = new WPInv_Invoice($invoice); |
|
| 193 | 193 | return $invoice->get_discount_code(); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * @deprecated |
| 198 | 198 | */ |
| 199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
| 200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
| 200 | + $invoice = new WPInv_Invoice($invoice); |
|
| 201 | 201 | $total = $invoice->get_total(); |
| 202 | 202 | |
| 203 | - if ( $currency ) { |
|
| 204 | - return wpinv_price( wpinv_format_amount( $total ), $invoice->get_currency() ); |
|
| 203 | + if ($currency) { |
|
| 204 | + return wpinv_price(wpinv_format_amount($total), $invoice->get_currency()); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
| 210 | 210 | /** |
| 211 | 211 | * @deprecated |
| 212 | 212 | */ |
| 213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
| 214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
| 214 | + $invoice = new WPInv_Invoice($invoice); |
|
| 215 | 215 | |
| 216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
| 216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
| 217 | 217 | $date_created = $invoice->get_created_date(); |
| 218 | 218 | |
| 219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
| 219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * @deprecated |
| 224 | 224 | */ |
| 225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
| 226 | - wpinv_get_date_created( $invoice, $format ); |
|
| 225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
| 226 | + wpinv_get_date_created($invoice, $format); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | 230 | * @deprecated |
| 231 | 231 | */ |
| 232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
| 233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
| 233 | + $invoice = new WPInv_Invoice($invoice); |
|
| 234 | 234 | return $invoice->get_vat_number(); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | 238 | * @deprecated |
| 239 | 239 | */ |
| 240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
| 241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
| 240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
| 241 | + $invoice = new WPInv_Invoice($invoice); |
|
| 242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * @deprecated |
| 247 | 247 | */ |
| 248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
| 249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 248 | +function wpinv_get_payment_key($invoice = 0) { |
|
| 249 | + $invoice = new WPInv_Invoice($invoice); |
|
| 250 | 250 | return $invoice->get_key(); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * @deprecated |
| 255 | 255 | */ |
| 256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
| 257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
| 257 | + $invoice = new WPInv_Invoice($invoice); |
|
| 258 | 258 | return $invoice->get_number(); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
| 401 | 401 | /** |
| 402 | 402 | * @deprecated |
| 403 | 403 | */ |
| 404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
| 405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 406 | - return $invoice->update_status( $new_status ); |
|
| 404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
| 405 | + $invoice = new WPInv_Invoice($invoice); |
|
| 406 | + return $invoice->update_status($new_status); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
| 456 | 456 | /** |
| 457 | 457 | * @deprecated |
| 458 | 458 | */ |
| 459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
| 459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
| 460 | 460 | |
| 461 | 461 | // Fetch the invoice. |
| 462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 463 | 463 | |
| 464 | - if ( 0 == $invoice->get_id() ) { |
|
| 464 | + if (0 == $invoice->get_id()) { |
|
| 465 | 465 | return false; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // Prepare the transaction id. |
| 469 | - if ( empty( $transaction_id ) ) { |
|
| 469 | + if (empty($transaction_id)) { |
|
| 470 | 470 | $transaction_id = $invoice_id; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // Set the transaction id; |
| 474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
| 474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
| 475 | 475 | |
| 476 | 476 | // Save the invoice. |
| 477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
| 484 | 484 | * @param WPInv_Invoice $invoice |
| 485 | 485 | * @param string $gateway |
| 486 | 486 | */ |
| 487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
| 487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
| 488 | 488 | |
| 489 | 489 | $payment_data = array( |
| 490 | 490 | 'invoice_id' => $invoice->get_id(), |
| 491 | 491 | 'items' => $invoice->get_cart_details(), |
| 492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
| 492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
| 493 | 493 | 'fees' => $invoice->get_total_fees(), |
| 494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
| 495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
| 497 | 497 | 'price' => $invoice->get_total(), |
| 498 | 498 | 'invoice_key' => $invoice->get_key(), |
| 499 | 499 | 'user_email' => $invoice->get_email(), |
| 500 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 500 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 501 | 501 | 'user_info' => $invoice->get_user_info(), |
| 502 | - 'post_data' => stripslashes_deep( $_POST ), |
|
| 502 | + 'post_data' => stripslashes_deep($_POST), |
|
| 503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
| 504 | 504 | 'gateway' => $gateway, |
| 505 | 505 | 'card_info' => array(), |
| 506 | 506 | 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
| 509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
| 519 | 519 | /** |
| 520 | 520 | * @deprecated |
| 521 | 521 | */ |
| 522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
| 523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 525 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
| 523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
| 524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
| 525 | + wp_die($message, $title, array('response' => $status)); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
| 640 | 640 | /** |
| 641 | 641 | * @deprecated |
| 642 | 642 | */ |
| 643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
| 644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
| 643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
| 644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** |
| 648 | 648 | * @deprecated |
| 649 | 649 | */ |
| 650 | -function wpinv_clean_invoice_number( $number ) { |
|
| 650 | +function wpinv_clean_invoice_number($number) { |
|
| 651 | 651 | return $number; |
| 652 | 652 | } |
| 653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
| 852 | 852 | /** |
| 853 | 853 | * @deprecated |
| 854 | 854 | */ |
| 855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
| 855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
| 856 | 856 | |
| 857 | - if ( $echo ) { |
|
| 858 | - echo wpinv_item_price( $item_id ); |
|
| 857 | + if ($echo) { |
|
| 858 | + echo wpinv_item_price($item_id); |
|
| 859 | 859 | } else { |
| 860 | - return wpinv_item_price( $item_id ); |
|
| 860 | + return wpinv_item_price($item_id); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | } |
| 864 | 864 | \ No newline at end of file |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | * Checks if the current user cna view an invoice receipt. |
| 68 | 68 | */ |
| 69 | 69 | function wpinv_can_view_receipt( $invoice ) { |
| 70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
| 70 | + return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | function getpaid_get_current_invoice_id() { |
| 15 | 15 | |
| 16 | 16 | // Ensure that we have an invoice key. |
| 17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
| 17 | + if (empty($_GET['invoice_key'])) { |
|
| 18 | 18 | return 0; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // Retrieve an invoice using the key. |
| 22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
| 22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
| 23 | 23 | |
| 24 | 24 | // Compare the invoice key and the parsed key. |
| 25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
| 25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
| 26 | 26 | return $invoice->get_id(); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Checks if the current user cna view an invoice. |
| 34 | 34 | */ |
| 35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
| 36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 35 | +function wpinv_user_can_view_invoice($invoice) { |
|
| 36 | + $invoice = new WPInv_Invoice($invoice); |
|
| 37 | 37 | |
| 38 | 38 | // Abort if the invoice does not exist. |
| 39 | - if ( 0 == $invoice->get_id() ) { |
|
| 39 | + if (0 == $invoice->get_id()) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Don't allow trash, draft status |
| 44 | - if ( $invoice->is_draft() ) { |
|
| 44 | + if ($invoice->is_draft()) { |
|
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
| 49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
| 49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
| 50 | 50 | return true; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // Always enable for admins.. |
| 54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
| 54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
| 55 | 55 | return true; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Else, ensure that this is their invoice. |
| 59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
| 59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
| 60 | 60 | return true; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
| 63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Checks if the current user cna view an invoice receipt. |
| 68 | 68 | */ |
| 69 | -function wpinv_can_view_receipt( $invoice ) { |
|
| 70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
| 69 | +function wpinv_can_view_receipt($invoice) { |
|
| 70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function getpaid_get_invoice_post_types() { |
| 79 | 79 | $post_types = array( |
| 80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
| 81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
| 80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
| 81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
| 84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param string $post_type The post type to check for. |
| 92 | 92 | */ |
| 93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
| 94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
| 93 | +function getpaid_is_invoice_post_type($post_type) { |
|
| 94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 103 | 103 | */ |
| 104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
| 105 | - $data[ 'invoice_id' ] = 0; |
|
| 106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
| 105 | + $data['invoice_id'] = 0; |
|
| 106 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
| 113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 115 | 115 | */ |
| 116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
| 116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
| 117 | 117 | |
| 118 | 118 | // Backwards compatibility. |
| 119 | - if ( ! empty( $data['ID'] ) ) { |
|
| 119 | + if (!empty($data['ID'])) { |
|
| 120 | 120 | $data['invoice_id'] = $data['ID']; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Do we have an invoice id? |
| 124 | - if ( empty( $data['invoice_id'] ) ) { |
|
| 125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
| 124 | + if (empty($data['invoice_id'])) { |
|
| 125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Retrieve the invoice. |
| 129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
| 129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
| 130 | 130 | |
| 131 | 131 | // And abort if it does not exist. |
| 132 | - if ( empty( $invoice ) ) { |
|
| 133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
| 132 | + if (empty($invoice)) { |
|
| 133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Do not update totals for paid / refunded invoices. |
| 137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 138 | 138 | |
| 139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
| 140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
| 139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
| 140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
| 145 | + return wpinv_insert_invoice($data, $wp_error); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
| 153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
| 154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
| 155 | 155 | */ |
| 156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
| 156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
| 157 | 157 | |
| 158 | 158 | // Ensure that we have invoice data. |
| 159 | - if ( empty( $data ) ) { |
|
| 159 | + if (empty($data)) { |
|
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // The invoice id will be provided when updating an invoice. |
| 164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
| 164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
| 165 | 165 | |
| 166 | 166 | // Retrieve the invoice. |
| 167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
| 167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
| 168 | 168 | |
| 169 | 169 | // Do we have an error? |
| 170 | - if ( ! empty( $invoice->last_error ) ) { |
|
| 171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
| 170 | + if (!empty($invoice->last_error)) { |
|
| 171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Backwards compatibility (billing address). |
| 175 | - if ( ! empty( $data['user_info'] ) ) { |
|
| 175 | + if (!empty($data['user_info'])) { |
|
| 176 | 176 | |
| 177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
| 177 | + foreach ($data['user_info'] as $key => $value) { |
|
| 178 | 178 | |
| 179 | - if ( $key == 'discounts' ) { |
|
| 179 | + if ($key == 'discounts') { |
|
| 180 | 180 | $value = (array) $value; |
| 181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
| 181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
| 182 | 182 | } else { |
| 183 | - $data[ $key ] = $value; |
|
| 183 | + $data[$key] = $value; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Backwards compatibility. |
| 191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
| 191 | + if (!empty($data['payment_details'])) { |
|
| 192 | 192 | |
| 193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
| 194 | - $data[ $key ] = $value; |
|
| 193 | + foreach ($data['payment_details'] as $key => $value) { |
|
| 194 | + $data[$key] = $value; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Set up the owner of the invoice. |
| 200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
| 200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
| 201 | 201 | |
| 202 | 202 | // Make sure the user exists. |
| 203 | - if ( ! get_userdata( $user_id ) ) { |
|
| 204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
| 203 | + if (!get_userdata($user_id)) { |
|
| 204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $address = wpinv_get_user_address( $user_id ); |
|
| 207 | + $address = wpinv_get_user_address($user_id); |
|
| 208 | 208 | |
| 209 | - foreach ( $address as $key => $value ) { |
|
| 209 | + foreach ($address as $key => $value) { |
|
| 210 | 210 | |
| 211 | - if ( $value == '' ) { |
|
| 212 | - $address[ $key ] = null; |
|
| 211 | + if ($value == '') { |
|
| 212 | + $address[$key] = null; |
|
| 213 | 213 | } else { |
| 214 | - $address[ $key ] = wpinv_clean( $value ); |
|
| 214 | + $address[$key] = wpinv_clean($value); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
| 222 | 222 | array( |
| 223 | 223 | |
| 224 | 224 | // Basic info. |
| 225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
| 226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
| 227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
| 228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
| 229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
| 230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
| 231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
| 232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
| 233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
| 234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
| 235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
| 236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
| 237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
| 225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
| 226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
| 227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
| 228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
| 229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
| 230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
| 231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
| 232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
| 233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
| 234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
| 235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
| 236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
| 237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
| 238 | 238 | |
| 239 | 239 | // Payment info. |
| 240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
| 241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
| 242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
| 243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
| 244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
| 245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
| 246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
| 247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
| 248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
| 249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
| 250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
| 251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
| 240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
| 241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
| 242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
| 243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
| 244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
| 245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
| 246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
| 247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
| 248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
| 249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
| 250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
| 251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | // Billing details. |
| 255 | 255 | 'user_id' => $data['user_id'], |
| 256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
| 257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
| 258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
| 259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
| 260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
| 261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
| 262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
| 263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
| 264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
| 265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
| 266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
| 256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
| 257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
| 258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
| 259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
| 260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
| 261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
| 262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
| 263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
| 264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
| 265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
| 266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
| 267 | 267 | |
| 268 | 268 | ) |
| 269 | 269 | |
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | // Backwards compatibililty. |
| 273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
| 273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
| 274 | 274 | $data['items'] = array(); |
| 275 | 275 | |
| 276 | - foreach( $data['cart_details'] as $_item ) { |
|
| 276 | + foreach ($data['cart_details'] as $_item) { |
|
| 277 | 277 | |
| 278 | 278 | // Ensure that we have an item id. |
| 279 | - if ( empty( $_item['id'] ) ) { |
|
| 279 | + if (empty($_item['id'])) { |
|
| 280 | 280 | continue; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // Retrieve the item. |
| 284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
| 284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
| 285 | 285 | |
| 286 | 286 | // Ensure that it is purchasable. |
| 287 | - if ( ! $item->can_purchase() ) { |
|
| 287 | + if (!$item->can_purchase()) { |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Set quantity. |
| 292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
| 293 | - $item->set_quantity( $_item['quantity'] ); |
|
| 292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
| 293 | + $item->set_quantity($_item['quantity']); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Set price. |
| 297 | - if ( isset( $_item['item_price'] ) ) { |
|
| 298 | - $item->set_price( $_item['item_price'] ); |
|
| 297 | + if (isset($_item['item_price'])) { |
|
| 298 | + $item->set_price($_item['item_price']); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( isset( $_item['custom_price'] ) ) { |
|
| 302 | - $item->set_price( $_item['custom_price'] ); |
|
| 301 | + if (isset($_item['custom_price'])) { |
|
| 302 | + $item->set_price($_item['custom_price']); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Set name. |
| 306 | - if ( ! empty( $_item['name'] ) ) { |
|
| 307 | - $item->set_name( $_item['name'] ); |
|
| 306 | + if (!empty($_item['name'])) { |
|
| 307 | + $item->set_name($_item['name']); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Set description. |
| 311 | - if ( isset( $_item['description'] ) ) { |
|
| 312 | - $item->set_custom_description( $_item['description'] ); |
|
| 311 | + if (isset($_item['description'])) { |
|
| 312 | + $item->set_custom_description($_item['description']); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Set meta. |
| 316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
| 316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
| 317 | 317 | |
| 318 | - $item->set_item_meta( $_item['meta'] ); |
|
| 318 | + $item->set_item_meta($_item['meta']); |
|
| 319 | 319 | |
| 320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
| 321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
| 320 | + if (isset($_item['meta']['description'])) { |
|
| 321 | + $item->set_custom_description($_item['meta']['description']); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Add invoice items. |
| 332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
| 332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
| 333 | 333 | |
| 334 | - $invoice->set_items( array() ); |
|
| 334 | + $invoice->set_items(array()); |
|
| 335 | 335 | |
| 336 | - foreach ( $data['items'] as $item ) { |
|
| 336 | + foreach ($data['items'] as $item) { |
|
| 337 | 337 | |
| 338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
| 339 | - $invoice->add_item( $item ); |
|
| 338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
| 339 | + $invoice->add_item($item); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | } |
@@ -346,30 +346,30 @@ discard block |
||
| 346 | 346 | // Save the invoice. |
| 347 | 347 | $invoice->save(); |
| 348 | 348 | |
| 349 | - if ( ! $invoice->get_id() ) { |
|
| 350 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
| 349 | + if (!$invoice->get_id()) { |
|
| 350 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // Add private note. |
| 354 | - if ( ! empty( $data['private_note'] ) ) { |
|
| 355 | - $invoice->add_note( $data['private_note'] ); |
|
| 354 | + if (!empty($data['private_note'])) { |
|
| 355 | + $invoice->add_note($data['private_note']); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | // User notes. |
| 359 | - if ( !empty( $data['user_note'] ) ) { |
|
| 360 | - $invoice->add_note( $data['user_note'], true ); |
|
| 359 | + if (!empty($data['user_note'])) { |
|
| 360 | + $invoice->add_note($data['user_note'], true); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // Created via. |
| 364 | - if ( isset( $data['created_via'] ) ) { |
|
| 365 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
| 364 | + if (isset($data['created_via'])) { |
|
| 365 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Backwards compatiblity. |
| 369 | - if ( $invoice->is_quote() ) { |
|
| 369 | + if ($invoice->is_quote()) { |
|
| 370 | 370 | |
| 371 | - if ( isset( $data['valid_until'] ) ) { |
|
| 372 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
| 371 | + if (isset($data['valid_until'])) { |
|
| 372 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
| 373 | 373 | } |
| 374 | 374 | return $invoice; |
| 375 | 375 | |
@@ -384,18 +384,18 @@ discard block |
||
| 384 | 384 | * @param $bool $deprecated |
| 385 | 385 | * @return WPInv_Invoice|null |
| 386 | 386 | */ |
| 387 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
| 387 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
| 388 | 388 | |
| 389 | 389 | // If we are retrieving the invoice from the cart... |
| 390 | - if ( $deprecated && empty( $invoice ) ) { |
|
| 390 | + if ($deprecated && empty($invoice)) { |
|
| 391 | 391 | $invoice = (int) getpaid_get_current_invoice_id(); |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // Retrieve the invoice. |
| 395 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 395 | + $invoice = new WPInv_Invoice($invoice); |
|
| 396 | 396 | |
| 397 | 397 | // Check if it exists. |
| 398 | - if ( $invoice->get_id() != 0 ) { |
|
| 398 | + if ($invoice->get_id() != 0) { |
|
| 399 | 399 | return $invoice; |
| 400 | 400 | } |
| 401 | 401 | |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | * @param array $args Args to search for. |
| 409 | 409 | * @return WPInv_Invoice[]|int[]|object |
| 410 | 410 | */ |
| 411 | -function wpinv_get_invoices( $args ) { |
|
| 411 | +function wpinv_get_invoices($args) { |
|
| 412 | 412 | |
| 413 | 413 | // Prepare args. |
| 414 | 414 | $args = wp_parse_args( |
| 415 | 415 | $args, |
| 416 | 416 | array( |
| 417 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 417 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 418 | 418 | 'type' => 'wpi_invoice', |
| 419 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 419 | + 'limit' => get_option('posts_per_page'), |
|
| 420 | 420 | 'return' => 'objects', |
| 421 | 421 | ) |
| 422 | 422 | ); |
@@ -434,24 +434,24 @@ discard block |
||
| 434 | 434 | 'post__in' => 'include', |
| 435 | 435 | ); |
| 436 | 436 | |
| 437 | - foreach ( $map_legacy as $to => $from ) { |
|
| 438 | - if ( isset( $args[ $from ] ) ) { |
|
| 439 | - $args[ $to ] = $args[ $from ]; |
|
| 440 | - unset( $args[ $from ] ); |
|
| 437 | + foreach ($map_legacy as $to => $from) { |
|
| 438 | + if (isset($args[$from])) { |
|
| 439 | + $args[$to] = $args[$from]; |
|
| 440 | + unset($args[$from]); |
|
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // Backwards compatibility. |
| 445 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
| 445 | + if (!empty($args['email']) && empty($args['user'])) { |
|
| 446 | 446 | $args['user'] = $args['email']; |
| 447 | - unset( $args['email'] ); |
|
| 447 | + unset($args['email']); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Handle cases where the user is set as an email. |
| 451 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
| 452 | - $user = get_user_by( 'email', $args['user'] ); |
|
| 451 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
| 452 | + $user = get_user_by('email', $args['user']); |
|
| 453 | 453 | |
| 454 | - if ( $user ) { |
|
| 454 | + if ($user) { |
|
| 455 | 455 | $args['author'] = $user->user_email; |
| 456 | 456 | } |
| 457 | 457 | |
@@ -462,31 +462,31 @@ discard block |
||
| 462 | 462 | |
| 463 | 463 | // Show all posts. |
| 464 | 464 | $paginate = true; |
| 465 | - if ( isset( $args['paginate'] ) ) { |
|
| 465 | + if (isset($args['paginate'])) { |
|
| 466 | 466 | |
| 467 | 467 | $paginate = $args['paginate']; |
| 468 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
| 469 | - unset( $args['paginate'] ); |
|
| 468 | + $args['no_found_rows'] = empty($args['paginate']); |
|
| 469 | + unset($args['paginate']); |
|
| 470 | 470 | |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // Whether to return objects or fields. |
| 474 | 474 | $return = $args['return']; |
| 475 | - unset( $args['return'] ); |
|
| 475 | + unset($args['return']); |
|
| 476 | 476 | |
| 477 | 477 | // Get invoices. |
| 478 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
| 478 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
| 479 | 479 | |
| 480 | 480 | // Prepare the results. |
| 481 | - if ( 'objects' === $return ) { |
|
| 482 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
| 483 | - } elseif ( 'self' === $return ) { |
|
| 481 | + if ('objects' === $return) { |
|
| 482 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
| 483 | + } elseif ('self' === $return) { |
|
| 484 | 484 | return $invoices; |
| 485 | 485 | } else { |
| 486 | 486 | $results = $invoices->posts; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - if ( $paginate ) { |
|
| 489 | + if ($paginate) { |
|
| 490 | 490 | return (object) array( |
| 491 | 491 | 'invoices' => $results, |
| 492 | 492 | 'total' => $invoices->found_posts, |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | * @param string $transaction_id The transaction id to check. |
| 505 | 505 | * @return int Invoice id on success or 0 on failure |
| 506 | 506 | */ |
| 507 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
| 508 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
| 507 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
| 508 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | /** |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | * @param string $invoice_number The invoice number to check. |
| 515 | 515 | * @return int Invoice id on success or 0 on failure |
| 516 | 516 | */ |
| 517 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
| 518 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
| 517 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
| 518 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -524,8 +524,8 @@ discard block |
||
| 524 | 524 | * @param string $invoice_key The invoice key to check. |
| 525 | 525 | * @return int Invoice id on success or 0 on failure |
| 526 | 526 | */ |
| 527 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
| 528 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
| 527 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
| 528 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -535,19 +535,19 @@ discard block |
||
| 535 | 535 | * @param string $type Optionally filter by type i.e customer|system |
| 536 | 536 | * @return array|null |
| 537 | 537 | */ |
| 538 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
| 538 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
| 539 | 539 | |
| 540 | 540 | // Prepare the invoice. |
| 541 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 542 | - if ( empty( $invoice ) ) { |
|
| 541 | + $invoice = wpinv_get_invoice($invoice); |
|
| 542 | + if (empty($invoice)) { |
|
| 543 | 543 | return NULL; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | // Fetch notes. |
| 547 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
| 547 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
| 548 | 548 | |
| 549 | 549 | // Filter the notes. |
| 550 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
| 550 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -557,27 +557,27 @@ discard block |
||
| 557 | 557 | $columns = array( |
| 558 | 558 | |
| 559 | 559 | 'invoice-number' => array( |
| 560 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
| 560 | + 'title' => __('Invoice', 'invoicing'), |
|
| 561 | 561 | 'class' => 'text-left' |
| 562 | 562 | ), |
| 563 | 563 | |
| 564 | 564 | 'created-date' => array( |
| 565 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
| 565 | + 'title' => __('Created Date', 'invoicing'), |
|
| 566 | 566 | 'class' => 'text-left' |
| 567 | 567 | ), |
| 568 | 568 | |
| 569 | 569 | 'payment-date' => array( |
| 570 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
| 570 | + 'title' => __('Payment Date', 'invoicing'), |
|
| 571 | 571 | 'class' => 'text-left' |
| 572 | 572 | ), |
| 573 | 573 | |
| 574 | 574 | 'invoice-status' => array( |
| 575 | - 'title' => __( 'Status', 'invoicing' ), |
|
| 575 | + 'title' => __('Status', 'invoicing'), |
|
| 576 | 576 | 'class' => 'text-center' |
| 577 | 577 | ), |
| 578 | 578 | |
| 579 | 579 | 'invoice-total' => array( |
| 580 | - 'title' => __( 'Total', 'invoicing' ), |
|
| 580 | + 'title' => __('Total', 'invoicing'), |
|
| 581 | 581 | 'class' => 'text-right' |
| 582 | 582 | ), |
| 583 | 583 | |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | ); |
| 590 | 590 | |
| 591 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
| 591 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -598,54 +598,54 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | // Find the invoice. |
| 600 | 600 | $invoice_id = getpaid_get_current_invoice_id(); |
| 601 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 601 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 602 | 602 | |
| 603 | 603 | // Abort if non was found. |
| 604 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
| 604 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
| 605 | 605 | |
| 606 | 606 | return aui()->alert( |
| 607 | 607 | array( |
| 608 | 608 | 'type' => 'warning', |
| 609 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
| 609 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
| 610 | 610 | ) |
| 611 | 611 | ); |
| 612 | 612 | |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // Can the user view this invoice? |
| 616 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
| 616 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
| 617 | 617 | |
| 618 | 618 | return aui()->alert( |
| 619 | 619 | array( |
| 620 | 620 | 'type' => 'warning', |
| 621 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
| 621 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
| 622 | 622 | ) |
| 623 | 623 | ); |
| 624 | 624 | |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // Load the template. |
| 628 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
| 628 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
| 629 | 629 | |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | /** |
| 633 | 633 | * Displays the invoice history. |
| 634 | 634 | */ |
| 635 | -function getpaid_invoice_history( $user_id = 0 ) { |
|
| 635 | +function getpaid_invoice_history($user_id = 0) { |
|
| 636 | 636 | |
| 637 | 637 | // Ensure that we have a user id. |
| 638 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
| 638 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
| 639 | 639 | $user_id = get_current_user_id(); |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | // View user id. |
| 643 | - if ( empty( $user_id ) ) { |
|
| 643 | + if (empty($user_id)) { |
|
| 644 | 644 | |
| 645 | 645 | return aui()->alert( |
| 646 | 646 | array( |
| 647 | 647 | 'type' => 'warning', |
| 648 | - 'content' => __( 'You must be logged in to view your invoice history.', 'invoicing' ), |
|
| 648 | + 'content' => __('You must be logged in to view your invoice history.', 'invoicing'), |
|
| 649 | 649 | ) |
| 650 | 650 | ); |
| 651 | 651 | |
@@ -655,55 +655,55 @@ discard block |
||
| 655 | 655 | $invoices = wpinv_get_invoices( |
| 656 | 656 | |
| 657 | 657 | array( |
| 658 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 658 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
| 659 | 659 | 'user' => $user_id, |
| 660 | 660 | 'paginate' => true, |
| 661 | 661 | ) |
| 662 | 662 | |
| 663 | 663 | ); |
| 664 | 664 | |
| 665 | - if ( empty( $invoices->total ) ) { |
|
| 665 | + if (empty($invoices->total)) { |
|
| 666 | 666 | |
| 667 | 667 | return aui()->alert( |
| 668 | 668 | array( |
| 669 | 669 | 'type' => 'info', |
| 670 | - 'content' => __( 'No invoices found.', 'invoicing' ), |
|
| 670 | + 'content' => __('No invoices found.', 'invoicing'), |
|
| 671 | 671 | ) |
| 672 | 672 | ); |
| 673 | 673 | |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | // Load the template. |
| 677 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices' ) ); |
|
| 677 | + return wpinv_get_template_html('invoice-history.php', compact('invoices')); |
|
| 678 | 678 | |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
| 682 | 682 | * Formats an invoice number given an invoice type. |
| 683 | 683 | */ |
| 684 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
| 684 | +function wpinv_format_invoice_number($number, $type = '') { |
|
| 685 | 685 | |
| 686 | 686 | // Allow other plugins to overide this. |
| 687 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
| 688 | - if ( null !== $check ) { |
|
| 687 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
| 688 | + if (null !== $check) { |
|
| 689 | 689 | return $check; |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | // Ensure that we have a numeric number. |
| 693 | - if ( ! is_numeric( $number ) ) { |
|
| 693 | + if (!is_numeric($number)) { |
|
| 694 | 694 | return $number; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | // Format the number. |
| 698 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd' ) ); |
|
| 699 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
| 700 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
| 701 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
| 698 | + $padd = absint((int) wpinv_get_option('invoice_number_padd')); |
|
| 699 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
| 700 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
| 701 | + $formatted_number = zeroise(absint($number), $padd); |
|
| 702 | 702 | |
| 703 | 703 | // Add the prefix and post fix. |
| 704 | 704 | $formatted_number = $prefix . $formatted_number . $postfix; |
| 705 | 705 | |
| 706 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
| 706 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
@@ -712,58 +712,58 @@ discard block |
||
| 712 | 712 | * @param string $type. |
| 713 | 713 | * @return int|null|bool |
| 714 | 714 | */ |
| 715 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
| 715 | +function wpinv_get_next_invoice_number($type = '') { |
|
| 716 | 716 | |
| 717 | 717 | // Allow plugins to overide this. |
| 718 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
| 719 | - if ( null !== $check ) { |
|
| 718 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
| 719 | + if (null !== $check) { |
|
| 720 | 720 | return $check; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | // Ensure sequential invoice numbers is active. |
| 724 | - if ( ! wpinv_sequential_number_active() ) { |
|
| 724 | + if (!wpinv_sequential_number_active()) { |
|
| 725 | 725 | return false; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | // Retrieve the current number and the start number. |
| 729 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
| 730 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
| 729 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
| 730 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
| 731 | 731 | |
| 732 | 732 | // Ensure that we are starting at a positive integer. |
| 733 | - $start = max( $start, 1 ); |
|
| 733 | + $start = max($start, 1); |
|
| 734 | 734 | |
| 735 | 735 | // If this is the first invoice, use the start number. |
| 736 | - $number = max( $start, $number ); |
|
| 736 | + $number = max($start, $number); |
|
| 737 | 737 | |
| 738 | 738 | // Format the invoice number. |
| 739 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
| 739 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
| 740 | 740 | |
| 741 | 741 | // Ensure that this number is unique. |
| 742 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
| 742 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
| 743 | 743 | |
| 744 | 744 | // We found a match. Nice. |
| 745 | - if ( empty( $invoice_id ) ) { |
|
| 746 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
| 747 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
| 745 | + if (empty($invoice_id)) { |
|
| 746 | + update_option('wpinv_last_invoice_number', $number); |
|
| 747 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
| 751 | - return wpinv_get_next_invoice_number( $type ); |
|
| 750 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
| 751 | + return wpinv_get_next_invoice_number($type); |
|
| 752 | 752 | |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | /** |
| 756 | 756 | * The prefix used for invoice paths. |
| 757 | 757 | */ |
| 758 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
| 759 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
| 758 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
| 759 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | -function wpinv_generate_post_name( $post_ID ) { |
|
| 763 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
| 764 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
| 762 | +function wpinv_generate_post_name($post_ID) { |
|
| 763 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
| 764 | + $post_name = sanitize_title($prefix . $post_ID); |
|
| 765 | 765 | |
| 766 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
| 766 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | /** |
@@ -771,8 +771,8 @@ discard block |
||
| 771 | 771 | * |
| 772 | 772 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 773 | 773 | */ |
| 774 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
| 775 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 774 | +function wpinv_is_invoice_viewed($invoice) { |
|
| 775 | + $invoice = new WPInv_Invoice($invoice); |
|
| 776 | 776 | return (bool) $invoice->get_is_viewed(); |
| 777 | 777 | } |
| 778 | 778 | |
@@ -781,17 +781,17 @@ discard block |
||
| 781 | 781 | * |
| 782 | 782 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
| 783 | 783 | */ |
| 784 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
| 785 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 784 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
| 785 | + $invoice = new WPInv_Invoice($invoice); |
|
| 786 | 786 | |
| 787 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
| 788 | - $invoice->set_is_viewed( true ); |
|
| 787 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
| 788 | + $invoice->set_is_viewed(true); |
|
| 789 | 789 | $invoice->save(); |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | } |
| 793 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 794 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
| 793 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 794 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
| 795 | 795 | |
| 796 | 796 | /** |
| 797 | 797 | * Processes an invoice refund. |
@@ -801,27 +801,27 @@ discard block |
||
| 801 | 801 | * @param array $status_transition |
| 802 | 802 | * @todo: descrease customer/store earnings |
| 803 | 803 | */ |
| 804 | -function getpaid_maybe_process_refund( $invoice_id, $invoice, $status_transition ) { |
|
| 804 | +function getpaid_maybe_process_refund($invoice_id, $invoice, $status_transition) { |
|
| 805 | 805 | |
| 806 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
| 806 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
| 807 | 807 | return; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | $discount_code = $invoice->get_discount_code(); |
| 811 | - if ( ! empty( $discount_code ) ) { |
|
| 812 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 811 | + if (!empty($discount_code)) { |
|
| 812 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 813 | 813 | |
| 814 | - if ( $discount->exists() ) { |
|
| 814 | + if ($discount->exists()) { |
|
| 815 | 815 | $discount->increase_usage( -1 ); |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice_id ); |
|
| 821 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice_id ); |
|
| 822 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice_id ); |
|
| 820 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice_id); |
|
| 821 | + do_action('wpinv_refund_invoice', $invoice, $invoice_id); |
|
| 822 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice_id); |
|
| 823 | 823 | } |
| 824 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3 ); |
|
| 824 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3); |
|
| 825 | 825 | |
| 826 | 826 | |
| 827 | 827 | /** |
@@ -829,48 +829,48 @@ discard block |
||
| 829 | 829 | * |
| 830 | 830 | * @param int $invoice_id |
| 831 | 831 | */ |
| 832 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
| 832 | +function getpaid_process_invoice_payment($invoice_id) { |
|
| 833 | 833 | |
| 834 | 834 | // Fetch the invoice. |
| 835 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 835 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 836 | 836 | |
| 837 | 837 | // We only want to do this once. |
| 838 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
| 838 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
| 839 | 839 | return; |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
| 842 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
| 843 | 843 | |
| 844 | 844 | // Fires when processing a payment. |
| 845 | - do_action( 'getpaid_process_payment', $invoice ); |
|
| 845 | + do_action('getpaid_process_payment', $invoice); |
|
| 846 | 846 | |
| 847 | 847 | // Fire an action for each invoice item. |
| 848 | - foreach( $invoice->get_items() as $item ) { |
|
| 849 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
| 848 | + foreach ($invoice->get_items() as $item) { |
|
| 849 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | // Increase discount usage. |
| 853 | 853 | $discount_code = $invoice->get_discount_code(); |
| 854 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
| 855 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 854 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
| 855 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 856 | 856 | |
| 857 | - if ( $discount->exists() ) { |
|
| 857 | + if ($discount->exists()) { |
|
| 858 | 858 | $discount->increase_usage(); |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | // Record reverse vat. |
| 864 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
| 864 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
| 865 | 865 | |
| 866 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
| 867 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
| 866 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
| 867 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | } |
| 873 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
| 873 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
| 874 | 874 | |
| 875 | 875 | /** |
| 876 | 876 | * Returns an array of invoice item columns |
@@ -878,13 +878,13 @@ discard block |
||
| 878 | 878 | * @param int|WPInv_Invoice $invoice |
| 879 | 879 | * @return array |
| 880 | 880 | */ |
| 881 | -function getpaid_invoice_item_columns( $invoice ) { |
|
| 881 | +function getpaid_invoice_item_columns($invoice) { |
|
| 882 | 882 | |
| 883 | 883 | // Prepare the invoice. |
| 884 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 884 | + $invoice = new WPInv_Invoice($invoice); |
|
| 885 | 885 | |
| 886 | 886 | // Abort if there is no invoice. |
| 887 | - if ( 0 == $invoice->get_id() ) { |
|
| 887 | + if (0 == $invoice->get_id()) { |
|
| 888 | 888 | return array(); |
| 889 | 889 | } |
| 890 | 890 | |
@@ -892,47 +892,47 @@ discard block |
||
| 892 | 892 | $columns = apply_filters( |
| 893 | 893 | 'getpaid_invoice_item_columns', |
| 894 | 894 | array( |
| 895 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 896 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 897 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 898 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 895 | + 'name' => __('Item', 'invoicing'), |
|
| 896 | + 'price' => __('Price', 'invoicing'), |
|
| 897 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 898 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 899 | 899 | ), |
| 900 | 900 | $invoice |
| 901 | 901 | ); |
| 902 | 902 | |
| 903 | 903 | // Quantities. |
| 904 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
| 904 | + if (isset($columns['quantity'])) { |
|
| 905 | 905 | |
| 906 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 907 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
| 906 | + if ('hours' == $invoice->get_template()) { |
|
| 907 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
| 911 | - unset( $columns[ 'quantity' ] ); |
|
| 910 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
| 911 | + unset($columns['quantity']); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | |
| 917 | 917 | // Price. |
| 918 | - if ( isset( $columns[ 'price' ] ) ) { |
|
| 918 | + if (isset($columns['price'])) { |
|
| 919 | 919 | |
| 920 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 921 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
| 920 | + if ('amount' == $invoice->get_template()) { |
|
| 921 | + $columns['price'] = __('Amount', 'invoicing'); |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - if ( 'hours' == $invoice->get_template() ) { |
|
| 925 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
| 924 | + if ('hours' == $invoice->get_template()) { |
|
| 925 | + $columns['price'] = __('Rate', 'invoicing'); |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | |
| 931 | 931 | // Sub total. |
| 932 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
| 932 | + if (isset($columns['subtotal'])) { |
|
| 933 | 933 | |
| 934 | - if ( 'amount' == $invoice->get_template() ) { |
|
| 935 | - unset( $columns[ 'subtotal' ] ); |
|
| 934 | + if ('amount' == $invoice->get_template()) { |
|
| 935 | + unset($columns['subtotal']); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | } |
@@ -946,30 +946,30 @@ discard block |
||
| 946 | 946 | * @param int|WPInv_Invoice $invoice |
| 947 | 947 | * @return array |
| 948 | 948 | */ |
| 949 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
| 949 | +function getpaid_invoice_totals_rows($invoice) { |
|
| 950 | 950 | |
| 951 | 951 | // Prepare the invoice. |
| 952 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 952 | + $invoice = new WPInv_Invoice($invoice); |
|
| 953 | 953 | |
| 954 | 954 | // Abort if there is no invoice. |
| 955 | - if ( 0 == $invoice->get_id() ) { |
|
| 955 | + if (0 == $invoice->get_id()) { |
|
| 956 | 956 | return array(); |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | $totals = apply_filters( |
| 960 | 960 | 'getpaid_invoice_totals_rows', |
| 961 | 961 | array( |
| 962 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 963 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 964 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
| 965 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 966 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 962 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 963 | + 'tax' => __('Tax', 'invoicing'), |
|
| 964 | + 'fee' => __('Fee', 'invoicing'), |
|
| 965 | + 'discount' => __('Discount', 'invoicing'), |
|
| 966 | + 'total' => __('Total', 'invoicing'), |
|
| 967 | 967 | ), |
| 968 | 968 | $invoice |
| 969 | 969 | ); |
| 970 | 970 | |
| 971 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
| 972 | - unset( $totals['tax'] ); |
|
| 971 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
| 972 | + unset($totals['tax']); |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | return $totals; |
@@ -980,46 +980,46 @@ discard block |
||
| 980 | 980 | * |
| 981 | 981 | * @param WPInv_Invoice $invoice |
| 982 | 982 | */ |
| 983 | -function getpaid_new_invoice( $invoice ) { |
|
| 983 | +function getpaid_new_invoice($invoice) { |
|
| 984 | 984 | |
| 985 | - if ( ! $invoice->get_status() ) { |
|
| 985 | + if (!$invoice->get_status()) { |
|
| 986 | 986 | return; |
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | // Add an invoice created note. |
| 990 | 990 | $invoice->add_note( |
| 991 | 991 | wp_sprintf( |
| 992 | - __( 'Invoice created with the status "%s".', 'invoicing' ), |
|
| 993 | - wpinv_status_nicename( $invoice->get_status() ) |
|
| 992 | + __('Invoice created with the status "%s".', 'invoicing'), |
|
| 993 | + wpinv_status_nicename($invoice->get_status()) |
|
| 994 | 994 | ) |
| 995 | 995 | ); |
| 996 | 996 | |
| 997 | 997 | } |
| 998 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
| 998 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
| 999 | 999 | |
| 1000 | 1000 | /** |
| 1001 | 1001 | * This function updates invoice caches. |
| 1002 | 1002 | * |
| 1003 | 1003 | * @param WPInv_Invoice $invoice |
| 1004 | 1004 | */ |
| 1005 | -function getpaid_update_invoice_caches( $invoice ) { |
|
| 1005 | +function getpaid_update_invoice_caches($invoice) { |
|
| 1006 | 1006 | |
| 1007 | 1007 | // Cache invoice number. |
| 1008 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
| 1008 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
| 1009 | 1009 | |
| 1010 | 1010 | // Cache invoice key. |
| 1011 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
| 1011 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
| 1012 | 1012 | |
| 1013 | 1013 | // (Maybe) cache transaction id. |
| 1014 | 1014 | $transaction_id = $invoice->get_transaction_id(); |
| 1015 | 1015 | |
| 1016 | - if ( ! empty( $transaction_id ) ) { |
|
| 1017 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
| 1016 | + if (!empty($transaction_id)) { |
|
| 1017 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | } |
| 1021 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
| 1022 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
| 1021 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
| 1022 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
| 1023 | 1023 | |
| 1024 | 1024 | /** |
| 1025 | 1025 | * Duplicates an invoice. |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
| 1030 | 1030 | * @return WPInv_Invoice The new invoice. |
| 1031 | 1031 | */ |
| 1032 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
| 1032 | +function getpaid_duplicate_invoice($old_invoice) { |
|
| 1033 | 1033 | |
| 1034 | 1034 | // Create the new invoice. |
| 1035 | 1035 | $invoice = new WPInv_Invoice(); |
@@ -218,8 +218,9 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | // Setup possible parts |
| 220 | 220 | $templates = array(); |
| 221 | - if ( isset( $name ) ) |
|
| 222 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 221 | + if ( isset( $name ) ) { |
|
| 222 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 223 | + } |
|
| 223 | 224 | $templates[] = $slug . '.php'; |
| 224 | 225 | |
| 225 | 226 | // Allow template parts to be filtered |
@@ -237,8 +238,9 @@ discard block |
||
| 237 | 238 | foreach ( (array)$template_names as $template_name ) { |
| 238 | 239 | |
| 239 | 240 | // Continue if template is empty |
| 240 | - if ( empty( $template_name ) ) |
|
| 241 | - continue; |
|
| 241 | + if ( empty( $template_name ) ) { |
|
| 242 | + continue; |
|
| 243 | + } |
|
| 242 | 244 | |
| 243 | 245 | // Trim off any slashes from the template name |
| 244 | 246 | $template_name = ltrim( $template_name, '/' ); |
@@ -257,8 +259,9 @@ discard block |
||
| 257 | 259 | } |
| 258 | 260 | } |
| 259 | 261 | |
| 260 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 261 | - load_template( $located, $require_once ); |
|
| 262 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 263 | + load_template( $located, $require_once ); |
|
| 264 | + } |
|
| 262 | 265 | |
| 263 | 266 | return $located; |
| 264 | 267 | } |
@@ -336,8 +339,9 @@ discard block |
||
| 336 | 339 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
| 337 | 340 | $args = array( 'nopaging' => true ); |
| 338 | 341 | |
| 339 | - if ( ! empty( $status ) ) |
|
| 340 | - $args['post_status'] = $status; |
|
| 342 | + if ( ! empty( $status ) ) { |
|
| 343 | + $args['post_status'] = $status; |
|
| 344 | + } |
|
| 341 | 345 | |
| 342 | 346 | $discounts = wpinv_get_discounts( $args ); |
| 343 | 347 | $options = array(); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -175,122 +175,122 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 179 | 179 | |
| 180 | - // Setup possible parts |
|
| 181 | - $templates = array(); |
|
| 182 | - if ( isset( $name ) ) |
|
| 183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 184 | - $templates[] = $slug . '.php'; |
|
| 180 | + // Setup possible parts |
|
| 181 | + $templates = array(); |
|
| 182 | + if ( isset( $name ) ) |
|
| 183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 184 | + $templates[] = $slug . '.php'; |
|
| 185 | 185 | |
| 186 | - // Allow template parts to be filtered |
|
| 187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 186 | + // Allow template parts to be filtered |
|
| 187 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 188 | 188 | |
| 189 | - // Return the part that is found |
|
| 190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 189 | + // Return the part that is found |
|
| 190 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
| 194 | - // No file found yet |
|
| 195 | - $located = false; |
|
| 194 | + // No file found yet |
|
| 195 | + $located = false; |
|
| 196 | 196 | |
| 197 | - // Try to find a template file |
|
| 198 | - foreach ( (array)$template_names as $template_name ) { |
|
| 197 | + // Try to find a template file |
|
| 198 | + foreach ( (array)$template_names as $template_name ) { |
|
| 199 | 199 | |
| 200 | - // Continue if template is empty |
|
| 201 | - if ( empty( $template_name ) ) |
|
| 202 | - continue; |
|
| 200 | + // Continue if template is empty |
|
| 201 | + if ( empty( $template_name ) ) |
|
| 202 | + continue; |
|
| 203 | 203 | |
| 204 | - // Trim off any slashes from the template name |
|
| 205 | - $template_name = ltrim( $template_name, '/' ); |
|
| 204 | + // Trim off any slashes from the template name |
|
| 205 | + $template_name = ltrim( $template_name, '/' ); |
|
| 206 | 206 | |
| 207 | - // try locating this template file by looping through the template paths |
|
| 208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 207 | + // try locating this template file by looping through the template paths |
|
| 208 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 209 | 209 | |
| 210 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 211 | - $located = $template_path . $template_name; |
|
| 212 | - break; |
|
| 213 | - } |
|
| 214 | - } |
|
| 210 | + if( file_exists( $template_path . $template_name ) ) { |
|
| 211 | + $located = $template_path . $template_name; |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - if( !empty( $located ) ) { |
|
| 217 | - break; |
|
| 218 | - } |
|
| 219 | - } |
|
| 216 | + if( !empty( $located ) ) { |
|
| 217 | + break; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 222 | - load_template( $located, $require_once ); |
|
| 221 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
| 222 | + load_template( $located, $require_once ); |
|
| 223 | 223 | |
| 224 | - return $located; |
|
| 224 | + return $located; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | function wpinv_get_theme_template_paths() { |
| 228 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 228 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 229 | 229 | |
| 230 | - $file_paths = array( |
|
| 231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 233 | - 100 => wpinv_get_templates_dir() |
|
| 234 | - ); |
|
| 230 | + $file_paths = array( |
|
| 231 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 232 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 233 | + 100 => wpinv_get_templates_dir() |
|
| 234 | + ); |
|
| 235 | 235 | |
| 236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 236 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 237 | 237 | |
| 238 | - // sort the file paths based on priority |
|
| 239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 238 | + // sort the file paths based on priority |
|
| 239 | + ksort( $file_paths, SORT_NUMERIC ); |
|
| 240 | 240 | |
| 241 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 241 | + return array_map( 'trailingslashit', $file_paths ); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function wpinv_checkout_meta_tags() { |
| 245 | 245 | |
| 246 | - $pages = array(); |
|
| 247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 246 | + $pages = array(); |
|
| 247 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
| 248 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 249 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 250 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 251 | 251 | |
| 252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 253 | - return; |
|
| 254 | - } |
|
| 252 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 253 | + return; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 256 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 257 | 257 | } |
| 258 | 258 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
| 259 | 259 | |
| 260 | 260 | function wpinv_add_body_classes( $class ) { |
| 261 | - $classes = (array)$class; |
|
| 261 | + $classes = (array)$class; |
|
| 262 | 262 | |
| 263 | - if( wpinv_is_checkout() ) { |
|
| 264 | - $classes[] = 'wpinv-checkout'; |
|
| 265 | - $classes[] = 'wpinv-page'; |
|
| 266 | - } |
|
| 263 | + if( wpinv_is_checkout() ) { |
|
| 264 | + $classes[] = 'wpinv-checkout'; |
|
| 265 | + $classes[] = 'wpinv-page'; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - if( wpinv_is_success_page() ) { |
|
| 269 | - $classes[] = 'wpinv-success'; |
|
| 270 | - $classes[] = 'wpinv-page'; |
|
| 271 | - } |
|
| 268 | + if( wpinv_is_success_page() ) { |
|
| 269 | + $classes[] = 'wpinv-success'; |
|
| 270 | + $classes[] = 'wpinv-page'; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 274 | - $classes[] = 'wpinv-failed-transaction'; |
|
| 275 | - $classes[] = 'wpinv-page'; |
|
| 276 | - } |
|
| 273 | + if( wpinv_is_failed_transaction_page() ) { |
|
| 274 | + $classes[] = 'wpinv-failed-transaction'; |
|
| 275 | + $classes[] = 'wpinv-page'; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - if( wpinv_is_invoice_history_page() ) { |
|
| 279 | - $classes[] = 'wpinv-history'; |
|
| 280 | - $classes[] = 'wpinv-page'; |
|
| 281 | - } |
|
| 278 | + if( wpinv_is_invoice_history_page() ) { |
|
| 279 | + $classes[] = 'wpinv-history'; |
|
| 280 | + $classes[] = 'wpinv-page'; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 284 | - $classes[] = 'wpinv-subscription'; |
|
| 285 | - $classes[] = 'wpinv-page'; |
|
| 286 | - } |
|
| 283 | + if( wpinv_is_subscriptions_history_page() ) { |
|
| 284 | + $classes[] = 'wpinv-subscription'; |
|
| 285 | + $classes[] = 'wpinv-page'; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - if( wpinv_is_test_mode() ) { |
|
| 289 | - $classes[] = 'wpinv-test-mode'; |
|
| 290 | - $classes[] = 'wpinv-page'; |
|
| 291 | - } |
|
| 288 | + if( wpinv_is_test_mode() ) { |
|
| 289 | + $classes[] = 'wpinv-test-mode'; |
|
| 290 | + $classes[] = 'wpinv-page'; |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - return array_unique( $classes ); |
|
| 293 | + return array_unique( $classes ); |
|
| 294 | 294 | } |
| 295 | 295 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
| 296 | 296 | |
@@ -992,21 +992,21 @@ discard block |
||
| 992 | 992 | |
| 993 | 993 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
| 994 | 994 | |
| 995 | - // Remove unavailable tags. |
|
| 995 | + // Remove unavailable tags. |
|
| 996 | 996 | $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
| 997 | 997 | |
| 998 | 998 | // Clean up white space. |
| 999 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 999 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 1000 | 1000 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
| 1001 | 1001 | |
| 1002 | 1002 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 1003 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 1003 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 1004 | 1004 | |
| 1005 | 1005 | // Add html breaks. |
| 1006 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 1006 | + $formatted_address = implode( $separator, $formatted_address ); |
|
| 1007 | 1007 | |
| 1008 | - // We're done! |
|
| 1009 | - return $formatted_address; |
|
| 1008 | + // We're done! |
|
| 1009 | + return $formatted_address; |
|
| 1010 | 1010 | |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1208,7 +1208,7 @@ discard block |
||
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | function wpinv_empty_cart_message() { |
| 1211 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1211 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | /** |
@@ -1498,10 +1498,10 @@ discard block |
||
| 1498 | 1498 | |
| 1499 | 1499 | if ( 0 == count( $form->get_items() ) ) { |
| 1500 | 1500 | echo aui()->alert( |
| 1501 | - array( |
|
| 1502 | - 'type' => 'warning', |
|
| 1503 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1504 | - ) |
|
| 1501 | + array( |
|
| 1502 | + 'type' => 'warning', |
|
| 1503 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1504 | + ) |
|
| 1505 | 1505 | ); |
| 1506 | 1506 | return; |
| 1507 | 1507 | } |
@@ -1517,21 +1517,21 @@ discard block |
||
| 1517 | 1517 | $invoice = wpinv_get_invoice( $invoice_id ); |
| 1518 | 1518 | |
| 1519 | 1519 | if ( empty( $invoice ) ) { |
| 1520 | - echo aui()->alert( |
|
| 1521 | - array( |
|
| 1522 | - 'type' => 'warning', |
|
| 1523 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1524 | - ) |
|
| 1520 | + echo aui()->alert( |
|
| 1521 | + array( |
|
| 1522 | + 'type' => 'warning', |
|
| 1523 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1524 | + ) |
|
| 1525 | 1525 | ); |
| 1526 | 1526 | return; |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | if ( $invoice->is_paid() ) { |
| 1530 | - echo aui()->alert( |
|
| 1531 | - array( |
|
| 1532 | - 'type' => 'warning', |
|
| 1533 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1534 | - ) |
|
| 1530 | + echo aui()->alert( |
|
| 1531 | + array( |
|
| 1532 | + 'type' => 'warning', |
|
| 1533 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1534 | + ) |
|
| 1535 | 1535 | ); |
| 1536 | 1536 | return; |
| 1537 | 1537 | } |
@@ -1594,7 +1594,7 @@ discard block |
||
| 1594 | 1594 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | - if ( ! empty( $items ) ) { |
|
| 1597 | + if ( ! empty( $items ) ) { |
|
| 1598 | 1598 | $items = esc_attr( $items ); |
| 1599 | 1599 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
| 1600 | 1600 | } |
@@ -4,99 +4,99 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Displays an invoice. |
| 11 | 11 | * |
| 12 | 12 | * @param WPInv_Invoice $invoice. |
| 13 | 13 | */ |
| 14 | -function getpaid_invoice( $invoice ) { |
|
| 15 | - if ( ! empty( $invoice ) ) { |
|
| 16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
| 14 | +function getpaid_invoice($invoice) { |
|
| 15 | + if (!empty($invoice)) { |
|
| 16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
| 19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Displays the invoice footer. |
| 23 | 23 | */ |
| 24 | -function getpaid_invoice_footer( $invoice ) { |
|
| 25 | - if ( ! empty( $invoice ) ) { |
|
| 26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
| 24 | +function getpaid_invoice_footer($invoice) { |
|
| 25 | + if (!empty($invoice)) { |
|
| 26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
| 29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Displays the invoice top bar. |
| 33 | 33 | */ |
| 34 | -function getpaid_invoice_header( $invoice ) { |
|
| 35 | - if ( ! empty( $invoice ) ) { |
|
| 36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
| 34 | +function getpaid_invoice_header($invoice) { |
|
| 35 | + if (!empty($invoice)) { |
|
| 36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
| 39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Displays actions on the left side of the header. |
| 43 | 43 | */ |
| 44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
| 45 | - if ( ! empty( $invoice ) ) { |
|
| 46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
| 44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
| 45 | + if (!empty($invoice)) { |
|
| 46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
| 49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Displays actions on the right side of the invoice top bar. |
| 53 | 53 | */ |
| 54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
| 55 | - if ( ! empty( $invoice ) ) { |
|
| 56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
| 54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
| 55 | + if (!empty($invoice)) { |
|
| 56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
| 59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Displays the invoice title, watermark, logo etc. |
| 63 | 63 | */ |
| 64 | -function getpaid_invoice_details_top( $invoice ) { |
|
| 65 | - if ( ! empty( $invoice ) ) { |
|
| 66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
| 64 | +function getpaid_invoice_details_top($invoice) { |
|
| 65 | + if (!empty($invoice)) { |
|
| 66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
| 69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Displays the company logo. |
| 73 | 73 | */ |
| 74 | -function getpaid_invoice_logo( $invoice ) { |
|
| 75 | - if ( ! empty( $invoice ) ) { |
|
| 76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
| 74 | +function getpaid_invoice_logo($invoice) { |
|
| 75 | + if (!empty($invoice)) { |
|
| 76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
| 79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Displays the type of invoice. |
| 83 | 83 | */ |
| 84 | -function getpaid_invoice_type( $invoice ) { |
|
| 85 | - if ( ! empty( $invoice ) ) { |
|
| 86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
| 84 | +function getpaid_invoice_type($invoice) { |
|
| 85 | + if (!empty($invoice)) { |
|
| 86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
| 89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Displays the invoice details. |
| 93 | 93 | */ |
| 94 | -function getpaid_invoice_details_main( $invoice ) { |
|
| 95 | - if ( ! empty( $invoice ) ) { |
|
| 96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
| 94 | +function getpaid_invoice_details_main($invoice) { |
|
| 95 | + if (!empty($invoice)) { |
|
| 96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
| 99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 127 | 127 | */ |
| 128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 129 | - return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
| 128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 129 | + return getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | 151 | function wpinv_template_path() { |
| 152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
| 170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
| 171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 172 | 172 | */ |
| 173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
| 173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 179 | 179 | |
| 180 | 180 | // Setup possible parts |
| 181 | 181 | $templates = array(); |
| 182 | - if ( isset( $name ) ) |
|
| 182 | + if (isset($name)) |
|
| 183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
| 184 | 184 | $templates[] = $slug . '.php'; |
| 185 | 185 | |
| 186 | 186 | // Allow template parts to be filtered |
| 187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 188 | 188 | |
| 189 | 189 | // Return the part that is found |
| 190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 194 | 194 | // No file found yet |
| 195 | 195 | $located = false; |
| 196 | 196 | |
| 197 | 197 | // Try to find a template file |
| 198 | - foreach ( (array)$template_names as $template_name ) { |
|
| 198 | + foreach ((array) $template_names as $template_name) { |
|
| 199 | 199 | |
| 200 | 200 | // Continue if template is empty |
| 201 | - if ( empty( $template_name ) ) |
|
| 201 | + if (empty($template_name)) |
|
| 202 | 202 | continue; |
| 203 | 203 | |
| 204 | 204 | // Trim off any slashes from the template name |
| 205 | - $template_name = ltrim( $template_name, '/' ); |
|
| 205 | + $template_name = ltrim($template_name, '/'); |
|
| 206 | 206 | |
| 207 | 207 | // try locating this template file by looping through the template paths |
| 208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 209 | 209 | |
| 210 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 210 | + if (file_exists($template_path . $template_name)) { |
|
| 211 | 211 | $located = $template_path . $template_name; |
| 212 | 212 | break; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if( !empty( $located ) ) { |
|
| 216 | + if (!empty($located)) { |
|
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 222 | - load_template( $located, $require_once ); |
|
| 221 | + if ((true == $load) && !empty($located)) |
|
| 222 | + load_template($located, $require_once); |
|
| 223 | 223 | |
| 224 | 224 | return $located; |
| 225 | 225 | } |
@@ -228,155 +228,155 @@ discard block |
||
| 228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 229 | 229 | |
| 230 | 230 | $file_paths = array( |
| 231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 233 | 233 | 100 => wpinv_get_templates_dir() |
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 237 | 237 | |
| 238 | 238 | // sort the file paths based on priority |
| 239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 239 | + ksort($file_paths, SORT_NUMERIC); |
|
| 240 | 240 | |
| 241 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 241 | + return array_map('trailingslashit', $file_paths); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function wpinv_checkout_meta_tags() { |
| 245 | 245 | |
| 246 | 246 | $pages = array(); |
| 247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 247 | + $pages[] = wpinv_get_option('success_page'); |
|
| 248 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 251 | 251 | |
| 252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 257 | 257 | } |
| 258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 259 | 259 | |
| 260 | -function wpinv_add_body_classes( $class ) { |
|
| 261 | - $classes = (array)$class; |
|
| 260 | +function wpinv_add_body_classes($class) { |
|
| 261 | + $classes = (array) $class; |
|
| 262 | 262 | |
| 263 | - if( wpinv_is_checkout() ) { |
|
| 263 | + if (wpinv_is_checkout()) { |
|
| 264 | 264 | $classes[] = 'wpinv-checkout'; |
| 265 | 265 | $classes[] = 'wpinv-page'; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if( wpinv_is_success_page() ) { |
|
| 268 | + if (wpinv_is_success_page()) { |
|
| 269 | 269 | $classes[] = 'wpinv-success'; |
| 270 | 270 | $classes[] = 'wpinv-page'; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 273 | + if (wpinv_is_failed_transaction_page()) { |
|
| 274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
| 275 | 275 | $classes[] = 'wpinv-page'; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if( wpinv_is_invoice_history_page() ) { |
|
| 278 | + if (wpinv_is_invoice_history_page()) { |
|
| 279 | 279 | $classes[] = 'wpinv-history'; |
| 280 | 280 | $classes[] = 'wpinv-page'; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 283 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 284 | 284 | $classes[] = 'wpinv-subscription'; |
| 285 | 285 | $classes[] = 'wpinv-page'; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if( wpinv_is_test_mode() ) { |
|
| 288 | + if (wpinv_is_test_mode()) { |
|
| 289 | 289 | $classes[] = 'wpinv-test-mode'; |
| 290 | 290 | $classes[] = 'wpinv-page'; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - return array_unique( $classes ); |
|
| 293 | + return array_unique($classes); |
|
| 294 | 294 | } |
| 295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 296 | 296 | |
| 297 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 298 | - $args = array( 'nopaging' => true ); |
|
| 297 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 298 | + $args = array('nopaging' => true); |
|
| 299 | 299 | |
| 300 | - if ( ! empty( $status ) ) |
|
| 300 | + if (!empty($status)) |
|
| 301 | 301 | $args['post_status'] = $status; |
| 302 | 302 | |
| 303 | - $discounts = wpinv_get_discounts( $args ); |
|
| 303 | + $discounts = wpinv_get_discounts($args); |
|
| 304 | 304 | $options = array(); |
| 305 | 305 | |
| 306 | - if ( $discounts ) { |
|
| 307 | - foreach ( $discounts as $discount ) { |
|
| 308 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 306 | + if ($discounts) { |
|
| 307 | + foreach ($discounts as $discount) { |
|
| 308 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 309 | 309 | } |
| 310 | 310 | } else { |
| 311 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 311 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $output = wpinv_html_select( array( |
|
| 314 | + $output = wpinv_html_select(array( |
|
| 315 | 315 | 'name' => $name, |
| 316 | 316 | 'selected' => $selected, |
| 317 | 317 | 'options' => $options, |
| 318 | 318 | 'show_option_all' => false, |
| 319 | 319 | 'show_option_none' => false, |
| 320 | - ) ); |
|
| 320 | + )); |
|
| 321 | 321 | |
| 322 | 322 | return $output; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 326 | - $current = date( 'Y' ); |
|
| 327 | - $start_year = $current - absint( $years_before ); |
|
| 328 | - $end_year = $current + absint( $years_after ); |
|
| 329 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 325 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 326 | + $current = date('Y'); |
|
| 327 | + $start_year = $current - absint($years_before); |
|
| 328 | + $end_year = $current + absint($years_after); |
|
| 329 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 330 | 330 | $options = array(); |
| 331 | 331 | |
| 332 | - while ( $start_year <= $end_year ) { |
|
| 333 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 332 | + while ($start_year <= $end_year) { |
|
| 333 | + $options[absint($start_year)] = $start_year; |
|
| 334 | 334 | $start_year++; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $output = wpinv_html_select( array( |
|
| 337 | + $output = wpinv_html_select(array( |
|
| 338 | 338 | 'name' => $name, |
| 339 | 339 | 'selected' => $selected, |
| 340 | 340 | 'options' => $options, |
| 341 | 341 | 'show_option_all' => false, |
| 342 | 342 | 'show_option_none' => false |
| 343 | - ) ); |
|
| 343 | + )); |
|
| 344 | 344 | |
| 345 | 345 | return $output; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 348 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 349 | 349 | |
| 350 | 350 | $options = array( |
| 351 | - '1' => __( 'January', 'invoicing' ), |
|
| 352 | - '2' => __( 'February', 'invoicing' ), |
|
| 353 | - '3' => __( 'March', 'invoicing' ), |
|
| 354 | - '4' => __( 'April', 'invoicing' ), |
|
| 355 | - '5' => __( 'May', 'invoicing' ), |
|
| 356 | - '6' => __( 'June', 'invoicing' ), |
|
| 357 | - '7' => __( 'July', 'invoicing' ), |
|
| 358 | - '8' => __( 'August', 'invoicing' ), |
|
| 359 | - '9' => __( 'September', 'invoicing' ), |
|
| 360 | - '10' => __( 'October', 'invoicing' ), |
|
| 361 | - '11' => __( 'November', 'invoicing' ), |
|
| 362 | - '12' => __( 'December', 'invoicing' ), |
|
| 351 | + '1' => __('January', 'invoicing'), |
|
| 352 | + '2' => __('February', 'invoicing'), |
|
| 353 | + '3' => __('March', 'invoicing'), |
|
| 354 | + '4' => __('April', 'invoicing'), |
|
| 355 | + '5' => __('May', 'invoicing'), |
|
| 356 | + '6' => __('June', 'invoicing'), |
|
| 357 | + '7' => __('July', 'invoicing'), |
|
| 358 | + '8' => __('August', 'invoicing'), |
|
| 359 | + '9' => __('September', 'invoicing'), |
|
| 360 | + '10' => __('October', 'invoicing'), |
|
| 361 | + '11' => __('November', 'invoicing'), |
|
| 362 | + '12' => __('December', 'invoicing'), |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | // If no month is selected, default to the current month |
| 366 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 366 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 367 | 367 | |
| 368 | - $output = wpinv_html_select( array( |
|
| 368 | + $output = wpinv_html_select(array( |
|
| 369 | 369 | 'name' => $name, |
| 370 | 370 | 'selected' => $selected, |
| 371 | 371 | 'options' => $options, |
| 372 | 372 | 'show_option_all' => false, |
| 373 | 373 | 'show_option_none' => false |
| 374 | - ) ); |
|
| 374 | + )); |
|
| 375 | 375 | |
| 376 | 376 | return $output; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | -function wpinv_html_select( $args = array() ) { |
|
| 379 | +function wpinv_html_select($args = array()) { |
|
| 380 | 380 | $defaults = array( |
| 381 | 381 | 'options' => array(), |
| 382 | 382 | 'name' => null, |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | 'selected' => 0, |
| 386 | 386 | 'placeholder' => null, |
| 387 | 387 | 'multiple' => false, |
| 388 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 389 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 388 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 389 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 390 | 390 | 'data' => array(), |
| 391 | 391 | 'onchange' => null, |
| 392 | 392 | 'required' => false, |
@@ -394,74 +394,74 @@ discard block |
||
| 394 | 394 | 'readonly' => false, |
| 395 | 395 | ); |
| 396 | 396 | |
| 397 | - $args = wp_parse_args( $args, $defaults ); |
|
| 397 | + $args = wp_parse_args($args, $defaults); |
|
| 398 | 398 | |
| 399 | 399 | $data_elements = ''; |
| 400 | - foreach ( $args['data'] as $key => $value ) { |
|
| 401 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 400 | + foreach ($args['data'] as $key => $value) { |
|
| 401 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if( $args['multiple'] ) { |
|
| 404 | + if ($args['multiple']) { |
|
| 405 | 405 | $multiple = ' MULTIPLE'; |
| 406 | 406 | } else { |
| 407 | 407 | $multiple = ''; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - if( $args['placeholder'] ) { |
|
| 410 | + if ($args['placeholder']) { |
|
| 411 | 411 | $placeholder = $args['placeholder']; |
| 412 | 412 | } else { |
| 413 | 413 | $placeholder = ''; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $options = ''; |
| 417 | - if( !empty( $args['onchange'] ) ) { |
|
| 418 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 417 | + if (!empty($args['onchange'])) { |
|
| 418 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - if( !empty( $args['required'] ) ) { |
|
| 421 | + if (!empty($args['required'])) { |
|
| 422 | 422 | $options .= ' required="required"'; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if( !empty( $args['disabled'] ) ) { |
|
| 425 | + if (!empty($args['disabled'])) { |
|
| 426 | 426 | $options .= ' disabled'; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if( !empty( $args['readonly'] ) ) { |
|
| 429 | + if (!empty($args['readonly'])) { |
|
| 430 | 430 | $options .= ' readonly'; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 434 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 433 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 434 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 435 | 435 | |
| 436 | - if ( $args['show_option_all'] ) { |
|
| 437 | - if( $args['multiple'] ) { |
|
| 438 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 436 | + if ($args['show_option_all']) { |
|
| 437 | + if ($args['multiple']) { |
|
| 438 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 439 | 439 | } else { |
| 440 | - $selected = selected( $args['selected'], 0, false ); |
|
| 440 | + $selected = selected($args['selected'], 0, false); |
|
| 441 | 441 | } |
| 442 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 442 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if ( !empty( $args['options'] ) ) { |
|
| 445 | + if (!empty($args['options'])) { |
|
| 446 | 446 | |
| 447 | - if ( $args['show_option_none'] ) { |
|
| 448 | - if( $args['multiple'] ) { |
|
| 449 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 447 | + if ($args['show_option_none']) { |
|
| 448 | + if ($args['multiple']) { |
|
| 449 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 450 | 450 | } else { |
| 451 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 451 | + $selected = selected($args['selected'] === "", true, false); |
|
| 452 | 452 | } |
| 453 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 453 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - foreach( $args['options'] as $key => $option ) { |
|
| 456 | + foreach ($args['options'] as $key => $option) { |
|
| 457 | 457 | |
| 458 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 459 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 458 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 459 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
| 460 | 460 | } else { |
| 461 | - $selected = selected( $args['selected'], $key, false ); |
|
| 461 | + $selected = selected($args['selected'], $key, false); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 464 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | return $output; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 473 | +function wpinv_item_dropdown($args = array()) { |
|
| 474 | 474 | $defaults = array( |
| 475 | 475 | 'name' => 'wpi_item', |
| 476 | 476 | 'id' => 'wpi_item', |
@@ -478,14 +478,14 @@ discard block |
||
| 478 | 478 | 'multiple' => false, |
| 479 | 479 | 'selected' => 0, |
| 480 | 480 | 'number' => 100, |
| 481 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 482 | - 'data' => array( 'search-type' => 'item' ), |
|
| 481 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 482 | + 'data' => array('search-type' => 'item'), |
|
| 483 | 483 | 'show_option_all' => false, |
| 484 | 484 | 'show_option_none' => false, |
| 485 | 485 | 'show_recurring' => false, |
| 486 | 486 | ); |
| 487 | 487 | |
| 488 | - $args = wp_parse_args( $args, $defaults ); |
|
| 488 | + $args = wp_parse_args($args, $defaults); |
|
| 489 | 489 | |
| 490 | 490 | $item_args = array( |
| 491 | 491 | 'post_type' => 'wpi_item', |
@@ -494,44 +494,44 @@ discard block |
||
| 494 | 494 | 'posts_per_page' => $args['number'] |
| 495 | 495 | ); |
| 496 | 496 | |
| 497 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 497 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 498 | 498 | |
| 499 | - $items = get_posts( $item_args ); |
|
| 499 | + $items = get_posts($item_args); |
|
| 500 | 500 | $options = array(); |
| 501 | - if ( $items ) { |
|
| 502 | - foreach ( $items as $item ) { |
|
| 503 | - $title = esc_html( $item->post_title ); |
|
| 501 | + if ($items) { |
|
| 502 | + foreach ($items as $item) { |
|
| 503 | + $title = esc_html($item->post_title); |
|
| 504 | 504 | |
| 505 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 506 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 505 | + if (!empty($args['show_recurring'])) { |
|
| 506 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - $options[ absint( $item->ID ) ] = $title; |
|
| 509 | + $options[absint($item->ID)] = $title; |
|
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | // This ensures that any selected items are included in the drop down |
| 514 | - if( is_array( $args['selected'] ) ) { |
|
| 515 | - foreach( $args['selected'] as $item ) { |
|
| 516 | - if( ! in_array( $item, $options ) ) { |
|
| 517 | - $title = get_the_title( $item ); |
|
| 518 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 519 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 514 | + if (is_array($args['selected'])) { |
|
| 515 | + foreach ($args['selected'] as $item) { |
|
| 516 | + if (!in_array($item, $options)) { |
|
| 517 | + $title = get_the_title($item); |
|
| 518 | + if (!empty($args['show_recurring'])) { |
|
| 519 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 520 | 520 | } |
| 521 | 521 | $options[$item] = $title; |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 525 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 526 | - $title = get_the_title( $args['selected'] ); |
|
| 527 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 528 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 524 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 525 | + if (!in_array($args['selected'], $options)) { |
|
| 526 | + $title = get_the_title($args['selected']); |
|
| 527 | + if (!empty($args['show_recurring'])) { |
|
| 528 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 529 | 529 | } |
| 530 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 530 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - $output = wpinv_html_select( array( |
|
| 534 | + $output = wpinv_html_select(array( |
|
| 535 | 535 | 'name' => $args['name'], |
| 536 | 536 | 'selected' => $args['selected'], |
| 537 | 537 | 'id' => $args['id'], |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | 'show_option_all' => $args['show_option_all'], |
| 543 | 543 | 'show_option_none' => $args['show_option_none'], |
| 544 | 544 | 'data' => $args['data'], |
| 545 | - ) ); |
|
| 545 | + )); |
|
| 546 | 546 | |
| 547 | 547 | return $output; |
| 548 | 548 | } |
@@ -562,16 +562,16 @@ discard block |
||
| 562 | 562 | ); |
| 563 | 563 | |
| 564 | 564 | $options = array(); |
| 565 | - if ( $items ) { |
|
| 566 | - foreach ( $items as $item ) { |
|
| 567 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
| 565 | + if ($items) { |
|
| 566 | + foreach ($items as $item) { |
|
| 567 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | return $options; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 574 | +function wpinv_html_checkbox($args = array()) { |
|
| 575 | 575 | $defaults = array( |
| 576 | 576 | 'name' => null, |
| 577 | 577 | 'current' => null, |
@@ -582,17 +582,17 @@ discard block |
||
| 582 | 582 | ) |
| 583 | 583 | ); |
| 584 | 584 | |
| 585 | - $args = wp_parse_args( $args, $defaults ); |
|
| 585 | + $args = wp_parse_args($args, $defaults); |
|
| 586 | 586 | |
| 587 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 587 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 588 | 588 | $options = ''; |
| 589 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 589 | + if (!empty($args['options']['disabled'])) { |
|
| 590 | 590 | $options .= ' disabled="disabled"'; |
| 591 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 591 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 592 | 592 | $options .= ' readonly'; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 595 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 596 | 596 | |
| 597 | 597 | return $output; |
| 598 | 598 | } |
@@ -600,30 +600,30 @@ discard block |
||
| 600 | 600 | /** |
| 601 | 601 | * Displays a hidden field. |
| 602 | 602 | */ |
| 603 | -function getpaid_hidden_field( $name, $value ) { |
|
| 604 | - $name = sanitize_text_field( $name ); |
|
| 605 | - $value = esc_attr( $value ); |
|
| 603 | +function getpaid_hidden_field($name, $value) { |
|
| 604 | + $name = sanitize_text_field($name); |
|
| 605 | + $value = esc_attr($value); |
|
| 606 | 606 | |
| 607 | 607 | echo "<input type='hidden' name='$name' value='$value' />"; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | -function wpinv_html_text( $args = array() ) { |
|
| 610 | +function wpinv_html_text($args = array()) { |
|
| 611 | 611 | // Backwards compatibility |
| 612 | - if ( func_num_args() > 1 ) { |
|
| 612 | + if (func_num_args() > 1) { |
|
| 613 | 613 | $args = func_get_args(); |
| 614 | 614 | |
| 615 | 615 | $name = $args[0]; |
| 616 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 617 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 618 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 616 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 617 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 618 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | $defaults = array( |
| 622 | 622 | 'id' => '', |
| 623 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 624 | - 'value' => isset( $value ) ? $value : null, |
|
| 625 | - 'label' => isset( $label ) ? $label : null, |
|
| 626 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 623 | + 'name' => isset($name) ? $name : 'text', |
|
| 624 | + 'value' => isset($value) ? $value : null, |
|
| 625 | + 'label' => isset($label) ? $label : null, |
|
| 626 | + 'desc' => isset($desc) ? $desc : null, |
|
| 627 | 627 | 'placeholder' => '', |
| 628 | 628 | 'class' => 'regular-text', |
| 629 | 629 | 'disabled' => false, |
@@ -633,51 +633,51 @@ discard block |
||
| 633 | 633 | 'data' => false |
| 634 | 634 | ); |
| 635 | 635 | |
| 636 | - $args = wp_parse_args( $args, $defaults ); |
|
| 636 | + $args = wp_parse_args($args, $defaults); |
|
| 637 | 637 | |
| 638 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 638 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 639 | 639 | $options = ''; |
| 640 | - if( $args['required'] ) { |
|
| 640 | + if ($args['required']) { |
|
| 641 | 641 | $options .= ' required="required"'; |
| 642 | 642 | } |
| 643 | - if( $args['readonly'] ) { |
|
| 643 | + if ($args['readonly']) { |
|
| 644 | 644 | $options .= ' readonly'; |
| 645 | 645 | } |
| 646 | - if( $args['readonly'] ) { |
|
| 646 | + if ($args['readonly']) { |
|
| 647 | 647 | $options .= ' readonly'; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | $data = ''; |
| 651 | - if ( !empty( $args['data'] ) ) { |
|
| 652 | - foreach ( $args['data'] as $key => $value ) { |
|
| 653 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 651 | + if (!empty($args['data'])) { |
|
| 652 | + foreach ($args['data'] as $key => $value) { |
|
| 653 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 658 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 659 | - if ( ! empty( $args['desc'] ) ) { |
|
| 660 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 657 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 658 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 659 | + if (!empty($args['desc'])) { |
|
| 660 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 663 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 664 | 664 | |
| 665 | 665 | $output .= '</span>'; |
| 666 | 666 | |
| 667 | 667 | return $output; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | -function wpinv_html_date_field( $args = array() ) { |
|
| 671 | - if( empty( $args['class'] ) ) { |
|
| 670 | +function wpinv_html_date_field($args = array()) { |
|
| 671 | + if (empty($args['class'])) { |
|
| 672 | 672 | $args['class'] = 'wpiDatepicker'; |
| 673 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 673 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 674 | 674 | $args['class'] .= ' wpiDatepicker'; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - return wpinv_html_text( $args ); |
|
| 677 | + return wpinv_html_text($args); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | -function wpinv_html_textarea( $args = array() ) { |
|
| 680 | +function wpinv_html_textarea($args = array()) { |
|
| 681 | 681 | $defaults = array( |
| 682 | 682 | 'name' => 'textarea', |
| 683 | 683 | 'value' => null, |
@@ -688,31 +688,31 @@ discard block |
||
| 688 | 688 | 'placeholder' => '', |
| 689 | 689 | ); |
| 690 | 690 | |
| 691 | - $args = wp_parse_args( $args, $defaults ); |
|
| 691 | + $args = wp_parse_args($args, $defaults); |
|
| 692 | 692 | |
| 693 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 693 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 694 | 694 | $disabled = ''; |
| 695 | - if( $args['disabled'] ) { |
|
| 695 | + if ($args['disabled']) { |
|
| 696 | 696 | $disabled = ' disabled="disabled"'; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 700 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 701 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 699 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 700 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 701 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 702 | 702 | |
| 703 | - if ( ! empty( $args['desc'] ) ) { |
|
| 704 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 703 | + if (!empty($args['desc'])) { |
|
| 704 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 705 | 705 | } |
| 706 | 706 | $output .= '</span>'; |
| 707 | 707 | |
| 708 | 708 | return $output; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 711 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 712 | 712 | $defaults = array( |
| 713 | 713 | 'name' => 'user_id', |
| 714 | 714 | 'value' => null, |
| 715 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 715 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 716 | 716 | 'label' => null, |
| 717 | 717 | 'desc' => null, |
| 718 | 718 | 'class' => '', |
@@ -721,13 +721,13 @@ discard block |
||
| 721 | 721 | 'data' => false |
| 722 | 722 | ); |
| 723 | 723 | |
| 724 | - $args = wp_parse_args( $args, $defaults ); |
|
| 724 | + $args = wp_parse_args($args, $defaults); |
|
| 725 | 725 | |
| 726 | 726 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 727 | 727 | |
| 728 | 728 | $output = '<span class="wpinv_user_search_wrap">'; |
| 729 | - $output .= wpinv_html_text( $args ); |
|
| 730 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 729 | + $output .= wpinv_html_text($args); |
|
| 730 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 731 | 731 | $output .= '</span>'; |
| 732 | 732 | |
| 733 | 733 | return $output; |
@@ -743,20 +743,20 @@ discard block |
||
| 743 | 743 | * |
| 744 | 744 | * @param string $template the template that is currently being used. |
| 745 | 745 | */ |
| 746 | -function wpinv_template( $template ) { |
|
| 746 | +function wpinv_template($template) { |
|
| 747 | 747 | global $post; |
| 748 | 748 | |
| 749 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
| 749 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
| 750 | 750 | |
| 751 | 751 | // If the user can view this invoice, display it. |
| 752 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 752 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 753 | 753 | |
| 754 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 754 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 755 | 755 | |
| 756 | 756 | // Else display an error message. |
| 757 | 757 | } else { |
| 758 | 758 | |
| 759 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 759 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 760 | 760 | |
| 761 | 761 | } |
| 762 | 762 | |
@@ -764,46 +764,46 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | return $template; |
| 766 | 766 | } |
| 767 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 767 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 768 | 768 | |
| 769 | 769 | function wpinv_get_business_address() { |
| 770 | 770 | $business_address = wpinv_store_address(); |
| 771 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 771 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 772 | 772 | |
| 773 | 773 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 774 | 774 | |
| 775 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 775 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
| 779 | 779 | * Displays the company address. |
| 780 | 780 | */ |
| 781 | 781 | function wpinv_display_from_address() { |
| 782 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
| 782 | + wpinv_get_template('invoice/company-address.php'); |
|
| 783 | 783 | } |
| 784 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
| 784 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
| 785 | 785 | |
| 786 | -function wpinv_watermark( $id = 0 ) { |
|
| 787 | - $output = wpinv_get_watermark( $id ); |
|
| 788 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 786 | +function wpinv_watermark($id = 0) { |
|
| 787 | + $output = wpinv_get_watermark($id); |
|
| 788 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | -function wpinv_get_watermark( $id ) { |
|
| 792 | - if ( !$id > 0 ) { |
|
| 791 | +function wpinv_get_watermark($id) { |
|
| 792 | + if (!$id > 0) { |
|
| 793 | 793 | return NULL; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - $invoice = wpinv_get_invoice( $id ); |
|
| 796 | + $invoice = wpinv_get_invoice($id); |
|
| 797 | 797 | |
| 798 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 799 | - if ( $invoice->is_paid() ) { |
|
| 800 | - return __( 'Paid', 'invoicing' ); |
|
| 798 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 799 | + if ($invoice->is_paid()) { |
|
| 800 | + return __('Paid', 'invoicing'); |
|
| 801 | 801 | } |
| 802 | - if ( $invoice->is_refunded() ) { |
|
| 803 | - return __( 'Refunded', 'invoicing' ); |
|
| 802 | + if ($invoice->is_refunded()) { |
|
| 803 | + return __('Refunded', 'invoicing'); |
|
| 804 | 804 | } |
| 805 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 806 | - return __( 'Cancelled', 'invoicing' ); |
|
| 805 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 806 | + return __('Cancelled', 'invoicing'); |
|
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | |
@@ -813,140 +813,140 @@ discard block |
||
| 813 | 813 | /** |
| 814 | 814 | * @deprecated |
| 815 | 815 | */ |
| 816 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 817 | - return getpaid_invoice_meta( $invoice ); |
|
| 816 | +function wpinv_display_invoice_details($invoice) { |
|
| 817 | + return getpaid_invoice_meta($invoice); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
| 821 | 821 | * Displays invoice meta. |
| 822 | 822 | */ |
| 823 | -function getpaid_invoice_meta( $invoice ) { |
|
| 823 | +function getpaid_invoice_meta($invoice) { |
|
| 824 | 824 | |
| 825 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 825 | + $invoice = new WPInv_Invoice($invoice); |
|
| 826 | 826 | |
| 827 | 827 | // Ensure that we have an invoice. |
| 828 | - if ( 0 == $invoice->get_id() ) { |
|
| 828 | + if (0 == $invoice->get_id()) { |
|
| 829 | 829 | return; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | // Load the invoice meta. |
| 833 | - $meta = array( |
|
| 833 | + $meta = array( |
|
| 834 | 834 | |
| 835 | 835 | 'number' => array( |
| 836 | 836 | 'label' => sprintf( |
| 837 | - __( '%s Number', 'invoicing' ), |
|
| 838 | - ucfirst( $invoice->get_type() ) |
|
| 837 | + __('%s Number', 'invoicing'), |
|
| 838 | + ucfirst($invoice->get_type()) |
|
| 839 | 839 | ), |
| 840 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
| 840 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
| 841 | 841 | ), |
| 842 | 842 | |
| 843 | 843 | 'status' => array( |
| 844 | 844 | 'label' => sprintf( |
| 845 | - __( '%s Status', 'invoicing' ), |
|
| 846 | - ucfirst( $invoice->get_type() ) |
|
| 845 | + __('%s Status', 'invoicing'), |
|
| 846 | + ucfirst($invoice->get_type()) |
|
| 847 | 847 | ), |
| 848 | 848 | 'value' => $invoice->get_status_label_html(), |
| 849 | 849 | ), |
| 850 | 850 | |
| 851 | 851 | 'date' => array( |
| 852 | 852 | 'label' => sprintf( |
| 853 | - __( '%s Date', 'invoicing' ), |
|
| 854 | - ucfirst( $invoice->get_type() ) |
|
| 853 | + __('%s Date', 'invoicing'), |
|
| 854 | + ucfirst($invoice->get_type()) |
|
| 855 | 855 | ), |
| 856 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
| 856 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
| 857 | 857 | ), |
| 858 | 858 | |
| 859 | 859 | 'date_paid' => array( |
| 860 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
| 861 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
| 860 | + 'label' => __('Paid On', 'invoicing'), |
|
| 861 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
| 862 | 862 | ), |
| 863 | 863 | |
| 864 | 864 | 'gateway' => array( |
| 865 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
| 866 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
| 865 | + 'label' => __('Payment Method', 'invoicing'), |
|
| 866 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
| 867 | 867 | ), |
| 868 | 868 | |
| 869 | 869 | 'transaction_id' => array( |
| 870 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
| 871 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
| 870 | + 'label' => __('Transaction ID', 'invoicing'), |
|
| 871 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
| 872 | 872 | ), |
| 873 | 873 | |
| 874 | 874 | 'due_date' => array( |
| 875 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
| 876 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
| 875 | + 'label' => __('Due Date', 'invoicing'), |
|
| 876 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
| 877 | 877 | ), |
| 878 | 878 | |
| 879 | 879 | 'vat_number' => array( |
| 880 | 880 | 'label' => sprintf( |
| 881 | - __( '%s Number', 'invoicing' ), |
|
| 881 | + __('%s Number', 'invoicing'), |
|
| 882 | 882 | getpaid_tax()->get_vat_name() |
| 883 | 883 | ), |
| 884 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
| 884 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
| 885 | 885 | ), |
| 886 | 886 | |
| 887 | 887 | ); |
| 888 | 888 | |
| 889 | 889 | // If it is not paid, remove the date of payment. |
| 890 | - if ( ! $invoice->is_paid() ) { |
|
| 891 | - unset( $meta[ 'date_paid' ] ); |
|
| 892 | - unset( $meta[ 'transaction_id' ] ); |
|
| 890 | + if (!$invoice->is_paid()) { |
|
| 891 | + unset($meta['date_paid']); |
|
| 892 | + unset($meta['transaction_id']); |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
| 896 | - unset( $meta[ 'gateway' ] ); |
|
| 895 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
| 896 | + unset($meta['gateway']); |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | // Only display the due date if due dates are enabled. |
| 900 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
| 901 | - unset( $meta[ 'due_date' ] ); |
|
| 900 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
| 901 | + unset($meta['due_date']); |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | // Only display the vat number if taxes are enabled. |
| 905 | - if ( ! wpinv_use_taxes() ) { |
|
| 906 | - unset( $meta[ 'vat_number' ] ); |
|
| 905 | + if (!wpinv_use_taxes()) { |
|
| 906 | + unset($meta['vat_number']); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - if ( $invoice->is_recurring() ) { |
|
| 909 | + if ($invoice->is_recurring()) { |
|
| 910 | 910 | |
| 911 | 911 | // Link to the parent invoice. |
| 912 | - if ( $invoice->is_renewal() ) { |
|
| 912 | + if ($invoice->is_renewal()) { |
|
| 913 | 913 | |
| 914 | - $meta[ 'parent' ] = array( |
|
| 914 | + $meta['parent'] = array( |
|
| 915 | 915 | |
| 916 | 916 | 'label' => sprintf( |
| 917 | - __( 'Parent %s', 'invoicing' ), |
|
| 918 | - ucfirst( $invoice->get_type() ) |
|
| 917 | + __('Parent %s', 'invoicing'), |
|
| 918 | + ucfirst($invoice->get_type()) |
|
| 919 | 919 | ), |
| 920 | 920 | |
| 921 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
| 921 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
| 922 | 922 | |
| 923 | 923 | ); |
| 924 | 924 | |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - $subscription = wpinv_get_subscription( $invoice ); |
|
| 927 | + $subscription = wpinv_get_subscription($invoice); |
|
| 928 | 928 | |
| 929 | - if ( ! empty ( $subscription ) ) { |
|
| 929 | + if (!empty ($subscription)) { |
|
| 930 | 930 | |
| 931 | 931 | // Display the renewal date. |
| 932 | - if ( $subscription->is_active() && 'cancelled' != $subscription->status ) { |
|
| 932 | + if ($subscription->is_active() && 'cancelled' != $subscription->status) { |
|
| 933 | 933 | |
| 934 | - $meta[ 'renewal_date' ] = array( |
|
| 934 | + $meta['renewal_date'] = array( |
|
| 935 | 935 | |
| 936 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 937 | - 'value' => getpaid_format_date( $subscription->expiration ), |
|
| 936 | + 'label' => __('Renews On', 'invoicing'), |
|
| 937 | + 'value' => getpaid_format_date($subscription->expiration), |
|
| 938 | 938 | |
| 939 | 939 | ); |
| 940 | 940 | |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - if ( $invoice->is_parent() ) { |
|
| 943 | + if ($invoice->is_parent()) { |
|
| 944 | 944 | |
| 945 | 945 | // Display the recurring amount. |
| 946 | - $meta[ 'recurring_total' ] = array( |
|
| 946 | + $meta['recurring_total'] = array( |
|
| 947 | 947 | |
| 948 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
| 949 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ), |
|
| 948 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
| 949 | + 'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()), |
|
| 950 | 950 | |
| 951 | 951 | ); |
| 952 | 952 | |
@@ -956,20 +956,20 @@ discard block |
||
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | // Add the invoice total to the meta. |
| 959 | - $meta[ 'invoice_total' ] = array( |
|
| 959 | + $meta['invoice_total'] = array( |
|
| 960 | 960 | |
| 961 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
| 962 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
| 961 | + 'label' => __('Total Amount', 'invoicing'), |
|
| 962 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
| 963 | 963 | |
| 964 | 964 | ); |
| 965 | 965 | |
| 966 | 966 | // Provide a way for third party plugins to filter the meta. |
| 967 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
| 967 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
| 968 | 968 | |
| 969 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
| 969 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
| 970 | 970 | |
| 971 | 971 | } |
| 972 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
| 972 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
| 973 | 973 | |
| 974 | 974 | /** |
| 975 | 975 | * Retrieves the address markup to use on Invoices. |
@@ -981,29 +981,29 @@ discard block |
||
| 981 | 981 | * @param string $separator How to separate address lines. |
| 982 | 982 | * @return string |
| 983 | 983 | */ |
| 984 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 984 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 985 | 985 | |
| 986 | 986 | // Retrieve the address markup... |
| 987 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 988 | - $format = wpinv_get_full_address_format( $country ); |
|
| 987 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 988 | + $format = wpinv_get_full_address_format($country); |
|
| 989 | 989 | |
| 990 | 990 | // ... and the replacements. |
| 991 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 991 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 992 | 992 | |
| 993 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 993 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 994 | 994 | |
| 995 | 995 | // Remove unavailable tags. |
| 996 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
| 996 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
| 997 | 997 | |
| 998 | 998 | // Clean up white space. |
| 999 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 1000 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 999 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 1000 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 1001 | 1001 | |
| 1002 | 1002 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 1003 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 1003 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 1004 | 1004 | |
| 1005 | 1005 | // Add html breaks. |
| 1006 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 1006 | + $formatted_address = implode($separator, $formatted_address); |
|
| 1007 | 1007 | |
| 1008 | 1008 | // We're done! |
| 1009 | 1009 | return $formatted_address; |
@@ -1015,88 +1015,88 @@ discard block |
||
| 1015 | 1015 | * |
| 1016 | 1016 | * @param WPInv_Invoice $invoice |
| 1017 | 1017 | */ |
| 1018 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
| 1019 | - if ( ! empty( $invoice ) ) { |
|
| 1020 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
| 1018 | +function wpinv_display_to_address($invoice = 0) { |
|
| 1019 | + if (!empty($invoice)) { |
|
| 1020 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
| 1021 | 1021 | } |
| 1022 | 1022 | } |
| 1023 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
| 1023 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
| 1024 | 1024 | |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
| 1027 | 1027 | * Displays invoice line items. |
| 1028 | 1028 | */ |
| 1029 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 1029 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 1030 | 1030 | |
| 1031 | 1031 | // Prepare the invoice. |
| 1032 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1032 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1033 | 1033 | |
| 1034 | 1034 | // Abort if there is no invoice. |
| 1035 | - if ( 0 == $invoice->get_id() ) { |
|
| 1035 | + if (0 == $invoice->get_id()) { |
|
| 1036 | 1036 | return; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | // Line item columns. |
| 1040 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
| 1041 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
| 1040 | + $columns = getpaid_invoice_item_columns($invoice); |
|
| 1041 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
| 1042 | 1042 | |
| 1043 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
| 1043 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
| 1044 | 1044 | } |
| 1045 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
| 1045 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
| 1046 | 1046 | |
| 1047 | 1047 | /** |
| 1048 | 1048 | * Displays invoice notices on invoices. |
| 1049 | 1049 | */ |
| 1050 | 1050 | function wpinv_display_invoice_notice() { |
| 1051 | 1051 | |
| 1052 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
| 1053 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
| 1052 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
| 1053 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
| 1054 | 1054 | |
| 1055 | - if ( empty( $label ) && empty( $notice ) ) { |
|
| 1055 | + if (empty($label) && empty($notice)) { |
|
| 1056 | 1056 | return; |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
| 1060 | 1060 | |
| 1061 | - if ( ! empty( $label ) ) { |
|
| 1062 | - $label = sanitize_text_field( $label ); |
|
| 1061 | + if (!empty($label)) { |
|
| 1062 | + $label = sanitize_text_field($label); |
|
| 1063 | 1063 | echo "<h5>$label</h5>"; |
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | - if ( ! empty( $notice ) ) { |
|
| 1067 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
| 1066 | + if (!empty($notice)) { |
|
| 1067 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | echo '</div>'; |
| 1071 | 1071 | } |
| 1072 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
| 1072 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
| 1073 | 1073 | |
| 1074 | 1074 | /** |
| 1075 | 1075 | * @param WPInv_Invoice $invoice |
| 1076 | 1076 | */ |
| 1077 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 1077 | +function wpinv_display_invoice_notes($invoice) { |
|
| 1078 | 1078 | |
| 1079 | 1079 | // Retrieve the notes. |
| 1080 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
| 1080 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
| 1081 | 1081 | |
| 1082 | 1082 | // Abort if we have non. |
| 1083 | - if ( empty( $notes ) ) { |
|
| 1083 | + if (empty($notes)) { |
|
| 1084 | 1084 | return; |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | // Echo the note. |
| 1088 | 1088 | echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">'; |
| 1089 | - echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>'; |
|
| 1089 | + echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>'; |
|
| 1090 | 1090 | echo '<ul class="getpaid-invoice-notes mt-4 p-0">'; |
| 1091 | 1091 | |
| 1092 | - foreach( $notes as $note ) { |
|
| 1093 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 1092 | + foreach ($notes as $note) { |
|
| 1093 | + wpinv_get_invoice_note_line_item($note); |
|
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | 1096 | echo '</ul>'; |
| 1097 | 1097 | echo '</div>'; |
| 1098 | 1098 | } |
| 1099 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
| 1099 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
| 1100 | 1100 | |
| 1101 | 1101 | /** |
| 1102 | 1102 | * Loads scripts on our invoice templates. |
@@ -1104,32 +1104,32 @@ discard block |
||
| 1104 | 1104 | function wpinv_display_style() { |
| 1105 | 1105 | |
| 1106 | 1106 | // Make sure that all scripts have been loaded. |
| 1107 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
| 1108 | - do_action( 'wp_enqueue_scripts' ); |
|
| 1107 | + if (!did_action('wp_enqueue_scripts')) { |
|
| 1108 | + do_action('wp_enqueue_scripts'); |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | // Register the invoices style. |
| 1112 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
| 1112 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
| 1113 | 1113 | |
| 1114 | 1114 | // Load required styles |
| 1115 | - wp_print_styles( 'open-sans' ); |
|
| 1116 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 1117 | - wp_print_styles( 'ayecode-ui' ); |
|
| 1115 | + wp_print_styles('open-sans'); |
|
| 1116 | + wp_print_styles('wpinv-single-style'); |
|
| 1117 | + wp_print_styles('ayecode-ui'); |
|
| 1118 | 1118 | |
| 1119 | 1119 | // Maybe load custom css. |
| 1120 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
| 1120 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
| 1121 | 1121 | |
| 1122 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
| 1123 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 1124 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 1122 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 1123 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 1124 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 1125 | 1125 | echo '<style type="text/css">'; |
| 1126 | 1126 | echo $custom_css; |
| 1127 | 1127 | echo '</style>'; |
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | 1130 | } |
| 1131 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 1132 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 1131 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 1132 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 1133 | 1133 | |
| 1134 | 1134 | |
| 1135 | 1135 | /** |
@@ -1141,41 +1141,41 @@ discard block |
||
| 1141 | 1141 | // Retrieve the current invoice. |
| 1142 | 1142 | $invoice_id = getpaid_get_current_invoice_id(); |
| 1143 | 1143 | |
| 1144 | - if ( empty( $invoice_id ) ) { |
|
| 1144 | + if (empty($invoice_id)) { |
|
| 1145 | 1145 | |
| 1146 | 1146 | return aui()->alert( |
| 1147 | 1147 | array( |
| 1148 | 1148 | 'type' => 'warning', |
| 1149 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
| 1149 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
| 1150 | 1150 | ) |
| 1151 | 1151 | ); |
| 1152 | 1152 | |
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | // Can the user view this invoice? |
| 1156 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
| 1156 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
| 1157 | 1157 | |
| 1158 | 1158 | return aui()->alert( |
| 1159 | 1159 | array( |
| 1160 | 1160 | 'type' => 'warning', |
| 1161 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
| 1161 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
| 1162 | 1162 | ) |
| 1163 | 1163 | ); |
| 1164 | 1164 | |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | // Ensure that it is not yet paid for. |
| 1168 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1168 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1169 | 1169 | |
| 1170 | 1170 | // Maybe mark it as viewed. |
| 1171 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
| 1171 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
| 1172 | 1172 | |
| 1173 | - if ( $invoice->is_paid() ) { |
|
| 1173 | + if ($invoice->is_paid()) { |
|
| 1174 | 1174 | |
| 1175 | 1175 | return aui()->alert( |
| 1176 | 1176 | array( |
| 1177 | 1177 | 'type' => 'success', |
| 1178 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
| 1178 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
| 1179 | 1179 | ) |
| 1180 | 1180 | ); |
| 1181 | 1181 | |
@@ -1185,14 +1185,14 @@ discard block |
||
| 1185 | 1185 | $wpi_checkout_id = $invoice_id; |
| 1186 | 1186 | |
| 1187 | 1187 | // We'll display this invoice via the default form. |
| 1188 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1188 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1189 | 1189 | |
| 1190 | - if ( 0 == $form->get_id() ) { |
|
| 1190 | + if (0 == $form->get_id()) { |
|
| 1191 | 1191 | |
| 1192 | 1192 | return aui()->alert( |
| 1193 | 1193 | array( |
| 1194 | 1194 | 'type' => 'warning', |
| 1195 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
| 1195 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
| 1196 | 1196 | ) |
| 1197 | 1197 | ); |
| 1198 | 1198 | |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | |
| 1201 | 1201 | // Set the invoice. |
| 1202 | 1202 | $form->invoice = $invoice; |
| 1203 | - $form->set_items( $invoice->get_items() ); |
|
| 1203 | + $form->set_items($invoice->get_items()); |
|
| 1204 | 1204 | |
| 1205 | 1205 | // Generate the html. |
| 1206 | 1206 | return $form->get_html(); |
@@ -1208,7 +1208,7 @@ discard block |
||
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | function wpinv_empty_cart_message() { |
| 1211 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1211 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | /** |
@@ -1225,38 +1225,38 @@ discard block |
||
| 1225 | 1225 | ) |
| 1226 | 1226 | ); |
| 1227 | 1227 | } |
| 1228 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1228 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1229 | 1229 | |
| 1230 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1231 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1230 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1231 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1232 | 1232 | |
| 1233 | - if ( empty( $invoice ) ) { |
|
| 1233 | + if (empty($invoice)) { |
|
| 1234 | 1234 | return NULL; |
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | $billing_details = $invoice->get_user_info(); |
| 1238 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 1238 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 1239 | 1239 | |
| 1240 | 1240 | ob_start(); |
| 1241 | 1241 | ?> |
| 1242 | 1242 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1243 | 1243 | <tbody> |
| 1244 | 1244 | <tr class="wpi-receipt-name"> |
| 1245 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1246 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1245 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1246 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1247 | 1247 | </tr> |
| 1248 | 1248 | <tr class="wpi-receipt-email"> |
| 1249 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1250 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1249 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1250 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1251 | 1251 | </tr> |
| 1252 | 1252 | <tr class="wpi-receipt-address"> |
| 1253 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1254 | - <td><?php echo $address_row ;?></td> |
|
| 1253 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1254 | + <td><?php echo $address_row; ?></td> |
|
| 1255 | 1255 | </tr> |
| 1256 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1256 | + <?php if ($billing_details['phone']) { ?> |
|
| 1257 | 1257 | <tr class="wpi-receipt-phone"> |
| 1258 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1259 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1258 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1259 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1260 | 1260 | </tr> |
| 1261 | 1261 | <?php } ?> |
| 1262 | 1262 | </tbody> |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | <?php |
| 1265 | 1265 | $output = ob_get_clean(); |
| 1266 | 1266 | |
| 1267 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1267 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1268 | 1268 | |
| 1269 | 1269 | echo $output; |
| 1270 | 1270 | } |
@@ -1272,88 +1272,88 @@ discard block |
||
| 1272 | 1272 | /** |
| 1273 | 1273 | * Filters the receipt page. |
| 1274 | 1274 | */ |
| 1275 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1275 | +function wpinv_filter_success_page_content($content) { |
|
| 1276 | 1276 | |
| 1277 | 1277 | // Ensure this is our page. |
| 1278 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1278 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1279 | 1279 | |
| 1280 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
| 1281 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
| 1280 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
| 1281 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
| 1282 | 1282 | |
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | 1285 | return $content; |
| 1286 | 1286 | } |
| 1287 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1287 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1288 | 1288 | |
| 1289 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1289 | +function wpinv_invoice_link($invoice_id) { |
|
| 1290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1291 | 1291 | |
| 1292 | - if ( empty( $invoice ) ) { |
|
| 1292 | + if (empty($invoice)) { |
|
| 1293 | 1293 | return NULL; |
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1296 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1297 | 1297 | |
| 1298 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1298 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
| 1302 | - if ( empty( $invoice ) ) { |
|
| 1301 | +function wpinv_cart_total_label($label, $invoice) { |
|
| 1302 | + if (empty($invoice)) { |
|
| 1303 | 1303 | return $label; |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | $prefix_label = ''; |
| 1307 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
| 1308 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
| 1309 | - } else if ( $invoice->is_renewal() ) { |
|
| 1310 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
| 1307 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
| 1308 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
| 1309 | + } else if ($invoice->is_renewal()) { |
|
| 1310 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | - if ( $prefix_label != '' ) { |
|
| 1314 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 1313 | + if ($prefix_label != '') { |
|
| 1314 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | return $label; |
| 1318 | 1318 | } |
| 1319 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 1320 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 1321 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 1319 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 1320 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 1321 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 1322 | 1322 | |
| 1323 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 1324 | - if ( empty( $note ) ) { |
|
| 1323 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 1324 | + if (empty($note)) { |
|
| 1325 | 1325 | return NULL; |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | - if ( is_int( $note ) ) { |
|
| 1329 | - $note = get_comment( $note ); |
|
| 1328 | + if (is_int($note)) { |
|
| 1329 | + $note = get_comment($note); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 1332 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 1333 | 1333 | return NULL; |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | - $note_classes = array( 'note' ); |
|
| 1337 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 1336 | + $note_classes = array('note'); |
|
| 1337 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 1338 | 1338 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 1339 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 1340 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 1339 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 1340 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 1341 | 1341 | |
| 1342 | 1342 | ob_start(); |
| 1343 | 1343 | ?> |
| 1344 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3"> |
|
| 1344 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3"> |
|
| 1345 | 1345 | <div class="note_content bg-light border position-relative p-4"> |
| 1346 | 1346 | |
| 1347 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 1347 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 1348 | 1348 | |
| 1349 | - <?php if ( ! is_admin() ) : ?> |
|
| 1349 | + <?php if (!is_admin()) : ?> |
|
| 1350 | 1350 | <em class="meta position-absolute form-text"> |
| 1351 | 1351 | <?php |
| 1352 | 1352 | printf( |
| 1353 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1353 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1354 | 1354 | $note->comment_author, |
| 1355 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1356 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1355 | + getpaid_format_date_value($note->comment_date), |
|
| 1356 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1357 | 1357 | ); |
| 1358 | 1358 | ?> |
| 1359 | 1359 | </em> |
@@ -1361,21 +1361,21 @@ discard block |
||
| 1361 | 1361 | |
| 1362 | 1362 | </div> |
| 1363 | 1363 | |
| 1364 | - <?php if ( is_admin() ) : ?> |
|
| 1364 | + <?php if (is_admin()) : ?> |
|
| 1365 | 1365 | |
| 1366 | 1366 | <p class="meta px-4 py-2"> |
| 1367 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
| 1367 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
| 1368 | 1368 | <?php |
| 1369 | 1369 | printf( |
| 1370 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1370 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1371 | 1371 | $note->comment_author, |
| 1372 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1373 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1372 | + getpaid_format_date_value($note->comment_date), |
|
| 1373 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1374 | 1374 | ); |
| 1375 | 1375 | ?> |
| 1376 | 1376 | </abbr> |
| 1377 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
| 1378 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 1377 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
| 1378 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 1379 | 1379 | <?php } ?> |
| 1380 | 1380 | </p> |
| 1381 | 1381 | |
@@ -1384,9 +1384,9 @@ discard block |
||
| 1384 | 1384 | </li> |
| 1385 | 1385 | <?php |
| 1386 | 1386 | $note_content = ob_get_clean(); |
| 1387 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 1387 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 1388 | 1388 | |
| 1389 | - if ( $echo ) { |
|
| 1389 | + if ($echo) { |
|
| 1390 | 1390 | echo $note_content; |
| 1391 | 1391 | } else { |
| 1392 | 1392 | return $note_content; |
@@ -1396,36 +1396,36 @@ discard block |
||
| 1396 | 1396 | function wpinv_invalid_invoice_content() { |
| 1397 | 1397 | global $post; |
| 1398 | 1398 | |
| 1399 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 1399 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 1400 | 1400 | |
| 1401 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 1402 | - if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 1403 | - if ( is_user_logged_in() ) { |
|
| 1404 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1405 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 1406 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 1401 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 1402 | + if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 1403 | + if (is_user_logged_in()) { |
|
| 1404 | + if (wpinv_require_login_to_checkout()) { |
|
| 1405 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 1406 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 1407 | 1407 | } |
| 1408 | 1408 | } |
| 1409 | 1409 | } else { |
| 1410 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1411 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 1412 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 1410 | + if (wpinv_require_login_to_checkout()) { |
|
| 1411 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 1412 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 1413 | 1413 | } |
| 1414 | 1414 | } |
| 1415 | 1415 | } |
| 1416 | 1416 | } else { |
| 1417 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 1417 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 1418 | 1418 | } |
| 1419 | 1419 | ?> |
| 1420 | 1420 | <div class="row wpinv-row-invalid"> |
| 1421 | 1421 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 1422 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 1422 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 1423 | 1423 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 1424 | 1424 | </div> |
| 1425 | 1425 | </div> |
| 1426 | 1426 | <?php |
| 1427 | 1427 | } |
| 1428 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 1428 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 1429 | 1429 | |
| 1430 | 1430 | /** |
| 1431 | 1431 | * Function to get privacy policy text. |
@@ -1434,21 +1434,21 @@ discard block |
||
| 1434 | 1434 | * @return string |
| 1435 | 1435 | */ |
| 1436 | 1436 | function wpinv_get_policy_text() { |
| 1437 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 1437 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 1438 | 1438 | |
| 1439 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
| 1439 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 1440 | 1440 | |
| 1441 | - if(!$privacy_page_id){ |
|
| 1442 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 1441 | + if (!$privacy_page_id) { |
|
| 1442 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 1445 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 1446 | 1446 | |
| 1447 | 1447 | $find_replace = array( |
| 1448 | 1448 | '[wpinv_privacy_policy]' => $privacy_link, |
| 1449 | 1449 | ); |
| 1450 | 1450 | |
| 1451 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 1451 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 1452 | 1452 | |
| 1453 | 1453 | return wp_kses_post(wpautop($privacy_text)); |
| 1454 | 1454 | } |
@@ -1456,21 +1456,21 @@ discard block |
||
| 1456 | 1456 | function wpinv_oxygen_fix_conflict() { |
| 1457 | 1457 | global $ct_ignore_post_types; |
| 1458 | 1458 | |
| 1459 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 1459 | + if (!is_array($ct_ignore_post_types)) { |
|
| 1460 | 1460 | $ct_ignore_post_types = array(); |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
| 1463 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
| 1464 | 1464 | |
| 1465 | - foreach ( $post_types as $post_type ) { |
|
| 1465 | + foreach ($post_types as $post_type) { |
|
| 1466 | 1466 | $ct_ignore_post_types[] = $post_type; |
| 1467 | 1467 | |
| 1468 | 1468 | // Ignore post type |
| 1469 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 1469 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 1473 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 1472 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 1473 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | /** |
@@ -1478,10 +1478,10 @@ discard block |
||
| 1478 | 1478 | * |
| 1479 | 1479 | * @param GetPaid_Payment_Form $form |
| 1480 | 1480 | */ |
| 1481 | -function getpaid_display_payment_form( $form ) { |
|
| 1481 | +function getpaid_display_payment_form($form) { |
|
| 1482 | 1482 | |
| 1483 | - if ( is_numeric( $form ) ) { |
|
| 1484 | - $form = new GetPaid_Payment_Form( $form ); |
|
| 1483 | + if (is_numeric($form)) { |
|
| 1484 | + $form = new GetPaid_Payment_Form($form); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | $form->display(); |
@@ -1491,16 +1491,16 @@ discard block |
||
| 1491 | 1491 | /** |
| 1492 | 1492 | * Helper function to display a item payment form on the frontend. |
| 1493 | 1493 | */ |
| 1494 | -function getpaid_display_item_payment_form( $items ) { |
|
| 1494 | +function getpaid_display_item_payment_form($items) { |
|
| 1495 | 1495 | |
| 1496 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1497 | - $form->set_items( $items ); |
|
| 1496 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1497 | + $form->set_items($items); |
|
| 1498 | 1498 | |
| 1499 | - if ( 0 == count( $form->get_items() ) ) { |
|
| 1499 | + if (0 == count($form->get_items())) { |
|
| 1500 | 1500 | echo aui()->alert( |
| 1501 | 1501 | array( |
| 1502 | 1502 | 'type' => 'warning', |
| 1503 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1503 | + 'content' => __('No published items found', 'invoicing'), |
|
| 1504 | 1504 | ) |
| 1505 | 1505 | ); |
| 1506 | 1506 | return; |
@@ -1512,32 +1512,32 @@ discard block |
||
| 1512 | 1512 | /** |
| 1513 | 1513 | * Helper function to display an invoice payment form on the frontend. |
| 1514 | 1514 | */ |
| 1515 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
| 1515 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
| 1516 | 1516 | |
| 1517 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1517 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1518 | 1518 | |
| 1519 | - if ( empty( $invoice ) ) { |
|
| 1519 | + if (empty($invoice)) { |
|
| 1520 | 1520 | echo aui()->alert( |
| 1521 | 1521 | array( |
| 1522 | 1522 | 'type' => 'warning', |
| 1523 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1523 | + 'content' => __('Invoice not found', 'invoicing'), |
|
| 1524 | 1524 | ) |
| 1525 | 1525 | ); |
| 1526 | 1526 | return; |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | - if ( $invoice->is_paid() ) { |
|
| 1529 | + if ($invoice->is_paid()) { |
|
| 1530 | 1530 | echo aui()->alert( |
| 1531 | 1531 | array( |
| 1532 | 1532 | 'type' => 'warning', |
| 1533 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1533 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
| 1534 | 1534 | ) |
| 1535 | 1535 | ); |
| 1536 | 1536 | return; |
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1540 | - $form->set_items( $invoice->get_items() ); |
|
| 1539 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1540 | + $form->set_items($invoice->get_items()); |
|
| 1541 | 1541 | |
| 1542 | 1542 | $form->display(); |
| 1543 | 1543 | } |
@@ -1545,23 +1545,23 @@ discard block |
||
| 1545 | 1545 | /** |
| 1546 | 1546 | * Helper function to convert item string to array. |
| 1547 | 1547 | */ |
| 1548 | -function getpaid_convert_items_to_array( $items ) { |
|
| 1549 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
| 1548 | +function getpaid_convert_items_to_array($items) { |
|
| 1549 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
| 1550 | 1550 | $prepared = array(); |
| 1551 | 1551 | |
| 1552 | - foreach ( $items as $item ) { |
|
| 1553 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
| 1552 | + foreach ($items as $item) { |
|
| 1553 | + $data = array_map('trim', explode('|', $item)); |
|
| 1554 | 1554 | |
| 1555 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
| 1555 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
| 1556 | 1556 | continue; |
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | 1559 | $quantity = 1; |
| 1560 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
| 1560 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
| 1561 | 1561 | $quantity = (int) $data[1]; |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | - $prepared[ $data[0] ] = $quantity; |
|
| 1564 | + $prepared[$data[0]] = $quantity; |
|
| 1565 | 1565 | |
| 1566 | 1566 | } |
| 1567 | 1567 | |
@@ -1571,13 +1571,13 @@ discard block |
||
| 1571 | 1571 | /** |
| 1572 | 1572 | * Helper function to convert item array to string. |
| 1573 | 1573 | */ |
| 1574 | -function getpaid_convert_items_to_string( $items ) { |
|
| 1574 | +function getpaid_convert_items_to_string($items) { |
|
| 1575 | 1575 | $prepared = array(); |
| 1576 | 1576 | |
| 1577 | - foreach ( $items as $item => $quantity ) { |
|
| 1577 | + foreach ($items as $item => $quantity) { |
|
| 1578 | 1578 | $prepared[] = "$item|$quantity"; |
| 1579 | 1579 | } |
| 1580 | - return implode( ',', $prepared ); |
|
| 1580 | + return implode(',', $prepared); |
|
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | 1583 | /** |
@@ -1585,22 +1585,22 @@ discard block |
||
| 1585 | 1585 | * |
| 1586 | 1586 | * Provide a label and one of $form, $items or $invoice. |
| 1587 | 1587 | */ |
| 1588 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
| 1589 | - $label = sanitize_text_field( $label ); |
|
| 1588 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
| 1589 | + $label = sanitize_text_field($label); |
|
| 1590 | 1590 | $nonce = wp_create_nonce('getpaid_ajax_form'); |
| 1591 | 1591 | |
| 1592 | - if ( ! empty( $form ) ) { |
|
| 1593 | - $form = esc_attr( $form ); |
|
| 1592 | + if (!empty($form)) { |
|
| 1593 | + $form = esc_attr($form); |
|
| 1594 | 1594 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | - if ( ! empty( $items ) ) { |
|
| 1598 | - $items = esc_attr( $items ); |
|
| 1597 | + if (!empty($items)) { |
|
| 1598 | + $items = esc_attr($items); |
|
| 1599 | 1599 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | - if ( ! empty( $invoice ) ) { |
|
| 1603 | - $invoice = esc_attr( $invoice ); |
|
| 1602 | + if (!empty($invoice)) { |
|
| 1603 | + $invoice = esc_attr($invoice); |
|
| 1604 | 1604 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; |
| 1605 | 1605 | } |
| 1606 | 1606 | |
@@ -1611,17 +1611,17 @@ discard block |
||
| 1611 | 1611 | * |
| 1612 | 1612 | * @param WPInv_Invoice $invoice |
| 1613 | 1613 | */ |
| 1614 | -function getpaid_the_invoice_description( $invoice ) { |
|
| 1614 | +function getpaid_the_invoice_description($invoice) { |
|
| 1615 | 1615 | $description = $invoice->get_description(); |
| 1616 | 1616 | |
| 1617 | - if ( empty( $description ) ) { |
|
| 1617 | + if (empty($description)) { |
|
| 1618 | 1618 | return; |
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | - $description = wp_kses_post( $description ); |
|
| 1621 | + $description = wp_kses_post($description); |
|
| 1622 | 1622 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>"; |
| 1623 | 1623 | } |
| 1624 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
| 1624 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
| 1625 | 1625 | |
| 1626 | 1626 | /** |
| 1627 | 1627 | * Render element on a form. |
@@ -1629,60 +1629,60 @@ discard block |
||
| 1629 | 1629 | * @param array $element |
| 1630 | 1630 | * @param GetPaid_Payment_Form $form |
| 1631 | 1631 | */ |
| 1632 | -function getpaid_payment_form_element( $element, $form ) { |
|
| 1632 | +function getpaid_payment_form_element($element, $form) { |
|
| 1633 | 1633 | |
| 1634 | 1634 | // Set up the args. |
| 1635 | - $element_type = trim( $element['type'] ); |
|
| 1635 | + $element_type = trim($element['type']); |
|
| 1636 | 1636 | $element['form'] = $form; |
| 1637 | - extract( $element ); |
|
| 1637 | + extract($element); |
|
| 1638 | 1638 | |
| 1639 | 1639 | // Try to locate the appropriate template. |
| 1640 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
| 1640 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
| 1641 | 1641 | |
| 1642 | 1642 | // Abort if this is not our element. |
| 1643 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1643 | + if (empty($located) || !file_exists($located)) { |
|
| 1644 | 1644 | return; |
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 | // Generate the class and id of the element. |
| 1648 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
| 1649 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
| 1648 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
| 1649 | + $id = isset($id) ? $id : uniqid('gp'); |
|
| 1650 | 1650 | |
| 1651 | 1651 | // Echo the opening wrapper. |
| 1652 | 1652 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
| 1653 | 1653 | |
| 1654 | 1654 | // Fires before displaying a given element type's content. |
| 1655 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
| 1655 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
| 1656 | 1656 | |
| 1657 | 1657 | // Include the template for the element. |
| 1658 | 1658 | include $located; |
| 1659 | 1659 | |
| 1660 | 1660 | // Fires after displaying a given element type's content. |
| 1661 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
| 1661 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
| 1662 | 1662 | |
| 1663 | 1663 | // Echo the closing wrapper. |
| 1664 | 1664 | echo '</div>'; |
| 1665 | 1665 | } |
| 1666 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
| 1666 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
| 1667 | 1667 | |
| 1668 | 1668 | /** |
| 1669 | 1669 | * Render an element's edit page. |
| 1670 | 1670 | * |
| 1671 | 1671 | * @param WP_Post $post |
| 1672 | 1672 | */ |
| 1673 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
| 1673 | +function getpaid_payment_form_edit_element_template($post) { |
|
| 1674 | 1674 | |
| 1675 | 1675 | // Retrieve all elements. |
| 1676 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1676 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1677 | 1677 | |
| 1678 | - foreach ( $all_elements as $element ) { |
|
| 1678 | + foreach ($all_elements as $element) { |
|
| 1679 | 1679 | |
| 1680 | 1680 | // Try to locate the appropriate template. |
| 1681 | - $element = sanitize_key( $element ); |
|
| 1682 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
| 1681 | + $element = sanitize_key($element); |
|
| 1682 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
| 1683 | 1683 | |
| 1684 | 1684 | // Continue if this is not our element. |
| 1685 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1685 | + if (empty($located) || !file_exists($located)) { |
|
| 1686 | 1686 | continue; |
| 1687 | 1687 | } |
| 1688 | 1688 | |
@@ -1693,7 +1693,7 @@ discard block |
||
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | } |
| 1696 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
| 1696 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
| 1697 | 1697 | |
| 1698 | 1698 | /** |
| 1699 | 1699 | * Render an element's preview. |
@@ -1702,16 +1702,16 @@ discard block |
||
| 1702 | 1702 | function getpaid_payment_form_render_element_preview_template() { |
| 1703 | 1703 | |
| 1704 | 1704 | // Retrieve all elements. |
| 1705 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1705 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1706 | 1706 | |
| 1707 | - foreach ( $all_elements as $element ) { |
|
| 1707 | + foreach ($all_elements as $element) { |
|
| 1708 | 1708 | |
| 1709 | 1709 | // Try to locate the appropriate template. |
| 1710 | - $element = sanitize_key( $element ); |
|
| 1711 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
| 1710 | + $element = sanitize_key($element); |
|
| 1711 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
| 1712 | 1712 | |
| 1713 | 1713 | // Continue if this is not our element. |
| 1714 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1714 | + if (empty($located) || !file_exists($located)) { |
|
| 1715 | 1715 | continue; |
| 1716 | 1716 | } |
| 1717 | 1717 | |
@@ -1722,7 +1722,7 @@ discard block |
||
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | 1724 | } |
| 1725 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
| 1725 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
| 1726 | 1726 | |
| 1727 | 1727 | /** |
| 1728 | 1728 | * Shows a list of gateways that support recurring payments. |
@@ -1730,17 +1730,17 @@ discard block |
||
| 1730 | 1730 | function wpinv_get_recurring_gateways_text() { |
| 1731 | 1731 | $gateways = array(); |
| 1732 | 1732 | |
| 1733 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 1734 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 1735 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
| 1733 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 1734 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 1735 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
| 1736 | 1736 | } |
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | - if ( empty( $gateways ) ) { |
|
| 1740 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
| 1739 | + if (empty($gateways)) { |
|
| 1740 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
| 1743 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
| 1744 | 1744 | |
| 1745 | 1745 | } |
| 1746 | 1746 | |
@@ -1750,7 +1750,7 @@ discard block |
||
| 1750 | 1750 | * @return GetPaid_Template |
| 1751 | 1751 | */ |
| 1752 | 1752 | function getpaid_template() { |
| 1753 | - return getpaid()->get( 'template' ); |
|
| 1753 | + return getpaid()->get('template'); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | 1756 | /** |
@@ -1759,23 +1759,23 @@ discard block |
||
| 1759 | 1759 | * @param array args |
| 1760 | 1760 | * @return string |
| 1761 | 1761 | */ |
| 1762 | -function getpaid_paginate_links( $args ) { |
|
| 1762 | +function getpaid_paginate_links($args) { |
|
| 1763 | 1763 | |
| 1764 | 1764 | $args['type'] = 'array'; |
| 1765 | 1765 | $args['mid_size'] = 1; |
| 1766 | - $pages = paginate_links( $args ); |
|
| 1766 | + $pages = paginate_links($args); |
|
| 1767 | 1767 | |
| 1768 | - if ( ! is_array( $pages ) ) { |
|
| 1768 | + if (!is_array($pages)) { |
|
| 1769 | 1769 | return ''; |
| 1770 | 1770 | } |
| 1771 | 1771 | |
| 1772 | 1772 | $_pages = array(); |
| 1773 | - foreach ( $pages as $page ) { |
|
| 1774 | - $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page ); |
|
| 1773 | + foreach ($pages as $page) { |
|
| 1774 | + $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page); |
|
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | 1777 | $links = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>"; |
| 1778 | - $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages ); |
|
| 1778 | + $links .= join("</li>\n\t\t<li class='page-item'>", $_pages); |
|
| 1779 | 1779 | $links .= "</li>\n\t</ul>\n</nav>\n"; |
| 1780 | 1780 | |
| 1781 | 1781 | return $links; |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | * @package Invoicing/data |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | return array( |
| 12 | 12 | "AD" => "AD\d{3}", |
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | $this->set_id( $invoice_id ); |
| 157 | 157 | } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
| 158 | 158 | $this->set_id( $invoice_id ); |
| 159 | - }else { |
|
| 159 | + } else { |
|
| 160 | 160 | $this->set_object_read( true ); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | class WPInv_Invoice extends GetPaid_Data { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Which data store to load. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 17 | + * Which data store to load. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | 21 | protected $data_store_name = 'invoice'; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * This is the name of this object type. |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 24 | + * This is the name of this object type. |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | protected $object_type = 'invoice'; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.19 |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $data = array( |
|
| 37 | - 'parent_id' => 0, |
|
| 38 | - 'status' => 'wpi-pending', |
|
| 39 | - 'version' => '', |
|
| 40 | - 'date_created' => null, |
|
| 31 | + * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.19 |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $data = array( |
|
| 37 | + 'parent_id' => 0, |
|
| 38 | + 'status' => 'wpi-pending', |
|
| 39 | + 'version' => '', |
|
| 40 | + 'date_created' => null, |
|
| 41 | 41 | 'date_modified' => null, |
| 42 | 42 | 'due_date' => null, |
| 43 | 43 | 'completed_date' => null, |
@@ -79,22 +79,22 @@ discard block |
||
| 79 | 79 | 'transaction_id' => '', |
| 80 | 80 | 'currency' => '', |
| 81 | 81 | 'disable_taxes' => false, |
| 82 | - 'subscription_id' => null, |
|
| 83 | - 'remote_subscription_id' => null, |
|
| 84 | - 'is_viewed' => false, |
|
| 85 | - 'email_cc' => '', |
|
| 86 | - 'template' => 'quantity', // hours, amount only |
|
| 87 | - 'created_via' => null, |
|
| 82 | + 'subscription_id' => null, |
|
| 83 | + 'remote_subscription_id' => null, |
|
| 84 | + 'is_viewed' => false, |
|
| 85 | + 'email_cc' => '', |
|
| 86 | + 'template' => 'quantity', // hours, amount only |
|
| 87 | + 'created_via' => null, |
|
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Stores meta in cache for future reads. |
|
| 92 | - * |
|
| 93 | - * A group must be set to to enable caching. |
|
| 94 | - * |
|
| 95 | - * @var string |
|
| 96 | - */ |
|
| 97 | - protected $cache_group = 'getpaid_invoices'; |
|
| 91 | + * Stores meta in cache for future reads. |
|
| 92 | + * |
|
| 93 | + * A group must be set to to enable caching. |
|
| 94 | + * |
|
| 95 | + * @var string |
|
| 96 | + */ |
|
| 97 | + protected $cache_group = 'getpaid_invoices'; |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Stores a reference to the original WP_Post object |
@@ -108,104 +108,104 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @var int |
| 110 | 110 | */ |
| 111 | - protected $recurring_item = null; |
|
| 111 | + protected $recurring_item = null; |
|
| 112 | 112 | |
| 113 | - /** |
|
| 113 | + /** |
|
| 114 | 114 | * Stores an array of item totals. |
| 115 | - * |
|
| 116 | - * e.g $totals['discount'] = array( |
|
| 117 | - * 'initial' => 10, |
|
| 118 | - * 'recurring' => 10, |
|
| 119 | - * ) |
|
| 115 | + * |
|
| 116 | + * e.g $totals['discount'] = array( |
|
| 117 | + * 'initial' => 10, |
|
| 118 | + * 'recurring' => 10, |
|
| 119 | + * ) |
|
| 120 | 120 | * |
| 121 | 121 | * @var array |
| 122 | 122 | */ |
| 123 | - protected $totals = array(); |
|
| 123 | + protected $totals = array(); |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Stores the status transition information. |
|
| 127 | - * |
|
| 128 | - * @since 1.0.19 |
|
| 129 | - * @var bool |
|
| 130 | - */ |
|
| 131 | - protected $status_transition = false; |
|
| 125 | + /** |
|
| 126 | + * Stores the status transition information. |
|
| 127 | + * |
|
| 128 | + * @since 1.0.19 |
|
| 129 | + * @var bool |
|
| 130 | + */ |
|
| 131 | + protected $status_transition = false; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 135 | - * |
|
| 136 | - * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 137 | - */ |
|
| 134 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 135 | + * |
|
| 136 | + * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 137 | + */ |
|
| 138 | 138 | public function __construct( $invoice = false ) { |
| 139 | 139 | |
| 140 | 140 | parent::__construct( $invoice ); |
| 141 | 141 | |
| 142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 143 | - $this->set_id( $invoice ); |
|
| 144 | - } elseif ( $invoice instanceof self ) { |
|
| 145 | - $this->set_id( $invoice->get_id() ); |
|
| 146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | - $this->set_id( $invoice->ID ); |
|
| 148 | - } elseif ( is_array( $invoice ) ) { |
|
| 149 | - $this->set_props( $invoice ); |
|
| 150 | - |
|
| 151 | - if ( isset( $invoice['ID'] ) ) { |
|
| 152 | - $this->set_id( $invoice['ID'] ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | - $this->set_id( $invoice_id ); |
|
| 161 | - }else { |
|
| 162 | - $this->set_object_read( true ); |
|
| 163 | - } |
|
| 142 | + if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 143 | + $this->set_id( $invoice ); |
|
| 144 | + } elseif ( $invoice instanceof self ) { |
|
| 145 | + $this->set_id( $invoice->get_id() ); |
|
| 146 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | + $this->set_id( $invoice->ID ); |
|
| 148 | + } elseif ( is_array( $invoice ) ) { |
|
| 149 | + $this->set_props( $invoice ); |
|
| 150 | + |
|
| 151 | + if ( isset( $invoice['ID'] ) ) { |
|
| 152 | + $this->set_id( $invoice['ID'] ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | + $this->set_id( $invoice_id ); |
|
| 157 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | + $this->set_id( $invoice_id ); |
|
| 159 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | + $this->set_id( $invoice_id ); |
|
| 161 | + }else { |
|
| 162 | + $this->set_object_read( true ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | // Load the datastore. |
| 166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 166 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 167 | 167 | |
| 168 | - if ( $this->get_id() > 0 ) { |
|
| 168 | + if ( $this->get_id() > 0 ) { |
|
| 169 | 169 | $this->post = get_post( $this->get_id() ); |
| 170 | 170 | $this->ID = $this->get_id(); |
| 171 | - $this->data_store->read( $this ); |
|
| 171 | + $this->data_store->read( $this ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Given an invoice key/number, it returns its id. |
|
| 178 | - * |
|
| 179 | - * |
|
| 180 | - * @static |
|
| 181 | - * @param string $value The invoice key or number |
|
| 182 | - * @param string $field Either key, transaction_id or number. |
|
| 183 | - * @since 1.0.15 |
|
| 184 | - * @return int |
|
| 185 | - */ |
|
| 186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 177 | + * Given an invoice key/number, it returns its id. |
|
| 178 | + * |
|
| 179 | + * |
|
| 180 | + * @static |
|
| 181 | + * @param string $value The invoice key or number |
|
| 182 | + * @param string $field Either key, transaction_id or number. |
|
| 183 | + * @since 1.0.15 |
|
| 184 | + * @return int |
|
| 185 | + */ |
|
| 186 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | - // Trim the value. |
|
| 190 | - $value = trim( $value ); |
|
| 189 | + // Trim the value. |
|
| 190 | + $value = trim( $value ); |
|
| 191 | 191 | |
| 192 | - if ( empty( $value ) ) { |
|
| 193 | - return 0; |
|
| 194 | - } |
|
| 192 | + if ( empty( $value ) ) { |
|
| 193 | + return 0; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | // Valid fields. |
| 197 | 197 | $fields = array( 'key', 'number', 'transaction_id' ); |
| 198 | 198 | |
| 199 | - // Ensure a field has been passed. |
|
| 200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 201 | - return 0; |
|
| 202 | - } |
|
| 199 | + // Ensure a field has been passed. |
|
| 200 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 201 | + return 0; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - // Maybe retrieve from the cache. |
|
| 205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | - if ( false !== $invoice_id ) { |
|
| 207 | - return $invoice_id; |
|
| 208 | - } |
|
| 204 | + // Maybe retrieve from the cache. |
|
| 205 | + $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | + if ( false !== $invoice_id ) { |
|
| 207 | + return $invoice_id; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | // Fetch from the db. |
| 211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - // Update the cache with our data |
|
| 217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 216 | + // Update the cache with our data |
|
| 217 | + wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 218 | 218 | |
| 219 | - return $invoice_id; |
|
| 219 | + return $invoice_id; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -242,80 +242,80 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | - * Get parent invoice ID. |
|
| 246 | - * |
|
| 247 | - * @since 1.0.19 |
|
| 248 | - * @param string $context View or edit context. |
|
| 249 | - * @return int |
|
| 250 | - */ |
|
| 251 | - public function get_parent_id( $context = 'view' ) { |
|
| 252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 245 | + * Get parent invoice ID. |
|
| 246 | + * |
|
| 247 | + * @since 1.0.19 |
|
| 248 | + * @param string $context View or edit context. |
|
| 249 | + * @return int |
|
| 250 | + */ |
|
| 251 | + public function get_parent_id( $context = 'view' ) { |
|
| 252 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | - * Get parent invoice. |
|
| 257 | - * |
|
| 258 | - * @since 1.0.19 |
|
| 259 | - * @return WPInv_Invoice |
|
| 260 | - */ |
|
| 256 | + * Get parent invoice. |
|
| 257 | + * |
|
| 258 | + * @since 1.0.19 |
|
| 259 | + * @return WPInv_Invoice |
|
| 260 | + */ |
|
| 261 | 261 | public function get_parent_payment() { |
| 262 | 262 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | - * Alias for self::get_parent_payment(). |
|
| 267 | - * |
|
| 268 | - * @since 1.0.19 |
|
| 269 | - * @return WPInv_Invoice |
|
| 270 | - */ |
|
| 266 | + * Alias for self::get_parent_payment(). |
|
| 267 | + * |
|
| 268 | + * @since 1.0.19 |
|
| 269 | + * @return WPInv_Invoice |
|
| 270 | + */ |
|
| 271 | 271 | public function get_parent() { |
| 272 | 272 | return $this->get_parent_payment(); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * Get invoice status. |
|
| 277 | - * |
|
| 278 | - * @since 1.0.19 |
|
| 279 | - * @param string $context View or edit context. |
|
| 280 | - * @return string |
|
| 281 | - */ |
|
| 282 | - public function get_status( $context = 'view' ) { |
|
| 283 | - return $this->get_prop( 'status', $context ); |
|
| 284 | - } |
|
| 276 | + * Get invoice status. |
|
| 277 | + * |
|
| 278 | + * @since 1.0.19 |
|
| 279 | + * @param string $context View or edit context. |
|
| 280 | + * @return string |
|
| 281 | + */ |
|
| 282 | + public function get_status( $context = 'view' ) { |
|
| 283 | + return $this->get_prop( 'status', $context ); |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * Retrieves an array of possible invoice statuses. |
|
| 288 | - * |
|
| 289 | - * @since 1.0.19 |
|
| 290 | - * @return array |
|
| 291 | - */ |
|
| 292 | - public function get_all_statuses() { |
|
| 293 | - |
|
| 294 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 295 | - |
|
| 296 | - // For backwards compatibility. |
|
| 297 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 286 | + /** |
|
| 287 | + * Retrieves an array of possible invoice statuses. |
|
| 288 | + * |
|
| 289 | + * @since 1.0.19 |
|
| 290 | + * @return array |
|
| 291 | + */ |
|
| 292 | + public function get_all_statuses() { |
|
| 293 | + |
|
| 294 | + $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 295 | + |
|
| 296 | + // For backwards compatibility. |
|
| 297 | + if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 298 | 298 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
| 299 | - } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - return $statuses; |
|
| 301 | + return $statuses; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Get invoice status nice name. |
|
| 306 | - * |
|
| 307 | - * @since 1.0.19 |
|
| 308 | - * @return string |
|
| 309 | - */ |
|
| 305 | + * Get invoice status nice name. |
|
| 306 | + * |
|
| 307 | + * @since 1.0.19 |
|
| 308 | + * @return string |
|
| 309 | + */ |
|
| 310 | 310 | public function get_status_nicename() { |
| 311 | - $statuses = $this->get_all_statuses(); |
|
| 311 | + $statuses = $this->get_all_statuses(); |
|
| 312 | 312 | |
| 313 | 313 | $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
| 314 | 314 | |
| 315 | 315 | return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - /** |
|
| 318 | + /** |
|
| 319 | 319 | * Retrieves the invoice status label html |
| 320 | 320 | * |
| 321 | 321 | * @since 1.0.0 |
@@ -323,262 +323,262 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | public function get_status_label_html() { |
| 325 | 325 | |
| 326 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 327 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 326 | + $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 327 | + $status = sanitize_html_class( $this->get_status() ); |
|
| 328 | 328 | |
| 329 | - return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
|
| 330 | - } |
|
| 329 | + return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | - * Get plugin version when the invoice was created. |
|
| 334 | - * |
|
| 335 | - * @since 1.0.19 |
|
| 336 | - * @param string $context View or edit context. |
|
| 337 | - * @return string |
|
| 338 | - */ |
|
| 339 | - public function get_version( $context = 'view' ) { |
|
| 340 | - return $this->get_prop( 'version', $context ); |
|
| 341 | - } |
|
| 333 | + * Get plugin version when the invoice was created. |
|
| 334 | + * |
|
| 335 | + * @since 1.0.19 |
|
| 336 | + * @param string $context View or edit context. |
|
| 337 | + * @return string |
|
| 338 | + */ |
|
| 339 | + public function get_version( $context = 'view' ) { |
|
| 340 | + return $this->get_prop( 'version', $context ); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - /** |
|
| 344 | - * @deprecated |
|
| 345 | - */ |
|
| 346 | - public function get_invoice_date( $format = true ) { |
|
| 347 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 348 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 349 | - $formatted = getpaid_format_date( $date ); |
|
| 343 | + /** |
|
| 344 | + * @deprecated |
|
| 345 | + */ |
|
| 346 | + public function get_invoice_date( $format = true ) { |
|
| 347 | + $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 348 | + $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 349 | + $formatted = getpaid_format_date( $date ); |
|
| 350 | 350 | |
| 351 | - if ( $format ) { |
|
| 352 | - return $formatted; |
|
| 353 | - } |
|
| 351 | + if ( $format ) { |
|
| 352 | + return $formatted; |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - return empty( $formatted ) ? '' : $date; |
|
| 355 | + return empty( $formatted ) ? '' : $date; |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | - * Get date when the invoice was created. |
|
| 361 | - * |
|
| 362 | - * @since 1.0.19 |
|
| 363 | - * @param string $context View or edit context. |
|
| 364 | - * @return string |
|
| 365 | - */ |
|
| 366 | - public function get_date_created( $context = 'view' ) { |
|
| 367 | - return $this->get_prop( 'date_created', $context ); |
|
| 368 | - } |
|
| 360 | + * Get date when the invoice was created. |
|
| 361 | + * |
|
| 362 | + * @since 1.0.19 |
|
| 363 | + * @param string $context View or edit context. |
|
| 364 | + * @return string |
|
| 365 | + */ |
|
| 366 | + public function get_date_created( $context = 'view' ) { |
|
| 367 | + return $this->get_prop( 'date_created', $context ); |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - /** |
|
| 371 | - * Alias for self::get_date_created(). |
|
| 372 | - * |
|
| 373 | - * @since 1.0.19 |
|
| 374 | - * @param string $context View or edit context. |
|
| 375 | - * @return string |
|
| 376 | - */ |
|
| 377 | - public function get_created_date( $context = 'view' ) { |
|
| 378 | - return $this->get_date_created( $context ); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Get GMT date when the invoice was created. |
|
| 383 | - * |
|
| 384 | - * @since 1.0.19 |
|
| 385 | - * @param string $context View or edit context. |
|
| 386 | - * @return string |
|
| 387 | - */ |
|
| 388 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 370 | + /** |
|
| 371 | + * Alias for self::get_date_created(). |
|
| 372 | + * |
|
| 373 | + * @since 1.0.19 |
|
| 374 | + * @param string $context View or edit context. |
|
| 375 | + * @return string |
|
| 376 | + */ |
|
| 377 | + public function get_created_date( $context = 'view' ) { |
|
| 378 | + return $this->get_date_created( $context ); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Get GMT date when the invoice was created. |
|
| 383 | + * |
|
| 384 | + * @since 1.0.19 |
|
| 385 | + * @param string $context View or edit context. |
|
| 386 | + * @return string |
|
| 387 | + */ |
|
| 388 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 389 | 389 | $date = $this->get_date_created( $context ); |
| 390 | 390 | |
| 391 | 391 | if ( $date ) { |
| 392 | 392 | $date = get_gmt_from_date( $date ); |
| 393 | 393 | } |
| 394 | - return $date; |
|
| 394 | + return $date; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | /** |
| 398 | - * Get date when the invoice was last modified. |
|
| 399 | - * |
|
| 400 | - * @since 1.0.19 |
|
| 401 | - * @param string $context View or edit context. |
|
| 402 | - * @return string |
|
| 403 | - */ |
|
| 404 | - public function get_date_modified( $context = 'view' ) { |
|
| 405 | - return $this->get_prop( 'date_modified', $context ); |
|
| 406 | - } |
|
| 398 | + * Get date when the invoice was last modified. |
|
| 399 | + * |
|
| 400 | + * @since 1.0.19 |
|
| 401 | + * @param string $context View or edit context. |
|
| 402 | + * @return string |
|
| 403 | + */ |
|
| 404 | + public function get_date_modified( $context = 'view' ) { |
|
| 405 | + return $this->get_prop( 'date_modified', $context ); |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Alias for self::get_date_modified(). |
|
| 410 | - * |
|
| 411 | - * @since 1.0.19 |
|
| 412 | - * @param string $context View or edit context. |
|
| 413 | - * @return string |
|
| 414 | - */ |
|
| 415 | - public function get_modified_date( $context = 'view' ) { |
|
| 416 | - return $this->get_date_modified( $context ); |
|
| 408 | + /** |
|
| 409 | + * Alias for self::get_date_modified(). |
|
| 410 | + * |
|
| 411 | + * @since 1.0.19 |
|
| 412 | + * @param string $context View or edit context. |
|
| 413 | + * @return string |
|
| 414 | + */ |
|
| 415 | + public function get_modified_date( $context = 'view' ) { |
|
| 416 | + return $this->get_date_modified( $context ); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | - * Get GMT date when the invoice was last modified. |
|
| 421 | - * |
|
| 422 | - * @since 1.0.19 |
|
| 423 | - * @param string $context View or edit context. |
|
| 424 | - * @return string |
|
| 425 | - */ |
|
| 426 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 420 | + * Get GMT date when the invoice was last modified. |
|
| 421 | + * |
|
| 422 | + * @since 1.0.19 |
|
| 423 | + * @param string $context View or edit context. |
|
| 424 | + * @return string |
|
| 425 | + */ |
|
| 426 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 427 | 427 | $date = $this->get_date_modified( $context ); |
| 428 | 428 | |
| 429 | 429 | if ( $date ) { |
| 430 | 430 | $date = get_gmt_from_date( $date ); |
| 431 | 431 | } |
| 432 | - return $date; |
|
| 432 | + return $date; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | /** |
| 436 | - * Get the invoice due date. |
|
| 437 | - * |
|
| 438 | - * @since 1.0.19 |
|
| 439 | - * @param string $context View or edit context. |
|
| 440 | - * @return string |
|
| 441 | - */ |
|
| 442 | - public function get_due_date( $context = 'view' ) { |
|
| 443 | - return $this->get_prop( 'due_date', $context ); |
|
| 436 | + * Get the invoice due date. |
|
| 437 | + * |
|
| 438 | + * @since 1.0.19 |
|
| 439 | + * @param string $context View or edit context. |
|
| 440 | + * @return string |
|
| 441 | + */ |
|
| 442 | + public function get_due_date( $context = 'view' ) { |
|
| 443 | + return $this->get_prop( 'due_date', $context ); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | /** |
| 447 | - * Alias for self::get_due_date(). |
|
| 448 | - * |
|
| 449 | - * @since 1.0.19 |
|
| 450 | - * @param string $context View or edit context. |
|
| 451 | - * @return string |
|
| 452 | - */ |
|
| 453 | - public function get_date_due( $context = 'view' ) { |
|
| 454 | - return $this->get_due_date( $context ); |
|
| 447 | + * Alias for self::get_due_date(). |
|
| 448 | + * |
|
| 449 | + * @since 1.0.19 |
|
| 450 | + * @param string $context View or edit context. |
|
| 451 | + * @return string |
|
| 452 | + */ |
|
| 453 | + public function get_date_due( $context = 'view' ) { |
|
| 454 | + return $this->get_due_date( $context ); |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | /** |
| 458 | - * Get the invoice GMT due date. |
|
| 459 | - * |
|
| 460 | - * @since 1.0.19 |
|
| 461 | - * @param string $context View or edit context. |
|
| 462 | - * @return string |
|
| 463 | - */ |
|
| 464 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 458 | + * Get the invoice GMT due date. |
|
| 459 | + * |
|
| 460 | + * @since 1.0.19 |
|
| 461 | + * @param string $context View or edit context. |
|
| 462 | + * @return string |
|
| 463 | + */ |
|
| 464 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 465 | 465 | $date = $this->get_due_date( $context ); |
| 466 | 466 | |
| 467 | 467 | if ( $date ) { |
| 468 | 468 | $date = get_gmt_from_date( $date ); |
| 469 | 469 | } |
| 470 | - return $date; |
|
| 470 | + return $date; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | /** |
| 474 | - * Alias for self::get_due_date_gmt(). |
|
| 475 | - * |
|
| 476 | - * @since 1.0.19 |
|
| 477 | - * @param string $context View or edit context. |
|
| 478 | - * @return string |
|
| 479 | - */ |
|
| 480 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 481 | - return $this->get_due_date_gmt( $context ); |
|
| 474 | + * Alias for self::get_due_date_gmt(). |
|
| 475 | + * |
|
| 476 | + * @since 1.0.19 |
|
| 477 | + * @param string $context View or edit context. |
|
| 478 | + * @return string |
|
| 479 | + */ |
|
| 480 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 481 | + return $this->get_due_date_gmt( $context ); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
| 485 | - * Get date when the invoice was completed. |
|
| 486 | - * |
|
| 487 | - * @since 1.0.19 |
|
| 488 | - * @param string $context View or edit context. |
|
| 489 | - * @return string |
|
| 490 | - */ |
|
| 491 | - public function get_completed_date( $context = 'view' ) { |
|
| 492 | - return $this->get_prop( 'completed_date', $context ); |
|
| 485 | + * Get date when the invoice was completed. |
|
| 486 | + * |
|
| 487 | + * @since 1.0.19 |
|
| 488 | + * @param string $context View or edit context. |
|
| 489 | + * @return string |
|
| 490 | + */ |
|
| 491 | + public function get_completed_date( $context = 'view' ) { |
|
| 492 | + return $this->get_prop( 'completed_date', $context ); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
| 496 | - * Alias for self::get_completed_date(). |
|
| 497 | - * |
|
| 498 | - * @since 1.0.19 |
|
| 499 | - * @param string $context View or edit context. |
|
| 500 | - * @return string |
|
| 501 | - */ |
|
| 502 | - public function get_date_completed( $context = 'view' ) { |
|
| 503 | - return $this->get_completed_date( $context ); |
|
| 496 | + * Alias for self::get_completed_date(). |
|
| 497 | + * |
|
| 498 | + * @since 1.0.19 |
|
| 499 | + * @param string $context View or edit context. |
|
| 500 | + * @return string |
|
| 501 | + */ |
|
| 502 | + public function get_date_completed( $context = 'view' ) { |
|
| 503 | + return $this->get_completed_date( $context ); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
| 507 | - * Get GMT date when the invoice was was completed. |
|
| 508 | - * |
|
| 509 | - * @since 1.0.19 |
|
| 510 | - * @param string $context View or edit context. |
|
| 511 | - * @return string |
|
| 512 | - */ |
|
| 513 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 507 | + * Get GMT date when the invoice was was completed. |
|
| 508 | + * |
|
| 509 | + * @since 1.0.19 |
|
| 510 | + * @param string $context View or edit context. |
|
| 511 | + * @return string |
|
| 512 | + */ |
|
| 513 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 514 | 514 | $date = $this->get_completed_date( $context ); |
| 515 | 515 | |
| 516 | 516 | if ( $date ) { |
| 517 | 517 | $date = get_gmt_from_date( $date ); |
| 518 | 518 | } |
| 519 | - return $date; |
|
| 519 | + return $date; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
| 523 | - * Alias for self::get_completed_date_gmt(). |
|
| 524 | - * |
|
| 525 | - * @since 1.0.19 |
|
| 526 | - * @param string $context View or edit context. |
|
| 527 | - * @return string |
|
| 528 | - */ |
|
| 529 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 530 | - return $this->get_completed_date_gmt( $context ); |
|
| 523 | + * Alias for self::get_completed_date_gmt(). |
|
| 524 | + * |
|
| 525 | + * @since 1.0.19 |
|
| 526 | + * @param string $context View or edit context. |
|
| 527 | + * @return string |
|
| 528 | + */ |
|
| 529 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 530 | + return $this->get_completed_date_gmt( $context ); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | - * Get the invoice number. |
|
| 535 | - * |
|
| 536 | - * @since 1.0.19 |
|
| 537 | - * @param string $context View or edit context. |
|
| 538 | - * @return string |
|
| 539 | - */ |
|
| 540 | - public function get_number( $context = 'view' ) { |
|
| 541 | - $number = $this->get_prop( 'number', $context ); |
|
| 534 | + * Get the invoice number. |
|
| 535 | + * |
|
| 536 | + * @since 1.0.19 |
|
| 537 | + * @param string $context View or edit context. |
|
| 538 | + * @return string |
|
| 539 | + */ |
|
| 540 | + public function get_number( $context = 'view' ) { |
|
| 541 | + $number = $this->get_prop( 'number', $context ); |
|
| 542 | 542 | |
| 543 | - if ( empty( $number ) ) { |
|
| 544 | - $number = $this->generate_number(); |
|
| 545 | - $this->set_number( $this->generate_number() ); |
|
| 546 | - } |
|
| 543 | + if ( empty( $number ) ) { |
|
| 544 | + $number = $this->generate_number(); |
|
| 545 | + $this->set_number( $this->generate_number() ); |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - return $number; |
|
| 548 | + return $number; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - /** |
|
| 552 | - * Set the invoice number. |
|
| 553 | - * |
|
| 554 | - * @since 1.0.19 |
|
| 555 | - */ |
|
| 556 | - public function maybe_set_number() { |
|
| 551 | + /** |
|
| 552 | + * Set the invoice number. |
|
| 553 | + * |
|
| 554 | + * @since 1.0.19 |
|
| 555 | + */ |
|
| 556 | + public function maybe_set_number() { |
|
| 557 | 557 | $number = $this->get_number(); |
| 558 | 558 | |
| 559 | 559 | if ( empty( $number ) || $this->get_id() == $number ) { |
| 560 | - $this->set_number( $this->generate_number() ); |
|
| 560 | + $this->set_number( $this->generate_number() ); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - } |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | 565 | /** |
| 566 | - * Get the invoice key. |
|
| 567 | - * |
|
| 568 | - * @since 1.0.19 |
|
| 569 | - * @param string $context View or edit context. |
|
| 570 | - * @return string |
|
| 571 | - */ |
|
| 572 | - public function get_key( $context = 'view' ) { |
|
| 566 | + * Get the invoice key. |
|
| 567 | + * |
|
| 568 | + * @since 1.0.19 |
|
| 569 | + * @param string $context View or edit context. |
|
| 570 | + * @return string |
|
| 571 | + */ |
|
| 572 | + public function get_key( $context = 'view' ) { |
|
| 573 | 573 | return $this->get_prop( 'key', $context ); |
| 574 | - } |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * Set the invoice key. |
|
| 578 | - * |
|
| 579 | - * @since 1.0.19 |
|
| 580 | - */ |
|
| 581 | - public function maybe_set_key() { |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * Set the invoice key. |
|
| 578 | + * |
|
| 579 | + * @since 1.0.19 |
|
| 580 | + */ |
|
| 581 | + public function maybe_set_key() { |
|
| 582 | 582 | $key = $this->get_key(); |
| 583 | 583 | |
| 584 | 584 | if ( empty( $key ) ) { |
@@ -589,126 +589,126 @@ discard block |
||
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
| 592 | - * Get the invoice type. |
|
| 593 | - * |
|
| 594 | - * @since 1.0.19 |
|
| 595 | - * @param string $context View or edit context. |
|
| 596 | - * @return string |
|
| 597 | - */ |
|
| 598 | - public function get_type( $context = 'view' ) { |
|
| 592 | + * Get the invoice type. |
|
| 593 | + * |
|
| 594 | + * @since 1.0.19 |
|
| 595 | + * @param string $context View or edit context. |
|
| 596 | + * @return string |
|
| 597 | + */ |
|
| 598 | + public function get_type( $context = 'view' ) { |
|
| 599 | 599 | return $this->get_prop( 'type', $context ); |
| 600 | - } |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | - /** |
|
| 603 | - * @deprecated |
|
| 604 | - */ |
|
| 605 | - public function get_invoice_quote_type() { |
|
| 602 | + /** |
|
| 603 | + * @deprecated |
|
| 604 | + */ |
|
| 605 | + public function get_invoice_quote_type() { |
|
| 606 | 606 | ucfirst( $this->get_type() ); |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
| 610 | - * Get the invoice post type. |
|
| 611 | - * |
|
| 612 | - * @since 1.0.19 |
|
| 613 | - * @param string $context View or edit context. |
|
| 614 | - * @return string |
|
| 615 | - */ |
|
| 616 | - public function get_post_type( $context = 'view' ) { |
|
| 610 | + * Get the invoice post type. |
|
| 611 | + * |
|
| 612 | + * @since 1.0.19 |
|
| 613 | + * @param string $context View or edit context. |
|
| 614 | + * @return string |
|
| 615 | + */ |
|
| 616 | + public function get_post_type( $context = 'view' ) { |
|
| 617 | 617 | return $this->get_prop( 'post_type', $context ); |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
| 621 | - * Get the invoice mode. |
|
| 622 | - * |
|
| 623 | - * @since 1.0.19 |
|
| 624 | - * @param string $context View or edit context. |
|
| 625 | - * @return string |
|
| 626 | - */ |
|
| 627 | - public function get_mode( $context = 'view' ) { |
|
| 621 | + * Get the invoice mode. |
|
| 622 | + * |
|
| 623 | + * @since 1.0.19 |
|
| 624 | + * @param string $context View or edit context. |
|
| 625 | + * @return string |
|
| 626 | + */ |
|
| 627 | + public function get_mode( $context = 'view' ) { |
|
| 628 | 628 | return $this->get_prop( 'mode', $context ); |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | - * Get the invoice path. |
|
| 633 | - * |
|
| 634 | - * @since 1.0.19 |
|
| 635 | - * @param string $context View or edit context. |
|
| 636 | - * @return string |
|
| 637 | - */ |
|
| 638 | - public function get_path( $context = 'view' ) { |
|
| 632 | + * Get the invoice path. |
|
| 633 | + * |
|
| 634 | + * @since 1.0.19 |
|
| 635 | + * @param string $context View or edit context. |
|
| 636 | + * @return string |
|
| 637 | + */ |
|
| 638 | + public function get_path( $context = 'view' ) { |
|
| 639 | 639 | $path = $this->get_prop( 'path', $context ); |
| 640 | - $prefix = wpinv_post_name_prefix( $this->get_post_type() ); |
|
| 640 | + $prefix = wpinv_post_name_prefix( $this->get_post_type() ); |
|
| 641 | 641 | |
| 642 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 643 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
| 644 | - $this->set_path( $path ); |
|
| 645 | - } |
|
| 642 | + if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 643 | + $path = sanitize_title( $prefix . $this->get_id() ); |
|
| 644 | + $this->set_path( $path ); |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | - return $path; |
|
| 647 | + return $path; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | /** |
| 651 | - * Get the invoice name/title. |
|
| 652 | - * |
|
| 653 | - * @since 1.0.19 |
|
| 654 | - * @param string $context View or edit context. |
|
| 655 | - * @return string |
|
| 656 | - */ |
|
| 657 | - public function get_name( $context = 'view' ) { |
|
| 651 | + * Get the invoice name/title. |
|
| 652 | + * |
|
| 653 | + * @since 1.0.19 |
|
| 654 | + * @param string $context View or edit context. |
|
| 655 | + * @return string |
|
| 656 | + */ |
|
| 657 | + public function get_name( $context = 'view' ) { |
|
| 658 | 658 | return $this->get_prop( 'title', $context ); |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
| 662 | - * Alias of self::get_name(). |
|
| 663 | - * |
|
| 664 | - * @since 1.0.19 |
|
| 665 | - * @param string $context View or edit context. |
|
| 666 | - * @return string |
|
| 667 | - */ |
|
| 668 | - public function get_title( $context = 'view' ) { |
|
| 669 | - return $this->get_name( $context ); |
|
| 662 | + * Alias of self::get_name(). |
|
| 663 | + * |
|
| 664 | + * @since 1.0.19 |
|
| 665 | + * @param string $context View or edit context. |
|
| 666 | + * @return string |
|
| 667 | + */ |
|
| 668 | + public function get_title( $context = 'view' ) { |
|
| 669 | + return $this->get_name( $context ); |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | /** |
| 673 | - * Get the invoice description. |
|
| 674 | - * |
|
| 675 | - * @since 1.0.19 |
|
| 676 | - * @param string $context View or edit context. |
|
| 677 | - * @return string |
|
| 678 | - */ |
|
| 679 | - public function get_description( $context = 'view' ) { |
|
| 680 | - return $this->get_prop( 'description', $context ); |
|
| 673 | + * Get the invoice description. |
|
| 674 | + * |
|
| 675 | + * @since 1.0.19 |
|
| 676 | + * @param string $context View or edit context. |
|
| 677 | + * @return string |
|
| 678 | + */ |
|
| 679 | + public function get_description( $context = 'view' ) { |
|
| 680 | + return $this->get_prop( 'description', $context ); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
| 684 | - * Alias of self::get_description(). |
|
| 685 | - * |
|
| 686 | - * @since 1.0.19 |
|
| 687 | - * @param string $context View or edit context. |
|
| 688 | - * @return string |
|
| 689 | - */ |
|
| 690 | - public function get_excerpt( $context = 'view' ) { |
|
| 691 | - return $this->get_description( $context ); |
|
| 684 | + * Alias of self::get_description(). |
|
| 685 | + * |
|
| 686 | + * @since 1.0.19 |
|
| 687 | + * @param string $context View or edit context. |
|
| 688 | + * @return string |
|
| 689 | + */ |
|
| 690 | + public function get_excerpt( $context = 'view' ) { |
|
| 691 | + return $this->get_description( $context ); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /** |
| 695 | - * Alias of self::get_description(). |
|
| 696 | - * |
|
| 697 | - * @since 1.0.19 |
|
| 698 | - * @param string $context View or edit context. |
|
| 699 | - * @return string |
|
| 700 | - */ |
|
| 701 | - public function get_summary( $context = 'view' ) { |
|
| 702 | - return $this->get_description( $context ); |
|
| 695 | + * Alias of self::get_description(). |
|
| 696 | + * |
|
| 697 | + * @since 1.0.19 |
|
| 698 | + * @param string $context View or edit context. |
|
| 699 | + * @return string |
|
| 700 | + */ |
|
| 701 | + public function get_summary( $context = 'view' ) { |
|
| 702 | + return $this->get_description( $context ); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | /** |
| 706 | - * Returns the user info. |
|
| 707 | - * |
|
| 708 | - * @since 1.0.19 |
|
| 706 | + * Returns the user info. |
|
| 707 | + * |
|
| 708 | + * @since 1.0.19 |
|
| 709 | 709 | * @param string $context View or edit context. |
| 710 | - * @return array |
|
| 711 | - */ |
|
| 710 | + * @return array |
|
| 711 | + */ |
|
| 712 | 712 | public function get_user_info( $context = 'view' ) { |
| 713 | 713 | |
| 714 | 714 | $user_info = array( |
@@ -725,616 +725,616 @@ discard block |
||
| 725 | 725 | 'company' => $this->get_company( $context ), |
| 726 | 726 | 'vat_number' => $this->get_vat_number( $context ), |
| 727 | 727 | 'discount' => $this->get_discount_code( $context ), |
| 728 | - ); |
|
| 728 | + ); |
|
| 729 | + |
|
| 730 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 731 | + |
|
| 732 | + } |
|
| 733 | + |
|
| 734 | + /** |
|
| 735 | + * Get the customer id. |
|
| 736 | + * |
|
| 737 | + * @since 1.0.19 |
|
| 738 | + * @param string $context View or edit context. |
|
| 739 | + * @return int |
|
| 740 | + */ |
|
| 741 | + public function get_author( $context = 'view' ) { |
|
| 742 | + return (int) $this->get_prop( 'author', $context ); |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + /** |
|
| 746 | + * Alias of self::get_author(). |
|
| 747 | + * |
|
| 748 | + * @since 1.0.19 |
|
| 749 | + * @param string $context View or edit context. |
|
| 750 | + * @return int |
|
| 751 | + */ |
|
| 752 | + public function get_user_id( $context = 'view' ) { |
|
| 753 | + return $this->get_author( $context ); |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + /** |
|
| 757 | + * Alias of self::get_author(). |
|
| 758 | + * |
|
| 759 | + * @since 1.0.19 |
|
| 760 | + * @param string $context View or edit context. |
|
| 761 | + * @return int |
|
| 762 | + */ |
|
| 763 | + public function get_customer_id( $context = 'view' ) { |
|
| 764 | + return $this->get_author( $context ); |
|
| 765 | + } |
|
| 729 | 766 | |
| 730 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 767 | + /** |
|
| 768 | + * Get the customer's ip. |
|
| 769 | + * |
|
| 770 | + * @since 1.0.19 |
|
| 771 | + * @param string $context View or edit context. |
|
| 772 | + * @return string |
|
| 773 | + */ |
|
| 774 | + public function get_ip( $context = 'view' ) { |
|
| 775 | + return $this->get_prop( 'user_ip', $context ); |
|
| 776 | + } |
|
| 731 | 777 | |
| 778 | + /** |
|
| 779 | + * Alias of self::get_ip(). |
|
| 780 | + * |
|
| 781 | + * @since 1.0.19 |
|
| 782 | + * @param string $context View or edit context. |
|
| 783 | + * @return string |
|
| 784 | + */ |
|
| 785 | + public function get_user_ip( $context = 'view' ) { |
|
| 786 | + return $this->get_ip( $context ); |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * Alias of self::get_ip(). |
|
| 791 | + * |
|
| 792 | + * @since 1.0.19 |
|
| 793 | + * @param string $context View or edit context. |
|
| 794 | + * @return string |
|
| 795 | + */ |
|
| 796 | + public function get_customer_ip( $context = 'view' ) { |
|
| 797 | + return $this->get_ip( $context ); |
|
| 732 | 798 | } |
| 733 | 799 | |
| 734 | 800 | /** |
| 735 | - * Get the customer id. |
|
| 736 | - * |
|
| 737 | - * @since 1.0.19 |
|
| 738 | - * @param string $context View or edit context. |
|
| 739 | - * @return int |
|
| 740 | - */ |
|
| 741 | - public function get_author( $context = 'view' ) { |
|
| 742 | - return (int) $this->get_prop( 'author', $context ); |
|
| 801 | + * Get the customer's first name. |
|
| 802 | + * |
|
| 803 | + * @since 1.0.19 |
|
| 804 | + * @param string $context View or edit context. |
|
| 805 | + * @return string |
|
| 806 | + */ |
|
| 807 | + public function get_first_name( $context = 'view' ) { |
|
| 808 | + return $this->get_prop( 'first_name', $context ); |
|
| 743 | 809 | } |
| 744 | 810 | |
| 745 | 811 | /** |
| 746 | - * Alias of self::get_author(). |
|
| 747 | - * |
|
| 748 | - * @since 1.0.19 |
|
| 749 | - * @param string $context View or edit context. |
|
| 750 | - * @return int |
|
| 751 | - */ |
|
| 752 | - public function get_user_id( $context = 'view' ) { |
|
| 753 | - return $this->get_author( $context ); |
|
| 812 | + * Alias of self::get_first_name(). |
|
| 813 | + * |
|
| 814 | + * @since 1.0.19 |
|
| 815 | + * @param string $context View or edit context. |
|
| 816 | + * @return int |
|
| 817 | + */ |
|
| 818 | + public function get_user_first_name( $context = 'view' ) { |
|
| 819 | + return $this->get_first_name( $context ); |
|
| 754 | 820 | } |
| 755 | 821 | |
| 756 | - /** |
|
| 757 | - * Alias of self::get_author(). |
|
| 758 | - * |
|
| 759 | - * @since 1.0.19 |
|
| 760 | - * @param string $context View or edit context. |
|
| 761 | - * @return int |
|
| 762 | - */ |
|
| 763 | - public function get_customer_id( $context = 'view' ) { |
|
| 764 | - return $this->get_author( $context ); |
|
| 822 | + /** |
|
| 823 | + * Alias of self::get_first_name(). |
|
| 824 | + * |
|
| 825 | + * @since 1.0.19 |
|
| 826 | + * @param string $context View or edit context. |
|
| 827 | + * @return int |
|
| 828 | + */ |
|
| 829 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 830 | + return $this->get_first_name( $context ); |
|
| 765 | 831 | } |
| 766 | 832 | |
| 767 | 833 | /** |
| 768 | - * Get the customer's ip. |
|
| 769 | - * |
|
| 770 | - * @since 1.0.19 |
|
| 771 | - * @param string $context View or edit context. |
|
| 772 | - * @return string |
|
| 773 | - */ |
|
| 774 | - public function get_ip( $context = 'view' ) { |
|
| 775 | - return $this->get_prop( 'user_ip', $context ); |
|
| 834 | + * Get the customer's last name. |
|
| 835 | + * |
|
| 836 | + * @since 1.0.19 |
|
| 837 | + * @param string $context View or edit context. |
|
| 838 | + * @return string |
|
| 839 | + */ |
|
| 840 | + public function get_last_name( $context = 'view' ) { |
|
| 841 | + return $this->get_prop( 'last_name', $context ); |
|
| 776 | 842 | } |
| 777 | 843 | |
| 778 | 844 | /** |
| 779 | - * Alias of self::get_ip(). |
|
| 780 | - * |
|
| 781 | - * @since 1.0.19 |
|
| 782 | - * @param string $context View or edit context. |
|
| 783 | - * @return string |
|
| 784 | - */ |
|
| 785 | - public function get_user_ip( $context = 'view' ) { |
|
| 786 | - return $this->get_ip( $context ); |
|
| 845 | + * Alias of self::get_last_name(). |
|
| 846 | + * |
|
| 847 | + * @since 1.0.19 |
|
| 848 | + * @param string $context View or edit context. |
|
| 849 | + * @return int |
|
| 850 | + */ |
|
| 851 | + public function get_user_last_name( $context = 'view' ) { |
|
| 852 | + return $this->get_last_name( $context ); |
|
| 787 | 853 | } |
| 788 | 854 | |
| 789 | - /** |
|
| 790 | - * Alias of self::get_ip(). |
|
| 791 | - * |
|
| 792 | - * @since 1.0.19 |
|
| 793 | - * @param string $context View or edit context. |
|
| 794 | - * @return string |
|
| 795 | - */ |
|
| 796 | - public function get_customer_ip( $context = 'view' ) { |
|
| 797 | - return $this->get_ip( $context ); |
|
| 855 | + /** |
|
| 856 | + * Alias of self::get_last_name(). |
|
| 857 | + * |
|
| 858 | + * @since 1.0.19 |
|
| 859 | + * @param string $context View or edit context. |
|
| 860 | + * @return int |
|
| 861 | + */ |
|
| 862 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 863 | + return $this->get_last_name( $context ); |
|
| 798 | 864 | } |
| 799 | 865 | |
| 800 | 866 | /** |
| 801 | - * Get the customer's first name. |
|
| 802 | - * |
|
| 803 | - * @since 1.0.19 |
|
| 804 | - * @param string $context View or edit context. |
|
| 805 | - * @return string |
|
| 806 | - */ |
|
| 807 | - public function get_first_name( $context = 'view' ) { |
|
| 808 | - return $this->get_prop( 'first_name', $context ); |
|
| 867 | + * Get the customer's full name. |
|
| 868 | + * |
|
| 869 | + * @since 1.0.19 |
|
| 870 | + * @param string $context View or edit context. |
|
| 871 | + * @return string |
|
| 872 | + */ |
|
| 873 | + public function get_full_name( $context = 'view' ) { |
|
| 874 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 809 | 875 | } |
| 810 | 876 | |
| 811 | 877 | /** |
| 812 | - * Alias of self::get_first_name(). |
|
| 813 | - * |
|
| 814 | - * @since 1.0.19 |
|
| 815 | - * @param string $context View or edit context. |
|
| 816 | - * @return int |
|
| 817 | - */ |
|
| 818 | - public function get_user_first_name( $context = 'view' ) { |
|
| 819 | - return $this->get_first_name( $context ); |
|
| 878 | + * Alias of self::get_full_name(). |
|
| 879 | + * |
|
| 880 | + * @since 1.0.19 |
|
| 881 | + * @param string $context View or edit context. |
|
| 882 | + * @return int |
|
| 883 | + */ |
|
| 884 | + public function get_user_full_name( $context = 'view' ) { |
|
| 885 | + return $this->get_full_name( $context ); |
|
| 820 | 886 | } |
| 821 | 887 | |
| 822 | - /** |
|
| 823 | - * Alias of self::get_first_name(). |
|
| 824 | - * |
|
| 825 | - * @since 1.0.19 |
|
| 826 | - * @param string $context View or edit context. |
|
| 827 | - * @return int |
|
| 828 | - */ |
|
| 829 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 830 | - return $this->get_first_name( $context ); |
|
| 888 | + /** |
|
| 889 | + * Alias of self::get_full_name(). |
|
| 890 | + * |
|
| 891 | + * @since 1.0.19 |
|
| 892 | + * @param string $context View or edit context. |
|
| 893 | + * @return int |
|
| 894 | + */ |
|
| 895 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 896 | + return $this->get_full_name( $context ); |
|
| 831 | 897 | } |
| 832 | 898 | |
| 833 | 899 | /** |
| 834 | - * Get the customer's last name. |
|
| 835 | - * |
|
| 836 | - * @since 1.0.19 |
|
| 837 | - * @param string $context View or edit context. |
|
| 838 | - * @return string |
|
| 839 | - */ |
|
| 840 | - public function get_last_name( $context = 'view' ) { |
|
| 841 | - return $this->get_prop( 'last_name', $context ); |
|
| 900 | + * Get the customer's phone number. |
|
| 901 | + * |
|
| 902 | + * @since 1.0.19 |
|
| 903 | + * @param string $context View or edit context. |
|
| 904 | + * @return string |
|
| 905 | + */ |
|
| 906 | + public function get_phone( $context = 'view' ) { |
|
| 907 | + return $this->get_prop( 'phone', $context ); |
|
| 842 | 908 | } |
| 843 | 909 | |
| 844 | 910 | /** |
| 845 | - * Alias of self::get_last_name(). |
|
| 846 | - * |
|
| 847 | - * @since 1.0.19 |
|
| 848 | - * @param string $context View or edit context. |
|
| 849 | - * @return int |
|
| 850 | - */ |
|
| 851 | - public function get_user_last_name( $context = 'view' ) { |
|
| 852 | - return $this->get_last_name( $context ); |
|
| 911 | + * Alias of self::get_phone(). |
|
| 912 | + * |
|
| 913 | + * @since 1.0.19 |
|
| 914 | + * @param string $context View or edit context. |
|
| 915 | + * @return int |
|
| 916 | + */ |
|
| 917 | + public function get_phone_number( $context = 'view' ) { |
|
| 918 | + return $this->get_phone( $context ); |
|
| 853 | 919 | } |
| 854 | 920 | |
| 855 | 921 | /** |
| 856 | - * Alias of self::get_last_name(). |
|
| 857 | - * |
|
| 858 | - * @since 1.0.19 |
|
| 859 | - * @param string $context View or edit context. |
|
| 860 | - * @return int |
|
| 861 | - */ |
|
| 862 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 863 | - return $this->get_last_name( $context ); |
|
| 922 | + * Alias of self::get_phone(). |
|
| 923 | + * |
|
| 924 | + * @since 1.0.19 |
|
| 925 | + * @param string $context View or edit context. |
|
| 926 | + * @return int |
|
| 927 | + */ |
|
| 928 | + public function get_user_phone( $context = 'view' ) { |
|
| 929 | + return $this->get_phone( $context ); |
|
| 864 | 930 | } |
| 865 | 931 | |
| 866 | 932 | /** |
| 867 | - * Get the customer's full name. |
|
| 868 | - * |
|
| 869 | - * @since 1.0.19 |
|
| 870 | - * @param string $context View or edit context. |
|
| 871 | - * @return string |
|
| 872 | - */ |
|
| 873 | - public function get_full_name( $context = 'view' ) { |
|
| 874 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 933 | + * Alias of self::get_phone(). |
|
| 934 | + * |
|
| 935 | + * @since 1.0.19 |
|
| 936 | + * @param string $context View or edit context. |
|
| 937 | + * @return int |
|
| 938 | + */ |
|
| 939 | + public function get_customer_phone( $context = 'view' ) { |
|
| 940 | + return $this->get_phone( $context ); |
|
| 941 | + } |
|
| 942 | + |
|
| 943 | + /** |
|
| 944 | + * Get the customer's email address. |
|
| 945 | + * |
|
| 946 | + * @since 1.0.19 |
|
| 947 | + * @param string $context View or edit context. |
|
| 948 | + * @return string |
|
| 949 | + */ |
|
| 950 | + public function get_email( $context = 'view' ) { |
|
| 951 | + return $this->get_prop( 'email', $context ); |
|
| 952 | + } |
|
| 953 | + |
|
| 954 | + /** |
|
| 955 | + * Alias of self::get_email(). |
|
| 956 | + * |
|
| 957 | + * @since 1.0.19 |
|
| 958 | + * @param string $context View or edit context. |
|
| 959 | + * @return string |
|
| 960 | + */ |
|
| 961 | + public function get_email_address( $context = 'view' ) { |
|
| 962 | + return $this->get_email( $context ); |
|
| 963 | + } |
|
| 964 | + |
|
| 965 | + /** |
|
| 966 | + * Alias of self::get_email(). |
|
| 967 | + * |
|
| 968 | + * @since 1.0.19 |
|
| 969 | + * @param string $context View or edit context. |
|
| 970 | + * @return int |
|
| 971 | + */ |
|
| 972 | + public function get_user_email( $context = 'view' ) { |
|
| 973 | + return $this->get_email( $context ); |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + /** |
|
| 977 | + * Alias of self::get_email(). |
|
| 978 | + * |
|
| 979 | + * @since 1.0.19 |
|
| 980 | + * @param string $context View or edit context. |
|
| 981 | + * @return int |
|
| 982 | + */ |
|
| 983 | + public function get_customer_email( $context = 'view' ) { |
|
| 984 | + return $this->get_email( $context ); |
|
| 985 | + } |
|
| 986 | + |
|
| 987 | + /** |
|
| 988 | + * Get the customer's country. |
|
| 989 | + * |
|
| 990 | + * @since 1.0.19 |
|
| 991 | + * @param string $context View or edit context. |
|
| 992 | + * @return string |
|
| 993 | + */ |
|
| 994 | + public function get_country( $context = 'view' ) { |
|
| 995 | + $country = $this->get_prop( 'country', $context ); |
|
| 996 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 997 | + } |
|
| 998 | + |
|
| 999 | + /** |
|
| 1000 | + * Alias of self::get_country(). |
|
| 1001 | + * |
|
| 1002 | + * @since 1.0.19 |
|
| 1003 | + * @param string $context View or edit context. |
|
| 1004 | + * @return int |
|
| 1005 | + */ |
|
| 1006 | + public function get_user_country( $context = 'view' ) { |
|
| 1007 | + return $this->get_country( $context ); |
|
| 1008 | + } |
|
| 1009 | + |
|
| 1010 | + /** |
|
| 1011 | + * Alias of self::get_country(). |
|
| 1012 | + * |
|
| 1013 | + * @since 1.0.19 |
|
| 1014 | + * @param string $context View or edit context. |
|
| 1015 | + * @return int |
|
| 1016 | + */ |
|
| 1017 | + public function get_customer_country( $context = 'view' ) { |
|
| 1018 | + return $this->get_country( $context ); |
|
| 875 | 1019 | } |
| 876 | 1020 | |
| 877 | 1021 | /** |
| 878 | - * Alias of self::get_full_name(). |
|
| 879 | - * |
|
| 880 | - * @since 1.0.19 |
|
| 881 | - * @param string $context View or edit context. |
|
| 882 | - * @return int |
|
| 883 | - */ |
|
| 884 | - public function get_user_full_name( $context = 'view' ) { |
|
| 885 | - return $this->get_full_name( $context ); |
|
| 1022 | + * Get the customer's state. |
|
| 1023 | + * |
|
| 1024 | + * @since 1.0.19 |
|
| 1025 | + * @param string $context View or edit context. |
|
| 1026 | + * @return string |
|
| 1027 | + */ |
|
| 1028 | + public function get_state( $context = 'view' ) { |
|
| 1029 | + $state = $this->get_prop( 'state', $context ); |
|
| 1030 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 886 | 1031 | } |
| 887 | 1032 | |
| 888 | 1033 | /** |
| 889 | - * Alias of self::get_full_name(). |
|
| 890 | - * |
|
| 891 | - * @since 1.0.19 |
|
| 892 | - * @param string $context View or edit context. |
|
| 893 | - * @return int |
|
| 894 | - */ |
|
| 895 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 896 | - return $this->get_full_name( $context ); |
|
| 1034 | + * Alias of self::get_state(). |
|
| 1035 | + * |
|
| 1036 | + * @since 1.0.19 |
|
| 1037 | + * @param string $context View or edit context. |
|
| 1038 | + * @return int |
|
| 1039 | + */ |
|
| 1040 | + public function get_user_state( $context = 'view' ) { |
|
| 1041 | + return $this->get_state( $context ); |
|
| 897 | 1042 | } |
| 898 | 1043 | |
| 899 | 1044 | /** |
| 900 | - * Get the customer's phone number. |
|
| 901 | - * |
|
| 902 | - * @since 1.0.19 |
|
| 903 | - * @param string $context View or edit context. |
|
| 904 | - * @return string |
|
| 905 | - */ |
|
| 906 | - public function get_phone( $context = 'view' ) { |
|
| 907 | - return $this->get_prop( 'phone', $context ); |
|
| 1045 | + * Alias of self::get_state(). |
|
| 1046 | + * |
|
| 1047 | + * @since 1.0.19 |
|
| 1048 | + * @param string $context View or edit context. |
|
| 1049 | + * @return int |
|
| 1050 | + */ |
|
| 1051 | + public function get_customer_state( $context = 'view' ) { |
|
| 1052 | + return $this->get_state( $context ); |
|
| 908 | 1053 | } |
| 909 | 1054 | |
| 910 | 1055 | /** |
| 911 | - * Alias of self::get_phone(). |
|
| 912 | - * |
|
| 913 | - * @since 1.0.19 |
|
| 914 | - * @param string $context View or edit context. |
|
| 915 | - * @return int |
|
| 916 | - */ |
|
| 917 | - public function get_phone_number( $context = 'view' ) { |
|
| 918 | - return $this->get_phone( $context ); |
|
| 1056 | + * Get the customer's city. |
|
| 1057 | + * |
|
| 1058 | + * @since 1.0.19 |
|
| 1059 | + * @param string $context View or edit context. |
|
| 1060 | + * @return string |
|
| 1061 | + */ |
|
| 1062 | + public function get_city( $context = 'view' ) { |
|
| 1063 | + return $this->get_prop( 'city', $context ); |
|
| 919 | 1064 | } |
| 920 | 1065 | |
| 921 | 1066 | /** |
| 922 | - * Alias of self::get_phone(). |
|
| 923 | - * |
|
| 924 | - * @since 1.0.19 |
|
| 925 | - * @param string $context View or edit context. |
|
| 926 | - * @return int |
|
| 927 | - */ |
|
| 928 | - public function get_user_phone( $context = 'view' ) { |
|
| 929 | - return $this->get_phone( $context ); |
|
| 1067 | + * Alias of self::get_city(). |
|
| 1068 | + * |
|
| 1069 | + * @since 1.0.19 |
|
| 1070 | + * @param string $context View or edit context. |
|
| 1071 | + * @return string |
|
| 1072 | + */ |
|
| 1073 | + public function get_user_city( $context = 'view' ) { |
|
| 1074 | + return $this->get_city( $context ); |
|
| 930 | 1075 | } |
| 931 | 1076 | |
| 932 | 1077 | /** |
| 933 | - * Alias of self::get_phone(). |
|
| 934 | - * |
|
| 935 | - * @since 1.0.19 |
|
| 936 | - * @param string $context View or edit context. |
|
| 937 | - * @return int |
|
| 938 | - */ |
|
| 939 | - public function get_customer_phone( $context = 'view' ) { |
|
| 940 | - return $this->get_phone( $context ); |
|
| 1078 | + * Alias of self::get_city(). |
|
| 1079 | + * |
|
| 1080 | + * @since 1.0.19 |
|
| 1081 | + * @param string $context View or edit context. |
|
| 1082 | + * @return string |
|
| 1083 | + */ |
|
| 1084 | + public function get_customer_city( $context = 'view' ) { |
|
| 1085 | + return $this->get_city( $context ); |
|
| 941 | 1086 | } |
| 942 | 1087 | |
| 943 | 1088 | /** |
| 944 | - * Get the customer's email address. |
|
| 945 | - * |
|
| 946 | - * @since 1.0.19 |
|
| 947 | - * @param string $context View or edit context. |
|
| 948 | - * @return string |
|
| 949 | - */ |
|
| 950 | - public function get_email( $context = 'view' ) { |
|
| 951 | - return $this->get_prop( 'email', $context ); |
|
| 1089 | + * Get the customer's zip. |
|
| 1090 | + * |
|
| 1091 | + * @since 1.0.19 |
|
| 1092 | + * @param string $context View or edit context. |
|
| 1093 | + * @return string |
|
| 1094 | + */ |
|
| 1095 | + public function get_zip( $context = 'view' ) { |
|
| 1096 | + return $this->get_prop( 'zip', $context ); |
|
| 952 | 1097 | } |
| 953 | 1098 | |
| 954 | 1099 | /** |
| 955 | - * Alias of self::get_email(). |
|
| 956 | - * |
|
| 957 | - * @since 1.0.19 |
|
| 958 | - * @param string $context View or edit context. |
|
| 959 | - * @return string |
|
| 960 | - */ |
|
| 961 | - public function get_email_address( $context = 'view' ) { |
|
| 962 | - return $this->get_email( $context ); |
|
| 1100 | + * Alias of self::get_zip(). |
|
| 1101 | + * |
|
| 1102 | + * @since 1.0.19 |
|
| 1103 | + * @param string $context View or edit context. |
|
| 1104 | + * @return string |
|
| 1105 | + */ |
|
| 1106 | + public function get_user_zip( $context = 'view' ) { |
|
| 1107 | + return $this->get_zip( $context ); |
|
| 963 | 1108 | } |
| 964 | 1109 | |
| 965 | 1110 | /** |
| 966 | - * Alias of self::get_email(). |
|
| 967 | - * |
|
| 968 | - * @since 1.0.19 |
|
| 969 | - * @param string $context View or edit context. |
|
| 970 | - * @return int |
|
| 971 | - */ |
|
| 972 | - public function get_user_email( $context = 'view' ) { |
|
| 973 | - return $this->get_email( $context ); |
|
| 1111 | + * Alias of self::get_zip(). |
|
| 1112 | + * |
|
| 1113 | + * @since 1.0.19 |
|
| 1114 | + * @param string $context View or edit context. |
|
| 1115 | + * @return string |
|
| 1116 | + */ |
|
| 1117 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1118 | + return $this->get_zip( $context ); |
|
| 974 | 1119 | } |
| 975 | 1120 | |
| 976 | 1121 | /** |
| 977 | - * Alias of self::get_email(). |
|
| 978 | - * |
|
| 979 | - * @since 1.0.19 |
|
| 980 | - * @param string $context View or edit context. |
|
| 981 | - * @return int |
|
| 982 | - */ |
|
| 983 | - public function get_customer_email( $context = 'view' ) { |
|
| 984 | - return $this->get_email( $context ); |
|
| 1122 | + * Get the customer's company. |
|
| 1123 | + * |
|
| 1124 | + * @since 1.0.19 |
|
| 1125 | + * @param string $context View or edit context. |
|
| 1126 | + * @return string |
|
| 1127 | + */ |
|
| 1128 | + public function get_company( $context = 'view' ) { |
|
| 1129 | + return $this->get_prop( 'company', $context ); |
|
| 985 | 1130 | } |
| 986 | 1131 | |
| 987 | 1132 | /** |
| 988 | - * Get the customer's country. |
|
| 989 | - * |
|
| 990 | - * @since 1.0.19 |
|
| 991 | - * @param string $context View or edit context. |
|
| 992 | - * @return string |
|
| 993 | - */ |
|
| 994 | - public function get_country( $context = 'view' ) { |
|
| 995 | - $country = $this->get_prop( 'country', $context ); |
|
| 996 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1133 | + * Alias of self::get_company(). |
|
| 1134 | + * |
|
| 1135 | + * @since 1.0.19 |
|
| 1136 | + * @param string $context View or edit context. |
|
| 1137 | + * @return string |
|
| 1138 | + */ |
|
| 1139 | + public function get_user_company( $context = 'view' ) { |
|
| 1140 | + return $this->get_company( $context ); |
|
| 997 | 1141 | } |
| 998 | 1142 | |
| 999 | 1143 | /** |
| 1000 | - * Alias of self::get_country(). |
|
| 1001 | - * |
|
| 1002 | - * @since 1.0.19 |
|
| 1003 | - * @param string $context View or edit context. |
|
| 1004 | - * @return int |
|
| 1005 | - */ |
|
| 1006 | - public function get_user_country( $context = 'view' ) { |
|
| 1007 | - return $this->get_country( $context ); |
|
| 1144 | + * Alias of self::get_company(). |
|
| 1145 | + * |
|
| 1146 | + * @since 1.0.19 |
|
| 1147 | + * @param string $context View or edit context. |
|
| 1148 | + * @return string |
|
| 1149 | + */ |
|
| 1150 | + public function get_customer_company( $context = 'view' ) { |
|
| 1151 | + return $this->get_company( $context ); |
|
| 1008 | 1152 | } |
| 1009 | 1153 | |
| 1010 | 1154 | /** |
| 1011 | - * Alias of self::get_country(). |
|
| 1012 | - * |
|
| 1013 | - * @since 1.0.19 |
|
| 1014 | - * @param string $context View or edit context. |
|
| 1015 | - * @return int |
|
| 1016 | - */ |
|
| 1017 | - public function get_customer_country( $context = 'view' ) { |
|
| 1018 | - return $this->get_country( $context ); |
|
| 1155 | + * Get the customer's vat number. |
|
| 1156 | + * |
|
| 1157 | + * @since 1.0.19 |
|
| 1158 | + * @param string $context View or edit context. |
|
| 1159 | + * @return string |
|
| 1160 | + */ |
|
| 1161 | + public function get_vat_number( $context = 'view' ) { |
|
| 1162 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1019 | 1163 | } |
| 1020 | 1164 | |
| 1021 | 1165 | /** |
| 1022 | - * Get the customer's state. |
|
| 1023 | - * |
|
| 1024 | - * @since 1.0.19 |
|
| 1025 | - * @param string $context View or edit context. |
|
| 1026 | - * @return string |
|
| 1027 | - */ |
|
| 1028 | - public function get_state( $context = 'view' ) { |
|
| 1029 | - $state = $this->get_prop( 'state', $context ); |
|
| 1030 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1166 | + * Alias of self::get_vat_number(). |
|
| 1167 | + * |
|
| 1168 | + * @since 1.0.19 |
|
| 1169 | + * @param string $context View or edit context. |
|
| 1170 | + * @return string |
|
| 1171 | + */ |
|
| 1172 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1173 | + return $this->get_vat_number( $context ); |
|
| 1031 | 1174 | } |
| 1032 | 1175 | |
| 1033 | 1176 | /** |
| 1034 | - * Alias of self::get_state(). |
|
| 1035 | - * |
|
| 1036 | - * @since 1.0.19 |
|
| 1037 | - * @param string $context View or edit context. |
|
| 1038 | - * @return int |
|
| 1039 | - */ |
|
| 1040 | - public function get_user_state( $context = 'view' ) { |
|
| 1041 | - return $this->get_state( $context ); |
|
| 1177 | + * Alias of self::get_vat_number(). |
|
| 1178 | + * |
|
| 1179 | + * @since 1.0.19 |
|
| 1180 | + * @param string $context View or edit context. |
|
| 1181 | + * @return string |
|
| 1182 | + */ |
|
| 1183 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1184 | + return $this->get_vat_number( $context ); |
|
| 1042 | 1185 | } |
| 1043 | 1186 | |
| 1044 | 1187 | /** |
| 1045 | - * Alias of self::get_state(). |
|
| 1046 | - * |
|
| 1047 | - * @since 1.0.19 |
|
| 1048 | - * @param string $context View or edit context. |
|
| 1049 | - * @return int |
|
| 1050 | - */ |
|
| 1051 | - public function get_customer_state( $context = 'view' ) { |
|
| 1052 | - return $this->get_state( $context ); |
|
| 1188 | + * Get the customer's vat rate. |
|
| 1189 | + * |
|
| 1190 | + * @since 1.0.19 |
|
| 1191 | + * @param string $context View or edit context. |
|
| 1192 | + * @return string |
|
| 1193 | + */ |
|
| 1194 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1195 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1053 | 1196 | } |
| 1054 | 1197 | |
| 1055 | 1198 | /** |
| 1056 | - * Get the customer's city. |
|
| 1057 | - * |
|
| 1058 | - * @since 1.0.19 |
|
| 1059 | - * @param string $context View or edit context. |
|
| 1060 | - * @return string |
|
| 1061 | - */ |
|
| 1062 | - public function get_city( $context = 'view' ) { |
|
| 1063 | - return $this->get_prop( 'city', $context ); |
|
| 1199 | + * Alias of self::get_vat_rate(). |
|
| 1200 | + * |
|
| 1201 | + * @since 1.0.19 |
|
| 1202 | + * @param string $context View or edit context. |
|
| 1203 | + * @return string |
|
| 1204 | + */ |
|
| 1205 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1206 | + return $this->get_vat_rate( $context ); |
|
| 1064 | 1207 | } |
| 1065 | 1208 | |
| 1066 | 1209 | /** |
| 1067 | - * Alias of self::get_city(). |
|
| 1068 | - * |
|
| 1069 | - * @since 1.0.19 |
|
| 1070 | - * @param string $context View or edit context. |
|
| 1071 | - * @return string |
|
| 1072 | - */ |
|
| 1073 | - public function get_user_city( $context = 'view' ) { |
|
| 1074 | - return $this->get_city( $context ); |
|
| 1210 | + * Alias of self::get_vat_rate(). |
|
| 1211 | + * |
|
| 1212 | + * @since 1.0.19 |
|
| 1213 | + * @param string $context View or edit context. |
|
| 1214 | + * @return string |
|
| 1215 | + */ |
|
| 1216 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1217 | + return $this->get_vat_rate( $context ); |
|
| 1075 | 1218 | } |
| 1076 | 1219 | |
| 1077 | 1220 | /** |
| 1078 | - * Alias of self::get_city(). |
|
| 1079 | - * |
|
| 1080 | - * @since 1.0.19 |
|
| 1081 | - * @param string $context View or edit context. |
|
| 1082 | - * @return string |
|
| 1083 | - */ |
|
| 1084 | - public function get_customer_city( $context = 'view' ) { |
|
| 1085 | - return $this->get_city( $context ); |
|
| 1221 | + * Get the customer's address. |
|
| 1222 | + * |
|
| 1223 | + * @since 1.0.19 |
|
| 1224 | + * @param string $context View or edit context. |
|
| 1225 | + * @return string |
|
| 1226 | + */ |
|
| 1227 | + public function get_address( $context = 'view' ) { |
|
| 1228 | + return $this->get_prop( 'address', $context ); |
|
| 1086 | 1229 | } |
| 1087 | 1230 | |
| 1088 | 1231 | /** |
| 1089 | - * Get the customer's zip. |
|
| 1090 | - * |
|
| 1091 | - * @since 1.0.19 |
|
| 1092 | - * @param string $context View or edit context. |
|
| 1093 | - * @return string |
|
| 1094 | - */ |
|
| 1095 | - public function get_zip( $context = 'view' ) { |
|
| 1096 | - return $this->get_prop( 'zip', $context ); |
|
| 1232 | + * Alias of self::get_address(). |
|
| 1233 | + * |
|
| 1234 | + * @since 1.0.19 |
|
| 1235 | + * @param string $context View or edit context. |
|
| 1236 | + * @return string |
|
| 1237 | + */ |
|
| 1238 | + public function get_user_address( $context = 'view' ) { |
|
| 1239 | + return $this->get_address( $context ); |
|
| 1097 | 1240 | } |
| 1098 | 1241 | |
| 1099 | 1242 | /** |
| 1100 | - * Alias of self::get_zip(). |
|
| 1101 | - * |
|
| 1102 | - * @since 1.0.19 |
|
| 1103 | - * @param string $context View or edit context. |
|
| 1104 | - * @return string |
|
| 1105 | - */ |
|
| 1106 | - public function get_user_zip( $context = 'view' ) { |
|
| 1107 | - return $this->get_zip( $context ); |
|
| 1243 | + * Alias of self::get_address(). |
|
| 1244 | + * |
|
| 1245 | + * @since 1.0.19 |
|
| 1246 | + * @param string $context View or edit context. |
|
| 1247 | + * @return string |
|
| 1248 | + */ |
|
| 1249 | + public function get_customer_address( $context = 'view' ) { |
|
| 1250 | + return $this->get_address( $context ); |
|
| 1108 | 1251 | } |
| 1109 | 1252 | |
| 1110 | 1253 | /** |
| 1111 | - * Alias of self::get_zip(). |
|
| 1112 | - * |
|
| 1113 | - * @since 1.0.19 |
|
| 1114 | - * @param string $context View or edit context. |
|
| 1115 | - * @return string |
|
| 1116 | - */ |
|
| 1117 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1118 | - return $this->get_zip( $context ); |
|
| 1254 | + * Get whether the customer has viewed the invoice or not. |
|
| 1255 | + * |
|
| 1256 | + * @since 1.0.19 |
|
| 1257 | + * @param string $context View or edit context. |
|
| 1258 | + * @return bool |
|
| 1259 | + */ |
|
| 1260 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1261 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1119 | 1262 | } |
| 1120 | 1263 | |
| 1121 | 1264 | /** |
| 1122 | - * Get the customer's company. |
|
| 1123 | - * |
|
| 1124 | - * @since 1.0.19 |
|
| 1125 | - * @param string $context View or edit context. |
|
| 1126 | - * @return string |
|
| 1127 | - */ |
|
| 1128 | - public function get_company( $context = 'view' ) { |
|
| 1129 | - return $this->get_prop( 'company', $context ); |
|
| 1265 | + * Get other recipients for invoice communications. |
|
| 1266 | + * |
|
| 1267 | + * @since 1.0.19 |
|
| 1268 | + * @param string $context View or edit context. |
|
| 1269 | + * @return bool |
|
| 1270 | + */ |
|
| 1271 | + public function get_email_cc( $context = 'view' ) { |
|
| 1272 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1130 | 1273 | } |
| 1131 | 1274 | |
| 1132 | 1275 | /** |
| 1133 | - * Alias of self::get_company(). |
|
| 1134 | - * |
|
| 1135 | - * @since 1.0.19 |
|
| 1136 | - * @param string $context View or edit context. |
|
| 1137 | - * @return string |
|
| 1138 | - */ |
|
| 1139 | - public function get_user_company( $context = 'view' ) { |
|
| 1140 | - return $this->get_company( $context ); |
|
| 1276 | + * Get invoice template. |
|
| 1277 | + * |
|
| 1278 | + * @since 1.0.19 |
|
| 1279 | + * @param string $context View or edit context. |
|
| 1280 | + * @return bool |
|
| 1281 | + */ |
|
| 1282 | + public function get_template( $context = 'view' ) { |
|
| 1283 | + return $this->get_prop( 'template', $context ); |
|
| 1141 | 1284 | } |
| 1142 | 1285 | |
| 1143 | 1286 | /** |
| 1144 | - * Alias of self::get_company(). |
|
| 1145 | - * |
|
| 1146 | - * @since 1.0.19 |
|
| 1147 | - * @param string $context View or edit context. |
|
| 1148 | - * @return string |
|
| 1149 | - */ |
|
| 1150 | - public function get_customer_company( $context = 'view' ) { |
|
| 1151 | - return $this->get_company( $context ); |
|
| 1287 | + * Get invoice source. |
|
| 1288 | + * |
|
| 1289 | + * @since 1.0.19 |
|
| 1290 | + * @param string $context View or edit context. |
|
| 1291 | + * @return bool |
|
| 1292 | + */ |
|
| 1293 | + public function get_created_via( $context = 'view' ) { |
|
| 1294 | + return $this->get_prop( 'created_via', $context ); |
|
| 1152 | 1295 | } |
| 1153 | 1296 | |
| 1154 | 1297 | /** |
| 1155 | - * Get the customer's vat number. |
|
| 1156 | - * |
|
| 1157 | - * @since 1.0.19 |
|
| 1158 | - * @param string $context View or edit context. |
|
| 1159 | - * @return string |
|
| 1160 | - */ |
|
| 1161 | - public function get_vat_number( $context = 'view' ) { |
|
| 1162 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1298 | + * Get whether the customer has confirmed their address. |
|
| 1299 | + * |
|
| 1300 | + * @since 1.0.19 |
|
| 1301 | + * @param string $context View or edit context. |
|
| 1302 | + * @return bool |
|
| 1303 | + */ |
|
| 1304 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1305 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1163 | 1306 | } |
| 1164 | 1307 | |
| 1165 | 1308 | /** |
| 1166 | - * Alias of self::get_vat_number(). |
|
| 1167 | - * |
|
| 1168 | - * @since 1.0.19 |
|
| 1169 | - * @param string $context View or edit context. |
|
| 1170 | - * @return string |
|
| 1171 | - */ |
|
| 1172 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1173 | - return $this->get_vat_number( $context ); |
|
| 1309 | + * Alias of self::get_address_confirmed(). |
|
| 1310 | + * |
|
| 1311 | + * @since 1.0.19 |
|
| 1312 | + * @param string $context View or edit context. |
|
| 1313 | + * @return bool |
|
| 1314 | + */ |
|
| 1315 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1316 | + return $this->get_address_confirmed( $context ); |
|
| 1174 | 1317 | } |
| 1175 | 1318 | |
| 1176 | 1319 | /** |
| 1177 | - * Alias of self::get_vat_number(). |
|
| 1178 | - * |
|
| 1179 | - * @since 1.0.19 |
|
| 1180 | - * @param string $context View or edit context. |
|
| 1181 | - * @return string |
|
| 1182 | - */ |
|
| 1183 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1184 | - return $this->get_vat_number( $context ); |
|
| 1320 | + * Alias of self::get_address(). |
|
| 1321 | + * |
|
| 1322 | + * @since 1.0.19 |
|
| 1323 | + * @param string $context View or edit context. |
|
| 1324 | + * @return bool |
|
| 1325 | + */ |
|
| 1326 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1327 | + return $this->get_address_confirmed( $context ); |
|
| 1185 | 1328 | } |
| 1186 | 1329 | |
| 1187 | 1330 | /** |
| 1188 | - * Get the customer's vat rate. |
|
| 1189 | - * |
|
| 1190 | - * @since 1.0.19 |
|
| 1191 | - * @param string $context View or edit context. |
|
| 1192 | - * @return string |
|
| 1193 | - */ |
|
| 1194 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1195 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1196 | - } |
|
| 1197 | - |
|
| 1198 | - /** |
|
| 1199 | - * Alias of self::get_vat_rate(). |
|
| 1200 | - * |
|
| 1201 | - * @since 1.0.19 |
|
| 1202 | - * @param string $context View or edit context. |
|
| 1203 | - * @return string |
|
| 1204 | - */ |
|
| 1205 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1206 | - return $this->get_vat_rate( $context ); |
|
| 1207 | - } |
|
| 1208 | - |
|
| 1209 | - /** |
|
| 1210 | - * Alias of self::get_vat_rate(). |
|
| 1211 | - * |
|
| 1212 | - * @since 1.0.19 |
|
| 1213 | - * @param string $context View or edit context. |
|
| 1214 | - * @return string |
|
| 1215 | - */ |
|
| 1216 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1217 | - return $this->get_vat_rate( $context ); |
|
| 1218 | - } |
|
| 1219 | - |
|
| 1220 | - /** |
|
| 1221 | - * Get the customer's address. |
|
| 1222 | - * |
|
| 1223 | - * @since 1.0.19 |
|
| 1224 | - * @param string $context View or edit context. |
|
| 1225 | - * @return string |
|
| 1226 | - */ |
|
| 1227 | - public function get_address( $context = 'view' ) { |
|
| 1228 | - return $this->get_prop( 'address', $context ); |
|
| 1229 | - } |
|
| 1230 | - |
|
| 1231 | - /** |
|
| 1232 | - * Alias of self::get_address(). |
|
| 1233 | - * |
|
| 1234 | - * @since 1.0.19 |
|
| 1235 | - * @param string $context View or edit context. |
|
| 1236 | - * @return string |
|
| 1237 | - */ |
|
| 1238 | - public function get_user_address( $context = 'view' ) { |
|
| 1239 | - return $this->get_address( $context ); |
|
| 1240 | - } |
|
| 1241 | - |
|
| 1242 | - /** |
|
| 1243 | - * Alias of self::get_address(). |
|
| 1244 | - * |
|
| 1245 | - * @since 1.0.19 |
|
| 1246 | - * @param string $context View or edit context. |
|
| 1247 | - * @return string |
|
| 1248 | - */ |
|
| 1249 | - public function get_customer_address( $context = 'view' ) { |
|
| 1250 | - return $this->get_address( $context ); |
|
| 1251 | - } |
|
| 1252 | - |
|
| 1253 | - /** |
|
| 1254 | - * Get whether the customer has viewed the invoice or not. |
|
| 1255 | - * |
|
| 1256 | - * @since 1.0.19 |
|
| 1257 | - * @param string $context View or edit context. |
|
| 1258 | - * @return bool |
|
| 1259 | - */ |
|
| 1260 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1261 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1262 | - } |
|
| 1263 | - |
|
| 1264 | - /** |
|
| 1265 | - * Get other recipients for invoice communications. |
|
| 1266 | - * |
|
| 1267 | - * @since 1.0.19 |
|
| 1268 | - * @param string $context View or edit context. |
|
| 1269 | - * @return bool |
|
| 1270 | - */ |
|
| 1271 | - public function get_email_cc( $context = 'view' ) { |
|
| 1272 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1273 | - } |
|
| 1274 | - |
|
| 1275 | - /** |
|
| 1276 | - * Get invoice template. |
|
| 1277 | - * |
|
| 1278 | - * @since 1.0.19 |
|
| 1279 | - * @param string $context View or edit context. |
|
| 1280 | - * @return bool |
|
| 1281 | - */ |
|
| 1282 | - public function get_template( $context = 'view' ) { |
|
| 1283 | - return $this->get_prop( 'template', $context ); |
|
| 1284 | - } |
|
| 1285 | - |
|
| 1286 | - /** |
|
| 1287 | - * Get invoice source. |
|
| 1288 | - * |
|
| 1289 | - * @since 1.0.19 |
|
| 1290 | - * @param string $context View or edit context. |
|
| 1291 | - * @return bool |
|
| 1292 | - */ |
|
| 1293 | - public function get_created_via( $context = 'view' ) { |
|
| 1294 | - return $this->get_prop( 'created_via', $context ); |
|
| 1295 | - } |
|
| 1296 | - |
|
| 1297 | - /** |
|
| 1298 | - * Get whether the customer has confirmed their address. |
|
| 1299 | - * |
|
| 1300 | - * @since 1.0.19 |
|
| 1301 | - * @param string $context View or edit context. |
|
| 1302 | - * @return bool |
|
| 1303 | - */ |
|
| 1304 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1305 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1306 | - } |
|
| 1307 | - |
|
| 1308 | - /** |
|
| 1309 | - * Alias of self::get_address_confirmed(). |
|
| 1310 | - * |
|
| 1311 | - * @since 1.0.19 |
|
| 1312 | - * @param string $context View or edit context. |
|
| 1313 | - * @return bool |
|
| 1314 | - */ |
|
| 1315 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1316 | - return $this->get_address_confirmed( $context ); |
|
| 1317 | - } |
|
| 1318 | - |
|
| 1319 | - /** |
|
| 1320 | - * Alias of self::get_address(). |
|
| 1321 | - * |
|
| 1322 | - * @since 1.0.19 |
|
| 1323 | - * @param string $context View or edit context. |
|
| 1324 | - * @return bool |
|
| 1325 | - */ |
|
| 1326 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1327 | - return $this->get_address_confirmed( $context ); |
|
| 1328 | - } |
|
| 1329 | - |
|
| 1330 | - /** |
|
| 1331 | - * Get the invoice subtotal. |
|
| 1332 | - * |
|
| 1333 | - * @since 1.0.19 |
|
| 1334 | - * @param string $context View or edit context. |
|
| 1335 | - * @return float |
|
| 1336 | - */ |
|
| 1337 | - public function get_subtotal( $context = 'view' ) { |
|
| 1331 | + * Get the invoice subtotal. |
|
| 1332 | + * |
|
| 1333 | + * @since 1.0.19 |
|
| 1334 | + * @param string $context View or edit context. |
|
| 1335 | + * @return float |
|
| 1336 | + */ |
|
| 1337 | + public function get_subtotal( $context = 'view' ) { |
|
| 1338 | 1338 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1339 | 1339 | |
| 1340 | 1340 | // Backwards compatibility. |
@@ -1346,165 +1346,165 @@ discard block |
||
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | /** |
| 1349 | - * Get the invoice discount total. |
|
| 1350 | - * |
|
| 1351 | - * @since 1.0.19 |
|
| 1352 | - * @param string $context View or edit context. |
|
| 1353 | - * @return float |
|
| 1354 | - */ |
|
| 1355 | - public function get_total_discount( $context = 'view' ) { |
|
| 1356 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1349 | + * Get the invoice discount total. |
|
| 1350 | + * |
|
| 1351 | + * @since 1.0.19 |
|
| 1352 | + * @param string $context View or edit context. |
|
| 1353 | + * @return float |
|
| 1354 | + */ |
|
| 1355 | + public function get_total_discount( $context = 'view' ) { |
|
| 1356 | + return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | 1359 | /** |
| 1360 | - * Get the invoice tax total. |
|
| 1361 | - * |
|
| 1362 | - * @since 1.0.19 |
|
| 1363 | - * @param string $context View or edit context. |
|
| 1364 | - * @return float |
|
| 1365 | - */ |
|
| 1366 | - public function get_total_tax( $context = 'view' ) { |
|
| 1367 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1368 | - } |
|
| 1360 | + * Get the invoice tax total. |
|
| 1361 | + * |
|
| 1362 | + * @since 1.0.19 |
|
| 1363 | + * @param string $context View or edit context. |
|
| 1364 | + * @return float |
|
| 1365 | + */ |
|
| 1366 | + public function get_total_tax( $context = 'view' ) { |
|
| 1367 | + return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1368 | + } |
|
| 1369 | 1369 | |
| 1370 | - /** |
|
| 1371 | - * @deprecated |
|
| 1372 | - */ |
|
| 1373 | - public function get_final_tax( $currency = false ) { |
|
| 1374 | - $tax = $this->get_total_tax(); |
|
| 1370 | + /** |
|
| 1371 | + * @deprecated |
|
| 1372 | + */ |
|
| 1373 | + public function get_final_tax( $currency = false ) { |
|
| 1374 | + $tax = $this->get_total_tax(); |
|
| 1375 | 1375 | |
| 1376 | 1376 | if ( $currency ) { |
| 1377 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1377 | + return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | return $tax; |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | /** |
| 1384 | - * Get the invoice fees total. |
|
| 1385 | - * |
|
| 1386 | - * @since 1.0.19 |
|
| 1387 | - * @param string $context View or edit context. |
|
| 1388 | - * @return float |
|
| 1389 | - */ |
|
| 1390 | - public function get_total_fees( $context = 'view' ) { |
|
| 1391 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1384 | + * Get the invoice fees total. |
|
| 1385 | + * |
|
| 1386 | + * @since 1.0.19 |
|
| 1387 | + * @param string $context View or edit context. |
|
| 1388 | + * @return float |
|
| 1389 | + */ |
|
| 1390 | + public function get_total_fees( $context = 'view' ) { |
|
| 1391 | + return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | /** |
| 1395 | - * Alias for self::get_total_fees(). |
|
| 1396 | - * |
|
| 1397 | - * @since 1.0.19 |
|
| 1398 | - * @param string $context View or edit context. |
|
| 1399 | - * @return float |
|
| 1400 | - */ |
|
| 1401 | - public function get_fees_total( $context = 'view' ) { |
|
| 1402 | - return $this->get_total_fees( $context ); |
|
| 1395 | + * Alias for self::get_total_fees(). |
|
| 1396 | + * |
|
| 1397 | + * @since 1.0.19 |
|
| 1398 | + * @param string $context View or edit context. |
|
| 1399 | + * @return float |
|
| 1400 | + */ |
|
| 1401 | + public function get_fees_total( $context = 'view' ) { |
|
| 1402 | + return $this->get_total_fees( $context ); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | /** |
| 1406 | - * Get the invoice total. |
|
| 1407 | - * |
|
| 1408 | - * @since 1.0.19 |
|
| 1406 | + * Get the invoice total. |
|
| 1407 | + * |
|
| 1408 | + * @since 1.0.19 |
|
| 1409 | 1409 | * @return float |
| 1410 | - */ |
|
| 1411 | - public function get_total() { |
|
| 1412 | - $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1413 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1414 | - } |
|
| 1410 | + */ |
|
| 1411 | + public function get_total() { |
|
| 1412 | + $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1413 | + return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1414 | + } |
|
| 1415 | 1415 | |
| 1416 | - /** |
|
| 1417 | - * Get the invoice totals. |
|
| 1418 | - * |
|
| 1419 | - * @since 1.0.19 |
|
| 1416 | + /** |
|
| 1417 | + * Get the invoice totals. |
|
| 1418 | + * |
|
| 1419 | + * @since 1.0.19 |
|
| 1420 | 1420 | * @return float |
| 1421 | - */ |
|
| 1422 | - public function get_totals() { |
|
| 1423 | - return $this->totals; |
|
| 1421 | + */ |
|
| 1422 | + public function get_totals() { |
|
| 1423 | + return $this->totals; |
|
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | /** |
| 1427 | - * Get the initial invoice total. |
|
| 1428 | - * |
|
| 1429 | - * @since 1.0.19 |
|
| 1427 | + * Get the initial invoice total. |
|
| 1428 | + * |
|
| 1429 | + * @since 1.0.19 |
|
| 1430 | 1430 | * @param string $context View or edit context. |
| 1431 | 1431 | * @return float |
| 1432 | - */ |
|
| 1432 | + */ |
|
| 1433 | 1433 | public function get_initial_total() { |
| 1434 | 1434 | |
| 1435 | - if ( empty( $this->totals ) ) { |
|
| 1436 | - $this->recalculate_total(); |
|
| 1437 | - } |
|
| 1435 | + if ( empty( $this->totals ) ) { |
|
| 1436 | + $this->recalculate_total(); |
|
| 1437 | + } |
|
| 1438 | 1438 | |
| 1439 | - $tax = $this->totals['tax']['initial']; |
|
| 1440 | - $fee = $this->totals['fee']['initial']; |
|
| 1441 | - $discount = $this->totals['discount']['initial']; |
|
| 1442 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1443 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1439 | + $tax = $this->totals['tax']['initial']; |
|
| 1440 | + $fee = $this->totals['fee']['initial']; |
|
| 1441 | + $discount = $this->totals['discount']['initial']; |
|
| 1442 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1443 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1444 | 1444 | |
| 1445 | - if ( 0 > $total ) { |
|
| 1446 | - $total = 0; |
|
| 1447 | - } |
|
| 1445 | + if ( 0 > $total ) { |
|
| 1446 | + $total = 0; |
|
| 1447 | + } |
|
| 1448 | 1448 | |
| 1449 | 1449 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1450 | - } |
|
| 1450 | + } |
|
| 1451 | 1451 | |
| 1452 | - /** |
|
| 1453 | - * Get the recurring invoice total. |
|
| 1454 | - * |
|
| 1455 | - * @since 1.0.19 |
|
| 1452 | + /** |
|
| 1453 | + * Get the recurring invoice total. |
|
| 1454 | + * |
|
| 1455 | + * @since 1.0.19 |
|
| 1456 | 1456 | * @param string $context View or edit context. |
| 1457 | 1457 | * @return float |
| 1458 | - */ |
|
| 1458 | + */ |
|
| 1459 | 1459 | public function get_recurring_total() { |
| 1460 | 1460 | |
| 1461 | - if ( empty( $this->totals ) ) { |
|
| 1462 | - $this->recalculate_total(); |
|
| 1463 | - } |
|
| 1461 | + if ( empty( $this->totals ) ) { |
|
| 1462 | + $this->recalculate_total(); |
|
| 1463 | + } |
|
| 1464 | 1464 | |
| 1465 | - $tax = $this->totals['tax']['recurring']; |
|
| 1466 | - $fee = $this->totals['fee']['recurring']; |
|
| 1467 | - $discount = $this->totals['discount']['recurring']; |
|
| 1468 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1469 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1465 | + $tax = $this->totals['tax']['recurring']; |
|
| 1466 | + $fee = $this->totals['fee']['recurring']; |
|
| 1467 | + $discount = $this->totals['discount']['recurring']; |
|
| 1468 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1469 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1470 | 1470 | |
| 1471 | - if ( 0 > $total ) { |
|
| 1472 | - $total = 0; |
|
| 1473 | - } |
|
| 1471 | + if ( 0 > $total ) { |
|
| 1472 | + $total = 0; |
|
| 1473 | + } |
|
| 1474 | 1474 | |
| 1475 | 1475 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1476 | - } |
|
| 1476 | + } |
|
| 1477 | 1477 | |
| 1478 | - /** |
|
| 1479 | - * Returns recurring payment details. |
|
| 1480 | - * |
|
| 1481 | - * @since 1.0.19 |
|
| 1478 | + /** |
|
| 1479 | + * Returns recurring payment details. |
|
| 1480 | + * |
|
| 1481 | + * @since 1.0.19 |
|
| 1482 | 1482 | * @param string $field Optionally provide a field to return. |
| 1483 | - * @param string $currency Whether to include the currency. |
|
| 1483 | + * @param string $currency Whether to include the currency. |
|
| 1484 | 1484 | * @return float |
| 1485 | - */ |
|
| 1485 | + */ |
|
| 1486 | 1486 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1487 | 1487 | |
| 1488 | - // Maybe recalculate totals. |
|
| 1489 | - if ( empty( $this->totals ) ) { |
|
| 1490 | - $this->recalculate_total(); |
|
| 1491 | - } |
|
| 1488 | + // Maybe recalculate totals. |
|
| 1489 | + if ( empty( $this->totals ) ) { |
|
| 1490 | + $this->recalculate_total(); |
|
| 1491 | + } |
|
| 1492 | 1492 | |
| 1493 | - // Prepare recurring totals. |
|
| 1493 | + // Prepare recurring totals. |
|
| 1494 | 1494 | $data = apply_filters( |
| 1495 | - 'wpinv_get_invoice_recurring_details', |
|
| 1496 | - array( |
|
| 1497 | - 'cart_details' => $this->get_cart_details(), |
|
| 1498 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1499 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1500 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1501 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1502 | - 'total' => $this->get_recurring_total(), |
|
| 1503 | - ), |
|
| 1504 | - $this, |
|
| 1505 | - $field, |
|
| 1506 | - $currency |
|
| 1507 | - ); |
|
| 1495 | + 'wpinv_get_invoice_recurring_details', |
|
| 1496 | + array( |
|
| 1497 | + 'cart_details' => $this->get_cart_details(), |
|
| 1498 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1499 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1500 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1501 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1502 | + 'total' => $this->get_recurring_total(), |
|
| 1503 | + ), |
|
| 1504 | + $this, |
|
| 1505 | + $field, |
|
| 1506 | + $currency |
|
| 1507 | + ); |
|
| 1508 | 1508 | |
| 1509 | 1509 | if ( isset( $data[$field] ) ) { |
| 1510 | 1510 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1514,156 +1514,156 @@ discard block |
||
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | /** |
| 1517 | - * Get the invoice fees. |
|
| 1518 | - * |
|
| 1519 | - * @since 1.0.19 |
|
| 1520 | - * @param string $context View or edit context. |
|
| 1521 | - * @return array |
|
| 1522 | - */ |
|
| 1523 | - public function get_fees( $context = 'view' ) { |
|
| 1524 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1517 | + * Get the invoice fees. |
|
| 1518 | + * |
|
| 1519 | + * @since 1.0.19 |
|
| 1520 | + * @param string $context View or edit context. |
|
| 1521 | + * @return array |
|
| 1522 | + */ |
|
| 1523 | + public function get_fees( $context = 'view' ) { |
|
| 1524 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | /** |
| 1528 | - * Get the invoice discounts. |
|
| 1529 | - * |
|
| 1530 | - * @since 1.0.19 |
|
| 1531 | - * @param string $context View or edit context. |
|
| 1532 | - * @return array |
|
| 1533 | - */ |
|
| 1534 | - public function get_discounts( $context = 'view' ) { |
|
| 1535 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1528 | + * Get the invoice discounts. |
|
| 1529 | + * |
|
| 1530 | + * @since 1.0.19 |
|
| 1531 | + * @param string $context View or edit context. |
|
| 1532 | + * @return array |
|
| 1533 | + */ |
|
| 1534 | + public function get_discounts( $context = 'view' ) { |
|
| 1535 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | /** |
| 1539 | - * Get the invoice taxes. |
|
| 1540 | - * |
|
| 1541 | - * @since 1.0.19 |
|
| 1542 | - * @param string $context View or edit context. |
|
| 1543 | - * @return array |
|
| 1544 | - */ |
|
| 1545 | - public function get_taxes( $context = 'view' ) { |
|
| 1546 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1539 | + * Get the invoice taxes. |
|
| 1540 | + * |
|
| 1541 | + * @since 1.0.19 |
|
| 1542 | + * @param string $context View or edit context. |
|
| 1543 | + * @return array |
|
| 1544 | + */ |
|
| 1545 | + public function get_taxes( $context = 'view' ) { |
|
| 1546 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | 1549 | /** |
| 1550 | - * Get the invoice items. |
|
| 1551 | - * |
|
| 1552 | - * @since 1.0.19 |
|
| 1553 | - * @param string $context View or edit context. |
|
| 1554 | - * @return GetPaid_Form_Item[] |
|
| 1555 | - */ |
|
| 1556 | - public function get_items( $context = 'view' ) { |
|
| 1550 | + * Get the invoice items. |
|
| 1551 | + * |
|
| 1552 | + * @since 1.0.19 |
|
| 1553 | + * @param string $context View or edit context. |
|
| 1554 | + * @return GetPaid_Form_Item[] |
|
| 1555 | + */ |
|
| 1556 | + public function get_items( $context = 'view' ) { |
|
| 1557 | 1557 | return $this->get_prop( 'items', $context ); |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | 1560 | /** |
| 1561 | - * Get the invoice's payment form. |
|
| 1562 | - * |
|
| 1563 | - * @since 1.0.19 |
|
| 1564 | - * @param string $context View or edit context. |
|
| 1565 | - * @return int |
|
| 1566 | - */ |
|
| 1567 | - public function get_payment_form( $context = 'view' ) { |
|
| 1568 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1561 | + * Get the invoice's payment form. |
|
| 1562 | + * |
|
| 1563 | + * @since 1.0.19 |
|
| 1564 | + * @param string $context View or edit context. |
|
| 1565 | + * @return int |
|
| 1566 | + */ |
|
| 1567 | + public function get_payment_form( $context = 'view' ) { |
|
| 1568 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | /** |
| 1572 | - * Get the invoice's submission id. |
|
| 1573 | - * |
|
| 1574 | - * @since 1.0.19 |
|
| 1575 | - * @param string $context View or edit context. |
|
| 1576 | - * @return string |
|
| 1577 | - */ |
|
| 1578 | - public function get_submission_id( $context = 'view' ) { |
|
| 1579 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1572 | + * Get the invoice's submission id. |
|
| 1573 | + * |
|
| 1574 | + * @since 1.0.19 |
|
| 1575 | + * @param string $context View or edit context. |
|
| 1576 | + * @return string |
|
| 1577 | + */ |
|
| 1578 | + public function get_submission_id( $context = 'view' ) { |
|
| 1579 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | 1582 | /** |
| 1583 | - * Get the invoice's discount code. |
|
| 1584 | - * |
|
| 1585 | - * @since 1.0.19 |
|
| 1586 | - * @param string $context View or edit context. |
|
| 1587 | - * @return string |
|
| 1588 | - */ |
|
| 1589 | - public function get_discount_code( $context = 'view' ) { |
|
| 1590 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1583 | + * Get the invoice's discount code. |
|
| 1584 | + * |
|
| 1585 | + * @since 1.0.19 |
|
| 1586 | + * @param string $context View or edit context. |
|
| 1587 | + * @return string |
|
| 1588 | + */ |
|
| 1589 | + public function get_discount_code( $context = 'view' ) { |
|
| 1590 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | /** |
| 1594 | - * Get the invoice's gateway. |
|
| 1595 | - * |
|
| 1596 | - * @since 1.0.19 |
|
| 1597 | - * @param string $context View or edit context. |
|
| 1598 | - * @return string |
|
| 1599 | - */ |
|
| 1600 | - public function get_gateway( $context = 'view' ) { |
|
| 1601 | - return $this->get_prop( 'gateway', $context ); |
|
| 1594 | + * Get the invoice's gateway. |
|
| 1595 | + * |
|
| 1596 | + * @since 1.0.19 |
|
| 1597 | + * @param string $context View or edit context. |
|
| 1598 | + * @return string |
|
| 1599 | + */ |
|
| 1600 | + public function get_gateway( $context = 'view' ) { |
|
| 1601 | + return $this->get_prop( 'gateway', $context ); |
|
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | /** |
| 1605 | - * Get the invoice's gateway display title. |
|
| 1606 | - * |
|
| 1607 | - * @since 1.0.19 |
|
| 1608 | - * @return string |
|
| 1609 | - */ |
|
| 1605 | + * Get the invoice's gateway display title. |
|
| 1606 | + * |
|
| 1607 | + * @since 1.0.19 |
|
| 1608 | + * @return string |
|
| 1609 | + */ |
|
| 1610 | 1610 | public function get_gateway_title() { |
| 1611 | 1611 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1612 | 1612 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | /** |
| 1616 | - * Get the invoice's transaction id. |
|
| 1617 | - * |
|
| 1618 | - * @since 1.0.19 |
|
| 1619 | - * @param string $context View or edit context. |
|
| 1620 | - * @return string |
|
| 1621 | - */ |
|
| 1622 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1623 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1616 | + * Get the invoice's transaction id. |
|
| 1617 | + * |
|
| 1618 | + * @since 1.0.19 |
|
| 1619 | + * @param string $context View or edit context. |
|
| 1620 | + * @return string |
|
| 1621 | + */ |
|
| 1622 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1623 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | 1626 | /** |
| 1627 | - * Get the invoice's currency. |
|
| 1628 | - * |
|
| 1629 | - * @since 1.0.19 |
|
| 1630 | - * @param string $context View or edit context. |
|
| 1631 | - * @return string |
|
| 1632 | - */ |
|
| 1633 | - public function get_currency( $context = 'view' ) { |
|
| 1627 | + * Get the invoice's currency. |
|
| 1628 | + * |
|
| 1629 | + * @since 1.0.19 |
|
| 1630 | + * @param string $context View or edit context. |
|
| 1631 | + * @return string |
|
| 1632 | + */ |
|
| 1633 | + public function get_currency( $context = 'view' ) { |
|
| 1634 | 1634 | $currency = $this->get_prop( 'currency', $context ); |
| 1635 | 1635 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | /** |
| 1639 | - * Checks if we are charging taxes for this invoice. |
|
| 1640 | - * |
|
| 1641 | - * @since 1.0.19 |
|
| 1642 | - * @param string $context View or edit context. |
|
| 1643 | - * @return bool |
|
| 1644 | - */ |
|
| 1645 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1639 | + * Checks if we are charging taxes for this invoice. |
|
| 1640 | + * |
|
| 1641 | + * @since 1.0.19 |
|
| 1642 | + * @param string $context View or edit context. |
|
| 1643 | + * @return bool |
|
| 1644 | + */ |
|
| 1645 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1646 | 1646 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | 1649 | /** |
| 1650 | - * Retrieves the subscription id for an invoice. |
|
| 1651 | - * |
|
| 1652 | - * @since 1.0.19 |
|
| 1653 | - * @param string $context View or edit context. |
|
| 1654 | - * @return int |
|
| 1655 | - */ |
|
| 1650 | + * Retrieves the subscription id for an invoice. |
|
| 1651 | + * |
|
| 1652 | + * @since 1.0.19 |
|
| 1653 | + * @param string $context View or edit context. |
|
| 1654 | + * @return int |
|
| 1655 | + */ |
|
| 1656 | 1656 | public function get_subscription_id( $context = 'view' ) { |
| 1657 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1658 | - } |
|
| 1659 | - |
|
| 1660 | - /** |
|
| 1661 | - * Retrieves the remote subscription id for an invoice. |
|
| 1662 | - * |
|
| 1663 | - * @since 1.0.19 |
|
| 1664 | - * @param string $context View or edit context. |
|
| 1665 | - * @return int |
|
| 1666 | - */ |
|
| 1657 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + /** |
|
| 1661 | + * Retrieves the remote subscription id for an invoice. |
|
| 1662 | + * |
|
| 1663 | + * @since 1.0.19 |
|
| 1664 | + * @param string $context View or edit context. |
|
| 1665 | + * @return int |
|
| 1666 | + */ |
|
| 1667 | 1667 | public function get_remote_subscription_id( $context = 'view' ) { |
| 1668 | 1668 | $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
| 1669 | 1669 | |
@@ -1676,12 +1676,12 @@ discard block |
||
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | 1678 | /** |
| 1679 | - * Retrieves the payment meta for an invoice. |
|
| 1680 | - * |
|
| 1681 | - * @since 1.0.19 |
|
| 1682 | - * @param string $context View or edit context. |
|
| 1683 | - * @return array |
|
| 1684 | - */ |
|
| 1679 | + * Retrieves the payment meta for an invoice. |
|
| 1680 | + * |
|
| 1681 | + * @since 1.0.19 |
|
| 1682 | + * @param string $context View or edit context. |
|
| 1683 | + * @return array |
|
| 1684 | + */ |
|
| 1685 | 1685 | public function get_payment_meta( $context = 'view' ) { |
| 1686 | 1686 | |
| 1687 | 1687 | return array( |
@@ -1701,31 +1701,31 @@ discard block |
||
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | 1703 | /** |
| 1704 | - * Retrieves the cart details for an invoice. |
|
| 1705 | - * |
|
| 1706 | - * @since 1.0.19 |
|
| 1707 | - * @return array |
|
| 1708 | - */ |
|
| 1704 | + * Retrieves the cart details for an invoice. |
|
| 1705 | + * |
|
| 1706 | + * @since 1.0.19 |
|
| 1707 | + * @return array |
|
| 1708 | + */ |
|
| 1709 | 1709 | public function get_cart_details() { |
| 1710 | 1710 | $items = $this->get_items(); |
| 1711 | 1711 | $cart_details = array(); |
| 1712 | 1712 | |
| 1713 | 1713 | foreach ( $items as $item_id => $item ) { |
| 1714 | - $item->invoice_id = $this->get_id(); |
|
| 1714 | + $item->invoice_id = $this->get_id(); |
|
| 1715 | 1715 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1716 | 1716 | } |
| 1717 | 1717 | |
| 1718 | 1718 | return $cart_details; |
| 1719 | - } |
|
| 1719 | + } |
|
| 1720 | 1720 | |
| 1721 | - /** |
|
| 1722 | - * Retrieves the recurring item. |
|
| 1723 | - * |
|
| 1724 | - * @return null|GetPaid_Form_Item|int |
|
| 1725 | - */ |
|
| 1726 | - public function get_recurring( $object = false ) { |
|
| 1721 | + /** |
|
| 1722 | + * Retrieves the recurring item. |
|
| 1723 | + * |
|
| 1724 | + * @return null|GetPaid_Form_Item|int |
|
| 1725 | + */ |
|
| 1726 | + public function get_recurring( $object = false ) { |
|
| 1727 | 1727 | |
| 1728 | - // Are we returning an object? |
|
| 1728 | + // Are we returning an object? |
|
| 1729 | 1729 | if ( $object ) { |
| 1730 | 1730 | return $this->get_item( $this->recurring_item ); |
| 1731 | 1731 | } |
@@ -1733,100 +1733,100 @@ discard block |
||
| 1733 | 1733 | return $this->recurring_item; |
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | - /** |
|
| 1737 | - * Retrieves the subscription name. |
|
| 1738 | - * |
|
| 1739 | - * @since 1.0.19 |
|
| 1740 | - * @return string |
|
| 1741 | - */ |
|
| 1742 | - public function get_subscription_name() { |
|
| 1736 | + /** |
|
| 1737 | + * Retrieves the subscription name. |
|
| 1738 | + * |
|
| 1739 | + * @since 1.0.19 |
|
| 1740 | + * @return string |
|
| 1741 | + */ |
|
| 1742 | + public function get_subscription_name() { |
|
| 1743 | 1743 | |
| 1744 | - // Retrieve the recurring name |
|
| 1744 | + // Retrieve the recurring name |
|
| 1745 | 1745 | $item = $this->get_recurring( true ); |
| 1746 | 1746 | |
| 1747 | - // Abort if it does not exist. |
|
| 1747 | + // Abort if it does not exist. |
|
| 1748 | 1748 | if ( empty( $item ) ) { |
| 1749 | 1749 | return ''; |
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | - // Return the item name. |
|
| 1752 | + // Return the item name. |
|
| 1753 | 1753 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1754 | - } |
|
| 1755 | - |
|
| 1756 | - /** |
|
| 1757 | - * Retrieves the view url. |
|
| 1758 | - * |
|
| 1759 | - * @since 1.0.19 |
|
| 1760 | - * @return string |
|
| 1761 | - */ |
|
| 1762 | - public function get_view_url() { |
|
| 1754 | + } |
|
| 1755 | + |
|
| 1756 | + /** |
|
| 1757 | + * Retrieves the view url. |
|
| 1758 | + * |
|
| 1759 | + * @since 1.0.19 |
|
| 1760 | + * @return string |
|
| 1761 | + */ |
|
| 1762 | + public function get_view_url() { |
|
| 1763 | 1763 | $invoice_url = get_permalink( $this->get_id() ); |
| 1764 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1764 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1765 | 1765 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1766 | - } |
|
| 1766 | + } |
|
| 1767 | 1767 | |
| 1768 | - /** |
|
| 1769 | - * Retrieves the payment url. |
|
| 1770 | - * |
|
| 1771 | - * @since 1.0.19 |
|
| 1772 | - * @return string |
|
| 1773 | - */ |
|
| 1774 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1768 | + /** |
|
| 1769 | + * Retrieves the payment url. |
|
| 1770 | + * |
|
| 1771 | + * @since 1.0.19 |
|
| 1772 | + * @return string |
|
| 1773 | + */ |
|
| 1774 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1775 | 1775 | |
| 1776 | - // Retrieve the checkout url. |
|
| 1776 | + // Retrieve the checkout url. |
|
| 1777 | 1777 | $pay_url = wpinv_get_checkout_uri(); |
| 1778 | 1778 | |
| 1779 | - // Maybe force ssl. |
|
| 1779 | + // Maybe force ssl. |
|
| 1780 | 1780 | if ( is_ssl() ) { |
| 1781 | 1781 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | - // Add the invoice key. |
|
| 1785 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1784 | + // Add the invoice key. |
|
| 1785 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1786 | 1786 | |
| 1787 | - // (Maybe?) add a secret |
|
| 1787 | + // (Maybe?) add a secret |
|
| 1788 | 1788 | if ( $secret ) { |
| 1789 | 1789 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | 1792 | return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
| 1793 | - } |
|
| 1793 | + } |
|
| 1794 | 1794 | |
| 1795 | - /** |
|
| 1796 | - * Retrieves the receipt url. |
|
| 1797 | - * |
|
| 1798 | - * @since 1.0.19 |
|
| 1799 | - * @return string |
|
| 1800 | - */ |
|
| 1801 | - public function get_receipt_url() { |
|
| 1802 | - |
|
| 1803 | - // Retrieve the checkout url. |
|
| 1795 | + /** |
|
| 1796 | + * Retrieves the receipt url. |
|
| 1797 | + * |
|
| 1798 | + * @since 1.0.19 |
|
| 1799 | + * @return string |
|
| 1800 | + */ |
|
| 1801 | + public function get_receipt_url() { |
|
| 1802 | + |
|
| 1803 | + // Retrieve the checkout url. |
|
| 1804 | 1804 | $receipt_url = wpinv_get_success_page_uri(); |
| 1805 | 1805 | |
| 1806 | - // Maybe force ssl. |
|
| 1806 | + // Maybe force ssl. |
|
| 1807 | 1807 | if ( is_ssl() ) { |
| 1808 | 1808 | $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
| 1809 | 1809 | } |
| 1810 | 1810 | |
| 1811 | - // Add the invoice key. |
|
| 1812 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1811 | + // Add the invoice key. |
|
| 1812 | + $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1813 | 1813 | |
| 1814 | 1814 | return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | 1817 | /** |
| 1818 | - * Magic method for accessing invoice properties. |
|
| 1819 | - * |
|
| 1820 | - * @since 1.0.15 |
|
| 1821 | - * @access public |
|
| 1822 | - * |
|
| 1823 | - * @param string $key Discount data to retrieve |
|
| 1824 | - * @param string $context View or edit context. |
|
| 1825 | - * @return mixed Value of the given invoice property (if set). |
|
| 1826 | - */ |
|
| 1827 | - public function get( $key, $context = 'view' ) { |
|
| 1818 | + * Magic method for accessing invoice properties. |
|
| 1819 | + * |
|
| 1820 | + * @since 1.0.15 |
|
| 1821 | + * @access public |
|
| 1822 | + * |
|
| 1823 | + * @param string $key Discount data to retrieve |
|
| 1824 | + * @param string $context View or edit context. |
|
| 1825 | + * @return mixed Value of the given invoice property (if set). |
|
| 1826 | + */ |
|
| 1827 | + public function get( $key, $context = 'view' ) { |
|
| 1828 | 1828 | return $this->get_prop( $key, $context ); |
| 1829 | - } |
|
| 1829 | + } |
|
| 1830 | 1830 | |
| 1831 | 1831 | /* |
| 1832 | 1832 | |-------------------------------------------------------------------------- |
@@ -1839,130 +1839,130 @@ discard block |
||
| 1839 | 1839 | */ |
| 1840 | 1840 | |
| 1841 | 1841 | /** |
| 1842 | - * Magic method for setting invoice properties. |
|
| 1843 | - * |
|
| 1844 | - * @since 1.0.19 |
|
| 1845 | - * @access public |
|
| 1846 | - * |
|
| 1847 | - * @param string $key Discount data to retrieve |
|
| 1848 | - * @param mixed $value new value. |
|
| 1849 | - * @return mixed Value of the given invoice property (if set). |
|
| 1850 | - */ |
|
| 1851 | - public function set( $key, $value ) { |
|
| 1842 | + * Magic method for setting invoice properties. |
|
| 1843 | + * |
|
| 1844 | + * @since 1.0.19 |
|
| 1845 | + * @access public |
|
| 1846 | + * |
|
| 1847 | + * @param string $key Discount data to retrieve |
|
| 1848 | + * @param mixed $value new value. |
|
| 1849 | + * @return mixed Value of the given invoice property (if set). |
|
| 1850 | + */ |
|
| 1851 | + public function set( $key, $value ) { |
|
| 1852 | 1852 | |
| 1853 | 1853 | $setter = "set_$key"; |
| 1854 | 1854 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1855 | 1855 | $this->{$setter}( $value ); |
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | - } |
|
| 1858 | + } |
|
| 1859 | 1859 | |
| 1860 | - /** |
|
| 1861 | - * Sets item status. |
|
| 1862 | - * |
|
| 1863 | - * @since 1.0.19 |
|
| 1864 | - * @param string $new_status New status. |
|
| 1865 | - * @param string $note Optional note to add. |
|
| 1866 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1867 | - * @return array details of change. |
|
| 1868 | - */ |
|
| 1869 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1870 | - $old_status = $this->get_status(); |
|
| 1860 | + /** |
|
| 1861 | + * Sets item status. |
|
| 1862 | + * |
|
| 1863 | + * @since 1.0.19 |
|
| 1864 | + * @param string $new_status New status. |
|
| 1865 | + * @param string $note Optional note to add. |
|
| 1866 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1867 | + * @return array details of change. |
|
| 1868 | + */ |
|
| 1869 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1870 | + $old_status = $this->get_status(); |
|
| 1871 | 1871 | |
| 1872 | - $statuses = $this->get_all_statuses(); |
|
| 1872 | + $statuses = $this->get_all_statuses(); |
|
| 1873 | 1873 | |
| 1874 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1875 | - unset( $statuses[ 'draft' ] ); |
|
| 1876 | - } |
|
| 1874 | + if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1875 | + unset( $statuses[ 'draft' ] ); |
|
| 1876 | + } |
|
| 1877 | 1877 | |
| 1878 | - $this->set_prop( 'status', $new_status ); |
|
| 1878 | + $this->set_prop( 'status', $new_status ); |
|
| 1879 | 1879 | |
| 1880 | - // If setting the status, ensure it's set to a valid status. |
|
| 1881 | - if ( true === $this->object_read ) { |
|
| 1880 | + // If setting the status, ensure it's set to a valid status. |
|
| 1881 | + if ( true === $this->object_read ) { |
|
| 1882 | 1882 | |
| 1883 | - // Only allow valid new status. |
|
| 1884 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1885 | - $new_status = 'wpi-pending'; |
|
| 1886 | - } |
|
| 1883 | + // Only allow valid new status. |
|
| 1884 | + if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1885 | + $new_status = 'wpi-pending'; |
|
| 1886 | + } |
|
| 1887 | 1887 | |
| 1888 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1889 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1890 | - $old_status = 'wpi-pending'; |
|
| 1891 | - } |
|
| 1888 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1889 | + if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1890 | + $old_status = 'wpi-pending'; |
|
| 1891 | + } |
|
| 1892 | 1892 | |
| 1893 | - // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1894 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1895 | - $old_status = 'wpi-pending'; |
|
| 1896 | - } |
|
| 1893 | + // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1894 | + if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1895 | + $old_status = 'wpi-pending'; |
|
| 1896 | + } |
|
| 1897 | 1897 | |
| 1898 | - } |
|
| 1898 | + } |
|
| 1899 | 1899 | |
| 1900 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1901 | - $this->status_transition = array( |
|
| 1902 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1903 | - 'to' => $new_status, |
|
| 1904 | - 'note' => $note, |
|
| 1905 | - 'manual' => (bool) $manual_update, |
|
| 1906 | - ); |
|
| 1900 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1901 | + $this->status_transition = array( |
|
| 1902 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1903 | + 'to' => $new_status, |
|
| 1904 | + 'note' => $note, |
|
| 1905 | + 'manual' => (bool) $manual_update, |
|
| 1906 | + ); |
|
| 1907 | 1907 | |
| 1908 | - if ( $manual_update ) { |
|
| 1909 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1910 | - } |
|
| 1908 | + if ( $manual_update ) { |
|
| 1909 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1910 | + } |
|
| 1911 | 1911 | |
| 1912 | - $this->maybe_set_date_paid(); |
|
| 1912 | + $this->maybe_set_date_paid(); |
|
| 1913 | 1913 | |
| 1914 | - } |
|
| 1914 | + } |
|
| 1915 | 1915 | |
| 1916 | - return array( |
|
| 1917 | - 'from' => $old_status, |
|
| 1918 | - 'to' => $new_status, |
|
| 1919 | - ); |
|
| 1920 | - } |
|
| 1916 | + return array( |
|
| 1917 | + 'from' => $old_status, |
|
| 1918 | + 'to' => $new_status, |
|
| 1919 | + ); |
|
| 1920 | + } |
|
| 1921 | 1921 | |
| 1922 | - /** |
|
| 1923 | - * Maybe set date paid. |
|
| 1924 | - * |
|
| 1925 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 1926 | - * order status. |
|
| 1927 | - * |
|
| 1928 | - * @since 1.0.19 |
|
| 1929 | - */ |
|
| 1930 | - public function maybe_set_date_paid() { |
|
| 1922 | + /** |
|
| 1923 | + * Maybe set date paid. |
|
| 1924 | + * |
|
| 1925 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 1926 | + * order status. |
|
| 1927 | + * |
|
| 1928 | + * @since 1.0.19 |
|
| 1929 | + */ |
|
| 1930 | + public function maybe_set_date_paid() { |
|
| 1931 | 1931 | |
| 1932 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1933 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1934 | - } |
|
| 1935 | - } |
|
| 1932 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1933 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1934 | + } |
|
| 1935 | + } |
|
| 1936 | 1936 | |
| 1937 | 1937 | /** |
| 1938 | - * Set parent invoice ID. |
|
| 1939 | - * |
|
| 1940 | - * @since 1.0.19 |
|
| 1941 | - */ |
|
| 1942 | - public function set_parent_id( $value ) { |
|
| 1943 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1944 | - return; |
|
| 1945 | - } |
|
| 1946 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1938 | + * Set parent invoice ID. |
|
| 1939 | + * |
|
| 1940 | + * @since 1.0.19 |
|
| 1941 | + */ |
|
| 1942 | + public function set_parent_id( $value ) { |
|
| 1943 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1944 | + return; |
|
| 1945 | + } |
|
| 1946 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1947 | 1947 | } |
| 1948 | 1948 | |
| 1949 | 1949 | /** |
| 1950 | - * Set plugin version when the invoice was created. |
|
| 1951 | - * |
|
| 1952 | - * @since 1.0.19 |
|
| 1953 | - */ |
|
| 1954 | - public function set_version( $value ) { |
|
| 1955 | - $this->set_prop( 'version', $value ); |
|
| 1950 | + * Set plugin version when the invoice was created. |
|
| 1951 | + * |
|
| 1952 | + * @since 1.0.19 |
|
| 1953 | + */ |
|
| 1954 | + public function set_version( $value ) { |
|
| 1955 | + $this->set_prop( 'version', $value ); |
|
| 1956 | 1956 | } |
| 1957 | - |
|
| 1958 | - /** |
|
| 1959 | - * Set date when the invoice was created. |
|
| 1960 | - * |
|
| 1961 | - * @since 1.0.19 |
|
| 1962 | - * @param string $value Value to set. |
|
| 1957 | + |
|
| 1958 | + /** |
|
| 1959 | + * Set date when the invoice was created. |
|
| 1960 | + * |
|
| 1961 | + * @since 1.0.19 |
|
| 1962 | + * @param string $value Value to set. |
|
| 1963 | 1963 | * @return bool Whether or not the date was set. |
| 1964 | - */ |
|
| 1965 | - public function set_date_created( $value ) { |
|
| 1964 | + */ |
|
| 1965 | + public function set_date_created( $value ) { |
|
| 1966 | 1966 | $date = strtotime( $value ); |
| 1967 | 1967 | |
| 1968 | 1968 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1975,13 +1975,13 @@ discard block |
||
| 1975 | 1975 | } |
| 1976 | 1976 | |
| 1977 | 1977 | /** |
| 1978 | - * Set date invoice due date. |
|
| 1979 | - * |
|
| 1980 | - * @since 1.0.19 |
|
| 1981 | - * @param string $value Value to set. |
|
| 1978 | + * Set date invoice due date. |
|
| 1979 | + * |
|
| 1980 | + * @since 1.0.19 |
|
| 1981 | + * @param string $value Value to set. |
|
| 1982 | 1982 | * @return bool Whether or not the date was set. |
| 1983 | - */ |
|
| 1984 | - public function set_due_date( $value ) { |
|
| 1983 | + */ |
|
| 1984 | + public function set_due_date( $value ) { |
|
| 1985 | 1985 | $date = strtotime( $value ); |
| 1986 | 1986 | |
| 1987 | 1987 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1989,29 +1989,29 @@ discard block |
||
| 1989 | 1989 | return true; |
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | - $this->set_prop( 'due_date', '' ); |
|
| 1992 | + $this->set_prop( 'due_date', '' ); |
|
| 1993 | 1993 | return false; |
| 1994 | 1994 | |
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | 1997 | /** |
| 1998 | - * Alias of self::set_due_date(). |
|
| 1999 | - * |
|
| 2000 | - * @since 1.0.19 |
|
| 2001 | - * @param string $value New name. |
|
| 2002 | - */ |
|
| 2003 | - public function set_date_due( $value ) { |
|
| 2004 | - $this->set_due_date( $value ); |
|
| 1998 | + * Alias of self::set_due_date(). |
|
| 1999 | + * |
|
| 2000 | + * @since 1.0.19 |
|
| 2001 | + * @param string $value New name. |
|
| 2002 | + */ |
|
| 2003 | + public function set_date_due( $value ) { |
|
| 2004 | + $this->set_due_date( $value ); |
|
| 2005 | 2005 | } |
| 2006 | 2006 | |
| 2007 | 2007 | /** |
| 2008 | - * Set date invoice was completed. |
|
| 2009 | - * |
|
| 2010 | - * @since 1.0.19 |
|
| 2011 | - * @param string $value Value to set. |
|
| 2008 | + * Set date invoice was completed. |
|
| 2009 | + * |
|
| 2010 | + * @since 1.0.19 |
|
| 2011 | + * @param string $value Value to set. |
|
| 2012 | 2012 | * @return bool Whether or not the date was set. |
| 2013 | - */ |
|
| 2014 | - public function set_completed_date( $value ) { |
|
| 2013 | + */ |
|
| 2014 | + public function set_completed_date( $value ) { |
|
| 2015 | 2015 | $date = strtotime( $value ); |
| 2016 | 2016 | |
| 2017 | 2017 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2019,29 +2019,29 @@ discard block |
||
| 2019 | 2019 | return true; |
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | - $this->set_prop( 'completed_date', '' ); |
|
| 2022 | + $this->set_prop( 'completed_date', '' ); |
|
| 2023 | 2023 | return false; |
| 2024 | 2024 | |
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | /** |
| 2028 | - * Alias of self::set_completed_date(). |
|
| 2029 | - * |
|
| 2030 | - * @since 1.0.19 |
|
| 2031 | - * @param string $value New name. |
|
| 2032 | - */ |
|
| 2033 | - public function set_date_completed( $value ) { |
|
| 2034 | - $this->set_completed_date( $value ); |
|
| 2028 | + * Alias of self::set_completed_date(). |
|
| 2029 | + * |
|
| 2030 | + * @since 1.0.19 |
|
| 2031 | + * @param string $value New name. |
|
| 2032 | + */ |
|
| 2033 | + public function set_date_completed( $value ) { |
|
| 2034 | + $this->set_completed_date( $value ); |
|
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | /** |
| 2038 | - * Set date when the invoice was last modified. |
|
| 2039 | - * |
|
| 2040 | - * @since 1.0.19 |
|
| 2041 | - * @param string $value Value to set. |
|
| 2038 | + * Set date when the invoice was last modified. |
|
| 2039 | + * |
|
| 2040 | + * @since 1.0.19 |
|
| 2041 | + * @param string $value Value to set. |
|
| 2042 | 2042 | * @return bool Whether or not the date was set. |
| 2043 | - */ |
|
| 2044 | - public function set_date_modified( $value ) { |
|
| 2043 | + */ |
|
| 2044 | + public function set_date_modified( $value ) { |
|
| 2045 | 2045 | $date = strtotime( $value ); |
| 2046 | 2046 | |
| 2047 | 2047 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2049,763 +2049,763 @@ discard block |
||
| 2049 | 2049 | return true; |
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | - $this->set_prop( 'date_modified', '' ); |
|
| 2052 | + $this->set_prop( 'date_modified', '' ); |
|
| 2053 | 2053 | return false; |
| 2054 | 2054 | |
| 2055 | 2055 | } |
| 2056 | 2056 | |
| 2057 | 2057 | /** |
| 2058 | - * Set the invoice number. |
|
| 2059 | - * |
|
| 2060 | - * @since 1.0.19 |
|
| 2061 | - * @param string $value New number. |
|
| 2062 | - */ |
|
| 2063 | - public function set_number( $value ) { |
|
| 2058 | + * Set the invoice number. |
|
| 2059 | + * |
|
| 2060 | + * @since 1.0.19 |
|
| 2061 | + * @param string $value New number. |
|
| 2062 | + */ |
|
| 2063 | + public function set_number( $value ) { |
|
| 2064 | 2064 | $number = sanitize_text_field( $value ); |
| 2065 | - $this->set_prop( 'number', $number ); |
|
| 2065 | + $this->set_prop( 'number', $number ); |
|
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | 2068 | /** |
| 2069 | - * Set the invoice type. |
|
| 2070 | - * |
|
| 2071 | - * @since 1.0.19 |
|
| 2072 | - * @param string $value Type. |
|
| 2073 | - */ |
|
| 2074 | - public function set_type( $value ) { |
|
| 2069 | + * Set the invoice type. |
|
| 2070 | + * |
|
| 2071 | + * @since 1.0.19 |
|
| 2072 | + * @param string $value Type. |
|
| 2073 | + */ |
|
| 2074 | + public function set_type( $value ) { |
|
| 2075 | 2075 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 2076 | - $this->set_prop( 'type', $type ); |
|
| 2077 | - } |
|
| 2076 | + $this->set_prop( 'type', $type ); |
|
| 2077 | + } |
|
| 2078 | 2078 | |
| 2079 | 2079 | /** |
| 2080 | - * Set the invoice post type. |
|
| 2081 | - * |
|
| 2082 | - * @since 1.0.19 |
|
| 2083 | - * @param string $value Post type. |
|
| 2084 | - */ |
|
| 2085 | - public function set_post_type( $value ) { |
|
| 2080 | + * Set the invoice post type. |
|
| 2081 | + * |
|
| 2082 | + * @since 1.0.19 |
|
| 2083 | + * @param string $value Post type. |
|
| 2084 | + */ |
|
| 2085 | + public function set_post_type( $value ) { |
|
| 2086 | 2086 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 2087 | - $this->set_type( $value ); |
|
| 2087 | + $this->set_type( $value ); |
|
| 2088 | 2088 | $this->set_prop( 'post_type', $value ); |
| 2089 | 2089 | } |
| 2090 | 2090 | } |
| 2091 | 2091 | |
| 2092 | 2092 | /** |
| 2093 | - * Set the invoice key. |
|
| 2094 | - * |
|
| 2095 | - * @since 1.0.19 |
|
| 2096 | - * @param string $value New key. |
|
| 2097 | - */ |
|
| 2098 | - public function set_key( $value ) { |
|
| 2093 | + * Set the invoice key. |
|
| 2094 | + * |
|
| 2095 | + * @since 1.0.19 |
|
| 2096 | + * @param string $value New key. |
|
| 2097 | + */ |
|
| 2098 | + public function set_key( $value ) { |
|
| 2099 | 2099 | $key = sanitize_text_field( $value ); |
| 2100 | - $this->set_prop( 'key', $key ); |
|
| 2100 | + $this->set_prop( 'key', $key ); |
|
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | /** |
| 2104 | - * Set the invoice mode. |
|
| 2105 | - * |
|
| 2106 | - * @since 1.0.19 |
|
| 2107 | - * @param string $value mode. |
|
| 2108 | - */ |
|
| 2109 | - public function set_mode( $value ) { |
|
| 2104 | + * Set the invoice mode. |
|
| 2105 | + * |
|
| 2106 | + * @since 1.0.19 |
|
| 2107 | + * @param string $value mode. |
|
| 2108 | + */ |
|
| 2109 | + public function set_mode( $value ) { |
|
| 2110 | 2110 | if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
| 2111 | 2111 | $this->set_prop( 'value', $value ); |
| 2112 | 2112 | } |
| 2113 | 2113 | } |
| 2114 | 2114 | |
| 2115 | 2115 | /** |
| 2116 | - * Set the invoice path. |
|
| 2117 | - * |
|
| 2118 | - * @since 1.0.19 |
|
| 2119 | - * @param string $value path. |
|
| 2120 | - */ |
|
| 2121 | - public function set_path( $value ) { |
|
| 2116 | + * Set the invoice path. |
|
| 2117 | + * |
|
| 2118 | + * @since 1.0.19 |
|
| 2119 | + * @param string $value path. |
|
| 2120 | + */ |
|
| 2121 | + public function set_path( $value ) { |
|
| 2122 | 2122 | $this->set_prop( 'path', $value ); |
| 2123 | 2123 | } |
| 2124 | 2124 | |
| 2125 | 2125 | /** |
| 2126 | - * Set the invoice name. |
|
| 2127 | - * |
|
| 2128 | - * @since 1.0.19 |
|
| 2129 | - * @param string $value New name. |
|
| 2130 | - */ |
|
| 2131 | - public function set_name( $value ) { |
|
| 2126 | + * Set the invoice name. |
|
| 2127 | + * |
|
| 2128 | + * @since 1.0.19 |
|
| 2129 | + * @param string $value New name. |
|
| 2130 | + */ |
|
| 2131 | + public function set_name( $value ) { |
|
| 2132 | 2132 | $name = sanitize_text_field( $value ); |
| 2133 | - $this->set_prop( 'name', $name ); |
|
| 2133 | + $this->set_prop( 'name', $name ); |
|
| 2134 | 2134 | } |
| 2135 | 2135 | |
| 2136 | 2136 | /** |
| 2137 | - * Alias of self::set_name(). |
|
| 2138 | - * |
|
| 2139 | - * @since 1.0.19 |
|
| 2140 | - * @param string $value New name. |
|
| 2141 | - */ |
|
| 2142 | - public function set_title( $value ) { |
|
| 2143 | - $this->set_name( $value ); |
|
| 2137 | + * Alias of self::set_name(). |
|
| 2138 | + * |
|
| 2139 | + * @since 1.0.19 |
|
| 2140 | + * @param string $value New name. |
|
| 2141 | + */ |
|
| 2142 | + public function set_title( $value ) { |
|
| 2143 | + $this->set_name( $value ); |
|
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | /** |
| 2147 | - * Set the invoice description. |
|
| 2148 | - * |
|
| 2149 | - * @since 1.0.19 |
|
| 2150 | - * @param string $value New description. |
|
| 2151 | - */ |
|
| 2152 | - public function set_description( $value ) { |
|
| 2147 | + * Set the invoice description. |
|
| 2148 | + * |
|
| 2149 | + * @since 1.0.19 |
|
| 2150 | + * @param string $value New description. |
|
| 2151 | + */ |
|
| 2152 | + public function set_description( $value ) { |
|
| 2153 | 2153 | $description = wp_kses_post( $value ); |
| 2154 | - return $this->set_prop( 'description', $description ); |
|
| 2154 | + return $this->set_prop( 'description', $description ); |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | /** |
| 2158 | - * Alias of self::set_description(). |
|
| 2159 | - * |
|
| 2160 | - * @since 1.0.19 |
|
| 2161 | - * @param string $value New description. |
|
| 2162 | - */ |
|
| 2163 | - public function set_excerpt( $value ) { |
|
| 2164 | - $this->set_description( $value ); |
|
| 2158 | + * Alias of self::set_description(). |
|
| 2159 | + * |
|
| 2160 | + * @since 1.0.19 |
|
| 2161 | + * @param string $value New description. |
|
| 2162 | + */ |
|
| 2163 | + public function set_excerpt( $value ) { |
|
| 2164 | + $this->set_description( $value ); |
|
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | 2167 | /** |
| 2168 | - * Alias of self::set_description(). |
|
| 2169 | - * |
|
| 2170 | - * @since 1.0.19 |
|
| 2171 | - * @param string $value New description. |
|
| 2172 | - */ |
|
| 2173 | - public function set_summary( $value ) { |
|
| 2174 | - $this->set_description( $value ); |
|
| 2168 | + * Alias of self::set_description(). |
|
| 2169 | + * |
|
| 2170 | + * @since 1.0.19 |
|
| 2171 | + * @param string $value New description. |
|
| 2172 | + */ |
|
| 2173 | + public function set_summary( $value ) { |
|
| 2174 | + $this->set_description( $value ); |
|
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | 2177 | /** |
| 2178 | - * Set the receiver of the invoice. |
|
| 2179 | - * |
|
| 2180 | - * @since 1.0.19 |
|
| 2181 | - * @param int $value New author. |
|
| 2182 | - */ |
|
| 2183 | - public function set_author( $value ) { |
|
| 2184 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2178 | + * Set the receiver of the invoice. |
|
| 2179 | + * |
|
| 2180 | + * @since 1.0.19 |
|
| 2181 | + * @param int $value New author. |
|
| 2182 | + */ |
|
| 2183 | + public function set_author( $value ) { |
|
| 2184 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2185 | 2185 | |
| 2186 | - if ( $user && $user->ID ) { |
|
| 2187 | - $this->set_prop( 'author', $user->ID ); |
|
| 2188 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2189 | - } |
|
| 2186 | + if ( $user && $user->ID ) { |
|
| 2187 | + $this->set_prop( 'author', $user->ID ); |
|
| 2188 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2189 | + } |
|
| 2190 | 2190 | |
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | /** |
| 2194 | - * Alias of self::set_author(). |
|
| 2195 | - * |
|
| 2196 | - * @since 1.0.19 |
|
| 2197 | - * @param int $value New user id. |
|
| 2198 | - */ |
|
| 2199 | - public function set_user_id( $value ) { |
|
| 2200 | - $this->set_author( $value ); |
|
| 2194 | + * Alias of self::set_author(). |
|
| 2195 | + * |
|
| 2196 | + * @since 1.0.19 |
|
| 2197 | + * @param int $value New user id. |
|
| 2198 | + */ |
|
| 2199 | + public function set_user_id( $value ) { |
|
| 2200 | + $this->set_author( $value ); |
|
| 2201 | + } |
|
| 2202 | + |
|
| 2203 | + /** |
|
| 2204 | + * Alias of self::set_author(). |
|
| 2205 | + * |
|
| 2206 | + * @since 1.0.19 |
|
| 2207 | + * @param int $value New user id. |
|
| 2208 | + */ |
|
| 2209 | + public function set_customer_id( $value ) { |
|
| 2210 | + $this->set_author( $value ); |
|
| 2211 | + } |
|
| 2212 | + |
|
| 2213 | + /** |
|
| 2214 | + * Set the customer's ip. |
|
| 2215 | + * |
|
| 2216 | + * @since 1.0.19 |
|
| 2217 | + * @param string $value ip address. |
|
| 2218 | + */ |
|
| 2219 | + public function set_ip( $value ) { |
|
| 2220 | + $this->set_prop( 'ip', $value ); |
|
| 2221 | + } |
|
| 2222 | + |
|
| 2223 | + /** |
|
| 2224 | + * Alias of self::set_ip(). |
|
| 2225 | + * |
|
| 2226 | + * @since 1.0.19 |
|
| 2227 | + * @param string $value ip address. |
|
| 2228 | + */ |
|
| 2229 | + public function set_user_ip( $value ) { |
|
| 2230 | + $this->set_ip( $value ); |
|
| 2231 | + } |
|
| 2232 | + |
|
| 2233 | + /** |
|
| 2234 | + * Set the customer's first name. |
|
| 2235 | + * |
|
| 2236 | + * @since 1.0.19 |
|
| 2237 | + * @param string $value first name. |
|
| 2238 | + */ |
|
| 2239 | + public function set_first_name( $value ) { |
|
| 2240 | + $this->set_prop( 'first_name', $value ); |
|
| 2201 | 2241 | } |
| 2202 | 2242 | |
| 2203 | 2243 | /** |
| 2204 | - * Alias of self::set_author(). |
|
| 2205 | - * |
|
| 2206 | - * @since 1.0.19 |
|
| 2207 | - * @param int $value New user id. |
|
| 2208 | - */ |
|
| 2209 | - public function set_customer_id( $value ) { |
|
| 2210 | - $this->set_author( $value ); |
|
| 2244 | + * Alias of self::set_first_name(). |
|
| 2245 | + * |
|
| 2246 | + * @since 1.0.19 |
|
| 2247 | + * @param string $value first name. |
|
| 2248 | + */ |
|
| 2249 | + public function set_user_first_name( $value ) { |
|
| 2250 | + $this->set_first_name( $value ); |
|
| 2211 | 2251 | } |
| 2212 | 2252 | |
| 2213 | 2253 | /** |
| 2214 | - * Set the customer's ip. |
|
| 2215 | - * |
|
| 2216 | - * @since 1.0.19 |
|
| 2217 | - * @param string $value ip address. |
|
| 2218 | - */ |
|
| 2219 | - public function set_ip( $value ) { |
|
| 2220 | - $this->set_prop( 'ip', $value ); |
|
| 2254 | + * Alias of self::set_first_name(). |
|
| 2255 | + * |
|
| 2256 | + * @since 1.0.19 |
|
| 2257 | + * @param string $value first name. |
|
| 2258 | + */ |
|
| 2259 | + public function set_customer_first_name( $value ) { |
|
| 2260 | + $this->set_first_name( $value ); |
|
| 2221 | 2261 | } |
| 2222 | 2262 | |
| 2223 | 2263 | /** |
| 2224 | - * Alias of self::set_ip(). |
|
| 2225 | - * |
|
| 2226 | - * @since 1.0.19 |
|
| 2227 | - * @param string $value ip address. |
|
| 2228 | - */ |
|
| 2229 | - public function set_user_ip( $value ) { |
|
| 2230 | - $this->set_ip( $value ); |
|
| 2264 | + * Set the customer's last name. |
|
| 2265 | + * |
|
| 2266 | + * @since 1.0.19 |
|
| 2267 | + * @param string $value last name. |
|
| 2268 | + */ |
|
| 2269 | + public function set_last_name( $value ) { |
|
| 2270 | + $this->set_prop( 'last_name', $value ); |
|
| 2231 | 2271 | } |
| 2232 | 2272 | |
| 2233 | 2273 | /** |
| 2234 | - * Set the customer's first name. |
|
| 2235 | - * |
|
| 2236 | - * @since 1.0.19 |
|
| 2237 | - * @param string $value first name. |
|
| 2238 | - */ |
|
| 2239 | - public function set_first_name( $value ) { |
|
| 2240 | - $this->set_prop( 'first_name', $value ); |
|
| 2274 | + * Alias of self::set_last_name(). |
|
| 2275 | + * |
|
| 2276 | + * @since 1.0.19 |
|
| 2277 | + * @param string $value last name. |
|
| 2278 | + */ |
|
| 2279 | + public function set_user_last_name( $value ) { |
|
| 2280 | + $this->set_last_name( $value ); |
|
| 2241 | 2281 | } |
| 2242 | 2282 | |
| 2243 | 2283 | /** |
| 2244 | - * Alias of self::set_first_name(). |
|
| 2245 | - * |
|
| 2246 | - * @since 1.0.19 |
|
| 2247 | - * @param string $value first name. |
|
| 2248 | - */ |
|
| 2249 | - public function set_user_first_name( $value ) { |
|
| 2250 | - $this->set_first_name( $value ); |
|
| 2284 | + * Alias of self::set_last_name(). |
|
| 2285 | + * |
|
| 2286 | + * @since 1.0.19 |
|
| 2287 | + * @param string $value last name. |
|
| 2288 | + */ |
|
| 2289 | + public function set_customer_last_name( $value ) { |
|
| 2290 | + $this->set_last_name( $value ); |
|
| 2251 | 2291 | } |
| 2252 | 2292 | |
| 2253 | 2293 | /** |
| 2254 | - * Alias of self::set_first_name(). |
|
| 2255 | - * |
|
| 2256 | - * @since 1.0.19 |
|
| 2257 | - * @param string $value first name. |
|
| 2258 | - */ |
|
| 2259 | - public function set_customer_first_name( $value ) { |
|
| 2260 | - $this->set_first_name( $value ); |
|
| 2294 | + * Set the customer's phone number. |
|
| 2295 | + * |
|
| 2296 | + * @since 1.0.19 |
|
| 2297 | + * @param string $value phone. |
|
| 2298 | + */ |
|
| 2299 | + public function set_phone( $value ) { |
|
| 2300 | + $this->set_prop( 'phone', $value ); |
|
| 2261 | 2301 | } |
| 2262 | 2302 | |
| 2263 | 2303 | /** |
| 2264 | - * Set the customer's last name. |
|
| 2265 | - * |
|
| 2266 | - * @since 1.0.19 |
|
| 2267 | - * @param string $value last name. |
|
| 2268 | - */ |
|
| 2269 | - public function set_last_name( $value ) { |
|
| 2270 | - $this->set_prop( 'last_name', $value ); |
|
| 2304 | + * Alias of self::set_phone(). |
|
| 2305 | + * |
|
| 2306 | + * @since 1.0.19 |
|
| 2307 | + * @param string $value phone. |
|
| 2308 | + */ |
|
| 2309 | + public function set_user_phone( $value ) { |
|
| 2310 | + $this->set_phone( $value ); |
|
| 2271 | 2311 | } |
| 2272 | 2312 | |
| 2273 | 2313 | /** |
| 2274 | - * Alias of self::set_last_name(). |
|
| 2275 | - * |
|
| 2276 | - * @since 1.0.19 |
|
| 2277 | - * @param string $value last name. |
|
| 2278 | - */ |
|
| 2279 | - public function set_user_last_name( $value ) { |
|
| 2280 | - $this->set_last_name( $value ); |
|
| 2314 | + * Alias of self::set_phone(). |
|
| 2315 | + * |
|
| 2316 | + * @since 1.0.19 |
|
| 2317 | + * @param string $value phone. |
|
| 2318 | + */ |
|
| 2319 | + public function set_customer_phone( $value ) { |
|
| 2320 | + $this->set_phone( $value ); |
|
| 2281 | 2321 | } |
| 2282 | 2322 | |
| 2283 | 2323 | /** |
| 2284 | - * Alias of self::set_last_name(). |
|
| 2285 | - * |
|
| 2286 | - * @since 1.0.19 |
|
| 2287 | - * @param string $value last name. |
|
| 2288 | - */ |
|
| 2289 | - public function set_customer_last_name( $value ) { |
|
| 2290 | - $this->set_last_name( $value ); |
|
| 2324 | + * Alias of self::set_phone(). |
|
| 2325 | + * |
|
| 2326 | + * @since 1.0.19 |
|
| 2327 | + * @param string $value phone. |
|
| 2328 | + */ |
|
| 2329 | + public function set_phone_number( $value ) { |
|
| 2330 | + $this->set_phone( $value ); |
|
| 2291 | 2331 | } |
| 2292 | 2332 | |
| 2293 | 2333 | /** |
| 2294 | - * Set the customer's phone number. |
|
| 2295 | - * |
|
| 2296 | - * @since 1.0.19 |
|
| 2297 | - * @param string $value phone. |
|
| 2298 | - */ |
|
| 2299 | - public function set_phone( $value ) { |
|
| 2300 | - $this->set_prop( 'phone', $value ); |
|
| 2334 | + * Set the customer's email address. |
|
| 2335 | + * |
|
| 2336 | + * @since 1.0.19 |
|
| 2337 | + * @param string $value email address. |
|
| 2338 | + */ |
|
| 2339 | + public function set_email( $value ) { |
|
| 2340 | + $this->set_prop( 'email', $value ); |
|
| 2301 | 2341 | } |
| 2302 | 2342 | |
| 2303 | 2343 | /** |
| 2304 | - * Alias of self::set_phone(). |
|
| 2305 | - * |
|
| 2306 | - * @since 1.0.19 |
|
| 2307 | - * @param string $value phone. |
|
| 2308 | - */ |
|
| 2309 | - public function set_user_phone( $value ) { |
|
| 2310 | - $this->set_phone( $value ); |
|
| 2344 | + * Alias of self::set_email(). |
|
| 2345 | + * |
|
| 2346 | + * @since 1.0.19 |
|
| 2347 | + * @param string $value email address. |
|
| 2348 | + */ |
|
| 2349 | + public function set_user_email( $value ) { |
|
| 2350 | + $this->set_email( $value ); |
|
| 2311 | 2351 | } |
| 2312 | 2352 | |
| 2313 | 2353 | /** |
| 2314 | - * Alias of self::set_phone(). |
|
| 2315 | - * |
|
| 2316 | - * @since 1.0.19 |
|
| 2317 | - * @param string $value phone. |
|
| 2318 | - */ |
|
| 2319 | - public function set_customer_phone( $value ) { |
|
| 2320 | - $this->set_phone( $value ); |
|
| 2354 | + * Alias of self::set_email(). |
|
| 2355 | + * |
|
| 2356 | + * @since 1.0.19 |
|
| 2357 | + * @param string $value email address. |
|
| 2358 | + */ |
|
| 2359 | + public function set_email_address( $value ) { |
|
| 2360 | + $this->set_email( $value ); |
|
| 2321 | 2361 | } |
| 2322 | 2362 | |
| 2323 | 2363 | /** |
| 2324 | - * Alias of self::set_phone(). |
|
| 2325 | - * |
|
| 2326 | - * @since 1.0.19 |
|
| 2327 | - * @param string $value phone. |
|
| 2328 | - */ |
|
| 2329 | - public function set_phone_number( $value ) { |
|
| 2330 | - $this->set_phone( $value ); |
|
| 2364 | + * Alias of self::set_email(). |
|
| 2365 | + * |
|
| 2366 | + * @since 1.0.19 |
|
| 2367 | + * @param string $value email address. |
|
| 2368 | + */ |
|
| 2369 | + public function set_customer_email( $value ) { |
|
| 2370 | + $this->set_email( $value ); |
|
| 2331 | 2371 | } |
| 2332 | 2372 | |
| 2333 | 2373 | /** |
| 2334 | - * Set the customer's email address. |
|
| 2335 | - * |
|
| 2336 | - * @since 1.0.19 |
|
| 2337 | - * @param string $value email address. |
|
| 2338 | - */ |
|
| 2339 | - public function set_email( $value ) { |
|
| 2340 | - $this->set_prop( 'email', $value ); |
|
| 2374 | + * Set the customer's country. |
|
| 2375 | + * |
|
| 2376 | + * @since 1.0.19 |
|
| 2377 | + * @param string $value country. |
|
| 2378 | + */ |
|
| 2379 | + public function set_country( $value ) { |
|
| 2380 | + $this->set_prop( 'country', $value ); |
|
| 2341 | 2381 | } |
| 2342 | 2382 | |
| 2343 | 2383 | /** |
| 2344 | - * Alias of self::set_email(). |
|
| 2345 | - * |
|
| 2346 | - * @since 1.0.19 |
|
| 2347 | - * @param string $value email address. |
|
| 2348 | - */ |
|
| 2349 | - public function set_user_email( $value ) { |
|
| 2350 | - $this->set_email( $value ); |
|
| 2384 | + * Alias of self::set_country(). |
|
| 2385 | + * |
|
| 2386 | + * @since 1.0.19 |
|
| 2387 | + * @param string $value country. |
|
| 2388 | + */ |
|
| 2389 | + public function set_user_country( $value ) { |
|
| 2390 | + $this->set_country( $value ); |
|
| 2351 | 2391 | } |
| 2352 | 2392 | |
| 2353 | 2393 | /** |
| 2354 | - * Alias of self::set_email(). |
|
| 2355 | - * |
|
| 2356 | - * @since 1.0.19 |
|
| 2357 | - * @param string $value email address. |
|
| 2358 | - */ |
|
| 2359 | - public function set_email_address( $value ) { |
|
| 2360 | - $this->set_email( $value ); |
|
| 2394 | + * Alias of self::set_country(). |
|
| 2395 | + * |
|
| 2396 | + * @since 1.0.19 |
|
| 2397 | + * @param string $value country. |
|
| 2398 | + */ |
|
| 2399 | + public function set_customer_country( $value ) { |
|
| 2400 | + $this->set_country( $value ); |
|
| 2361 | 2401 | } |
| 2362 | 2402 | |
| 2363 | 2403 | /** |
| 2364 | - * Alias of self::set_email(). |
|
| 2365 | - * |
|
| 2366 | - * @since 1.0.19 |
|
| 2367 | - * @param string $value email address. |
|
| 2368 | - */ |
|
| 2369 | - public function set_customer_email( $value ) { |
|
| 2370 | - $this->set_email( $value ); |
|
| 2404 | + * Set the customer's state. |
|
| 2405 | + * |
|
| 2406 | + * @since 1.0.19 |
|
| 2407 | + * @param string $value state. |
|
| 2408 | + */ |
|
| 2409 | + public function set_state( $value ) { |
|
| 2410 | + $this->set_prop( 'state', $value ); |
|
| 2371 | 2411 | } |
| 2372 | 2412 | |
| 2373 | 2413 | /** |
| 2374 | - * Set the customer's country. |
|
| 2375 | - * |
|
| 2376 | - * @since 1.0.19 |
|
| 2377 | - * @param string $value country. |
|
| 2378 | - */ |
|
| 2379 | - public function set_country( $value ) { |
|
| 2380 | - $this->set_prop( 'country', $value ); |
|
| 2414 | + * Alias of self::set_state(). |
|
| 2415 | + * |
|
| 2416 | + * @since 1.0.19 |
|
| 2417 | + * @param string $value state. |
|
| 2418 | + */ |
|
| 2419 | + public function set_user_state( $value ) { |
|
| 2420 | + $this->set_state( $value ); |
|
| 2381 | 2421 | } |
| 2382 | 2422 | |
| 2383 | 2423 | /** |
| 2384 | - * Alias of self::set_country(). |
|
| 2385 | - * |
|
| 2386 | - * @since 1.0.19 |
|
| 2387 | - * @param string $value country. |
|
| 2388 | - */ |
|
| 2389 | - public function set_user_country( $value ) { |
|
| 2390 | - $this->set_country( $value ); |
|
| 2424 | + * Alias of self::set_state(). |
|
| 2425 | + * |
|
| 2426 | + * @since 1.0.19 |
|
| 2427 | + * @param string $value state. |
|
| 2428 | + */ |
|
| 2429 | + public function set_customer_state( $value ) { |
|
| 2430 | + $this->set_state( $value ); |
|
| 2391 | 2431 | } |
| 2392 | 2432 | |
| 2393 | 2433 | /** |
| 2394 | - * Alias of self::set_country(). |
|
| 2395 | - * |
|
| 2396 | - * @since 1.0.19 |
|
| 2397 | - * @param string $value country. |
|
| 2398 | - */ |
|
| 2399 | - public function set_customer_country( $value ) { |
|
| 2400 | - $this->set_country( $value ); |
|
| 2434 | + * Set the customer's city. |
|
| 2435 | + * |
|
| 2436 | + * @since 1.0.19 |
|
| 2437 | + * @param string $value city. |
|
| 2438 | + */ |
|
| 2439 | + public function set_city( $value ) { |
|
| 2440 | + $this->set_prop( 'city', $value ); |
|
| 2401 | 2441 | } |
| 2402 | 2442 | |
| 2403 | 2443 | /** |
| 2404 | - * Set the customer's state. |
|
| 2405 | - * |
|
| 2406 | - * @since 1.0.19 |
|
| 2407 | - * @param string $value state. |
|
| 2408 | - */ |
|
| 2409 | - public function set_state( $value ) { |
|
| 2410 | - $this->set_prop( 'state', $value ); |
|
| 2444 | + * Alias of self::set_city(). |
|
| 2445 | + * |
|
| 2446 | + * @since 1.0.19 |
|
| 2447 | + * @param string $value city. |
|
| 2448 | + */ |
|
| 2449 | + public function set_user_city( $value ) { |
|
| 2450 | + $this->set_city( $value ); |
|
| 2411 | 2451 | } |
| 2412 | 2452 | |
| 2413 | 2453 | /** |
| 2414 | - * Alias of self::set_state(). |
|
| 2415 | - * |
|
| 2416 | - * @since 1.0.19 |
|
| 2417 | - * @param string $value state. |
|
| 2418 | - */ |
|
| 2419 | - public function set_user_state( $value ) { |
|
| 2420 | - $this->set_state( $value ); |
|
| 2454 | + * Alias of self::set_city(). |
|
| 2455 | + * |
|
| 2456 | + * @since 1.0.19 |
|
| 2457 | + * @param string $value city. |
|
| 2458 | + */ |
|
| 2459 | + public function set_customer_city( $value ) { |
|
| 2460 | + $this->set_city( $value ); |
|
| 2421 | 2461 | } |
| 2422 | 2462 | |
| 2423 | 2463 | /** |
| 2424 | - * Alias of self::set_state(). |
|
| 2425 | - * |
|
| 2426 | - * @since 1.0.19 |
|
| 2427 | - * @param string $value state. |
|
| 2428 | - */ |
|
| 2429 | - public function set_customer_state( $value ) { |
|
| 2430 | - $this->set_state( $value ); |
|
| 2464 | + * Set the customer's zip code. |
|
| 2465 | + * |
|
| 2466 | + * @since 1.0.19 |
|
| 2467 | + * @param string $value zip. |
|
| 2468 | + */ |
|
| 2469 | + public function set_zip( $value ) { |
|
| 2470 | + $this->set_prop( 'zip', $value ); |
|
| 2431 | 2471 | } |
| 2432 | 2472 | |
| 2433 | 2473 | /** |
| 2434 | - * Set the customer's city. |
|
| 2435 | - * |
|
| 2436 | - * @since 1.0.19 |
|
| 2437 | - * @param string $value city. |
|
| 2438 | - */ |
|
| 2439 | - public function set_city( $value ) { |
|
| 2440 | - $this->set_prop( 'city', $value ); |
|
| 2474 | + * Alias of self::set_zip(). |
|
| 2475 | + * |
|
| 2476 | + * @since 1.0.19 |
|
| 2477 | + * @param string $value zip. |
|
| 2478 | + */ |
|
| 2479 | + public function set_user_zip( $value ) { |
|
| 2480 | + $this->set_zip( $value ); |
|
| 2441 | 2481 | } |
| 2442 | 2482 | |
| 2443 | 2483 | /** |
| 2444 | - * Alias of self::set_city(). |
|
| 2445 | - * |
|
| 2446 | - * @since 1.0.19 |
|
| 2447 | - * @param string $value city. |
|
| 2448 | - */ |
|
| 2449 | - public function set_user_city( $value ) { |
|
| 2450 | - $this->set_city( $value ); |
|
| 2484 | + * Alias of self::set_zip(). |
|
| 2485 | + * |
|
| 2486 | + * @since 1.0.19 |
|
| 2487 | + * @param string $value zip. |
|
| 2488 | + */ |
|
| 2489 | + public function set_customer_zip( $value ) { |
|
| 2490 | + $this->set_zip( $value ); |
|
| 2451 | 2491 | } |
| 2452 | 2492 | |
| 2453 | 2493 | /** |
| 2454 | - * Alias of self::set_city(). |
|
| 2455 | - * |
|
| 2456 | - * @since 1.0.19 |
|
| 2457 | - * @param string $value city. |
|
| 2458 | - */ |
|
| 2459 | - public function set_customer_city( $value ) { |
|
| 2460 | - $this->set_city( $value ); |
|
| 2494 | + * Set the customer's company. |
|
| 2495 | + * |
|
| 2496 | + * @since 1.0.19 |
|
| 2497 | + * @param string $value company. |
|
| 2498 | + */ |
|
| 2499 | + public function set_company( $value ) { |
|
| 2500 | + $this->set_prop( 'company', $value ); |
|
| 2461 | 2501 | } |
| 2462 | 2502 | |
| 2463 | 2503 | /** |
| 2464 | - * Set the customer's zip code. |
|
| 2465 | - * |
|
| 2466 | - * @since 1.0.19 |
|
| 2467 | - * @param string $value zip. |
|
| 2468 | - */ |
|
| 2469 | - public function set_zip( $value ) { |
|
| 2470 | - $this->set_prop( 'zip', $value ); |
|
| 2504 | + * Alias of self::set_company(). |
|
| 2505 | + * |
|
| 2506 | + * @since 1.0.19 |
|
| 2507 | + * @param string $value company. |
|
| 2508 | + */ |
|
| 2509 | + public function set_user_company( $value ) { |
|
| 2510 | + $this->set_company( $value ); |
|
| 2471 | 2511 | } |
| 2472 | 2512 | |
| 2473 | 2513 | /** |
| 2474 | - * Alias of self::set_zip(). |
|
| 2475 | - * |
|
| 2476 | - * @since 1.0.19 |
|
| 2477 | - * @param string $value zip. |
|
| 2478 | - */ |
|
| 2479 | - public function set_user_zip( $value ) { |
|
| 2480 | - $this->set_zip( $value ); |
|
| 2514 | + * Alias of self::set_company(). |
|
| 2515 | + * |
|
| 2516 | + * @since 1.0.19 |
|
| 2517 | + * @param string $value company. |
|
| 2518 | + */ |
|
| 2519 | + public function set_customer_company( $value ) { |
|
| 2520 | + $this->set_company( $value ); |
|
| 2481 | 2521 | } |
| 2482 | 2522 | |
| 2483 | 2523 | /** |
| 2484 | - * Alias of self::set_zip(). |
|
| 2485 | - * |
|
| 2486 | - * @since 1.0.19 |
|
| 2487 | - * @param string $value zip. |
|
| 2488 | - */ |
|
| 2489 | - public function set_customer_zip( $value ) { |
|
| 2490 | - $this->set_zip( $value ); |
|
| 2524 | + * Set the customer's var number. |
|
| 2525 | + * |
|
| 2526 | + * @since 1.0.19 |
|
| 2527 | + * @param string $value var number. |
|
| 2528 | + */ |
|
| 2529 | + public function set_vat_number( $value ) { |
|
| 2530 | + $this->set_prop( 'vat_number', $value ); |
|
| 2491 | 2531 | } |
| 2492 | 2532 | |
| 2493 | 2533 | /** |
| 2494 | - * Set the customer's company. |
|
| 2495 | - * |
|
| 2496 | - * @since 1.0.19 |
|
| 2497 | - * @param string $value company. |
|
| 2498 | - */ |
|
| 2499 | - public function set_company( $value ) { |
|
| 2500 | - $this->set_prop( 'company', $value ); |
|
| 2534 | + * Alias of self::set_vat_number(). |
|
| 2535 | + * |
|
| 2536 | + * @since 1.0.19 |
|
| 2537 | + * @param string $value var number. |
|
| 2538 | + */ |
|
| 2539 | + public function set_user_vat_number( $value ) { |
|
| 2540 | + $this->set_vat_number( $value ); |
|
| 2501 | 2541 | } |
| 2502 | 2542 | |
| 2503 | 2543 | /** |
| 2504 | - * Alias of self::set_company(). |
|
| 2505 | - * |
|
| 2506 | - * @since 1.0.19 |
|
| 2507 | - * @param string $value company. |
|
| 2508 | - */ |
|
| 2509 | - public function set_user_company( $value ) { |
|
| 2510 | - $this->set_company( $value ); |
|
| 2544 | + * Alias of self::set_vat_number(). |
|
| 2545 | + * |
|
| 2546 | + * @since 1.0.19 |
|
| 2547 | + * @param string $value var number. |
|
| 2548 | + */ |
|
| 2549 | + public function set_customer_vat_number( $value ) { |
|
| 2550 | + $this->set_vat_number( $value ); |
|
| 2511 | 2551 | } |
| 2512 | 2552 | |
| 2513 | 2553 | /** |
| 2514 | - * Alias of self::set_company(). |
|
| 2515 | - * |
|
| 2516 | - * @since 1.0.19 |
|
| 2517 | - * @param string $value company. |
|
| 2518 | - */ |
|
| 2519 | - public function set_customer_company( $value ) { |
|
| 2520 | - $this->set_company( $value ); |
|
| 2554 | + * Set the customer's vat rate. |
|
| 2555 | + * |
|
| 2556 | + * @since 1.0.19 |
|
| 2557 | + * @param string $value var rate. |
|
| 2558 | + */ |
|
| 2559 | + public function set_vat_rate( $value ) { |
|
| 2560 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2521 | 2561 | } |
| 2522 | 2562 | |
| 2523 | 2563 | /** |
| 2524 | - * Set the customer's var number. |
|
| 2525 | - * |
|
| 2526 | - * @since 1.0.19 |
|
| 2527 | - * @param string $value var number. |
|
| 2528 | - */ |
|
| 2529 | - public function set_vat_number( $value ) { |
|
| 2530 | - $this->set_prop( 'vat_number', $value ); |
|
| 2564 | + * Alias of self::set_vat_rate(). |
|
| 2565 | + * |
|
| 2566 | + * @since 1.0.19 |
|
| 2567 | + * @param string $value var number. |
|
| 2568 | + */ |
|
| 2569 | + public function set_user_vat_rate( $value ) { |
|
| 2570 | + $this->set_vat_rate( $value ); |
|
| 2531 | 2571 | } |
| 2532 | 2572 | |
| 2533 | 2573 | /** |
| 2534 | - * Alias of self::set_vat_number(). |
|
| 2535 | - * |
|
| 2536 | - * @since 1.0.19 |
|
| 2537 | - * @param string $value var number. |
|
| 2538 | - */ |
|
| 2539 | - public function set_user_vat_number( $value ) { |
|
| 2540 | - $this->set_vat_number( $value ); |
|
| 2574 | + * Alias of self::set_vat_rate(). |
|
| 2575 | + * |
|
| 2576 | + * @since 1.0.19 |
|
| 2577 | + * @param string $value var number. |
|
| 2578 | + */ |
|
| 2579 | + public function set_customer_vat_rate( $value ) { |
|
| 2580 | + $this->set_vat_rate( $value ); |
|
| 2541 | 2581 | } |
| 2542 | 2582 | |
| 2543 | 2583 | /** |
| 2544 | - * Alias of self::set_vat_number(). |
|
| 2545 | - * |
|
| 2546 | - * @since 1.0.19 |
|
| 2547 | - * @param string $value var number. |
|
| 2548 | - */ |
|
| 2549 | - public function set_customer_vat_number( $value ) { |
|
| 2550 | - $this->set_vat_number( $value ); |
|
| 2584 | + * Set the customer's address. |
|
| 2585 | + * |
|
| 2586 | + * @since 1.0.19 |
|
| 2587 | + * @param string $value address. |
|
| 2588 | + */ |
|
| 2589 | + public function set_address( $value ) { |
|
| 2590 | + $this->set_prop( 'address', $value ); |
|
| 2551 | 2591 | } |
| 2552 | 2592 | |
| 2553 | 2593 | /** |
| 2554 | - * Set the customer's vat rate. |
|
| 2555 | - * |
|
| 2556 | - * @since 1.0.19 |
|
| 2557 | - * @param string $value var rate. |
|
| 2558 | - */ |
|
| 2559 | - public function set_vat_rate( $value ) { |
|
| 2560 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2594 | + * Alias of self::set_address(). |
|
| 2595 | + * |
|
| 2596 | + * @since 1.0.19 |
|
| 2597 | + * @param string $value address. |
|
| 2598 | + */ |
|
| 2599 | + public function set_user_address( $value ) { |
|
| 2600 | + $this->set_address( $value ); |
|
| 2561 | 2601 | } |
| 2562 | 2602 | |
| 2563 | 2603 | /** |
| 2564 | - * Alias of self::set_vat_rate(). |
|
| 2565 | - * |
|
| 2566 | - * @since 1.0.19 |
|
| 2567 | - * @param string $value var number. |
|
| 2568 | - */ |
|
| 2569 | - public function set_user_vat_rate( $value ) { |
|
| 2570 | - $this->set_vat_rate( $value ); |
|
| 2604 | + * Alias of self::set_address(). |
|
| 2605 | + * |
|
| 2606 | + * @since 1.0.19 |
|
| 2607 | + * @param string $value address. |
|
| 2608 | + */ |
|
| 2609 | + public function set_customer_address( $value ) { |
|
| 2610 | + $this->set_address( $value ); |
|
| 2571 | 2611 | } |
| 2572 | 2612 | |
| 2573 | 2613 | /** |
| 2574 | - * Alias of self::set_vat_rate(). |
|
| 2575 | - * |
|
| 2576 | - * @since 1.0.19 |
|
| 2577 | - * @param string $value var number. |
|
| 2578 | - */ |
|
| 2579 | - public function set_customer_vat_rate( $value ) { |
|
| 2580 | - $this->set_vat_rate( $value ); |
|
| 2614 | + * Set whether the customer has viewed the invoice or not. |
|
| 2615 | + * |
|
| 2616 | + * @since 1.0.19 |
|
| 2617 | + * @param int|bool $value confirmed. |
|
| 2618 | + */ |
|
| 2619 | + public function set_is_viewed( $value ) { |
|
| 2620 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2581 | 2621 | } |
| 2582 | 2622 | |
| 2583 | 2623 | /** |
| 2584 | - * Set the customer's address. |
|
| 2585 | - * |
|
| 2586 | - * @since 1.0.19 |
|
| 2587 | - * @param string $value address. |
|
| 2588 | - */ |
|
| 2589 | - public function set_address( $value ) { |
|
| 2590 | - $this->set_prop( 'address', $value ); |
|
| 2624 | + * Set extra email recipients. |
|
| 2625 | + * |
|
| 2626 | + * @since 1.0.19 |
|
| 2627 | + * @param string $value email recipients. |
|
| 2628 | + */ |
|
| 2629 | + public function set_email_cc( $value ) { |
|
| 2630 | + $this->set_prop( 'email_cc', $value ); |
|
| 2591 | 2631 | } |
| 2592 | 2632 | |
| 2593 | 2633 | /** |
| 2594 | - * Alias of self::set_address(). |
|
| 2595 | - * |
|
| 2596 | - * @since 1.0.19 |
|
| 2597 | - * @param string $value address. |
|
| 2598 | - */ |
|
| 2599 | - public function set_user_address( $value ) { |
|
| 2600 | - $this->set_address( $value ); |
|
| 2634 | + * Set the invoice template. |
|
| 2635 | + * |
|
| 2636 | + * @since 1.0.19 |
|
| 2637 | + * @param string $value template. |
|
| 2638 | + */ |
|
| 2639 | + public function set_template( $value ) { |
|
| 2640 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2641 | + $this->set_prop( 'template', $value ); |
|
| 2642 | + } |
|
| 2601 | 2643 | } |
| 2602 | 2644 | |
| 2603 | 2645 | /** |
| 2604 | - * Alias of self::set_address(). |
|
| 2605 | - * |
|
| 2606 | - * @since 1.0.19 |
|
| 2607 | - * @param string $value address. |
|
| 2608 | - */ |
|
| 2609 | - public function set_customer_address( $value ) { |
|
| 2610 | - $this->set_address( $value ); |
|
| 2646 | + * Set the invoice source. |
|
| 2647 | + * |
|
| 2648 | + * @since 1.0.19 |
|
| 2649 | + * @param string $value email recipients. |
|
| 2650 | + */ |
|
| 2651 | + public function created_via( $value ) { |
|
| 2652 | + $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2611 | 2653 | } |
| 2612 | 2654 | |
| 2613 | 2655 | /** |
| 2614 | - * Set whether the customer has viewed the invoice or not. |
|
| 2615 | - * |
|
| 2616 | - * @since 1.0.19 |
|
| 2617 | - * @param int|bool $value confirmed. |
|
| 2618 | - */ |
|
| 2619 | - public function set_is_viewed( $value ) { |
|
| 2620 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2621 | - } |
|
| 2622 | - |
|
| 2623 | - /** |
|
| 2624 | - * Set extra email recipients. |
|
| 2625 | - * |
|
| 2626 | - * @since 1.0.19 |
|
| 2627 | - * @param string $value email recipients. |
|
| 2628 | - */ |
|
| 2629 | - public function set_email_cc( $value ) { |
|
| 2630 | - $this->set_prop( 'email_cc', $value ); |
|
| 2631 | - } |
|
| 2632 | - |
|
| 2633 | - /** |
|
| 2634 | - * Set the invoice template. |
|
| 2635 | - * |
|
| 2636 | - * @since 1.0.19 |
|
| 2637 | - * @param string $value template. |
|
| 2638 | - */ |
|
| 2639 | - public function set_template( $value ) { |
|
| 2640 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2641 | - $this->set_prop( 'template', $value ); |
|
| 2642 | - } |
|
| 2643 | - } |
|
| 2644 | - |
|
| 2645 | - /** |
|
| 2646 | - * Set the invoice source. |
|
| 2647 | - * |
|
| 2648 | - * @since 1.0.19 |
|
| 2649 | - * @param string $value email recipients. |
|
| 2650 | - */ |
|
| 2651 | - public function created_via( $value ) { |
|
| 2652 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2653 | - } |
|
| 2654 | - |
|
| 2655 | - /** |
|
| 2656 | - * Set the customer's address confirmed status. |
|
| 2657 | - * |
|
| 2658 | - * @since 1.0.19 |
|
| 2659 | - * @param int|bool $value confirmed. |
|
| 2660 | - */ |
|
| 2661 | - public function set_address_confirmed( $value ) { |
|
| 2662 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2656 | + * Set the customer's address confirmed status. |
|
| 2657 | + * |
|
| 2658 | + * @since 1.0.19 |
|
| 2659 | + * @param int|bool $value confirmed. |
|
| 2660 | + */ |
|
| 2661 | + public function set_address_confirmed( $value ) { |
|
| 2662 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | /** |
| 2666 | - * Alias of self::set_address_confirmed(). |
|
| 2667 | - * |
|
| 2668 | - * @since 1.0.19 |
|
| 2669 | - * @param int|bool $value confirmed. |
|
| 2670 | - */ |
|
| 2671 | - public function set_user_address_confirmed( $value ) { |
|
| 2672 | - $this->set_address_confirmed( $value ); |
|
| 2666 | + * Alias of self::set_address_confirmed(). |
|
| 2667 | + * |
|
| 2668 | + * @since 1.0.19 |
|
| 2669 | + * @param int|bool $value confirmed. |
|
| 2670 | + */ |
|
| 2671 | + public function set_user_address_confirmed( $value ) { |
|
| 2672 | + $this->set_address_confirmed( $value ); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
| 2676 | - * Alias of self::set_address_confirmed(). |
|
| 2677 | - * |
|
| 2678 | - * @since 1.0.19 |
|
| 2679 | - * @param int|bool $value confirmed. |
|
| 2680 | - */ |
|
| 2681 | - public function set_customer_address_confirmed( $value ) { |
|
| 2682 | - $this->set_address_confirmed( $value ); |
|
| 2676 | + * Alias of self::set_address_confirmed(). |
|
| 2677 | + * |
|
| 2678 | + * @since 1.0.19 |
|
| 2679 | + * @param int|bool $value confirmed. |
|
| 2680 | + */ |
|
| 2681 | + public function set_customer_address_confirmed( $value ) { |
|
| 2682 | + $this->set_address_confirmed( $value ); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
| 2686 | - * Set the invoice sub total. |
|
| 2687 | - * |
|
| 2688 | - * @since 1.0.19 |
|
| 2689 | - * @param float $value sub total. |
|
| 2690 | - */ |
|
| 2691 | - public function set_subtotal( $value ) { |
|
| 2692 | - $this->set_prop( 'subtotal', $value ); |
|
| 2686 | + * Set the invoice sub total. |
|
| 2687 | + * |
|
| 2688 | + * @since 1.0.19 |
|
| 2689 | + * @param float $value sub total. |
|
| 2690 | + */ |
|
| 2691 | + public function set_subtotal( $value ) { |
|
| 2692 | + $this->set_prop( 'subtotal', $value ); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
| 2696 | - * Set the invoice discount amount. |
|
| 2697 | - * |
|
| 2698 | - * @since 1.0.19 |
|
| 2699 | - * @param float $value discount total. |
|
| 2700 | - */ |
|
| 2701 | - public function set_total_discount( $value ) { |
|
| 2702 | - $this->set_prop( 'total_discount', $value ); |
|
| 2696 | + * Set the invoice discount amount. |
|
| 2697 | + * |
|
| 2698 | + * @since 1.0.19 |
|
| 2699 | + * @param float $value discount total. |
|
| 2700 | + */ |
|
| 2701 | + public function set_total_discount( $value ) { |
|
| 2702 | + $this->set_prop( 'total_discount', $value ); |
|
| 2703 | 2703 | } |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
| 2706 | - * Alias of self::set_total_discount(). |
|
| 2707 | - * |
|
| 2708 | - * @since 1.0.19 |
|
| 2709 | - * @param float $value discount total. |
|
| 2710 | - */ |
|
| 2711 | - public function set_discount( $value ) { |
|
| 2712 | - $this->set_total_discount( $value ); |
|
| 2706 | + * Alias of self::set_total_discount(). |
|
| 2707 | + * |
|
| 2708 | + * @since 1.0.19 |
|
| 2709 | + * @param float $value discount total. |
|
| 2710 | + */ |
|
| 2711 | + public function set_discount( $value ) { |
|
| 2712 | + $this->set_total_discount( $value ); |
|
| 2713 | 2713 | } |
| 2714 | 2714 | |
| 2715 | 2715 | /** |
| 2716 | - * Set the invoice tax amount. |
|
| 2717 | - * |
|
| 2718 | - * @since 1.0.19 |
|
| 2719 | - * @param float $value tax total. |
|
| 2720 | - */ |
|
| 2721 | - public function set_total_tax( $value ) { |
|
| 2722 | - $this->set_prop( 'total_tax', $value ); |
|
| 2716 | + * Set the invoice tax amount. |
|
| 2717 | + * |
|
| 2718 | + * @since 1.0.19 |
|
| 2719 | + * @param float $value tax total. |
|
| 2720 | + */ |
|
| 2721 | + public function set_total_tax( $value ) { |
|
| 2722 | + $this->set_prop( 'total_tax', $value ); |
|
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | 2725 | /** |
| 2726 | - * Alias of self::set_total_tax(). |
|
| 2727 | - * |
|
| 2728 | - * @since 1.0.19 |
|
| 2729 | - * @param float $value tax total. |
|
| 2730 | - */ |
|
| 2731 | - public function set_tax_total( $value ) { |
|
| 2732 | - $this->set_total_tax( $value ); |
|
| 2726 | + * Alias of self::set_total_tax(). |
|
| 2727 | + * |
|
| 2728 | + * @since 1.0.19 |
|
| 2729 | + * @param float $value tax total. |
|
| 2730 | + */ |
|
| 2731 | + public function set_tax_total( $value ) { |
|
| 2732 | + $this->set_total_tax( $value ); |
|
| 2733 | 2733 | } |
| 2734 | 2734 | |
| 2735 | 2735 | /** |
| 2736 | - * Set the invoice fees amount. |
|
| 2737 | - * |
|
| 2738 | - * @since 1.0.19 |
|
| 2739 | - * @param float $value fees total. |
|
| 2740 | - */ |
|
| 2741 | - public function set_total_fees( $value ) { |
|
| 2742 | - $this->set_prop( 'total_fees', $value ); |
|
| 2736 | + * Set the invoice fees amount. |
|
| 2737 | + * |
|
| 2738 | + * @since 1.0.19 |
|
| 2739 | + * @param float $value fees total. |
|
| 2740 | + */ |
|
| 2741 | + public function set_total_fees( $value ) { |
|
| 2742 | + $this->set_prop( 'total_fees', $value ); |
|
| 2743 | 2743 | } |
| 2744 | 2744 | |
| 2745 | 2745 | /** |
| 2746 | - * Alias of self::set_total_fees(). |
|
| 2747 | - * |
|
| 2748 | - * @since 1.0.19 |
|
| 2749 | - * @param float $value fees total. |
|
| 2750 | - */ |
|
| 2751 | - public function set_fees_total( $value ) { |
|
| 2752 | - $this->set_total_fees( $value ); |
|
| 2746 | + * Alias of self::set_total_fees(). |
|
| 2747 | + * |
|
| 2748 | + * @since 1.0.19 |
|
| 2749 | + * @param float $value fees total. |
|
| 2750 | + */ |
|
| 2751 | + public function set_fees_total( $value ) { |
|
| 2752 | + $this->set_total_fees( $value ); |
|
| 2753 | 2753 | } |
| 2754 | 2754 | |
| 2755 | 2755 | /** |
| 2756 | - * Set the invoice fees. |
|
| 2757 | - * |
|
| 2758 | - * @since 1.0.19 |
|
| 2759 | - * @param array $value fees. |
|
| 2760 | - */ |
|
| 2761 | - public function set_fees( $value ) { |
|
| 2756 | + * Set the invoice fees. |
|
| 2757 | + * |
|
| 2758 | + * @since 1.0.19 |
|
| 2759 | + * @param array $value fees. |
|
| 2760 | + */ |
|
| 2761 | + public function set_fees( $value ) { |
|
| 2762 | 2762 | |
| 2763 | - if ( ! is_array( $value ) ) { |
|
| 2764 | - $value = array(); |
|
| 2765 | - } |
|
| 2763 | + if ( ! is_array( $value ) ) { |
|
| 2764 | + $value = array(); |
|
| 2765 | + } |
|
| 2766 | 2766 | |
| 2767 | - $this->set_prop( 'fees', $value ); |
|
| 2767 | + $this->set_prop( 'fees', $value ); |
|
| 2768 | 2768 | |
| 2769 | 2769 | } |
| 2770 | 2770 | |
| 2771 | 2771 | /** |
| 2772 | - * Set the invoice taxes. |
|
| 2773 | - * |
|
| 2774 | - * @since 1.0.19 |
|
| 2775 | - * @param array $value taxes. |
|
| 2776 | - */ |
|
| 2777 | - public function set_taxes( $value ) { |
|
| 2772 | + * Set the invoice taxes. |
|
| 2773 | + * |
|
| 2774 | + * @since 1.0.19 |
|
| 2775 | + * @param array $value taxes. |
|
| 2776 | + */ |
|
| 2777 | + public function set_taxes( $value ) { |
|
| 2778 | 2778 | |
| 2779 | - if ( ! is_array( $value ) ) { |
|
| 2780 | - $value = array(); |
|
| 2781 | - } |
|
| 2779 | + if ( ! is_array( $value ) ) { |
|
| 2780 | + $value = array(); |
|
| 2781 | + } |
|
| 2782 | 2782 | |
| 2783 | - $this->set_prop( 'taxes', $value ); |
|
| 2783 | + $this->set_prop( 'taxes', $value ); |
|
| 2784 | 2784 | |
| 2785 | 2785 | } |
| 2786 | 2786 | |
| 2787 | 2787 | /** |
| 2788 | - * Set the invoice discounts. |
|
| 2789 | - * |
|
| 2790 | - * @since 1.0.19 |
|
| 2791 | - * @param array $value discounts. |
|
| 2792 | - */ |
|
| 2793 | - public function set_discounts( $value ) { |
|
| 2788 | + * Set the invoice discounts. |
|
| 2789 | + * |
|
| 2790 | + * @since 1.0.19 |
|
| 2791 | + * @param array $value discounts. |
|
| 2792 | + */ |
|
| 2793 | + public function set_discounts( $value ) { |
|
| 2794 | 2794 | |
| 2795 | - if ( ! is_array( $value ) ) { |
|
| 2796 | - $value = array(); |
|
| 2797 | - } |
|
| 2795 | + if ( ! is_array( $value ) ) { |
|
| 2796 | + $value = array(); |
|
| 2797 | + } |
|
| 2798 | 2798 | |
| 2799 | - $this->set_prop( 'discounts', $value ); |
|
| 2799 | + $this->set_prop( 'discounts', $value ); |
|
| 2800 | 2800 | } |
| 2801 | 2801 | |
| 2802 | 2802 | /** |
| 2803 | - * Set the invoice items. |
|
| 2804 | - * |
|
| 2805 | - * @since 1.0.19 |
|
| 2806 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2807 | - */ |
|
| 2808 | - public function set_items( $value ) { |
|
| 2803 | + * Set the invoice items. |
|
| 2804 | + * |
|
| 2805 | + * @since 1.0.19 |
|
| 2806 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2807 | + */ |
|
| 2808 | + public function set_items( $value ) { |
|
| 2809 | 2809 | |
| 2810 | 2810 | // Remove existing items. |
| 2811 | 2811 | $this->set_prop( 'items', array() ); |
@@ -2822,95 +2822,95 @@ discard block |
||
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | 2824 | /** |
| 2825 | - * Set the payment form. |
|
| 2826 | - * |
|
| 2827 | - * @since 1.0.19 |
|
| 2828 | - * @param int $value payment form. |
|
| 2829 | - */ |
|
| 2830 | - public function set_payment_form( $value ) { |
|
| 2831 | - $this->set_prop( 'payment_form', $value ); |
|
| 2825 | + * Set the payment form. |
|
| 2826 | + * |
|
| 2827 | + * @since 1.0.19 |
|
| 2828 | + * @param int $value payment form. |
|
| 2829 | + */ |
|
| 2830 | + public function set_payment_form( $value ) { |
|
| 2831 | + $this->set_prop( 'payment_form', $value ); |
|
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | 2834 | /** |
| 2835 | - * Set the submission id. |
|
| 2836 | - * |
|
| 2837 | - * @since 1.0.19 |
|
| 2838 | - * @param string $value submission id. |
|
| 2839 | - */ |
|
| 2840 | - public function set_submission_id( $value ) { |
|
| 2841 | - $this->set_prop( 'submission_id', $value ); |
|
| 2835 | + * Set the submission id. |
|
| 2836 | + * |
|
| 2837 | + * @since 1.0.19 |
|
| 2838 | + * @param string $value submission id. |
|
| 2839 | + */ |
|
| 2840 | + public function set_submission_id( $value ) { |
|
| 2841 | + $this->set_prop( 'submission_id', $value ); |
|
| 2842 | 2842 | } |
| 2843 | 2843 | |
| 2844 | 2844 | /** |
| 2845 | - * Set the discount code. |
|
| 2846 | - * |
|
| 2847 | - * @since 1.0.19 |
|
| 2848 | - * @param string $value discount code. |
|
| 2849 | - */ |
|
| 2850 | - public function set_discount_code( $value ) { |
|
| 2851 | - $this->set_prop( 'discount_code', $value ); |
|
| 2845 | + * Set the discount code. |
|
| 2846 | + * |
|
| 2847 | + * @since 1.0.19 |
|
| 2848 | + * @param string $value discount code. |
|
| 2849 | + */ |
|
| 2850 | + public function set_discount_code( $value ) { |
|
| 2851 | + $this->set_prop( 'discount_code', $value ); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | /** |
| 2855 | - * Set the gateway. |
|
| 2856 | - * |
|
| 2857 | - * @since 1.0.19 |
|
| 2858 | - * @param string $value gateway. |
|
| 2859 | - */ |
|
| 2860 | - public function set_gateway( $value ) { |
|
| 2861 | - $this->set_prop( 'gateway', $value ); |
|
| 2855 | + * Set the gateway. |
|
| 2856 | + * |
|
| 2857 | + * @since 1.0.19 |
|
| 2858 | + * @param string $value gateway. |
|
| 2859 | + */ |
|
| 2860 | + public function set_gateway( $value ) { |
|
| 2861 | + $this->set_prop( 'gateway', $value ); |
|
| 2862 | 2862 | } |
| 2863 | 2863 | |
| 2864 | 2864 | /** |
| 2865 | - * Set the transaction id. |
|
| 2866 | - * |
|
| 2867 | - * @since 1.0.19 |
|
| 2868 | - * @param string $value transaction id. |
|
| 2869 | - */ |
|
| 2870 | - public function set_transaction_id( $value ) { |
|
| 2871 | - if ( ! empty( $value ) ) { |
|
| 2872 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2873 | - } |
|
| 2865 | + * Set the transaction id. |
|
| 2866 | + * |
|
| 2867 | + * @since 1.0.19 |
|
| 2868 | + * @param string $value transaction id. |
|
| 2869 | + */ |
|
| 2870 | + public function set_transaction_id( $value ) { |
|
| 2871 | + if ( ! empty( $value ) ) { |
|
| 2872 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2873 | + } |
|
| 2874 | 2874 | } |
| 2875 | 2875 | |
| 2876 | 2876 | /** |
| 2877 | - * Set the currency id. |
|
| 2878 | - * |
|
| 2879 | - * @since 1.0.19 |
|
| 2880 | - * @param string $value currency id. |
|
| 2881 | - */ |
|
| 2882 | - public function set_currency( $value ) { |
|
| 2883 | - $this->set_prop( 'currency', $value ); |
|
| 2877 | + * Set the currency id. |
|
| 2878 | + * |
|
| 2879 | + * @since 1.0.19 |
|
| 2880 | + * @param string $value currency id. |
|
| 2881 | + */ |
|
| 2882 | + public function set_currency( $value ) { |
|
| 2883 | + $this->set_prop( 'currency', $value ); |
|
| 2884 | 2884 | } |
| 2885 | 2885 | |
| 2886 | - /** |
|
| 2887 | - * Set whether to disable taxes. |
|
| 2888 | - * |
|
| 2889 | - * @since 1.0.19 |
|
| 2890 | - * @param bool $value value. |
|
| 2891 | - */ |
|
| 2892 | - public function set_disable_taxes( $value ) { |
|
| 2893 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2894 | - } |
|
| 2886 | + /** |
|
| 2887 | + * Set whether to disable taxes. |
|
| 2888 | + * |
|
| 2889 | + * @since 1.0.19 |
|
| 2890 | + * @param bool $value value. |
|
| 2891 | + */ |
|
| 2892 | + public function set_disable_taxes( $value ) { |
|
| 2893 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2894 | + } |
|
| 2895 | 2895 | |
| 2896 | 2896 | /** |
| 2897 | - * Set the subscription id. |
|
| 2898 | - * |
|
| 2899 | - * @since 1.0.19 |
|
| 2900 | - * @param string $value subscription id. |
|
| 2901 | - */ |
|
| 2902 | - public function set_subscription_id( $value ) { |
|
| 2903 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2904 | - } |
|
| 2897 | + * Set the subscription id. |
|
| 2898 | + * |
|
| 2899 | + * @since 1.0.19 |
|
| 2900 | + * @param string $value subscription id. |
|
| 2901 | + */ |
|
| 2902 | + public function set_subscription_id( $value ) { |
|
| 2903 | + $this->set_prop( 'subscription_id', $value ); |
|
| 2904 | + } |
|
| 2905 | 2905 | |
| 2906 | - /** |
|
| 2907 | - * Set the remote subscription id. |
|
| 2908 | - * |
|
| 2909 | - * @since 1.0.19 |
|
| 2910 | - * @param string $value subscription id. |
|
| 2911 | - */ |
|
| 2912 | - public function set_remote_subscription_id( $value ) { |
|
| 2913 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2906 | + /** |
|
| 2907 | + * Set the remote subscription id. |
|
| 2908 | + * |
|
| 2909 | + * @since 1.0.19 |
|
| 2910 | + * @param string $value subscription id. |
|
| 2911 | + */ |
|
| 2912 | + public function set_remote_subscription_id( $value ) { |
|
| 2913 | + $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2914 | 2914 | } |
| 2915 | 2915 | |
| 2916 | 2916 | /* |
@@ -2949,12 +2949,12 @@ discard block |
||
| 2949 | 2949 | */ |
| 2950 | 2950 | public function is_taxable() { |
| 2951 | 2951 | return ! $this->get_disable_taxes(); |
| 2952 | - } |
|
| 2952 | + } |
|
| 2953 | 2953 | |
| 2954 | - /** |
|
| 2955 | - * @deprecated |
|
| 2956 | - */ |
|
| 2957 | - public function has_vat() { |
|
| 2954 | + /** |
|
| 2955 | + * @deprecated |
|
| 2956 | + */ |
|
| 2957 | + public function has_vat() { |
|
| 2958 | 2958 | global $wpinv_euvat, $wpi_country; |
| 2959 | 2959 | |
| 2960 | 2960 | $requires_vat = false; |
@@ -2965,17 +2965,17 @@ discard block |
||
| 2965 | 2965 | } |
| 2966 | 2966 | |
| 2967 | 2967 | return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
| 2968 | - } |
|
| 2968 | + } |
|
| 2969 | 2969 | |
| 2970 | - /** |
|
| 2971 | - * Checks to see if the invoice requires payment. |
|
| 2972 | - */ |
|
| 2973 | - public function is_free() { |
|
| 2970 | + /** |
|
| 2971 | + * Checks to see if the invoice requires payment. |
|
| 2972 | + */ |
|
| 2973 | + public function is_free() { |
|
| 2974 | 2974 | $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
| 2975 | 2975 | |
| 2976 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2977 | - $is_free = false; |
|
| 2978 | - } |
|
| 2976 | + if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2977 | + $is_free = false; |
|
| 2978 | + } |
|
| 2979 | 2979 | |
| 2980 | 2980 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 2981 | 2981 | } |
@@ -2986,46 +2986,46 @@ discard block |
||
| 2986 | 2986 | public function is_paid() { |
| 2987 | 2987 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 2988 | 2988 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 2989 | - } |
|
| 2989 | + } |
|
| 2990 | 2990 | |
| 2991 | - /** |
|
| 2991 | + /** |
|
| 2992 | 2992 | * Checks if the invoice needs payment. |
| 2993 | 2993 | */ |
| 2994 | - public function needs_payment() { |
|
| 2995 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2994 | + public function needs_payment() { |
|
| 2995 | + $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2996 | 2996 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 2997 | 2997 | } |
| 2998 | 2998 | |
| 2999 | - /** |
|
| 2999 | + /** |
|
| 3000 | 3000 | * Checks if the invoice is refunded. |
| 3001 | 3001 | */ |
| 3002 | - public function is_refunded() { |
|
| 3002 | + public function is_refunded() { |
|
| 3003 | 3003 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 3004 | 3004 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 3005 | - } |
|
| 3005 | + } |
|
| 3006 | 3006 | |
| 3007 | - /** |
|
| 3007 | + /** |
|
| 3008 | 3008 | * Checks if the invoice is held. |
| 3009 | 3009 | */ |
| 3010 | - public function is_held() { |
|
| 3010 | + public function is_held() { |
|
| 3011 | 3011 | $is_held = $this->has_status( 'wpi-onhold' ); |
| 3012 | 3012 | return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
| 3013 | - } |
|
| 3013 | + } |
|
| 3014 | 3014 | |
| 3015 | - /** |
|
| 3015 | + /** |
|
| 3016 | 3016 | * Checks if the invoice is due. |
| 3017 | 3017 | */ |
| 3018 | - public function is_due() { |
|
| 3019 | - $due_date = $this->get_due_date(); |
|
| 3020 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3021 | - } |
|
| 3018 | + public function is_due() { |
|
| 3019 | + $due_date = $this->get_due_date(); |
|
| 3020 | + return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3021 | + } |
|
| 3022 | 3022 | |
| 3023 | - /** |
|
| 3023 | + /** |
|
| 3024 | 3024 | * Checks if the invoice is draft. |
| 3025 | 3025 | */ |
| 3026 | - public function is_draft() { |
|
| 3026 | + public function is_draft() { |
|
| 3027 | 3027 | return $this->has_status( 'draft, auto-draft' ); |
| 3028 | - } |
|
| 3028 | + } |
|
| 3029 | 3029 | |
| 3030 | 3030 | /** |
| 3031 | 3031 | * Checks if the invoice has a given status. |
@@ -3033,9 +3033,9 @@ discard block |
||
| 3033 | 3033 | public function has_status( $status ) { |
| 3034 | 3034 | $status = wpinv_parse_list( $status ); |
| 3035 | 3035 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 3036 | - } |
|
| 3036 | + } |
|
| 3037 | 3037 | |
| 3038 | - /** |
|
| 3038 | + /** |
|
| 3039 | 3039 | * Checks if the invoice is of a given type. |
| 3040 | 3040 | */ |
| 3041 | 3041 | public function is_type( $type ) { |
@@ -3058,25 +3058,25 @@ discard block |
||
| 3058 | 3058 | */ |
| 3059 | 3059 | public function has_free_trial() { |
| 3060 | 3060 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 3061 | - } |
|
| 3061 | + } |
|
| 3062 | 3062 | |
| 3063 | - /** |
|
| 3063 | + /** |
|
| 3064 | 3064 | * @deprecated |
| 3065 | 3065 | */ |
| 3066 | 3066 | public function is_free_trial() { |
| 3067 | 3067 | $this->has_free_trial(); |
| 3068 | 3068 | } |
| 3069 | 3069 | |
| 3070 | - /** |
|
| 3070 | + /** |
|
| 3071 | 3071 | * Check if the initial payment if 0. |
| 3072 | 3072 | * |
| 3073 | 3073 | */ |
| 3074 | - public function is_initial_free() { |
|
| 3074 | + public function is_initial_free() { |
|
| 3075 | 3075 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 3076 | 3076 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 3077 | 3077 | } |
| 3078 | 3078 | |
| 3079 | - /** |
|
| 3079 | + /** |
|
| 3080 | 3080 | * Check if the recurring item has a free trial. |
| 3081 | 3081 | * |
| 3082 | 3082 | */ |
@@ -3089,21 +3089,21 @@ discard block |
||
| 3089 | 3089 | |
| 3090 | 3090 | $item = $this->get_recurring( true ); |
| 3091 | 3091 | return $item->has_free_trial(); |
| 3092 | - } |
|
| 3092 | + } |
|
| 3093 | 3093 | |
| 3094 | - /** |
|
| 3094 | + /** |
|
| 3095 | 3095 | * Check if the free trial is a result of a discount. |
| 3096 | 3096 | */ |
| 3097 | 3097 | public function is_free_trial_from_discount() { |
| 3098 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3099 | - } |
|
| 3098 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3099 | + } |
|
| 3100 | 3100 | |
| 3101 | - /** |
|
| 3101 | + /** |
|
| 3102 | 3102 | * @deprecated |
| 3103 | 3103 | */ |
| 3104 | 3104 | public function discount_first_payment_only() { |
| 3105 | 3105 | |
| 3106 | - $discount_code = $this->get_discount_code(); |
|
| 3106 | + $discount_code = $this->get_discount_code(); |
|
| 3107 | 3107 | if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
| 3108 | 3108 | return true; |
| 3109 | 3109 | } |
@@ -3134,28 +3134,28 @@ discard block |
||
| 3134 | 3134 | */ |
| 3135 | 3135 | public function add_item( $item ) { |
| 3136 | 3136 | |
| 3137 | - if ( is_array( $item ) ) { |
|
| 3138 | - $item = $this->process_array_item( $item ); |
|
| 3139 | - } |
|
| 3137 | + if ( is_array( $item ) ) { |
|
| 3138 | + $item = $this->process_array_item( $item ); |
|
| 3139 | + } |
|
| 3140 | 3140 | |
| 3141 | - if ( is_numeric( $item ) ) { |
|
| 3142 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3143 | - } |
|
| 3141 | + if ( is_numeric( $item ) ) { |
|
| 3142 | + $item = new GetPaid_Form_Item( $item ); |
|
| 3143 | + } |
|
| 3144 | 3144 | |
| 3145 | 3145 | // Make sure that it is available for purchase. |
| 3146 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3147 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3146 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3147 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3148 | 3148 | } |
| 3149 | 3149 | |
| 3150 | 3150 | // Do we have a recurring item? |
| 3151 | - if ( $item->is_recurring() ) { |
|
| 3151 | + if ( $item->is_recurring() ) { |
|
| 3152 | 3152 | |
| 3153 | - // An invoice can only contain one recurring item. |
|
| 3154 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3155 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3156 | - } |
|
| 3153 | + // An invoice can only contain one recurring item. |
|
| 3154 | + if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3155 | + return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3156 | + } |
|
| 3157 | 3157 | |
| 3158 | - $this->recurring_item = $item->get_id(); |
|
| 3158 | + $this->recurring_item = $item->get_id(); |
|
| 3159 | 3159 | } |
| 3160 | 3160 | |
| 3161 | 3161 | // Invoice id. |
@@ -3166,60 +3166,60 @@ discard block |
||
| 3166 | 3166 | $items[ (int) $item->get_id() ] = $item; |
| 3167 | 3167 | |
| 3168 | 3168 | $this->set_prop( 'items', $items ); |
| 3169 | - return true; |
|
| 3170 | - } |
|
| 3169 | + return true; |
|
| 3170 | + } |
|
| 3171 | 3171 | |
| 3172 | - /** |
|
| 3173 | - * Converts an array to an item. |
|
| 3174 | - * |
|
| 3175 | - * @since 1.0.19 |
|
| 3176 | - * @return GetPaid_Form_Item |
|
| 3177 | - */ |
|
| 3178 | - protected function process_array_item( $array ) { |
|
| 3172 | + /** |
|
| 3173 | + * Converts an array to an item. |
|
| 3174 | + * |
|
| 3175 | + * @since 1.0.19 |
|
| 3176 | + * @return GetPaid_Form_Item |
|
| 3177 | + */ |
|
| 3178 | + protected function process_array_item( $array ) { |
|
| 3179 | 3179 | |
| 3180 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3181 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3180 | + $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3181 | + $item = new GetPaid_Form_Item( $item_id ); |
|
| 3182 | 3182 | |
| 3183 | - // Set item data. |
|
| 3184 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3185 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3186 | - $method = "set_$key"; |
|
| 3187 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3188 | - } |
|
| 3189 | - } |
|
| 3183 | + // Set item data. |
|
| 3184 | + foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3185 | + if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3186 | + $method = "set_$key"; |
|
| 3187 | + $item->$method( $array[ "item_$key" ] ); |
|
| 3188 | + } |
|
| 3189 | + } |
|
| 3190 | 3190 | |
| 3191 | - if ( isset( $array['quantity'] ) ) { |
|
| 3192 | - $item->set_quantity( $array['quantity'] ); |
|
| 3193 | - } |
|
| 3191 | + if ( isset( $array['quantity'] ) ) { |
|
| 3192 | + $item->set_quantity( $array['quantity'] ); |
|
| 3193 | + } |
|
| 3194 | 3194 | |
| 3195 | - // Set item meta. |
|
| 3196 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3197 | - $item->set_item_meta( $array['meta'] ); |
|
| 3198 | - } |
|
| 3195 | + // Set item meta. |
|
| 3196 | + if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3197 | + $item->set_item_meta( $array['meta'] ); |
|
| 3198 | + } |
|
| 3199 | 3199 | |
| 3200 | - return $item; |
|
| 3200 | + return $item; |
|
| 3201 | 3201 | |
| 3202 | - } |
|
| 3202 | + } |
|
| 3203 | 3203 | |
| 3204 | 3204 | /** |
| 3205 | - * Retrieves a specific item. |
|
| 3206 | - * |
|
| 3207 | - * @since 1.0.19 |
|
| 3208 | - */ |
|
| 3209 | - public function get_item( $item_id ) { |
|
| 3210 | - $items = $this->get_items(); |
|
| 3211 | - $item_id = (int) $item_id; |
|
| 3212 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3205 | + * Retrieves a specific item. |
|
| 3206 | + * |
|
| 3207 | + * @since 1.0.19 |
|
| 3208 | + */ |
|
| 3209 | + public function get_item( $item_id ) { |
|
| 3210 | + $items = $this->get_items(); |
|
| 3211 | + $item_id = (int) $item_id; |
|
| 3212 | + return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3213 | 3213 | } |
| 3214 | 3214 | |
| 3215 | 3215 | /** |
| 3216 | - * Removes a specific item. |
|
| 3217 | - * |
|
| 3218 | - * @since 1.0.19 |
|
| 3219 | - */ |
|
| 3220 | - public function remove_item( $item_id ) { |
|
| 3221 | - $items = $this->get_items(); |
|
| 3222 | - $item_id = (int) $item_id; |
|
| 3216 | + * Removes a specific item. |
|
| 3217 | + * |
|
| 3218 | + * @since 1.0.19 |
|
| 3219 | + */ |
|
| 3220 | + public function remove_item( $item_id ) { |
|
| 3221 | + $items = $this->get_items(); |
|
| 3222 | + $item_id = (int) $item_id; |
|
| 3223 | 3223 | |
| 3224 | 3224 | if ( $item_id == $this->recurring_item ) { |
| 3225 | 3225 | $this->recurring_item = null; |
@@ -3232,35 +3232,35 @@ discard block |
||
| 3232 | 3232 | } |
| 3233 | 3233 | |
| 3234 | 3234 | /** |
| 3235 | - * Adds a fee to the invoice. |
|
| 3236 | - * |
|
| 3237 | - * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3238 | - * @since 1.0.19 |
|
| 3239 | - */ |
|
| 3235 | + * Adds a fee to the invoice. |
|
| 3236 | + * |
|
| 3237 | + * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3238 | + * @since 1.0.19 |
|
| 3239 | + */ |
|
| 3240 | 3240 | public function add_fee( $fee ) { |
| 3241 | 3241 | |
| 3242 | - $fees = $this->get_fees(); |
|
| 3243 | - $fees[ $fee['name'] ] = $fee; |
|
| 3244 | - $this->set_prop( 'fees', $fees ); |
|
| 3242 | + $fees = $this->get_fees(); |
|
| 3243 | + $fees[ $fee['name'] ] = $fee; |
|
| 3244 | + $this->set_prop( 'fees', $fees ); |
|
| 3245 | 3245 | |
| 3246 | 3246 | } |
| 3247 | 3247 | |
| 3248 | 3248 | /** |
| 3249 | - * Retrieves a specific fee. |
|
| 3250 | - * |
|
| 3251 | - * @since 1.0.19 |
|
| 3252 | - */ |
|
| 3253 | - public function get_fee( $fee ) { |
|
| 3249 | + * Retrieves a specific fee. |
|
| 3250 | + * |
|
| 3251 | + * @since 1.0.19 |
|
| 3252 | + */ |
|
| 3253 | + public function get_fee( $fee ) { |
|
| 3254 | 3254 | $fees = $this->get_fees(); |
| 3255 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3255 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3256 | 3256 | } |
| 3257 | 3257 | |
| 3258 | 3258 | /** |
| 3259 | - * Removes a specific fee. |
|
| 3260 | - * |
|
| 3261 | - * @since 1.0.19 |
|
| 3262 | - */ |
|
| 3263 | - public function remove_fee( $fee ) { |
|
| 3259 | + * Removes a specific fee. |
|
| 3260 | + * |
|
| 3261 | + * @since 1.0.19 |
|
| 3262 | + */ |
|
| 3263 | + public function remove_fee( $fee ) { |
|
| 3264 | 3264 | $fees = $this->get_fees(); |
| 3265 | 3265 | if ( isset( $fees[ $fee ] ) ) { |
| 3266 | 3266 | unset( $fees[ $fee ] ); |
@@ -3268,43 +3268,43 @@ discard block |
||
| 3268 | 3268 | } |
| 3269 | 3269 | } |
| 3270 | 3270 | |
| 3271 | - /** |
|
| 3272 | - * Adds a discount to the invoice. |
|
| 3273 | - * |
|
| 3274 | - * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3275 | - * @since 1.0.19 |
|
| 3276 | - */ |
|
| 3277 | - public function add_discount( $discount ) { |
|
| 3271 | + /** |
|
| 3272 | + * Adds a discount to the invoice. |
|
| 3273 | + * |
|
| 3274 | + * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3275 | + * @since 1.0.19 |
|
| 3276 | + */ |
|
| 3277 | + public function add_discount( $discount ) { |
|
| 3278 | 3278 | |
| 3279 | - $discounts = $this->get_discounts(); |
|
| 3280 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3281 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3279 | + $discounts = $this->get_discounts(); |
|
| 3280 | + $discounts[ $discount['name'] ] = $discount; |
|
| 3281 | + $this->set_prop( 'discounts', $discounts ); |
|
| 3282 | 3282 | |
| 3283 | - } |
|
| 3283 | + } |
|
| 3284 | 3284 | |
| 3285 | 3285 | /** |
| 3286 | - * Retrieves a specific discount. |
|
| 3287 | - * |
|
| 3288 | - * @since 1.0.19 |
|
| 3289 | - * @return float |
|
| 3290 | - */ |
|
| 3291 | - public function get_discount( $discount = false ) { |
|
| 3286 | + * Retrieves a specific discount. |
|
| 3287 | + * |
|
| 3288 | + * @since 1.0.19 |
|
| 3289 | + * @return float |
|
| 3290 | + */ |
|
| 3291 | + public function get_discount( $discount = false ) { |
|
| 3292 | 3292 | |
| 3293 | - // Backwards compatibilty. |
|
| 3294 | - if ( empty( $discount ) ) { |
|
| 3295 | - return $this->get_total_discount(); |
|
| 3296 | - } |
|
| 3293 | + // Backwards compatibilty. |
|
| 3294 | + if ( empty( $discount ) ) { |
|
| 3295 | + return $this->get_total_discount(); |
|
| 3296 | + } |
|
| 3297 | 3297 | |
| 3298 | 3298 | $discounts = $this->get_discounts(); |
| 3299 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3299 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3300 | 3300 | } |
| 3301 | 3301 | |
| 3302 | 3302 | /** |
| 3303 | - * Removes a specific discount. |
|
| 3304 | - * |
|
| 3305 | - * @since 1.0.19 |
|
| 3306 | - */ |
|
| 3307 | - public function remove_discount( $discount ) { |
|
| 3303 | + * Removes a specific discount. |
|
| 3304 | + * |
|
| 3305 | + * @since 1.0.19 |
|
| 3306 | + */ |
|
| 3307 | + public function remove_discount( $discount ) { |
|
| 3308 | 3308 | $discounts = $this->get_discounts(); |
| 3309 | 3309 | if ( isset( $discounts[ $discount ] ) ) { |
| 3310 | 3310 | unset( $discounts[ $discount ] ); |
@@ -3321,34 +3321,34 @@ discard block |
||
| 3321 | 3321 | if ( $this->is_taxable() ) { |
| 3322 | 3322 | |
| 3323 | 3323 | $taxes = $this->get_taxes(); |
| 3324 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3325 | - $this->set_prop( 'taxes', $tax ); |
|
| 3324 | + $taxes[ $tax['name'] ] = $tax; |
|
| 3325 | + $this->set_prop( 'taxes', $tax ); |
|
| 3326 | 3326 | |
| 3327 | 3327 | } |
| 3328 | 3328 | } |
| 3329 | 3329 | |
| 3330 | 3330 | /** |
| 3331 | - * Retrieves a specific tax. |
|
| 3332 | - * |
|
| 3333 | - * @since 1.0.19 |
|
| 3334 | - */ |
|
| 3335 | - public function get_tax( $tax = null ) { |
|
| 3331 | + * Retrieves a specific tax. |
|
| 3332 | + * |
|
| 3333 | + * @since 1.0.19 |
|
| 3334 | + */ |
|
| 3335 | + public function get_tax( $tax = null ) { |
|
| 3336 | 3336 | |
| 3337 | - // Backwards compatility. |
|
| 3338 | - if ( empty( $tax ) ) { |
|
| 3339 | - return $this->get_total_tax(); |
|
| 3340 | - } |
|
| 3337 | + // Backwards compatility. |
|
| 3338 | + if ( empty( $tax ) ) { |
|
| 3339 | + return $this->get_total_tax(); |
|
| 3340 | + } |
|
| 3341 | 3341 | |
| 3342 | 3342 | $taxes = $this->get_taxes(); |
| 3343 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3343 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3344 | 3344 | } |
| 3345 | 3345 | |
| 3346 | 3346 | /** |
| 3347 | - * Removes a specific tax. |
|
| 3348 | - * |
|
| 3349 | - * @since 1.0.19 |
|
| 3350 | - */ |
|
| 3351 | - public function remove_tax( $tax ) { |
|
| 3347 | + * Removes a specific tax. |
|
| 3348 | + * |
|
| 3349 | + * @since 1.0.19 |
|
| 3350 | + */ |
|
| 3351 | + public function remove_tax( $tax ) { |
|
| 3352 | 3352 | $taxes = $this->get_taxes(); |
| 3353 | 3353 | if ( isset( $taxes[ $tax ] ) ) { |
| 3354 | 3354 | unset( $taxes[ $tax ] ); |
@@ -3357,134 +3357,134 @@ discard block |
||
| 3357 | 3357 | } |
| 3358 | 3358 | |
| 3359 | 3359 | /** |
| 3360 | - * Recalculates the invoice subtotal. |
|
| 3361 | - * |
|
| 3362 | - * @since 1.0.19 |
|
| 3363 | - * @return float The recalculated subtotal |
|
| 3364 | - */ |
|
| 3365 | - public function recalculate_subtotal() { |
|
| 3360 | + * Recalculates the invoice subtotal. |
|
| 3361 | + * |
|
| 3362 | + * @since 1.0.19 |
|
| 3363 | + * @return float The recalculated subtotal |
|
| 3364 | + */ |
|
| 3365 | + public function recalculate_subtotal() { |
|
| 3366 | 3366 | $items = $this->get_items(); |
| 3367 | - $subtotal = 0; |
|
| 3368 | - $recurring = 0; |
|
| 3367 | + $subtotal = 0; |
|
| 3368 | + $recurring = 0; |
|
| 3369 | 3369 | |
| 3370 | 3370 | foreach ( $items as $item ) { |
| 3371 | - $subtotal += $item->get_sub_total(); |
|
| 3372 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3371 | + $subtotal += $item->get_sub_total(); |
|
| 3372 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3373 | 3373 | } |
| 3374 | 3374 | |
| 3375 | - $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3376 | - $this->set_subtotal( $current ); |
|
| 3375 | + $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3376 | + $this->set_subtotal( $current ); |
|
| 3377 | 3377 | |
| 3378 | - $this->totals['subtotal'] = array( |
|
| 3379 | - 'initial' => $subtotal, |
|
| 3380 | - 'recurring' => $recurring, |
|
| 3381 | - ); |
|
| 3378 | + $this->totals['subtotal'] = array( |
|
| 3379 | + 'initial' => $subtotal, |
|
| 3380 | + 'recurring' => $recurring, |
|
| 3381 | + ); |
|
| 3382 | 3382 | |
| 3383 | 3383 | return $current; |
| 3384 | 3384 | } |
| 3385 | 3385 | |
| 3386 | 3386 | /** |
| 3387 | - * Recalculates the invoice discount total. |
|
| 3388 | - * |
|
| 3389 | - * @since 1.0.19 |
|
| 3390 | - * @return float The recalculated discount |
|
| 3391 | - */ |
|
| 3392 | - public function recalculate_total_discount() { |
|
| 3387 | + * Recalculates the invoice discount total. |
|
| 3388 | + * |
|
| 3389 | + * @since 1.0.19 |
|
| 3390 | + * @return float The recalculated discount |
|
| 3391 | + */ |
|
| 3392 | + public function recalculate_total_discount() { |
|
| 3393 | 3393 | $discounts = $this->get_discounts(); |
| 3394 | - $discount = 0; |
|
| 3395 | - $recurring = 0; |
|
| 3394 | + $discount = 0; |
|
| 3395 | + $recurring = 0; |
|
| 3396 | 3396 | |
| 3397 | 3397 | foreach ( $discounts as $data ) { |
| 3398 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3399 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3400 | - } |
|
| 3398 | + $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3399 | + $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3400 | + } |
|
| 3401 | 3401 | |
| 3402 | - $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3402 | + $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3403 | 3403 | |
| 3404 | - $this->set_total_discount( $current ); |
|
| 3404 | + $this->set_total_discount( $current ); |
|
| 3405 | 3405 | |
| 3406 | - $this->totals['discount'] = array( |
|
| 3407 | - 'initial' => $discount, |
|
| 3408 | - 'recurring' => $recurring, |
|
| 3409 | - ); |
|
| 3406 | + $this->totals['discount'] = array( |
|
| 3407 | + 'initial' => $discount, |
|
| 3408 | + 'recurring' => $recurring, |
|
| 3409 | + ); |
|
| 3410 | 3410 | |
| 3411 | - return $current; |
|
| 3411 | + return $current; |
|
| 3412 | 3412 | |
| 3413 | 3413 | } |
| 3414 | 3414 | |
| 3415 | 3415 | /** |
| 3416 | - * Recalculates the invoice tax total. |
|
| 3417 | - * |
|
| 3418 | - * @since 1.0.19 |
|
| 3419 | - * @return float The recalculated tax |
|
| 3420 | - */ |
|
| 3421 | - public function recalculate_total_tax() { |
|
| 3416 | + * Recalculates the invoice tax total. |
|
| 3417 | + * |
|
| 3418 | + * @since 1.0.19 |
|
| 3419 | + * @return float The recalculated tax |
|
| 3420 | + */ |
|
| 3421 | + public function recalculate_total_tax() { |
|
| 3422 | 3422 | $taxes = $this->get_taxes(); |
| 3423 | - $tax = 0; |
|
| 3424 | - $recurring = 0; |
|
| 3423 | + $tax = 0; |
|
| 3424 | + $recurring = 0; |
|
| 3425 | 3425 | |
| 3426 | 3426 | foreach ( $taxes as $data ) { |
| 3427 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3428 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3429 | - } |
|
| 3427 | + $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3428 | + $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3429 | + } |
|
| 3430 | 3430 | |
| 3431 | - $current = $this->is_renewal() ? $recurring : $tax; |
|
| 3432 | - $this->set_total_tax( $current ); |
|
| 3431 | + $current = $this->is_renewal() ? $recurring : $tax; |
|
| 3432 | + $this->set_total_tax( $current ); |
|
| 3433 | 3433 | |
| 3434 | - $this->totals['tax'] = array( |
|
| 3435 | - 'initial' => $tax, |
|
| 3436 | - 'recurring' => $recurring, |
|
| 3437 | - ); |
|
| 3434 | + $this->totals['tax'] = array( |
|
| 3435 | + 'initial' => $tax, |
|
| 3436 | + 'recurring' => $recurring, |
|
| 3437 | + ); |
|
| 3438 | 3438 | |
| 3439 | - return $current; |
|
| 3439 | + return $current; |
|
| 3440 | 3440 | |
| 3441 | 3441 | } |
| 3442 | 3442 | |
| 3443 | 3443 | /** |
| 3444 | - * Recalculates the invoice fees total. |
|
| 3445 | - * |
|
| 3446 | - * @since 1.0.19 |
|
| 3447 | - * @return float The recalculated fee |
|
| 3448 | - */ |
|
| 3449 | - public function recalculate_total_fees() { |
|
| 3450 | - $fees = $this->get_fees(); |
|
| 3451 | - $fee = 0; |
|
| 3452 | - $recurring = 0; |
|
| 3444 | + * Recalculates the invoice fees total. |
|
| 3445 | + * |
|
| 3446 | + * @since 1.0.19 |
|
| 3447 | + * @return float The recalculated fee |
|
| 3448 | + */ |
|
| 3449 | + public function recalculate_total_fees() { |
|
| 3450 | + $fees = $this->get_fees(); |
|
| 3451 | + $fee = 0; |
|
| 3452 | + $recurring = 0; |
|
| 3453 | 3453 | |
| 3454 | 3454 | foreach ( $fees as $data ) { |
| 3455 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3456 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3457 | - } |
|
| 3455 | + $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3456 | + $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3457 | + } |
|
| 3458 | 3458 | |
| 3459 | - $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3460 | - $this->set_total_fees( $current ); |
|
| 3459 | + $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3460 | + $this->set_total_fees( $current ); |
|
| 3461 | 3461 | |
| 3462 | - $this->totals['fee'] = array( |
|
| 3463 | - 'initial' => $fee, |
|
| 3464 | - 'recurring' => $recurring, |
|
| 3465 | - ); |
|
| 3462 | + $this->totals['fee'] = array( |
|
| 3463 | + 'initial' => $fee, |
|
| 3464 | + 'recurring' => $recurring, |
|
| 3465 | + ); |
|
| 3466 | 3466 | |
| 3467 | 3467 | $this->set_total_fees( $fee ); |
| 3468 | 3468 | return $current; |
| 3469 | 3469 | } |
| 3470 | 3470 | |
| 3471 | 3471 | /** |
| 3472 | - * Recalculates the invoice total. |
|
| 3473 | - * |
|
| 3474 | - * @since 1.0.19 |
|
| 3472 | + * Recalculates the invoice total. |
|
| 3473 | + * |
|
| 3474 | + * @since 1.0.19 |
|
| 3475 | 3475 | * @return float The invoice total |
| 3476 | - */ |
|
| 3477 | - public function recalculate_total() { |
|
| 3476 | + */ |
|
| 3477 | + public function recalculate_total() { |
|
| 3478 | 3478 | $this->recalculate_subtotal(); |
| 3479 | 3479 | $this->recalculate_total_fees(); |
| 3480 | 3480 | $this->recalculate_total_discount(); |
| 3481 | 3481 | $this->recalculate_total_tax(); |
| 3482 | - return $this->get_total(); |
|
| 3483 | - } |
|
| 3482 | + return $this->get_total(); |
|
| 3483 | + } |
|
| 3484 | 3484 | |
| 3485 | - /** |
|
| 3486 | - * @deprecated |
|
| 3487 | - */ |
|
| 3485 | + /** |
|
| 3486 | + * @deprecated |
|
| 3487 | + */ |
|
| 3488 | 3488 | public function recalculate_totals( $temp = false ) { |
| 3489 | 3489 | $this->update_items( $temp ); |
| 3490 | 3490 | $this->save( true ); |
@@ -3502,7 +3502,7 @@ discard block |
||
| 3502 | 3502 | * Adds a note to an invoice. |
| 3503 | 3503 | * |
| 3504 | 3504 | * @param string $note The note being added. |
| 3505 | - * @return int|false The new note's ID on success, false on failure. |
|
| 3505 | + * @return int|false The new note's ID on success, false on failure. |
|
| 3506 | 3506 | * |
| 3507 | 3507 | */ |
| 3508 | 3508 | public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
@@ -3512,21 +3512,21 @@ discard block |
||
| 3512 | 3512 | return false; |
| 3513 | 3513 | } |
| 3514 | 3514 | |
| 3515 | - $author = 'System'; |
|
| 3516 | - $author_email = '[email protected]'; |
|
| 3515 | + $author = 'System'; |
|
| 3516 | + $author_email = '[email protected]'; |
|
| 3517 | 3517 | |
| 3518 | - // If this is an admin comment or it has been added by the user. |
|
| 3519 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3520 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3518 | + // If this is an admin comment or it has been added by the user. |
|
| 3519 | + if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3520 | + $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3521 | 3521 | $author = $user->display_name; |
| 3522 | 3522 | $author_email = $user->user_email; |
| 3523 | - } |
|
| 3523 | + } |
|
| 3524 | 3524 | |
| 3525 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3525 | + return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3526 | 3526 | |
| 3527 | - } |
|
| 3527 | + } |
|
| 3528 | 3528 | |
| 3529 | - /** |
|
| 3529 | + /** |
|
| 3530 | 3530 | * Generates a unique key for the invoice. |
| 3531 | 3531 | */ |
| 3532 | 3532 | public function generate_key( $string = '' ) { |
@@ -3546,113 +3546,113 @@ discard block |
||
| 3546 | 3546 | $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
| 3547 | 3547 | } |
| 3548 | 3548 | |
| 3549 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3550 | - |
|
| 3551 | - } |
|
| 3552 | - |
|
| 3553 | - /** |
|
| 3554 | - * Handle the status transition. |
|
| 3555 | - */ |
|
| 3556 | - protected function status_transition() { |
|
| 3557 | - $status_transition = $this->status_transition; |
|
| 3558 | - |
|
| 3559 | - // Reset status transition variable. |
|
| 3560 | - $this->status_transition = false; |
|
| 3561 | - |
|
| 3562 | - if ( $status_transition ) { |
|
| 3563 | - try { |
|
| 3549 | + return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3564 | 3550 | |
| 3565 | - // Fire a hook for the status change. |
|
| 3566 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3567 | - |
|
| 3568 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3569 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3570 | - |
|
| 3571 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3572 | - |
|
| 3573 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3574 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3575 | - |
|
| 3576 | - // Fire another hook. |
|
| 3577 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3578 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3579 | - |
|
| 3580 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3581 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3582 | - |
|
| 3583 | - // Note the transition occurred. |
|
| 3584 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3585 | - |
|
| 3586 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3587 | - if ( |
|
| 3588 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3589 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3590 | - ) { |
|
| 3591 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3592 | - } |
|
| 3593 | - |
|
| 3594 | - // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3595 | - if ( |
|
| 3596 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3597 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3598 | - ) { |
|
| 3599 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3600 | - } |
|
| 3601 | - } else { |
|
| 3602 | - /* translators: %s: new invoice status */ |
|
| 3603 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3604 | - |
|
| 3605 | - // Note the transition occurred. |
|
| 3606 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3551 | + } |
|
| 3607 | 3552 | |
| 3608 | - } |
|
| 3609 | - } catch ( Exception $e ) { |
|
| 3610 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3611 | - } |
|
| 3612 | - } |
|
| 3613 | - } |
|
| 3553 | + /** |
|
| 3554 | + * Handle the status transition. |
|
| 3555 | + */ |
|
| 3556 | + protected function status_transition() { |
|
| 3557 | + $status_transition = $this->status_transition; |
|
| 3558 | + |
|
| 3559 | + // Reset status transition variable. |
|
| 3560 | + $this->status_transition = false; |
|
| 3561 | + |
|
| 3562 | + if ( $status_transition ) { |
|
| 3563 | + try { |
|
| 3564 | + |
|
| 3565 | + // Fire a hook for the status change. |
|
| 3566 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3567 | + |
|
| 3568 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3569 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3570 | + |
|
| 3571 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3572 | + |
|
| 3573 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3574 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3575 | + |
|
| 3576 | + // Fire another hook. |
|
| 3577 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3578 | + do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3579 | + |
|
| 3580 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3581 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3582 | + |
|
| 3583 | + // Note the transition occurred. |
|
| 3584 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3585 | + |
|
| 3586 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3587 | + if ( |
|
| 3588 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3589 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3590 | + ) { |
|
| 3591 | + do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3592 | + } |
|
| 3593 | + |
|
| 3594 | + // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3595 | + if ( |
|
| 3596 | + in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3597 | + && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3598 | + ) { |
|
| 3599 | + do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3600 | + } |
|
| 3601 | + } else { |
|
| 3602 | + /* translators: %s: new invoice status */ |
|
| 3603 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3604 | + |
|
| 3605 | + // Note the transition occurred. |
|
| 3606 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3607 | + |
|
| 3608 | + } |
|
| 3609 | + } catch ( Exception $e ) { |
|
| 3610 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3611 | + } |
|
| 3612 | + } |
|
| 3613 | + } |
|
| 3614 | 3614 | |
| 3615 | - /** |
|
| 3616 | - * Updates an invoice status. |
|
| 3617 | - */ |
|
| 3618 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3615 | + /** |
|
| 3616 | + * Updates an invoice status. |
|
| 3617 | + */ |
|
| 3618 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3619 | 3619 | |
| 3620 | - // Fires before updating a status. |
|
| 3621 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3620 | + // Fires before updating a status. |
|
| 3621 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3622 | 3622 | |
| 3623 | - // Update the status. |
|
| 3624 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3623 | + // Update the status. |
|
| 3624 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3625 | 3625 | |
| 3626 | - // Save the order. |
|
| 3627 | - return $this->save(); |
|
| 3626 | + // Save the order. |
|
| 3627 | + return $this->save(); |
|
| 3628 | 3628 | |
| 3629 | - } |
|
| 3629 | + } |
|
| 3630 | 3630 | |
| 3631 | - /** |
|
| 3632 | - * @deprecated |
|
| 3633 | - */ |
|
| 3634 | - public function refresh_item_ids() { |
|
| 3631 | + /** |
|
| 3632 | + * @deprecated |
|
| 3633 | + */ |
|
| 3634 | + public function refresh_item_ids() { |
|
| 3635 | 3635 | $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
| 3636 | 3636 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3637 | - } |
|
| 3637 | + } |
|
| 3638 | 3638 | |
| 3639 | - /** |
|
| 3640 | - * @deprecated |
|
| 3641 | - */ |
|
| 3642 | - public function update_items( $temp = false ) { |
|
| 3639 | + /** |
|
| 3640 | + * @deprecated |
|
| 3641 | + */ |
|
| 3642 | + public function update_items( $temp = false ) { |
|
| 3643 | 3643 | |
| 3644 | - $this->set_items( $this->get_items() ); |
|
| 3644 | + $this->set_items( $this->get_items() ); |
|
| 3645 | 3645 | |
| 3646 | - if ( ! $temp ) { |
|
| 3647 | - $this->save(); |
|
| 3648 | - } |
|
| 3646 | + if ( ! $temp ) { |
|
| 3647 | + $this->save(); |
|
| 3648 | + } |
|
| 3649 | 3649 | |
| 3650 | 3650 | return $this; |
| 3651 | - } |
|
| 3651 | + } |
|
| 3652 | 3652 | |
| 3653 | - /** |
|
| 3654 | - * @deprecated |
|
| 3655 | - */ |
|
| 3653 | + /** |
|
| 3654 | + * @deprecated |
|
| 3655 | + */ |
|
| 3656 | 3656 | public function validate_discount() { |
| 3657 | 3657 | |
| 3658 | 3658 | $discount_code = $this->get_discount_code(); |
@@ -3668,97 +3668,97 @@ discard block |
||
| 3668 | 3668 | |
| 3669 | 3669 | } |
| 3670 | 3670 | |
| 3671 | - /** |
|
| 3672 | - * Refunds an invoice. |
|
| 3673 | - */ |
|
| 3671 | + /** |
|
| 3672 | + * Refunds an invoice. |
|
| 3673 | + */ |
|
| 3674 | 3674 | public function refund() { |
| 3675 | - $this->set_status( 'wpi-refunded' ); |
|
| 3675 | + $this->set_status( 'wpi-refunded' ); |
|
| 3676 | 3676 | $this->save(); |
| 3677 | - } |
|
| 3677 | + } |
|
| 3678 | 3678 | |
| 3679 | - /** |
|
| 3680 | - * Marks an invoice as paid. |
|
| 3681 | - * |
|
| 3682 | - * @param string $transaction_id |
|
| 3683 | - */ |
|
| 3679 | + /** |
|
| 3680 | + * Marks an invoice as paid. |
|
| 3681 | + * |
|
| 3682 | + * @param string $transaction_id |
|
| 3683 | + */ |
|
| 3684 | 3684 | public function mark_paid( $transaction_id = null, $note = '' ) { |
| 3685 | 3685 | |
| 3686 | - // Set the transaction id. |
|
| 3687 | - if ( empty( $transaction_id ) ) { |
|
| 3688 | - $transaction_id = $this->generate_key('trans_'); |
|
| 3689 | - } |
|
| 3686 | + // Set the transaction id. |
|
| 3687 | + if ( empty( $transaction_id ) ) { |
|
| 3688 | + $transaction_id = $this->generate_key('trans_'); |
|
| 3689 | + } |
|
| 3690 | 3690 | |
| 3691 | - if ( ! $this->get_transaction_id() ) { |
|
| 3692 | - $this->set_transaction_id( $transaction_id ); |
|
| 3693 | - } |
|
| 3691 | + if ( ! $this->get_transaction_id() ) { |
|
| 3692 | + $this->set_transaction_id( $transaction_id ); |
|
| 3693 | + } |
|
| 3694 | 3694 | |
| 3695 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3696 | - return $this->save(); |
|
| 3697 | - } |
|
| 3695 | + if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3696 | + return $this->save(); |
|
| 3697 | + } |
|
| 3698 | 3698 | |
| 3699 | - // Set the completed date. |
|
| 3700 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3699 | + // Set the completed date. |
|
| 3700 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3701 | 3701 | |
| 3702 | - // Set the new status. |
|
| 3703 | - if ( $this->is_renewal() ) { |
|
| 3702 | + // Set the new status. |
|
| 3703 | + if ( $this->is_renewal() ) { |
|
| 3704 | 3704 | |
| 3705 | - $_note = sprintf( |
|
| 3706 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3707 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3708 | - ); |
|
| 3705 | + $_note = sprintf( |
|
| 3706 | + __( 'Renewed via %s', 'invoicing' ), |
|
| 3707 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3708 | + ); |
|
| 3709 | 3709 | |
| 3710 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3711 | - $_note = $note; |
|
| 3712 | - } |
|
| 3710 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3711 | + $_note = $note; |
|
| 3712 | + } |
|
| 3713 | 3713 | |
| 3714 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3714 | + $this->set_status( 'wpi-renewal', $_note ); |
|
| 3715 | 3715 | |
| 3716 | - } else { |
|
| 3716 | + } else { |
|
| 3717 | 3717 | |
| 3718 | - $_note = sprintf( |
|
| 3719 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3720 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3721 | - ); |
|
| 3718 | + $_note = sprintf( |
|
| 3719 | + __( 'Paid via %s', 'invoicing' ), |
|
| 3720 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3721 | + ); |
|
| 3722 | 3722 | |
| 3723 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3724 | - $_note = $note; |
|
| 3725 | - } |
|
| 3723 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3724 | + $_note = $note; |
|
| 3725 | + } |
|
| 3726 | 3726 | |
| 3727 | - $this->set_status( 'publish',$_note ); |
|
| 3727 | + $this->set_status( 'publish',$_note ); |
|
| 3728 | 3728 | |
| 3729 | - } |
|
| 3729 | + } |
|
| 3730 | 3730 | |
| 3731 | - // Set checkout mode. |
|
| 3732 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3733 | - $this->set_mode( $mode ); |
|
| 3731 | + // Set checkout mode. |
|
| 3732 | + $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3733 | + $this->set_mode( $mode ); |
|
| 3734 | 3734 | |
| 3735 | - // Save the invoice. |
|
| 3735 | + // Save the invoice. |
|
| 3736 | 3736 | $this->save(); |
| 3737 | - } |
|
| 3738 | - |
|
| 3739 | - |
|
| 3740 | - /** |
|
| 3741 | - * Save data to the database. |
|
| 3742 | - * |
|
| 3743 | - * @since 1.0.19 |
|
| 3744 | - * @return int invoice ID |
|
| 3745 | - */ |
|
| 3746 | - public function save() { |
|
| 3747 | - $this->maybe_set_date_paid(); |
|
| 3748 | - $this->maybe_set_key(); |
|
| 3749 | - parent::save(); |
|
| 3750 | - $this->clear_cache(); |
|
| 3751 | - $this->status_transition(); |
|
| 3752 | - return $this->get_id(); |
|
| 3753 | - } |
|
| 3754 | - |
|
| 3755 | - /** |
|
| 3737 | + } |
|
| 3738 | + |
|
| 3739 | + |
|
| 3740 | + /** |
|
| 3741 | + * Save data to the database. |
|
| 3742 | + * |
|
| 3743 | + * @since 1.0.19 |
|
| 3744 | + * @return int invoice ID |
|
| 3745 | + */ |
|
| 3746 | + public function save() { |
|
| 3747 | + $this->maybe_set_date_paid(); |
|
| 3748 | + $this->maybe_set_key(); |
|
| 3749 | + parent::save(); |
|
| 3750 | + $this->clear_cache(); |
|
| 3751 | + $this->status_transition(); |
|
| 3752 | + return $this->get_id(); |
|
| 3753 | + } |
|
| 3754 | + |
|
| 3755 | + /** |
|
| 3756 | 3756 | * Clears the subscription's cache. |
| 3757 | 3757 | */ |
| 3758 | 3758 | public function clear_cache() { |
| 3759 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3760 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3761 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3762 | - } |
|
| 3759 | + wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3760 | + wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3761 | + wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3762 | + } |
|
| 3763 | 3763 | |
| 3764 | 3764 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Invoice class. |
@@ -135,40 +135,40 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
| 137 | 137 | */ |
| 138 | - public function __construct( $invoice = false ) { |
|
| 138 | + public function __construct($invoice = false) { |
|
| 139 | 139 | |
| 140 | - parent::__construct( $invoice ); |
|
| 140 | + parent::__construct($invoice); |
|
| 141 | 141 | |
| 142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 143 | - $this->set_id( $invoice ); |
|
| 144 | - } elseif ( $invoice instanceof self ) { |
|
| 145 | - $this->set_id( $invoice->get_id() ); |
|
| 146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | - $this->set_id( $invoice->ID ); |
|
| 148 | - } elseif ( is_array( $invoice ) ) { |
|
| 149 | - $this->set_props( $invoice ); |
|
| 142 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
| 143 | + $this->set_id($invoice); |
|
| 144 | + } elseif ($invoice instanceof self) { |
|
| 145 | + $this->set_id($invoice->get_id()); |
|
| 146 | + } elseif (!empty($invoice->ID)) { |
|
| 147 | + $this->set_id($invoice->ID); |
|
| 148 | + } elseif (is_array($invoice)) { |
|
| 149 | + $this->set_props($invoice); |
|
| 150 | 150 | |
| 151 | - if ( isset( $invoice['ID'] ) ) { |
|
| 152 | - $this->set_id( $invoice['ID'] ); |
|
| 151 | + if (isset($invoice['ID'])) { |
|
| 152 | + $this->set_id($invoice['ID']); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | - $this->set_id( $invoice_id ); |
|
| 161 | - }else { |
|
| 162 | - $this->set_object_read( true ); |
|
| 155 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
| 156 | + $this->set_id($invoice_id); |
|
| 157 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
| 158 | + $this->set_id($invoice_id); |
|
| 159 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
| 160 | + $this->set_id($invoice_id); |
|
| 161 | + } else { |
|
| 162 | + $this->set_object_read(true); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Load the datastore. |
| 166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 166 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 167 | 167 | |
| 168 | - if ( $this->get_id() > 0 ) { |
|
| 169 | - $this->post = get_post( $this->get_id() ); |
|
| 168 | + if ($this->get_id() > 0) { |
|
| 169 | + $this->post = get_post($this->get_id()); |
|
| 170 | 170 | $this->ID = $this->get_id(); |
| 171 | - $this->data_store->read( $this ); |
|
| 171 | + $this->data_store->read($this); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | } |
@@ -183,38 +183,38 @@ discard block |
||
| 183 | 183 | * @since 1.0.15 |
| 184 | 184 | * @return int |
| 185 | 185 | */ |
| 186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 186 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | 189 | // Trim the value. |
| 190 | - $value = trim( $value ); |
|
| 190 | + $value = trim($value); |
|
| 191 | 191 | |
| 192 | - if ( empty( $value ) ) { |
|
| 192 | + if (empty($value)) { |
|
| 193 | 193 | return 0; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Valid fields. |
| 197 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
| 197 | + $fields = array('key', 'number', 'transaction_id'); |
|
| 198 | 198 | |
| 199 | 199 | // Ensure a field has been passed. |
| 200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 200 | + if (empty($field) || !in_array($field, $fields)) { |
|
| 201 | 201 | return 0; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Maybe retrieve from the cache. |
| 205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | - if ( false !== $invoice_id ) { |
|
| 205 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 206 | + if (false !== $invoice_id) { |
|
| 207 | 207 | return $invoice_id; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Fetch from the db. |
| 211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 212 | 212 | $invoice_id = (int) $wpdb->get_var( |
| 213 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
| 213 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | 216 | // Update the cache with our data |
| 217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 217 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 218 | 218 | |
| 219 | 219 | return $invoice_id; |
| 220 | 220 | } |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * Checks if an invoice key is set. |
| 224 | 224 | */ |
| 225 | - public function _isset( $key ) { |
|
| 226 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 225 | + public function _isset($key) { |
|
| 226 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /* |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | * @param string $context View or edit context. |
| 249 | 249 | * @return int |
| 250 | 250 | */ |
| 251 | - public function get_parent_id( $context = 'view' ) { |
|
| 252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 251 | + public function get_parent_id($context = 'view') { |
|
| 252 | + return (int) $this->get_prop('parent_id', $context); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @return WPInv_Invoice |
| 260 | 260 | */ |
| 261 | 261 | public function get_parent_payment() { |
| 262 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 262 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | * @param string $context View or edit context. |
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | - public function get_status( $context = 'view' ) { |
|
| 283 | - return $this->get_prop( 'status', $context ); |
|
| 282 | + public function get_status($context = 'view') { |
|
| 283 | + return $this->get_prop('status', $context); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -291,10 +291,10 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function get_all_statuses() { |
| 293 | 293 | |
| 294 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
| 294 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
| 295 | 295 | |
| 296 | 296 | // For backwards compatibility. |
| 297 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
| 297 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
| 298 | 298 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
| 299 | 299 | } |
| 300 | 300 | |
@@ -310,9 +310,9 @@ discard block |
||
| 310 | 310 | public function get_status_nicename() { |
| 311 | 311 | $statuses = $this->get_all_statuses(); |
| 312 | 312 | |
| 313 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 313 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 314 | 314 | |
| 315 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
| 315 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | public function get_status_label_html() { |
| 325 | 325 | |
| 326 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 327 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 326 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
| 327 | + $status = sanitize_html_class($this->get_status()); |
|
| 328 | 328 | |
| 329 | 329 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
| 330 | 330 | } |
@@ -336,23 +336,23 @@ discard block |
||
| 336 | 336 | * @param string $context View or edit context. |
| 337 | 337 | * @return string |
| 338 | 338 | */ |
| 339 | - public function get_version( $context = 'view' ) { |
|
| 340 | - return $this->get_prop( 'version', $context ); |
|
| 339 | + public function get_version($context = 'view') { |
|
| 340 | + return $this->get_prop('version', $context); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
| 344 | 344 | * @deprecated |
| 345 | 345 | */ |
| 346 | - public function get_invoice_date( $format = true ) { |
|
| 347 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 348 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 349 | - $formatted = getpaid_format_date( $date ); |
|
| 346 | + public function get_invoice_date($format = true) { |
|
| 347 | + $date = getpaid_format_date($this->get_date_completed()); |
|
| 348 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 349 | + $formatted = getpaid_format_date($date); |
|
| 350 | 350 | |
| 351 | - if ( $format ) { |
|
| 351 | + if ($format) { |
|
| 352 | 352 | return $formatted; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - return empty( $formatted ) ? '' : $date; |
|
| 355 | + return empty($formatted) ? '' : $date; |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | * @param string $context View or edit context. |
| 364 | 364 | * @return string |
| 365 | 365 | */ |
| 366 | - public function get_date_created( $context = 'view' ) { |
|
| 367 | - return $this->get_prop( 'date_created', $context ); |
|
| 366 | + public function get_date_created($context = 'view') { |
|
| 367 | + return $this->get_prop('date_created', $context); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -374,8 +374,8 @@ discard block |
||
| 374 | 374 | * @param string $context View or edit context. |
| 375 | 375 | * @return string |
| 376 | 376 | */ |
| 377 | - public function get_created_date( $context = 'view' ) { |
|
| 378 | - return $this->get_date_created( $context ); |
|
| 377 | + public function get_created_date($context = 'view') { |
|
| 378 | + return $this->get_date_created($context); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -385,11 +385,11 @@ discard block |
||
| 385 | 385 | * @param string $context View or edit context. |
| 386 | 386 | * @return string |
| 387 | 387 | */ |
| 388 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 389 | - $date = $this->get_date_created( $context ); |
|
| 388 | + public function get_date_created_gmt($context = 'view') { |
|
| 389 | + $date = $this->get_date_created($context); |
|
| 390 | 390 | |
| 391 | - if ( $date ) { |
|
| 392 | - $date = get_gmt_from_date( $date ); |
|
| 391 | + if ($date) { |
|
| 392 | + $date = get_gmt_from_date($date); |
|
| 393 | 393 | } |
| 394 | 394 | return $date; |
| 395 | 395 | } |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | * @param string $context View or edit context. |
| 402 | 402 | * @return string |
| 403 | 403 | */ |
| 404 | - public function get_date_modified( $context = 'view' ) { |
|
| 405 | - return $this->get_prop( 'date_modified', $context ); |
|
| 404 | + public function get_date_modified($context = 'view') { |
|
| 405 | + return $this->get_prop('date_modified', $context); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
@@ -412,8 +412,8 @@ discard block |
||
| 412 | 412 | * @param string $context View or edit context. |
| 413 | 413 | * @return string |
| 414 | 414 | */ |
| 415 | - public function get_modified_date( $context = 'view' ) { |
|
| 416 | - return $this->get_date_modified( $context ); |
|
| 415 | + public function get_modified_date($context = 'view') { |
|
| 416 | + return $this->get_date_modified($context); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | /** |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | * @param string $context View or edit context. |
| 424 | 424 | * @return string |
| 425 | 425 | */ |
| 426 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 427 | - $date = $this->get_date_modified( $context ); |
|
| 426 | + public function get_date_modified_gmt($context = 'view') { |
|
| 427 | + $date = $this->get_date_modified($context); |
|
| 428 | 428 | |
| 429 | - if ( $date ) { |
|
| 430 | - $date = get_gmt_from_date( $date ); |
|
| 429 | + if ($date) { |
|
| 430 | + $date = get_gmt_from_date($date); |
|
| 431 | 431 | } |
| 432 | 432 | return $date; |
| 433 | 433 | } |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | * @param string $context View or edit context. |
| 440 | 440 | * @return string |
| 441 | 441 | */ |
| 442 | - public function get_due_date( $context = 'view' ) { |
|
| 443 | - return $this->get_prop( 'due_date', $context ); |
|
| 442 | + public function get_due_date($context = 'view') { |
|
| 443 | + return $this->get_prop('due_date', $context); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | /** |
@@ -450,8 +450,8 @@ discard block |
||
| 450 | 450 | * @param string $context View or edit context. |
| 451 | 451 | * @return string |
| 452 | 452 | */ |
| 453 | - public function get_date_due( $context = 'view' ) { |
|
| 454 | - return $this->get_due_date( $context ); |
|
| 453 | + public function get_date_due($context = 'view') { |
|
| 454 | + return $this->get_due_date($context); |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | /** |
@@ -461,11 +461,11 @@ discard block |
||
| 461 | 461 | * @param string $context View or edit context. |
| 462 | 462 | * @return string |
| 463 | 463 | */ |
| 464 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 465 | - $date = $this->get_due_date( $context ); |
|
| 464 | + public function get_due_date_gmt($context = 'view') { |
|
| 465 | + $date = $this->get_due_date($context); |
|
| 466 | 466 | |
| 467 | - if ( $date ) { |
|
| 468 | - $date = get_gmt_from_date( $date ); |
|
| 467 | + if ($date) { |
|
| 468 | + $date = get_gmt_from_date($date); |
|
| 469 | 469 | } |
| 470 | 470 | return $date; |
| 471 | 471 | } |
@@ -477,8 +477,8 @@ discard block |
||
| 477 | 477 | * @param string $context View or edit context. |
| 478 | 478 | * @return string |
| 479 | 479 | */ |
| 480 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 481 | - return $this->get_due_date_gmt( $context ); |
|
| 480 | + public function get_gmt_date_due($context = 'view') { |
|
| 481 | + return $this->get_due_date_gmt($context); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | * @param string $context View or edit context. |
| 489 | 489 | * @return string |
| 490 | 490 | */ |
| 491 | - public function get_completed_date( $context = 'view' ) { |
|
| 492 | - return $this->get_prop( 'completed_date', $context ); |
|
| 491 | + public function get_completed_date($context = 'view') { |
|
| 492 | + return $this->get_prop('completed_date', $context); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -499,8 +499,8 @@ discard block |
||
| 499 | 499 | * @param string $context View or edit context. |
| 500 | 500 | * @return string |
| 501 | 501 | */ |
| 502 | - public function get_date_completed( $context = 'view' ) { |
|
| 503 | - return $this->get_completed_date( $context ); |
|
| 502 | + public function get_date_completed($context = 'view') { |
|
| 503 | + return $this->get_completed_date($context); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -510,11 +510,11 @@ discard block |
||
| 510 | 510 | * @param string $context View or edit context. |
| 511 | 511 | * @return string |
| 512 | 512 | */ |
| 513 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 514 | - $date = $this->get_completed_date( $context ); |
|
| 513 | + public function get_completed_date_gmt($context = 'view') { |
|
| 514 | + $date = $this->get_completed_date($context); |
|
| 515 | 515 | |
| 516 | - if ( $date ) { |
|
| 517 | - $date = get_gmt_from_date( $date ); |
|
| 516 | + if ($date) { |
|
| 517 | + $date = get_gmt_from_date($date); |
|
| 518 | 518 | } |
| 519 | 519 | return $date; |
| 520 | 520 | } |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | * @param string $context View or edit context. |
| 527 | 527 | * @return string |
| 528 | 528 | */ |
| 529 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 530 | - return $this->get_completed_date_gmt( $context ); |
|
| 529 | + public function get_gmt_completed_date($context = 'view') { |
|
| 530 | + return $this->get_completed_date_gmt($context); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -537,12 +537,12 @@ discard block |
||
| 537 | 537 | * @param string $context View or edit context. |
| 538 | 538 | * @return string |
| 539 | 539 | */ |
| 540 | - public function get_number( $context = 'view' ) { |
|
| 541 | - $number = $this->get_prop( 'number', $context ); |
|
| 540 | + public function get_number($context = 'view') { |
|
| 541 | + $number = $this->get_prop('number', $context); |
|
| 542 | 542 | |
| 543 | - if ( empty( $number ) ) { |
|
| 543 | + if (empty($number)) { |
|
| 544 | 544 | $number = $this->generate_number(); |
| 545 | - $this->set_number( $this->generate_number() ); |
|
| 545 | + $this->set_number($this->generate_number()); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | return $number; |
@@ -556,8 +556,8 @@ discard block |
||
| 556 | 556 | public function maybe_set_number() { |
| 557 | 557 | $number = $this->get_number(); |
| 558 | 558 | |
| 559 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
| 560 | - $this->set_number( $this->generate_number() ); |
|
| 559 | + if (empty($number) || $this->get_id() == $number) { |
|
| 560 | + $this->set_number($this->generate_number()); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | } |
@@ -569,8 +569,8 @@ discard block |
||
| 569 | 569 | * @param string $context View or edit context. |
| 570 | 570 | * @return string |
| 571 | 571 | */ |
| 572 | - public function get_key( $context = 'view' ) { |
|
| 573 | - return $this->get_prop( 'key', $context ); |
|
| 572 | + public function get_key($context = 'view') { |
|
| 573 | + return $this->get_prop('key', $context); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
@@ -581,9 +581,9 @@ discard block |
||
| 581 | 581 | public function maybe_set_key() { |
| 582 | 582 | $key = $this->get_key(); |
| 583 | 583 | |
| 584 | - if ( empty( $key ) ) { |
|
| 585 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
| 586 | - $this->set_key( $key ); |
|
| 584 | + if (empty($key)) { |
|
| 585 | + $key = $this->generate_key($this->get_type() . '_'); |
|
| 586 | + $this->set_key($key); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | } |
@@ -595,15 +595,15 @@ discard block |
||
| 595 | 595 | * @param string $context View or edit context. |
| 596 | 596 | * @return string |
| 597 | 597 | */ |
| 598 | - public function get_type( $context = 'view' ) { |
|
| 599 | - return $this->get_prop( 'type', $context ); |
|
| 598 | + public function get_type($context = 'view') { |
|
| 599 | + return $this->get_prop('type', $context); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
| 603 | 603 | * @deprecated |
| 604 | 604 | */ |
| 605 | 605 | public function get_invoice_quote_type() { |
| 606 | - ucfirst( $this->get_type() ); |
|
| 606 | + ucfirst($this->get_type()); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | * @param string $context View or edit context. |
| 614 | 614 | * @return string |
| 615 | 615 | */ |
| 616 | - public function get_post_type( $context = 'view' ) { |
|
| 617 | - return $this->get_prop( 'post_type', $context ); |
|
| 616 | + public function get_post_type($context = 'view') { |
|
| 617 | + return $this->get_prop('post_type', $context); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
@@ -624,8 +624,8 @@ discard block |
||
| 624 | 624 | * @param string $context View or edit context. |
| 625 | 625 | * @return string |
| 626 | 626 | */ |
| 627 | - public function get_mode( $context = 'view' ) { |
|
| 628 | - return $this->get_prop( 'mode', $context ); |
|
| 627 | + public function get_mode($context = 'view') { |
|
| 628 | + return $this->get_prop('mode', $context); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
@@ -635,13 +635,13 @@ discard block |
||
| 635 | 635 | * @param string $context View or edit context. |
| 636 | 636 | * @return string |
| 637 | 637 | */ |
| 638 | - public function get_path( $context = 'view' ) { |
|
| 639 | - $path = $this->get_prop( 'path', $context ); |
|
| 640 | - $prefix = wpinv_post_name_prefix( $this->get_post_type() ); |
|
| 638 | + public function get_path($context = 'view') { |
|
| 639 | + $path = $this->get_prop('path', $context); |
|
| 640 | + $prefix = wpinv_post_name_prefix($this->get_post_type()); |
|
| 641 | 641 | |
| 642 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 643 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
| 644 | - $this->set_path( $path ); |
|
| 642 | + if (0 !== strpos($path, $prefix)) { |
|
| 643 | + $path = sanitize_title($prefix . $this->get_id()); |
|
| 644 | + $this->set_path($path); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | return $path; |
@@ -654,8 +654,8 @@ discard block |
||
| 654 | 654 | * @param string $context View or edit context. |
| 655 | 655 | * @return string |
| 656 | 656 | */ |
| 657 | - public function get_name( $context = 'view' ) { |
|
| 658 | - return $this->get_prop( 'title', $context ); |
|
| 657 | + public function get_name($context = 'view') { |
|
| 658 | + return $this->get_prop('title', $context); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -665,8 +665,8 @@ discard block |
||
| 665 | 665 | * @param string $context View or edit context. |
| 666 | 666 | * @return string |
| 667 | 667 | */ |
| 668 | - public function get_title( $context = 'view' ) { |
|
| 669 | - return $this->get_name( $context ); |
|
| 668 | + public function get_title($context = 'view') { |
|
| 669 | + return $this->get_name($context); |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | /** |
@@ -676,8 +676,8 @@ discard block |
||
| 676 | 676 | * @param string $context View or edit context. |
| 677 | 677 | * @return string |
| 678 | 678 | */ |
| 679 | - public function get_description( $context = 'view' ) { |
|
| 680 | - return $this->get_prop( 'description', $context ); |
|
| 679 | + public function get_description($context = 'view') { |
|
| 680 | + return $this->get_prop('description', $context); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -687,8 +687,8 @@ discard block |
||
| 687 | 687 | * @param string $context View or edit context. |
| 688 | 688 | * @return string |
| 689 | 689 | */ |
| 690 | - public function get_excerpt( $context = 'view' ) { |
|
| 691 | - return $this->get_description( $context ); |
|
| 690 | + public function get_excerpt($context = 'view') { |
|
| 691 | + return $this->get_description($context); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /** |
@@ -698,8 +698,8 @@ discard block |
||
| 698 | 698 | * @param string $context View or edit context. |
| 699 | 699 | * @return string |
| 700 | 700 | */ |
| 701 | - public function get_summary( $context = 'view' ) { |
|
| 702 | - return $this->get_description( $context ); |
|
| 701 | + public function get_summary($context = 'view') { |
|
| 702 | + return $this->get_description($context); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | /** |
@@ -709,25 +709,25 @@ discard block |
||
| 709 | 709 | * @param string $context View or edit context. |
| 710 | 710 | * @return array |
| 711 | 711 | */ |
| 712 | - public function get_user_info( $context = 'view' ) { |
|
| 712 | + public function get_user_info($context = 'view') { |
|
| 713 | 713 | |
| 714 | 714 | $user_info = array( |
| 715 | - 'user_id' => $this->get_user_id( $context ), |
|
| 716 | - 'email' => $this->get_email( $context ), |
|
| 717 | - 'first_name' => $this->get_first_name( $context ), |
|
| 718 | - 'last_name' => $this->get_last_name( $context ), |
|
| 719 | - 'address' => $this->get_address( $context ), |
|
| 720 | - 'phone' => $this->get_phone( $context ), |
|
| 721 | - 'city' => $this->get_city( $context ), |
|
| 722 | - 'country' => $this->get_country( $context ), |
|
| 723 | - 'state' => $this->get_state( $context ), |
|
| 724 | - 'zip' => $this->get_zip( $context ), |
|
| 725 | - 'company' => $this->get_company( $context ), |
|
| 726 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 727 | - 'discount' => $this->get_discount_code( $context ), |
|
| 715 | + 'user_id' => $this->get_user_id($context), |
|
| 716 | + 'email' => $this->get_email($context), |
|
| 717 | + 'first_name' => $this->get_first_name($context), |
|
| 718 | + 'last_name' => $this->get_last_name($context), |
|
| 719 | + 'address' => $this->get_address($context), |
|
| 720 | + 'phone' => $this->get_phone($context), |
|
| 721 | + 'city' => $this->get_city($context), |
|
| 722 | + 'country' => $this->get_country($context), |
|
| 723 | + 'state' => $this->get_state($context), |
|
| 724 | + 'zip' => $this->get_zip($context), |
|
| 725 | + 'company' => $this->get_company($context), |
|
| 726 | + 'vat_number' => $this->get_vat_number($context), |
|
| 727 | + 'discount' => $this->get_discount_code($context), |
|
| 728 | 728 | ); |
| 729 | 729 | |
| 730 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 730 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 731 | 731 | |
| 732 | 732 | } |
| 733 | 733 | |
@@ -738,8 +738,8 @@ discard block |
||
| 738 | 738 | * @param string $context View or edit context. |
| 739 | 739 | * @return int |
| 740 | 740 | */ |
| 741 | - public function get_author( $context = 'view' ) { |
|
| 742 | - return (int) $this->get_prop( 'author', $context ); |
|
| 741 | + public function get_author($context = 'view') { |
|
| 742 | + return (int) $this->get_prop('author', $context); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | /** |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | * @param string $context View or edit context. |
| 750 | 750 | * @return int |
| 751 | 751 | */ |
| 752 | - public function get_user_id( $context = 'view' ) { |
|
| 753 | - return $this->get_author( $context ); |
|
| 752 | + public function get_user_id($context = 'view') { |
|
| 753 | + return $this->get_author($context); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
@@ -760,8 +760,8 @@ discard block |
||
| 760 | 760 | * @param string $context View or edit context. |
| 761 | 761 | * @return int |
| 762 | 762 | */ |
| 763 | - public function get_customer_id( $context = 'view' ) { |
|
| 764 | - return $this->get_author( $context ); |
|
| 763 | + public function get_customer_id($context = 'view') { |
|
| 764 | + return $this->get_author($context); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -771,8 +771,8 @@ discard block |
||
| 771 | 771 | * @param string $context View or edit context. |
| 772 | 772 | * @return string |
| 773 | 773 | */ |
| 774 | - public function get_ip( $context = 'view' ) { |
|
| 775 | - return $this->get_prop( 'user_ip', $context ); |
|
| 774 | + public function get_ip($context = 'view') { |
|
| 775 | + return $this->get_prop('user_ip', $context); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
@@ -782,8 +782,8 @@ discard block |
||
| 782 | 782 | * @param string $context View or edit context. |
| 783 | 783 | * @return string |
| 784 | 784 | */ |
| 785 | - public function get_user_ip( $context = 'view' ) { |
|
| 786 | - return $this->get_ip( $context ); |
|
| 785 | + public function get_user_ip($context = 'view') { |
|
| 786 | + return $this->get_ip($context); |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
@@ -793,8 +793,8 @@ discard block |
||
| 793 | 793 | * @param string $context View or edit context. |
| 794 | 794 | * @return string |
| 795 | 795 | */ |
| 796 | - public function get_customer_ip( $context = 'view' ) { |
|
| 797 | - return $this->get_ip( $context ); |
|
| 796 | + public function get_customer_ip($context = 'view') { |
|
| 797 | + return $this->get_ip($context); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | * @param string $context View or edit context. |
| 805 | 805 | * @return string |
| 806 | 806 | */ |
| 807 | - public function get_first_name( $context = 'view' ) { |
|
| 808 | - return $this->get_prop( 'first_name', $context ); |
|
| 807 | + public function get_first_name($context = 'view') { |
|
| 808 | + return $this->get_prop('first_name', $context); |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | /** |
@@ -815,8 +815,8 @@ discard block |
||
| 815 | 815 | * @param string $context View or edit context. |
| 816 | 816 | * @return int |
| 817 | 817 | */ |
| 818 | - public function get_user_first_name( $context = 'view' ) { |
|
| 819 | - return $this->get_first_name( $context ); |
|
| 818 | + public function get_user_first_name($context = 'view') { |
|
| 819 | + return $this->get_first_name($context); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | /** |
@@ -826,8 +826,8 @@ discard block |
||
| 826 | 826 | * @param string $context View or edit context. |
| 827 | 827 | * @return int |
| 828 | 828 | */ |
| 829 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 830 | - return $this->get_first_name( $context ); |
|
| 829 | + public function get_customer_first_name($context = 'view') { |
|
| 830 | + return $this->get_first_name($context); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | /** |
@@ -837,8 +837,8 @@ discard block |
||
| 837 | 837 | * @param string $context View or edit context. |
| 838 | 838 | * @return string |
| 839 | 839 | */ |
| 840 | - public function get_last_name( $context = 'view' ) { |
|
| 841 | - return $this->get_prop( 'last_name', $context ); |
|
| 840 | + public function get_last_name($context = 'view') { |
|
| 841 | + return $this->get_prop('last_name', $context); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | /** |
@@ -848,8 +848,8 @@ discard block |
||
| 848 | 848 | * @param string $context View or edit context. |
| 849 | 849 | * @return int |
| 850 | 850 | */ |
| 851 | - public function get_user_last_name( $context = 'view' ) { |
|
| 852 | - return $this->get_last_name( $context ); |
|
| 851 | + public function get_user_last_name($context = 'view') { |
|
| 852 | + return $this->get_last_name($context); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | /** |
@@ -859,8 +859,8 @@ discard block |
||
| 859 | 859 | * @param string $context View or edit context. |
| 860 | 860 | * @return int |
| 861 | 861 | */ |
| 862 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 863 | - return $this->get_last_name( $context ); |
|
| 862 | + public function get_customer_last_name($context = 'view') { |
|
| 863 | + return $this->get_last_name($context); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -870,8 +870,8 @@ discard block |
||
| 870 | 870 | * @param string $context View or edit context. |
| 871 | 871 | * @return string |
| 872 | 872 | */ |
| 873 | - public function get_full_name( $context = 'view' ) { |
|
| 874 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 873 | + public function get_full_name($context = 'view') { |
|
| 874 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | /** |
@@ -881,8 +881,8 @@ discard block |
||
| 881 | 881 | * @param string $context View or edit context. |
| 882 | 882 | * @return int |
| 883 | 883 | */ |
| 884 | - public function get_user_full_name( $context = 'view' ) { |
|
| 885 | - return $this->get_full_name( $context ); |
|
| 884 | + public function get_user_full_name($context = 'view') { |
|
| 885 | + return $this->get_full_name($context); |
|
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | /** |
@@ -892,8 +892,8 @@ discard block |
||
| 892 | 892 | * @param string $context View or edit context. |
| 893 | 893 | * @return int |
| 894 | 894 | */ |
| 895 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 896 | - return $this->get_full_name( $context ); |
|
| 895 | + public function get_customer_full_name($context = 'view') { |
|
| 896 | + return $this->get_full_name($context); |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | /** |
@@ -903,8 +903,8 @@ discard block |
||
| 903 | 903 | * @param string $context View or edit context. |
| 904 | 904 | * @return string |
| 905 | 905 | */ |
| 906 | - public function get_phone( $context = 'view' ) { |
|
| 907 | - return $this->get_prop( 'phone', $context ); |
|
| 906 | + public function get_phone($context = 'view') { |
|
| 907 | + return $this->get_prop('phone', $context); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | /** |
@@ -914,8 +914,8 @@ discard block |
||
| 914 | 914 | * @param string $context View or edit context. |
| 915 | 915 | * @return int |
| 916 | 916 | */ |
| 917 | - public function get_phone_number( $context = 'view' ) { |
|
| 918 | - return $this->get_phone( $context ); |
|
| 917 | + public function get_phone_number($context = 'view') { |
|
| 918 | + return $this->get_phone($context); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -925,8 +925,8 @@ discard block |
||
| 925 | 925 | * @param string $context View or edit context. |
| 926 | 926 | * @return int |
| 927 | 927 | */ |
| 928 | - public function get_user_phone( $context = 'view' ) { |
|
| 929 | - return $this->get_phone( $context ); |
|
| 928 | + public function get_user_phone($context = 'view') { |
|
| 929 | + return $this->get_phone($context); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | /** |
@@ -936,8 +936,8 @@ discard block |
||
| 936 | 936 | * @param string $context View or edit context. |
| 937 | 937 | * @return int |
| 938 | 938 | */ |
| 939 | - public function get_customer_phone( $context = 'view' ) { |
|
| 940 | - return $this->get_phone( $context ); |
|
| 939 | + public function get_customer_phone($context = 'view') { |
|
| 940 | + return $this->get_phone($context); |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | /** |
@@ -947,8 +947,8 @@ discard block |
||
| 947 | 947 | * @param string $context View or edit context. |
| 948 | 948 | * @return string |
| 949 | 949 | */ |
| 950 | - public function get_email( $context = 'view' ) { |
|
| 951 | - return $this->get_prop( 'email', $context ); |
|
| 950 | + public function get_email($context = 'view') { |
|
| 951 | + return $this->get_prop('email', $context); |
|
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | /** |
@@ -958,8 +958,8 @@ discard block |
||
| 958 | 958 | * @param string $context View or edit context. |
| 959 | 959 | * @return string |
| 960 | 960 | */ |
| 961 | - public function get_email_address( $context = 'view' ) { |
|
| 962 | - return $this->get_email( $context ); |
|
| 961 | + public function get_email_address($context = 'view') { |
|
| 962 | + return $this->get_email($context); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | /** |
@@ -969,8 +969,8 @@ discard block |
||
| 969 | 969 | * @param string $context View or edit context. |
| 970 | 970 | * @return int |
| 971 | 971 | */ |
| 972 | - public function get_user_email( $context = 'view' ) { |
|
| 973 | - return $this->get_email( $context ); |
|
| 972 | + public function get_user_email($context = 'view') { |
|
| 973 | + return $this->get_email($context); |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /** |
@@ -980,8 +980,8 @@ discard block |
||
| 980 | 980 | * @param string $context View or edit context. |
| 981 | 981 | * @return int |
| 982 | 982 | */ |
| 983 | - public function get_customer_email( $context = 'view' ) { |
|
| 984 | - return $this->get_email( $context ); |
|
| 983 | + public function get_customer_email($context = 'view') { |
|
| 984 | + return $this->get_email($context); |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | /** |
@@ -991,9 +991,9 @@ discard block |
||
| 991 | 991 | * @param string $context View or edit context. |
| 992 | 992 | * @return string |
| 993 | 993 | */ |
| 994 | - public function get_country( $context = 'view' ) { |
|
| 995 | - $country = $this->get_prop( 'country', $context ); |
|
| 996 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 994 | + public function get_country($context = 'view') { |
|
| 995 | + $country = $this->get_prop('country', $context); |
|
| 996 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | /** |
@@ -1003,8 +1003,8 @@ discard block |
||
| 1003 | 1003 | * @param string $context View or edit context. |
| 1004 | 1004 | * @return int |
| 1005 | 1005 | */ |
| 1006 | - public function get_user_country( $context = 'view' ) { |
|
| 1007 | - return $this->get_country( $context ); |
|
| 1006 | + public function get_user_country($context = 'view') { |
|
| 1007 | + return $this->get_country($context); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | /** |
@@ -1014,8 +1014,8 @@ discard block |
||
| 1014 | 1014 | * @param string $context View or edit context. |
| 1015 | 1015 | * @return int |
| 1016 | 1016 | */ |
| 1017 | - public function get_customer_country( $context = 'view' ) { |
|
| 1018 | - return $this->get_country( $context ); |
|
| 1017 | + public function get_customer_country($context = 'view') { |
|
| 1018 | + return $this->get_country($context); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | /** |
@@ -1025,9 +1025,9 @@ discard block |
||
| 1025 | 1025 | * @param string $context View or edit context. |
| 1026 | 1026 | * @return string |
| 1027 | 1027 | */ |
| 1028 | - public function get_state( $context = 'view' ) { |
|
| 1029 | - $state = $this->get_prop( 'state', $context ); |
|
| 1030 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1028 | + public function get_state($context = 'view') { |
|
| 1029 | + $state = $this->get_prop('state', $context); |
|
| 1030 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | /** |
@@ -1037,8 +1037,8 @@ discard block |
||
| 1037 | 1037 | * @param string $context View or edit context. |
| 1038 | 1038 | * @return int |
| 1039 | 1039 | */ |
| 1040 | - public function get_user_state( $context = 'view' ) { |
|
| 1041 | - return $this->get_state( $context ); |
|
| 1040 | + public function get_user_state($context = 'view') { |
|
| 1041 | + return $this->get_state($context); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | /** |
@@ -1048,8 +1048,8 @@ discard block |
||
| 1048 | 1048 | * @param string $context View or edit context. |
| 1049 | 1049 | * @return int |
| 1050 | 1050 | */ |
| 1051 | - public function get_customer_state( $context = 'view' ) { |
|
| 1052 | - return $this->get_state( $context ); |
|
| 1051 | + public function get_customer_state($context = 'view') { |
|
| 1052 | + return $this->get_state($context); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | /** |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | * @param string $context View or edit context. |
| 1060 | 1060 | * @return string |
| 1061 | 1061 | */ |
| 1062 | - public function get_city( $context = 'view' ) { |
|
| 1063 | - return $this->get_prop( 'city', $context ); |
|
| 1062 | + public function get_city($context = 'view') { |
|
| 1063 | + return $this->get_prop('city', $context); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | /** |
@@ -1070,8 +1070,8 @@ discard block |
||
| 1070 | 1070 | * @param string $context View or edit context. |
| 1071 | 1071 | * @return string |
| 1072 | 1072 | */ |
| 1073 | - public function get_user_city( $context = 'view' ) { |
|
| 1074 | - return $this->get_city( $context ); |
|
| 1073 | + public function get_user_city($context = 'view') { |
|
| 1074 | + return $this->get_city($context); |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1081,8 +1081,8 @@ discard block |
||
| 1081 | 1081 | * @param string $context View or edit context. |
| 1082 | 1082 | * @return string |
| 1083 | 1083 | */ |
| 1084 | - public function get_customer_city( $context = 'view' ) { |
|
| 1085 | - return $this->get_city( $context ); |
|
| 1084 | + public function get_customer_city($context = 'view') { |
|
| 1085 | + return $this->get_city($context); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -1092,8 +1092,8 @@ discard block |
||
| 1092 | 1092 | * @param string $context View or edit context. |
| 1093 | 1093 | * @return string |
| 1094 | 1094 | */ |
| 1095 | - public function get_zip( $context = 'view' ) { |
|
| 1096 | - return $this->get_prop( 'zip', $context ); |
|
| 1095 | + public function get_zip($context = 'view') { |
|
| 1096 | + return $this->get_prop('zip', $context); |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | /** |
@@ -1103,8 +1103,8 @@ discard block |
||
| 1103 | 1103 | * @param string $context View or edit context. |
| 1104 | 1104 | * @return string |
| 1105 | 1105 | */ |
| 1106 | - public function get_user_zip( $context = 'view' ) { |
|
| 1107 | - return $this->get_zip( $context ); |
|
| 1106 | + public function get_user_zip($context = 'view') { |
|
| 1107 | + return $this->get_zip($context); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | /** |
@@ -1114,8 +1114,8 @@ discard block |
||
| 1114 | 1114 | * @param string $context View or edit context. |
| 1115 | 1115 | * @return string |
| 1116 | 1116 | */ |
| 1117 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1118 | - return $this->get_zip( $context ); |
|
| 1117 | + public function get_customer_zip($context = 'view') { |
|
| 1118 | + return $this->get_zip($context); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | /** |
@@ -1125,8 +1125,8 @@ discard block |
||
| 1125 | 1125 | * @param string $context View or edit context. |
| 1126 | 1126 | * @return string |
| 1127 | 1127 | */ |
| 1128 | - public function get_company( $context = 'view' ) { |
|
| 1129 | - return $this->get_prop( 'company', $context ); |
|
| 1128 | + public function get_company($context = 'view') { |
|
| 1129 | + return $this->get_prop('company', $context); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | /** |
@@ -1136,8 +1136,8 @@ discard block |
||
| 1136 | 1136 | * @param string $context View or edit context. |
| 1137 | 1137 | * @return string |
| 1138 | 1138 | */ |
| 1139 | - public function get_user_company( $context = 'view' ) { |
|
| 1140 | - return $this->get_company( $context ); |
|
| 1139 | + public function get_user_company($context = 'view') { |
|
| 1140 | + return $this->get_company($context); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
@@ -1147,8 +1147,8 @@ discard block |
||
| 1147 | 1147 | * @param string $context View or edit context. |
| 1148 | 1148 | * @return string |
| 1149 | 1149 | */ |
| 1150 | - public function get_customer_company( $context = 'view' ) { |
|
| 1151 | - return $this->get_company( $context ); |
|
| 1150 | + public function get_customer_company($context = 'view') { |
|
| 1151 | + return $this->get_company($context); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | /** |
@@ -1158,8 +1158,8 @@ discard block |
||
| 1158 | 1158 | * @param string $context View or edit context. |
| 1159 | 1159 | * @return string |
| 1160 | 1160 | */ |
| 1161 | - public function get_vat_number( $context = 'view' ) { |
|
| 1162 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1161 | + public function get_vat_number($context = 'view') { |
|
| 1162 | + return $this->get_prop('vat_number', $context); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | /** |
@@ -1169,8 +1169,8 @@ discard block |
||
| 1169 | 1169 | * @param string $context View or edit context. |
| 1170 | 1170 | * @return string |
| 1171 | 1171 | */ |
| 1172 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1173 | - return $this->get_vat_number( $context ); |
|
| 1172 | + public function get_user_vat_number($context = 'view') { |
|
| 1173 | + return $this->get_vat_number($context); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | /** |
@@ -1180,8 +1180,8 @@ discard block |
||
| 1180 | 1180 | * @param string $context View or edit context. |
| 1181 | 1181 | * @return string |
| 1182 | 1182 | */ |
| 1183 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1184 | - return $this->get_vat_number( $context ); |
|
| 1183 | + public function get_customer_vat_number($context = 'view') { |
|
| 1184 | + return $this->get_vat_number($context); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | 1187 | /** |
@@ -1191,8 +1191,8 @@ discard block |
||
| 1191 | 1191 | * @param string $context View or edit context. |
| 1192 | 1192 | * @return string |
| 1193 | 1193 | */ |
| 1194 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1195 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1194 | + public function get_vat_rate($context = 'view') { |
|
| 1195 | + return $this->get_prop('vat_rate', $context); |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | /** |
@@ -1202,8 +1202,8 @@ discard block |
||
| 1202 | 1202 | * @param string $context View or edit context. |
| 1203 | 1203 | * @return string |
| 1204 | 1204 | */ |
| 1205 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1206 | - return $this->get_vat_rate( $context ); |
|
| 1205 | + public function get_user_vat_rate($context = 'view') { |
|
| 1206 | + return $this->get_vat_rate($context); |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | /** |
@@ -1213,8 +1213,8 @@ discard block |
||
| 1213 | 1213 | * @param string $context View or edit context. |
| 1214 | 1214 | * @return string |
| 1215 | 1215 | */ |
| 1216 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1217 | - return $this->get_vat_rate( $context ); |
|
| 1216 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1217 | + return $this->get_vat_rate($context); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | /** |
@@ -1224,8 +1224,8 @@ discard block |
||
| 1224 | 1224 | * @param string $context View or edit context. |
| 1225 | 1225 | * @return string |
| 1226 | 1226 | */ |
| 1227 | - public function get_address( $context = 'view' ) { |
|
| 1228 | - return $this->get_prop( 'address', $context ); |
|
| 1227 | + public function get_address($context = 'view') { |
|
| 1228 | + return $this->get_prop('address', $context); |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | /** |
@@ -1235,8 +1235,8 @@ discard block |
||
| 1235 | 1235 | * @param string $context View or edit context. |
| 1236 | 1236 | * @return string |
| 1237 | 1237 | */ |
| 1238 | - public function get_user_address( $context = 'view' ) { |
|
| 1239 | - return $this->get_address( $context ); |
|
| 1238 | + public function get_user_address($context = 'view') { |
|
| 1239 | + return $this->get_address($context); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | /** |
@@ -1246,8 +1246,8 @@ discard block |
||
| 1246 | 1246 | * @param string $context View or edit context. |
| 1247 | 1247 | * @return string |
| 1248 | 1248 | */ |
| 1249 | - public function get_customer_address( $context = 'view' ) { |
|
| 1250 | - return $this->get_address( $context ); |
|
| 1249 | + public function get_customer_address($context = 'view') { |
|
| 1250 | + return $this->get_address($context); |
|
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | /** |
@@ -1257,8 +1257,8 @@ discard block |
||
| 1257 | 1257 | * @param string $context View or edit context. |
| 1258 | 1258 | * @return bool |
| 1259 | 1259 | */ |
| 1260 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1261 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1260 | + public function get_is_viewed($context = 'view') { |
|
| 1261 | + return (bool) $this->get_prop('is_viewed', $context); |
|
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | 1264 | /** |
@@ -1268,8 +1268,8 @@ discard block |
||
| 1268 | 1268 | * @param string $context View or edit context. |
| 1269 | 1269 | * @return bool |
| 1270 | 1270 | */ |
| 1271 | - public function get_email_cc( $context = 'view' ) { |
|
| 1272 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1271 | + public function get_email_cc($context = 'view') { |
|
| 1272 | + return $this->get_prop('email_cc', $context); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | /** |
@@ -1279,8 +1279,8 @@ discard block |
||
| 1279 | 1279 | * @param string $context View or edit context. |
| 1280 | 1280 | * @return bool |
| 1281 | 1281 | */ |
| 1282 | - public function get_template( $context = 'view' ) { |
|
| 1283 | - return $this->get_prop( 'template', $context ); |
|
| 1282 | + public function get_template($context = 'view') { |
|
| 1283 | + return $this->get_prop('template', $context); |
|
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | 1286 | /** |
@@ -1290,8 +1290,8 @@ discard block |
||
| 1290 | 1290 | * @param string $context View or edit context. |
| 1291 | 1291 | * @return bool |
| 1292 | 1292 | */ |
| 1293 | - public function get_created_via( $context = 'view' ) { |
|
| 1294 | - return $this->get_prop( 'created_via', $context ); |
|
| 1293 | + public function get_created_via($context = 'view') { |
|
| 1294 | + return $this->get_prop('created_via', $context); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | /** |
@@ -1301,8 +1301,8 @@ discard block |
||
| 1301 | 1301 | * @param string $context View or edit context. |
| 1302 | 1302 | * @return bool |
| 1303 | 1303 | */ |
| 1304 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1305 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1304 | + public function get_address_confirmed($context = 'view') { |
|
| 1305 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | /** |
@@ -1312,8 +1312,8 @@ discard block |
||
| 1312 | 1312 | * @param string $context View or edit context. |
| 1313 | 1313 | * @return bool |
| 1314 | 1314 | */ |
| 1315 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1316 | - return $this->get_address_confirmed( $context ); |
|
| 1315 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1316 | + return $this->get_address_confirmed($context); |
|
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | /** |
@@ -1323,8 +1323,8 @@ discard block |
||
| 1323 | 1323 | * @param string $context View or edit context. |
| 1324 | 1324 | * @return bool |
| 1325 | 1325 | */ |
| 1326 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1327 | - return $this->get_address_confirmed( $context ); |
|
| 1326 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1327 | + return $this->get_address_confirmed($context); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | /** |
@@ -1334,12 +1334,12 @@ discard block |
||
| 1334 | 1334 | * @param string $context View or edit context. |
| 1335 | 1335 | * @return float |
| 1336 | 1336 | */ |
| 1337 | - public function get_subtotal( $context = 'view' ) { |
|
| 1338 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1337 | + public function get_subtotal($context = 'view') { |
|
| 1338 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1339 | 1339 | |
| 1340 | 1340 | // Backwards compatibility. |
| 1341 | - if ( is_bool( $context ) && $context ) { |
|
| 1342 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
| 1341 | + if (is_bool($context) && $context) { |
|
| 1342 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | return $subtotal; |
@@ -1352,8 +1352,8 @@ discard block |
||
| 1352 | 1352 | * @param string $context View or edit context. |
| 1353 | 1353 | * @return float |
| 1354 | 1354 | */ |
| 1355 | - public function get_total_discount( $context = 'view' ) { |
|
| 1356 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1355 | + public function get_total_discount($context = 'view') { |
|
| 1356 | + return (float) $this->get_prop('total_discount', $context); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | 1359 | /** |
@@ -1363,18 +1363,18 @@ discard block |
||
| 1363 | 1363 | * @param string $context View or edit context. |
| 1364 | 1364 | * @return float |
| 1365 | 1365 | */ |
| 1366 | - public function get_total_tax( $context = 'view' ) { |
|
| 1367 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1366 | + public function get_total_tax($context = 'view') { |
|
| 1367 | + return (float) $this->get_prop('total_tax', $context); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | /** |
| 1371 | 1371 | * @deprecated |
| 1372 | 1372 | */ |
| 1373 | - public function get_final_tax( $currency = false ) { |
|
| 1373 | + public function get_final_tax($currency = false) { |
|
| 1374 | 1374 | $tax = $this->get_total_tax(); |
| 1375 | 1375 | |
| 1376 | - if ( $currency ) { |
|
| 1377 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1376 | + if ($currency) { |
|
| 1377 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | return $tax; |
@@ -1387,8 +1387,8 @@ discard block |
||
| 1387 | 1387 | * @param string $context View or edit context. |
| 1388 | 1388 | * @return float |
| 1389 | 1389 | */ |
| 1390 | - public function get_total_fees( $context = 'view' ) { |
|
| 1391 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1390 | + public function get_total_fees($context = 'view') { |
|
| 1391 | + return (float) $this->get_prop('total_fees', $context); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | /** |
@@ -1398,8 +1398,8 @@ discard block |
||
| 1398 | 1398 | * @param string $context View or edit context. |
| 1399 | 1399 | * @return float |
| 1400 | 1400 | */ |
| 1401 | - public function get_fees_total( $context = 'view' ) { |
|
| 1402 | - return $this->get_total_fees( $context ); |
|
| 1401 | + public function get_fees_total($context = 'view') { |
|
| 1402 | + return $this->get_total_fees($context); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | /** |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | */ |
| 1411 | 1411 | public function get_total() { |
| 1412 | 1412 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
| 1413 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1413 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | 1416 | /** |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | */ |
| 1433 | 1433 | public function get_initial_total() { |
| 1434 | 1434 | |
| 1435 | - if ( empty( $this->totals ) ) { |
|
| 1435 | + if (empty($this->totals)) { |
|
| 1436 | 1436 | $this->recalculate_total(); |
| 1437 | 1437 | } |
| 1438 | 1438 | |
@@ -1442,11 +1442,11 @@ discard block |
||
| 1442 | 1442 | $subtotal = $this->totals['subtotal']['initial']; |
| 1443 | 1443 | $total = $tax + $fee - $discount + $subtotal; |
| 1444 | 1444 | |
| 1445 | - if ( 0 > $total ) { |
|
| 1445 | + if (0 > $total) { |
|
| 1446 | 1446 | $total = 0; |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1449 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | 1452 | /** |
@@ -1458,7 +1458,7 @@ discard block |
||
| 1458 | 1458 | */ |
| 1459 | 1459 | public function get_recurring_total() { |
| 1460 | 1460 | |
| 1461 | - if ( empty( $this->totals ) ) { |
|
| 1461 | + if (empty($this->totals)) { |
|
| 1462 | 1462 | $this->recalculate_total(); |
| 1463 | 1463 | } |
| 1464 | 1464 | |
@@ -1468,11 +1468,11 @@ discard block |
||
| 1468 | 1468 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1469 | 1469 | $total = $tax + $fee - $discount + $subtotal; |
| 1470 | 1470 | |
| 1471 | - if ( 0 > $total ) { |
|
| 1471 | + if (0 > $total) { |
|
| 1472 | 1472 | $total = 0; |
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1475 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | 1478 | /** |
@@ -1483,10 +1483,10 @@ discard block |
||
| 1483 | 1483 | * @param string $currency Whether to include the currency. |
| 1484 | 1484 | * @return float |
| 1485 | 1485 | */ |
| 1486 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1486 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1487 | 1487 | |
| 1488 | 1488 | // Maybe recalculate totals. |
| 1489 | - if ( empty( $this->totals ) ) { |
|
| 1489 | + if (empty($this->totals)) { |
|
| 1490 | 1490 | $this->recalculate_total(); |
| 1491 | 1491 | } |
| 1492 | 1492 | |
@@ -1506,8 +1506,8 @@ discard block |
||
| 1506 | 1506 | $currency |
| 1507 | 1507 | ); |
| 1508 | 1508 | |
| 1509 | - if ( isset( $data[$field] ) ) { |
|
| 1510 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1509 | + if (isset($data[$field])) { |
|
| 1510 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | return $data; |
@@ -1520,8 +1520,8 @@ discard block |
||
| 1520 | 1520 | * @param string $context View or edit context. |
| 1521 | 1521 | * @return array |
| 1522 | 1522 | */ |
| 1523 | - public function get_fees( $context = 'view' ) { |
|
| 1524 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1523 | + public function get_fees($context = 'view') { |
|
| 1524 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | /** |
@@ -1531,8 +1531,8 @@ discard block |
||
| 1531 | 1531 | * @param string $context View or edit context. |
| 1532 | 1532 | * @return array |
| 1533 | 1533 | */ |
| 1534 | - public function get_discounts( $context = 'view' ) { |
|
| 1535 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1534 | + public function get_discounts($context = 'view') { |
|
| 1535 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | /** |
@@ -1542,8 +1542,8 @@ discard block |
||
| 1542 | 1542 | * @param string $context View or edit context. |
| 1543 | 1543 | * @return array |
| 1544 | 1544 | */ |
| 1545 | - public function get_taxes( $context = 'view' ) { |
|
| 1546 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1545 | + public function get_taxes($context = 'view') { |
|
| 1546 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | 1549 | /** |
@@ -1553,8 +1553,8 @@ discard block |
||
| 1553 | 1553 | * @param string $context View or edit context. |
| 1554 | 1554 | * @return GetPaid_Form_Item[] |
| 1555 | 1555 | */ |
| 1556 | - public function get_items( $context = 'view' ) { |
|
| 1557 | - return $this->get_prop( 'items', $context ); |
|
| 1556 | + public function get_items($context = 'view') { |
|
| 1557 | + return $this->get_prop('items', $context); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | 1560 | /** |
@@ -1564,8 +1564,8 @@ discard block |
||
| 1564 | 1564 | * @param string $context View or edit context. |
| 1565 | 1565 | * @return int |
| 1566 | 1566 | */ |
| 1567 | - public function get_payment_form( $context = 'view' ) { |
|
| 1568 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1567 | + public function get_payment_form($context = 'view') { |
|
| 1568 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | /** |
@@ -1575,8 +1575,8 @@ discard block |
||
| 1575 | 1575 | * @param string $context View or edit context. |
| 1576 | 1576 | * @return string |
| 1577 | 1577 | */ |
| 1578 | - public function get_submission_id( $context = 'view' ) { |
|
| 1579 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1578 | + public function get_submission_id($context = 'view') { |
|
| 1579 | + return $this->get_prop('submission_id', $context); |
|
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | 1582 | /** |
@@ -1586,8 +1586,8 @@ discard block |
||
| 1586 | 1586 | * @param string $context View or edit context. |
| 1587 | 1587 | * @return string |
| 1588 | 1588 | */ |
| 1589 | - public function get_discount_code( $context = 'view' ) { |
|
| 1590 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1589 | + public function get_discount_code($context = 'view') { |
|
| 1590 | + return $this->get_prop('discount_code', $context); |
|
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | /** |
@@ -1597,8 +1597,8 @@ discard block |
||
| 1597 | 1597 | * @param string $context View or edit context. |
| 1598 | 1598 | * @return string |
| 1599 | 1599 | */ |
| 1600 | - public function get_gateway( $context = 'view' ) { |
|
| 1601 | - return $this->get_prop( 'gateway', $context ); |
|
| 1600 | + public function get_gateway($context = 'view') { |
|
| 1601 | + return $this->get_prop('gateway', $context); |
|
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | /** |
@@ -1608,8 +1608,8 @@ discard block |
||
| 1608 | 1608 | * @return string |
| 1609 | 1609 | */ |
| 1610 | 1610 | public function get_gateway_title() { |
| 1611 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1612 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1611 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1612 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | /** |
@@ -1619,8 +1619,8 @@ discard block |
||
| 1619 | 1619 | * @param string $context View or edit context. |
| 1620 | 1620 | * @return string |
| 1621 | 1621 | */ |
| 1622 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1623 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1622 | + public function get_transaction_id($context = 'view') { |
|
| 1623 | + return $this->get_prop('transaction_id', $context); |
|
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | 1626 | /** |
@@ -1630,9 +1630,9 @@ discard block |
||
| 1630 | 1630 | * @param string $context View or edit context. |
| 1631 | 1631 | * @return string |
| 1632 | 1632 | */ |
| 1633 | - public function get_currency( $context = 'view' ) { |
|
| 1634 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1635 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1633 | + public function get_currency($context = 'view') { |
|
| 1634 | + $currency = $this->get_prop('currency', $context); |
|
| 1635 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | /** |
@@ -1642,8 +1642,8 @@ discard block |
||
| 1642 | 1642 | * @param string $context View or edit context. |
| 1643 | 1643 | * @return bool |
| 1644 | 1644 | */ |
| 1645 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1646 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1645 | + public function get_disable_taxes($context = 'view') { |
|
| 1646 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | 1649 | /** |
@@ -1653,8 +1653,8 @@ discard block |
||
| 1653 | 1653 | * @param string $context View or edit context. |
| 1654 | 1654 | * @return int |
| 1655 | 1655 | */ |
| 1656 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1657 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1656 | + public function get_subscription_id($context = 'view') { |
|
| 1657 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | 1660 | /** |
@@ -1664,12 +1664,12 @@ discard block |
||
| 1664 | 1664 | * @param string $context View or edit context. |
| 1665 | 1665 | * @return int |
| 1666 | 1666 | */ |
| 1667 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
| 1668 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
| 1667 | + public function get_remote_subscription_id($context = 'view') { |
|
| 1668 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
| 1669 | 1669 | |
| 1670 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1670 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1671 | 1671 | $parent = $this->get_parent(); |
| 1672 | - return $parent->get_subscription_id( $context ); |
|
| 1672 | + return $parent->get_subscription_id($context); |
|
| 1673 | 1673 | } |
| 1674 | 1674 | |
| 1675 | 1675 | return $subscription_id; |
@@ -1682,20 +1682,20 @@ discard block |
||
| 1682 | 1682 | * @param string $context View or edit context. |
| 1683 | 1683 | * @return array |
| 1684 | 1684 | */ |
| 1685 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1685 | + public function get_payment_meta($context = 'view') { |
|
| 1686 | 1686 | |
| 1687 | 1687 | return array( |
| 1688 | - 'price' => $this->get_total( $context ), |
|
| 1689 | - 'date' => $this->get_date_created( $context ), |
|
| 1690 | - 'user_email' => $this->get_email( $context ), |
|
| 1691 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1692 | - 'currency' => $this->get_currency( $context ), |
|
| 1693 | - 'items' => $this->get_items( $context ), |
|
| 1694 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1688 | + 'price' => $this->get_total($context), |
|
| 1689 | + 'date' => $this->get_date_created($context), |
|
| 1690 | + 'user_email' => $this->get_email($context), |
|
| 1691 | + 'invoice_key' => $this->get_key($context), |
|
| 1692 | + 'currency' => $this->get_currency($context), |
|
| 1693 | + 'items' => $this->get_items($context), |
|
| 1694 | + 'user_info' => $this->get_user_info($context), |
|
| 1695 | 1695 | 'cart_details' => $this->get_cart_details(), |
| 1696 | - 'status' => $this->get_status( $context ), |
|
| 1697 | - 'fees' => $this->get_fees( $context ), |
|
| 1698 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1696 | + 'status' => $this->get_status($context), |
|
| 1697 | + 'fees' => $this->get_fees($context), |
|
| 1698 | + 'taxes' => $this->get_taxes($context), |
|
| 1699 | 1699 | ); |
| 1700 | 1700 | |
| 1701 | 1701 | } |
@@ -1710,9 +1710,9 @@ discard block |
||
| 1710 | 1710 | $items = $this->get_items(); |
| 1711 | 1711 | $cart_details = array(); |
| 1712 | 1712 | |
| 1713 | - foreach ( $items as $item_id => $item ) { |
|
| 1713 | + foreach ($items as $item_id => $item) { |
|
| 1714 | 1714 | $item->invoice_id = $this->get_id(); |
| 1715 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1715 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1716 | 1716 | } |
| 1717 | 1717 | |
| 1718 | 1718 | return $cart_details; |
@@ -1723,11 +1723,11 @@ discard block |
||
| 1723 | 1723 | * |
| 1724 | 1724 | * @return null|GetPaid_Form_Item|int |
| 1725 | 1725 | */ |
| 1726 | - public function get_recurring( $object = false ) { |
|
| 1726 | + public function get_recurring($object = false) { |
|
| 1727 | 1727 | |
| 1728 | 1728 | // Are we returning an object? |
| 1729 | - if ( $object ) { |
|
| 1730 | - return $this->get_item( $this->recurring_item ); |
|
| 1729 | + if ($object) { |
|
| 1730 | + return $this->get_item($this->recurring_item); |
|
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | 1733 | return $this->recurring_item; |
@@ -1742,15 +1742,15 @@ discard block |
||
| 1742 | 1742 | public function get_subscription_name() { |
| 1743 | 1743 | |
| 1744 | 1744 | // Retrieve the recurring name |
| 1745 | - $item = $this->get_recurring( true ); |
|
| 1745 | + $item = $this->get_recurring(true); |
|
| 1746 | 1746 | |
| 1747 | 1747 | // Abort if it does not exist. |
| 1748 | - if ( empty( $item ) ) { |
|
| 1748 | + if (empty($item)) { |
|
| 1749 | 1749 | return ''; |
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | 1752 | // Return the item name. |
| 1753 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1753 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | 1756 | /** |
@@ -1760,9 +1760,9 @@ discard block |
||
| 1760 | 1760 | * @return string |
| 1761 | 1761 | */ |
| 1762 | 1762 | public function get_view_url() { |
| 1763 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1764 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1765 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1763 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1764 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1765 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | /** |
@@ -1771,25 +1771,25 @@ discard block |
||
| 1771 | 1771 | * @since 1.0.19 |
| 1772 | 1772 | * @return string |
| 1773 | 1773 | */ |
| 1774 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1774 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1775 | 1775 | |
| 1776 | 1776 | // Retrieve the checkout url. |
| 1777 | 1777 | $pay_url = wpinv_get_checkout_uri(); |
| 1778 | 1778 | |
| 1779 | 1779 | // Maybe force ssl. |
| 1780 | - if ( is_ssl() ) { |
|
| 1781 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1780 | + if (is_ssl()) { |
|
| 1781 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | 1784 | // Add the invoice key. |
| 1785 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1785 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1786 | 1786 | |
| 1787 | 1787 | // (Maybe?) add a secret |
| 1788 | - if ( $secret ) { |
|
| 1789 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1788 | + if ($secret) { |
|
| 1789 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1792 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | 1795 | /** |
@@ -1804,14 +1804,14 @@ discard block |
||
| 1804 | 1804 | $receipt_url = wpinv_get_success_page_uri(); |
| 1805 | 1805 | |
| 1806 | 1806 | // Maybe force ssl. |
| 1807 | - if ( is_ssl() ) { |
|
| 1808 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
| 1807 | + if (is_ssl()) { |
|
| 1808 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
| 1809 | 1809 | } |
| 1810 | 1810 | |
| 1811 | 1811 | // Add the invoice key. |
| 1812 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1812 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
| 1813 | 1813 | |
| 1814 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
| 1814 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | 1817 | /** |
@@ -1824,8 +1824,8 @@ discard block |
||
| 1824 | 1824 | * @param string $context View or edit context. |
| 1825 | 1825 | * @return mixed Value of the given invoice property (if set). |
| 1826 | 1826 | */ |
| 1827 | - public function get( $key, $context = 'view' ) { |
|
| 1828 | - return $this->get_prop( $key, $context ); |
|
| 1827 | + public function get($key, $context = 'view') { |
|
| 1828 | + return $this->get_prop($key, $context); |
|
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | 1831 | /* |
@@ -1848,11 +1848,11 @@ discard block |
||
| 1848 | 1848 | * @param mixed $value new value. |
| 1849 | 1849 | * @return mixed Value of the given invoice property (if set). |
| 1850 | 1850 | */ |
| 1851 | - public function set( $key, $value ) { |
|
| 1851 | + public function set($key, $value) { |
|
| 1852 | 1852 | |
| 1853 | 1853 | $setter = "set_$key"; |
| 1854 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1855 | - $this->{$setter}( $value ); |
|
| 1854 | + if (is_callable(array($this, $setter))) { |
|
| 1855 | + $this->{$setter}($value); |
|
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | } |
@@ -1866,47 +1866,47 @@ discard block |
||
| 1866 | 1866 | * @param bool $manual_update Is this a manual status change?. |
| 1867 | 1867 | * @return array details of change. |
| 1868 | 1868 | */ |
| 1869 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1869 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1870 | 1870 | $old_status = $this->get_status(); |
| 1871 | 1871 | |
| 1872 | 1872 | $statuses = $this->get_all_statuses(); |
| 1873 | 1873 | |
| 1874 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1875 | - unset( $statuses[ 'draft' ] ); |
|
| 1874 | + if (isset($statuses['draft'])) { |
|
| 1875 | + unset($statuses['draft']); |
|
| 1876 | 1876 | } |
| 1877 | 1877 | |
| 1878 | - $this->set_prop( 'status', $new_status ); |
|
| 1878 | + $this->set_prop('status', $new_status); |
|
| 1879 | 1879 | |
| 1880 | 1880 | // If setting the status, ensure it's set to a valid status. |
| 1881 | - if ( true === $this->object_read ) { |
|
| 1881 | + if (true === $this->object_read) { |
|
| 1882 | 1882 | |
| 1883 | 1883 | // Only allow valid new status. |
| 1884 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1884 | + if (!array_key_exists($new_status, $statuses)) { |
|
| 1885 | 1885 | $new_status = 'wpi-pending'; |
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | 1888 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1889 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1889 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
| 1890 | 1890 | $old_status = 'wpi-pending'; |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
| 1894 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1894 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
| 1895 | 1895 | $old_status = 'wpi-pending'; |
| 1896 | 1896 | } |
| 1897 | 1897 | |
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1900 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
| 1901 | 1901 | $this->status_transition = array( |
| 1902 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1902 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1903 | 1903 | 'to' => $new_status, |
| 1904 | 1904 | 'note' => $note, |
| 1905 | 1905 | 'manual' => (bool) $manual_update, |
| 1906 | 1906 | ); |
| 1907 | 1907 | |
| 1908 | - if ( $manual_update ) { |
|
| 1909 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1908 | + if ($manual_update) { |
|
| 1909 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | $this->maybe_set_date_paid(); |
@@ -1929,8 +1929,8 @@ discard block |
||
| 1929 | 1929 | */ |
| 1930 | 1930 | public function maybe_set_date_paid() { |
| 1931 | 1931 | |
| 1932 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1933 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1932 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 1933 | + $this->set_date_completed(current_time('mysql')); |
|
| 1934 | 1934 | } |
| 1935 | 1935 | } |
| 1936 | 1936 | |
@@ -1939,11 +1939,11 @@ discard block |
||
| 1939 | 1939 | * |
| 1940 | 1940 | * @since 1.0.19 |
| 1941 | 1941 | */ |
| 1942 | - public function set_parent_id( $value ) { |
|
| 1943 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1942 | + public function set_parent_id($value) { |
|
| 1943 | + if ($value && ($value === $this->get_id())) { |
|
| 1944 | 1944 | return; |
| 1945 | 1945 | } |
| 1946 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1946 | + $this->set_prop('parent_id', absint($value)); |
|
| 1947 | 1947 | } |
| 1948 | 1948 | |
| 1949 | 1949 | /** |
@@ -1951,8 +1951,8 @@ discard block |
||
| 1951 | 1951 | * |
| 1952 | 1952 | * @since 1.0.19 |
| 1953 | 1953 | */ |
| 1954 | - public function set_version( $value ) { |
|
| 1955 | - $this->set_prop( 'version', $value ); |
|
| 1954 | + public function set_version($value) { |
|
| 1955 | + $this->set_prop('version', $value); |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | /** |
@@ -1962,15 +1962,15 @@ discard block |
||
| 1962 | 1962 | * @param string $value Value to set. |
| 1963 | 1963 | * @return bool Whether or not the date was set. |
| 1964 | 1964 | */ |
| 1965 | - public function set_date_created( $value ) { |
|
| 1966 | - $date = strtotime( $value ); |
|
| 1965 | + public function set_date_created($value) { |
|
| 1966 | + $date = strtotime($value); |
|
| 1967 | 1967 | |
| 1968 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1969 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1968 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1969 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 1970 | 1970 | return true; |
| 1971 | 1971 | } |
| 1972 | 1972 | |
| 1973 | - return $this->set_prop( 'date_created', '' ); |
|
| 1973 | + return $this->set_prop('date_created', ''); |
|
| 1974 | 1974 | |
| 1975 | 1975 | } |
| 1976 | 1976 | |
@@ -1981,15 +1981,15 @@ discard block |
||
| 1981 | 1981 | * @param string $value Value to set. |
| 1982 | 1982 | * @return bool Whether or not the date was set. |
| 1983 | 1983 | */ |
| 1984 | - public function set_due_date( $value ) { |
|
| 1985 | - $date = strtotime( $value ); |
|
| 1984 | + public function set_due_date($value) { |
|
| 1985 | + $date = strtotime($value); |
|
| 1986 | 1986 | |
| 1987 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1988 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1987 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1988 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 1989 | 1989 | return true; |
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | - $this->set_prop( 'due_date', '' ); |
|
| 1992 | + $this->set_prop('due_date', ''); |
|
| 1993 | 1993 | return false; |
| 1994 | 1994 | |
| 1995 | 1995 | } |
@@ -2000,8 +2000,8 @@ discard block |
||
| 2000 | 2000 | * @since 1.0.19 |
| 2001 | 2001 | * @param string $value New name. |
| 2002 | 2002 | */ |
| 2003 | - public function set_date_due( $value ) { |
|
| 2004 | - $this->set_due_date( $value ); |
|
| 2003 | + public function set_date_due($value) { |
|
| 2004 | + $this->set_due_date($value); |
|
| 2005 | 2005 | } |
| 2006 | 2006 | |
| 2007 | 2007 | /** |
@@ -2011,15 +2011,15 @@ discard block |
||
| 2011 | 2011 | * @param string $value Value to set. |
| 2012 | 2012 | * @return bool Whether or not the date was set. |
| 2013 | 2013 | */ |
| 2014 | - public function set_completed_date( $value ) { |
|
| 2015 | - $date = strtotime( $value ); |
|
| 2014 | + public function set_completed_date($value) { |
|
| 2015 | + $date = strtotime($value); |
|
| 2016 | 2016 | |
| 2017 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2018 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2017 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2018 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 2019 | 2019 | return true; |
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | - $this->set_prop( 'completed_date', '' ); |
|
| 2022 | + $this->set_prop('completed_date', ''); |
|
| 2023 | 2023 | return false; |
| 2024 | 2024 | |
| 2025 | 2025 | } |
@@ -2030,8 +2030,8 @@ discard block |
||
| 2030 | 2030 | * @since 1.0.19 |
| 2031 | 2031 | * @param string $value New name. |
| 2032 | 2032 | */ |
| 2033 | - public function set_date_completed( $value ) { |
|
| 2034 | - $this->set_completed_date( $value ); |
|
| 2033 | + public function set_date_completed($value) { |
|
| 2034 | + $this->set_completed_date($value); |
|
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | /** |
@@ -2041,15 +2041,15 @@ discard block |
||
| 2041 | 2041 | * @param string $value Value to set. |
| 2042 | 2042 | * @return bool Whether or not the date was set. |
| 2043 | 2043 | */ |
| 2044 | - public function set_date_modified( $value ) { |
|
| 2045 | - $date = strtotime( $value ); |
|
| 2044 | + public function set_date_modified($value) { |
|
| 2045 | + $date = strtotime($value); |
|
| 2046 | 2046 | |
| 2047 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2048 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2047 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2048 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 2049 | 2049 | return true; |
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | - $this->set_prop( 'date_modified', '' ); |
|
| 2052 | + $this->set_prop('date_modified', ''); |
|
| 2053 | 2053 | return false; |
| 2054 | 2054 | |
| 2055 | 2055 | } |
@@ -2060,9 +2060,9 @@ discard block |
||
| 2060 | 2060 | * @since 1.0.19 |
| 2061 | 2061 | * @param string $value New number. |
| 2062 | 2062 | */ |
| 2063 | - public function set_number( $value ) { |
|
| 2064 | - $number = sanitize_text_field( $value ); |
|
| 2065 | - $this->set_prop( 'number', $number ); |
|
| 2063 | + public function set_number($value) { |
|
| 2064 | + $number = sanitize_text_field($value); |
|
| 2065 | + $this->set_prop('number', $number); |
|
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | 2068 | /** |
@@ -2071,9 +2071,9 @@ discard block |
||
| 2071 | 2071 | * @since 1.0.19 |
| 2072 | 2072 | * @param string $value Type. |
| 2073 | 2073 | */ |
| 2074 | - public function set_type( $value ) { |
|
| 2075 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 2076 | - $this->set_prop( 'type', $type ); |
|
| 2074 | + public function set_type($value) { |
|
| 2075 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 2076 | + $this->set_prop('type', $type); |
|
| 2077 | 2077 | } |
| 2078 | 2078 | |
| 2079 | 2079 | /** |
@@ -2082,10 +2082,10 @@ discard block |
||
| 2082 | 2082 | * @since 1.0.19 |
| 2083 | 2083 | * @param string $value Post type. |
| 2084 | 2084 | */ |
| 2085 | - public function set_post_type( $value ) { |
|
| 2086 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 2087 | - $this->set_type( $value ); |
|
| 2088 | - $this->set_prop( 'post_type', $value ); |
|
| 2085 | + public function set_post_type($value) { |
|
| 2086 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 2087 | + $this->set_type($value); |
|
| 2088 | + $this->set_prop('post_type', $value); |
|
| 2089 | 2089 | } |
| 2090 | 2090 | } |
| 2091 | 2091 | |
@@ -2095,9 +2095,9 @@ discard block |
||
| 2095 | 2095 | * @since 1.0.19 |
| 2096 | 2096 | * @param string $value New key. |
| 2097 | 2097 | */ |
| 2098 | - public function set_key( $value ) { |
|
| 2099 | - $key = sanitize_text_field( $value ); |
|
| 2100 | - $this->set_prop( 'key', $key ); |
|
| 2098 | + public function set_key($value) { |
|
| 2099 | + $key = sanitize_text_field($value); |
|
| 2100 | + $this->set_prop('key', $key); |
|
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | /** |
@@ -2106,9 +2106,9 @@ discard block |
||
| 2106 | 2106 | * @since 1.0.19 |
| 2107 | 2107 | * @param string $value mode. |
| 2108 | 2108 | */ |
| 2109 | - public function set_mode( $value ) { |
|
| 2110 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2111 | - $this->set_prop( 'value', $value ); |
|
| 2109 | + public function set_mode($value) { |
|
| 2110 | + if (!in_array($value, array('live', 'test'))) { |
|
| 2111 | + $this->set_prop('value', $value); |
|
| 2112 | 2112 | } |
| 2113 | 2113 | } |
| 2114 | 2114 | |
@@ -2118,8 +2118,8 @@ discard block |
||
| 2118 | 2118 | * @since 1.0.19 |
| 2119 | 2119 | * @param string $value path. |
| 2120 | 2120 | */ |
| 2121 | - public function set_path( $value ) { |
|
| 2122 | - $this->set_prop( 'path', $value ); |
|
| 2121 | + public function set_path($value) { |
|
| 2122 | + $this->set_prop('path', $value); |
|
| 2123 | 2123 | } |
| 2124 | 2124 | |
| 2125 | 2125 | /** |
@@ -2128,9 +2128,9 @@ discard block |
||
| 2128 | 2128 | * @since 1.0.19 |
| 2129 | 2129 | * @param string $value New name. |
| 2130 | 2130 | */ |
| 2131 | - public function set_name( $value ) { |
|
| 2132 | - $name = sanitize_text_field( $value ); |
|
| 2133 | - $this->set_prop( 'name', $name ); |
|
| 2131 | + public function set_name($value) { |
|
| 2132 | + $name = sanitize_text_field($value); |
|
| 2133 | + $this->set_prop('name', $name); |
|
| 2134 | 2134 | } |
| 2135 | 2135 | |
| 2136 | 2136 | /** |
@@ -2139,8 +2139,8 @@ discard block |
||
| 2139 | 2139 | * @since 1.0.19 |
| 2140 | 2140 | * @param string $value New name. |
| 2141 | 2141 | */ |
| 2142 | - public function set_title( $value ) { |
|
| 2143 | - $this->set_name( $value ); |
|
| 2142 | + public function set_title($value) { |
|
| 2143 | + $this->set_name($value); |
|
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | /** |
@@ -2149,9 +2149,9 @@ discard block |
||
| 2149 | 2149 | * @since 1.0.19 |
| 2150 | 2150 | * @param string $value New description. |
| 2151 | 2151 | */ |
| 2152 | - public function set_description( $value ) { |
|
| 2153 | - $description = wp_kses_post( $value ); |
|
| 2154 | - return $this->set_prop( 'description', $description ); |
|
| 2152 | + public function set_description($value) { |
|
| 2153 | + $description = wp_kses_post($value); |
|
| 2154 | + return $this->set_prop('description', $description); |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | /** |
@@ -2160,8 +2160,8 @@ discard block |
||
| 2160 | 2160 | * @since 1.0.19 |
| 2161 | 2161 | * @param string $value New description. |
| 2162 | 2162 | */ |
| 2163 | - public function set_excerpt( $value ) { |
|
| 2164 | - $this->set_description( $value ); |
|
| 2163 | + public function set_excerpt($value) { |
|
| 2164 | + $this->set_description($value); |
|
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | 2167 | /** |
@@ -2170,8 +2170,8 @@ discard block |
||
| 2170 | 2170 | * @since 1.0.19 |
| 2171 | 2171 | * @param string $value New description. |
| 2172 | 2172 | */ |
| 2173 | - public function set_summary( $value ) { |
|
| 2174 | - $this->set_description( $value ); |
|
| 2173 | + public function set_summary($value) { |
|
| 2174 | + $this->set_description($value); |
|
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | 2177 | /** |
@@ -2180,12 +2180,12 @@ discard block |
||
| 2180 | 2180 | * @since 1.0.19 |
| 2181 | 2181 | * @param int $value New author. |
| 2182 | 2182 | */ |
| 2183 | - public function set_author( $value ) { |
|
| 2184 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2183 | + public function set_author($value) { |
|
| 2184 | + $user = get_user_by('id', (int) $value); |
|
| 2185 | 2185 | |
| 2186 | - if ( $user && $user->ID ) { |
|
| 2187 | - $this->set_prop( 'author', $user->ID ); |
|
| 2188 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2186 | + if ($user && $user->ID) { |
|
| 2187 | + $this->set_prop('author', $user->ID); |
|
| 2188 | + $this->set_prop('email', $user->user_email); |
|
| 2189 | 2189 | } |
| 2190 | 2190 | |
| 2191 | 2191 | } |
@@ -2196,8 +2196,8 @@ discard block |
||
| 2196 | 2196 | * @since 1.0.19 |
| 2197 | 2197 | * @param int $value New user id. |
| 2198 | 2198 | */ |
| 2199 | - public function set_user_id( $value ) { |
|
| 2200 | - $this->set_author( $value ); |
|
| 2199 | + public function set_user_id($value) { |
|
| 2200 | + $this->set_author($value); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | 2203 | /** |
@@ -2206,8 +2206,8 @@ discard block |
||
| 2206 | 2206 | * @since 1.0.19 |
| 2207 | 2207 | * @param int $value New user id. |
| 2208 | 2208 | */ |
| 2209 | - public function set_customer_id( $value ) { |
|
| 2210 | - $this->set_author( $value ); |
|
| 2209 | + public function set_customer_id($value) { |
|
| 2210 | + $this->set_author($value); |
|
| 2211 | 2211 | } |
| 2212 | 2212 | |
| 2213 | 2213 | /** |
@@ -2216,8 +2216,8 @@ discard block |
||
| 2216 | 2216 | * @since 1.0.19 |
| 2217 | 2217 | * @param string $value ip address. |
| 2218 | 2218 | */ |
| 2219 | - public function set_ip( $value ) { |
|
| 2220 | - $this->set_prop( 'ip', $value ); |
|
| 2219 | + public function set_ip($value) { |
|
| 2220 | + $this->set_prop('ip', $value); |
|
| 2221 | 2221 | } |
| 2222 | 2222 | |
| 2223 | 2223 | /** |
@@ -2226,8 +2226,8 @@ discard block |
||
| 2226 | 2226 | * @since 1.0.19 |
| 2227 | 2227 | * @param string $value ip address. |
| 2228 | 2228 | */ |
| 2229 | - public function set_user_ip( $value ) { |
|
| 2230 | - $this->set_ip( $value ); |
|
| 2229 | + public function set_user_ip($value) { |
|
| 2230 | + $this->set_ip($value); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | /** |
@@ -2236,8 +2236,8 @@ discard block |
||
| 2236 | 2236 | * @since 1.0.19 |
| 2237 | 2237 | * @param string $value first name. |
| 2238 | 2238 | */ |
| 2239 | - public function set_first_name( $value ) { |
|
| 2240 | - $this->set_prop( 'first_name', $value ); |
|
| 2239 | + public function set_first_name($value) { |
|
| 2240 | + $this->set_prop('first_name', $value); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | /** |
@@ -2246,8 +2246,8 @@ discard block |
||
| 2246 | 2246 | * @since 1.0.19 |
| 2247 | 2247 | * @param string $value first name. |
| 2248 | 2248 | */ |
| 2249 | - public function set_user_first_name( $value ) { |
|
| 2250 | - $this->set_first_name( $value ); |
|
| 2249 | + public function set_user_first_name($value) { |
|
| 2250 | + $this->set_first_name($value); |
|
| 2251 | 2251 | } |
| 2252 | 2252 | |
| 2253 | 2253 | /** |
@@ -2256,8 +2256,8 @@ discard block |
||
| 2256 | 2256 | * @since 1.0.19 |
| 2257 | 2257 | * @param string $value first name. |
| 2258 | 2258 | */ |
| 2259 | - public function set_customer_first_name( $value ) { |
|
| 2260 | - $this->set_first_name( $value ); |
|
| 2259 | + public function set_customer_first_name($value) { |
|
| 2260 | + $this->set_first_name($value); |
|
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | /** |
@@ -2266,8 +2266,8 @@ discard block |
||
| 2266 | 2266 | * @since 1.0.19 |
| 2267 | 2267 | * @param string $value last name. |
| 2268 | 2268 | */ |
| 2269 | - public function set_last_name( $value ) { |
|
| 2270 | - $this->set_prop( 'last_name', $value ); |
|
| 2269 | + public function set_last_name($value) { |
|
| 2270 | + $this->set_prop('last_name', $value); |
|
| 2271 | 2271 | } |
| 2272 | 2272 | |
| 2273 | 2273 | /** |
@@ -2276,8 +2276,8 @@ discard block |
||
| 2276 | 2276 | * @since 1.0.19 |
| 2277 | 2277 | * @param string $value last name. |
| 2278 | 2278 | */ |
| 2279 | - public function set_user_last_name( $value ) { |
|
| 2280 | - $this->set_last_name( $value ); |
|
| 2279 | + public function set_user_last_name($value) { |
|
| 2280 | + $this->set_last_name($value); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | /** |
@@ -2286,8 +2286,8 @@ discard block |
||
| 2286 | 2286 | * @since 1.0.19 |
| 2287 | 2287 | * @param string $value last name. |
| 2288 | 2288 | */ |
| 2289 | - public function set_customer_last_name( $value ) { |
|
| 2290 | - $this->set_last_name( $value ); |
|
| 2289 | + public function set_customer_last_name($value) { |
|
| 2290 | + $this->set_last_name($value); |
|
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | 2293 | /** |
@@ -2296,8 +2296,8 @@ discard block |
||
| 2296 | 2296 | * @since 1.0.19 |
| 2297 | 2297 | * @param string $value phone. |
| 2298 | 2298 | */ |
| 2299 | - public function set_phone( $value ) { |
|
| 2300 | - $this->set_prop( 'phone', $value ); |
|
| 2299 | + public function set_phone($value) { |
|
| 2300 | + $this->set_prop('phone', $value); |
|
| 2301 | 2301 | } |
| 2302 | 2302 | |
| 2303 | 2303 | /** |
@@ -2306,8 +2306,8 @@ discard block |
||
| 2306 | 2306 | * @since 1.0.19 |
| 2307 | 2307 | * @param string $value phone. |
| 2308 | 2308 | */ |
| 2309 | - public function set_user_phone( $value ) { |
|
| 2310 | - $this->set_phone( $value ); |
|
| 2309 | + public function set_user_phone($value) { |
|
| 2310 | + $this->set_phone($value); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | |
| 2313 | 2313 | /** |
@@ -2316,8 +2316,8 @@ discard block |
||
| 2316 | 2316 | * @since 1.0.19 |
| 2317 | 2317 | * @param string $value phone. |
| 2318 | 2318 | */ |
| 2319 | - public function set_customer_phone( $value ) { |
|
| 2320 | - $this->set_phone( $value ); |
|
| 2319 | + public function set_customer_phone($value) { |
|
| 2320 | + $this->set_phone($value); |
|
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | /** |
@@ -2326,8 +2326,8 @@ discard block |
||
| 2326 | 2326 | * @since 1.0.19 |
| 2327 | 2327 | * @param string $value phone. |
| 2328 | 2328 | */ |
| 2329 | - public function set_phone_number( $value ) { |
|
| 2330 | - $this->set_phone( $value ); |
|
| 2329 | + public function set_phone_number($value) { |
|
| 2330 | + $this->set_phone($value); |
|
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | 2333 | /** |
@@ -2336,8 +2336,8 @@ discard block |
||
| 2336 | 2336 | * @since 1.0.19 |
| 2337 | 2337 | * @param string $value email address. |
| 2338 | 2338 | */ |
| 2339 | - public function set_email( $value ) { |
|
| 2340 | - $this->set_prop( 'email', $value ); |
|
| 2339 | + public function set_email($value) { |
|
| 2340 | + $this->set_prop('email', $value); |
|
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | 2343 | /** |
@@ -2346,8 +2346,8 @@ discard block |
||
| 2346 | 2346 | * @since 1.0.19 |
| 2347 | 2347 | * @param string $value email address. |
| 2348 | 2348 | */ |
| 2349 | - public function set_user_email( $value ) { |
|
| 2350 | - $this->set_email( $value ); |
|
| 2349 | + public function set_user_email($value) { |
|
| 2350 | + $this->set_email($value); |
|
| 2351 | 2351 | } |
| 2352 | 2352 | |
| 2353 | 2353 | /** |
@@ -2356,8 +2356,8 @@ discard block |
||
| 2356 | 2356 | * @since 1.0.19 |
| 2357 | 2357 | * @param string $value email address. |
| 2358 | 2358 | */ |
| 2359 | - public function set_email_address( $value ) { |
|
| 2360 | - $this->set_email( $value ); |
|
| 2359 | + public function set_email_address($value) { |
|
| 2360 | + $this->set_email($value); |
|
| 2361 | 2361 | } |
| 2362 | 2362 | |
| 2363 | 2363 | /** |
@@ -2366,8 +2366,8 @@ discard block |
||
| 2366 | 2366 | * @since 1.0.19 |
| 2367 | 2367 | * @param string $value email address. |
| 2368 | 2368 | */ |
| 2369 | - public function set_customer_email( $value ) { |
|
| 2370 | - $this->set_email( $value ); |
|
| 2369 | + public function set_customer_email($value) { |
|
| 2370 | + $this->set_email($value); |
|
| 2371 | 2371 | } |
| 2372 | 2372 | |
| 2373 | 2373 | /** |
@@ -2376,8 +2376,8 @@ discard block |
||
| 2376 | 2376 | * @since 1.0.19 |
| 2377 | 2377 | * @param string $value country. |
| 2378 | 2378 | */ |
| 2379 | - public function set_country( $value ) { |
|
| 2380 | - $this->set_prop( 'country', $value ); |
|
| 2379 | + public function set_country($value) { |
|
| 2380 | + $this->set_prop('country', $value); |
|
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | 2383 | /** |
@@ -2386,8 +2386,8 @@ discard block |
||
| 2386 | 2386 | * @since 1.0.19 |
| 2387 | 2387 | * @param string $value country. |
| 2388 | 2388 | */ |
| 2389 | - public function set_user_country( $value ) { |
|
| 2390 | - $this->set_country( $value ); |
|
| 2389 | + public function set_user_country($value) { |
|
| 2390 | + $this->set_country($value); |
|
| 2391 | 2391 | } |
| 2392 | 2392 | |
| 2393 | 2393 | /** |
@@ -2396,8 +2396,8 @@ discard block |
||
| 2396 | 2396 | * @since 1.0.19 |
| 2397 | 2397 | * @param string $value country. |
| 2398 | 2398 | */ |
| 2399 | - public function set_customer_country( $value ) { |
|
| 2400 | - $this->set_country( $value ); |
|
| 2399 | + public function set_customer_country($value) { |
|
| 2400 | + $this->set_country($value); |
|
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | /** |
@@ -2406,8 +2406,8 @@ discard block |
||
| 2406 | 2406 | * @since 1.0.19 |
| 2407 | 2407 | * @param string $value state. |
| 2408 | 2408 | */ |
| 2409 | - public function set_state( $value ) { |
|
| 2410 | - $this->set_prop( 'state', $value ); |
|
| 2409 | + public function set_state($value) { |
|
| 2410 | + $this->set_prop('state', $value); |
|
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | 2413 | /** |
@@ -2416,8 +2416,8 @@ discard block |
||
| 2416 | 2416 | * @since 1.0.19 |
| 2417 | 2417 | * @param string $value state. |
| 2418 | 2418 | */ |
| 2419 | - public function set_user_state( $value ) { |
|
| 2420 | - $this->set_state( $value ); |
|
| 2419 | + public function set_user_state($value) { |
|
| 2420 | + $this->set_state($value); |
|
| 2421 | 2421 | } |
| 2422 | 2422 | |
| 2423 | 2423 | /** |
@@ -2426,8 +2426,8 @@ discard block |
||
| 2426 | 2426 | * @since 1.0.19 |
| 2427 | 2427 | * @param string $value state. |
| 2428 | 2428 | */ |
| 2429 | - public function set_customer_state( $value ) { |
|
| 2430 | - $this->set_state( $value ); |
|
| 2429 | + public function set_customer_state($value) { |
|
| 2430 | + $this->set_state($value); |
|
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | 2433 | /** |
@@ -2436,8 +2436,8 @@ discard block |
||
| 2436 | 2436 | * @since 1.0.19 |
| 2437 | 2437 | * @param string $value city. |
| 2438 | 2438 | */ |
| 2439 | - public function set_city( $value ) { |
|
| 2440 | - $this->set_prop( 'city', $value ); |
|
| 2439 | + public function set_city($value) { |
|
| 2440 | + $this->set_prop('city', $value); |
|
| 2441 | 2441 | } |
| 2442 | 2442 | |
| 2443 | 2443 | /** |
@@ -2446,8 +2446,8 @@ discard block |
||
| 2446 | 2446 | * @since 1.0.19 |
| 2447 | 2447 | * @param string $value city. |
| 2448 | 2448 | */ |
| 2449 | - public function set_user_city( $value ) { |
|
| 2450 | - $this->set_city( $value ); |
|
| 2449 | + public function set_user_city($value) { |
|
| 2450 | + $this->set_city($value); |
|
| 2451 | 2451 | } |
| 2452 | 2452 | |
| 2453 | 2453 | /** |
@@ -2456,8 +2456,8 @@ discard block |
||
| 2456 | 2456 | * @since 1.0.19 |
| 2457 | 2457 | * @param string $value city. |
| 2458 | 2458 | */ |
| 2459 | - public function set_customer_city( $value ) { |
|
| 2460 | - $this->set_city( $value ); |
|
| 2459 | + public function set_customer_city($value) { |
|
| 2460 | + $this->set_city($value); |
|
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | 2463 | /** |
@@ -2466,8 +2466,8 @@ discard block |
||
| 2466 | 2466 | * @since 1.0.19 |
| 2467 | 2467 | * @param string $value zip. |
| 2468 | 2468 | */ |
| 2469 | - public function set_zip( $value ) { |
|
| 2470 | - $this->set_prop( 'zip', $value ); |
|
| 2469 | + public function set_zip($value) { |
|
| 2470 | + $this->set_prop('zip', $value); |
|
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | 2473 | /** |
@@ -2476,8 +2476,8 @@ discard block |
||
| 2476 | 2476 | * @since 1.0.19 |
| 2477 | 2477 | * @param string $value zip. |
| 2478 | 2478 | */ |
| 2479 | - public function set_user_zip( $value ) { |
|
| 2480 | - $this->set_zip( $value ); |
|
| 2479 | + public function set_user_zip($value) { |
|
| 2480 | + $this->set_zip($value); |
|
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | 2483 | /** |
@@ -2486,8 +2486,8 @@ discard block |
||
| 2486 | 2486 | * @since 1.0.19 |
| 2487 | 2487 | * @param string $value zip. |
| 2488 | 2488 | */ |
| 2489 | - public function set_customer_zip( $value ) { |
|
| 2490 | - $this->set_zip( $value ); |
|
| 2489 | + public function set_customer_zip($value) { |
|
| 2490 | + $this->set_zip($value); |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | /** |
@@ -2496,8 +2496,8 @@ discard block |
||
| 2496 | 2496 | * @since 1.0.19 |
| 2497 | 2497 | * @param string $value company. |
| 2498 | 2498 | */ |
| 2499 | - public function set_company( $value ) { |
|
| 2500 | - $this->set_prop( 'company', $value ); |
|
| 2499 | + public function set_company($value) { |
|
| 2500 | + $this->set_prop('company', $value); |
|
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | 2503 | /** |
@@ -2506,8 +2506,8 @@ discard block |
||
| 2506 | 2506 | * @since 1.0.19 |
| 2507 | 2507 | * @param string $value company. |
| 2508 | 2508 | */ |
| 2509 | - public function set_user_company( $value ) { |
|
| 2510 | - $this->set_company( $value ); |
|
| 2509 | + public function set_user_company($value) { |
|
| 2510 | + $this->set_company($value); |
|
| 2511 | 2511 | } |
| 2512 | 2512 | |
| 2513 | 2513 | /** |
@@ -2516,8 +2516,8 @@ discard block |
||
| 2516 | 2516 | * @since 1.0.19 |
| 2517 | 2517 | * @param string $value company. |
| 2518 | 2518 | */ |
| 2519 | - public function set_customer_company( $value ) { |
|
| 2520 | - $this->set_company( $value ); |
|
| 2519 | + public function set_customer_company($value) { |
|
| 2520 | + $this->set_company($value); |
|
| 2521 | 2521 | } |
| 2522 | 2522 | |
| 2523 | 2523 | /** |
@@ -2526,8 +2526,8 @@ discard block |
||
| 2526 | 2526 | * @since 1.0.19 |
| 2527 | 2527 | * @param string $value var number. |
| 2528 | 2528 | */ |
| 2529 | - public function set_vat_number( $value ) { |
|
| 2530 | - $this->set_prop( 'vat_number', $value ); |
|
| 2529 | + public function set_vat_number($value) { |
|
| 2530 | + $this->set_prop('vat_number', $value); |
|
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | 2533 | /** |
@@ -2536,8 +2536,8 @@ discard block |
||
| 2536 | 2536 | * @since 1.0.19 |
| 2537 | 2537 | * @param string $value var number. |
| 2538 | 2538 | */ |
| 2539 | - public function set_user_vat_number( $value ) { |
|
| 2540 | - $this->set_vat_number( $value ); |
|
| 2539 | + public function set_user_vat_number($value) { |
|
| 2540 | + $this->set_vat_number($value); |
|
| 2541 | 2541 | } |
| 2542 | 2542 | |
| 2543 | 2543 | /** |
@@ -2546,8 +2546,8 @@ discard block |
||
| 2546 | 2546 | * @since 1.0.19 |
| 2547 | 2547 | * @param string $value var number. |
| 2548 | 2548 | */ |
| 2549 | - public function set_customer_vat_number( $value ) { |
|
| 2550 | - $this->set_vat_number( $value ); |
|
| 2549 | + public function set_customer_vat_number($value) { |
|
| 2550 | + $this->set_vat_number($value); |
|
| 2551 | 2551 | } |
| 2552 | 2552 | |
| 2553 | 2553 | /** |
@@ -2556,8 +2556,8 @@ discard block |
||
| 2556 | 2556 | * @since 1.0.19 |
| 2557 | 2557 | * @param string $value var rate. |
| 2558 | 2558 | */ |
| 2559 | - public function set_vat_rate( $value ) { |
|
| 2560 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2559 | + public function set_vat_rate($value) { |
|
| 2560 | + $this->set_prop('vat_rate', $value); |
|
| 2561 | 2561 | } |
| 2562 | 2562 | |
| 2563 | 2563 | /** |
@@ -2566,8 +2566,8 @@ discard block |
||
| 2566 | 2566 | * @since 1.0.19 |
| 2567 | 2567 | * @param string $value var number. |
| 2568 | 2568 | */ |
| 2569 | - public function set_user_vat_rate( $value ) { |
|
| 2570 | - $this->set_vat_rate( $value ); |
|
| 2569 | + public function set_user_vat_rate($value) { |
|
| 2570 | + $this->set_vat_rate($value); |
|
| 2571 | 2571 | } |
| 2572 | 2572 | |
| 2573 | 2573 | /** |
@@ -2576,8 +2576,8 @@ discard block |
||
| 2576 | 2576 | * @since 1.0.19 |
| 2577 | 2577 | * @param string $value var number. |
| 2578 | 2578 | */ |
| 2579 | - public function set_customer_vat_rate( $value ) { |
|
| 2580 | - $this->set_vat_rate( $value ); |
|
| 2579 | + public function set_customer_vat_rate($value) { |
|
| 2580 | + $this->set_vat_rate($value); |
|
| 2581 | 2581 | } |
| 2582 | 2582 | |
| 2583 | 2583 | /** |
@@ -2586,8 +2586,8 @@ discard block |
||
| 2586 | 2586 | * @since 1.0.19 |
| 2587 | 2587 | * @param string $value address. |
| 2588 | 2588 | */ |
| 2589 | - public function set_address( $value ) { |
|
| 2590 | - $this->set_prop( 'address', $value ); |
|
| 2589 | + public function set_address($value) { |
|
| 2590 | + $this->set_prop('address', $value); |
|
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | 2593 | /** |
@@ -2596,8 +2596,8 @@ discard block |
||
| 2596 | 2596 | * @since 1.0.19 |
| 2597 | 2597 | * @param string $value address. |
| 2598 | 2598 | */ |
| 2599 | - public function set_user_address( $value ) { |
|
| 2600 | - $this->set_address( $value ); |
|
| 2599 | + public function set_user_address($value) { |
|
| 2600 | + $this->set_address($value); |
|
| 2601 | 2601 | } |
| 2602 | 2602 | |
| 2603 | 2603 | /** |
@@ -2606,8 +2606,8 @@ discard block |
||
| 2606 | 2606 | * @since 1.0.19 |
| 2607 | 2607 | * @param string $value address. |
| 2608 | 2608 | */ |
| 2609 | - public function set_customer_address( $value ) { |
|
| 2610 | - $this->set_address( $value ); |
|
| 2609 | + public function set_customer_address($value) { |
|
| 2610 | + $this->set_address($value); |
|
| 2611 | 2611 | } |
| 2612 | 2612 | |
| 2613 | 2613 | /** |
@@ -2616,8 +2616,8 @@ discard block |
||
| 2616 | 2616 | * @since 1.0.19 |
| 2617 | 2617 | * @param int|bool $value confirmed. |
| 2618 | 2618 | */ |
| 2619 | - public function set_is_viewed( $value ) { |
|
| 2620 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2619 | + public function set_is_viewed($value) { |
|
| 2620 | + $this->set_prop('is_viewed', $value); |
|
| 2621 | 2621 | } |
| 2622 | 2622 | |
| 2623 | 2623 | /** |
@@ -2626,8 +2626,8 @@ discard block |
||
| 2626 | 2626 | * @since 1.0.19 |
| 2627 | 2627 | * @param string $value email recipients. |
| 2628 | 2628 | */ |
| 2629 | - public function set_email_cc( $value ) { |
|
| 2630 | - $this->set_prop( 'email_cc', $value ); |
|
| 2629 | + public function set_email_cc($value) { |
|
| 2630 | + $this->set_prop('email_cc', $value); |
|
| 2631 | 2631 | } |
| 2632 | 2632 | |
| 2633 | 2633 | /** |
@@ -2636,9 +2636,9 @@ discard block |
||
| 2636 | 2636 | * @since 1.0.19 |
| 2637 | 2637 | * @param string $value template. |
| 2638 | 2638 | */ |
| 2639 | - public function set_template( $value ) { |
|
| 2640 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2641 | - $this->set_prop( 'template', $value ); |
|
| 2639 | + public function set_template($value) { |
|
| 2640 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2641 | + $this->set_prop('template', $value); |
|
| 2642 | 2642 | } |
| 2643 | 2643 | } |
| 2644 | 2644 | |
@@ -2648,8 +2648,8 @@ discard block |
||
| 2648 | 2648 | * @since 1.0.19 |
| 2649 | 2649 | * @param string $value email recipients. |
| 2650 | 2650 | */ |
| 2651 | - public function created_via( $value ) { |
|
| 2652 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2651 | + public function created_via($value) { |
|
| 2652 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | |
| 2655 | 2655 | /** |
@@ -2658,8 +2658,8 @@ discard block |
||
| 2658 | 2658 | * @since 1.0.19 |
| 2659 | 2659 | * @param int|bool $value confirmed. |
| 2660 | 2660 | */ |
| 2661 | - public function set_address_confirmed( $value ) { |
|
| 2662 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2661 | + public function set_address_confirmed($value) { |
|
| 2662 | + $this->set_prop('address_confirmed', $value); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | /** |
@@ -2668,8 +2668,8 @@ discard block |
||
| 2668 | 2668 | * @since 1.0.19 |
| 2669 | 2669 | * @param int|bool $value confirmed. |
| 2670 | 2670 | */ |
| 2671 | - public function set_user_address_confirmed( $value ) { |
|
| 2672 | - $this->set_address_confirmed( $value ); |
|
| 2671 | + public function set_user_address_confirmed($value) { |
|
| 2672 | + $this->set_address_confirmed($value); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
@@ -2678,8 +2678,8 @@ discard block |
||
| 2678 | 2678 | * @since 1.0.19 |
| 2679 | 2679 | * @param int|bool $value confirmed. |
| 2680 | 2680 | */ |
| 2681 | - public function set_customer_address_confirmed( $value ) { |
|
| 2682 | - $this->set_address_confirmed( $value ); |
|
| 2681 | + public function set_customer_address_confirmed($value) { |
|
| 2682 | + $this->set_address_confirmed($value); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
@@ -2688,8 +2688,8 @@ discard block |
||
| 2688 | 2688 | * @since 1.0.19 |
| 2689 | 2689 | * @param float $value sub total. |
| 2690 | 2690 | */ |
| 2691 | - public function set_subtotal( $value ) { |
|
| 2692 | - $this->set_prop( 'subtotal', $value ); |
|
| 2691 | + public function set_subtotal($value) { |
|
| 2692 | + $this->set_prop('subtotal', $value); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
@@ -2698,8 +2698,8 @@ discard block |
||
| 2698 | 2698 | * @since 1.0.19 |
| 2699 | 2699 | * @param float $value discount total. |
| 2700 | 2700 | */ |
| 2701 | - public function set_total_discount( $value ) { |
|
| 2702 | - $this->set_prop( 'total_discount', $value ); |
|
| 2701 | + public function set_total_discount($value) { |
|
| 2702 | + $this->set_prop('total_discount', $value); |
|
| 2703 | 2703 | } |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
@@ -2708,8 +2708,8 @@ discard block |
||
| 2708 | 2708 | * @since 1.0.19 |
| 2709 | 2709 | * @param float $value discount total. |
| 2710 | 2710 | */ |
| 2711 | - public function set_discount( $value ) { |
|
| 2712 | - $this->set_total_discount( $value ); |
|
| 2711 | + public function set_discount($value) { |
|
| 2712 | + $this->set_total_discount($value); |
|
| 2713 | 2713 | } |
| 2714 | 2714 | |
| 2715 | 2715 | /** |
@@ -2718,8 +2718,8 @@ discard block |
||
| 2718 | 2718 | * @since 1.0.19 |
| 2719 | 2719 | * @param float $value tax total. |
| 2720 | 2720 | */ |
| 2721 | - public function set_total_tax( $value ) { |
|
| 2722 | - $this->set_prop( 'total_tax', $value ); |
|
| 2721 | + public function set_total_tax($value) { |
|
| 2722 | + $this->set_prop('total_tax', $value); |
|
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | 2725 | /** |
@@ -2728,8 +2728,8 @@ discard block |
||
| 2728 | 2728 | * @since 1.0.19 |
| 2729 | 2729 | * @param float $value tax total. |
| 2730 | 2730 | */ |
| 2731 | - public function set_tax_total( $value ) { |
|
| 2732 | - $this->set_total_tax( $value ); |
|
| 2731 | + public function set_tax_total($value) { |
|
| 2732 | + $this->set_total_tax($value); |
|
| 2733 | 2733 | } |
| 2734 | 2734 | |
| 2735 | 2735 | /** |
@@ -2738,8 +2738,8 @@ discard block |
||
| 2738 | 2738 | * @since 1.0.19 |
| 2739 | 2739 | * @param float $value fees total. |
| 2740 | 2740 | */ |
| 2741 | - public function set_total_fees( $value ) { |
|
| 2742 | - $this->set_prop( 'total_fees', $value ); |
|
| 2741 | + public function set_total_fees($value) { |
|
| 2742 | + $this->set_prop('total_fees', $value); |
|
| 2743 | 2743 | } |
| 2744 | 2744 | |
| 2745 | 2745 | /** |
@@ -2748,8 +2748,8 @@ discard block |
||
| 2748 | 2748 | * @since 1.0.19 |
| 2749 | 2749 | * @param float $value fees total. |
| 2750 | 2750 | */ |
| 2751 | - public function set_fees_total( $value ) { |
|
| 2752 | - $this->set_total_fees( $value ); |
|
| 2751 | + public function set_fees_total($value) { |
|
| 2752 | + $this->set_total_fees($value); |
|
| 2753 | 2753 | } |
| 2754 | 2754 | |
| 2755 | 2755 | /** |
@@ -2758,13 +2758,13 @@ discard block |
||
| 2758 | 2758 | * @since 1.0.19 |
| 2759 | 2759 | * @param array $value fees. |
| 2760 | 2760 | */ |
| 2761 | - public function set_fees( $value ) { |
|
| 2761 | + public function set_fees($value) { |
|
| 2762 | 2762 | |
| 2763 | - if ( ! is_array( $value ) ) { |
|
| 2763 | + if (!is_array($value)) { |
|
| 2764 | 2764 | $value = array(); |
| 2765 | 2765 | } |
| 2766 | 2766 | |
| 2767 | - $this->set_prop( 'fees', $value ); |
|
| 2767 | + $this->set_prop('fees', $value); |
|
| 2768 | 2768 | |
| 2769 | 2769 | } |
| 2770 | 2770 | |
@@ -2774,13 +2774,13 @@ discard block |
||
| 2774 | 2774 | * @since 1.0.19 |
| 2775 | 2775 | * @param array $value taxes. |
| 2776 | 2776 | */ |
| 2777 | - public function set_taxes( $value ) { |
|
| 2777 | + public function set_taxes($value) { |
|
| 2778 | 2778 | |
| 2779 | - if ( ! is_array( $value ) ) { |
|
| 2779 | + if (!is_array($value)) { |
|
| 2780 | 2780 | $value = array(); |
| 2781 | 2781 | } |
| 2782 | 2782 | |
| 2783 | - $this->set_prop( 'taxes', $value ); |
|
| 2783 | + $this->set_prop('taxes', $value); |
|
| 2784 | 2784 | |
| 2785 | 2785 | } |
| 2786 | 2786 | |
@@ -2790,13 +2790,13 @@ discard block |
||
| 2790 | 2790 | * @since 1.0.19 |
| 2791 | 2791 | * @param array $value discounts. |
| 2792 | 2792 | */ |
| 2793 | - public function set_discounts( $value ) { |
|
| 2793 | + public function set_discounts($value) { |
|
| 2794 | 2794 | |
| 2795 | - if ( ! is_array( $value ) ) { |
|
| 2795 | + if (!is_array($value)) { |
|
| 2796 | 2796 | $value = array(); |
| 2797 | 2797 | } |
| 2798 | 2798 | |
| 2799 | - $this->set_prop( 'discounts', $value ); |
|
| 2799 | + $this->set_prop('discounts', $value); |
|
| 2800 | 2800 | } |
| 2801 | 2801 | |
| 2802 | 2802 | /** |
@@ -2805,18 +2805,18 @@ discard block |
||
| 2805 | 2805 | * @since 1.0.19 |
| 2806 | 2806 | * @param GetPaid_Form_Item[] $value items. |
| 2807 | 2807 | */ |
| 2808 | - public function set_items( $value ) { |
|
| 2808 | + public function set_items($value) { |
|
| 2809 | 2809 | |
| 2810 | 2810 | // Remove existing items. |
| 2811 | - $this->set_prop( 'items', array() ); |
|
| 2811 | + $this->set_prop('items', array()); |
|
| 2812 | 2812 | |
| 2813 | 2813 | // Ensure that we have an array. |
| 2814 | - if ( ! is_array( $value ) ) { |
|
| 2814 | + if (!is_array($value)) { |
|
| 2815 | 2815 | return; |
| 2816 | 2816 | } |
| 2817 | 2817 | |
| 2818 | - foreach ( $value as $item ) { |
|
| 2819 | - $this->add_item( $item ); |
|
| 2818 | + foreach ($value as $item) { |
|
| 2819 | + $this->add_item($item); |
|
| 2820 | 2820 | } |
| 2821 | 2821 | |
| 2822 | 2822 | } |
@@ -2827,8 +2827,8 @@ discard block |
||
| 2827 | 2827 | * @since 1.0.19 |
| 2828 | 2828 | * @param int $value payment form. |
| 2829 | 2829 | */ |
| 2830 | - public function set_payment_form( $value ) { |
|
| 2831 | - $this->set_prop( 'payment_form', $value ); |
|
| 2830 | + public function set_payment_form($value) { |
|
| 2831 | + $this->set_prop('payment_form', $value); |
|
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | 2834 | /** |
@@ -2837,8 +2837,8 @@ discard block |
||
| 2837 | 2837 | * @since 1.0.19 |
| 2838 | 2838 | * @param string $value submission id. |
| 2839 | 2839 | */ |
| 2840 | - public function set_submission_id( $value ) { |
|
| 2841 | - $this->set_prop( 'submission_id', $value ); |
|
| 2840 | + public function set_submission_id($value) { |
|
| 2841 | + $this->set_prop('submission_id', $value); |
|
| 2842 | 2842 | } |
| 2843 | 2843 | |
| 2844 | 2844 | /** |
@@ -2847,8 +2847,8 @@ discard block |
||
| 2847 | 2847 | * @since 1.0.19 |
| 2848 | 2848 | * @param string $value discount code. |
| 2849 | 2849 | */ |
| 2850 | - public function set_discount_code( $value ) { |
|
| 2851 | - $this->set_prop( 'discount_code', $value ); |
|
| 2850 | + public function set_discount_code($value) { |
|
| 2851 | + $this->set_prop('discount_code', $value); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | /** |
@@ -2857,8 +2857,8 @@ discard block |
||
| 2857 | 2857 | * @since 1.0.19 |
| 2858 | 2858 | * @param string $value gateway. |
| 2859 | 2859 | */ |
| 2860 | - public function set_gateway( $value ) { |
|
| 2861 | - $this->set_prop( 'gateway', $value ); |
|
| 2860 | + public function set_gateway($value) { |
|
| 2861 | + $this->set_prop('gateway', $value); |
|
| 2862 | 2862 | } |
| 2863 | 2863 | |
| 2864 | 2864 | /** |
@@ -2867,9 +2867,9 @@ discard block |
||
| 2867 | 2867 | * @since 1.0.19 |
| 2868 | 2868 | * @param string $value transaction id. |
| 2869 | 2869 | */ |
| 2870 | - public function set_transaction_id( $value ) { |
|
| 2871 | - if ( ! empty( $value ) ) { |
|
| 2872 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2870 | + public function set_transaction_id($value) { |
|
| 2871 | + if (!empty($value)) { |
|
| 2872 | + $this->set_prop('transaction_id', $value); |
|
| 2873 | 2873 | } |
| 2874 | 2874 | } |
| 2875 | 2875 | |
@@ -2879,8 +2879,8 @@ discard block |
||
| 2879 | 2879 | * @since 1.0.19 |
| 2880 | 2880 | * @param string $value currency id. |
| 2881 | 2881 | */ |
| 2882 | - public function set_currency( $value ) { |
|
| 2883 | - $this->set_prop( 'currency', $value ); |
|
| 2882 | + public function set_currency($value) { |
|
| 2883 | + $this->set_prop('currency', $value); |
|
| 2884 | 2884 | } |
| 2885 | 2885 | |
| 2886 | 2886 | /** |
@@ -2889,8 +2889,8 @@ discard block |
||
| 2889 | 2889 | * @since 1.0.19 |
| 2890 | 2890 | * @param bool $value value. |
| 2891 | 2891 | */ |
| 2892 | - public function set_disable_taxes( $value ) { |
|
| 2893 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2892 | + public function set_disable_taxes($value) { |
|
| 2893 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 2894 | 2894 | } |
| 2895 | 2895 | |
| 2896 | 2896 | /** |
@@ -2899,8 +2899,8 @@ discard block |
||
| 2899 | 2899 | * @since 1.0.19 |
| 2900 | 2900 | * @param string $value subscription id. |
| 2901 | 2901 | */ |
| 2902 | - public function set_subscription_id( $value ) { |
|
| 2903 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2902 | + public function set_subscription_id($value) { |
|
| 2903 | + $this->set_prop('subscription_id', $value); |
|
| 2904 | 2904 | } |
| 2905 | 2905 | |
| 2906 | 2906 | /** |
@@ -2909,8 +2909,8 @@ discard block |
||
| 2909 | 2909 | * @since 1.0.19 |
| 2910 | 2910 | * @param string $value subscription id. |
| 2911 | 2911 | */ |
| 2912 | - public function set_remote_subscription_id( $value ) { |
|
| 2913 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2912 | + public function set_remote_subscription_id($value) { |
|
| 2913 | + $this->set_prop('remote_subscription_id', $value); |
|
| 2914 | 2914 | } |
| 2915 | 2915 | |
| 2916 | 2916 | /* |
@@ -2927,28 +2927,28 @@ discard block |
||
| 2927 | 2927 | */ |
| 2928 | 2928 | public function is_parent() { |
| 2929 | 2929 | $parent = $this->get_parent_id(); |
| 2930 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 2930 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 2931 | 2931 | } |
| 2932 | 2932 | |
| 2933 | 2933 | /** |
| 2934 | 2934 | * Checks if this is a renewal invoice. |
| 2935 | 2935 | */ |
| 2936 | 2936 | public function is_renewal() { |
| 2937 | - return ! $this->is_parent(); |
|
| 2937 | + return !$this->is_parent(); |
|
| 2938 | 2938 | } |
| 2939 | 2939 | |
| 2940 | 2940 | /** |
| 2941 | 2941 | * Checks if this is a recurring invoice. |
| 2942 | 2942 | */ |
| 2943 | 2943 | public function is_recurring() { |
| 2944 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
| 2944 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
| 2945 | 2945 | } |
| 2946 | 2946 | |
| 2947 | 2947 | /** |
| 2948 | 2948 | * Checks if this is a taxable invoice. |
| 2949 | 2949 | */ |
| 2950 | 2950 | public function is_taxable() { |
| 2951 | - return ! $this->get_disable_taxes(); |
|
| 2951 | + return !$this->get_disable_taxes(); |
|
| 2952 | 2952 | } |
| 2953 | 2953 | |
| 2954 | 2954 | /** |
@@ -2959,57 +2959,57 @@ discard block |
||
| 2959 | 2959 | |
| 2960 | 2960 | $requires_vat = false; |
| 2961 | 2961 | |
| 2962 | - if ( $this->country ) { |
|
| 2962 | + if ($this->country) { |
|
| 2963 | 2963 | $wpi_country = $this->country; |
| 2964 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
| 2964 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
| 2965 | 2965 | } |
| 2966 | 2966 | |
| 2967 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
| 2967 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
| 2968 | 2968 | } |
| 2969 | 2969 | |
| 2970 | 2970 | /** |
| 2971 | 2971 | * Checks to see if the invoice requires payment. |
| 2972 | 2972 | */ |
| 2973 | 2973 | public function is_free() { |
| 2974 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
| 2974 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
| 2975 | 2975 | |
| 2976 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2976 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
| 2977 | 2977 | $is_free = false; |
| 2978 | 2978 | } |
| 2979 | 2979 | |
| 2980 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 2980 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 2981 | 2981 | } |
| 2982 | 2982 | |
| 2983 | 2983 | /** |
| 2984 | 2984 | * Checks if the invoice is paid. |
| 2985 | 2985 | */ |
| 2986 | 2986 | public function is_paid() { |
| 2987 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 2988 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 2987 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 2988 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 2989 | 2989 | } |
| 2990 | 2990 | |
| 2991 | 2991 | /** |
| 2992 | 2992 | * Checks if the invoice needs payment. |
| 2993 | 2993 | */ |
| 2994 | 2994 | public function needs_payment() { |
| 2995 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2996 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 2995 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
| 2996 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 2997 | 2997 | } |
| 2998 | 2998 | |
| 2999 | 2999 | /** |
| 3000 | 3000 | * Checks if the invoice is refunded. |
| 3001 | 3001 | */ |
| 3002 | 3002 | public function is_refunded() { |
| 3003 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 3004 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 3003 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 3004 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 3005 | 3005 | } |
| 3006 | 3006 | |
| 3007 | 3007 | /** |
| 3008 | 3008 | * Checks if the invoice is held. |
| 3009 | 3009 | */ |
| 3010 | 3010 | public function is_held() { |
| 3011 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
| 3012 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
| 3011 | + $is_held = $this->has_status('wpi-onhold'); |
|
| 3012 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
| 3013 | 3013 | } |
| 3014 | 3014 | |
| 3015 | 3015 | /** |
@@ -3017,30 +3017,30 @@ discard block |
||
| 3017 | 3017 | */ |
| 3018 | 3018 | public function is_due() { |
| 3019 | 3019 | $due_date = $this->get_due_date(); |
| 3020 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3020 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
| 3021 | 3021 | } |
| 3022 | 3022 | |
| 3023 | 3023 | /** |
| 3024 | 3024 | * Checks if the invoice is draft. |
| 3025 | 3025 | */ |
| 3026 | 3026 | public function is_draft() { |
| 3027 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 3027 | + return $this->has_status('draft, auto-draft'); |
|
| 3028 | 3028 | } |
| 3029 | 3029 | |
| 3030 | 3030 | /** |
| 3031 | 3031 | * Checks if the invoice has a given status. |
| 3032 | 3032 | */ |
| 3033 | - public function has_status( $status ) { |
|
| 3034 | - $status = wpinv_parse_list( $status ); |
|
| 3035 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 3033 | + public function has_status($status) { |
|
| 3034 | + $status = wpinv_parse_list($status); |
|
| 3035 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 3036 | 3036 | } |
| 3037 | 3037 | |
| 3038 | 3038 | /** |
| 3039 | 3039 | * Checks if the invoice is of a given type. |
| 3040 | 3040 | */ |
| 3041 | - public function is_type( $type ) { |
|
| 3042 | - $type = wpinv_parse_list( $type ); |
|
| 3043 | - return in_array( $this->get_type(), $type ); |
|
| 3041 | + public function is_type($type) { |
|
| 3042 | + $type = wpinv_parse_list($type); |
|
| 3043 | + return in_array($this->get_type(), $type); |
|
| 3044 | 3044 | } |
| 3045 | 3045 | |
| 3046 | 3046 | /** |
@@ -3072,8 +3072,8 @@ discard block |
||
| 3072 | 3072 | * |
| 3073 | 3073 | */ |
| 3074 | 3074 | public function is_initial_free() { |
| 3075 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 3076 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 3075 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 3076 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 3077 | 3077 | } |
| 3078 | 3078 | |
| 3079 | 3079 | /** |
@@ -3083,11 +3083,11 @@ discard block |
||
| 3083 | 3083 | public function item_has_free_trial() { |
| 3084 | 3084 | |
| 3085 | 3085 | // Ensure we have a recurring item. |
| 3086 | - if ( ! $this->is_recurring() ) { |
|
| 3086 | + if (!$this->is_recurring()) { |
|
| 3087 | 3087 | return false; |
| 3088 | 3088 | } |
| 3089 | 3089 | |
| 3090 | - $item = $this->get_recurring( true ); |
|
| 3090 | + $item = $this->get_recurring(true); |
|
| 3091 | 3091 | return $item->has_free_trial(); |
| 3092 | 3092 | } |
| 3093 | 3093 | |
@@ -3095,7 +3095,7 @@ discard block |
||
| 3095 | 3095 | * Check if the free trial is a result of a discount. |
| 3096 | 3096 | */ |
| 3097 | 3097 | public function is_free_trial_from_discount() { |
| 3098 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3098 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 3099 | 3099 | } |
| 3100 | 3100 | |
| 3101 | 3101 | /** |
@@ -3104,17 +3104,17 @@ discard block |
||
| 3104 | 3104 | public function discount_first_payment_only() { |
| 3105 | 3105 | |
| 3106 | 3106 | $discount_code = $this->get_discount_code(); |
| 3107 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
| 3107 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
| 3108 | 3108 | return true; |
| 3109 | 3109 | } |
| 3110 | 3110 | |
| 3111 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3111 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3112 | 3112 | |
| 3113 | - if ( ! $discount || ! $discount->exists() ) { |
|
| 3113 | + if (!$discount || !$discount->exists()) { |
|
| 3114 | 3114 | return true; |
| 3115 | 3115 | } |
| 3116 | 3116 | |
| 3117 | - return ! $discount->get_is_recurring(); |
|
| 3117 | + return !$discount->get_is_recurring(); |
|
| 3118 | 3118 | } |
| 3119 | 3119 | |
| 3120 | 3120 | /* |
@@ -3132,27 +3132,27 @@ discard block |
||
| 3132 | 3132 | * @param GetPaid_Form_Item|array $item |
| 3133 | 3133 | * @return WP_Error|Bool |
| 3134 | 3134 | */ |
| 3135 | - public function add_item( $item ) { |
|
| 3135 | + public function add_item($item) { |
|
| 3136 | 3136 | |
| 3137 | - if ( is_array( $item ) ) { |
|
| 3138 | - $item = $this->process_array_item( $item ); |
|
| 3137 | + if (is_array($item)) { |
|
| 3138 | + $item = $this->process_array_item($item); |
|
| 3139 | 3139 | } |
| 3140 | 3140 | |
| 3141 | - if ( is_numeric( $item ) ) { |
|
| 3142 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3141 | + if (is_numeric($item)) { |
|
| 3142 | + $item = new GetPaid_Form_Item($item); |
|
| 3143 | 3143 | } |
| 3144 | 3144 | |
| 3145 | 3145 | // Make sure that it is available for purchase. |
| 3146 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3147 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3146 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 3147 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3148 | 3148 | } |
| 3149 | 3149 | |
| 3150 | 3150 | // Do we have a recurring item? |
| 3151 | - if ( $item->is_recurring() ) { |
|
| 3151 | + if ($item->is_recurring()) { |
|
| 3152 | 3152 | |
| 3153 | 3153 | // An invoice can only contain one recurring item. |
| 3154 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3155 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3154 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
| 3155 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
| 3156 | 3156 | } |
| 3157 | 3157 | |
| 3158 | 3158 | $this->recurring_item = $item->get_id(); |
@@ -3163,9 +3163,9 @@ discard block |
||
| 3163 | 3163 | |
| 3164 | 3164 | // Retrieve all items. |
| 3165 | 3165 | $items = $this->get_items(); |
| 3166 | - $items[ (int) $item->get_id() ] = $item; |
|
| 3166 | + $items[(int) $item->get_id()] = $item; |
|
| 3167 | 3167 | |
| 3168 | - $this->set_prop( 'items', $items ); |
|
| 3168 | + $this->set_prop('items', $items); |
|
| 3169 | 3169 | return true; |
| 3170 | 3170 | } |
| 3171 | 3171 | |
@@ -3175,26 +3175,26 @@ discard block |
||
| 3175 | 3175 | * @since 1.0.19 |
| 3176 | 3176 | * @return GetPaid_Form_Item |
| 3177 | 3177 | */ |
| 3178 | - protected function process_array_item( $array ) { |
|
| 3178 | + protected function process_array_item($array) { |
|
| 3179 | 3179 | |
| 3180 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3181 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3180 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
| 3181 | + $item = new GetPaid_Form_Item($item_id); |
|
| 3182 | 3182 | |
| 3183 | 3183 | // Set item data. |
| 3184 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3185 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3184 | + foreach (array('name', 'price', 'description') as $key) { |
|
| 3185 | + if (isset($array["item_$key"])) { |
|
| 3186 | 3186 | $method = "set_$key"; |
| 3187 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3187 | + $item->$method($array["item_$key"]); |
|
| 3188 | 3188 | } |
| 3189 | 3189 | } |
| 3190 | 3190 | |
| 3191 | - if ( isset( $array['quantity'] ) ) { |
|
| 3192 | - $item->set_quantity( $array['quantity'] ); |
|
| 3191 | + if (isset($array['quantity'])) { |
|
| 3192 | + $item->set_quantity($array['quantity']); |
|
| 3193 | 3193 | } |
| 3194 | 3194 | |
| 3195 | 3195 | // Set item meta. |
| 3196 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3197 | - $item->set_item_meta( $array['meta'] ); |
|
| 3196 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
| 3197 | + $item->set_item_meta($array['meta']); |
|
| 3198 | 3198 | } |
| 3199 | 3199 | |
| 3200 | 3200 | return $item; |
@@ -3206,10 +3206,10 @@ discard block |
||
| 3206 | 3206 | * |
| 3207 | 3207 | * @since 1.0.19 |
| 3208 | 3208 | */ |
| 3209 | - public function get_item( $item_id ) { |
|
| 3209 | + public function get_item($item_id) { |
|
| 3210 | 3210 | $items = $this->get_items(); |
| 3211 | 3211 | $item_id = (int) $item_id; |
| 3212 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3212 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
| 3213 | 3213 | } |
| 3214 | 3214 | |
| 3215 | 3215 | /** |
@@ -3217,17 +3217,17 @@ discard block |
||
| 3217 | 3217 | * |
| 3218 | 3218 | * @since 1.0.19 |
| 3219 | 3219 | */ |
| 3220 | - public function remove_item( $item_id ) { |
|
| 3220 | + public function remove_item($item_id) { |
|
| 3221 | 3221 | $items = $this->get_items(); |
| 3222 | 3222 | $item_id = (int) $item_id; |
| 3223 | 3223 | |
| 3224 | - if ( $item_id == $this->recurring_item ) { |
|
| 3224 | + if ($item_id == $this->recurring_item) { |
|
| 3225 | 3225 | $this->recurring_item = null; |
| 3226 | 3226 | } |
| 3227 | 3227 | |
| 3228 | - if ( isset( $items[ $item_id ] ) ) { |
|
| 3229 | - unset( $items[ $item_id ] ); |
|
| 3230 | - $this->set_prop( 'items', $items ); |
|
| 3228 | + if (isset($items[$item_id])) { |
|
| 3229 | + unset($items[$item_id]); |
|
| 3230 | + $this->set_prop('items', $items); |
|
| 3231 | 3231 | } |
| 3232 | 3232 | } |
| 3233 | 3233 | |
@@ -3237,11 +3237,11 @@ discard block |
||
| 3237 | 3237 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
| 3238 | 3238 | * @since 1.0.19 |
| 3239 | 3239 | */ |
| 3240 | - public function add_fee( $fee ) { |
|
| 3240 | + public function add_fee($fee) { |
|
| 3241 | 3241 | |
| 3242 | 3242 | $fees = $this->get_fees(); |
| 3243 | - $fees[ $fee['name'] ] = $fee; |
|
| 3244 | - $this->set_prop( 'fees', $fees ); |
|
| 3243 | + $fees[$fee['name']] = $fee; |
|
| 3244 | + $this->set_prop('fees', $fees); |
|
| 3245 | 3245 | |
| 3246 | 3246 | } |
| 3247 | 3247 | |
@@ -3250,9 +3250,9 @@ discard block |
||
| 3250 | 3250 | * |
| 3251 | 3251 | * @since 1.0.19 |
| 3252 | 3252 | */ |
| 3253 | - public function get_fee( $fee ) { |
|
| 3253 | + public function get_fee($fee) { |
|
| 3254 | 3254 | $fees = $this->get_fees(); |
| 3255 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3255 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3256 | 3256 | } |
| 3257 | 3257 | |
| 3258 | 3258 | /** |
@@ -3260,11 +3260,11 @@ discard block |
||
| 3260 | 3260 | * |
| 3261 | 3261 | * @since 1.0.19 |
| 3262 | 3262 | */ |
| 3263 | - public function remove_fee( $fee ) { |
|
| 3263 | + public function remove_fee($fee) { |
|
| 3264 | 3264 | $fees = $this->get_fees(); |
| 3265 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3266 | - unset( $fees[ $fee ] ); |
|
| 3267 | - $this->set_prop( 'fees', $fees ); |
|
| 3265 | + if (isset($fees[$fee])) { |
|
| 3266 | + unset($fees[$fee]); |
|
| 3267 | + $this->set_prop('fees', $fees); |
|
| 3268 | 3268 | } |
| 3269 | 3269 | } |
| 3270 | 3270 | |
@@ -3274,11 +3274,11 @@ discard block |
||
| 3274 | 3274 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
| 3275 | 3275 | * @since 1.0.19 |
| 3276 | 3276 | */ |
| 3277 | - public function add_discount( $discount ) { |
|
| 3277 | + public function add_discount($discount) { |
|
| 3278 | 3278 | |
| 3279 | 3279 | $discounts = $this->get_discounts(); |
| 3280 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3281 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3280 | + $discounts[$discount['name']] = $discount; |
|
| 3281 | + $this->set_prop('discounts', $discounts); |
|
| 3282 | 3282 | |
| 3283 | 3283 | } |
| 3284 | 3284 | |
@@ -3288,15 +3288,15 @@ discard block |
||
| 3288 | 3288 | * @since 1.0.19 |
| 3289 | 3289 | * @return float |
| 3290 | 3290 | */ |
| 3291 | - public function get_discount( $discount = false ) { |
|
| 3291 | + public function get_discount($discount = false) { |
|
| 3292 | 3292 | |
| 3293 | 3293 | // Backwards compatibilty. |
| 3294 | - if ( empty( $discount ) ) { |
|
| 3294 | + if (empty($discount)) { |
|
| 3295 | 3295 | return $this->get_total_discount(); |
| 3296 | 3296 | } |
| 3297 | 3297 | |
| 3298 | 3298 | $discounts = $this->get_discounts(); |
| 3299 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3299 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3300 | 3300 | } |
| 3301 | 3301 | |
| 3302 | 3302 | /** |
@@ -3304,11 +3304,11 @@ discard block |
||
| 3304 | 3304 | * |
| 3305 | 3305 | * @since 1.0.19 |
| 3306 | 3306 | */ |
| 3307 | - public function remove_discount( $discount ) { |
|
| 3307 | + public function remove_discount($discount) { |
|
| 3308 | 3308 | $discounts = $this->get_discounts(); |
| 3309 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3310 | - unset( $discounts[ $discount ] ); |
|
| 3311 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3309 | + if (isset($discounts[$discount])) { |
|
| 3310 | + unset($discounts[$discount]); |
|
| 3311 | + $this->set_prop('discounts', $discounts); |
|
| 3312 | 3312 | } |
| 3313 | 3313 | } |
| 3314 | 3314 | |
@@ -3317,12 +3317,12 @@ discard block |
||
| 3317 | 3317 | * |
| 3318 | 3318 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
| 3319 | 3319 | */ |
| 3320 | - public function add_tax( $tax ) { |
|
| 3321 | - if ( $this->is_taxable() ) { |
|
| 3320 | + public function add_tax($tax) { |
|
| 3321 | + if ($this->is_taxable()) { |
|
| 3322 | 3322 | |
| 3323 | - $taxes = $this->get_taxes(); |
|
| 3324 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3325 | - $this->set_prop( 'taxes', $tax ); |
|
| 3323 | + $taxes = $this->get_taxes(); |
|
| 3324 | + $taxes[$tax['name']] = $tax; |
|
| 3325 | + $this->set_prop('taxes', $tax); |
|
| 3326 | 3326 | |
| 3327 | 3327 | } |
| 3328 | 3328 | } |
@@ -3332,15 +3332,15 @@ discard block |
||
| 3332 | 3332 | * |
| 3333 | 3333 | * @since 1.0.19 |
| 3334 | 3334 | */ |
| 3335 | - public function get_tax( $tax = null ) { |
|
| 3335 | + public function get_tax($tax = null) { |
|
| 3336 | 3336 | |
| 3337 | 3337 | // Backwards compatility. |
| 3338 | - if ( empty( $tax ) ) { |
|
| 3338 | + if (empty($tax)) { |
|
| 3339 | 3339 | return $this->get_total_tax(); |
| 3340 | 3340 | } |
| 3341 | 3341 | |
| 3342 | 3342 | $taxes = $this->get_taxes(); |
| 3343 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3343 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3344 | 3344 | } |
| 3345 | 3345 | |
| 3346 | 3346 | /** |
@@ -3348,11 +3348,11 @@ discard block |
||
| 3348 | 3348 | * |
| 3349 | 3349 | * @since 1.0.19 |
| 3350 | 3350 | */ |
| 3351 | - public function remove_tax( $tax ) { |
|
| 3351 | + public function remove_tax($tax) { |
|
| 3352 | 3352 | $taxes = $this->get_taxes(); |
| 3353 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3354 | - unset( $taxes[ $tax ] ); |
|
| 3355 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3353 | + if (isset($taxes[$tax])) { |
|
| 3354 | + unset($taxes[$tax]); |
|
| 3355 | + $this->set_prop('taxes', $taxes); |
|
| 3356 | 3356 | } |
| 3357 | 3357 | } |
| 3358 | 3358 | |
@@ -3363,17 +3363,17 @@ discard block |
||
| 3363 | 3363 | * @return float The recalculated subtotal |
| 3364 | 3364 | */ |
| 3365 | 3365 | public function recalculate_subtotal() { |
| 3366 | - $items = $this->get_items(); |
|
| 3366 | + $items = $this->get_items(); |
|
| 3367 | 3367 | $subtotal = 0; |
| 3368 | 3368 | $recurring = 0; |
| 3369 | 3369 | |
| 3370 | - foreach ( $items as $item ) { |
|
| 3370 | + foreach ($items as $item) { |
|
| 3371 | 3371 | $subtotal += $item->get_sub_total(); |
| 3372 | 3372 | $recurring += $item->get_recurring_sub_total(); |
| 3373 | 3373 | } |
| 3374 | 3374 | |
| 3375 | 3375 | $current = $this->is_renewal() ? $recurring : $subtotal; |
| 3376 | - $this->set_subtotal( $current ); |
|
| 3376 | + $this->set_subtotal($current); |
|
| 3377 | 3377 | |
| 3378 | 3378 | $this->totals['subtotal'] = array( |
| 3379 | 3379 | 'initial' => $subtotal, |
@@ -3394,14 +3394,14 @@ discard block |
||
| 3394 | 3394 | $discount = 0; |
| 3395 | 3395 | $recurring = 0; |
| 3396 | 3396 | |
| 3397 | - foreach ( $discounts as $data ) { |
|
| 3398 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3399 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3397 | + foreach ($discounts as $data) { |
|
| 3398 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
| 3399 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
| 3400 | 3400 | } |
| 3401 | 3401 | |
| 3402 | 3402 | $current = $this->is_renewal() ? $recurring : $discount; |
| 3403 | 3403 | |
| 3404 | - $this->set_total_discount( $current ); |
|
| 3404 | + $this->set_total_discount($current); |
|
| 3405 | 3405 | |
| 3406 | 3406 | $this->totals['discount'] = array( |
| 3407 | 3407 | 'initial' => $discount, |
@@ -3419,17 +3419,17 @@ discard block |
||
| 3419 | 3419 | * @return float The recalculated tax |
| 3420 | 3420 | */ |
| 3421 | 3421 | public function recalculate_total_tax() { |
| 3422 | - $taxes = $this->get_taxes(); |
|
| 3422 | + $taxes = $this->get_taxes(); |
|
| 3423 | 3423 | $tax = 0; |
| 3424 | 3424 | $recurring = 0; |
| 3425 | 3425 | |
| 3426 | - foreach ( $taxes as $data ) { |
|
| 3427 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3428 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3426 | + foreach ($taxes as $data) { |
|
| 3427 | + $tax += wpinv_sanitize_amount($data['initial_tax']); |
|
| 3428 | + $recurring += wpinv_sanitize_amount($data['recurring_tax']); |
|
| 3429 | 3429 | } |
| 3430 | 3430 | |
| 3431 | 3431 | $current = $this->is_renewal() ? $recurring : $tax; |
| 3432 | - $this->set_total_tax( $current ); |
|
| 3432 | + $this->set_total_tax($current); |
|
| 3433 | 3433 | |
| 3434 | 3434 | $this->totals['tax'] = array( |
| 3435 | 3435 | 'initial' => $tax, |
@@ -3451,20 +3451,20 @@ discard block |
||
| 3451 | 3451 | $fee = 0; |
| 3452 | 3452 | $recurring = 0; |
| 3453 | 3453 | |
| 3454 | - foreach ( $fees as $data ) { |
|
| 3455 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3456 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3454 | + foreach ($fees as $data) { |
|
| 3455 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
| 3456 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
| 3457 | 3457 | } |
| 3458 | 3458 | |
| 3459 | 3459 | $current = $this->is_renewal() ? $recurring : $fee; |
| 3460 | - $this->set_total_fees( $current ); |
|
| 3460 | + $this->set_total_fees($current); |
|
| 3461 | 3461 | |
| 3462 | 3462 | $this->totals['fee'] = array( |
| 3463 | 3463 | 'initial' => $fee, |
| 3464 | 3464 | 'recurring' => $recurring, |
| 3465 | 3465 | ); |
| 3466 | 3466 | |
| 3467 | - $this->set_total_fees( $fee ); |
|
| 3467 | + $this->set_total_fees($fee); |
|
| 3468 | 3468 | return $current; |
| 3469 | 3469 | } |
| 3470 | 3470 | |
@@ -3485,9 +3485,9 @@ discard block |
||
| 3485 | 3485 | /** |
| 3486 | 3486 | * @deprecated |
| 3487 | 3487 | */ |
| 3488 | - public function recalculate_totals( $temp = false ) { |
|
| 3489 | - $this->update_items( $temp ); |
|
| 3490 | - $this->save( true ); |
|
| 3488 | + public function recalculate_totals($temp = false) { |
|
| 3489 | + $this->update_items($temp); |
|
| 3490 | + $this->save(true); |
|
| 3491 | 3491 | return $this; |
| 3492 | 3492 | } |
| 3493 | 3493 | |
@@ -3505,10 +3505,10 @@ discard block |
||
| 3505 | 3505 | * @return int|false The new note's ID on success, false on failure. |
| 3506 | 3506 | * |
| 3507 | 3507 | */ |
| 3508 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3508 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3509 | 3509 | |
| 3510 | 3510 | // Bail if no note specified or this invoice is not yet saved. |
| 3511 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
| 3511 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
| 3512 | 3512 | return false; |
| 3513 | 3513 | } |
| 3514 | 3514 | |
@@ -3516,23 +3516,23 @@ discard block |
||
| 3516 | 3516 | $author_email = '[email protected]'; |
| 3517 | 3517 | |
| 3518 | 3518 | // If this is an admin comment or it has been added by the user. |
| 3519 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3520 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3519 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
| 3520 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3521 | 3521 | $author = $user->display_name; |
| 3522 | 3522 | $author_email = $user->user_email; |
| 3523 | 3523 | } |
| 3524 | 3524 | |
| 3525 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3525 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
| 3526 | 3526 | |
| 3527 | 3527 | } |
| 3528 | 3528 | |
| 3529 | 3529 | /** |
| 3530 | 3530 | * Generates a unique key for the invoice. |
| 3531 | 3531 | */ |
| 3532 | - public function generate_key( $string = '' ) { |
|
| 3533 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3532 | + public function generate_key($string = '') { |
|
| 3533 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3534 | 3534 | return strtolower( |
| 3535 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3535 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3536 | 3536 | ); |
| 3537 | 3537 | } |
| 3538 | 3538 | |
@@ -3542,11 +3542,11 @@ discard block |
||
| 3542 | 3542 | public function generate_number() { |
| 3543 | 3543 | $number = $this->get_id(); |
| 3544 | 3544 | |
| 3545 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
| 3546 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
| 3545 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
| 3546 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
| 3547 | 3547 | } |
| 3548 | 3548 | |
| 3549 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3549 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
| 3550 | 3550 | |
| 3551 | 3551 | } |
| 3552 | 3552 | |
@@ -3559,55 +3559,55 @@ discard block |
||
| 3559 | 3559 | // Reset status transition variable. |
| 3560 | 3560 | $this->status_transition = false; |
| 3561 | 3561 | |
| 3562 | - if ( $status_transition ) { |
|
| 3562 | + if ($status_transition) { |
|
| 3563 | 3563 | try { |
| 3564 | 3564 | |
| 3565 | 3565 | // Fire a hook for the status change. |
| 3566 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3566 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
| 3567 | 3567 | |
| 3568 | 3568 | // @deprecated this is deprecated and will be removed in the future. |
| 3569 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3569 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3570 | 3570 | |
| 3571 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3571 | + if (!empty($status_transition['from'])) { |
|
| 3572 | 3572 | |
| 3573 | 3573 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3574 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3574 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
| 3575 | 3575 | |
| 3576 | 3576 | // Fire another hook. |
| 3577 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3578 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3577 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
| 3578 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
| 3579 | 3579 | |
| 3580 | 3580 | // @deprecated this is deprecated and will be removed in the future. |
| 3581 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3581 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3582 | 3582 | |
| 3583 | 3583 | // Note the transition occurred. |
| 3584 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3584 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3585 | 3585 | |
| 3586 | 3586 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3587 | 3587 | if ( |
| 3588 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3589 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3588 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3589 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3590 | 3590 | ) { |
| 3591 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3591 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
| 3592 | 3592 | } |
| 3593 | 3593 | |
| 3594 | 3594 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
| 3595 | 3595 | if ( |
| 3596 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3597 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3596 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3597 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3598 | 3598 | ) { |
| 3599 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3599 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
| 3600 | 3600 | } |
| 3601 | 3601 | } else { |
| 3602 | 3602 | /* translators: %s: new invoice status */ |
| 3603 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
| 3603 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
| 3604 | 3604 | |
| 3605 | 3605 | // Note the transition occurred. |
| 3606 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3606 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3607 | 3607 | |
| 3608 | 3608 | } |
| 3609 | - } catch ( Exception $e ) { |
|
| 3610 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3609 | + } catch (Exception $e) { |
|
| 3610 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3611 | 3611 | } |
| 3612 | 3612 | } |
| 3613 | 3613 | } |
@@ -3615,13 +3615,13 @@ discard block |
||
| 3615 | 3615 | /** |
| 3616 | 3616 | * Updates an invoice status. |
| 3617 | 3617 | */ |
| 3618 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3618 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3619 | 3619 | |
| 3620 | 3620 | // Fires before updating a status. |
| 3621 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3621 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3622 | 3622 | |
| 3623 | 3623 | // Update the status. |
| 3624 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3624 | + $this->set_status($new_status, $note, $manual); |
|
| 3625 | 3625 | |
| 3626 | 3626 | // Save the order. |
| 3627 | 3627 | return $this->save(); |
@@ -3632,18 +3632,18 @@ discard block |
||
| 3632 | 3632 | * @deprecated |
| 3633 | 3633 | */ |
| 3634 | 3634 | public function refresh_item_ids() { |
| 3635 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
| 3636 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3635 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
| 3636 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3637 | 3637 | } |
| 3638 | 3638 | |
| 3639 | 3639 | /** |
| 3640 | 3640 | * @deprecated |
| 3641 | 3641 | */ |
| 3642 | - public function update_items( $temp = false ) { |
|
| 3642 | + public function update_items($temp = false) { |
|
| 3643 | 3643 | |
| 3644 | - $this->set_items( $this->get_items() ); |
|
| 3644 | + $this->set_items($this->get_items()); |
|
| 3645 | 3645 | |
| 3646 | - if ( ! $temp ) { |
|
| 3646 | + if (!$temp) { |
|
| 3647 | 3647 | $this->save(); |
| 3648 | 3648 | } |
| 3649 | 3649 | |
@@ -3657,11 +3657,11 @@ discard block |
||
| 3657 | 3657 | |
| 3658 | 3658 | $discount_code = $this->get_discount_code(); |
| 3659 | 3659 | |
| 3660 | - if ( empty( $discount_code ) ) { |
|
| 3660 | + if (empty($discount_code)) { |
|
| 3661 | 3661 | return false; |
| 3662 | 3662 | } |
| 3663 | 3663 | |
| 3664 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3664 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3665 | 3665 | |
| 3666 | 3666 | // Ensure it is active. |
| 3667 | 3667 | return $discount->exists(); |
@@ -3672,7 +3672,7 @@ discard block |
||
| 3672 | 3672 | * Refunds an invoice. |
| 3673 | 3673 | */ |
| 3674 | 3674 | public function refund() { |
| 3675 | - $this->set_status( 'wpi-refunded' ); |
|
| 3675 | + $this->set_status('wpi-refunded'); |
|
| 3676 | 3676 | $this->save(); |
| 3677 | 3677 | } |
| 3678 | 3678 | |
@@ -3681,56 +3681,56 @@ discard block |
||
| 3681 | 3681 | * |
| 3682 | 3682 | * @param string $transaction_id |
| 3683 | 3683 | */ |
| 3684 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
| 3684 | + public function mark_paid($transaction_id = null, $note = '') { |
|
| 3685 | 3685 | |
| 3686 | 3686 | // Set the transaction id. |
| 3687 | - if ( empty( $transaction_id ) ) { |
|
| 3687 | + if (empty($transaction_id)) { |
|
| 3688 | 3688 | $transaction_id = $this->generate_key('trans_'); |
| 3689 | 3689 | } |
| 3690 | 3690 | |
| 3691 | - if ( ! $this->get_transaction_id() ) { |
|
| 3692 | - $this->set_transaction_id( $transaction_id ); |
|
| 3691 | + if (!$this->get_transaction_id()) { |
|
| 3692 | + $this->set_transaction_id($transaction_id); |
|
| 3693 | 3693 | } |
| 3694 | 3694 | |
| 3695 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3695 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
| 3696 | 3696 | return $this->save(); |
| 3697 | 3697 | } |
| 3698 | 3698 | |
| 3699 | 3699 | // Set the completed date. |
| 3700 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3700 | + $this->set_date_completed(current_time('mysql')); |
|
| 3701 | 3701 | |
| 3702 | 3702 | // Set the new status. |
| 3703 | - if ( $this->is_renewal() ) { |
|
| 3703 | + if ($this->is_renewal()) { |
|
| 3704 | 3704 | |
| 3705 | 3705 | $_note = sprintf( |
| 3706 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3707 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3706 | + __('Renewed via %s', 'invoicing'), |
|
| 3707 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3708 | 3708 | ); |
| 3709 | 3709 | |
| 3710 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3710 | + if ('none' == $this->get_gateway()) { |
|
| 3711 | 3711 | $_note = $note; |
| 3712 | 3712 | } |
| 3713 | 3713 | |
| 3714 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3714 | + $this->set_status('wpi-renewal', $_note); |
|
| 3715 | 3715 | |
| 3716 | 3716 | } else { |
| 3717 | 3717 | |
| 3718 | 3718 | $_note = sprintf( |
| 3719 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3720 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3719 | + __('Paid via %s', 'invoicing'), |
|
| 3720 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3721 | 3721 | ); |
| 3722 | 3722 | |
| 3723 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3723 | + if ('none' == $this->get_gateway()) { |
|
| 3724 | 3724 | $_note = $note; |
| 3725 | 3725 | } |
| 3726 | 3726 | |
| 3727 | - $this->set_status( 'publish',$_note ); |
|
| 3727 | + $this->set_status('publish', $_note); |
|
| 3728 | 3728 | |
| 3729 | 3729 | } |
| 3730 | 3730 | |
| 3731 | 3731 | // Set checkout mode. |
| 3732 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3733 | - $this->set_mode( $mode ); |
|
| 3732 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
| 3733 | + $this->set_mode($mode); |
|
| 3734 | 3734 | |
| 3735 | 3735 | // Save the invoice. |
| 3736 | 3736 | $this->save(); |
@@ -3756,9 +3756,9 @@ discard block |
||
| 3756 | 3756 | * Clears the subscription's cache. |
| 3757 | 3757 | */ |
| 3758 | 3758 | public function clear_cache() { |
| 3759 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3760 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3761 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3759 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
| 3760 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
| 3761 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
| 3762 | 3762 | } |
| 3763 | 3763 | |
| 3764 | 3764 | } |
@@ -44,15 +44,15 @@ |
||
| 44 | 44 | parent::__construct( $options ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The Super block output function. |
|
| 49 | - * |
|
| 50 | - * @param array $args |
|
| 51 | - * @param array $widget_args |
|
| 52 | - * @param string $content |
|
| 53 | - * |
|
| 54 | - * @return mixed|string|bool |
|
| 55 | - */ |
|
| 47 | + /** |
|
| 48 | + * The Super block output function. |
|
| 49 | + * |
|
| 50 | + * @param array $args |
|
| 51 | + * @param array $widget_args |
|
| 52 | + * @param string $content |
|
| 53 | + * |
|
| 54 | + * @return mixed|string|bool |
|
| 55 | + */ |
|
| 56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 57 | 57 | return getpaid_invoice_history(); |
| 58 | 58 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | 'block-keywords'=> "['invoicing','history']", |
| 23 | 23 | 'class_name' => __CLASS__, |
| 24 | 24 | 'base_id' => 'wpinv_history', |
| 25 | - 'name' => __('GetPaid > Invoice History','invoicing'), |
|
| 25 | + 'name' => __('GetPaid > Invoice History', 'invoicing'), |
|
| 26 | 26 | 'widget_ops' => array( |
| 27 | 27 | 'classname' => 'wpinv-history-class bsui', |
| 28 | - 'description' => esc_html__('Displays invoice history.','invoicing'), |
|
| 28 | + 'description' => esc_html__('Displays invoice history.', 'invoicing'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'arguments' => array( |
| 31 | 31 | 'title' => array( |
| 32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 32 | + 'title' => __('Widget title', 'invoicing'), |
|
| 33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 34 | 34 | 'type' => 'text', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - parent::__construct( $options ); |
|
| 44 | + parent::__construct($options); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return mixed|string|bool |
| 55 | 55 | */ |
| 56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 57 | 57 | return getpaid_invoice_history(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -44,15 +44,15 @@ |
||
| 44 | 44 | parent::__construct( $options ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The Super block output function. |
|
| 49 | - * |
|
| 50 | - * @param array $args |
|
| 51 | - * @param array $widget_args |
|
| 52 | - * @param string $content |
|
| 53 | - * |
|
| 54 | - * @return mixed|string|bool |
|
| 55 | - */ |
|
| 47 | + /** |
|
| 48 | + * The Super block output function. |
|
| 49 | + * |
|
| 50 | + * @param array $args |
|
| 51 | + * @param array $widget_args |
|
| 52 | + * @param string $content |
|
| 53 | + * |
|
| 54 | + * @return mixed|string|bool |
|
| 55 | + */ |
|
| 56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 57 | 57 | return wpinv_payment_receipt(); |
| 58 | 58 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | 'block-keywords'=> "['invoicing','receipt']", |
| 23 | 23 | 'class_name' => __CLASS__, |
| 24 | 24 | 'base_id' => 'wpinv_receipt', |
| 25 | - 'name' => __('GetPaid > Invoice Receipt','invoicing'), |
|
| 25 | + 'name' => __('GetPaid > Invoice Receipt', 'invoicing'), |
|
| 26 | 26 | 'widget_ops' => array( |
| 27 | 27 | 'classname' => 'wpinv-receipt-class bsui', |
| 28 | - 'description' => esc_html__('Displays invoice receipt after checkout.','invoicing'), |
|
| 28 | + 'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'arguments' => array( |
| 31 | 31 | 'title' => array( |
| 32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 32 | + 'title' => __('Widget title', 'invoicing'), |
|
| 33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 34 | 34 | 'type' => 'text', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - parent::__construct( $options ); |
|
| 44 | + parent::__construct($options); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return mixed|string|bool |
| 55 | 55 | */ |
| 56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 57 | 57 | return wpinv_payment_receipt(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -394,15 +394,15 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | - * Fetches the database from the MaxMind service. |
|
| 398 | - * |
|
| 399 | - * @param string $license_key The license key to be used when downloading the database. |
|
| 400 | - */ |
|
| 397 | + * Fetches the database from the MaxMind service. |
|
| 398 | + * |
|
| 399 | + * @param string $license_key The license key to be used when downloading the database. |
|
| 400 | + */ |
|
| 401 | 401 | public static function geoip2_download_database() { |
| 402 | 402 | |
| 403 | 403 | // Allow us to easily interact with the filesystem. |
| 404 | 404 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 405 | - WP_Filesystem(); |
|
| 405 | + WP_Filesystem(); |
|
| 406 | 406 | global $wp_filesystem; |
| 407 | 407 | |
| 408 | 408 | $license_key = wpinv_get_option( 'maxmind_license_key' ); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Move the new database into position. |
| 436 | - $wp_filesystem->move( $database_path, $target_path, true ); |
|
| 436 | + $wp_filesystem->move( $database_path, $target_path, true ); |
|
| 437 | 437 | $wp_filesystem->delete( dirname( $database_path ) ); |
| 438 | 438 | |
| 439 | 439 | wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) ); |
@@ -452,16 +452,16 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | // The download URI of the database. |
| 454 | 454 | $source_url = add_query_arg( |
| 455 | - array( |
|
| 455 | + array( |
|
| 456 | 456 | 'license_key' => urlencode( sanitize_text_field( $license_key ) ), |
| 457 | 457 | 'edition_id' => $database, |
| 458 | - 'suffix' => 'tar.gz', |
|
| 459 | - ), |
|
| 460 | - 'https://download.maxmind.com/app/geoip_download' |
|
| 458 | + 'suffix' => 'tar.gz', |
|
| 459 | + ), |
|
| 460 | + 'https://download.maxmind.com/app/geoip_download' |
|
| 461 | 461 | ); |
| 462 | 462 | |
| 463 | 463 | // Needed for the download_url call right below. |
| 464 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
| 464 | + require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
| 465 | 465 | |
| 466 | 466 | // Download the file. |
| 467 | 467 | $tmp_archive_path = download_url( esc_url_raw( $source_url ) ); |
@@ -470,16 +470,16 @@ discard block |
||
| 470 | 470 | if ( is_wp_error( $tmp_archive_path ) ) { |
| 471 | 471 | |
| 472 | 472 | // Transform the error into something more informative. |
| 473 | - $error_data = $tmp_archive_path->get_error_data(); |
|
| 474 | - if ( isset( $error_data['code'] ) ) { |
|
| 475 | - switch ( $error_data['code'] ) { |
|
| 476 | - case 401: |
|
| 477 | - return new WP_Error( |
|
| 478 | - 'invoicing_maxmind_geolocation_database_license_key', |
|
| 479 | - __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
| 480 | - ); |
|
| 481 | - } |
|
| 482 | - } |
|
| 473 | + $error_data = $tmp_archive_path->get_error_data(); |
|
| 474 | + if ( isset( $error_data['code'] ) ) { |
|
| 475 | + switch ( $error_data['code'] ) { |
|
| 476 | + case 401: |
|
| 477 | + return new WP_Error( |
|
| 478 | + 'invoicing_maxmind_geolocation_database_license_key', |
|
| 479 | + __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
| 480 | + ); |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | 484 | return new WP_Error( 'invoicing_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) ); |
| 485 | 485 | |
@@ -487,19 +487,19 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | // Extract the database from the archive. |
| 489 | 489 | try { |
| 490 | - $file = new PharData( $tmp_archive_path ); |
|
| 490 | + $file = new PharData( $tmp_archive_path ); |
|
| 491 | 491 | $file_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb'; |
| 492 | 492 | |
| 493 | - $file->extractTo( |
|
| 494 | - dirname( $tmp_archive_path ), |
|
| 495 | - trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb', |
|
| 496 | - true |
|
| 493 | + $file->extractTo( |
|
| 494 | + dirname( $tmp_archive_path ), |
|
| 495 | + trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb', |
|
| 496 | + true |
|
| 497 | 497 | ); |
| 498 | 498 | |
| 499 | - } catch ( Exception $exception ) { |
|
| 500 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
| 501 | - } finally { |
|
| 502 | - // Remove the archive since we only care about a single file in it. |
|
| 499 | + } catch ( Exception $exception ) { |
|
| 500 | + return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
| 501 | + } finally { |
|
| 502 | + // Remove the archive since we only care about a single file in it. |
|
| 503 | 503 | unlink( $tmp_archive_path ); |
| 504 | 504 | } |
| 505 | 505 | |
@@ -1862,7 +1862,7 @@ discard block |
||
| 1862 | 1862 | $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
| 1863 | 1863 | |
| 1864 | 1864 | if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) { |
| 1865 | - return wp_sprintf( |
|
| 1865 | + return wp_sprintf( |
|
| 1866 | 1866 | __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), |
| 1867 | 1867 | getpaid_vat_name() |
| 1868 | 1868 | ); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) { |
| 713 | 713 | $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode; |
| 714 | 714 | } |
| 715 | - }elseif(!empty( $ip )){ |
|
| 715 | + } elseif(!empty( $ip )){ |
|
| 716 | 716 | $url = 'http://ip-api.com/json/' . $ip; |
| 717 | 717 | $response = wp_remote_get($url); |
| 718 | 718 | |
@@ -1513,16 +1513,18 @@ discard block |
||
| 1513 | 1513 | |
| 1514 | 1514 | if ( !empty( $tax_rates ) ) { |
| 1515 | 1515 | foreach ( $tax_rates as $key => $tax_rate ) { |
| 1516 | - if ( $country != $tax_rate['country'] ) |
|
| 1517 | - continue; |
|
| 1516 | + if ( $country != $tax_rate['country'] ) { |
|
| 1517 | + continue; |
|
| 1518 | + } |
|
| 1518 | 1519 | |
| 1519 | 1520 | if ( !empty( $tax_rate['global'] ) ) { |
| 1520 | 1521 | if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
| 1521 | 1522 | $rate = number_format( $tax_rate['rate'], 4 ); |
| 1522 | 1523 | } |
| 1523 | 1524 | } else { |
| 1524 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 1525 | - continue; |
|
| 1525 | + if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) { |
|
| 1526 | + continue; |
|
| 1527 | + } |
|
| 1526 | 1528 | |
| 1527 | 1529 | $state_rate = $tax_rate['rate']; |
| 1528 | 1530 | if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | class WPInv_EUVat { |
| 10 | 10 | |
@@ -24,128 +24,128 @@ discard block |
||
| 24 | 24 | public function init() { |
| 25 | 25 | |
| 26 | 26 | // If this is an admin page... |
| 27 | - if ( is_admin() ) { |
|
| 27 | + if (is_admin()) { |
|
| 28 | 28 | |
| 29 | 29 | // Register our scripts. |
| 30 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); |
|
| 31 | - add_action( 'wpinv_settings_sections_taxes', array( $this, 'section_vat_settings' ) ); |
|
| 32 | - add_action( 'wpinv_settings_taxes', array( $this, 'vat_settings' ) ); |
|
| 33 | - add_filter( 'wpinv_settings_taxes-vat_sanitize', array( $this, 'sanitize_vat_settings' ) ); |
|
| 34 | - add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( $this, 'sanitize_vat_rates' ) ); |
|
| 35 | - add_action( 'wp_ajax_wpinv_add_vat_class', array( $this, 'add_class' ) ); |
|
| 36 | - add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( $this, 'add_class' ) ); |
|
| 37 | - add_action( 'wp_ajax_wpinv_delete_vat_class', array( $this, 'delete_class' ) ); |
|
| 38 | - add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( $this, 'delete_class' ) ); |
|
| 39 | - add_action( 'wp_ajax_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) ); |
|
| 40 | - add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) ); |
|
| 41 | - add_action( 'wp_ajax_wpinv_geoip2', array( $this, 'geoip2_download_database' ) ); |
|
| 42 | - add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( $this, 'geoip2_download_database' ) ); |
|
| 30 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); |
|
| 31 | + add_action('wpinv_settings_sections_taxes', array($this, 'section_vat_settings')); |
|
| 32 | + add_action('wpinv_settings_taxes', array($this, 'vat_settings')); |
|
| 33 | + add_filter('wpinv_settings_taxes-vat_sanitize', array($this, 'sanitize_vat_settings')); |
|
| 34 | + add_filter('wpinv_settings_taxes-vat_rates_sanitize', array($this, 'sanitize_vat_rates')); |
|
| 35 | + add_action('wp_ajax_wpinv_add_vat_class', array($this, 'add_class')); |
|
| 36 | + add_action('wp_ajax_nopriv_wpinv_add_vat_class', array($this, 'add_class')); |
|
| 37 | + add_action('wp_ajax_wpinv_delete_vat_class', array($this, 'delete_class')); |
|
| 38 | + add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array($this, 'delete_class')); |
|
| 39 | + add_action('wp_ajax_wpinv_update_vat_rates', array($this, 'update_eu_rates')); |
|
| 40 | + add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array($this, 'update_eu_rates')); |
|
| 41 | + add_action('wp_ajax_wpinv_geoip2', array($this, 'geoip2_download_database')); |
|
| 42 | + add_action('wp_ajax_nopriv_wpinv_geoip2', array($this, 'geoip2_download_database')); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_vat_scripts' ) ); |
|
| 46 | - add_filter( 'wpinv_default_billing_country', array( $this, 'get_user_country' ), 10 ); |
|
| 47 | - add_filter( 'wpinv_get_user_country', array( $this, 'set_user_country' ), 10 ); |
|
| 48 | - add_action( 'wp_ajax_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) ); |
|
| 49 | - add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) ); |
|
| 45 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_vat_scripts')); |
|
| 46 | + add_filter('wpinv_default_billing_country', array($this, 'get_user_country'), 10); |
|
| 47 | + add_filter('wpinv_get_user_country', array($this, 'set_user_country'), 10); |
|
| 48 | + add_action('wp_ajax_wpinv_vat_validate', array($this, 'ajax_vat_validate')); |
|
| 49 | + add_action('wp_ajax_nopriv_wpinv_vat_validate', array($this, 'ajax_vat_validate')); |
|
| 50 | 50 | |
| 51 | - if ( wpinv_use_taxes() && self::allow_vat_rules() ) { |
|
| 52 | - add_filter( 'wpinv_tax_rate', array( $this, 'get_rate' ), 10, 4 ); |
|
| 51 | + if (wpinv_use_taxes() && self::allow_vat_rules()) { |
|
| 52 | + add_filter('wpinv_tax_rate', array($this, 'get_rate'), 10, 4); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public static function get_eu_states( $sort = true ) { |
|
| 57 | - $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' ); |
|
| 58 | - if ( $sort ) { |
|
| 59 | - $sort = sort( $eu_states ); |
|
| 56 | + public static function get_eu_states($sort = true) { |
|
| 57 | + $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'); |
|
| 58 | + if ($sort) { |
|
| 59 | + $sort = sort($eu_states); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
| 62 | + return apply_filters('wpinv_get_eu_states', $eu_states, $sort); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public static function get_gst_countries( $sort = true ) { |
|
| 66 | - $gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
| 65 | + public static function get_gst_countries($sort = true) { |
|
| 66 | + $gst_countries = array('AU', 'NZ', 'CA', 'CN'); |
|
| 67 | 67 | |
| 68 | - if ( $sort ) { |
|
| 69 | - $sort = sort( $gst_countries ); |
|
| 68 | + if ($sort) { |
|
| 69 | + $sort = sort($gst_countries); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
| 72 | + return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public static function is_eu_state( $country_code ) { |
|
| 76 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
| 75 | + public static function is_eu_state($country_code) { |
|
| 76 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false; |
|
| 77 | 77 | |
| 78 | - return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
| 78 | + return apply_filters('wpinv_is_eu_state', $return, $country_code); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public static function is_gst_country( $country_code ) { |
|
| 82 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
| 81 | + public static function is_gst_country($country_code) { |
|
| 82 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false; |
|
| 83 | 83 | |
| 84 | - return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
| 84 | + return apply_filters('wpinv_is_gst_country', $return, $country_code); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function enqueue_vat_scripts() { |
| 88 | - if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) { |
|
| 88 | + if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) { |
|
| 89 | 89 | $this->load_vat_scripts(); |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function load_vat_scripts(){ |
|
| 94 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 93 | + public function load_vat_scripts() { |
|
| 94 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 95 | 95 | |
| 96 | - wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 97 | - wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 96 | + wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 97 | + wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 98 | 98 | |
| 99 | - $vat_name = $this->get_vat_name(); |
|
| 99 | + $vat_name = $this->get_vat_name(); |
|
| 100 | 100 | |
| 101 | 101 | $vars = array(); |
| 102 | 102 | $vars['UseTaxes'] = wpinv_use_taxes(); |
| 103 | 103 | $vars['EUStates'] = self::get_eu_states(); |
| 104 | - $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' ); |
|
| 105 | - $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
| 106 | - $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
| 107 | - $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name ); |
|
| 108 | - $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name ); |
|
| 109 | - $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name ); |
|
| 110 | - $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name ); |
|
| 111 | - $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' ); |
|
| 104 | + $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing'); |
|
| 105 | + $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing'); |
|
| 106 | + $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
| 107 | + $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name); |
|
| 108 | + $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name); |
|
| 109 | + $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name); |
|
| 110 | + $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name); |
|
| 111 | + $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing'); |
|
| 112 | 112 | $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false; |
| 113 | 113 | $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true; |
| 114 | - $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' ); |
|
| 115 | - $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' ); |
|
| 116 | - $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' ); |
|
| 117 | - $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' ); |
|
| 118 | - $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' ); |
|
| 119 | - $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' ); |
|
| 120 | - $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' ); |
|
| 121 | - $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' ); |
|
| 122 | - $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name ); |
|
| 123 | - $vars['VatReseting'] = __( 'Reseting...', 'invoicing' ); |
|
| 124 | - $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 125 | - $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 126 | - $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' ); |
|
| 114 | + $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing'); |
|
| 115 | + $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing'); |
|
| 116 | + $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing'); |
|
| 117 | + $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing'); |
|
| 118 | + $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing'); |
|
| 119 | + $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing'); |
|
| 120 | + $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing'); |
|
| 121 | + $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing'); |
|
| 122 | + $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name); |
|
| 123 | + $vars['VatReseting'] = __('Reseting...', 'invoicing'); |
|
| 124 | + $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 125 | + $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 126 | + $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing'); |
|
| 127 | 127 | $vars['isFront'] = is_admin() ? false : true; |
| 128 | 128 | $vars['baseCountry'] = wpinv_get_default_country(); |
| 129 | - $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false ); |
|
| 130 | - $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false; |
|
| 129 | + $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false); |
|
| 130 | + $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false; |
|
| 131 | 131 | |
| 132 | - wp_enqueue_script( 'wpinv-vat-validation-script' ); |
|
| 133 | - wp_enqueue_script( 'wpinv-vat-script' ); |
|
| 134 | - wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars ); |
|
| 132 | + wp_enqueue_script('wpinv-vat-validation-script'); |
|
| 133 | + wp_enqueue_script('wpinv-vat-script'); |
|
| 134 | + wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public static function enqueue_admin_scripts() { |
| 138 | - if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) { |
|
| 138 | + if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) { |
|
| 139 | 139 | self::load_vat_scripts(); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public static function section_vat_settings( $sections ) { |
|
| 144 | - if ( !empty( $sections ) ) { |
|
| 145 | - $sections['vat'] = __( 'EU VAT Settings', 'invoicing' ); |
|
| 143 | + public static function section_vat_settings($sections) { |
|
| 144 | + if (!empty($sections)) { |
|
| 145 | + $sections['vat'] = __('EU VAT Settings', 'invoicing'); |
|
| 146 | 146 | |
| 147 | - if ( self::allow_vat_classes() ) { |
|
| 148 | - $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' ); |
|
| 147 | + if (self::allow_vat_classes()) { |
|
| 148 | + $sections['vat_rates'] = __('EU VAT Rates', 'invoicing'); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | return $sections; |
@@ -154,52 +154,52 @@ discard block |
||
| 154 | 154 | public static function vat_rates_settings() { |
| 155 | 155 | $vat_classes = self::get_rate_classes(); |
| 156 | 156 | $vat_rates = array(); |
| 157 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new'; |
|
| 158 | - $current_url = remove_query_arg( 'wpi_sub' ); |
|
| 157 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new'; |
|
| 158 | + $current_url = remove_query_arg('wpi_sub'); |
|
| 159 | 159 | |
| 160 | 160 | $vat_rates['vat_rates_header'] = array( |
| 161 | 161 | 'id' => 'vat_rates_header', |
| 162 | - 'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>', |
|
| 162 | + 'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>', |
|
| 163 | 163 | 'desc' => '', |
| 164 | 164 | 'type' => 'header', |
| 165 | 165 | 'size' => 'regular' |
| 166 | 166 | ); |
| 167 | 167 | $vat_rates['vat_rates_class'] = array( |
| 168 | 168 | 'id' => 'vat_rates_class', |
| 169 | - 'name' => __( 'Edit VAT Rates', 'invoicing' ), |
|
| 170 | - 'desc' => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ), |
|
| 169 | + 'name' => __('Edit VAT Rates', 'invoicing'), |
|
| 170 | + 'desc' => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'), |
|
| 171 | 171 | 'type' => 'select', |
| 172 | - 'options' => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ), |
|
| 173 | - 'placeholder' => __( 'Select a VAT Rate', 'invoicing' ), |
|
| 172 | + 'options' => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))), |
|
| 173 | + 'placeholder' => __('Select a VAT Rate', 'invoicing'), |
|
| 174 | 174 | 'selected' => $vat_class, |
| 175 | 175 | 'class' => 'wpi_select2', |
| 176 | 176 | 'onchange' => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;', |
| 177 | 177 | ); |
| 178 | 178 | |
| 179 | - if ( $vat_class != '_standard' && $vat_class != '_new' ) { |
|
| 179 | + if ($vat_class != '_standard' && $vat_class != '_new') { |
|
| 180 | 180 | $vat_rates['vat_rate_delete'] = array( |
| 181 | 181 | 'id' => 'vat_rate_delete', |
| 182 | 182 | 'type' => 'vat_rate_delete', |
| 183 | 183 | ); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ( $vat_class == '_new' ) { |
|
| 186 | + if ($vat_class == '_new') { |
|
| 187 | 187 | $vat_rates['vat_rates_settings'] = array( |
| 188 | 188 | 'id' => 'vat_rates_settings', |
| 189 | - 'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>', |
|
| 189 | + 'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>', |
|
| 190 | 190 | 'type' => 'header', |
| 191 | 191 | ); |
| 192 | 192 | $vat_rates['vat_rate_name'] = array( |
| 193 | 193 | 'id' => 'vat_rate_name', |
| 194 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 195 | - 'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ), |
|
| 194 | + 'name' => __('Name', 'invoicing'), |
|
| 195 | + 'desc' => __('A short name for the new VAT Rate class', 'invoicing'), |
|
| 196 | 196 | 'type' => 'text', |
| 197 | 197 | 'size' => 'regular', |
| 198 | 198 | ); |
| 199 | 199 | $vat_rates['vat_rate_desc'] = array( |
| 200 | 200 | 'id' => 'vat_rate_desc', |
| 201 | - 'name' => __( 'Description', 'invoicing' ), |
|
| 202 | - 'desc' => __( 'Manage VAT Rate class', 'invoicing' ), |
|
| 201 | + 'name' => __('Description', 'invoicing'), |
|
| 202 | + 'desc' => __('Manage VAT Rate class', 'invoicing'), |
|
| 203 | 203 | 'type' => 'text', |
| 204 | 204 | 'size' => 'regular', |
| 205 | 205 | ); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $vat_rates['vat_rates'] = array( |
| 212 | 212 | 'id' => 'vat_rates', |
| 213 | 213 | 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>', |
| 214 | - 'desc' => self::get_class_desc( $vat_class ), |
|
| 214 | + 'desc' => self::get_class_desc($vat_class), |
|
| 215 | 215 | 'type' => 'vat_rates', |
| 216 | 216 | ); |
| 217 | 217 | } |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | return $vat_rates; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - public static function vat_settings( $settings ) { |
|
| 223 | - if ( !empty( $settings ) ) { |
|
| 222 | + public static function vat_settings($settings) { |
|
| 223 | + if (!empty($settings)) { |
|
| 224 | 224 | $vat_settings = array(); |
| 225 | 225 | $vat_settings['vat_company_title'] = array( |
| 226 | 226 | 'id' => 'vat_company_title', |
| 227 | - 'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>', |
|
| 227 | + 'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>', |
|
| 228 | 228 | 'desc' => '', |
| 229 | 229 | 'type' => 'header', |
| 230 | 230 | 'size' => 'regular' |
@@ -232,22 +232,22 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $vat_settings['vat_company_name'] = array( |
| 234 | 234 | 'id' => 'vat_company_name', |
| 235 | - 'name' => __( 'Your Company Name', 'invoicing' ), |
|
| 236 | - 'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 235 | + 'name' => __('Your Company Name', 'invoicing'), |
|
| 236 | + 'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 237 | 237 | 'type' => 'text', |
| 238 | 238 | 'size' => 'regular', |
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | $vat_settings['vat_number'] = array( |
| 242 | 242 | 'id' => 'vat_number', |
| 243 | - 'name' => __( 'Your VAT Number', 'invoicing' ), |
|
| 243 | + 'name' => __('Your VAT Number', 'invoicing'), |
|
| 244 | 244 | 'type' => 'vat_number', |
| 245 | 245 | 'size' => 'regular', |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | 248 | $vat_settings['vat_settings_title'] = array( |
| 249 | 249 | 'id' => 'vat_settings_title', |
| 250 | - 'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>', |
|
| 250 | + 'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>', |
|
| 251 | 251 | 'desc' => '', |
| 252 | 252 | 'type' => 'header', |
| 253 | 253 | 'size' => 'regular' |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | $vat_settings['apply_vat_rules'] = array( |
| 257 | 257 | 'id' => 'apply_vat_rules', |
| 258 | - 'name' => __( 'Enable VAT Rules', 'invoicing' ), |
|
| 259 | - 'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>', |
|
| 258 | + 'name' => __('Enable VAT Rules', 'invoicing'), |
|
| 259 | + 'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>', |
|
| 260 | 260 | 'type' => 'checkbox', |
| 261 | 261 | 'std' => '1' |
| 262 | 262 | ); |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | $vat_settings['vat_prevent_b2c_purchase'] = array( |
| 274 | 274 | 'id' => 'vat_prevent_b2c_purchase', |
| 275 | - 'name' => __( 'Prevent EU B2C Sales', 'invoicing' ), |
|
| 276 | - 'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ), |
|
| 275 | + 'name' => __('Prevent EU B2C Sales', 'invoicing'), |
|
| 276 | + 'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'), |
|
| 277 | 277 | 'type' => 'checkbox' |
| 278 | 278 | ); |
| 279 | 279 | |
@@ -281,22 +281,22 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | $vat_settings['vat_same_country_rule'] = array( |
| 283 | 283 | 'id' => 'vat_same_country_rule', |
| 284 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
| 285 | - 'desc' => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ), |
|
| 284 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
| 285 | + 'desc' => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'), |
|
| 286 | 286 | 'type' => 'select', |
| 287 | 287 | 'options' => array( |
| 288 | - '' => __( 'Normal', 'invoicing' ), |
|
| 289 | - 'no' => __( 'No VAT', 'invoicing' ), |
|
| 290 | - 'always' => __( 'Always apply VAT', 'invoicing' ), |
|
| 288 | + '' => __('Normal', 'invoicing'), |
|
| 289 | + 'no' => __('No VAT', 'invoicing'), |
|
| 290 | + 'always' => __('Always apply VAT', 'invoicing'), |
|
| 291 | 291 | ), |
| 292 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
| 292 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
| 293 | 293 | 'std' => '', |
| 294 | 294 | 'class' => 'wpi_select2', |
| 295 | 295 | ); |
| 296 | 296 | |
| 297 | 297 | $vat_settings['vat_checkout_title'] = array( |
| 298 | 298 | 'id' => 'vat_checkout_title', |
| 299 | - 'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>', |
|
| 299 | + 'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>', |
|
| 300 | 300 | 'desc' => '', |
| 301 | 301 | 'type' => 'header', |
| 302 | 302 | 'size' => 'regular' |
@@ -304,22 +304,22 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | $vat_settings['vat_disable_fields'] = array( |
| 306 | 306 | 'id' => 'vat_disable_fields', |
| 307 | - 'name' => __( 'Disable VAT Fields', 'invoicing' ), |
|
| 308 | - 'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>', |
|
| 307 | + 'name' => __('Disable VAT Fields', 'invoicing'), |
|
| 308 | + 'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>', |
|
| 309 | 309 | 'type' => 'checkbox' |
| 310 | 310 | ); |
| 311 | 311 | |
| 312 | 312 | $vat_settings['maxmind_license_key'] = array( |
| 313 | 313 | 'id' => 'maxmind_license_key', |
| 314 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
| 314 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
| 315 | 315 | 'type' => 'text', |
| 316 | 316 | 'size' => 'regular', |
| 317 | - 'desc' => '<a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'The key that will be used when dealing with MaxMind Geolocation services.', 'invoicing' ) . '</a>', |
|
| 317 | + 'desc' => '<a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('The key that will be used when dealing with MaxMind Geolocation services.', 'invoicing') . '</a>', |
|
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | 320 | $vat_settings['vat_ip_lookup'] = array( |
| 321 | 321 | 'id' => 'vat_ip_lookup', |
| 322 | - 'name' => __( 'IP Country Look-up', 'invoicing' ), |
|
| 322 | + 'name' => __('IP Country Look-up', 'invoicing'), |
|
| 323 | 323 | 'type' => 'vat_ip_lookup', |
| 324 | 324 | 'size' => 'regular', |
| 325 | 325 | 'std' => 'default', |
@@ -328,14 +328,14 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | $vat_settings['vat_ip_country_default'] = array( |
| 330 | 330 | 'id' => 'vat_ip_country_default', |
| 331 | - 'name' => __( 'Enable IP Country as Default', 'invoicing' ), |
|
| 332 | - 'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ), |
|
| 331 | + 'name' => __('Enable IP Country as Default', 'invoicing'), |
|
| 332 | + 'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'), |
|
| 333 | 333 | 'type' => 'checkbox' |
| 334 | 334 | ); |
| 335 | 335 | |
| 336 | 336 | $vat_settings['vies_validation_title'] = array( |
| 337 | 337 | 'id' => 'vies_validation_title', |
| 338 | - 'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>', |
|
| 338 | + 'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>', |
|
| 339 | 339 | 'desc' => '', |
| 340 | 340 | 'type' => 'header', |
| 341 | 341 | 'size' => 'regular' |
@@ -343,37 +343,37 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $vat_settings['vat_vies_check'] = array( |
| 345 | 345 | 'id' => 'vat_vies_check', |
| 346 | - 'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ), |
|
| 347 | - 'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 346 | + 'name' => __('Disable VIES VAT ID Check', 'invoicing'), |
|
| 347 | + 'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 348 | 348 | 'type' => 'checkbox' |
| 349 | 349 | ); |
| 350 | 350 | |
| 351 | 351 | $vat_settings['vat_disable_company_name_check'] = array( |
| 352 | 352 | 'id' => 'vat_disable_company_name_check', |
| 353 | - 'name' => __( 'Disable VIES Name Check', 'invoicing' ), |
|
| 354 | - 'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 353 | + 'name' => __('Disable VIES Name Check', 'invoicing'), |
|
| 354 | + 'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 355 | 355 | 'type' => 'checkbox' |
| 356 | 356 | ); |
| 357 | 357 | |
| 358 | 358 | $vat_settings['vat_offline_check'] = array( |
| 359 | 359 | 'id' => 'vat_offline_check', |
| 360 | - 'name' => __( 'Disable Basic Checks', 'invoicing' ), |
|
| 361 | - 'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ), |
|
| 360 | + 'name' => __('Disable Basic Checks', 'invoicing'), |
|
| 361 | + 'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'), |
|
| 362 | 362 | 'type' => 'checkbox' |
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | |
| 366 | 366 | $settings['vat'] = $vat_settings; |
| 367 | 367 | |
| 368 | - if ( self::allow_vat_classes() ) { |
|
| 368 | + if (self::allow_vat_classes()) { |
|
| 369 | 369 | $settings['vat_rates'] = self::vat_rates_settings(); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | $eu_fallback_rate = array( |
| 373 | 373 | 'id' => 'eu_fallback_rate', |
| 374 | - 'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>', |
|
| 374 | + 'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>', |
|
| 375 | 375 | 'type' => 'eu_fallback_rate', |
| 376 | - 'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ), |
|
| 376 | + 'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'), |
|
| 377 | 377 | 'std' => '20', |
| 378 | 378 | 'size' => 'small' |
| 379 | 379 | ); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | public static function maxmind_folder() { |
| 390 | 390 | |
| 391 | - $upload_dir = wp_upload_dir(); |
|
| 391 | + $upload_dir = wp_upload_dir(); |
|
| 392 | 392 | return $upload_dir['basedir'] . '/invoicing'; |
| 393 | 393 | |
| 394 | 394 | } |
@@ -405,39 +405,39 @@ discard block |
||
| 405 | 405 | WP_Filesystem(); |
| 406 | 406 | global $wp_filesystem; |
| 407 | 407 | |
| 408 | - $license_key = wpinv_get_option( 'maxmind_license_key' ); |
|
| 408 | + $license_key = wpinv_get_option('maxmind_license_key'); |
|
| 409 | 409 | |
| 410 | - if ( empty( $license_key ) ) { |
|
| 411 | - echo __( 'Please enter your MaxMind license key then save the settings first before downloading the databases.', 'invoicing' ); |
|
| 410 | + if (empty($license_key)) { |
|
| 411 | + echo __('Please enter your MaxMind license key then save the settings first before downloading the databases.', 'invoicing'); |
|
| 412 | 412 | exit; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // The database files that we will download. |
| 416 | - $database_files = array( 'GeoLite2-Country', 'GeoLite2-City' ); |
|
| 416 | + $database_files = array('GeoLite2-Country', 'GeoLite2-City'); |
|
| 417 | 417 | |
| 418 | 418 | // The destination dir of all databases. |
| 419 | 419 | $destination_dir = self::maxmind_folder(); |
| 420 | 420 | |
| 421 | - if ( ! $wp_filesystem->is_dir( $destination_dir ) ) { |
|
| 422 | - $wp_filesystem->mkdir( $destination_dir ); |
|
| 421 | + if (!$wp_filesystem->is_dir($destination_dir)) { |
|
| 422 | + $wp_filesystem->mkdir($destination_dir); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - foreach( $database_files as $database ) { |
|
| 425 | + foreach ($database_files as $database) { |
|
| 426 | 426 | |
| 427 | - $database_path = self::geoip2_download_file( $license_key, $database ); |
|
| 428 | - $target_path = trailingslashit( $destination_dir ) . $database . '.mmdb'; |
|
| 427 | + $database_path = self::geoip2_download_file($license_key, $database); |
|
| 428 | + $target_path = trailingslashit($destination_dir) . $database . '.mmdb'; |
|
| 429 | 429 | |
| 430 | - if ( is_wp_error( $database_path ) ) { |
|
| 430 | + if (is_wp_error($database_path)) { |
|
| 431 | 431 | echo $database_path->get_error_message(); |
| 432 | 432 | exit; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Move the new database into position. |
| 436 | - $wp_filesystem->move( $database_path, $target_path, true ); |
|
| 437 | - $wp_filesystem->delete( dirname( $database_path ) ); |
|
| 436 | + $wp_filesystem->move($database_path, $target_path, true); |
|
| 437 | + $wp_filesystem->delete(dirname($database_path)); |
|
| 438 | 438 | |
| 439 | - wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) ); |
|
| 440 | - echo sprintf( __( 'GeoIP2 %s database updated successfully.', 'invoicing' ), $database ) . ' '; |
|
| 439 | + wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp')); |
|
| 440 | + echo sprintf(__('GeoIP2 %s database updated successfully.', 'invoicing'), $database) . ' '; |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | exit; |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @return string|WP_Error |
| 450 | 450 | */ |
| 451 | - public static function geoip2_download_file( $license_key, $database ) { |
|
| 451 | + public static function geoip2_download_file($license_key, $database) { |
|
| 452 | 452 | |
| 453 | 453 | // The download URI of the database. |
| 454 | 454 | $source_url = add_query_arg( |
| 455 | 455 | array( |
| 456 | - 'license_key' => urlencode( sanitize_text_field( $license_key ) ), |
|
| 456 | + 'license_key' => urlencode(sanitize_text_field($license_key)), |
|
| 457 | 457 | 'edition_id' => $database, |
| 458 | 458 | 'suffix' => 'tar.gz', |
| 459 | 459 | ), |
@@ -464,54 +464,54 @@ discard block |
||
| 464 | 464 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 465 | 465 | |
| 466 | 466 | // Download the file. |
| 467 | - $tmp_archive_path = download_url( esc_url_raw( $source_url ) ); |
|
| 467 | + $tmp_archive_path = download_url(esc_url_raw($source_url)); |
|
| 468 | 468 | |
| 469 | 469 | // Did we encounter an error? |
| 470 | - if ( is_wp_error( $tmp_archive_path ) ) { |
|
| 470 | + if (is_wp_error($tmp_archive_path)) { |
|
| 471 | 471 | |
| 472 | 472 | // Transform the error into something more informative. |
| 473 | 473 | $error_data = $tmp_archive_path->get_error_data(); |
| 474 | - if ( isset( $error_data['code'] ) ) { |
|
| 475 | - switch ( $error_data['code'] ) { |
|
| 474 | + if (isset($error_data['code'])) { |
|
| 475 | + switch ($error_data['code']) { |
|
| 476 | 476 | case 401: |
| 477 | 477 | return new WP_Error( |
| 478 | 478 | 'invoicing_maxmind_geolocation_database_license_key', |
| 479 | - __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
| 479 | + __('The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing') |
|
| 480 | 480 | ); |
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) ); |
|
| 484 | + return new WP_Error('invoicing_maxmind_geolocation_database_download', __('Failed to download the MaxMind database.', 'invoicing')); |
|
| 485 | 485 | |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | // Extract the database from the archive. |
| 489 | 489 | try { |
| 490 | - $file = new PharData( $tmp_archive_path ); |
|
| 491 | - $file_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb'; |
|
| 490 | + $file = new PharData($tmp_archive_path); |
|
| 491 | + $file_path = trailingslashit(dirname($tmp_archive_path)) . trailingslashit($file->current()->getFilename()) . $database . '.mmdb'; |
|
| 492 | 492 | |
| 493 | 493 | $file->extractTo( |
| 494 | - dirname( $tmp_archive_path ), |
|
| 495 | - trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb', |
|
| 494 | + dirname($tmp_archive_path), |
|
| 495 | + trailingslashit($file->current()->getFilename()) . $database . '.mmdb', |
|
| 496 | 496 | true |
| 497 | 497 | ); |
| 498 | 498 | |
| 499 | - } catch ( Exception $exception ) { |
|
| 500 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
| 499 | + } catch (Exception $exception) { |
|
| 500 | + return new WP_Error('invoicing_maxmind_geolocation_database_archive', $exception->getMessage()); |
|
| 501 | 501 | } finally { |
| 502 | 502 | // Remove the archive since we only care about a single file in it. |
| 503 | - unlink( $tmp_archive_path ); |
|
| 503 | + unlink($tmp_archive_path); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | return $file_path; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | public static function load_geoip2() { |
| 510 | - if ( defined( 'WPINV_GEOIP2_LODDED' ) ) { |
|
| 510 | + if (defined('WPINV_GEOIP2_LODDED')) { |
|
| 511 | 511 | return; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if ( !class_exists( '\MaxMind\Db\Reader' ) ) { |
|
| 514 | + if (!class_exists('\MaxMind\Db\Reader')) { |
|
| 515 | 515 | $maxmind_db_files = array( |
| 516 | 516 | 'Reader/Decoder.php', |
| 517 | 517 | 'Reader/InvalidDatabaseException.php', |
@@ -520,12 +520,12 @@ discard block |
||
| 520 | 520 | 'Reader.php', |
| 521 | 521 | ); |
| 522 | 522 | |
| 523 | - foreach ( $maxmind_db_files as $key => $file ) { |
|
| 524 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file ); |
|
| 523 | + foreach ($maxmind_db_files as $key => $file) { |
|
| 524 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file); |
|
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - if ( !class_exists( '\GeoIp2\Database\Reader' ) ) { |
|
| 528 | + if (!class_exists('\GeoIp2\Database\Reader')) { |
|
| 529 | 529 | $geoip2_files = array( |
| 530 | 530 | 'ProviderInterface.php', |
| 531 | 531 | 'Compat/JsonSerializable.php', |
@@ -559,23 +559,23 @@ discard block |
||
| 559 | 559 | 'WebService/Client.php', |
| 560 | 560 | ); |
| 561 | 561 | |
| 562 | - foreach ( $geoip2_files as $key => $file ) { |
|
| 563 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file ); |
|
| 562 | + foreach ($geoip2_files as $key => $file) { |
|
| 563 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file); |
|
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - define( 'WPINV_GEOIP2_LODDED', true ); |
|
| 567 | + define('WPINV_GEOIP2_LODDED', true); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | public static function geoip2_country_dbfile() { |
| 571 | 571 | $upload_dir = wp_upload_dir(); |
| 572 | 572 | |
| 573 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
| 573 | + if (!isset($upload_dir['basedir'])) { |
|
| 574 | 574 | return false; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb'; |
| 578 | - if ( !file_exists( $filename ) ) { |
|
| 578 | + if (!file_exists($filename)) { |
|
| 579 | 579 | return false; |
| 580 | 580 | } |
| 581 | 581 | |
@@ -585,12 +585,12 @@ discard block |
||
| 585 | 585 | public static function geoip2_city_dbfile() { |
| 586 | 586 | $upload_dir = wp_upload_dir(); |
| 587 | 587 | |
| 588 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
| 588 | + if (!isset($upload_dir['basedir'])) { |
|
| 589 | 589 | return false; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb'; |
| 593 | - if ( !file_exists( $filename ) ) { |
|
| 593 | + if (!file_exists($filename)) { |
|
| 594 | 594 | return false; |
| 595 | 595 | } |
| 596 | 596 | |
@@ -601,10 +601,10 @@ discard block |
||
| 601 | 601 | try { |
| 602 | 602 | self::load_geoip2(); |
| 603 | 603 | |
| 604 | - if ( $filename = self::geoip2_country_dbfile() ) { |
|
| 605 | - return new \GeoIp2\Database\Reader( $filename ); |
|
| 604 | + if ($filename = self::geoip2_country_dbfile()) { |
|
| 605 | + return new \GeoIp2\Database\Reader($filename); |
|
| 606 | 606 | } |
| 607 | - } catch( Exception $e ) { |
|
| 607 | + } catch (Exception $e) { |
|
| 608 | 608 | return false; |
| 609 | 609 | } |
| 610 | 610 | |
@@ -615,183 +615,183 @@ discard block |
||
| 615 | 615 | try { |
| 616 | 616 | self::load_geoip2(); |
| 617 | 617 | |
| 618 | - if ( $filename = self::geoip2_city_dbfile() ) { |
|
| 619 | - return new \GeoIp2\Database\Reader( $filename ); |
|
| 618 | + if ($filename = self::geoip2_city_dbfile()) { |
|
| 619 | + return new \GeoIp2\Database\Reader($filename); |
|
| 620 | 620 | } |
| 621 | - } catch( Exception $e ) { |
|
| 621 | + } catch (Exception $e) { |
|
| 622 | 622 | return false; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | return false; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - public static function geoip2_country_record( $ip_address ) { |
|
| 628 | + public static function geoip2_country_record($ip_address) { |
|
| 629 | 629 | try { |
| 630 | 630 | $reader = self::geoip2_country_reader(); |
| 631 | 631 | |
| 632 | - if ( $reader ) { |
|
| 633 | - $record = $reader->country( $ip_address ); |
|
| 632 | + if ($reader) { |
|
| 633 | + $record = $reader->country($ip_address); |
|
| 634 | 634 | |
| 635 | - if ( !empty( $record->country->isoCode ) ) { |
|
| 635 | + if (!empty($record->country->isoCode)) { |
|
| 636 | 636 | return $record; |
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | - } catch(\InvalidArgumentException $e) { |
|
| 640 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 639 | + } catch (\InvalidArgumentException $e) { |
|
| 640 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 641 | 641 | |
| 642 | 642 | return false; |
| 643 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 644 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 643 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 644 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 645 | 645 | |
| 646 | 646 | return false; |
| 647 | - } catch( Exception $e ) { |
|
| 647 | + } catch (Exception $e) { |
|
| 648 | 648 | return false; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | return false; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - public static function geoip2_city_record( $ip_address ) { |
|
| 654 | + public static function geoip2_city_record($ip_address) { |
|
| 655 | 655 | try { |
| 656 | 656 | $reader = self::geoip2_city_reader(); |
| 657 | 657 | |
| 658 | - if ( $reader ) { |
|
| 659 | - $record = $reader->city( $ip_address ); |
|
| 658 | + if ($reader) { |
|
| 659 | + $record = $reader->city($ip_address); |
|
| 660 | 660 | |
| 661 | - if ( !empty( $record->country->isoCode ) ) { |
|
| 661 | + if (!empty($record->country->isoCode)) { |
|
| 662 | 662 | return $record; |
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | - } catch(\InvalidArgumentException $e) { |
|
| 666 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 665 | + } catch (\InvalidArgumentException $e) { |
|
| 666 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 667 | 667 | |
| 668 | 668 | return false; |
| 669 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 670 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 669 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 670 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 671 | 671 | |
| 672 | 672 | return false; |
| 673 | - } catch( Exception $e ) { |
|
| 673 | + } catch (Exception $e) { |
|
| 674 | 674 | return false; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | return false; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - public static function geoip2_country_code( $ip_address ) { |
|
| 681 | - $record = self::geoip2_country_record( $ip_address ); |
|
| 682 | - return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country(); |
|
| 680 | + public static function geoip2_country_code($ip_address) { |
|
| 681 | + $record = self::geoip2_country_record($ip_address); |
|
| 682 | + return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country(); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // Find country by IP address. |
| 686 | - public static function get_country_by_ip( $ip = '' ) { |
|
| 686 | + public static function get_country_by_ip($ip = '') { |
|
| 687 | 687 | global $wpinv_ip_address_country; |
| 688 | 688 | return ''; |
| 689 | - if ( !empty( $wpinv_ip_address_country ) ) { |
|
| 689 | + if (!empty($wpinv_ip_address_country)) { |
|
| 690 | 690 | return $wpinv_ip_address_country; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - if ( empty( $ip ) ) { |
|
| 693 | + if (empty($ip)) { |
|
| 694 | 694 | $ip = wpinv_get_ip(); |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - $ip_country_service = wpinv_get_option( 'vat_ip_lookup' ); |
|
| 698 | - $is_default = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false; |
|
| 697 | + $ip_country_service = wpinv_get_option('vat_ip_lookup'); |
|
| 698 | + $is_default = empty($ip_country_service) || $ip_country_service === 'default' ? true : false; |
|
| 699 | 699 | |
| 700 | - if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country. |
|
| 701 | - if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) { |
|
| 700 | + if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country. |
|
| 701 | + if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) { |
|
| 702 | 702 | try { |
| 703 | - $wpinv_ip_address_country = geoip_country_code_by_name( $ip ); |
|
| 704 | - } catch( Exception $e ) { |
|
| 705 | - wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' ); |
|
| 703 | + $wpinv_ip_address_country = geoip_country_code_by_name($ip); |
|
| 704 | + } catch (Exception $e) { |
|
| 705 | + wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )'); |
|
| 706 | 706 | } |
| 707 | - } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) { |
|
| 708 | - $wpinv_ip_address_country = self::geoip2_country_code( $ip ); |
|
| 709 | - } else if ( function_exists( 'simplexml_load_file' ) && ini_get('allow_url_fopen') && ( $ip_country_service === 'geoplugin' || $is_default ) ) { |
|
| 710 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 707 | + } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) { |
|
| 708 | + $wpinv_ip_address_country = self::geoip2_country_code($ip); |
|
| 709 | + } else if (function_exists('simplexml_load_file') && ini_get('allow_url_fopen') && ($ip_country_service === 'geoplugin' || $is_default)) { |
|
| 710 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 711 | 711 | |
| 712 | - if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) { |
|
| 713 | - $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode; |
|
| 712 | + if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) { |
|
| 713 | + $wpinv_ip_address_country = (string) $load_xml->geoplugin_countryCode; |
|
| 714 | 714 | } |
| 715 | - }elseif(!empty( $ip )){ |
|
| 715 | + }elseif (!empty($ip)) { |
|
| 716 | 716 | $url = 'http://ip-api.com/json/' . $ip; |
| 717 | 717 | $response = wp_remote_get($url); |
| 718 | 718 | |
| 719 | - if ( is_array( $response ) && wp_remote_retrieve_response_code( $response ) == '200' ) { |
|
| 720 | - $data = json_decode(wp_remote_retrieve_body( $response ),true); |
|
| 721 | - if(!empty($data['countryCode'])){ |
|
| 722 | - $wpinv_ip_address_country = (string)$data['countryCode']; |
|
| 719 | + if (is_array($response) && wp_remote_retrieve_response_code($response) == '200') { |
|
| 720 | + $data = json_decode(wp_remote_retrieve_body($response), true); |
|
| 721 | + if (!empty($data['countryCode'])) { |
|
| 722 | + $wpinv_ip_address_country = (string) $data['countryCode']; |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - if ( empty( $wpinv_ip_address_country ) ) { |
|
| 728 | + if (empty($wpinv_ip_address_country)) { |
|
| 729 | 729 | $wpinv_ip_address_country = wpinv_get_default_country(); |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | return $wpinv_ip_address_country; |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - public static function sanitize_vat_settings( $input ) { |
|
| 735 | + public static function sanitize_vat_settings($input) { |
|
| 736 | 736 | global $wpinv_options; |
| 737 | 737 | |
| 738 | 738 | $valid = false; |
| 739 | 739 | $message = ''; |
| 740 | 740 | |
| 741 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 742 | - if ( empty( $wpinv_options['vat_offline_check'] ) ) { |
|
| 743 | - $valid = self::offline_check( $input['vat_number'] ); |
|
| 741 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 742 | + if (empty($wpinv_options['vat_offline_check'])) { |
|
| 743 | + $valid = self::offline_check($input['vat_number']); |
|
| 744 | 744 | } else { |
| 745 | 745 | $valid = true; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' ); |
|
| 748 | + $message = $valid ? '' : __('VAT number not validated', 'invoicing'); |
|
| 749 | 749 | } else { |
| 750 | - $result = self::check_vat( $input['vat_number'] ); |
|
| 750 | + $result = self::check_vat($input['vat_number']); |
|
| 751 | 751 | |
| 752 | - if ( empty( $result['valid'] ) ) { |
|
| 752 | + if (empty($result['valid'])) { |
|
| 753 | 753 | $valid = false; |
| 754 | 754 | $message = $result['message']; |
| 755 | 755 | } else { |
| 756 | - $valid = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] ); |
|
| 757 | - $message = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' ); |
|
| 756 | + $valid = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']); |
|
| 757 | + $message = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing'); |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if ( $message && self::is_vat_validated() != $valid ) { |
|
| 762 | - add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) ); |
|
| 761 | + if ($message && self::is_vat_validated() != $valid) { |
|
| 762 | + add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error')); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | $input['vat_valid'] = $valid; |
| 766 | 766 | return $input; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - public static function sanitize_vat_rates( $input ) { |
|
| 770 | - if( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 771 | - add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' ); |
|
| 769 | + public static function sanitize_vat_rates($input) { |
|
| 770 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 771 | + add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error'); |
|
| 772 | 772 | return $input; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | $vat_classes = self::get_rate_classes(); |
| 776 | - $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : ''; |
|
| 776 | + $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : ''; |
|
| 777 | 777 | |
| 778 | - if ( empty( $vat_class ) ) { |
|
| 779 | - add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' ); |
|
| 778 | + if (empty($vat_class)) { |
|
| 779 | + add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error'); |
|
| 780 | 780 | |
| 781 | 781 | return $input; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array(); |
|
| 784 | + $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array(); |
|
| 785 | 785 | |
| 786 | - if ( $vat_class === '_standard' ) { |
|
| 786 | + if ($vat_class === '_standard') { |
|
| 787 | 787 | // Save the active rates in the invoice settings |
| 788 | - update_option( 'wpinv_tax_rates', $new_rates ); |
|
| 788 | + update_option('wpinv_tax_rates', $new_rates); |
|
| 789 | 789 | } else { |
| 790 | 790 | // Get the existing set of rates |
| 791 | 791 | $rates = self::get_non_standard_rates(); |
| 792 | 792 | $rates[$vat_class] = $new_rates; |
| 793 | 793 | |
| 794 | - update_option( 'wpinv_vat_rates', $rates ); |
|
| 794 | + update_option('wpinv_vat_rates', $rates); |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | return $input; |
@@ -801,71 +801,71 @@ discard block |
||
| 801 | 801 | $response = array(); |
| 802 | 802 | $response['success'] = false; |
| 803 | 803 | |
| 804 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 805 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 806 | - wp_send_json( $response ); |
|
| 804 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 805 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 806 | + wp_send_json($response); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false; |
|
| 810 | - $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false; |
|
| 809 | + $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false; |
|
| 810 | + $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false; |
|
| 811 | 811 | |
| 812 | - if ( empty( $vat_class_name ) ) { |
|
| 813 | - $response['error'] = __( 'Select the VAT rate name', 'invoicing' ); |
|
| 814 | - wp_send_json( $response ); |
|
| 812 | + if (empty($vat_class_name)) { |
|
| 813 | + $response['error'] = __('Select the VAT rate name', 'invoicing'); |
|
| 814 | + wp_send_json($response); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $vat_classes = (array)self::get_rate_classes(); |
|
| 817 | + $vat_classes = (array) self::get_rate_classes(); |
|
| 818 | 818 | |
| 819 | - if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) { |
|
| 820 | - $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name ); |
|
| 821 | - wp_send_json( $response ); |
|
| 819 | + if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) { |
|
| 820 | + $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name); |
|
| 821 | + wp_send_json($response); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name ); |
|
| 825 | - $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) ); |
|
| 824 | + $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name); |
|
| 825 | + $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key)); |
|
| 826 | 826 | |
| 827 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
| 828 | - $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc ); |
|
| 827 | + $vat_classes = (array) self::get_rate_classes(true); |
|
| 828 | + $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc); |
|
| 829 | 829 | |
| 830 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
| 830 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
| 831 | 831 | |
| 832 | 832 | $response['success'] = true; |
| 833 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key ); |
|
| 833 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key); |
|
| 834 | 834 | |
| 835 | - wp_send_json( $response ); |
|
| 835 | + wp_send_json($response); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | public static function delete_class() { |
| 839 | 839 | $response = array(); |
| 840 | 840 | $response['success'] = false; |
| 841 | 841 | |
| 842 | - if ( !wpinv_current_user_can_manage_invoicing() || !isset( $_POST['class'] ) ) { |
|
| 843 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 844 | - wp_send_json( $response ); |
|
| 842 | + if (!wpinv_current_user_can_manage_invoicing() || !isset($_POST['class'])) { |
|
| 843 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 844 | + wp_send_json($response); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false; |
|
| 848 | - $vat_classes = (array)self::get_rate_classes(); |
|
| 847 | + $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false; |
|
| 848 | + $vat_classes = (array) self::get_rate_classes(); |
|
| 849 | 849 | |
| 850 | - if ( !isset( $vat_classes[$vat_class] ) ) { |
|
| 851 | - $response['error'] = __( 'Requested class does not exists', 'invoicing' ); |
|
| 852 | - wp_send_json( $response ); |
|
| 850 | + if (!isset($vat_classes[$vat_class])) { |
|
| 851 | + $response['error'] = __('Requested class does not exists', 'invoicing'); |
|
| 852 | + wp_send_json($response); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - if ( $vat_class == '_new' || $vat_class == '_standard' ) { |
|
| 856 | - $response['error'] = __( 'You can not delete standard rates class', 'invoicing' ); |
|
| 857 | - wp_send_json( $response ); |
|
| 855 | + if ($vat_class == '_new' || $vat_class == '_standard') { |
|
| 856 | + $response['error'] = __('You can not delete standard rates class', 'invoicing'); |
|
| 857 | + wp_send_json($response); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
| 861 | - unset( $vat_classes[$vat_class] ); |
|
| 860 | + $vat_classes = (array) self::get_rate_classes(true); |
|
| 861 | + unset($vat_classes[$vat_class]); |
|
| 862 | 862 | |
| 863 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
| 863 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
| 864 | 864 | |
| 865 | 865 | $response['success'] = true; |
| 866 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new' ); |
|
| 866 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new'); |
|
| 867 | 867 | |
| 868 | - wp_send_json( $response ); |
|
| 868 | + wp_send_json($response); |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | public static function update_eu_rates() { |
@@ -874,73 +874,73 @@ discard block |
||
| 874 | 874 | $response['error'] = null; |
| 875 | 875 | $response['data'] = null; |
| 876 | 876 | |
| 877 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 878 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 879 | - wp_send_json( $response ); |
|
| 877 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 878 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 879 | + wp_send_json($response); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - $group = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : ''; |
|
| 883 | - $euvatrates = self::request_euvatrates( $group ); |
|
| 882 | + $group = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : ''; |
|
| 883 | + $euvatrates = self::request_euvatrates($group); |
|
| 884 | 884 | |
| 885 | - if ( !empty( $euvatrates ) ) { |
|
| 886 | - if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) { |
|
| 885 | + if (!empty($euvatrates)) { |
|
| 886 | + if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) { |
|
| 887 | 887 | $response['success'] = true; |
| 888 | 888 | $response['data']['rates'] = $euvatrates['rates']; |
| 889 | - } else if ( !empty( $euvatrates['error'] ) ) { |
|
| 889 | + } else if (!empty($euvatrates['error'])) { |
|
| 890 | 890 | $response['error'] = $euvatrates['error']; |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - wp_send_json( $response ); |
|
| 894 | + wp_send_json($response); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | public static function hide_vat_fields() { |
| 898 | - $hide = wpinv_get_option( 'vat_disable_fields' ); |
|
| 898 | + $hide = wpinv_get_option('vat_disable_fields'); |
|
| 899 | 899 | |
| 900 | - return apply_filters( 'wpinv_hide_vat_fields', $hide ); |
|
| 900 | + return apply_filters('wpinv_hide_vat_fields', $hide); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | public static function same_country_rule() { |
| 904 | - $same_country_rule = wpinv_get_option( 'vat_same_country_rule' ); |
|
| 904 | + $same_country_rule = wpinv_get_option('vat_same_country_rule'); |
|
| 905 | 905 | |
| 906 | - return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule ); |
|
| 906 | + return apply_filters('wpinv_vat_same_country_rule', $same_country_rule); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | /** |
| 910 | 910 | * Retrieves the vat name. |
| 911 | 911 | */ |
| 912 | 912 | public function get_vat_name() { |
| 913 | - $vat_name = wpinv_get_option( 'vat_name' ); |
|
| 914 | - return empty( $vat_name ) ? __( 'VAT', 'invoicing' ) : sanitize_text_field( $vat_name ); |
|
| 913 | + $vat_name = wpinv_get_option('vat_name'); |
|
| 914 | + return empty($vat_name) ? __('VAT', 'invoicing') : sanitize_text_field($vat_name); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | public static function get_company_name() { |
| 918 | - $company_name = wpinv_get_option( 'vat_company_name' ); |
|
| 918 | + $company_name = wpinv_get_option('vat_company_name'); |
|
| 919 | 919 | |
| 920 | - return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
| 920 | + return apply_filters('wpinv_get_owner_company_name', $company_name); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | public static function get_vat_number() { |
| 924 | - $vat_number = wpinv_get_option( 'vat_number' ); |
|
| 924 | + $vat_number = wpinv_get_option('vat_number'); |
|
| 925 | 925 | |
| 926 | - return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
| 926 | + return apply_filters('wpinv_get_owner_vat_number', $vat_number); |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | public static function is_vat_validated() { |
| 930 | - $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
| 930 | + $validated = self::get_vat_number() && wpinv_get_option('vat_valid'); |
|
| 931 | 931 | |
| 932 | - return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
| 932 | + return apply_filters('wpinv_is_owner_vat_validated', $validated); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - public static function sanitize_vat( $vat_number, $country_code = '' ) { |
|
| 936 | - $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
| 935 | + public static function sanitize_vat($vat_number, $country_code = '') { |
|
| 936 | + $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
| 937 | 937 | |
| 938 | - if ( empty( $country_code ) ) { |
|
| 939 | - $country_code = substr( $vat_number, 0, 2 ); |
|
| 938 | + if (empty($country_code)) { |
|
| 939 | + $country_code = substr($vat_number, 0, 2); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - if ( strpos( $vat_number , $country_code ) === 0 ) { |
|
| 943 | - $vat = str_replace( $country_code, '', $vat_number ); |
|
| 942 | + if (strpos($vat_number, $country_code) === 0) { |
|
| 943 | + $vat = str_replace($country_code, '', $vat_number); |
|
| 944 | 944 | } else { |
| 945 | 945 | $vat = $country_code . $vat_number; |
| 946 | 946 | } |
@@ -953,140 +953,140 @@ discard block |
||
| 953 | 953 | return $return; |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | - public static function offline_check( $vat_number, $country_code = '', $formatted = false ) { |
|
| 957 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
| 956 | + public static function offline_check($vat_number, $country_code = '', $formatted = false) { |
|
| 957 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
| 958 | 958 | $vat_number = $vat['vat_number']; |
| 959 | 959 | $country_code = $vat['iso']; |
| 960 | 960 | $regex = array(); |
| 961 | 961 | |
| 962 | - switch ( $country_code ) { |
|
| 962 | + switch ($country_code) { |
|
| 963 | 963 | case 'AT': |
| 964 | - $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
| 964 | + $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
| 965 | 965 | break; |
| 966 | 966 | case 'BE': |
| 967 | - $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
| 967 | + $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
| 968 | 968 | break; |
| 969 | 969 | case 'BG': |
| 970 | - $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
| 970 | + $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
| 971 | 971 | break; |
| 972 | 972 | case 'CH': |
| 973 | 973 | case 'CHE': |
| 974 | - $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
| 974 | + $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
| 975 | 975 | break; |
| 976 | 976 | case 'CY': |
| 977 | - $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
| 977 | + $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
| 978 | 978 | break; |
| 979 | 979 | case 'CZ': |
| 980 | - $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
| 980 | + $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
| 981 | 981 | break; |
| 982 | 982 | case 'DE': |
| 983 | - $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
| 983 | + $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
| 984 | 984 | break; |
| 985 | 985 | case 'DK': |
| 986 | - $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
| 986 | + $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
| 987 | 987 | break; |
| 988 | 988 | case 'EE': |
| 989 | - $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
| 989 | + $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
| 990 | 990 | break; |
| 991 | 991 | case 'EL': |
| 992 | - $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
| 992 | + $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
| 993 | 993 | break; |
| 994 | 994 | case 'ES': |
| 995 | - $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
| 996 | - $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
| 997 | - $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
| 998 | - $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
| 995 | + $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
| 996 | + $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
| 997 | + $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
| 998 | + $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
| 999 | 999 | break; |
| 1000 | 1000 | case 'EU': |
| 1001 | - $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
| 1001 | + $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
| 1002 | 1002 | break; |
| 1003 | 1003 | case 'FI': |
| 1004 | - $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
| 1004 | + $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
| 1005 | 1005 | break; |
| 1006 | 1006 | case 'FR': |
| 1007 | - $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
| 1008 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
| 1009 | - $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
| 1010 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
| 1007 | + $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
| 1008 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
| 1009 | + $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
| 1010 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
| 1011 | 1011 | break; |
| 1012 | 1012 | case 'GB': |
| 1013 | - $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
| 1014 | - $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
| 1015 | - $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
| 1016 | - $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
| 1013 | + $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
| 1014 | + $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
| 1015 | + $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
| 1016 | + $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
| 1017 | 1017 | break; |
| 1018 | 1018 | case 'GR': |
| 1019 | - $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
| 1019 | + $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
| 1020 | 1020 | break; |
| 1021 | 1021 | case 'HR': |
| 1022 | - $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
| 1022 | + $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
| 1023 | 1023 | break; |
| 1024 | 1024 | case 'HU': |
| 1025 | - $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
| 1025 | + $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
| 1026 | 1026 | break; |
| 1027 | 1027 | case 'IE': |
| 1028 | - $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
| 1029 | - $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
| 1030 | - $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
| 1028 | + $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
| 1029 | + $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
| 1030 | + $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
| 1031 | 1031 | break; |
| 1032 | 1032 | case 'IT': |
| 1033 | - $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
| 1033 | + $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
| 1034 | 1034 | break; |
| 1035 | 1035 | case 'LV': |
| 1036 | - $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
| 1036 | + $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
| 1037 | 1037 | break; |
| 1038 | 1038 | case 'LT': |
| 1039 | - $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
| 1039 | + $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
| 1040 | 1040 | break; |
| 1041 | 1041 | case 'LU': |
| 1042 | - $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
| 1042 | + $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
| 1043 | 1043 | break; |
| 1044 | 1044 | case 'MT': |
| 1045 | - $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
| 1045 | + $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
| 1046 | 1046 | break; |
| 1047 | 1047 | case 'NL': |
| 1048 | - $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
| 1048 | + $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
| 1049 | 1049 | break; |
| 1050 | 1050 | case 'NO': |
| 1051 | - $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
| 1051 | + $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
| 1052 | 1052 | break; |
| 1053 | 1053 | case 'PL': |
| 1054 | - $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
| 1054 | + $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
| 1055 | 1055 | break; |
| 1056 | 1056 | case 'PT': |
| 1057 | - $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
| 1057 | + $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
| 1058 | 1058 | break; |
| 1059 | 1059 | case 'RO': |
| 1060 | - $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
| 1060 | + $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
| 1061 | 1061 | break; |
| 1062 | 1062 | case 'RS': |
| 1063 | - $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
| 1063 | + $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
| 1064 | 1064 | break; |
| 1065 | 1065 | case 'SI': |
| 1066 | - $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
| 1066 | + $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
| 1067 | 1067 | break; |
| 1068 | 1068 | case 'SK': |
| 1069 | - $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
| 1069 | + $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
| 1070 | 1070 | break; |
| 1071 | 1071 | case 'SE': |
| 1072 | - $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
| 1072 | + $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
| 1073 | 1073 | break; |
| 1074 | 1074 | default: |
| 1075 | 1075 | $regex = array(); |
| 1076 | 1076 | break; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - if ( empty( $regex ) ) { |
|
| 1079 | + if (empty($regex)) { |
|
| 1080 | 1080 | return false; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - foreach ( $regex as $pattern ) { |
|
| 1083 | + foreach ($regex as $pattern) { |
|
| 1084 | 1084 | $matches = null; |
| 1085 | - preg_match_all( $pattern, $vat_number, $matches ); |
|
| 1085 | + preg_match_all($pattern, $vat_number, $matches); |
|
| 1086 | 1086 | |
| 1087 | - if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) { |
|
| 1088 | - if ( $formatted ) { |
|
| 1089 | - return array( 'code' => $matches[1][0], 'number' => $matches[2][0] ); |
|
| 1087 | + if (!empty($matches[1][0]) && !empty($matches[2][0])) { |
|
| 1088 | + if ($formatted) { |
|
| 1089 | + return array('code' => $matches[1][0], 'number' => $matches[2][0]); |
|
| 1090 | 1090 | } else { |
| 1091 | 1091 | return true; |
| 1092 | 1092 | } |
@@ -1096,75 +1096,75 @@ discard block |
||
| 1096 | 1096 | return false; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - public static function vies_check( $vat_number, $country_code = '', $result = false ) { |
|
| 1100 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
| 1099 | + public static function vies_check($vat_number, $country_code = '', $result = false) { |
|
| 1100 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
| 1101 | 1101 | $vat_number = $vat['vat']; |
| 1102 | 1102 | $iso = $vat['iso']; |
| 1103 | 1103 | |
| 1104 | - $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number ); |
|
| 1104 | + $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number); |
|
| 1105 | 1105 | |
| 1106 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 1107 | - $response = file_get_contents( $url ); |
|
| 1108 | - } else if ( function_exists( 'curl_init' ) ) { |
|
| 1106 | + if (ini_get('allow_url_fopen')) { |
|
| 1107 | + $response = file_get_contents($url); |
|
| 1108 | + } else if (function_exists('curl_init')) { |
|
| 1109 | 1109 | $ch = curl_init(); |
| 1110 | 1110 | |
| 1111 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 1112 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); |
|
| 1113 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
| 1114 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); |
|
| 1115 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
|
| 1111 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1112 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
|
| 1113 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 1114 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 1115 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 1116 | 1116 | |
| 1117 | - $response = curl_exec( $ch ); |
|
| 1117 | + $response = curl_exec($ch); |
|
| 1118 | 1118 | |
| 1119 | - if ( curl_errno( $ch ) ) { |
|
| 1120 | - wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' ); |
|
| 1119 | + if (curl_errno($ch)) { |
|
| 1120 | + wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR'); |
|
| 1121 | 1121 | $response = ''; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - curl_close( $ch ); |
|
| 1124 | + curl_close($ch); |
|
| 1125 | 1125 | } else { |
| 1126 | - wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' ); |
|
| 1126 | + wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR'); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - if ( empty( $response ) ) { |
|
| 1129 | + if (empty($response)) { |
|
| 1130 | 1130 | return $result; |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - if ( preg_match( '/invalid VAT number/i', $response ) ) { |
|
| 1133 | + if (preg_match('/invalid VAT number/i', $response)) { |
|
| 1134 | 1134 | return false; |
| 1135 | - } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) { |
|
| 1136 | - $content = explode( "valid VAT number", htmlentities( $response ) ); |
|
| 1135 | + } else if (preg_match('/valid VAT number/i', $response, $matches)) { |
|
| 1136 | + $content = explode("valid VAT number", htmlentities($response)); |
|
| 1137 | 1137 | |
| 1138 | - if ( !empty( $content[1] ) ) { |
|
| 1139 | - preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches ); |
|
| 1138 | + if (!empty($content[1])) { |
|
| 1139 | + preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches); |
|
| 1140 | 1140 | |
| 1141 | - if ( !empty( $matches[2] ) && $matches[3] ) { |
|
| 1141 | + if (!empty($matches[2]) && $matches[3]) { |
|
| 1142 | 1142 | $return = array(); |
| 1143 | 1143 | |
| 1144 | - foreach ( $matches[2] as $key => $label ) { |
|
| 1145 | - $label = trim( $label ); |
|
| 1144 | + foreach ($matches[2] as $key => $label) { |
|
| 1145 | + $label = trim($label); |
|
| 1146 | 1146 | |
| 1147 | - switch ( strtolower( $label ) ) { |
|
| 1147 | + switch (strtolower($label)) { |
|
| 1148 | 1148 | case 'member state': |
| 1149 | - $return['state'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1149 | + $return['state'] = trim(strip_tags($matches[3][$key])); |
|
| 1150 | 1150 | break; |
| 1151 | 1151 | case 'vat number': |
| 1152 | - $return['number'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1152 | + $return['number'] = trim(strip_tags($matches[3][$key])); |
|
| 1153 | 1153 | break; |
| 1154 | 1154 | case 'name': |
| 1155 | - $return['company'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1155 | + $return['company'] = trim(strip_tags($matches[3][$key])); |
|
| 1156 | 1156 | break; |
| 1157 | 1157 | case 'address': |
| 1158 | - $address = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) ); |
|
| 1159 | - $return['address'] = trim( strip_tags( $address, '<br>' ) ); |
|
| 1158 | + $address = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key]))); |
|
| 1159 | + $return['address'] = trim(strip_tags($address, '<br>')); |
|
| 1160 | 1160 | break; |
| 1161 | 1161 | case 'consultation number': |
| 1162 | - $return['consultation'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1162 | + $return['consultation'] = trim(strip_tags($matches[3][$key])); |
|
| 1163 | 1163 | break; |
| 1164 | 1164 | } |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | - if ( !empty( $return ) ) { |
|
| 1167 | + if (!empty($return)) { |
|
| 1168 | 1168 | return $return; |
| 1169 | 1169 | } |
| 1170 | 1170 | } |
@@ -1176,62 +1176,62 @@ discard block |
||
| 1176 | 1176 | } |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | - public static function check_vat( $vat_number, $country_code = '' ) { |
|
| 1179 | + public static function check_vat($vat_number, $country_code = '') { |
|
| 1180 | 1180 | $vat_name = getpaid_vat_name(); |
| 1181 | 1181 | |
| 1182 | 1182 | $return = array(); |
| 1183 | 1183 | $return['valid'] = false; |
| 1184 | - $return['message'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 1184 | + $return['message'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 1185 | 1185 | |
| 1186 | - if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) { |
|
| 1186 | + if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) { |
|
| 1187 | 1187 | return $return; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | - $response = self::vies_check( $vat_number, $country_code ); |
|
| 1190 | + $response = self::vies_check($vat_number, $country_code); |
|
| 1191 | 1191 | |
| 1192 | - if ( $response ) { |
|
| 1193 | - $return['valid'] = true; |
|
| 1192 | + if ($response) { |
|
| 1193 | + $return['valid'] = true; |
|
| 1194 | 1194 | |
| 1195 | - if ( is_array( $response ) ) { |
|
| 1196 | - $return['company'] = isset( $response['company'] ) ? $response['company'] : ''; |
|
| 1197 | - $return['address'] = isset( $response['address'] ) ? $response['address'] : ''; |
|
| 1195 | + if (is_array($response)) { |
|
| 1196 | + $return['company'] = isset($response['company']) ? $response['company'] : ''; |
|
| 1197 | + $return['address'] = isset($response['address']) ? $response['address'] : ''; |
|
| 1198 | 1198 | $return['message'] = $return['company'] . '<br/>' . $return['address']; |
| 1199 | 1199 | } |
| 1200 | 1200 | } else { |
| 1201 | 1201 | $return['valid'] = false; |
| 1202 | - $return['message'] = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
| 1202 | + $return['message'] = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | return $return; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - public static function request_euvatrates( $group ) { |
|
| 1208 | + public static function request_euvatrates($group) { |
|
| 1209 | 1209 | $response = array(); |
| 1210 | 1210 | $response['success'] = false; |
| 1211 | 1211 | $response['error'] = null; |
| 1212 | 1212 | $response['eurates'] = null; |
| 1213 | 1213 | |
| 1214 | 1214 | $euvatrates_url = 'https://euvatrates.com/rates.json'; |
| 1215 | - $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url ); |
|
| 1216 | - $api_response = wp_remote_get( $euvatrates_url ); |
|
| 1215 | + $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url); |
|
| 1216 | + $api_response = wp_remote_get($euvatrates_url); |
|
| 1217 | 1217 | |
| 1218 | 1218 | try { |
| 1219 | - if ( is_wp_error( $api_response ) ) { |
|
| 1220 | - $response['error'] = __( $api_response->get_error_message(), 'invoicing' ); |
|
| 1219 | + if (is_wp_error($api_response)) { |
|
| 1220 | + $response['error'] = __($api_response->get_error_message(), 'invoicing'); |
|
| 1221 | 1221 | } else { |
| 1222 | - $body = json_decode( $api_response['body'] ); |
|
| 1223 | - if ( isset( $body->rates ) ) { |
|
| 1222 | + $body = json_decode($api_response['body']); |
|
| 1223 | + if (isset($body->rates)) { |
|
| 1224 | 1224 | $rates = array(); |
| 1225 | 1225 | |
| 1226 | - foreach ( $body->rates as $country_code => $rate ) { |
|
| 1226 | + foreach ($body->rates as $country_code => $rate) { |
|
| 1227 | 1227 | $vat_rate = array(); |
| 1228 | 1228 | $vat_rate['country'] = $rate->country; |
| 1229 | - $vat_rate['standard'] = (float)$rate->standard_rate; |
|
| 1230 | - $vat_rate['reduced'] = (float)$rate->reduced_rate; |
|
| 1231 | - $vat_rate['superreduced'] = (float)$rate->super_reduced_rate; |
|
| 1232 | - $vat_rate['parking'] = (float)$rate->parking_rate; |
|
| 1229 | + $vat_rate['standard'] = (float) $rate->standard_rate; |
|
| 1230 | + $vat_rate['reduced'] = (float) $rate->reduced_rate; |
|
| 1231 | + $vat_rate['superreduced'] = (float) $rate->super_reduced_rate; |
|
| 1232 | + $vat_rate['parking'] = (float) $rate->parking_rate; |
|
| 1233 | 1233 | |
| 1234 | - if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) { |
|
| 1234 | + if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) { |
|
| 1235 | 1235 | $vat_rate_group = array(); |
| 1236 | 1236 | $vat_rate_group['country'] = $rate->country; |
| 1237 | 1237 | $vat_rate_group[$group] = $vat_rate[$group]; |
@@ -1243,79 +1243,79 @@ discard block |
||
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | $response['success'] = true; |
| 1246 | - $response['rates'] = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group ); |
|
| 1246 | + $response['rates'] = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group); |
|
| 1247 | 1247 | } else { |
| 1248 | - $response['error'] = __( 'No EU rates found!', 'invoicing' ); |
|
| 1248 | + $response['error'] = __('No EU rates found!', 'invoicing'); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | } |
| 1251 | - } catch ( Exception $e ) { |
|
| 1252 | - $response['error'] = __( $e->getMessage(), 'invoicing' ); |
|
| 1251 | + } catch (Exception $e) { |
|
| 1252 | + $response['error'] = __($e->getMessage(), 'invoicing'); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | - return apply_filters( 'wpinv_response_euvatrates', $response, $group ); |
|
| 1255 | + return apply_filters('wpinv_response_euvatrates', $response, $group); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) { |
|
| 1258 | + public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) { |
|
| 1259 | 1259 | global $wpi_item_id, $wpi_country; |
| 1260 | 1260 | |
| 1261 | - if ( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1262 | - $country_code = trim( $_POST['wpinv_country'] ); |
|
| 1263 | - } else if ( !empty( $_POST['country'] ) ) { |
|
| 1264 | - $country_code = trim( $_POST['country'] ); |
|
| 1265 | - } else if ( !empty( $wpi_country ) ) { |
|
| 1261 | + if (!empty($_POST['wpinv_country'])) { |
|
| 1262 | + $country_code = trim($_POST['wpinv_country']); |
|
| 1263 | + } else if (!empty($_POST['country'])) { |
|
| 1264 | + $country_code = trim($_POST['country']); |
|
| 1265 | + } else if (!empty($wpi_country)) { |
|
| 1266 | 1266 | $country_code = $wpi_country; |
| 1267 | 1267 | } else { |
| 1268 | - $country_code = self::get_user_country( '', $user_id ); |
|
| 1268 | + $country_code = self::get_user_country('', $user_id); |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | - if ( $is_digital === null && $wpi_item_id ) { |
|
| 1272 | - $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules(); |
|
| 1271 | + if ($is_digital === null && $wpi_item_id) { |
|
| 1272 | + $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules(); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | - if ( !empty( $country_code ) ) { |
|
| 1276 | - $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( wpinv_get_default_country() ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( wpinv_get_default_country() ) ); |
|
| 1275 | + if (!empty($country_code)) { |
|
| 1276 | + $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(wpinv_get_default_country()) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(wpinv_get_default_country())); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | - return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id ); |
|
| 1279 | + return apply_filters('wpinv_requires_vat', $requires_vat, $user_id); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | - public static function tax_label( $label = '' ) { |
|
| 1282 | + public static function tax_label($label = '') { |
|
| 1283 | 1283 | global $wpi_requires_vat; |
| 1284 | 1284 | |
| 1285 | - if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) { |
|
| 1286 | - $wpi_requires_vat = self::requires_vat( 0, false ); |
|
| 1285 | + if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) { |
|
| 1286 | + $wpi_requires_vat = self::requires_vat(0, false); |
|
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | - return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) ); |
|
| 1289 | + return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing')); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | public static function standard_rates_label() { |
| 1293 | - return __( 'Standard Rates', 'invoicing' ); |
|
| 1293 | + return __('Standard Rates', 'invoicing'); |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | - public static function get_rate_classes( $with_desc = false ) { |
|
| 1297 | - $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true ); |
|
| 1298 | - $classes = maybe_unserialize( $rate_classes_option ); |
|
| 1296 | + public static function get_rate_classes($with_desc = false) { |
|
| 1297 | + $rate_classes_option = get_option('_wpinv_vat_rate_classes', true); |
|
| 1298 | + $classes = maybe_unserialize($rate_classes_option); |
|
| 1299 | 1299 | |
| 1300 | - if ( empty( $classes ) || !is_array( $classes ) ) { |
|
| 1300 | + if (empty($classes) || !is_array($classes)) { |
|
| 1301 | 1301 | $classes = array(); |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | $rate_classes = array(); |
| 1305 | - if ( !array_key_exists( '_standard', $classes ) ) { |
|
| 1306 | - if ( $with_desc ) { |
|
| 1307 | - $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) ); |
|
| 1305 | + if (!array_key_exists('_standard', $classes)) { |
|
| 1306 | + if ($with_desc) { |
|
| 1307 | + $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing')); |
|
| 1308 | 1308 | } else { |
| 1309 | 1309 | $rate_classes['_standard'] = self::standard_rates_label(); |
| 1310 | 1310 | } |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | - foreach ( $classes as $key => $class ) { |
|
| 1314 | - $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key; |
|
| 1315 | - $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : ''; |
|
| 1313 | + foreach ($classes as $key => $class) { |
|
| 1314 | + $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key; |
|
| 1315 | + $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : ''; |
|
| 1316 | 1316 | |
| 1317 | - if ( $with_desc ) { |
|
| 1318 | - $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc ); |
|
| 1317 | + if ($with_desc) { |
|
| 1318 | + $rate_classes[$key] = array('name' => $name, 'desc' => $desc); |
|
| 1319 | 1319 | } else { |
| 1320 | 1320 | $rate_classes[$key] = $name; |
| 1321 | 1321 | } |
@@ -1326,15 +1326,15 @@ discard block |
||
| 1326 | 1326 | |
| 1327 | 1327 | public static function get_all_classes() { |
| 1328 | 1328 | $classes = self::get_rate_classes(); |
| 1329 | - $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' ); |
|
| 1329 | + $classes['_exempt'] = __('Exempt (0%)', 'invoicing'); |
|
| 1330 | 1330 | |
| 1331 | - return apply_filters( 'wpinv_vat_get_all_classes', $classes ); |
|
| 1331 | + return apply_filters('wpinv_vat_get_all_classes', $classes); |
|
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | - public static function get_class_desc( $rate_class ) { |
|
| 1335 | - $rate_classes = self::get_rate_classes( true ); |
|
| 1334 | + public static function get_class_desc($rate_class) { |
|
| 1335 | + $rate_classes = self::get_rate_classes(true); |
|
| 1336 | 1336 | |
| 1337 | - if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) { |
|
| 1337 | + if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) { |
|
| 1338 | 1338 | return $rate_classes[$rate_class]['desc']; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
@@ -1350,107 +1350,107 @@ discard block |
||
| 1350 | 1350 | 'increased' => 'Increased' |
| 1351 | 1351 | ); |
| 1352 | 1352 | |
| 1353 | - return apply_filters( 'wpinv_get_vat_groups', $vat_groups ); |
|
| 1353 | + return apply_filters('wpinv_get_vat_groups', $vat_groups); |
|
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | public static function get_rules() { |
| 1357 | 1357 | $vat_rules = array( |
| 1358 | - 'digital' => __( 'Digital Product', 'invoicing' ), |
|
| 1359 | - 'physical' => __( 'Physical Product', 'invoicing' ), |
|
| 1360 | - '_exempt' => __( 'Tax-Free Product', 'invoicing' ), |
|
| 1358 | + 'digital' => __('Digital Product', 'invoicing'), |
|
| 1359 | + 'physical' => __('Physical Product', 'invoicing'), |
|
| 1360 | + '_exempt' => __('Tax-Free Product', 'invoicing'), |
|
| 1361 | 1361 | ); |
| 1362 | - return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
| 1362 | + return apply_filters('wpinv_get_vat_rules', $vat_rules); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - public static function get_vat_rates( $class ) { |
|
| 1366 | - if ( $class === '_standard' ) { |
|
| 1365 | + public static function get_vat_rates($class) { |
|
| 1366 | + if ($class === '_standard') { |
|
| 1367 | 1367 | return wpinv_get_tax_rates(); |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | $rates = self::get_non_standard_rates(); |
| 1371 | 1371 | |
| 1372 | - return array_key_exists( $class, $rates ) ? $rates[$class] : array(); |
|
| 1372 | + return array_key_exists($class, $rates) ? $rates[$class] : array(); |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | public static function get_non_standard_rates() { |
| 1376 | - $option = get_option( 'wpinv_vat_rates', array()); |
|
| 1377 | - return is_array( $option ) ? $option : array(); |
|
| 1376 | + $option = get_option('wpinv_vat_rates', array()); |
|
| 1377 | + return is_array($option) ? $option : array(); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | public static function allow_vat_rules() { |
| 1381 | - return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false ); |
|
| 1381 | + return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | public static function allow_vat_classes() { |
| 1385 | 1385 | return false; // TODO |
| 1386 | - return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false ); |
|
| 1386 | + return (wpinv_get_option('vat_allow_classes') ? true : false); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | - public static function get_item_class( $postID ) { |
|
| 1390 | - $class = get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
| 1389 | + public static function get_item_class($postID) { |
|
| 1390 | + $class = get_post_meta($postID, '_wpinv_vat_class', true); |
|
| 1391 | 1391 | |
| 1392 | - if ( empty( $class ) ) { |
|
| 1392 | + if (empty($class)) { |
|
| 1393 | 1393 | $class = '_standard'; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | - return apply_filters( 'wpinv_get_item_vat_class', $class, $postID ); |
|
| 1396 | + return apply_filters('wpinv_get_item_vat_class', $class, $postID); |
|
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | - public static function item_class_label( $postID ) { |
|
| 1399 | + public static function item_class_label($postID) { |
|
| 1400 | 1400 | $vat_classes = self::get_all_classes(); |
| 1401 | 1401 | |
| 1402 | - $class = self::get_item_class( $postID ); |
|
| 1403 | - $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' ); |
|
| 1402 | + $class = self::get_item_class($postID); |
|
| 1403 | + $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing'); |
|
| 1404 | 1404 | |
| 1405 | - return apply_filters( 'wpinv_item_class_label', $class, $postID ); |
|
| 1405 | + return apply_filters('wpinv_item_class_label', $class, $postID); |
|
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | - public static function get_item_rule( $postID ) { |
|
| 1409 | - $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
| 1408 | + public static function get_item_rule($postID) { |
|
| 1409 | + $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true); |
|
| 1410 | 1410 | |
| 1411 | - if ( empty( $rule_type ) ) { |
|
| 1411 | + if (empty($rule_type)) { |
|
| 1412 | 1412 | $rule_type = self::allow_vat_rules() ? 'digital' : 'physical'; |
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | - return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID ); |
|
| 1415 | + return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID); |
|
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | - public static function item_rule_label( $postID ) { |
|
| 1418 | + public static function item_rule_label($postID) { |
|
| 1419 | 1419 | $vat_rules = self::get_rules(); |
| 1420 | - $vat_rule = self::get_item_rule( $postID ); |
|
| 1421 | - $vat_rule = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule; |
|
| 1420 | + $vat_rule = self::get_item_rule($postID); |
|
| 1421 | + $vat_rule = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule; |
|
| 1422 | 1422 | |
| 1423 | - return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID ); |
|
| 1423 | + return apply_filters('wpinv_item_rule_label', $vat_rule, $postID); |
|
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | - public static function item_has_digital_rule( $item_id = 0 ) { |
|
| 1427 | - return self::get_item_rule( $item_id ) == 'digital' ? true : false; |
|
| 1426 | + public static function item_has_digital_rule($item_id = 0) { |
|
| 1427 | + return self::get_item_rule($item_id) == 'digital' ? true : false; |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | - public static function invoice_has_digital_rule( $invoice = 0 ) { |
|
| 1431 | - if ( !self::allow_vat_rules() ) { |
|
| 1430 | + public static function invoice_has_digital_rule($invoice = 0) { |
|
| 1431 | + if (!self::allow_vat_rules()) { |
|
| 1432 | 1432 | return false; |
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | - if ( empty( $invoice ) ) { |
|
| 1435 | + if (empty($invoice)) { |
|
| 1436 | 1436 | return true; |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | - if ( is_int( $invoice ) ) { |
|
| 1440 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 1439 | + if (is_int($invoice)) { |
|
| 1440 | + $invoice = new WPInv_Invoice($invoice); |
|
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) { |
|
| 1443 | + if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) { |
|
| 1444 | 1444 | return true; |
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | - $cart_items = $invoice->get_cart_details(); |
|
| 1447 | + $cart_items = $invoice->get_cart_details(); |
|
| 1448 | 1448 | |
| 1449 | - if ( !empty( $cart_items ) ) { |
|
| 1449 | + if (!empty($cart_items)) { |
|
| 1450 | 1450 | $has_digital_rule = false; |
| 1451 | 1451 | |
| 1452 | - foreach ( $cart_items as $key => $item ) { |
|
| 1453 | - if ( self::item_has_digital_rule( $item['id'] ) ) { |
|
| 1452 | + foreach ($cart_items as $key => $item) { |
|
| 1453 | + if (self::item_has_digital_rule($item['id'])) { |
|
| 1454 | 1454 | $has_digital_rule = true; |
| 1455 | 1455 | break; |
| 1456 | 1456 | } |
@@ -1462,71 +1462,71 @@ discard block |
||
| 1462 | 1462 | return $has_digital_rule; |
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | - public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) { |
|
| 1466 | - if ( !wpinv_use_taxes() ) { |
|
| 1465 | + public static function item_is_taxable($item_id = 0, $country = false, $state = false) { |
|
| 1466 | + if (!wpinv_use_taxes()) { |
|
| 1467 | 1467 | return false; |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | 1470 | $is_taxable = true; |
| 1471 | 1471 | |
| 1472 | - if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) { |
|
| 1472 | + if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') { |
|
| 1473 | 1473 | $is_taxable = false; |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | - if ( !empty( $item_id ) && self::get_item_rule( $item_id ) == '_exempt' ) { |
|
| 1476 | + if (!empty($item_id) && self::get_item_rule($item_id) == '_exempt') { |
|
| 1477 | 1477 | $is_taxable = false; |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | - return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state ); |
|
| 1480 | + return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - public static function find_rate( $country, $state, $rate, $class ) { |
|
| 1483 | + public static function find_rate($country, $state, $rate, $class) { |
|
| 1484 | 1484 | global $wpi_zero_tax; |
| 1485 | 1485 | |
| 1486 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
| 1486 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
| 1487 | 1487 | return 0; |
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | - $tax_rates = wpinv_get_tax_rates(); |
|
| 1490 | + $tax_rates = wpinv_get_tax_rates(); |
|
| 1491 | 1491 | |
| 1492 | - if ( $class !== '_standard' ) { |
|
| 1493 | - $class_rates = self::get_vat_rates( $class ); |
|
| 1492 | + if ($class !== '_standard') { |
|
| 1493 | + $class_rates = self::get_vat_rates($class); |
|
| 1494 | 1494 | |
| 1495 | - if ( is_array( $class_rates ) ) { |
|
| 1495 | + if (is_array($class_rates)) { |
|
| 1496 | 1496 | $indexed_class_rates = array(); |
| 1497 | 1497 | |
| 1498 | - foreach ( $class_rates as $key => $cr ) { |
|
| 1498 | + foreach ($class_rates as $key => $cr) { |
|
| 1499 | 1499 | $indexed_class_rates[$cr['country']] = $cr; |
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | - $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) { |
|
| 1502 | + $tax_rates = array_map(function($tr) use($indexed_class_rates) { |
|
| 1503 | 1503 | $tr_country = $tr['country']; |
| 1504 | - if ( !isset( $indexed_class_rates[$tr_country] ) ) { |
|
| 1504 | + if (!isset($indexed_class_rates[$tr_country])) { |
|
| 1505 | 1505 | return $tr; |
| 1506 | 1506 | } |
| 1507 | 1507 | $icr = $indexed_class_rates[$tr_country]; |
| 1508 | - return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr; |
|
| 1508 | + return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr; |
|
| 1509 | 1509 | |
| 1510 | - }, $tax_rates, $class_rates ); |
|
| 1510 | + }, $tax_rates, $class_rates); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | - if ( !empty( $tax_rates ) ) { |
|
| 1515 | - foreach ( $tax_rates as $key => $tax_rate ) { |
|
| 1516 | - if ( $country != $tax_rate['country'] ) |
|
| 1514 | + if (!empty($tax_rates)) { |
|
| 1515 | + foreach ($tax_rates as $key => $tax_rate) { |
|
| 1516 | + if ($country != $tax_rate['country']) |
|
| 1517 | 1517 | continue; |
| 1518 | 1518 | |
| 1519 | - if ( !empty( $tax_rate['global'] ) ) { |
|
| 1520 | - if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
|
| 1521 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
| 1519 | + if (!empty($tax_rate['global'])) { |
|
| 1520 | + if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) { |
|
| 1521 | + $rate = number_format($tax_rate['rate'], 4); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } else { |
| 1524 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 1524 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
| 1525 | 1525 | continue; |
| 1526 | 1526 | |
| 1527 | 1527 | $state_rate = $tax_rate['rate']; |
| 1528 | - if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
| 1529 | - $rate = number_format( $state_rate, 4 ); |
|
| 1528 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
| 1529 | + $rate = number_format($state_rate, 4); |
|
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
@@ -1535,84 +1535,84 @@ discard block |
||
| 1535 | 1535 | return $rate; |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | - public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) { |
|
| 1538 | + public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) { |
|
| 1539 | 1539 | global $wpinv_options, $wpi_item_id, $wpi_zero_tax; |
| 1540 | 1540 | |
| 1541 | 1541 | $item_id = $item_id > 0 ? $item_id : $wpi_item_id; |
| 1542 | 1542 | $allow_vat_classes = self::allow_vat_classes(); |
| 1543 | - $class = $item_id ? self::get_item_class( $item_id ) : '_standard'; |
|
| 1543 | + $class = $item_id ? self::get_item_class($item_id) : '_standard'; |
|
| 1544 | 1544 | |
| 1545 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
| 1545 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
| 1546 | 1546 | return 0; |
| 1547 | - } else if ( !$allow_vat_classes ) { |
|
| 1547 | + } else if (!$allow_vat_classes) { |
|
| 1548 | 1548 | $class = '_standard'; |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1551 | + if (!empty($_POST['wpinv_country'])) { |
|
| 1552 | 1552 | $post_country = $_POST['wpinv_country']; |
| 1553 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1553 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
| 1554 | 1554 | $post_country = $_POST['wpinv_country']; |
| 1555 | - } elseif( !empty( $_POST['country'] ) ) { |
|
| 1555 | + } elseif (!empty($_POST['country'])) { |
|
| 1556 | 1556 | $post_country = $_POST['country']; |
| 1557 | 1557 | } else { |
| 1558 | 1558 | $post_country = ''; |
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | - $country = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country ); |
|
| 1562 | - $base_country = wpinv_is_base_country( $country ); |
|
| 1561 | + $country = !empty($post_country) ? $post_country : wpinv_default_billing_country($country); |
|
| 1562 | + $base_country = wpinv_is_base_country($country); |
|
| 1563 | 1563 | |
| 1564 | - $requires_vat = self::requires_vat( 0, false ); |
|
| 1565 | - $is_digital = self::get_item_rule( $item_id ) == 'digital' ; |
|
| 1566 | - $rate = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
| 1564 | + $requires_vat = self::requires_vat(0, false); |
|
| 1565 | + $is_digital = self::get_item_rule($item_id) == 'digital'; |
|
| 1566 | + $rate = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
| 1567 | 1567 | |
| 1568 | - if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country |
|
| 1568 | + if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country |
|
| 1569 | 1569 | $rate = 0; |
| 1570 | - } else if ( $requires_vat ) { |
|
| 1571 | - $vat_number = self::get_user_vat_number( '', 0, true ); |
|
| 1570 | + } else if ($requires_vat) { |
|
| 1571 | + $vat_number = self::get_user_vat_number('', 0, true); |
|
| 1572 | 1572 | $vat_info = self::current_vat_data(); |
| 1573 | 1573 | |
| 1574 | - if ( is_array( $vat_info ) ) { |
|
| 1575 | - $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : ""; |
|
| 1574 | + if (is_array($vat_info)) { |
|
| 1575 | + $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : ""; |
|
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | - if ( $country == 'UK' ) { |
|
| 1578 | + if ($country == 'UK') { |
|
| 1579 | 1579 | $country = 'GB'; |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - if ( !empty( $vat_number ) ) { |
|
| 1582 | + if (!empty($vat_number)) { |
|
| 1583 | 1583 | $rate = 0; |
| 1584 | 1584 | } else { |
| 1585 | - $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
| 1585 | + $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | - if ( empty( $vat_number ) && !$is_digital ) { |
|
| 1589 | - if ( $base_country ) { |
|
| 1590 | - $rate = self::find_rate( $country, null, $rate, $class ); |
|
| 1588 | + if (empty($vat_number) && !$is_digital) { |
|
| 1589 | + if ($base_country) { |
|
| 1590 | + $rate = self::find_rate($country, null, $rate, $class); |
|
| 1591 | 1591 | } else { |
| 1592 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
| 1592 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
| 1593 | 1593 | $rate = $wpinv_options['eu_fallback_rate']; |
| 1594 | - } else if( !empty( $country ) ) { |
|
| 1595 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1594 | + } else if (!empty($country)) { |
|
| 1595 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1596 | 1596 | } |
| 1597 | 1597 | } |
| 1598 | - } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) { |
|
| 1599 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
| 1598 | + } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) { |
|
| 1599 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
| 1600 | 1600 | $rate = $wpinv_options['eu_fallback_rate']; |
| 1601 | - } else if( !empty( $country ) ) { |
|
| 1602 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1601 | + } else if (!empty($country)) { |
|
| 1602 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1603 | 1603 | } |
| 1604 | 1604 | } |
| 1605 | 1605 | } else { |
| 1606 | - if ( $is_digital ) { |
|
| 1606 | + if ($is_digital) { |
|
| 1607 | 1607 | $ip_country_code = self::get_country_by_ip(); |
| 1608 | 1608 | |
| 1609 | - if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) { |
|
| 1610 | - $rate = self::find_rate( $ip_country_code, '', 0, $class ); |
|
| 1609 | + if ($ip_country_code && self::is_eu_state($ip_country_code)) { |
|
| 1610 | + $rate = self::find_rate($ip_country_code, '', 0, $class); |
|
| 1611 | 1611 | } else { |
| 1612 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1612 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1613 | 1613 | } |
| 1614 | 1614 | } else { |
| 1615 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1615 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | } |
| 1618 | 1618 | |
@@ -1620,48 +1620,48 @@ discard block |
||
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | public static function current_vat_data() { |
| 1623 | - return getpaid_session()->get( 'user_vat_data' ); |
|
| 1623 | + return getpaid_session()->get('user_vat_data'); |
|
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | - public static function get_user_country( $country = '', $user_id = 0 ) { |
|
| 1627 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
| 1626 | + public static function get_user_country($country = '', $user_id = 0) { |
|
| 1627 | + $user_address = wpinv_get_user_address($user_id, false); |
|
| 1628 | 1628 | |
| 1629 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
| 1629 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
| 1630 | 1630 | $country = ''; |
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | - $country = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country']; |
|
| 1634 | - $result = apply_filters( 'wpinv_get_user_country', $country, $user_id ); |
|
| 1633 | + $country = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country']; |
|
| 1634 | + $result = apply_filters('wpinv_get_user_country', $country, $user_id); |
|
| 1635 | 1635 | |
| 1636 | - if ( empty( $result ) ) { |
|
| 1636 | + if (empty($result)) { |
|
| 1637 | 1637 | $result = self::get_country_by_ip(); |
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | 1640 | return $result; |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | - public static function set_user_country( $country = '', $user_id = 0 ) { |
|
| 1643 | + public static function set_user_country($country = '', $user_id = 0) { |
|
| 1644 | 1644 | global $wpi_userID; |
| 1645 | 1645 | |
| 1646 | - if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) { |
|
| 1646 | + if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) { |
|
| 1647 | 1647 | $country = wpinv_get_default_country(); |
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | 1650 | return $country; |
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | - public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) { |
|
| 1653 | + public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) { |
|
| 1654 | 1654 | global $wpi_current_id, $wpi_userID; |
| 1655 | 1655 | |
| 1656 | - if ( !empty( $_POST['new_user'] ) ) { |
|
| 1656 | + if (!empty($_POST['new_user'])) { |
|
| 1657 | 1657 | return ''; |
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | - if ( empty( $user_id ) ) { |
|
| 1661 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
| 1660 | + if (empty($user_id)) { |
|
| 1661 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | - $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true ); |
|
| 1664 | + $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true); |
|
| 1665 | 1665 | |
| 1666 | 1666 | /* TODO |
| 1667 | 1667 | if ( $is_valid && $vat_number ) { |
@@ -1672,38 +1672,38 @@ discard block |
||
| 1672 | 1672 | } |
| 1673 | 1673 | */ |
| 1674 | 1674 | |
| 1675 | - return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid ); |
|
| 1675 | + return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid); |
|
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | - public static function get_user_company( $company = '', $user_id = 0 ) { |
|
| 1678 | + public static function get_user_company($company = '', $user_id = 0) { |
|
| 1679 | 1679 | global $wpi_current_id, $wpi_userID; |
| 1680 | 1680 | |
| 1681 | - if ( empty( $user_id ) ) { |
|
| 1682 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
| 1681 | + if (empty($user_id)) { |
|
| 1682 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
| 1683 | 1683 | } |
| 1684 | 1684 | |
| 1685 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
| 1685 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
| 1686 | 1686 | |
| 1687 | - return apply_filters( 'wpinv_user_company', $company, $user_id ); |
|
| 1687 | + return apply_filters('wpinv_user_company', $company, $user_id); |
|
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - public static function save_user_vat_details( $company = '', $vat_number = '' ) { |
|
| 1691 | - $save = apply_filters( 'wpinv_allow_save_user_vat_details', true ); |
|
| 1690 | + public static function save_user_vat_details($company = '', $vat_number = '') { |
|
| 1691 | + $save = apply_filters('wpinv_allow_save_user_vat_details', true); |
|
| 1692 | 1692 | |
| 1693 | - if ( is_user_logged_in() && $save ) { |
|
| 1693 | + if (is_user_logged_in() && $save) { |
|
| 1694 | 1694 | $user_id = get_current_user_id(); |
| 1695 | 1695 | |
| 1696 | - if ( !empty( $vat_number ) ) { |
|
| 1697 | - update_user_meta( $user_id, '_wpinv_vat_number', $vat_number ); |
|
| 1696 | + if (!empty($vat_number)) { |
|
| 1697 | + update_user_meta($user_id, '_wpinv_vat_number', $vat_number); |
|
| 1698 | 1698 | } else { |
| 1699 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
| 1699 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | - if ( !empty( $company ) ) { |
|
| 1703 | - update_user_meta( $user_id, '_wpinv_company', $company ); |
|
| 1702 | + if (!empty($company)) { |
|
| 1703 | + update_user_meta($user_id, '_wpinv_company', $company); |
|
| 1704 | 1704 | } else { |
| 1705 | - delete_user_meta( $user_id, '_wpinv_company'); |
|
| 1706 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
| 1705 | + delete_user_meta($user_id, '_wpinv_company'); |
|
| 1706 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | |
@@ -1713,113 +1713,113 @@ discard block |
||
| 1713 | 1713 | public static function ajax_vat_validate() { |
| 1714 | 1714 | global $wpinv_options; |
| 1715 | 1715 | |
| 1716 | - $is_checkout = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false; |
|
| 1716 | + $is_checkout = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false; |
|
| 1717 | 1717 | $response = array(); |
| 1718 | 1718 | $response['success'] = false; |
| 1719 | 1719 | |
| 1720 | - if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) { |
|
| 1721 | - $response['error'] = __( 'Invalid security nonce', 'invoicing' ); |
|
| 1722 | - wp_send_json( $response ); |
|
| 1720 | + if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) { |
|
| 1721 | + $response['error'] = __('Invalid security nonce', 'invoicing'); |
|
| 1722 | + wp_send_json($response); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | - $vat_name = self::get_vat_name(); |
|
| 1725 | + $vat_name = self::get_vat_name(); |
|
| 1726 | 1726 | |
| 1727 | - if ( $is_checkout ) { |
|
| 1727 | + if ($is_checkout) { |
|
| 1728 | 1728 | $invoice = wpinv_get_invoice_cart(); |
| 1729 | 1729 | |
| 1730 | - if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) { |
|
| 1730 | + if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) { |
|
| 1731 | 1731 | $vat_info = array(); |
| 1732 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1732 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1733 | 1733 | |
| 1734 | 1734 | self::save_user_vat_details(); |
| 1735 | 1735 | |
| 1736 | 1736 | $response['success'] = true; |
| 1737 | - $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name ); |
|
| 1738 | - wp_send_json( $response ); |
|
| 1737 | + $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name); |
|
| 1738 | + wp_send_json($response); |
|
| 1739 | 1739 | } |
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | - $company = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : ''; |
|
| 1743 | - $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : ''; |
|
| 1742 | + $company = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : ''; |
|
| 1743 | + $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : ''; |
|
| 1744 | 1744 | |
| 1745 | - $vat_info = getpaid_session()->get( 'user_vat_data' ); |
|
| 1746 | - if ( !is_array( $vat_info ) || empty( $vat_info ) ) { |
|
| 1747 | - $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true ); |
|
| 1745 | + $vat_info = getpaid_session()->get('user_vat_data'); |
|
| 1746 | + if (!is_array($vat_info) || empty($vat_info)) { |
|
| 1747 | + $vat_info = array('company'=> $company, 'number' => '', 'valid' => true); |
|
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | - if ( empty( $vat_number ) ) { |
|
| 1751 | - if ( $is_checkout ) { |
|
| 1750 | + if (empty($vat_number)) { |
|
| 1751 | + if ($is_checkout) { |
|
| 1752 | 1752 | $response['success'] = true; |
| 1753 | - $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name ); |
|
| 1753 | + $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name); |
|
| 1754 | 1754 | |
| 1755 | - $vat_info = getpaid_session()->get( 'user_vat_data' ); |
|
| 1755 | + $vat_info = getpaid_session()->get('user_vat_data'); |
|
| 1756 | 1756 | $vat_info['number'] = ""; |
| 1757 | 1757 | $vat_info['valid'] = true; |
| 1758 | 1758 | |
| 1759 | - self::save_user_vat_details( $company ); |
|
| 1759 | + self::save_user_vat_details($company); |
|
| 1760 | 1760 | } else { |
| 1761 | - $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
| 1761 | + $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
| 1762 | 1762 | |
| 1763 | 1763 | $vat_info['valid'] = false; |
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1767 | - wp_send_json( $response ); |
|
| 1766 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1767 | + wp_send_json($response); |
|
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | - if ( empty( $company ) ) { |
|
| 1770 | + if (empty($company)) { |
|
| 1771 | 1771 | $vat_info['valid'] = false; |
| 1772 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1772 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1773 | 1773 | |
| 1774 | - $response['error'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
| 1775 | - wp_send_json( $response ); |
|
| 1774 | + $response['error'] = __('Please enter your registered company name!', 'invoicing'); |
|
| 1775 | + wp_send_json($response); |
|
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 1779 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
| 1778 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 1779 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
| 1780 | 1780 | $vat_info['valid'] = false; |
| 1781 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1781 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1782 | 1782 | |
| 1783 | - $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 1784 | - wp_send_json( $response ); |
|
| 1783 | + $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 1784 | + wp_send_json($response); |
|
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | $response['success'] = true; |
| 1788 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 1788 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 1789 | 1789 | } else { |
| 1790 | - $result = self::check_vat( $vat_number ); |
|
| 1790 | + $result = self::check_vat($vat_number); |
|
| 1791 | 1791 | |
| 1792 | - if ( empty( $result['valid'] ) ) { |
|
| 1792 | + if (empty($result['valid'])) { |
|
| 1793 | 1793 | $response['error'] = $result['message']; |
| 1794 | - wp_send_json( $response ); |
|
| 1794 | + wp_send_json($response); |
|
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
| 1798 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
| 1797 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
| 1798 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
| 1799 | 1799 | |
| 1800 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
| 1800 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
| 1801 | 1801 | |
| 1802 | - if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) { |
|
| 1802 | + if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) { |
|
| 1803 | 1803 | $response['success'] = true; |
| 1804 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 1804 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 1805 | 1805 | } else { |
| 1806 | 1806 | $vat_info['valid'] = false; |
| 1807 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1807 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1808 | 1808 | |
| 1809 | 1809 | $response['success'] = false; |
| 1810 | - $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
| 1811 | - wp_send_json( $response ); |
|
| 1810 | + $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
| 1811 | + wp_send_json($response); |
|
| 1812 | 1812 | } |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | - if ( $is_checkout ) { |
|
| 1816 | - self::save_user_vat_details( $company, $vat_number ); |
|
| 1815 | + if ($is_checkout) { |
|
| 1816 | + self::save_user_vat_details($company, $vat_number); |
|
| 1817 | 1817 | |
| 1818 | - $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true ); |
|
| 1819 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1818 | + $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true); |
|
| 1819 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | - wp_send_json( $response ); |
|
| 1822 | + wp_send_json($response); |
|
| 1823 | 1823 | } |
| 1824 | 1824 | |
| 1825 | 1825 | /** |
@@ -1827,16 +1827,16 @@ discard block |
||
| 1827 | 1827 | * |
| 1828 | 1828 | * @return string |
| 1829 | 1829 | */ |
| 1830 | - public static function validate_vat_number( $vat_number, $company, $country ) { |
|
| 1830 | + public static function validate_vat_number($vat_number, $company, $country) { |
|
| 1831 | 1831 | global $wpinv_options; |
| 1832 | 1832 | |
| 1833 | 1833 | // If we are not checking the vat number via view... |
| 1834 | - if ( ! empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 1834 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 1835 | 1835 | |
| 1836 | 1836 | // Try validating via regex. |
| 1837 | - if ( empty( $wpinv_options['vat_offline_check'] ) && ! self::offline_check( $vat_number, $country ) ) { |
|
| 1837 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number, $country)) { |
|
| 1838 | 1838 | return wp_sprintf( |
| 1839 | - __( 'Your %s number is invalid', 'invoicing' ), |
|
| 1839 | + __('Your %s number is invalid', 'invoicing'), |
|
| 1840 | 1840 | getpaid_vat_name() |
| 1841 | 1841 | ); |
| 1842 | 1842 | } |
@@ -1845,23 +1845,23 @@ discard block |
||
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | 1847 | // Validate the vat number. |
| 1848 | - $result = self::check_vat( $vat_number, $country ); |
|
| 1848 | + $result = self::check_vat($vat_number, $country); |
|
| 1849 | 1849 | |
| 1850 | - if ( empty( $result['valid'] ) ) { |
|
| 1850 | + if (empty($result['valid'])) { |
|
| 1851 | 1851 | return wp_sprintf( |
| 1852 | - __( 'Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing' ), |
|
| 1852 | + __('Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing'), |
|
| 1853 | 1853 | getpaid_vat_name() |
| 1854 | 1854 | ); |
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | // Validate the company. |
| 1858 | - $vies_company = ! empty( $result['company'] ) ? $result['company'] : ''; |
|
| 1859 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
| 1860 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
| 1858 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
| 1859 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
| 1860 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
| 1861 | 1861 | |
| 1862 | - if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) { |
|
| 1862 | + if (!$valid_company && !empty($wpinv_options['vat_disable_company_name_check'])) { |
|
| 1863 | 1863 | return wp_sprintf( |
| 1864 | - __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), |
|
| 1864 | + __('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), |
|
| 1865 | 1865 | getpaid_vat_name() |
| 1866 | 1866 | ); |
| 1867 | 1867 | } |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -if ( empty( $text ) ) { |
|
| 13 | - $text = __( 'Your IP address is:', 'invoicing' ); |
|
| 12 | +if (empty($text)) { |
|
| 13 | + $text = __('Your IP address is:', 'invoicing'); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -$ip_address = sanitize_text_field( wpinv_get_ip() ); |
|
| 17 | -$url = esc_url( getpaid_ip_location_url( $ip_address ) ); |
|
| 16 | +$ip_address = sanitize_text_field(wpinv_get_ip()); |
|
| 17 | +$url = esc_url(getpaid_ip_location_url($ip_address)); |
|
| 18 | 18 | |
| 19 | 19 | ?> |
| 20 | 20 | <div class="form-group getpaid-ip-info"> |
| 21 | - <span><?php echo wp_kses_post( $text ); ?></span> |
|
| 21 | + <span><?php echo wp_kses_post($text); ?></span> |
|
| 22 | 22 | <a target='_blank' href='<?php echo $url; ?>'><?php echo $ip_address; ?> <i class='fa fa-external-link-square' aria-hidden='true'></i></a> |
| 23 | 23 | </div> |