@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | $this->state = wpinv_get_default_state(); |
162 | 162 | |
163 | 163 | // Do we have an actual submission? |
164 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
165 | - $this->load_data( $_POST ); |
|
164 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
165 | + $this->load_data($_POST); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
@@ -171,29 +171,29 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @param array $data |
173 | 173 | */ |
174 | - public function load_data( $data ) { |
|
174 | + public function load_data($data) { |
|
175 | 175 | |
176 | 176 | // Prepare submitted data... |
177 | - $data = wp_unslash( $data ); |
|
177 | + $data = wp_unslash($data); |
|
178 | 178 | |
179 | 179 | // Filter the data. |
180 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
180 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
181 | 181 | |
182 | 182 | $this->data = $data; |
183 | 183 | |
184 | - $this->id = md5( wp_json_encode( $data ) ); |
|
184 | + $this->id = md5(wp_json_encode($data)); |
|
185 | 185 | |
186 | 186 | // Every submission needs an active payment form. |
187 | - if ( empty( $data['form_id'] ) ) { |
|
188 | - $this->last_error = __( 'Missing payment form', 'invoicing' ); |
|
187 | + if (empty($data['form_id'])) { |
|
188 | + $this->last_error = __('Missing payment form', 'invoicing'); |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | 192 | // Fetch the payment form. |
193 | - $form = new GetPaid_Payment_Form( $data['form_id'] ); |
|
193 | + $form = new GetPaid_Payment_Form($data['form_id']); |
|
194 | 194 | |
195 | - if ( ! $form->is_active() ) { |
|
196 | - $this->last_error = __( 'Payment form not active', 'invoicing' ); |
|
195 | + if (!$form->is_active()) { |
|
196 | + $this->last_error = __('Payment form not active', 'invoicing'); |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
@@ -201,37 +201,37 @@ discard block |
||
201 | 201 | $this->payment_form = $form; |
202 | 202 | |
203 | 203 | // For existing invoices, make sure that it is valid. |
204 | - if ( ! empty( $data['invoice_id'] ) ) { |
|
205 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
204 | + if (!empty($data['invoice_id'])) { |
|
205 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
206 | 206 | |
207 | - if ( empty( $invoice ) ) { |
|
208 | - $this->last_error = __( 'Invalid invoice', 'invoicing' ); |
|
207 | + if (empty($invoice)) { |
|
208 | + $this->last_error = __('Invalid invoice', 'invoicing'); |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - if ( $invoice->is_paid() ) { |
|
213 | - $this->last_error = __( 'This invoice is already paid for.', 'invoicing' ); |
|
212 | + if ($invoice->is_paid()) { |
|
213 | + $this->last_error = __('This invoice is already paid for.', 'invoicing'); |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
217 | + $this->payment_form->set_items($invoice->get_items()); |
|
218 | 218 | |
219 | 219 | $this->country = $invoice->get_country(); |
220 | 220 | $this->state = $invoice->get_state(); |
221 | 221 | $this->invoice = $invoice; |
222 | 222 | |
223 | 223 | // Default forms do not have items. |
224 | - } else if ( $form->is_default() && isset( $data['getpaid-items'] ) ) { |
|
225 | - $this->payment_form->set_items( wpinv_clean( $data['getpaid-items'] ) ); |
|
224 | + } else if ($form->is_default() && isset($data['getpaid-items'])) { |
|
225 | + $this->payment_form->set_items(wpinv_clean($data['getpaid-items'])); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // User's country. |
229 | - if ( ! empty( $data['wpinv_country'] ) ) { |
|
229 | + if (!empty($data['wpinv_country'])) { |
|
230 | 230 | $this->country = $data['wpinv_country']; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // User's state. |
234 | - if ( ! empty( $data['wpinv_state'] ) ) { |
|
234 | + if (!empty($data['wpinv_state'])) { |
|
235 | 235 | $this->country = $data['wpinv_state']; |
236 | 236 | } |
237 | 237 | |
@@ -240,42 +240,42 @@ discard block |
||
240 | 240 | |
241 | 241 | // Handle items. |
242 | 242 | $selected_items = array(); |
243 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
244 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
243 | + if (!empty($data['getpaid-items'])) { |
|
244 | + $selected_items = wpinv_clean($data['getpaid-items']); |
|
245 | 245 | } |
246 | 246 | |
247 | - foreach ( $this->payment_form->get_items() as $item ) { |
|
247 | + foreach ($this->payment_form->get_items() as $item) { |
|
248 | 248 | |
249 | 249 | // Continue if this is an optional item and it has not been selected. |
250 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
250 | + if (!$item->is_required() && !isset($selected_items[$item->get_id()])) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // (maybe) let customers change the quantities and prices. |
255 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
255 | + if (isset($selected_items[$item->get_id()])) { |
|
256 | 256 | |
257 | 257 | // Maybe change the quantities. |
258 | - if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) { |
|
259 | - $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
258 | + if ($item->allows_quantities() && is_numeric($selected_items[$item->get_id()]['quantity'])) { |
|
259 | + $item->set_quantity((int) $selected_items[$item->get_id()]['quantity']); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | // Maybe change the price. |
263 | - if ( $item->user_can_set_their_price() ) { |
|
264 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
263 | + if ($item->user_can_set_their_price()) { |
|
264 | + $price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']); |
|
265 | 265 | |
266 | 266 | // But don't get lower than the minimum price. |
267 | - if ( $price < $item->get_minimum_price() ) { |
|
267 | + if ($price < $item->get_minimum_price()) { |
|
268 | 268 | $price = $item->get_minimum_price(); |
269 | 269 | } |
270 | 270 | |
271 | - $item->set_price( $price ); |
|
271 | + $item->set_price($price); |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Add the item to the form. |
278 | - $this->add_item( $item ); |
|
278 | + $this->add_item($item); |
|
279 | 279 | |
280 | 280 | } |
281 | 281 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $this->maybe_validate_vat(); |
284 | 284 | |
285 | 285 | // Fired when we are done processing a submission. |
286 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
286 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
287 | 287 | |
288 | 288 | // Remove invalid discount. |
289 | 289 | $this->maybe_remove_discount(); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @return bool |
318 | 318 | */ |
319 | 319 | public function has_invoice() { |
320 | - return ! empty( $this->invoice ); |
|
320 | + return !empty($this->invoice); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | public function get_vat_number() { |
330 | 330 | |
331 | 331 | // Retrieve from the posted data. |
332 | - if ( ! empty( $this->data['wpinv_vat_number'] ) ) { |
|
333 | - return wpinv_clean( $this->data['wpinv_vat_number'] ); |
|
332 | + if (!empty($this->data['wpinv_vat_number'])) { |
|
333 | + return wpinv_clean($this->data['wpinv_vat_number']); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // Retrieve from the invoice. |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | public function get_company() { |
347 | 347 | |
348 | 348 | // Retrieve from the posted data. |
349 | - if ( ! empty( $this->data['wpinv_company'] ) ) { |
|
350 | - return wpinv_clean( $this->data['wpinv_company'] ); |
|
349 | + if (!empty($this->data['wpinv_company'])) { |
|
350 | + return wpinv_clean($this->data['wpinv_company']); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | // Retrieve from the invoice. |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @return string |
362 | 362 | */ |
363 | 363 | public function get_currency() { |
364 | - if ( $this->has_invoice() ) { |
|
364 | + if ($this->has_invoice()) { |
|
365 | 365 | return $this->invoice->get_currency(); |
366 | 366 | } |
367 | 367 | return wpinv_get_currency(); |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @since 1.0.19 |
384 | 384 | */ |
385 | - public function is_required_field_set( $field ) { |
|
386 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
385 | + public function is_required_field_set($field) { |
|
386 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | ///////// Items ////////////// |
@@ -394,31 +394,31 @@ discard block |
||
394 | 394 | * @since 1.0.19 |
395 | 395 | * @param GetPaid_Form_Item $item |
396 | 396 | */ |
397 | - public function add_item( $item ) { |
|
397 | + public function add_item($item) { |
|
398 | 398 | |
399 | 399 | // Make sure that it is available for purchase. |
400 | - if ( ! $item->can_purchase() ) { |
|
400 | + if (!$item->can_purchase()) { |
|
401 | 401 | return; |
402 | 402 | } |
403 | 403 | |
404 | 404 | // Do we have a recurring item? |
405 | - if ( $item->is_recurring() ) { |
|
405 | + if ($item->is_recurring()) { |
|
406 | 406 | |
407 | - if ( $this->has_recurring ) { |
|
408 | - $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' ); |
|
407 | + if ($this->has_recurring) { |
|
408 | + $this->last_error = __('You can only buy one recurring item at a time.', 'invoicing'); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | $this->has_recurring = true; |
412 | 412 | |
413 | 413 | } |
414 | 414 | |
415 | - $this->items[ $item->get_id() ] = $item; |
|
415 | + $this->items[$item->get_id()] = $item; |
|
416 | 416 | |
417 | 417 | $this->subtotal_amount += $item->get_sub_total(); |
418 | 418 | |
419 | - $this->process_item_discount( $item ); |
|
419 | + $this->process_item_discount($item); |
|
420 | 420 | |
421 | - $this->process_item_tax( $item ); |
|
421 | + $this->process_item_tax($item); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @since 1.0.19 |
428 | 428 | */ |
429 | - public function get_item( $item_id ) { |
|
430 | - return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null; |
|
429 | + public function get_item($item_id) { |
|
430 | + return isset($this->items[$item_id]) ? $this->items[$item_id] : null; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -447,16 +447,16 @@ discard block |
||
447 | 447 | * |
448 | 448 | * @since 1.0.19 |
449 | 449 | */ |
450 | - public function add_tax( $name, $amount, $recurring = false ) { |
|
451 | - $amount = (float) wpinv_sanitize_amount( $amount ); |
|
450 | + public function add_tax($name, $amount, $recurring = false) { |
|
451 | + $amount = (float) wpinv_sanitize_amount($amount); |
|
452 | 452 | |
453 | 453 | $this->total_tax_amount += $amount; |
454 | 454 | |
455 | - if ( isset( $this->taxes[ $name ] ) ) { |
|
456 | - $amount += $this->taxes[ $name ]['amount']; |
|
455 | + if (isset($this->taxes[$name])) { |
|
456 | + $amount += $this->taxes[$name]['amount']; |
|
457 | 457 | } |
458 | 458 | |
459 | - $this->taxes[ $name ] = compact( 'amount', 'recurring' ); |
|
459 | + $this->taxes[$name] = compact('amount', 'recurring'); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | |
470 | 470 | $use_taxes = wpinv_use_taxes(); |
471 | 471 | |
472 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
472 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
473 | 473 | $use_taxes = false; |
474 | 474 | } |
475 | 475 | |
476 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
476 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
477 | 477 | |
478 | 478 | } |
479 | 479 | |
@@ -483,23 +483,23 @@ discard block |
||
483 | 483 | * @since 1.0.19 |
484 | 484 | * @param GetPaid_Form_Item $item |
485 | 485 | */ |
486 | - public function process_item_tax( $item ) { |
|
486 | + public function process_item_tax($item) { |
|
487 | 487 | |
488 | 488 | // Abort early if we're not using taxes. |
489 | - if ( ! $this->use_taxes() ) { |
|
489 | + if (!$this->use_taxes()) { |
|
490 | 490 | return; |
491 | 491 | } |
492 | 492 | |
493 | - $rate = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() ); |
|
493 | + $rate = wpinv_get_tax_rate($this->country, $this->state, $item->get_id()); |
|
494 | 494 | $price = $item->get_sub_total(); |
495 | 495 | |
496 | - if ( wpinv_prices_include_tax() ) { |
|
497 | - $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
496 | + if (wpinv_prices_include_tax()) { |
|
497 | + $item_tax = $price - ($price - $price * $rate * 0.01); |
|
498 | 498 | } else { |
499 | 499 | $item_tax = $price * $rate * 0.01; |
500 | 500 | } |
501 | 501 | |
502 | - $this->add_tax( 'Tax', $item_tax ); |
|
502 | + $this->add_tax('Tax', $item_tax); |
|
503 | 503 | |
504 | 504 | } |
505 | 505 | |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @since 1.0.19 |
519 | 519 | */ |
520 | - public function get_tax( $name ) { |
|
521 | - return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ]['amount'] : 0; |
|
520 | + public function get_tax($name) { |
|
521 | + return isset($this->taxes[$name]) ? $this->taxes[$name]['amount'] : 0; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -537,16 +537,16 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @since 1.0.19 |
539 | 539 | */ |
540 | - public function add_discount( $name, $amount, $recurring = false ) { |
|
541 | - $amount = wpinv_sanitize_amount( $amount ); |
|
540 | + public function add_discount($name, $amount, $recurring = false) { |
|
541 | + $amount = wpinv_sanitize_amount($amount); |
|
542 | 542 | |
543 | 543 | $this->total_discount_amount += $amount; |
544 | 544 | |
545 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
546 | - $amount += $this->discounts[ $name ]['amount']; |
|
545 | + if (isset($this->discounts[$name])) { |
|
546 | + $amount += $this->discounts[$name]['amount']; |
|
547 | 547 | } |
548 | 548 | |
549 | - $this->discounts[ $name ] = compact( 'amount', 'recurring' ); |
|
549 | + $this->discounts[$name] = compact('amount', 'recurring'); |
|
550 | 550 | |
551 | 551 | } |
552 | 552 | |
@@ -555,11 +555,11 @@ discard block |
||
555 | 555 | * |
556 | 556 | * @since 1.0.19 |
557 | 557 | */ |
558 | - public function remove_discount( $name ) { |
|
558 | + public function remove_discount($name) { |
|
559 | 559 | |
560 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
561 | - $this->total_discount_amount -= $this->discounts[ $name ]['amount']; |
|
562 | - unset( $this->discounts[ $name ] ); |
|
560 | + if (isset($this->discounts[$name])) { |
|
561 | + $this->total_discount_amount -= $this->discounts[$name]['amount']; |
|
562 | + unset($this->discounts[$name]); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * @return bool |
572 | 572 | */ |
573 | 573 | public function has_discount_code() { |
574 | - return ! empty( $this->discount ); |
|
574 | + return !empty($this->discount); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -592,32 +592,32 @@ discard block |
||
592 | 592 | public function maybe_prepare_discount() { |
593 | 593 | |
594 | 594 | // Do we have a discount? |
595 | - if ( empty( $this->data['discount'] ) ) { |
|
595 | + if (empty($this->data['discount'])) { |
|
596 | 596 | return; |
597 | 597 | } |
598 | 598 | |
599 | 599 | // Fetch the discount. |
600 | - $discount = wpinv_get_discount_obj( $this->data['discount'] ); |
|
600 | + $discount = wpinv_get_discount_obj($this->data['discount']); |
|
601 | 601 | |
602 | 602 | // Ensure it is active. |
603 | - if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) { |
|
603 | + if (!$discount->exists() || !$discount->is_active() || !$discount->has_started() || $discount->is_expired()) { |
|
604 | 604 | $this->is_discount_valid = false; |
605 | - $this->last_error = __( 'Invalid or expired discount code', 'invoicing' ); |
|
605 | + $this->last_error = __('Invalid or expired discount code', 'invoicing'); |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | |
609 | 609 | // For single use discounts... |
610 | - if ( $discount->is_single_use ) { |
|
610 | + if ($discount->is_single_use) { |
|
611 | 611 | |
612 | - if ( ! $this->has_billing_email() ) { |
|
612 | + if (!$this->has_billing_email()) { |
|
613 | 613 | $this->is_discount_valid = false; |
614 | - $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' ); |
|
614 | + $this->last_error = __('You need to enter your billing email before applying this discount', 'invoicing'); |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 | |
618 | - if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) { |
|
618 | + if (!$discount->is_valid_for_user($this->get_billing_email())) { |
|
619 | 619 | $this->is_discount_valid = false; |
620 | - $this->last_error = __( 'You have already used this discount', 'invoicing' ); |
|
620 | + $this->last_error = __('You have already used this discount', 'invoicing'); |
|
621 | 621 | return; |
622 | 622 | } |
623 | 623 | |
@@ -636,35 +636,35 @@ discard block |
||
636 | 636 | public function maybe_remove_discount() { |
637 | 637 | |
638 | 638 | // Do we have a discount? |
639 | - if ( empty( $this->has_discount_code() ) ) { |
|
639 | + if (empty($this->has_discount_code())) { |
|
640 | 640 | return; |
641 | 641 | } |
642 | 642 | |
643 | 643 | // Fetch the discount amount. |
644 | - $amount = $this->get_discount( 'Discount' ); |
|
644 | + $amount = $this->get_discount('Discount'); |
|
645 | 645 | |
646 | 646 | // Abort early if this is a "zero" discount. |
647 | - if ( empty( $amount ) ) { |
|
647 | + if (empty($amount)) { |
|
648 | 648 | return; |
649 | 649 | } |
650 | 650 | |
651 | 651 | $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax(); |
652 | 652 | |
653 | - if ( ! $this->discount->is_minimum_amount_met( $total ) ) { |
|
653 | + if (!$this->discount->is_minimum_amount_met($total)) { |
|
654 | 654 | $this->is_discount_valid = false; |
655 | - $min = wpinv_price( wpinv_format_amount( $$this->discount->min_total ) ); |
|
656 | - $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ); |
|
655 | + $min = wpinv_price(wpinv_format_amount($$this->discount->min_total)); |
|
656 | + $this->last_error = sprintf(__('The minimum total for using this discount is %s', 'invoicing'), $min); |
|
657 | 657 | } |
658 | 658 | |
659 | - if ( ! $this->discount->is_maximum_amount_met( $total ) ) { |
|
659 | + if (!$this->discount->is_maximum_amount_met($total)) { |
|
660 | 660 | $this->is_discount_valid = false; |
661 | - $max = wpinv_price( wpinv_format_amount( $$this->discount->max_total ) ); |
|
662 | - $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ); |
|
661 | + $max = wpinv_price(wpinv_format_amount($$this->discount->max_total)); |
|
662 | + $this->last_error = sprintf(__('The maximum total for using this discount is %s', 'invoicing'), $max); |
|
663 | 663 | } |
664 | 664 | |
665 | - if ( ! $this->is_discount_valid ) { |
|
665 | + if (!$this->is_discount_valid) { |
|
666 | 666 | $this->discount = null; |
667 | - $this->remove_discount( 'Discount' ); |
|
667 | + $this->remove_discount('Discount'); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | } |
@@ -675,22 +675,22 @@ discard block |
||
675 | 675 | * @since 1.0.19 |
676 | 676 | * @param GetPaid_Form_Item $item |
677 | 677 | */ |
678 | - public function process_item_discount( $item ) { |
|
678 | + public function process_item_discount($item) { |
|
679 | 679 | |
680 | 680 | // Abort early if there is no discount. |
681 | - if ( ! $this->has_discount_code() ) { |
|
681 | + if (!$this->has_discount_code()) { |
|
682 | 682 | return; |
683 | 683 | } |
684 | 684 | |
685 | 685 | // Ensure that it is valid for this item. |
686 | - if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
686 | + if (!$this->discount->is_valid_for_items(array($item->get_id()))) { |
|
687 | 687 | return; |
688 | 688 | } |
689 | 689 | |
690 | 690 | // Fetch the discounted amount. |
691 | - $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() ); |
|
691 | + $discount = $this->discount->get_discounted_amount($item->get_price() * $item->get_quantity()); |
|
692 | 692 | |
693 | - $this->add_discount( 'Discount', $discount, $this->discount->is_recurring() ); |
|
693 | + $this->add_discount('Discount', $discount, $this->discount->is_recurring()); |
|
694 | 694 | |
695 | 695 | } |
696 | 696 | |
@@ -708,8 +708,8 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @since 1.0.19 |
710 | 710 | */ |
711 | - public function get_discount( $name ) { |
|
712 | - return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ]['amount'] : 0; |
|
711 | + public function get_discount($name) { |
|
712 | + return isset($this->discounts[$name]) ? $this->discounts[$name]['amount'] : 0; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -728,15 +728,15 @@ discard block |
||
728 | 728 | * |
729 | 729 | * @since 1.0.19 |
730 | 730 | */ |
731 | - public function add_fee( $name, $amount, $recurring = false ) { |
|
732 | - $amount = wpinv_sanitize_amount( $amount ); |
|
731 | + public function add_fee($name, $amount, $recurring = false) { |
|
732 | + $amount = wpinv_sanitize_amount($amount); |
|
733 | 733 | |
734 | 734 | $this->total_fees_amount += $amount; |
735 | - if ( isset( $this->fees[ $name ] ) ) { |
|
736 | - $amount += $this->fees[ $name ]['amount']; |
|
735 | + if (isset($this->fees[$name])) { |
|
736 | + $amount += $this->fees[$name]['amount']; |
|
737 | 737 | } |
738 | 738 | |
739 | - $this->fees[ $name ] = compact( 'amount', 'recurring' ); |
|
739 | + $this->fees[$name] = compact('amount', 'recurring'); |
|
740 | 740 | |
741 | 741 | } |
742 | 742 | |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @since 1.0.19 |
756 | 756 | */ |
757 | - public function get_fee( $name ) { |
|
758 | - return isset( $this->fees[ $name ] ) ? $this->fees[ $name ]['amount'] : 0; |
|
757 | + public function get_fee($name) { |
|
758 | + return isset($this->fees[$name]) ? $this->fees[$name]['amount'] : 0; |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | */ |
777 | 777 | public function get_total() { |
778 | 778 | $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
779 | - $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this ); |
|
780 | - return wpinv_sanitize_amount( $total ); |
|
779 | + $total = apply_filters('getpaid_get_submission_total_amount', $total, $this); |
|
780 | + return wpinv_sanitize_amount($total); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | public function get_payment_details() { |
789 | 789 | $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
790 | 790 | |
791 | - if ( $this->has_recurring ) { |
|
791 | + if ($this->has_recurring) { |
|
792 | 792 | $collect = true; |
793 | 793 | } |
794 | 794 | |
795 | - $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this ); |
|
795 | + $collect = apply_filters('getpaid_submission_collect_payment_details', $collect, $this); |
|
796 | 796 | return $collect; |
797 | 797 | } |
798 | 798 | |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | * @since 1.0.19 |
803 | 803 | */ |
804 | 804 | public function get_billing_email() { |
805 | - $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email']; |
|
806 | - return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this ); |
|
805 | + $billing_email = empty($this->data['billing_email']) ? '' : $this->data['billing_email']; |
|
806 | + return apply_filters('getpaid_get_submission_billing_email', $billing_email, $this); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | */ |
814 | 814 | public function has_billing_email() { |
815 | 815 | $billing_email = $this->get_billing_email(); |
816 | - return ! empty( $billing_email ); |
|
816 | + return !empty($billing_email); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
@@ -824,16 +824,16 @@ discard block |
||
824 | 824 | public function maybe_validate_vat() { |
825 | 825 | |
826 | 826 | // Make sure that taxes are enabled. |
827 | - if ( ! wpinv_use_taxes() ) { |
|
827 | + if (!wpinv_use_taxes()) { |
|
828 | 828 | return; |
829 | 829 | } |
830 | 830 | |
831 | 831 | // Check if we have a digital VAT rule. |
832 | 832 | $has_digital = false; |
833 | 833 | |
834 | - foreach ( $this->get_items() as $item ) { |
|
834 | + foreach ($this->get_items() as $item) { |
|
835 | 835 | |
836 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
836 | + if ('digital' == $item->get_vat_rule()) { |
|
837 | 837 | $has_digital = true; |
838 | 838 | break; |
839 | 839 | } |
@@ -844,14 +844,14 @@ discard block |
||
844 | 844 | |
845 | 845 | // Check if we require vat. |
846 | 846 | $requires_vat = ( |
847 | - ( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) |
|
848 | - || ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) |
|
847 | + (getpaid_is_eu_state($this->country) && (getpaid_is_eu_state(wpinv_get_default_country()) || $has_digital)) |
|
848 | + || (getpaid_is_gst_country($this->country) && getpaid_is_gst_country(wpinv_get_default_country())) |
|
849 | 849 | ); |
850 | 850 | |
851 | 851 | $this->requires_vat = $requires_vat; |
852 | 852 | |
853 | 853 | // Abort if we are not calculating the taxes. |
854 | - if ( ! $has_digital && ! $requires_vat ) { |
|
854 | + if (!$has_digital && !$requires_vat) { |
|
855 | 855 | return; |
856 | 856 | } |
857 | 857 | |
@@ -859,23 +859,23 @@ discard block |
||
859 | 859 | $vat_number = $this->get_vat_number(); |
860 | 860 | $company = $this->get_company(); |
861 | 861 | $ip_country = WPInv_EUVat::get_country_by_ip(); |
862 | - $is_eu = getpaid_is_eu_state( $this->country ); |
|
863 | - $is_ip_eu = getpaid_is_eu_state( $ip_country ); |
|
864 | - $is_non_eu = ! $is_eu && ! $is_ip_eu; |
|
865 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
862 | + $is_eu = getpaid_is_eu_state($this->country); |
|
863 | + $is_ip_eu = getpaid_is_eu_state($ip_country); |
|
864 | + $is_non_eu = !$is_eu && !$is_ip_eu; |
|
865 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
866 | 866 | |
867 | 867 | // If we're preventing business to consumer purchases... |
868 | - if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) { |
|
868 | + if (!empty($prevent_b2c) && !$is_non_eu && (empty($vat_number) || !$requires_vat)) { |
|
869 | 869 | |
870 | - if ( $is_eu ) { |
|
870 | + if ($is_eu) { |
|
871 | 871 | $this->last_error = wp_sprintf( |
872 | - __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
872 | + __('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'), |
|
873 | 873 | getpaid_vat_name() |
874 | 874 | ); |
875 | - } else if ( $has_digital && $is_ip_eu ) { |
|
875 | + } else if ($has_digital && $is_ip_eu) { |
|
876 | 876 | |
877 | 877 | $this->last_error = wp_sprintf( |
878 | - __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), |
|
878 | + __('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), |
|
879 | 879 | getpaid_vat_name() |
880 | 880 | ); |
881 | 881 | |
@@ -884,13 +884,13 @@ discard block |
||
884 | 884 | } |
885 | 885 | |
886 | 886 | // Abort if we are not validating vat. |
887 | - if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) { |
|
887 | + if (!$is_eu || !$requires_vat || empty($vat_number)) { |
|
888 | 888 | return; |
889 | 889 | } |
890 | 890 | |
891 | - $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country ); |
|
891 | + $is_valid = WPInv_EUVat::validate_vat_number($vat_number, $company, $this->country); |
|
892 | 892 | |
893 | - if ( is_string( $is_valid ) ) { |
|
893 | + if (is_string($is_valid)) { |
|
894 | 894 | $this->last_error = $is_valid; |
895 | 895 | } |
896 | 896 |
@@ -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,51 +781,51 @@ 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 | * Fetch a subscription given an invoice. |
798 | 798 | * |
799 | 799 | * @return WPInv_Subscription|bool |
800 | 800 | */ |
801 | -function wpinv_get_subscription( $invoice ) { |
|
801 | +function wpinv_get_subscription($invoice) { |
|
802 | 802 | |
803 | 803 | // Abort if we do not have an invoice. |
804 | - if ( empty( $invoice ) ) { |
|
804 | + if (empty($invoice)) { |
|
805 | 805 | return false; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Retrieve the invoice. |
809 | - $invoice = new WPInv_Invoice( $invoice ); |
|
809 | + $invoice = new WPInv_Invoice($invoice); |
|
810 | 810 | |
811 | 811 | // Ensure it is a recurring invoice. |
812 | - if ( ! $invoice->is_recurring() ) { |
|
812 | + if (!$invoice->is_recurring()) { |
|
813 | 813 | return false; |
814 | 814 | } |
815 | 815 | |
816 | 816 | // Fetch the subscription handler. |
817 | - $subs_db = new WPInv_Subscriptions_DB(); |
|
817 | + $subs_db = new WPInv_Subscriptions_DB(); |
|
818 | 818 | |
819 | 819 | // Fetch the parent in case it is a renewal. |
820 | - if ( $invoice->is_renewal() ) { |
|
821 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->get_parent_id(), 'number' => 1 ) ); |
|
820 | + if ($invoice->is_renewal()) { |
|
821 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->get_parent_id(), 'number' => 1)); |
|
822 | 822 | } else { |
823 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->get_id(), 'number' => 1 ) ); |
|
823 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->get_id(), 'number' => 1)); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | // Return the subscription if it exists. |
827 | - if ( ! empty( $subs ) ) { |
|
828 | - return reset( $subs ); |
|
827 | + if (!empty($subs)) { |
|
828 | + return reset($subs); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | return false; |
@@ -839,27 +839,27 @@ discard block |
||
839 | 839 | * @param array $status_transition |
840 | 840 | * @todo: descrease customer/store earnings |
841 | 841 | */ |
842 | -function getpaid_maybe_process_refund( $invoice_id, $invoice, $status_transition ) { |
|
842 | +function getpaid_maybe_process_refund($invoice_id, $invoice, $status_transition) { |
|
843 | 843 | |
844 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
844 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
845 | 845 | return; |
846 | 846 | } |
847 | 847 | |
848 | 848 | $discount_code = $invoice->get_discount_code(); |
849 | - if ( ! empty( $discount_code ) ) { |
|
850 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
849 | + if (!empty($discount_code)) { |
|
850 | + $discount = wpinv_get_discount_obj($discount_code); |
|
851 | 851 | |
852 | - if ( $discount->exists() ) { |
|
852 | + if ($discount->exists()) { |
|
853 | 853 | $discount->increase_usage( -1 ); |
854 | 854 | } |
855 | 855 | |
856 | 856 | } |
857 | 857 | |
858 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice_id ); |
|
859 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice_id ); |
|
860 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice_id ); |
|
858 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice_id); |
|
859 | + do_action('wpinv_refund_invoice', $invoice, $invoice_id); |
|
860 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice_id); |
|
861 | 861 | } |
862 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3 ); |
|
862 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3); |
|
863 | 863 | |
864 | 864 | |
865 | 865 | /** |
@@ -867,48 +867,48 @@ discard block |
||
867 | 867 | * |
868 | 868 | * @param int $invoice_id |
869 | 869 | */ |
870 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
870 | +function getpaid_process_invoice_payment($invoice_id) { |
|
871 | 871 | |
872 | 872 | // Fetch the invoice. |
873 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
873 | + $invoice = new WPInv_Invoice($invoice_id); |
|
874 | 874 | |
875 | 875 | // We only want to do this once. |
876 | - if ( 1 == get_post_meta( $invoice_id, 'wpinv_processed_payment', true ) ) { |
|
876 | + if (1 == get_post_meta($invoice_id, 'wpinv_processed_payment', true)) { |
|
877 | 877 | return; |
878 | 878 | } |
879 | 879 | |
880 | - update_post_meta( $invoice_id, 'wpinv_processed_payment', 1 ); |
|
880 | + update_post_meta($invoice_id, 'wpinv_processed_payment', 1); |
|
881 | 881 | |
882 | 882 | // Fires when processing a payment. |
883 | - do_action( 'getpaid_process_payment', $invoice ); |
|
883 | + do_action('getpaid_process_payment', $invoice); |
|
884 | 884 | |
885 | 885 | // Fire an action for each invoice item. |
886 | - foreach( $invoice->get_items() as $item ) { |
|
887 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
886 | + foreach ($invoice->get_items() as $item) { |
|
887 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | // Increase discount usage. |
891 | 891 | $discount_code = $invoice->get_discount_code(); |
892 | - if ( ! empty( $discount_code ) ) { |
|
893 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
892 | + if (!empty($discount_code)) { |
|
893 | + $discount = wpinv_get_discount_obj($discount_code); |
|
894 | 894 | |
895 | - if ( $discount->exists() ) { |
|
895 | + if ($discount->exists()) { |
|
896 | 896 | $discount->increase_usage(); |
897 | 897 | } |
898 | 898 | |
899 | 899 | } |
900 | 900 | |
901 | 901 | // Record reverse vat. |
902 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
902 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
903 | 903 | |
904 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
905 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
904 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
905 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | } |
909 | 909 | |
910 | 910 | } |
911 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
911 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
912 | 912 | |
913 | 913 | /** |
914 | 914 | * Returns an array of invoice item columns |
@@ -916,13 +916,13 @@ discard block |
||
916 | 916 | * @param int|WPInv_Invoice $invoice |
917 | 917 | * @return array |
918 | 918 | */ |
919 | -function getpaid_invoice_item_columns( $invoice ) { |
|
919 | +function getpaid_invoice_item_columns($invoice) { |
|
920 | 920 | |
921 | 921 | // Prepare the invoice. |
922 | - $invoice = new WPInv_Invoice( $invoice ); |
|
922 | + $invoice = new WPInv_Invoice($invoice); |
|
923 | 923 | |
924 | 924 | // Abort if there is no invoice. |
925 | - if ( 0 == $invoice->get_id() ) { |
|
925 | + if (0 == $invoice->get_id()) { |
|
926 | 926 | return array(); |
927 | 927 | } |
928 | 928 | |
@@ -930,47 +930,47 @@ discard block |
||
930 | 930 | $columns = apply_filters( |
931 | 931 | 'getpaid_invoice_item_columns', |
932 | 932 | array( |
933 | - 'name' => __( 'Item', 'invoicing' ), |
|
934 | - 'price' => __( 'Price', 'invoicing' ), |
|
935 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
936 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
933 | + 'name' => __('Item', 'invoicing'), |
|
934 | + 'price' => __('Price', 'invoicing'), |
|
935 | + 'quantity' => __('Quantity', 'invoicing'), |
|
936 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
937 | 937 | ), |
938 | 938 | $invoice |
939 | 939 | ); |
940 | 940 | |
941 | 941 | // Quantities. |
942 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
942 | + if (isset($columns['quantity'])) { |
|
943 | 943 | |
944 | - if ( 'hours' == $invoice->get_template() ) { |
|
945 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
944 | + if ('hours' == $invoice->get_template()) { |
|
945 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
946 | 946 | } |
947 | 947 | |
948 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
949 | - unset( $columns[ 'quantity' ] ); |
|
948 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
949 | + unset($columns['quantity']); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | } |
953 | 953 | |
954 | 954 | |
955 | 955 | // Price. |
956 | - if ( isset( $columns[ 'price' ] ) ) { |
|
956 | + if (isset($columns['price'])) { |
|
957 | 957 | |
958 | - if ( 'amount' == $invoice->get_template() ) { |
|
959 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
958 | + if ('amount' == $invoice->get_template()) { |
|
959 | + $columns['price'] = __('Amount', 'invoicing'); |
|
960 | 960 | } |
961 | 961 | |
962 | - if ( 'hours' == $invoice->get_template() ) { |
|
963 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
962 | + if ('hours' == $invoice->get_template()) { |
|
963 | + $columns['price'] = __('Rate', 'invoicing'); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | } |
967 | 967 | |
968 | 968 | |
969 | 969 | // Sub total. |
970 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
970 | + if (isset($columns['subtotal'])) { |
|
971 | 971 | |
972 | - if ( 'amount' == $invoice->get_template() ) { |
|
973 | - unset( $columns[ 'subtotal' ] ); |
|
972 | + if ('amount' == $invoice->get_template()) { |
|
973 | + unset($columns['subtotal']); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | } |
@@ -984,29 +984,29 @@ discard block |
||
984 | 984 | * @param int|WPInv_Invoice $invoice |
985 | 985 | * @return array |
986 | 986 | */ |
987 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
987 | +function getpaid_invoice_totals_rows($invoice) { |
|
988 | 988 | |
989 | 989 | // Prepare the invoice. |
990 | - $invoice = new WPInv_Invoice( $invoice ); |
|
990 | + $invoice = new WPInv_Invoice($invoice); |
|
991 | 991 | |
992 | 992 | // Abort if there is no invoice. |
993 | - if ( 0 == $invoice->get_id() ) { |
|
993 | + if (0 == $invoice->get_id()) { |
|
994 | 994 | return array(); |
995 | 995 | } |
996 | 996 | |
997 | 997 | $totals = apply_filters( |
998 | 998 | 'getpaid_invoice_totals_rows', |
999 | 999 | array( |
1000 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
1001 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
1002 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
1003 | - 'total' => __( 'Total', 'invoicing' ), |
|
1000 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
1001 | + 'tax' => __('Tax', 'invoicing'), |
|
1002 | + 'discount' => __('Discount', 'invoicing'), |
|
1003 | + 'total' => __('Total', 'invoicing'), |
|
1004 | 1004 | ), |
1005 | 1005 | $invoice |
1006 | 1006 | ); |
1007 | 1007 | |
1008 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
1009 | - unset( $totals['tax'] ); |
|
1008 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
1009 | + unset($totals['tax']); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | return $totals; |
@@ -1017,43 +1017,43 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @param WPInv_Invoice $invoice |
1019 | 1019 | */ |
1020 | -function getpaid_new_invoice( $invoice ) { |
|
1020 | +function getpaid_new_invoice($invoice) { |
|
1021 | 1021 | |
1022 | - if ( ! $invoice->get_status() ) { |
|
1022 | + if (!$invoice->get_status()) { |
|
1023 | 1023 | return; |
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | // Add an invoice created note. |
1027 | 1027 | $invoice->add_note( |
1028 | 1028 | wp_sprintf( |
1029 | - __( 'Invoice created with the status "%s".', 'invoicing' ), |
|
1030 | - wpinv_status_nicename( $invoice->get_status() ) |
|
1029 | + __('Invoice created with the status "%s".', 'invoicing'), |
|
1030 | + wpinv_status_nicename($invoice->get_status()) |
|
1031 | 1031 | ) |
1032 | 1032 | ); |
1033 | 1033 | |
1034 | 1034 | } |
1035 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
1035 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
1036 | 1036 | |
1037 | 1037 | /** |
1038 | 1038 | * This function updates invoice caches. |
1039 | 1039 | * |
1040 | 1040 | * @param WPInv_Invoice $invoice |
1041 | 1041 | */ |
1042 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1042 | +function getpaid_update_invoice_caches($invoice) { |
|
1043 | 1043 | |
1044 | 1044 | // Cache invoice number. |
1045 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1045 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1046 | 1046 | |
1047 | 1047 | // Cache invoice key. |
1048 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1048 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1049 | 1049 | |
1050 | 1050 | // (Maybe) cache transaction id. |
1051 | 1051 | $transaction_id = $invoice->get_transaction_id(); |
1052 | 1052 | |
1053 | - if ( ! empty( $transaction_id ) ) { |
|
1054 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1053 | + if (!empty($transaction_id)) { |
|
1054 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | } |
1058 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1059 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1058 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1059 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
@@ -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. |
@@ -134,40 +134,40 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
136 | 136 | */ |
137 | - public function __construct( $invoice = false ) { |
|
137 | + public function __construct($invoice = false) { |
|
138 | 138 | |
139 | - parent::__construct( $invoice ); |
|
139 | + parent::__construct($invoice); |
|
140 | 140 | |
141 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
142 | - $this->set_id( $invoice ); |
|
143 | - } elseif ( $invoice instanceof self ) { |
|
144 | - $this->set_id( $invoice->get_id() ); |
|
145 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
146 | - $this->set_id( $invoice->ID ); |
|
147 | - } elseif ( is_array( $invoice ) ) { |
|
148 | - $this->set_props( $invoice ); |
|
141 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
142 | + $this->set_id($invoice); |
|
143 | + } elseif ($invoice instanceof self) { |
|
144 | + $this->set_id($invoice->get_id()); |
|
145 | + } elseif (!empty($invoice->ID)) { |
|
146 | + $this->set_id($invoice->ID); |
|
147 | + } elseif (is_array($invoice)) { |
|
148 | + $this->set_props($invoice); |
|
149 | 149 | |
150 | - if ( isset( $invoice['ID'] ) ) { |
|
151 | - $this->set_id( $invoice['ID'] ); |
|
150 | + if (isset($invoice['ID'])) { |
|
151 | + $this->set_id($invoice['ID']); |
|
152 | 152 | } |
153 | 153 | |
154 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
155 | - $this->set_id( $invoice_id ); |
|
156 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
157 | - $this->set_id( $invoice_id ); |
|
158 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
159 | - $this->set_id( $invoice_id ); |
|
160 | - }else { |
|
161 | - $this->set_object_read( true ); |
|
154 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
155 | + $this->set_id($invoice_id); |
|
156 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
157 | + $this->set_id($invoice_id); |
|
158 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
159 | + $this->set_id($invoice_id); |
|
160 | + } else { |
|
161 | + $this->set_object_read(true); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Load the datastore. |
165 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
165 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
166 | 166 | |
167 | - if ( $this->get_id() > 0 ) { |
|
168 | - $this->post = get_post( $this->get_id() ); |
|
167 | + if ($this->get_id() > 0) { |
|
168 | + $this->post = get_post($this->get_id()); |
|
169 | 169 | $this->ID = $this->get_id(); |
170 | - $this->data_store->read( $this ); |
|
170 | + $this->data_store->read($this); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | } |
@@ -182,38 +182,38 @@ discard block |
||
182 | 182 | * @since 1.0.15 |
183 | 183 | * @return int |
184 | 184 | */ |
185 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
185 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
186 | 186 | global $wpdb; |
187 | 187 | |
188 | 188 | // Trim the value. |
189 | - $value = trim( $value ); |
|
189 | + $value = trim($value); |
|
190 | 190 | |
191 | - if ( empty( $value ) ) { |
|
191 | + if (empty($value)) { |
|
192 | 192 | return 0; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Valid fields. |
196 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
196 | + $fields = array('key', 'number', 'transaction_id'); |
|
197 | 197 | |
198 | 198 | // Ensure a field has been passed. |
199 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
199 | + if (empty($field) || !in_array($field, $fields)) { |
|
200 | 200 | return 0; |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Maybe retrieve from the cache. |
204 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
205 | - if ( false !== $invoice_id ) { |
|
204 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
205 | + if (false !== $invoice_id) { |
|
206 | 206 | return $invoice_id; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // Fetch from the db. |
210 | 210 | $table = $wpdb->prefix . 'getpaid_invoices'; |
211 | 211 | $invoice_id = (int) $wpdb->get_var( |
212 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
212 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | // Update the cache with our data |
216 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
216 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
217 | 217 | |
218 | 218 | return $invoice_id; |
219 | 219 | } |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | /** |
222 | 222 | * Checks if an invoice key is set. |
223 | 223 | */ |
224 | - public function _isset( $key ) { |
|
225 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
224 | + public function _isset($key) { |
|
225 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /* |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @param string $context View or edit context. |
248 | 248 | * @return int |
249 | 249 | */ |
250 | - public function get_parent_id( $context = 'view' ) { |
|
251 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
250 | + public function get_parent_id($context = 'view') { |
|
251 | + return (int) $this->get_prop('parent_id', $context); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @return WPInv_Invoice |
259 | 259 | */ |
260 | 260 | public function get_parent_payment() { |
261 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
261 | + return new WPInv_Invoice($this->get_parent_id()); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param string $context View or edit context. |
279 | 279 | * @return string |
280 | 280 | */ |
281 | - public function get_status( $context = 'view' ) { |
|
282 | - return $this->get_prop( 'status', $context ); |
|
281 | + public function get_status($context = 'view') { |
|
282 | + return $this->get_prop('status', $context); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function get_all_statuses() { |
292 | 292 | |
293 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
293 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
294 | 294 | |
295 | 295 | // For backwards compatibility. |
296 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
296 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
297 | 297 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
298 | 298 | } |
299 | 299 | |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | public function get_status_nicename() { |
310 | 310 | $statuses = $this->get_all_statuses(); |
311 | 311 | |
312 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
312 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
313 | 313 | |
314 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
314 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function get_status_label_html() { |
324 | 324 | |
325 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
326 | - $status = sanitize_html_class( $this->get_status() ); |
|
325 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
326 | + $status = sanitize_html_class($this->get_status()); |
|
327 | 327 | |
328 | 328 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
329 | 329 | } |
@@ -335,27 +335,27 @@ discard block |
||
335 | 335 | * @param string $context View or edit context. |
336 | 336 | * @return string |
337 | 337 | */ |
338 | - public function get_version( $context = 'view' ) { |
|
339 | - return $this->get_prop( 'version', $context ); |
|
338 | + public function get_version($context = 'view') { |
|
339 | + return $this->get_prop('version', $context); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | 343 | * @deprecated |
344 | 344 | */ |
345 | - public function get_invoice_date( $formatted = true ) { |
|
345 | + public function get_invoice_date($formatted = true) { |
|
346 | 346 | $date_completed = $this->get_date_completed(); |
347 | 347 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
348 | 348 | |
349 | - if ( $invoice_date == '' ) { |
|
349 | + if ($invoice_date == '') { |
|
350 | 350 | $date_created = $this->get_date_created(); |
351 | 351 | $invoice_date = $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
352 | 352 | } |
353 | 353 | |
354 | - if ( $formatted && $invoice_date ) { |
|
355 | - $invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) ); |
|
354 | + if ($formatted && $invoice_date) { |
|
355 | + $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date)); |
|
356 | 356 | } |
357 | 357 | |
358 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this ); |
|
358 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $context View or edit context. |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public function get_date_created( $context = 'view' ) { |
|
369 | - return $this->get_prop( 'date_created', $context ); |
|
368 | + public function get_date_created($context = 'view') { |
|
369 | + return $this->get_prop('date_created', $context); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param string $context View or edit context. |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public function get_created_date( $context = 'view' ) { |
|
380 | - return $this->get_date_created( $context ); |
|
379 | + public function get_created_date($context = 'view') { |
|
380 | + return $this->get_date_created($context); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | * @param string $context View or edit context. |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_date_created_gmt( $context = 'view' ) { |
|
391 | - $date = $this->get_date_created( $context ); |
|
390 | + public function get_date_created_gmt($context = 'view') { |
|
391 | + $date = $this->get_date_created($context); |
|
392 | 392 | |
393 | - if ( $date ) { |
|
394 | - $date = get_gmt_from_date( $date ); |
|
393 | + if ($date) { |
|
394 | + $date = get_gmt_from_date($date); |
|
395 | 395 | } |
396 | 396 | return $date; |
397 | 397 | } |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | * @param string $context View or edit context. |
404 | 404 | * @return string |
405 | 405 | */ |
406 | - public function get_date_modified( $context = 'view' ) { |
|
407 | - return $this->get_prop( 'date_modified', $context ); |
|
406 | + public function get_date_modified($context = 'view') { |
|
407 | + return $this->get_prop('date_modified', $context); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | * @param string $context View or edit context. |
415 | 415 | * @return string |
416 | 416 | */ |
417 | - public function get_modified_date( $context = 'view' ) { |
|
418 | - return $this->get_date_modified( $context ); |
|
417 | + public function get_modified_date($context = 'view') { |
|
418 | + return $this->get_date_modified($context); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | * @param string $context View or edit context. |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
429 | - $date = $this->get_date_modified( $context ); |
|
428 | + public function get_date_modified_gmt($context = 'view') { |
|
429 | + $date = $this->get_date_modified($context); |
|
430 | 430 | |
431 | - if ( $date ) { |
|
432 | - $date = get_gmt_from_date( $date ); |
|
431 | + if ($date) { |
|
432 | + $date = get_gmt_from_date($date); |
|
433 | 433 | } |
434 | 434 | return $date; |
435 | 435 | } |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * @param string $context View or edit context. |
442 | 442 | * @return string |
443 | 443 | */ |
444 | - public function get_due_date( $context = 'view' ) { |
|
445 | - return $this->get_prop( 'due_date', $context ); |
|
444 | + public function get_due_date($context = 'view') { |
|
445 | + return $this->get_prop('due_date', $context); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | /** |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | * @param string $context View or edit context. |
453 | 453 | * @return string |
454 | 454 | */ |
455 | - public function get_date_due( $context = 'view' ) { |
|
456 | - return $this->get_due_date( $context ); |
|
455 | + public function get_date_due($context = 'view') { |
|
456 | + return $this->get_due_date($context); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | * @param string $context View or edit context. |
464 | 464 | * @return string |
465 | 465 | */ |
466 | - public function get_due_date_gmt( $context = 'view' ) { |
|
467 | - $date = $this->get_due_date( $context ); |
|
466 | + public function get_due_date_gmt($context = 'view') { |
|
467 | + $date = $this->get_due_date($context); |
|
468 | 468 | |
469 | - if ( $date ) { |
|
470 | - $date = get_gmt_from_date( $date ); |
|
469 | + if ($date) { |
|
470 | + $date = get_gmt_from_date($date); |
|
471 | 471 | } |
472 | 472 | return $date; |
473 | 473 | } |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | * @param string $context View or edit context. |
480 | 480 | * @return string |
481 | 481 | */ |
482 | - public function get_gmt_date_due( $context = 'view' ) { |
|
483 | - return $this->get_due_date_gmt( $context ); |
|
482 | + public function get_gmt_date_due($context = 'view') { |
|
483 | + return $this->get_due_date_gmt($context); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | * @param string $context View or edit context. |
491 | 491 | * @return string |
492 | 492 | */ |
493 | - public function get_completed_date( $context = 'view' ) { |
|
494 | - return $this->get_prop( 'completed_date', $context ); |
|
493 | + public function get_completed_date($context = 'view') { |
|
494 | + return $this->get_prop('completed_date', $context); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | * @param string $context View or edit context. |
502 | 502 | * @return string |
503 | 503 | */ |
504 | - public function get_date_completed( $context = 'view' ) { |
|
505 | - return $this->get_completed_date( $context ); |
|
504 | + public function get_date_completed($context = 'view') { |
|
505 | + return $this->get_completed_date($context); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * @param string $context View or edit context. |
513 | 513 | * @return string |
514 | 514 | */ |
515 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
516 | - $date = $this->get_completed_date( $context ); |
|
515 | + public function get_completed_date_gmt($context = 'view') { |
|
516 | + $date = $this->get_completed_date($context); |
|
517 | 517 | |
518 | - if ( $date ) { |
|
519 | - $date = get_gmt_from_date( $date ); |
|
518 | + if ($date) { |
|
519 | + $date = get_gmt_from_date($date); |
|
520 | 520 | } |
521 | 521 | return $date; |
522 | 522 | } |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @param string $context View or edit context. |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
532 | - return $this->get_completed_date_gmt( $context ); |
|
531 | + public function get_gmt_completed_date($context = 'view') { |
|
532 | + return $this->get_completed_date_gmt($context); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -539,12 +539,12 @@ discard block |
||
539 | 539 | * @param string $context View or edit context. |
540 | 540 | * @return string |
541 | 541 | */ |
542 | - public function get_number( $context = 'view' ) { |
|
543 | - $number = $this->get_prop( 'number', $context ); |
|
542 | + public function get_number($context = 'view') { |
|
543 | + $number = $this->get_prop('number', $context); |
|
544 | 544 | |
545 | - if ( empty( $number ) ) { |
|
545 | + if (empty($number)) { |
|
546 | 546 | $number = $this->generate_number(); |
547 | - $this->set_number( $this->generate_number() ); |
|
547 | + $this->set_number($this->generate_number()); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | return $number; |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | public function maybe_set_number() { |
559 | 559 | $number = $this->get_number(); |
560 | 560 | |
561 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
562 | - $this->set_number( $this->generate_number() ); |
|
561 | + if (empty($number) || $this->get_id() == $number) { |
|
562 | + $this->set_number($this->generate_number()); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | } |
@@ -571,8 +571,8 @@ discard block |
||
571 | 571 | * @param string $context View or edit context. |
572 | 572 | * @return string |
573 | 573 | */ |
574 | - public function get_key( $context = 'view' ) { |
|
575 | - return $this->get_prop( 'key', $context ); |
|
574 | + public function get_key($context = 'view') { |
|
575 | + return $this->get_prop('key', $context); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -583,9 +583,9 @@ discard block |
||
583 | 583 | public function maybe_set_key() { |
584 | 584 | $key = $this->get_key(); |
585 | 585 | |
586 | - if ( empty( $key ) ) { |
|
587 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
588 | - $this->set_key( $key ); |
|
586 | + if (empty($key)) { |
|
587 | + $key = $this->generate_key($this->get_type() . '_'); |
|
588 | + $this->set_key($key); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | } |
@@ -597,15 +597,15 @@ discard block |
||
597 | 597 | * @param string $context View or edit context. |
598 | 598 | * @return string |
599 | 599 | */ |
600 | - public function get_type( $context = 'view' ) { |
|
601 | - return $this->get_prop( 'type', $context ); |
|
600 | + public function get_type($context = 'view') { |
|
601 | + return $this->get_prop('type', $context); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
605 | 605 | * @deprecated |
606 | 606 | */ |
607 | 607 | public function get_invoice_quote_type() { |
608 | - ucfirst( $this->get_type() ); |
|
608 | + ucfirst($this->get_type()); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -615,8 +615,8 @@ discard block |
||
615 | 615 | * @param string $context View or edit context. |
616 | 616 | * @return string |
617 | 617 | */ |
618 | - public function get_post_type( $context = 'view' ) { |
|
619 | - return $this->get_prop( 'post_type', $context ); |
|
618 | + public function get_post_type($context = 'view') { |
|
619 | + return $this->get_prop('post_type', $context); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -626,8 +626,8 @@ discard block |
||
626 | 626 | * @param string $context View or edit context. |
627 | 627 | * @return string |
628 | 628 | */ |
629 | - public function get_mode( $context = 'view' ) { |
|
630 | - return $this->get_prop( 'mode', $context ); |
|
629 | + public function get_mode($context = 'view') { |
|
630 | + return $this->get_prop('mode', $context); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | /** |
@@ -637,13 +637,13 @@ discard block |
||
637 | 637 | * @param string $context View or edit context. |
638 | 638 | * @return string |
639 | 639 | */ |
640 | - public function get_path( $context = 'view' ) { |
|
641 | - $path = $this->get_prop( 'path', $context ); |
|
642 | - $prefix = wpinv_post_name_prefix( $this->get_post_type() ); |
|
640 | + public function get_path($context = 'view') { |
|
641 | + $path = $this->get_prop('path', $context); |
|
642 | + $prefix = wpinv_post_name_prefix($this->get_post_type()); |
|
643 | 643 | |
644 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
645 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
646 | - $this->set_path( $path ); |
|
644 | + if (0 !== strpos($path, $prefix)) { |
|
645 | + $path = sanitize_title($prefix . $this->get_id()); |
|
646 | + $this->set_path($path); |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | return $path; |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | * @param string $context View or edit context. |
657 | 657 | * @return string |
658 | 658 | */ |
659 | - public function get_name( $context = 'view' ) { |
|
660 | - return $this->get_prop( 'title', $context ); |
|
659 | + public function get_name($context = 'view') { |
|
660 | + return $this->get_prop('title', $context); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -667,8 +667,8 @@ discard block |
||
667 | 667 | * @param string $context View or edit context. |
668 | 668 | * @return string |
669 | 669 | */ |
670 | - public function get_title( $context = 'view' ) { |
|
671 | - return $this->get_name( $context ); |
|
670 | + public function get_title($context = 'view') { |
|
671 | + return $this->get_name($context); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | /** |
@@ -678,8 +678,8 @@ discard block |
||
678 | 678 | * @param string $context View or edit context. |
679 | 679 | * @return string |
680 | 680 | */ |
681 | - public function get_description( $context = 'view' ) { |
|
682 | - return $this->get_prop( 'description', $context ); |
|
681 | + public function get_description($context = 'view') { |
|
682 | + return $this->get_prop('description', $context); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | /** |
@@ -689,8 +689,8 @@ discard block |
||
689 | 689 | * @param string $context View or edit context. |
690 | 690 | * @return string |
691 | 691 | */ |
692 | - public function get_excerpt( $context = 'view' ) { |
|
693 | - return $this->get_description( $context ); |
|
692 | + public function get_excerpt($context = 'view') { |
|
693 | + return $this->get_description($context); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | /** |
@@ -700,8 +700,8 @@ discard block |
||
700 | 700 | * @param string $context View or edit context. |
701 | 701 | * @return string |
702 | 702 | */ |
703 | - public function get_summary( $context = 'view' ) { |
|
704 | - return $this->get_description( $context ); |
|
703 | + public function get_summary($context = 'view') { |
|
704 | + return $this->get_description($context); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -711,25 +711,25 @@ discard block |
||
711 | 711 | * @param string $context View or edit context. |
712 | 712 | * @return array |
713 | 713 | */ |
714 | - public function get_user_info( $context = 'view' ) { |
|
714 | + public function get_user_info($context = 'view') { |
|
715 | 715 | |
716 | 716 | $user_info = array( |
717 | - 'user_id' => $this->get_user_id( $context ), |
|
718 | - 'email' => $this->get_email( $context ), |
|
719 | - 'first_name' => $this->get_first_name( $context ), |
|
720 | - 'last_name' => $this->get_last_name( $context ), |
|
721 | - 'address' => $this->get_address( $context ), |
|
722 | - 'phone' => $this->get_phone( $context ), |
|
723 | - 'city' => $this->get_city( $context ), |
|
724 | - 'country' => $this->get_country( $context ), |
|
725 | - 'state' => $this->get_state( $context ), |
|
726 | - 'zip' => $this->get_zip( $context ), |
|
727 | - 'company' => $this->get_company( $context ), |
|
728 | - 'vat_number' => $this->get_vat_number( $context ), |
|
729 | - 'discount' => $this->get_discount_code( $context ), |
|
717 | + 'user_id' => $this->get_user_id($context), |
|
718 | + 'email' => $this->get_email($context), |
|
719 | + 'first_name' => $this->get_first_name($context), |
|
720 | + 'last_name' => $this->get_last_name($context), |
|
721 | + 'address' => $this->get_address($context), |
|
722 | + 'phone' => $this->get_phone($context), |
|
723 | + 'city' => $this->get_city($context), |
|
724 | + 'country' => $this->get_country($context), |
|
725 | + 'state' => $this->get_state($context), |
|
726 | + 'zip' => $this->get_zip($context), |
|
727 | + 'company' => $this->get_company($context), |
|
728 | + 'vat_number' => $this->get_vat_number($context), |
|
729 | + 'discount' => $this->get_discount_code($context), |
|
730 | 730 | ); |
731 | 731 | |
732 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
732 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | * @param string $context View or edit context. |
741 | 741 | * @return int |
742 | 742 | */ |
743 | - public function get_author( $context = 'view' ) { |
|
744 | - return (int) $this->get_prop( 'author', $context ); |
|
743 | + public function get_author($context = 'view') { |
|
744 | + return (int) $this->get_prop('author', $context); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -751,8 +751,8 @@ discard block |
||
751 | 751 | * @param string $context View or edit context. |
752 | 752 | * @return int |
753 | 753 | */ |
754 | - public function get_user_id( $context = 'view' ) { |
|
755 | - return $this->get_author( $context ); |
|
754 | + public function get_user_id($context = 'view') { |
|
755 | + return $this->get_author($context); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
@@ -762,8 +762,8 @@ discard block |
||
762 | 762 | * @param string $context View or edit context. |
763 | 763 | * @return int |
764 | 764 | */ |
765 | - public function get_customer_id( $context = 'view' ) { |
|
766 | - return $this->get_author( $context ); |
|
765 | + public function get_customer_id($context = 'view') { |
|
766 | + return $this->get_author($context); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | /** |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | * @param string $context View or edit context. |
774 | 774 | * @return string |
775 | 775 | */ |
776 | - public function get_ip( $context = 'view' ) { |
|
777 | - return $this->get_prop( 'user_ip', $context ); |
|
776 | + public function get_ip($context = 'view') { |
|
777 | + return $this->get_prop('user_ip', $context); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | * @param string $context View or edit context. |
785 | 785 | * @return string |
786 | 786 | */ |
787 | - public function get_user_ip( $context = 'view' ) { |
|
788 | - return $this->get_ip( $context ); |
|
787 | + public function get_user_ip($context = 'view') { |
|
788 | + return $this->get_ip($context); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | /** |
@@ -795,8 +795,8 @@ discard block |
||
795 | 795 | * @param string $context View or edit context. |
796 | 796 | * @return string |
797 | 797 | */ |
798 | - public function get_customer_ip( $context = 'view' ) { |
|
799 | - return $this->get_ip( $context ); |
|
798 | + public function get_customer_ip($context = 'view') { |
|
799 | + return $this->get_ip($context); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -806,8 +806,8 @@ discard block |
||
806 | 806 | * @param string $context View or edit context. |
807 | 807 | * @return string |
808 | 808 | */ |
809 | - public function get_first_name( $context = 'view' ) { |
|
810 | - return $this->get_prop( 'first_name', $context ); |
|
809 | + public function get_first_name($context = 'view') { |
|
810 | + return $this->get_prop('first_name', $context); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | /** |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | * @param string $context View or edit context. |
818 | 818 | * @return int |
819 | 819 | */ |
820 | - public function get_user_first_name( $context = 'view' ) { |
|
821 | - return $this->get_first_name( $context ); |
|
820 | + public function get_user_first_name($context = 'view') { |
|
821 | + return $this->get_first_name($context); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | /** |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | * @param string $context View or edit context. |
829 | 829 | * @return int |
830 | 830 | */ |
831 | - public function get_customer_first_name( $context = 'view' ) { |
|
832 | - return $this->get_first_name( $context ); |
|
831 | + public function get_customer_first_name($context = 'view') { |
|
832 | + return $this->get_first_name($context); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -839,8 +839,8 @@ discard block |
||
839 | 839 | * @param string $context View or edit context. |
840 | 840 | * @return string |
841 | 841 | */ |
842 | - public function get_last_name( $context = 'view' ) { |
|
843 | - return $this->get_prop( 'last_name', $context ); |
|
842 | + public function get_last_name($context = 'view') { |
|
843 | + return $this->get_prop('last_name', $context); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | * @param string $context View or edit context. |
851 | 851 | * @return int |
852 | 852 | */ |
853 | - public function get_user_last_name( $context = 'view' ) { |
|
854 | - return $this->get_last_name( $context ); |
|
853 | + public function get_user_last_name($context = 'view') { |
|
854 | + return $this->get_last_name($context); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | * @param string $context View or edit context. |
862 | 862 | * @return int |
863 | 863 | */ |
864 | - public function get_customer_last_name( $context = 'view' ) { |
|
865 | - return $this->get_last_name( $context ); |
|
864 | + public function get_customer_last_name($context = 'view') { |
|
865 | + return $this->get_last_name($context); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | /** |
@@ -872,8 +872,8 @@ discard block |
||
872 | 872 | * @param string $context View or edit context. |
873 | 873 | * @return string |
874 | 874 | */ |
875 | - public function get_full_name( $context = 'view' ) { |
|
876 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
875 | + public function get_full_name($context = 'view') { |
|
876 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | /** |
@@ -883,8 +883,8 @@ discard block |
||
883 | 883 | * @param string $context View or edit context. |
884 | 884 | * @return int |
885 | 885 | */ |
886 | - public function get_user_full_name( $context = 'view' ) { |
|
887 | - return $this->get_full_name( $context ); |
|
886 | + public function get_user_full_name($context = 'view') { |
|
887 | + return $this->get_full_name($context); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -894,8 +894,8 @@ discard block |
||
894 | 894 | * @param string $context View or edit context. |
895 | 895 | * @return int |
896 | 896 | */ |
897 | - public function get_customer_full_name( $context = 'view' ) { |
|
898 | - return $this->get_full_name( $context ); |
|
897 | + public function get_customer_full_name($context = 'view') { |
|
898 | + return $this->get_full_name($context); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | /** |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | * @param string $context View or edit context. |
906 | 906 | * @return string |
907 | 907 | */ |
908 | - public function get_phone( $context = 'view' ) { |
|
909 | - return $this->get_prop( 'phone', $context ); |
|
908 | + public function get_phone($context = 'view') { |
|
909 | + return $this->get_prop('phone', $context); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | * @param string $context View or edit context. |
917 | 917 | * @return int |
918 | 918 | */ |
919 | - public function get_phone_number( $context = 'view' ) { |
|
920 | - return $this->get_phone( $context ); |
|
919 | + public function get_phone_number($context = 'view') { |
|
920 | + return $this->get_phone($context); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
@@ -927,8 +927,8 @@ discard block |
||
927 | 927 | * @param string $context View or edit context. |
928 | 928 | * @return int |
929 | 929 | */ |
930 | - public function get_user_phone( $context = 'view' ) { |
|
931 | - return $this->get_phone( $context ); |
|
930 | + public function get_user_phone($context = 'view') { |
|
931 | + return $this->get_phone($context); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | /** |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | * @param string $context View or edit context. |
939 | 939 | * @return int |
940 | 940 | */ |
941 | - public function get_customer_phone( $context = 'view' ) { |
|
942 | - return $this->get_phone( $context ); |
|
941 | + public function get_customer_phone($context = 'view') { |
|
942 | + return $this->get_phone($context); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | /** |
@@ -949,8 +949,8 @@ discard block |
||
949 | 949 | * @param string $context View or edit context. |
950 | 950 | * @return string |
951 | 951 | */ |
952 | - public function get_email( $context = 'view' ) { |
|
953 | - return $this->get_prop( 'email', $context ); |
|
952 | + public function get_email($context = 'view') { |
|
953 | + return $this->get_prop('email', $context); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
@@ -960,8 +960,8 @@ discard block |
||
960 | 960 | * @param string $context View or edit context. |
961 | 961 | * @return string |
962 | 962 | */ |
963 | - public function get_email_address( $context = 'view' ) { |
|
964 | - return $this->get_email( $context ); |
|
963 | + public function get_email_address($context = 'view') { |
|
964 | + return $this->get_email($context); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | /** |
@@ -971,8 +971,8 @@ discard block |
||
971 | 971 | * @param string $context View or edit context. |
972 | 972 | * @return int |
973 | 973 | */ |
974 | - public function get_user_email( $context = 'view' ) { |
|
975 | - return $this->get_email( $context ); |
|
974 | + public function get_user_email($context = 'view') { |
|
975 | + return $this->get_email($context); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | /** |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | * @param string $context View or edit context. |
983 | 983 | * @return int |
984 | 984 | */ |
985 | - public function get_customer_email( $context = 'view' ) { |
|
986 | - return $this->get_email( $context ); |
|
985 | + public function get_customer_email($context = 'view') { |
|
986 | + return $this->get_email($context); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | /** |
@@ -993,9 +993,9 @@ discard block |
||
993 | 993 | * @param string $context View or edit context. |
994 | 994 | * @return string |
995 | 995 | */ |
996 | - public function get_country( $context = 'view' ) { |
|
997 | - $country = $this->get_prop( 'country', $context ); |
|
998 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
996 | + public function get_country($context = 'view') { |
|
997 | + $country = $this->get_prop('country', $context); |
|
998 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | /** |
@@ -1005,8 +1005,8 @@ discard block |
||
1005 | 1005 | * @param string $context View or edit context. |
1006 | 1006 | * @return int |
1007 | 1007 | */ |
1008 | - public function get_user_country( $context = 'view' ) { |
|
1009 | - return $this->get_country( $context ); |
|
1008 | + public function get_user_country($context = 'view') { |
|
1009 | + return $this->get_country($context); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | /** |
@@ -1016,8 +1016,8 @@ discard block |
||
1016 | 1016 | * @param string $context View or edit context. |
1017 | 1017 | * @return int |
1018 | 1018 | */ |
1019 | - public function get_customer_country( $context = 'view' ) { |
|
1020 | - return $this->get_country( $context ); |
|
1019 | + public function get_customer_country($context = 'view') { |
|
1020 | + return $this->get_country($context); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1027,9 +1027,9 @@ discard block |
||
1027 | 1027 | * @param string $context View or edit context. |
1028 | 1028 | * @return string |
1029 | 1029 | */ |
1030 | - public function get_state( $context = 'view' ) { |
|
1031 | - $state = $this->get_prop( 'state', $context ); |
|
1032 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1030 | + public function get_state($context = 'view') { |
|
1031 | + $state = $this->get_prop('state', $context); |
|
1032 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | /** |
@@ -1039,8 +1039,8 @@ discard block |
||
1039 | 1039 | * @param string $context View or edit context. |
1040 | 1040 | * @return int |
1041 | 1041 | */ |
1042 | - public function get_user_state( $context = 'view' ) { |
|
1043 | - return $this->get_state( $context ); |
|
1042 | + public function get_user_state($context = 'view') { |
|
1043 | + return $this->get_state($context); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | /** |
@@ -1050,8 +1050,8 @@ discard block |
||
1050 | 1050 | * @param string $context View or edit context. |
1051 | 1051 | * @return int |
1052 | 1052 | */ |
1053 | - public function get_customer_state( $context = 'view' ) { |
|
1054 | - return $this->get_state( $context ); |
|
1053 | + public function get_customer_state($context = 'view') { |
|
1054 | + return $this->get_state($context); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | /** |
@@ -1061,8 +1061,8 @@ discard block |
||
1061 | 1061 | * @param string $context View or edit context. |
1062 | 1062 | * @return string |
1063 | 1063 | */ |
1064 | - public function get_city( $context = 'view' ) { |
|
1065 | - return $this->get_prop( 'city', $context ); |
|
1064 | + public function get_city($context = 'view') { |
|
1065 | + return $this->get_prop('city', $context); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | /** |
@@ -1072,8 +1072,8 @@ discard block |
||
1072 | 1072 | * @param string $context View or edit context. |
1073 | 1073 | * @return string |
1074 | 1074 | */ |
1075 | - public function get_user_city( $context = 'view' ) { |
|
1076 | - return $this->get_city( $context ); |
|
1075 | + public function get_user_city($context = 'view') { |
|
1076 | + return $this->get_city($context); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | /** |
@@ -1083,8 +1083,8 @@ discard block |
||
1083 | 1083 | * @param string $context View or edit context. |
1084 | 1084 | * @return string |
1085 | 1085 | */ |
1086 | - public function get_customer_city( $context = 'view' ) { |
|
1087 | - return $this->get_city( $context ); |
|
1086 | + public function get_customer_city($context = 'view') { |
|
1087 | + return $this->get_city($context); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | /** |
@@ -1094,8 +1094,8 @@ discard block |
||
1094 | 1094 | * @param string $context View or edit context. |
1095 | 1095 | * @return string |
1096 | 1096 | */ |
1097 | - public function get_zip( $context = 'view' ) { |
|
1098 | - return $this->get_prop( 'zip', $context ); |
|
1097 | + public function get_zip($context = 'view') { |
|
1098 | + return $this->get_prop('zip', $context); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | /** |
@@ -1105,8 +1105,8 @@ discard block |
||
1105 | 1105 | * @param string $context View or edit context. |
1106 | 1106 | * @return string |
1107 | 1107 | */ |
1108 | - public function get_user_zip( $context = 'view' ) { |
|
1109 | - return $this->get_zip( $context ); |
|
1108 | + public function get_user_zip($context = 'view') { |
|
1109 | + return $this->get_zip($context); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | /** |
@@ -1116,8 +1116,8 @@ discard block |
||
1116 | 1116 | * @param string $context View or edit context. |
1117 | 1117 | * @return string |
1118 | 1118 | */ |
1119 | - public function get_customer_zip( $context = 'view' ) { |
|
1120 | - return $this->get_zip( $context ); |
|
1119 | + public function get_customer_zip($context = 'view') { |
|
1120 | + return $this->get_zip($context); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | /** |
@@ -1127,8 +1127,8 @@ discard block |
||
1127 | 1127 | * @param string $context View or edit context. |
1128 | 1128 | * @return string |
1129 | 1129 | */ |
1130 | - public function get_company( $context = 'view' ) { |
|
1131 | - return $this->get_prop( 'company', $context ); |
|
1130 | + public function get_company($context = 'view') { |
|
1131 | + return $this->get_prop('company', $context); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | /** |
@@ -1138,8 +1138,8 @@ discard block |
||
1138 | 1138 | * @param string $context View or edit context. |
1139 | 1139 | * @return string |
1140 | 1140 | */ |
1141 | - public function get_user_company( $context = 'view' ) { |
|
1142 | - return $this->get_company( $context ); |
|
1141 | + public function get_user_company($context = 'view') { |
|
1142 | + return $this->get_company($context); |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | /** |
@@ -1149,8 +1149,8 @@ discard block |
||
1149 | 1149 | * @param string $context View or edit context. |
1150 | 1150 | * @return string |
1151 | 1151 | */ |
1152 | - public function get_customer_company( $context = 'view' ) { |
|
1153 | - return $this->get_company( $context ); |
|
1152 | + public function get_customer_company($context = 'view') { |
|
1153 | + return $this->get_company($context); |
|
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | /** |
@@ -1160,8 +1160,8 @@ discard block |
||
1160 | 1160 | * @param string $context View or edit context. |
1161 | 1161 | * @return string |
1162 | 1162 | */ |
1163 | - public function get_vat_number( $context = 'view' ) { |
|
1164 | - return $this->get_prop( 'vat_number', $context ); |
|
1163 | + public function get_vat_number($context = 'view') { |
|
1164 | + return $this->get_prop('vat_number', $context); |
|
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | /** |
@@ -1171,8 +1171,8 @@ discard block |
||
1171 | 1171 | * @param string $context View or edit context. |
1172 | 1172 | * @return string |
1173 | 1173 | */ |
1174 | - public function get_user_vat_number( $context = 'view' ) { |
|
1175 | - return $this->get_vat_number( $context ); |
|
1174 | + public function get_user_vat_number($context = 'view') { |
|
1175 | + return $this->get_vat_number($context); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | /** |
@@ -1182,8 +1182,8 @@ discard block |
||
1182 | 1182 | * @param string $context View or edit context. |
1183 | 1183 | * @return string |
1184 | 1184 | */ |
1185 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1186 | - return $this->get_vat_number( $context ); |
|
1185 | + public function get_customer_vat_number($context = 'view') { |
|
1186 | + return $this->get_vat_number($context); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | /** |
@@ -1193,8 +1193,8 @@ discard block |
||
1193 | 1193 | * @param string $context View or edit context. |
1194 | 1194 | * @return string |
1195 | 1195 | */ |
1196 | - public function get_vat_rate( $context = 'view' ) { |
|
1197 | - return $this->get_prop( 'vat_rate', $context ); |
|
1196 | + public function get_vat_rate($context = 'view') { |
|
1197 | + return $this->get_prop('vat_rate', $context); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | 1200 | /** |
@@ -1204,8 +1204,8 @@ discard block |
||
1204 | 1204 | * @param string $context View or edit context. |
1205 | 1205 | * @return string |
1206 | 1206 | */ |
1207 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1208 | - return $this->get_vat_rate( $context ); |
|
1207 | + public function get_user_vat_rate($context = 'view') { |
|
1208 | + return $this->get_vat_rate($context); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | /** |
@@ -1215,8 +1215,8 @@ discard block |
||
1215 | 1215 | * @param string $context View or edit context. |
1216 | 1216 | * @return string |
1217 | 1217 | */ |
1218 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1219 | - return $this->get_vat_rate( $context ); |
|
1218 | + public function get_customer_vat_rate($context = 'view') { |
|
1219 | + return $this->get_vat_rate($context); |
|
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | /** |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | * @param string $context View or edit context. |
1227 | 1227 | * @return string |
1228 | 1228 | */ |
1229 | - public function get_address( $context = 'view' ) { |
|
1230 | - return $this->get_prop( 'address', $context ); |
|
1229 | + public function get_address($context = 'view') { |
|
1230 | + return $this->get_prop('address', $context); |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | /** |
@@ -1237,8 +1237,8 @@ discard block |
||
1237 | 1237 | * @param string $context View or edit context. |
1238 | 1238 | * @return string |
1239 | 1239 | */ |
1240 | - public function get_user_address( $context = 'view' ) { |
|
1241 | - return $this->get_address( $context ); |
|
1240 | + public function get_user_address($context = 'view') { |
|
1241 | + return $this->get_address($context); |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | /** |
@@ -1248,8 +1248,8 @@ discard block |
||
1248 | 1248 | * @param string $context View or edit context. |
1249 | 1249 | * @return string |
1250 | 1250 | */ |
1251 | - public function get_customer_address( $context = 'view' ) { |
|
1252 | - return $this->get_address( $context ); |
|
1251 | + public function get_customer_address($context = 'view') { |
|
1252 | + return $this->get_address($context); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | /** |
@@ -1259,8 +1259,8 @@ discard block |
||
1259 | 1259 | * @param string $context View or edit context. |
1260 | 1260 | * @return bool |
1261 | 1261 | */ |
1262 | - public function get_is_viewed( $context = 'view' ) { |
|
1263 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1262 | + public function get_is_viewed($context = 'view') { |
|
1263 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | /** |
@@ -1270,8 +1270,8 @@ discard block |
||
1270 | 1270 | * @param string $context View or edit context. |
1271 | 1271 | * @return bool |
1272 | 1272 | */ |
1273 | - public function get_email_cc( $context = 'view' ) { |
|
1274 | - return $this->get_prop( 'email_cc', $context ); |
|
1273 | + public function get_email_cc($context = 'view') { |
|
1274 | + return $this->get_prop('email_cc', $context); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | /** |
@@ -1281,8 +1281,8 @@ discard block |
||
1281 | 1281 | * @param string $context View or edit context. |
1282 | 1282 | * @return bool |
1283 | 1283 | */ |
1284 | - public function get_template( $context = 'view' ) { |
|
1285 | - return $this->get_prop( 'template', $context ); |
|
1284 | + public function get_template($context = 'view') { |
|
1285 | + return $this->get_prop('template', $context); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | /** |
@@ -1292,8 +1292,8 @@ discard block |
||
1292 | 1292 | * @param string $context View or edit context. |
1293 | 1293 | * @return bool |
1294 | 1294 | */ |
1295 | - public function get_address_confirmed( $context = 'view' ) { |
|
1296 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1295 | + public function get_address_confirmed($context = 'view') { |
|
1296 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | /** |
@@ -1303,8 +1303,8 @@ discard block |
||
1303 | 1303 | * @param string $context View or edit context. |
1304 | 1304 | * @return bool |
1305 | 1305 | */ |
1306 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1307 | - return $this->get_address_confirmed( $context ); |
|
1306 | + public function get_user_address_confirmed($context = 'view') { |
|
1307 | + return $this->get_address_confirmed($context); |
|
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | /** |
@@ -1314,8 +1314,8 @@ discard block |
||
1314 | 1314 | * @param string $context View or edit context. |
1315 | 1315 | * @return bool |
1316 | 1316 | */ |
1317 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1318 | - return $this->get_address_confirmed( $context ); |
|
1317 | + public function get_customer_address_confirmed($context = 'view') { |
|
1318 | + return $this->get_address_confirmed($context); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | /** |
@@ -1325,12 +1325,12 @@ discard block |
||
1325 | 1325 | * @param string $context View or edit context. |
1326 | 1326 | * @return float |
1327 | 1327 | */ |
1328 | - public function get_subtotal( $context = 'view' ) { |
|
1329 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1328 | + public function get_subtotal($context = 'view') { |
|
1329 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1330 | 1330 | |
1331 | 1331 | // Backwards compatibility. |
1332 | - if ( is_bool( $context ) && $context ) { |
|
1333 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
1332 | + if (is_bool($context) && $context) { |
|
1333 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | return $subtotal; |
@@ -1343,8 +1343,8 @@ discard block |
||
1343 | 1343 | * @param string $context View or edit context. |
1344 | 1344 | * @return float |
1345 | 1345 | */ |
1346 | - public function get_total_discount( $context = 'view' ) { |
|
1347 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1346 | + public function get_total_discount($context = 'view') { |
|
1347 | + return (float) $this->get_prop('total_discount', $context); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | /** |
@@ -1354,18 +1354,18 @@ discard block |
||
1354 | 1354 | * @param string $context View or edit context. |
1355 | 1355 | * @return float |
1356 | 1356 | */ |
1357 | - public function get_total_tax( $context = 'view' ) { |
|
1358 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1357 | + public function get_total_tax($context = 'view') { |
|
1358 | + return (float) $this->get_prop('total_tax', $context); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | /** |
1362 | 1362 | * @deprecated |
1363 | 1363 | */ |
1364 | - public function get_final_tax( $currency = false ) { |
|
1364 | + public function get_final_tax($currency = false) { |
|
1365 | 1365 | $tax = $this->get_total_tax(); |
1366 | 1366 | |
1367 | - if ( $currency ) { |
|
1368 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
1367 | + if ($currency) { |
|
1368 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | return $tax; |
@@ -1378,8 +1378,8 @@ discard block |
||
1378 | 1378 | * @param string $context View or edit context. |
1379 | 1379 | * @return float |
1380 | 1380 | */ |
1381 | - public function get_total_fees( $context = 'view' ) { |
|
1382 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1381 | + public function get_total_fees($context = 'view') { |
|
1382 | + return (float) $this->get_prop('total_fees', $context); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | /** |
@@ -1389,8 +1389,8 @@ discard block |
||
1389 | 1389 | * @param string $context View or edit context. |
1390 | 1390 | * @return float |
1391 | 1391 | */ |
1392 | - public function get_fees_total( $context = 'view' ) { |
|
1393 | - return $this->get_total_fees( $context ); |
|
1392 | + public function get_fees_total($context = 'view') { |
|
1393 | + return $this->get_total_fees($context); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | /** |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | */ |
1402 | 1402 | public function get_total() { |
1403 | 1403 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
1404 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1404 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | /** |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | */ |
1424 | 1424 | public function get_initial_total() { |
1425 | 1425 | |
1426 | - if ( empty( $this->totals ) ) { |
|
1426 | + if (empty($this->totals)) { |
|
1427 | 1427 | $this->recalculate_total(); |
1428 | 1428 | } |
1429 | 1429 | |
@@ -1433,11 +1433,11 @@ discard block |
||
1433 | 1433 | $subtotal = $this->totals['subtotal']['initial']; |
1434 | 1434 | $total = $tax + $fee - $discount + $subtotal; |
1435 | 1435 | |
1436 | - if ( 0 > $total ) { |
|
1436 | + if (0 > $total) { |
|
1437 | 1437 | $total = 0; |
1438 | 1438 | } |
1439 | 1439 | |
1440 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1440 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1441 | 1441 | } |
1442 | 1442 | |
1443 | 1443 | /** |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | */ |
1450 | 1450 | public function get_recurring_total() { |
1451 | 1451 | |
1452 | - if ( empty( $this->totals ) ) { |
|
1452 | + if (empty($this->totals)) { |
|
1453 | 1453 | $this->recalculate_total(); |
1454 | 1454 | } |
1455 | 1455 | |
@@ -1459,11 +1459,11 @@ discard block |
||
1459 | 1459 | $subtotal = $this->totals['subtotal']['recurring']; |
1460 | 1460 | $total = $tax + $fee - $discount + $subtotal; |
1461 | 1461 | |
1462 | - if ( 0 > $total ) { |
|
1462 | + if (0 > $total) { |
|
1463 | 1463 | $total = 0; |
1464 | 1464 | } |
1465 | 1465 | |
1466 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1466 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | /** |
@@ -1474,10 +1474,10 @@ discard block |
||
1474 | 1474 | * @param string $currency Whether to include the currency. |
1475 | 1475 | * @return float |
1476 | 1476 | */ |
1477 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1477 | + public function get_recurring_details($field = '', $currency = false) { |
|
1478 | 1478 | |
1479 | 1479 | // Maybe recalculate totals. |
1480 | - if ( empty( $this->totals ) ) { |
|
1480 | + if (empty($this->totals)) { |
|
1481 | 1481 | $this->recalculate_total(); |
1482 | 1482 | } |
1483 | 1483 | |
@@ -1497,8 +1497,8 @@ discard block |
||
1497 | 1497 | $currency |
1498 | 1498 | ); |
1499 | 1499 | |
1500 | - if ( isset( $data[$field] ) ) { |
|
1501 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1500 | + if (isset($data[$field])) { |
|
1501 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | return $data; |
@@ -1511,8 +1511,8 @@ discard block |
||
1511 | 1511 | * @param string $context View or edit context. |
1512 | 1512 | * @return array |
1513 | 1513 | */ |
1514 | - public function get_fees( $context = 'view' ) { |
|
1515 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1514 | + public function get_fees($context = 'view') { |
|
1515 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | 1518 | /** |
@@ -1522,8 +1522,8 @@ discard block |
||
1522 | 1522 | * @param string $context View or edit context. |
1523 | 1523 | * @return array |
1524 | 1524 | */ |
1525 | - public function get_discounts( $context = 'view' ) { |
|
1526 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1525 | + public function get_discounts($context = 'view') { |
|
1526 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | /** |
@@ -1533,8 +1533,8 @@ discard block |
||
1533 | 1533 | * @param string $context View or edit context. |
1534 | 1534 | * @return array |
1535 | 1535 | */ |
1536 | - public function get_taxes( $context = 'view' ) { |
|
1537 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1536 | + public function get_taxes($context = 'view') { |
|
1537 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | /** |
@@ -1544,8 +1544,8 @@ discard block |
||
1544 | 1544 | * @param string $context View or edit context. |
1545 | 1545 | * @return GetPaid_Form_Item[] |
1546 | 1546 | */ |
1547 | - public function get_items( $context = 'view' ) { |
|
1548 | - return $this->get_prop( 'items', $context ); |
|
1547 | + public function get_items($context = 'view') { |
|
1548 | + return $this->get_prop('items', $context); |
|
1549 | 1549 | } |
1550 | 1550 | |
1551 | 1551 | /** |
@@ -1555,8 +1555,8 @@ discard block |
||
1555 | 1555 | * @param string $context View or edit context. |
1556 | 1556 | * @return int |
1557 | 1557 | */ |
1558 | - public function get_payment_form( $context = 'view' ) { |
|
1559 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1558 | + public function get_payment_form($context = 'view') { |
|
1559 | + return intval($this->get_prop('payment_form', $context)); |
|
1560 | 1560 | } |
1561 | 1561 | |
1562 | 1562 | /** |
@@ -1566,8 +1566,8 @@ discard block |
||
1566 | 1566 | * @param string $context View or edit context. |
1567 | 1567 | * @return string |
1568 | 1568 | */ |
1569 | - public function get_submission_id( $context = 'view' ) { |
|
1570 | - return $this->get_prop( 'submission_id', $context ); |
|
1569 | + public function get_submission_id($context = 'view') { |
|
1570 | + return $this->get_prop('submission_id', $context); |
|
1571 | 1571 | } |
1572 | 1572 | |
1573 | 1573 | /** |
@@ -1577,8 +1577,8 @@ discard block |
||
1577 | 1577 | * @param string $context View or edit context. |
1578 | 1578 | * @return string |
1579 | 1579 | */ |
1580 | - public function get_discount_code( $context = 'view' ) { |
|
1581 | - return $this->get_prop( 'discount_code', $context ); |
|
1580 | + public function get_discount_code($context = 'view') { |
|
1581 | + return $this->get_prop('discount_code', $context); |
|
1582 | 1582 | } |
1583 | 1583 | |
1584 | 1584 | /** |
@@ -1588,8 +1588,8 @@ discard block |
||
1588 | 1588 | * @param string $context View or edit context. |
1589 | 1589 | * @return string |
1590 | 1590 | */ |
1591 | - public function get_gateway( $context = 'view' ) { |
|
1592 | - return $this->get_prop( 'gateway', $context ); |
|
1591 | + public function get_gateway($context = 'view') { |
|
1592 | + return $this->get_prop('gateway', $context); |
|
1593 | 1593 | } |
1594 | 1594 | |
1595 | 1595 | /** |
@@ -1599,8 +1599,8 @@ discard block |
||
1599 | 1599 | * @return string |
1600 | 1600 | */ |
1601 | 1601 | public function get_gateway_title() { |
1602 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1603 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1602 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1603 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1604 | 1604 | } |
1605 | 1605 | |
1606 | 1606 | /** |
@@ -1610,8 +1610,8 @@ discard block |
||
1610 | 1610 | * @param string $context View or edit context. |
1611 | 1611 | * @return string |
1612 | 1612 | */ |
1613 | - public function get_transaction_id( $context = 'view' ) { |
|
1614 | - return $this->get_prop( 'transaction_id', $context ); |
|
1613 | + public function get_transaction_id($context = 'view') { |
|
1614 | + return $this->get_prop('transaction_id', $context); |
|
1615 | 1615 | } |
1616 | 1616 | |
1617 | 1617 | /** |
@@ -1621,9 +1621,9 @@ discard block |
||
1621 | 1621 | * @param string $context View or edit context. |
1622 | 1622 | * @return string |
1623 | 1623 | */ |
1624 | - public function get_currency( $context = 'view' ) { |
|
1625 | - $currency = $this->get_prop( 'currency', $context ); |
|
1626 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1624 | + public function get_currency($context = 'view') { |
|
1625 | + $currency = $this->get_prop('currency', $context); |
|
1626 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1627 | 1627 | } |
1628 | 1628 | |
1629 | 1629 | /** |
@@ -1633,8 +1633,8 @@ discard block |
||
1633 | 1633 | * @param string $context View or edit context. |
1634 | 1634 | * @return bool |
1635 | 1635 | */ |
1636 | - public function get_disable_taxes( $context = 'view' ) { |
|
1637 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1636 | + public function get_disable_taxes($context = 'view') { |
|
1637 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1638 | 1638 | } |
1639 | 1639 | |
1640 | 1640 | /** |
@@ -1644,8 +1644,8 @@ discard block |
||
1644 | 1644 | * @param string $context View or edit context. |
1645 | 1645 | * @return int |
1646 | 1646 | */ |
1647 | - public function get_subscription_id( $context = 'view' ) { |
|
1648 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1647 | + public function get_subscription_id($context = 'view') { |
|
1648 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | /** |
@@ -1655,12 +1655,12 @@ discard block |
||
1655 | 1655 | * @param string $context View or edit context. |
1656 | 1656 | * @return int |
1657 | 1657 | */ |
1658 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1659 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1658 | + public function get_remote_subscription_id($context = 'view') { |
|
1659 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1660 | 1660 | |
1661 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1661 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1662 | 1662 | $parent = $this->get_parent(); |
1663 | - return $parent->get_subscription_id( $context ); |
|
1663 | + return $parent->get_subscription_id($context); |
|
1664 | 1664 | } |
1665 | 1665 | |
1666 | 1666 | return $subscription_id; |
@@ -1673,20 +1673,20 @@ discard block |
||
1673 | 1673 | * @param string $context View or edit context. |
1674 | 1674 | * @return array |
1675 | 1675 | */ |
1676 | - public function get_payment_meta( $context = 'view' ) { |
|
1676 | + public function get_payment_meta($context = 'view') { |
|
1677 | 1677 | |
1678 | 1678 | return array( |
1679 | - 'price' => $this->get_total( $context ), |
|
1680 | - 'date' => $this->get_date_created( $context ), |
|
1681 | - 'user_email' => $this->get_email( $context ), |
|
1682 | - 'invoice_key' => $this->get_key( $context ), |
|
1683 | - 'currency' => $this->get_currency( $context ), |
|
1684 | - 'items' => $this->get_items( $context ), |
|
1685 | - 'user_info' => $this->get_user_info( $context ), |
|
1679 | + 'price' => $this->get_total($context), |
|
1680 | + 'date' => $this->get_date_created($context), |
|
1681 | + 'user_email' => $this->get_email($context), |
|
1682 | + 'invoice_key' => $this->get_key($context), |
|
1683 | + 'currency' => $this->get_currency($context), |
|
1684 | + 'items' => $this->get_items($context), |
|
1685 | + 'user_info' => $this->get_user_info($context), |
|
1686 | 1686 | 'cart_details' => $this->get_cart_details(), |
1687 | - 'status' => $this->get_status( $context ), |
|
1688 | - 'fees' => $this->get_fees( $context ), |
|
1689 | - 'taxes' => $this->get_taxes( $context ), |
|
1687 | + 'status' => $this->get_status($context), |
|
1688 | + 'fees' => $this->get_fees($context), |
|
1689 | + 'taxes' => $this->get_taxes($context), |
|
1690 | 1690 | ); |
1691 | 1691 | |
1692 | 1692 | } |
@@ -1701,9 +1701,9 @@ discard block |
||
1701 | 1701 | $items = $this->get_items(); |
1702 | 1702 | $cart_details = array(); |
1703 | 1703 | |
1704 | - foreach ( $items as $item_id => $item ) { |
|
1704 | + foreach ($items as $item_id => $item) { |
|
1705 | 1705 | $item->invoice_id = $this->get_id(); |
1706 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1706 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1707 | 1707 | } |
1708 | 1708 | |
1709 | 1709 | return $cart_details; |
@@ -1714,11 +1714,11 @@ discard block |
||
1714 | 1714 | * |
1715 | 1715 | * @return null|GetPaid_Form_Item|int |
1716 | 1716 | */ |
1717 | - public function get_recurring( $object = false ) { |
|
1717 | + public function get_recurring($object = false) { |
|
1718 | 1718 | |
1719 | 1719 | // Are we returning an object? |
1720 | - if ( $object ) { |
|
1721 | - return $this->get_item( $this->recurring_item ); |
|
1720 | + if ($object) { |
|
1721 | + return $this->get_item($this->recurring_item); |
|
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | return $this->recurring_item; |
@@ -1733,15 +1733,15 @@ discard block |
||
1733 | 1733 | public function get_subscription_name() { |
1734 | 1734 | |
1735 | 1735 | // Retrieve the recurring name |
1736 | - $item = $this->get_recurring( true ); |
|
1736 | + $item = $this->get_recurring(true); |
|
1737 | 1737 | |
1738 | 1738 | // Abort if it does not exist. |
1739 | - if ( empty( $item ) ) { |
|
1739 | + if (empty($item)) { |
|
1740 | 1740 | return ''; |
1741 | 1741 | } |
1742 | 1742 | |
1743 | 1743 | // Return the item name. |
1744 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1744 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | /** |
@@ -1751,9 +1751,9 @@ discard block |
||
1751 | 1751 | * @return string |
1752 | 1752 | */ |
1753 | 1753 | public function get_view_url() { |
1754 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1755 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1756 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1754 | + $invoice_url = get_permalink($this->get_id()); |
|
1755 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1756 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1757 | 1757 | } |
1758 | 1758 | |
1759 | 1759 | /** |
@@ -1762,25 +1762,25 @@ discard block |
||
1762 | 1762 | * @since 1.0.19 |
1763 | 1763 | * @return string |
1764 | 1764 | */ |
1765 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1765 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1766 | 1766 | |
1767 | 1767 | // Retrieve the checkout url. |
1768 | 1768 | $pay_url = wpinv_get_checkout_uri(); |
1769 | 1769 | |
1770 | 1770 | // Maybe force ssl. |
1771 | - if ( is_ssl() ) { |
|
1772 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1771 | + if (is_ssl()) { |
|
1772 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1773 | 1773 | } |
1774 | 1774 | |
1775 | 1775 | // Add the invoice key. |
1776 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1776 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1777 | 1777 | |
1778 | 1778 | // (Maybe?) add a secret |
1779 | - if ( $secret ) { |
|
1780 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1779 | + if ($secret) { |
|
1780 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1783 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | /** |
@@ -1795,14 +1795,14 @@ discard block |
||
1795 | 1795 | $receipt_url = wpinv_get_success_page_uri(); |
1796 | 1796 | |
1797 | 1797 | // Maybe force ssl. |
1798 | - if ( is_ssl() ) { |
|
1799 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1798 | + if (is_ssl()) { |
|
1799 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1800 | 1800 | } |
1801 | 1801 | |
1802 | 1802 | // Add the invoice key. |
1803 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1803 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1804 | 1804 | |
1805 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1805 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1806 | 1806 | } |
1807 | 1807 | |
1808 | 1808 | /** |
@@ -1815,8 +1815,8 @@ discard block |
||
1815 | 1815 | * @param string $context View or edit context. |
1816 | 1816 | * @return mixed Value of the given invoice property (if set). |
1817 | 1817 | */ |
1818 | - public function get( $key, $context = 'view' ) { |
|
1819 | - return $this->get_prop( $key, $context ); |
|
1818 | + public function get($key, $context = 'view') { |
|
1819 | + return $this->get_prop($key, $context); |
|
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | /* |
@@ -1839,11 +1839,11 @@ discard block |
||
1839 | 1839 | * @param mixed $value new value. |
1840 | 1840 | * @return mixed Value of the given invoice property (if set). |
1841 | 1841 | */ |
1842 | - public function set( $key, $value ) { |
|
1842 | + public function set($key, $value) { |
|
1843 | 1843 | |
1844 | 1844 | $setter = "set_$key"; |
1845 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1846 | - $this->{$setter}( $value ); |
|
1845 | + if (is_callable(array($this, $setter))) { |
|
1846 | + $this->{$setter}($value); |
|
1847 | 1847 | } |
1848 | 1848 | |
1849 | 1849 | } |
@@ -1857,47 +1857,47 @@ discard block |
||
1857 | 1857 | * @param bool $manual_update Is this a manual status change?. |
1858 | 1858 | * @return array details of change. |
1859 | 1859 | */ |
1860 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1860 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1861 | 1861 | $old_status = $this->get_status(); |
1862 | 1862 | |
1863 | 1863 | $statuses = $this->get_all_statuses(); |
1864 | 1864 | |
1865 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1866 | - unset( $statuses[ 'draft' ] ); |
|
1865 | + if (isset($statuses['draft'])) { |
|
1866 | + unset($statuses['draft']); |
|
1867 | 1867 | } |
1868 | 1868 | |
1869 | - $this->set_prop( 'status', $new_status ); |
|
1869 | + $this->set_prop('status', $new_status); |
|
1870 | 1870 | |
1871 | 1871 | // If setting the status, ensure it's set to a valid status. |
1872 | - if ( true === $this->object_read ) { |
|
1872 | + if (true === $this->object_read) { |
|
1873 | 1873 | |
1874 | 1874 | // Only allow valid new status. |
1875 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1875 | + if (!array_key_exists($new_status, $statuses)) { |
|
1876 | 1876 | $new_status = 'wpi-pending'; |
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1880 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1880 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1881 | 1881 | $old_status = 'wpi-pending'; |
1882 | 1882 | } |
1883 | 1883 | |
1884 | 1884 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1885 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1885 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1886 | 1886 | $old_status = 'wpi-pending'; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | 1889 | } |
1890 | 1890 | |
1891 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1891 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
1892 | 1892 | $this->status_transition = array( |
1893 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1893 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1894 | 1894 | 'to' => $new_status, |
1895 | 1895 | 'note' => $note, |
1896 | 1896 | 'manual' => (bool) $manual_update, |
1897 | 1897 | ); |
1898 | 1898 | |
1899 | - if ( $manual_update ) { |
|
1900 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1899 | + if ($manual_update) { |
|
1900 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | $this->maybe_set_date_paid(); |
@@ -1920,8 +1920,8 @@ discard block |
||
1920 | 1920 | */ |
1921 | 1921 | public function maybe_set_date_paid() { |
1922 | 1922 | |
1923 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1924 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1923 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1924 | + $this->set_date_completed(current_time('mysql')); |
|
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | |
@@ -1930,11 +1930,11 @@ discard block |
||
1930 | 1930 | * |
1931 | 1931 | * @since 1.0.19 |
1932 | 1932 | */ |
1933 | - public function set_parent_id( $value ) { |
|
1934 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1933 | + public function set_parent_id($value) { |
|
1934 | + if ($value && ($value === $this->get_id())) { |
|
1935 | 1935 | return; |
1936 | 1936 | } |
1937 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1937 | + $this->set_prop('parent_id', absint($value)); |
|
1938 | 1938 | } |
1939 | 1939 | |
1940 | 1940 | /** |
@@ -1942,8 +1942,8 @@ discard block |
||
1942 | 1942 | * |
1943 | 1943 | * @since 1.0.19 |
1944 | 1944 | */ |
1945 | - public function set_version( $value ) { |
|
1946 | - $this->set_prop( 'version', $value ); |
|
1945 | + public function set_version($value) { |
|
1946 | + $this->set_prop('version', $value); |
|
1947 | 1947 | } |
1948 | 1948 | |
1949 | 1949 | /** |
@@ -1953,15 +1953,15 @@ discard block |
||
1953 | 1953 | * @param string $value Value to set. |
1954 | 1954 | * @return bool Whether or not the date was set. |
1955 | 1955 | */ |
1956 | - public function set_date_created( $value ) { |
|
1957 | - $date = strtotime( $value ); |
|
1956 | + public function set_date_created($value) { |
|
1957 | + $date = strtotime($value); |
|
1958 | 1958 | |
1959 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1960 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
1959 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1960 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
1961 | 1961 | return true; |
1962 | 1962 | } |
1963 | 1963 | |
1964 | - return $this->set_prop( 'date_created', '' ); |
|
1964 | + return $this->set_prop('date_created', ''); |
|
1965 | 1965 | |
1966 | 1966 | } |
1967 | 1967 | |
@@ -1972,15 +1972,15 @@ discard block |
||
1972 | 1972 | * @param string $value Value to set. |
1973 | 1973 | * @return bool Whether or not the date was set. |
1974 | 1974 | */ |
1975 | - public function set_due_date( $value ) { |
|
1976 | - $date = strtotime( $value ); |
|
1975 | + public function set_due_date($value) { |
|
1976 | + $date = strtotime($value); |
|
1977 | 1977 | |
1978 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1979 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
1978 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1979 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
1980 | 1980 | return true; |
1981 | 1981 | } |
1982 | 1982 | |
1983 | - $this->set_prop( 'due_date', '' ); |
|
1983 | + $this->set_prop('due_date', ''); |
|
1984 | 1984 | return false; |
1985 | 1985 | |
1986 | 1986 | } |
@@ -1991,8 +1991,8 @@ discard block |
||
1991 | 1991 | * @since 1.0.19 |
1992 | 1992 | * @param string $value New name. |
1993 | 1993 | */ |
1994 | - public function set_date_due( $value ) { |
|
1995 | - $this->set_due_date( $value ); |
|
1994 | + public function set_date_due($value) { |
|
1995 | + $this->set_due_date($value); |
|
1996 | 1996 | } |
1997 | 1997 | |
1998 | 1998 | /** |
@@ -2002,15 +2002,15 @@ discard block |
||
2002 | 2002 | * @param string $value Value to set. |
2003 | 2003 | * @return bool Whether or not the date was set. |
2004 | 2004 | */ |
2005 | - public function set_completed_date( $value ) { |
|
2006 | - $date = strtotime( $value ); |
|
2005 | + public function set_completed_date($value) { |
|
2006 | + $date = strtotime($value); |
|
2007 | 2007 | |
2008 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2009 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2008 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2009 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2010 | 2010 | return true; |
2011 | 2011 | } |
2012 | 2012 | |
2013 | - $this->set_prop( 'completed_date', '' ); |
|
2013 | + $this->set_prop('completed_date', ''); |
|
2014 | 2014 | return false; |
2015 | 2015 | |
2016 | 2016 | } |
@@ -2021,8 +2021,8 @@ discard block |
||
2021 | 2021 | * @since 1.0.19 |
2022 | 2022 | * @param string $value New name. |
2023 | 2023 | */ |
2024 | - public function set_date_completed( $value ) { |
|
2025 | - $this->set_completed_date( $value ); |
|
2024 | + public function set_date_completed($value) { |
|
2025 | + $this->set_completed_date($value); |
|
2026 | 2026 | } |
2027 | 2027 | |
2028 | 2028 | /** |
@@ -2032,15 +2032,15 @@ discard block |
||
2032 | 2032 | * @param string $value Value to set. |
2033 | 2033 | * @return bool Whether or not the date was set. |
2034 | 2034 | */ |
2035 | - public function set_date_modified( $value ) { |
|
2036 | - $date = strtotime( $value ); |
|
2035 | + public function set_date_modified($value) { |
|
2036 | + $date = strtotime($value); |
|
2037 | 2037 | |
2038 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2039 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2038 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2039 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2040 | 2040 | return true; |
2041 | 2041 | } |
2042 | 2042 | |
2043 | - $this->set_prop( 'date_modified', '' ); |
|
2043 | + $this->set_prop('date_modified', ''); |
|
2044 | 2044 | return false; |
2045 | 2045 | |
2046 | 2046 | } |
@@ -2051,9 +2051,9 @@ discard block |
||
2051 | 2051 | * @since 1.0.19 |
2052 | 2052 | * @param string $value New number. |
2053 | 2053 | */ |
2054 | - public function set_number( $value ) { |
|
2055 | - $number = sanitize_text_field( $value ); |
|
2056 | - $this->set_prop( 'number', $number ); |
|
2054 | + public function set_number($value) { |
|
2055 | + $number = sanitize_text_field($value); |
|
2056 | + $this->set_prop('number', $number); |
|
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | /** |
@@ -2062,9 +2062,9 @@ discard block |
||
2062 | 2062 | * @since 1.0.19 |
2063 | 2063 | * @param string $value Type. |
2064 | 2064 | */ |
2065 | - public function set_type( $value ) { |
|
2066 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2067 | - $this->set_prop( 'type', $type ); |
|
2065 | + public function set_type($value) { |
|
2066 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2067 | + $this->set_prop('type', $type); |
|
2068 | 2068 | } |
2069 | 2069 | |
2070 | 2070 | /** |
@@ -2073,10 +2073,10 @@ discard block |
||
2073 | 2073 | * @since 1.0.19 |
2074 | 2074 | * @param string $value Post type. |
2075 | 2075 | */ |
2076 | - public function set_post_type( $value ) { |
|
2077 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2078 | - $this->set_type( $value ); |
|
2079 | - $this->set_prop( 'post_type', $value ); |
|
2076 | + public function set_post_type($value) { |
|
2077 | + if (getpaid_is_invoice_post_type($value)) { |
|
2078 | + $this->set_type($value); |
|
2079 | + $this->set_prop('post_type', $value); |
|
2080 | 2080 | } |
2081 | 2081 | } |
2082 | 2082 | |
@@ -2086,9 +2086,9 @@ discard block |
||
2086 | 2086 | * @since 1.0.19 |
2087 | 2087 | * @param string $value New key. |
2088 | 2088 | */ |
2089 | - public function set_key( $value ) { |
|
2090 | - $key = sanitize_text_field( $value ); |
|
2091 | - $this->set_prop( 'key', $key ); |
|
2089 | + public function set_key($value) { |
|
2090 | + $key = sanitize_text_field($value); |
|
2091 | + $this->set_prop('key', $key); |
|
2092 | 2092 | } |
2093 | 2093 | |
2094 | 2094 | /** |
@@ -2097,9 +2097,9 @@ discard block |
||
2097 | 2097 | * @since 1.0.19 |
2098 | 2098 | * @param string $value mode. |
2099 | 2099 | */ |
2100 | - public function set_mode( $value ) { |
|
2101 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
2102 | - $this->set_prop( 'value', $value ); |
|
2100 | + public function set_mode($value) { |
|
2101 | + if (!in_array($value, array('live', 'test'))) { |
|
2102 | + $this->set_prop('value', $value); |
|
2103 | 2103 | } |
2104 | 2104 | } |
2105 | 2105 | |
@@ -2109,8 +2109,8 @@ discard block |
||
2109 | 2109 | * @since 1.0.19 |
2110 | 2110 | * @param string $value path. |
2111 | 2111 | */ |
2112 | - public function set_path( $value ) { |
|
2113 | - $this->set_prop( 'path', $value ); |
|
2112 | + public function set_path($value) { |
|
2113 | + $this->set_prop('path', $value); |
|
2114 | 2114 | } |
2115 | 2115 | |
2116 | 2116 | /** |
@@ -2119,9 +2119,9 @@ discard block |
||
2119 | 2119 | * @since 1.0.19 |
2120 | 2120 | * @param string $value New name. |
2121 | 2121 | */ |
2122 | - public function set_name( $value ) { |
|
2123 | - $name = sanitize_text_field( $value ); |
|
2124 | - $this->set_prop( 'name', $name ); |
|
2122 | + public function set_name($value) { |
|
2123 | + $name = sanitize_text_field($value); |
|
2124 | + $this->set_prop('name', $name); |
|
2125 | 2125 | } |
2126 | 2126 | |
2127 | 2127 | /** |
@@ -2130,8 +2130,8 @@ discard block |
||
2130 | 2130 | * @since 1.0.19 |
2131 | 2131 | * @param string $value New name. |
2132 | 2132 | */ |
2133 | - public function set_title( $value ) { |
|
2134 | - $this->set_name( $value ); |
|
2133 | + public function set_title($value) { |
|
2134 | + $this->set_name($value); |
|
2135 | 2135 | } |
2136 | 2136 | |
2137 | 2137 | /** |
@@ -2140,9 +2140,9 @@ discard block |
||
2140 | 2140 | * @since 1.0.19 |
2141 | 2141 | * @param string $value New description. |
2142 | 2142 | */ |
2143 | - public function set_description( $value ) { |
|
2144 | - $description = wp_kses_post( $value ); |
|
2145 | - return $this->set_prop( 'description', $description ); |
|
2143 | + public function set_description($value) { |
|
2144 | + $description = wp_kses_post($value); |
|
2145 | + return $this->set_prop('description', $description); |
|
2146 | 2146 | } |
2147 | 2147 | |
2148 | 2148 | /** |
@@ -2151,8 +2151,8 @@ discard block |
||
2151 | 2151 | * @since 1.0.19 |
2152 | 2152 | * @param string $value New description. |
2153 | 2153 | */ |
2154 | - public function set_excerpt( $value ) { |
|
2155 | - $this->set_description( $value ); |
|
2154 | + public function set_excerpt($value) { |
|
2155 | + $this->set_description($value); |
|
2156 | 2156 | } |
2157 | 2157 | |
2158 | 2158 | /** |
@@ -2161,8 +2161,8 @@ discard block |
||
2161 | 2161 | * @since 1.0.19 |
2162 | 2162 | * @param string $value New description. |
2163 | 2163 | */ |
2164 | - public function set_summary( $value ) { |
|
2165 | - $this->set_description( $value ); |
|
2164 | + public function set_summary($value) { |
|
2165 | + $this->set_description($value); |
|
2166 | 2166 | } |
2167 | 2167 | |
2168 | 2168 | /** |
@@ -2171,12 +2171,12 @@ discard block |
||
2171 | 2171 | * @since 1.0.19 |
2172 | 2172 | * @param int $value New author. |
2173 | 2173 | */ |
2174 | - public function set_author( $value ) { |
|
2175 | - $user = get_user_by( 'id', (int) $value ); |
|
2174 | + public function set_author($value) { |
|
2175 | + $user = get_user_by('id', (int) $value); |
|
2176 | 2176 | |
2177 | - if ( $user && $user->ID ) { |
|
2178 | - $this->set_prop( 'author', $user->ID ); |
|
2179 | - $this->set_prop( 'email', $user->user_email ); |
|
2177 | + if ($user && $user->ID) { |
|
2178 | + $this->set_prop('author', $user->ID); |
|
2179 | + $this->set_prop('email', $user->user_email); |
|
2180 | 2180 | } |
2181 | 2181 | |
2182 | 2182 | } |
@@ -2187,8 +2187,8 @@ discard block |
||
2187 | 2187 | * @since 1.0.19 |
2188 | 2188 | * @param int $value New user id. |
2189 | 2189 | */ |
2190 | - public function set_user_id( $value ) { |
|
2191 | - $this->set_author( $value ); |
|
2190 | + public function set_user_id($value) { |
|
2191 | + $this->set_author($value); |
|
2192 | 2192 | } |
2193 | 2193 | |
2194 | 2194 | /** |
@@ -2197,8 +2197,8 @@ discard block |
||
2197 | 2197 | * @since 1.0.19 |
2198 | 2198 | * @param int $value New user id. |
2199 | 2199 | */ |
2200 | - public function set_customer_id( $value ) { |
|
2201 | - $this->set_author( $value ); |
|
2200 | + public function set_customer_id($value) { |
|
2201 | + $this->set_author($value); |
|
2202 | 2202 | } |
2203 | 2203 | |
2204 | 2204 | /** |
@@ -2207,8 +2207,8 @@ discard block |
||
2207 | 2207 | * @since 1.0.19 |
2208 | 2208 | * @param string $value ip address. |
2209 | 2209 | */ |
2210 | - public function set_ip( $value ) { |
|
2211 | - $this->set_prop( 'ip', $value ); |
|
2210 | + public function set_ip($value) { |
|
2211 | + $this->set_prop('ip', $value); |
|
2212 | 2212 | } |
2213 | 2213 | |
2214 | 2214 | /** |
@@ -2217,8 +2217,8 @@ discard block |
||
2217 | 2217 | * @since 1.0.19 |
2218 | 2218 | * @param string $value ip address. |
2219 | 2219 | */ |
2220 | - public function set_user_ip( $value ) { |
|
2221 | - $this->set_ip( $value ); |
|
2220 | + public function set_user_ip($value) { |
|
2221 | + $this->set_ip($value); |
|
2222 | 2222 | } |
2223 | 2223 | |
2224 | 2224 | /** |
@@ -2227,8 +2227,8 @@ discard block |
||
2227 | 2227 | * @since 1.0.19 |
2228 | 2228 | * @param string $value first name. |
2229 | 2229 | */ |
2230 | - public function set_first_name( $value ) { |
|
2231 | - $this->set_prop( 'first_name', $value ); |
|
2230 | + public function set_first_name($value) { |
|
2231 | + $this->set_prop('first_name', $value); |
|
2232 | 2232 | } |
2233 | 2233 | |
2234 | 2234 | /** |
@@ -2237,8 +2237,8 @@ discard block |
||
2237 | 2237 | * @since 1.0.19 |
2238 | 2238 | * @param string $value first name. |
2239 | 2239 | */ |
2240 | - public function set_user_first_name( $value ) { |
|
2241 | - $this->set_first_name( $value ); |
|
2240 | + public function set_user_first_name($value) { |
|
2241 | + $this->set_first_name($value); |
|
2242 | 2242 | } |
2243 | 2243 | |
2244 | 2244 | /** |
@@ -2247,8 +2247,8 @@ discard block |
||
2247 | 2247 | * @since 1.0.19 |
2248 | 2248 | * @param string $value first name. |
2249 | 2249 | */ |
2250 | - public function set_customer_first_name( $value ) { |
|
2251 | - $this->set_first_name( $value ); |
|
2250 | + public function set_customer_first_name($value) { |
|
2251 | + $this->set_first_name($value); |
|
2252 | 2252 | } |
2253 | 2253 | |
2254 | 2254 | /** |
@@ -2257,8 +2257,8 @@ discard block |
||
2257 | 2257 | * @since 1.0.19 |
2258 | 2258 | * @param string $value last name. |
2259 | 2259 | */ |
2260 | - public function set_last_name( $value ) { |
|
2261 | - $this->set_prop( 'last_name', $value ); |
|
2260 | + public function set_last_name($value) { |
|
2261 | + $this->set_prop('last_name', $value); |
|
2262 | 2262 | } |
2263 | 2263 | |
2264 | 2264 | /** |
@@ -2267,8 +2267,8 @@ discard block |
||
2267 | 2267 | * @since 1.0.19 |
2268 | 2268 | * @param string $value last name. |
2269 | 2269 | */ |
2270 | - public function set_user_last_name( $value ) { |
|
2271 | - $this->set_last_name( $value ); |
|
2270 | + public function set_user_last_name($value) { |
|
2271 | + $this->set_last_name($value); |
|
2272 | 2272 | } |
2273 | 2273 | |
2274 | 2274 | /** |
@@ -2277,8 +2277,8 @@ discard block |
||
2277 | 2277 | * @since 1.0.19 |
2278 | 2278 | * @param string $value last name. |
2279 | 2279 | */ |
2280 | - public function set_customer_last_name( $value ) { |
|
2281 | - $this->set_last_name( $value ); |
|
2280 | + public function set_customer_last_name($value) { |
|
2281 | + $this->set_last_name($value); |
|
2282 | 2282 | } |
2283 | 2283 | |
2284 | 2284 | /** |
@@ -2287,8 +2287,8 @@ discard block |
||
2287 | 2287 | * @since 1.0.19 |
2288 | 2288 | * @param string $value phone. |
2289 | 2289 | */ |
2290 | - public function set_phone( $value ) { |
|
2291 | - $this->set_prop( 'phone', $value ); |
|
2290 | + public function set_phone($value) { |
|
2291 | + $this->set_prop('phone', $value); |
|
2292 | 2292 | } |
2293 | 2293 | |
2294 | 2294 | /** |
@@ -2297,8 +2297,8 @@ discard block |
||
2297 | 2297 | * @since 1.0.19 |
2298 | 2298 | * @param string $value phone. |
2299 | 2299 | */ |
2300 | - public function set_user_phone( $value ) { |
|
2301 | - $this->set_phone( $value ); |
|
2300 | + public function set_user_phone($value) { |
|
2301 | + $this->set_phone($value); |
|
2302 | 2302 | } |
2303 | 2303 | |
2304 | 2304 | /** |
@@ -2307,8 +2307,8 @@ discard block |
||
2307 | 2307 | * @since 1.0.19 |
2308 | 2308 | * @param string $value phone. |
2309 | 2309 | */ |
2310 | - public function set_customer_phone( $value ) { |
|
2311 | - $this->set_phone( $value ); |
|
2310 | + public function set_customer_phone($value) { |
|
2311 | + $this->set_phone($value); |
|
2312 | 2312 | } |
2313 | 2313 | |
2314 | 2314 | /** |
@@ -2317,8 +2317,8 @@ discard block |
||
2317 | 2317 | * @since 1.0.19 |
2318 | 2318 | * @param string $value phone. |
2319 | 2319 | */ |
2320 | - public function set_phone_number( $value ) { |
|
2321 | - $this->set_phone( $value ); |
|
2320 | + public function set_phone_number($value) { |
|
2321 | + $this->set_phone($value); |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | 2324 | /** |
@@ -2327,8 +2327,8 @@ discard block |
||
2327 | 2327 | * @since 1.0.19 |
2328 | 2328 | * @param string $value email address. |
2329 | 2329 | */ |
2330 | - public function set_email( $value ) { |
|
2331 | - $this->set_prop( 'email', $value ); |
|
2330 | + public function set_email($value) { |
|
2331 | + $this->set_prop('email', $value); |
|
2332 | 2332 | } |
2333 | 2333 | |
2334 | 2334 | /** |
@@ -2337,8 +2337,8 @@ discard block |
||
2337 | 2337 | * @since 1.0.19 |
2338 | 2338 | * @param string $value email address. |
2339 | 2339 | */ |
2340 | - public function set_user_email( $value ) { |
|
2341 | - $this->set_email( $value ); |
|
2340 | + public function set_user_email($value) { |
|
2341 | + $this->set_email($value); |
|
2342 | 2342 | } |
2343 | 2343 | |
2344 | 2344 | /** |
@@ -2347,8 +2347,8 @@ discard block |
||
2347 | 2347 | * @since 1.0.19 |
2348 | 2348 | * @param string $value email address. |
2349 | 2349 | */ |
2350 | - public function set_email_address( $value ) { |
|
2351 | - $this->set_email( $value ); |
|
2350 | + public function set_email_address($value) { |
|
2351 | + $this->set_email($value); |
|
2352 | 2352 | } |
2353 | 2353 | |
2354 | 2354 | /** |
@@ -2357,8 +2357,8 @@ discard block |
||
2357 | 2357 | * @since 1.0.19 |
2358 | 2358 | * @param string $value email address. |
2359 | 2359 | */ |
2360 | - public function set_customer_email( $value ) { |
|
2361 | - $this->set_email( $value ); |
|
2360 | + public function set_customer_email($value) { |
|
2361 | + $this->set_email($value); |
|
2362 | 2362 | } |
2363 | 2363 | |
2364 | 2364 | /** |
@@ -2367,8 +2367,8 @@ discard block |
||
2367 | 2367 | * @since 1.0.19 |
2368 | 2368 | * @param string $value country. |
2369 | 2369 | */ |
2370 | - public function set_country( $value ) { |
|
2371 | - $this->set_prop( 'country', $value ); |
|
2370 | + public function set_country($value) { |
|
2371 | + $this->set_prop('country', $value); |
|
2372 | 2372 | } |
2373 | 2373 | |
2374 | 2374 | /** |
@@ -2377,8 +2377,8 @@ discard block |
||
2377 | 2377 | * @since 1.0.19 |
2378 | 2378 | * @param string $value country. |
2379 | 2379 | */ |
2380 | - public function set_user_country( $value ) { |
|
2381 | - $this->set_country( $value ); |
|
2380 | + public function set_user_country($value) { |
|
2381 | + $this->set_country($value); |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | /** |
@@ -2387,8 +2387,8 @@ discard block |
||
2387 | 2387 | * @since 1.0.19 |
2388 | 2388 | * @param string $value country. |
2389 | 2389 | */ |
2390 | - public function set_customer_country( $value ) { |
|
2391 | - $this->set_country( $value ); |
|
2390 | + public function set_customer_country($value) { |
|
2391 | + $this->set_country($value); |
|
2392 | 2392 | } |
2393 | 2393 | |
2394 | 2394 | /** |
@@ -2397,8 +2397,8 @@ discard block |
||
2397 | 2397 | * @since 1.0.19 |
2398 | 2398 | * @param string $value state. |
2399 | 2399 | */ |
2400 | - public function set_state( $value ) { |
|
2401 | - $this->set_prop( 'state', $value ); |
|
2400 | + public function set_state($value) { |
|
2401 | + $this->set_prop('state', $value); |
|
2402 | 2402 | } |
2403 | 2403 | |
2404 | 2404 | /** |
@@ -2407,8 +2407,8 @@ discard block |
||
2407 | 2407 | * @since 1.0.19 |
2408 | 2408 | * @param string $value state. |
2409 | 2409 | */ |
2410 | - public function set_user_state( $value ) { |
|
2411 | - $this->set_state( $value ); |
|
2410 | + public function set_user_state($value) { |
|
2411 | + $this->set_state($value); |
|
2412 | 2412 | } |
2413 | 2413 | |
2414 | 2414 | /** |
@@ -2417,8 +2417,8 @@ discard block |
||
2417 | 2417 | * @since 1.0.19 |
2418 | 2418 | * @param string $value state. |
2419 | 2419 | */ |
2420 | - public function set_customer_state( $value ) { |
|
2421 | - $this->set_state( $value ); |
|
2420 | + public function set_customer_state($value) { |
|
2421 | + $this->set_state($value); |
|
2422 | 2422 | } |
2423 | 2423 | |
2424 | 2424 | /** |
@@ -2427,8 +2427,8 @@ discard block |
||
2427 | 2427 | * @since 1.0.19 |
2428 | 2428 | * @param string $value city. |
2429 | 2429 | */ |
2430 | - public function set_city( $value ) { |
|
2431 | - $this->set_prop( 'city', $value ); |
|
2430 | + public function set_city($value) { |
|
2431 | + $this->set_prop('city', $value); |
|
2432 | 2432 | } |
2433 | 2433 | |
2434 | 2434 | /** |
@@ -2437,8 +2437,8 @@ discard block |
||
2437 | 2437 | * @since 1.0.19 |
2438 | 2438 | * @param string $value city. |
2439 | 2439 | */ |
2440 | - public function set_user_city( $value ) { |
|
2441 | - $this->set_city( $value ); |
|
2440 | + public function set_user_city($value) { |
|
2441 | + $this->set_city($value); |
|
2442 | 2442 | } |
2443 | 2443 | |
2444 | 2444 | /** |
@@ -2447,8 +2447,8 @@ discard block |
||
2447 | 2447 | * @since 1.0.19 |
2448 | 2448 | * @param string $value city. |
2449 | 2449 | */ |
2450 | - public function set_customer_city( $value ) { |
|
2451 | - $this->set_city( $value ); |
|
2450 | + public function set_customer_city($value) { |
|
2451 | + $this->set_city($value); |
|
2452 | 2452 | } |
2453 | 2453 | |
2454 | 2454 | /** |
@@ -2457,8 +2457,8 @@ discard block |
||
2457 | 2457 | * @since 1.0.19 |
2458 | 2458 | * @param string $value zip. |
2459 | 2459 | */ |
2460 | - public function set_zip( $value ) { |
|
2461 | - $this->set_prop( 'zip', $value ); |
|
2460 | + public function set_zip($value) { |
|
2461 | + $this->set_prop('zip', $value); |
|
2462 | 2462 | } |
2463 | 2463 | |
2464 | 2464 | /** |
@@ -2467,8 +2467,8 @@ discard block |
||
2467 | 2467 | * @since 1.0.19 |
2468 | 2468 | * @param string $value zip. |
2469 | 2469 | */ |
2470 | - public function set_user_zip( $value ) { |
|
2471 | - $this->set_zip( $value ); |
|
2470 | + public function set_user_zip($value) { |
|
2471 | + $this->set_zip($value); |
|
2472 | 2472 | } |
2473 | 2473 | |
2474 | 2474 | /** |
@@ -2477,8 +2477,8 @@ discard block |
||
2477 | 2477 | * @since 1.0.19 |
2478 | 2478 | * @param string $value zip. |
2479 | 2479 | */ |
2480 | - public function set_customer_zip( $value ) { |
|
2481 | - $this->set_zip( $value ); |
|
2480 | + public function set_customer_zip($value) { |
|
2481 | + $this->set_zip($value); |
|
2482 | 2482 | } |
2483 | 2483 | |
2484 | 2484 | /** |
@@ -2487,8 +2487,8 @@ discard block |
||
2487 | 2487 | * @since 1.0.19 |
2488 | 2488 | * @param string $value company. |
2489 | 2489 | */ |
2490 | - public function set_company( $value ) { |
|
2491 | - $this->set_prop( 'company', $value ); |
|
2490 | + public function set_company($value) { |
|
2491 | + $this->set_prop('company', $value); |
|
2492 | 2492 | } |
2493 | 2493 | |
2494 | 2494 | /** |
@@ -2497,8 +2497,8 @@ discard block |
||
2497 | 2497 | * @since 1.0.19 |
2498 | 2498 | * @param string $value company. |
2499 | 2499 | */ |
2500 | - public function set_user_company( $value ) { |
|
2501 | - $this->set_company( $value ); |
|
2500 | + public function set_user_company($value) { |
|
2501 | + $this->set_company($value); |
|
2502 | 2502 | } |
2503 | 2503 | |
2504 | 2504 | /** |
@@ -2507,8 +2507,8 @@ discard block |
||
2507 | 2507 | * @since 1.0.19 |
2508 | 2508 | * @param string $value company. |
2509 | 2509 | */ |
2510 | - public function set_customer_company( $value ) { |
|
2511 | - $this->set_company( $value ); |
|
2510 | + public function set_customer_company($value) { |
|
2511 | + $this->set_company($value); |
|
2512 | 2512 | } |
2513 | 2513 | |
2514 | 2514 | /** |
@@ -2517,8 +2517,8 @@ discard block |
||
2517 | 2517 | * @since 1.0.19 |
2518 | 2518 | * @param string $value var number. |
2519 | 2519 | */ |
2520 | - public function set_vat_number( $value ) { |
|
2521 | - $this->set_prop( 'vat_number', $value ); |
|
2520 | + public function set_vat_number($value) { |
|
2521 | + $this->set_prop('vat_number', $value); |
|
2522 | 2522 | } |
2523 | 2523 | |
2524 | 2524 | /** |
@@ -2527,8 +2527,8 @@ discard block |
||
2527 | 2527 | * @since 1.0.19 |
2528 | 2528 | * @param string $value var number. |
2529 | 2529 | */ |
2530 | - public function set_user_vat_number( $value ) { |
|
2531 | - $this->set_vat_number( $value ); |
|
2530 | + public function set_user_vat_number($value) { |
|
2531 | + $this->set_vat_number($value); |
|
2532 | 2532 | } |
2533 | 2533 | |
2534 | 2534 | /** |
@@ -2537,8 +2537,8 @@ discard block |
||
2537 | 2537 | * @since 1.0.19 |
2538 | 2538 | * @param string $value var number. |
2539 | 2539 | */ |
2540 | - public function set_customer_vat_number( $value ) { |
|
2541 | - $this->set_vat_number( $value ); |
|
2540 | + public function set_customer_vat_number($value) { |
|
2541 | + $this->set_vat_number($value); |
|
2542 | 2542 | } |
2543 | 2543 | |
2544 | 2544 | /** |
@@ -2547,8 +2547,8 @@ discard block |
||
2547 | 2547 | * @since 1.0.19 |
2548 | 2548 | * @param string $value var rate. |
2549 | 2549 | */ |
2550 | - public function set_vat_rate( $value ) { |
|
2551 | - $this->set_prop( 'vat_rate', $value ); |
|
2550 | + public function set_vat_rate($value) { |
|
2551 | + $this->set_prop('vat_rate', $value); |
|
2552 | 2552 | } |
2553 | 2553 | |
2554 | 2554 | /** |
@@ -2557,8 +2557,8 @@ discard block |
||
2557 | 2557 | * @since 1.0.19 |
2558 | 2558 | * @param string $value var number. |
2559 | 2559 | */ |
2560 | - public function set_user_vat_rate( $value ) { |
|
2561 | - $this->set_vat_rate( $value ); |
|
2560 | + public function set_user_vat_rate($value) { |
|
2561 | + $this->set_vat_rate($value); |
|
2562 | 2562 | } |
2563 | 2563 | |
2564 | 2564 | /** |
@@ -2567,8 +2567,8 @@ discard block |
||
2567 | 2567 | * @since 1.0.19 |
2568 | 2568 | * @param string $value var number. |
2569 | 2569 | */ |
2570 | - public function set_customer_vat_rate( $value ) { |
|
2571 | - $this->set_vat_rate( $value ); |
|
2570 | + public function set_customer_vat_rate($value) { |
|
2571 | + $this->set_vat_rate($value); |
|
2572 | 2572 | } |
2573 | 2573 | |
2574 | 2574 | /** |
@@ -2577,8 +2577,8 @@ discard block |
||
2577 | 2577 | * @since 1.0.19 |
2578 | 2578 | * @param string $value address. |
2579 | 2579 | */ |
2580 | - public function set_address( $value ) { |
|
2581 | - $this->set_prop( 'address', $value ); |
|
2580 | + public function set_address($value) { |
|
2581 | + $this->set_prop('address', $value); |
|
2582 | 2582 | } |
2583 | 2583 | |
2584 | 2584 | /** |
@@ -2587,8 +2587,8 @@ discard block |
||
2587 | 2587 | * @since 1.0.19 |
2588 | 2588 | * @param string $value address. |
2589 | 2589 | */ |
2590 | - public function set_user_address( $value ) { |
|
2591 | - $this->set_address( $value ); |
|
2590 | + public function set_user_address($value) { |
|
2591 | + $this->set_address($value); |
|
2592 | 2592 | } |
2593 | 2593 | |
2594 | 2594 | /** |
@@ -2597,8 +2597,8 @@ discard block |
||
2597 | 2597 | * @since 1.0.19 |
2598 | 2598 | * @param string $value address. |
2599 | 2599 | */ |
2600 | - public function set_customer_address( $value ) { |
|
2601 | - $this->set_address( $value ); |
|
2600 | + public function set_customer_address($value) { |
|
2601 | + $this->set_address($value); |
|
2602 | 2602 | } |
2603 | 2603 | |
2604 | 2604 | /** |
@@ -2607,8 +2607,8 @@ discard block |
||
2607 | 2607 | * @since 1.0.19 |
2608 | 2608 | * @param int|bool $value confirmed. |
2609 | 2609 | */ |
2610 | - public function set_is_viewed( $value ) { |
|
2611 | - $this->set_prop( 'is_viewed', $value ); |
|
2610 | + public function set_is_viewed($value) { |
|
2611 | + $this->set_prop('is_viewed', $value); |
|
2612 | 2612 | } |
2613 | 2613 | |
2614 | 2614 | /** |
@@ -2617,8 +2617,8 @@ discard block |
||
2617 | 2617 | * @since 1.0.19 |
2618 | 2618 | * @param string $value email recipients. |
2619 | 2619 | */ |
2620 | - public function set_email_cc( $value ) { |
|
2621 | - $this->set_prop( 'email_cc', $value ); |
|
2620 | + public function set_email_cc($value) { |
|
2621 | + $this->set_prop('email_cc', $value); |
|
2622 | 2622 | } |
2623 | 2623 | |
2624 | 2624 | /** |
@@ -2627,9 +2627,9 @@ discard block |
||
2627 | 2627 | * @since 1.0.19 |
2628 | 2628 | * @param string $value email recipients. |
2629 | 2629 | */ |
2630 | - public function set_template( $value ) { |
|
2631 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2632 | - $this->set_prop( 'template', $value ); |
|
2630 | + public function set_template($value) { |
|
2631 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2632 | + $this->set_prop('template', $value); |
|
2633 | 2633 | } |
2634 | 2634 | } |
2635 | 2635 | |
@@ -2639,8 +2639,8 @@ discard block |
||
2639 | 2639 | * @since 1.0.19 |
2640 | 2640 | * @param int|bool $value confirmed. |
2641 | 2641 | */ |
2642 | - public function set_address_confirmed( $value ) { |
|
2643 | - $this->set_prop( 'address_confirmed', $value ); |
|
2642 | + public function set_address_confirmed($value) { |
|
2643 | + $this->set_prop('address_confirmed', $value); |
|
2644 | 2644 | } |
2645 | 2645 | |
2646 | 2646 | /** |
@@ -2649,8 +2649,8 @@ discard block |
||
2649 | 2649 | * @since 1.0.19 |
2650 | 2650 | * @param int|bool $value confirmed. |
2651 | 2651 | */ |
2652 | - public function set_user_address_confirmed( $value ) { |
|
2653 | - $this->set_address_confirmed( $value ); |
|
2652 | + public function set_user_address_confirmed($value) { |
|
2653 | + $this->set_address_confirmed($value); |
|
2654 | 2654 | } |
2655 | 2655 | |
2656 | 2656 | /** |
@@ -2659,8 +2659,8 @@ discard block |
||
2659 | 2659 | * @since 1.0.19 |
2660 | 2660 | * @param int|bool $value confirmed. |
2661 | 2661 | */ |
2662 | - public function set_customer_address_confirmed( $value ) { |
|
2663 | - $this->set_address_confirmed( $value ); |
|
2662 | + public function set_customer_address_confirmed($value) { |
|
2663 | + $this->set_address_confirmed($value); |
|
2664 | 2664 | } |
2665 | 2665 | |
2666 | 2666 | /** |
@@ -2669,8 +2669,8 @@ discard block |
||
2669 | 2669 | * @since 1.0.19 |
2670 | 2670 | * @param float $value sub total. |
2671 | 2671 | */ |
2672 | - public function set_subtotal( $value ) { |
|
2673 | - $this->set_prop( 'subtotal', $value ); |
|
2672 | + public function set_subtotal($value) { |
|
2673 | + $this->set_prop('subtotal', $value); |
|
2674 | 2674 | } |
2675 | 2675 | |
2676 | 2676 | /** |
@@ -2679,8 +2679,8 @@ discard block |
||
2679 | 2679 | * @since 1.0.19 |
2680 | 2680 | * @param float $value discount total. |
2681 | 2681 | */ |
2682 | - public function set_total_discount( $value ) { |
|
2683 | - $this->set_prop( 'total_discount', $value ); |
|
2682 | + public function set_total_discount($value) { |
|
2683 | + $this->set_prop('total_discount', $value); |
|
2684 | 2684 | } |
2685 | 2685 | |
2686 | 2686 | /** |
@@ -2689,8 +2689,8 @@ discard block |
||
2689 | 2689 | * @since 1.0.19 |
2690 | 2690 | * @param float $value discount total. |
2691 | 2691 | */ |
2692 | - public function set_discount( $value ) { |
|
2693 | - $this->set_total_discount( $value ); |
|
2692 | + public function set_discount($value) { |
|
2693 | + $this->set_total_discount($value); |
|
2694 | 2694 | } |
2695 | 2695 | |
2696 | 2696 | /** |
@@ -2699,8 +2699,8 @@ discard block |
||
2699 | 2699 | * @since 1.0.19 |
2700 | 2700 | * @param float $value tax total. |
2701 | 2701 | */ |
2702 | - public function set_total_tax( $value ) { |
|
2703 | - $this->set_prop( 'total_tax', $value ); |
|
2702 | + public function set_total_tax($value) { |
|
2703 | + $this->set_prop('total_tax', $value); |
|
2704 | 2704 | } |
2705 | 2705 | |
2706 | 2706 | /** |
@@ -2709,8 +2709,8 @@ discard block |
||
2709 | 2709 | * @since 1.0.19 |
2710 | 2710 | * @param float $value tax total. |
2711 | 2711 | */ |
2712 | - public function set_tax_total( $value ) { |
|
2713 | - $this->set_total_tax( $value ); |
|
2712 | + public function set_tax_total($value) { |
|
2713 | + $this->set_total_tax($value); |
|
2714 | 2714 | } |
2715 | 2715 | |
2716 | 2716 | /** |
@@ -2719,8 +2719,8 @@ discard block |
||
2719 | 2719 | * @since 1.0.19 |
2720 | 2720 | * @param float $value fees total. |
2721 | 2721 | */ |
2722 | - public function set_total_fees( $value ) { |
|
2723 | - $this->set_prop( 'total_fees', $value ); |
|
2722 | + public function set_total_fees($value) { |
|
2723 | + $this->set_prop('total_fees', $value); |
|
2724 | 2724 | } |
2725 | 2725 | |
2726 | 2726 | /** |
@@ -2729,8 +2729,8 @@ discard block |
||
2729 | 2729 | * @since 1.0.19 |
2730 | 2730 | * @param float $value fees total. |
2731 | 2731 | */ |
2732 | - public function set_fees_total( $value ) { |
|
2733 | - $this->set_total_fees( $value ); |
|
2732 | + public function set_fees_total($value) { |
|
2733 | + $this->set_total_fees($value); |
|
2734 | 2734 | } |
2735 | 2735 | |
2736 | 2736 | /** |
@@ -2739,18 +2739,18 @@ discard block |
||
2739 | 2739 | * @since 1.0.19 |
2740 | 2740 | * @param array $value fees. |
2741 | 2741 | */ |
2742 | - public function set_fees( $value ) { |
|
2742 | + public function set_fees($value) { |
|
2743 | 2743 | |
2744 | - $this->set_prop( 'fees', array() ); |
|
2744 | + $this->set_prop('fees', array()); |
|
2745 | 2745 | |
2746 | 2746 | // Ensure that we have an array. |
2747 | - if ( ! is_array( $value ) ) { |
|
2747 | + if (!is_array($value)) { |
|
2748 | 2748 | return; |
2749 | 2749 | } |
2750 | 2750 | |
2751 | - foreach ( $value as $name => $data ) { |
|
2752 | - if ( isset( $data['amount'] ) ) { |
|
2753 | - $this->add_fee( $name, $data['amount'], $data['recurring'] ); |
|
2751 | + foreach ($value as $name => $data) { |
|
2752 | + if (isset($data['amount'])) { |
|
2753 | + $this->add_fee($name, $data['amount'], $data['recurring']); |
|
2754 | 2754 | } |
2755 | 2755 | } |
2756 | 2756 | |
@@ -2762,8 +2762,8 @@ discard block |
||
2762 | 2762 | * @since 1.0.19 |
2763 | 2763 | * @param array $value taxes. |
2764 | 2764 | */ |
2765 | - public function set_taxes( $value ) { |
|
2766 | - $this->set_prop( 'taxes', $value ); |
|
2765 | + public function set_taxes($value) { |
|
2766 | + $this->set_prop('taxes', $value); |
|
2767 | 2767 | } |
2768 | 2768 | |
2769 | 2769 | /** |
@@ -2772,17 +2772,17 @@ discard block |
||
2772 | 2772 | * @since 1.0.19 |
2773 | 2773 | * @param array $value discounts. |
2774 | 2774 | */ |
2775 | - public function set_discounts( $value ) { |
|
2776 | - $this->set_prop( 'discounts', array() ); |
|
2775 | + public function set_discounts($value) { |
|
2776 | + $this->set_prop('discounts', array()); |
|
2777 | 2777 | |
2778 | 2778 | // Ensure that we have an array. |
2779 | - if ( ! is_array( $value ) ) { |
|
2779 | + if (!is_array($value)) { |
|
2780 | 2780 | return; |
2781 | 2781 | } |
2782 | 2782 | |
2783 | - foreach ( $value as $name => $data ) { |
|
2784 | - if ( isset( $data['amount'] ) ) { |
|
2785 | - $this->add_discount( $name, $data['amount'], $data['recurring'] ); |
|
2783 | + foreach ($value as $name => $data) { |
|
2784 | + if (isset($data['amount'])) { |
|
2785 | + $this->add_discount($name, $data['amount'], $data['recurring']); |
|
2786 | 2786 | } |
2787 | 2787 | } |
2788 | 2788 | } |
@@ -2793,18 +2793,18 @@ discard block |
||
2793 | 2793 | * @since 1.0.19 |
2794 | 2794 | * @param GetPaid_Form_Item[] $value items. |
2795 | 2795 | */ |
2796 | - public function set_items( $value ) { |
|
2796 | + public function set_items($value) { |
|
2797 | 2797 | |
2798 | 2798 | // Remove existing items. |
2799 | - $this->set_prop( 'items', array() ); |
|
2799 | + $this->set_prop('items', array()); |
|
2800 | 2800 | |
2801 | 2801 | // Ensure that we have an array. |
2802 | - if ( ! is_array( $value ) ) { |
|
2802 | + if (!is_array($value)) { |
|
2803 | 2803 | return; |
2804 | 2804 | } |
2805 | 2805 | |
2806 | - foreach ( $value as $item ) { |
|
2807 | - $this->add_item( $item ); |
|
2806 | + foreach ($value as $item) { |
|
2807 | + $this->add_item($item); |
|
2808 | 2808 | } |
2809 | 2809 | |
2810 | 2810 | } |
@@ -2815,8 +2815,8 @@ discard block |
||
2815 | 2815 | * @since 1.0.19 |
2816 | 2816 | * @param int $value payment form. |
2817 | 2817 | */ |
2818 | - public function set_payment_form( $value ) { |
|
2819 | - $this->set_prop( 'payment_form', $value ); |
|
2818 | + public function set_payment_form($value) { |
|
2819 | + $this->set_prop('payment_form', $value); |
|
2820 | 2820 | } |
2821 | 2821 | |
2822 | 2822 | /** |
@@ -2825,8 +2825,8 @@ discard block |
||
2825 | 2825 | * @since 1.0.19 |
2826 | 2826 | * @param string $value submission id. |
2827 | 2827 | */ |
2828 | - public function set_submission_id( $value ) { |
|
2829 | - $this->set_prop( 'submission_id', $value ); |
|
2828 | + public function set_submission_id($value) { |
|
2829 | + $this->set_prop('submission_id', $value); |
|
2830 | 2830 | } |
2831 | 2831 | |
2832 | 2832 | /** |
@@ -2835,8 +2835,8 @@ discard block |
||
2835 | 2835 | * @since 1.0.19 |
2836 | 2836 | * @param string $value discount code. |
2837 | 2837 | */ |
2838 | - public function set_discount_code( $value ) { |
|
2839 | - $this->set_prop( 'discount_code', $value ); |
|
2838 | + public function set_discount_code($value) { |
|
2839 | + $this->set_prop('discount_code', $value); |
|
2840 | 2840 | } |
2841 | 2841 | |
2842 | 2842 | /** |
@@ -2845,8 +2845,8 @@ discard block |
||
2845 | 2845 | * @since 1.0.19 |
2846 | 2846 | * @param string $value gateway. |
2847 | 2847 | */ |
2848 | - public function set_gateway( $value ) { |
|
2849 | - $this->set_prop( 'gateway', $value ); |
|
2848 | + public function set_gateway($value) { |
|
2849 | + $this->set_prop('gateway', $value); |
|
2850 | 2850 | } |
2851 | 2851 | |
2852 | 2852 | /** |
@@ -2855,9 +2855,9 @@ discard block |
||
2855 | 2855 | * @since 1.0.19 |
2856 | 2856 | * @param string $value transaction id. |
2857 | 2857 | */ |
2858 | - public function set_transaction_id( $value ) { |
|
2859 | - if ( ! empty( $value ) ) { |
|
2860 | - $this->set_prop( 'transaction_id', $value ); |
|
2858 | + public function set_transaction_id($value) { |
|
2859 | + if (!empty($value)) { |
|
2860 | + $this->set_prop('transaction_id', $value); |
|
2861 | 2861 | } |
2862 | 2862 | } |
2863 | 2863 | |
@@ -2867,8 +2867,8 @@ discard block |
||
2867 | 2867 | * @since 1.0.19 |
2868 | 2868 | * @param string $value currency id. |
2869 | 2869 | */ |
2870 | - public function set_currency( $value ) { |
|
2871 | - $this->set_prop( 'currency', $value ); |
|
2870 | + public function set_currency($value) { |
|
2871 | + $this->set_prop('currency', $value); |
|
2872 | 2872 | } |
2873 | 2873 | |
2874 | 2874 | /** |
@@ -2877,8 +2877,8 @@ discard block |
||
2877 | 2877 | * @since 1.0.19 |
2878 | 2878 | * @param bool $value value. |
2879 | 2879 | */ |
2880 | - public function set_disable_taxes( $value ) { |
|
2881 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2880 | + public function set_disable_taxes($value) { |
|
2881 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2882 | 2882 | } |
2883 | 2883 | |
2884 | 2884 | /** |
@@ -2887,8 +2887,8 @@ discard block |
||
2887 | 2887 | * @since 1.0.19 |
2888 | 2888 | * @param string $value subscription id. |
2889 | 2889 | */ |
2890 | - public function set_subscription_id( $value ) { |
|
2891 | - $this->set_prop( 'subscription_id', $value ); |
|
2890 | + public function set_subscription_id($value) { |
|
2891 | + $this->set_prop('subscription_id', $value); |
|
2892 | 2892 | } |
2893 | 2893 | |
2894 | 2894 | /** |
@@ -2897,8 +2897,8 @@ discard block |
||
2897 | 2897 | * @since 1.0.19 |
2898 | 2898 | * @param string $value subscription id. |
2899 | 2899 | */ |
2900 | - public function set_remote_subscription_id( $value ) { |
|
2901 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
2900 | + public function set_remote_subscription_id($value) { |
|
2901 | + $this->set_prop('remote_subscription_id', $value); |
|
2902 | 2902 | } |
2903 | 2903 | |
2904 | 2904 | /* |
@@ -2915,28 +2915,28 @@ discard block |
||
2915 | 2915 | */ |
2916 | 2916 | public function is_parent() { |
2917 | 2917 | $parent = $this->get_parent_id(); |
2918 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
2918 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
2919 | 2919 | } |
2920 | 2920 | |
2921 | 2921 | /** |
2922 | 2922 | * Checks if this is a renewal invoice. |
2923 | 2923 | */ |
2924 | 2924 | public function is_renewal() { |
2925 | - return ! $this->is_parent(); |
|
2925 | + return !$this->is_parent(); |
|
2926 | 2926 | } |
2927 | 2927 | |
2928 | 2928 | /** |
2929 | 2929 | * Checks if this is a recurring invoice. |
2930 | 2930 | */ |
2931 | 2931 | public function is_recurring() { |
2932 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
2932 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
2933 | 2933 | } |
2934 | 2934 | |
2935 | 2935 | /** |
2936 | 2936 | * Checks if this is a taxable invoice. |
2937 | 2937 | */ |
2938 | 2938 | public function is_taxable() { |
2939 | - return ! $this->get_disable_taxes(); |
|
2939 | + return !$this->get_disable_taxes(); |
|
2940 | 2940 | } |
2941 | 2941 | |
2942 | 2942 | /** |
@@ -2947,57 +2947,57 @@ discard block |
||
2947 | 2947 | |
2948 | 2948 | $requires_vat = false; |
2949 | 2949 | |
2950 | - if ( $this->country ) { |
|
2950 | + if ($this->country) { |
|
2951 | 2951 | $wpi_country = $this->country; |
2952 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
2952 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
2953 | 2953 | } |
2954 | 2954 | |
2955 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
2955 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
2956 | 2956 | } |
2957 | 2957 | |
2958 | 2958 | /** |
2959 | 2959 | * Checks to see if the invoice requires payment. |
2960 | 2960 | */ |
2961 | 2961 | public function is_free() { |
2962 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
2962 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
2963 | 2963 | |
2964 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
2964 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
2965 | 2965 | $is_free = false; |
2966 | 2966 | } |
2967 | 2967 | |
2968 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2968 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2969 | 2969 | } |
2970 | 2970 | |
2971 | 2971 | /** |
2972 | 2972 | * Checks if the invoice is paid. |
2973 | 2973 | */ |
2974 | 2974 | public function is_paid() { |
2975 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2976 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2975 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2976 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
2977 | 2977 | } |
2978 | 2978 | |
2979 | 2979 | /** |
2980 | 2980 | * Checks if the invoice needs payment. |
2981 | 2981 | */ |
2982 | 2982 | public function needs_payment() { |
2983 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
2984 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
2983 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
2984 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
2985 | 2985 | } |
2986 | 2986 | |
2987 | 2987 | /** |
2988 | 2988 | * Checks if the invoice is refunded. |
2989 | 2989 | */ |
2990 | 2990 | public function is_refunded() { |
2991 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
2992 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
2991 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
2992 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
2993 | 2993 | } |
2994 | 2994 | |
2995 | 2995 | /** |
2996 | 2996 | * Checks if the invoice is held. |
2997 | 2997 | */ |
2998 | 2998 | public function is_held() { |
2999 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3000 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
2999 | + $is_held = $this->has_status('wpi-onhold'); |
|
3000 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3001 | 3001 | } |
3002 | 3002 | |
3003 | 3003 | /** |
@@ -3005,30 +3005,30 @@ discard block |
||
3005 | 3005 | */ |
3006 | 3006 | public function is_due() { |
3007 | 3007 | $due_date = $this->get_due_date(); |
3008 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3008 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3009 | 3009 | } |
3010 | 3010 | |
3011 | 3011 | /** |
3012 | 3012 | * Checks if the invoice is draft. |
3013 | 3013 | */ |
3014 | 3014 | public function is_draft() { |
3015 | - return $this->has_status( 'draft, auto-draft' ); |
|
3015 | + return $this->has_status('draft, auto-draft'); |
|
3016 | 3016 | } |
3017 | 3017 | |
3018 | 3018 | /** |
3019 | 3019 | * Checks if the invoice has a given status. |
3020 | 3020 | */ |
3021 | - public function has_status( $status ) { |
|
3022 | - $status = wpinv_parse_list( $status ); |
|
3023 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3021 | + public function has_status($status) { |
|
3022 | + $status = wpinv_parse_list($status); |
|
3023 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3024 | 3024 | } |
3025 | 3025 | |
3026 | 3026 | /** |
3027 | 3027 | * Checks if the invoice is of a given type. |
3028 | 3028 | */ |
3029 | - public function is_type( $type ) { |
|
3030 | - $type = wpinv_parse_list( $type ); |
|
3031 | - return in_array( $this->get_type(), $type ); |
|
3029 | + public function is_type($type) { |
|
3030 | + $type = wpinv_parse_list($type); |
|
3031 | + return in_array($this->get_type(), $type); |
|
3032 | 3032 | } |
3033 | 3033 | |
3034 | 3034 | /** |
@@ -3060,8 +3060,8 @@ discard block |
||
3060 | 3060 | * |
3061 | 3061 | */ |
3062 | 3062 | public function is_initial_free() { |
3063 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3064 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3063 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3064 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3065 | 3065 | } |
3066 | 3066 | |
3067 | 3067 | /** |
@@ -3071,11 +3071,11 @@ discard block |
||
3071 | 3071 | public function item_has_free_trial() { |
3072 | 3072 | |
3073 | 3073 | // Ensure we have a recurring item. |
3074 | - if ( ! $this->is_recurring() ) { |
|
3074 | + if (!$this->is_recurring()) { |
|
3075 | 3075 | return false; |
3076 | 3076 | } |
3077 | 3077 | |
3078 | - $item = $this->get_recurring( true ); |
|
3078 | + $item = $this->get_recurring(true); |
|
3079 | 3079 | return $item->has_free_trial(); |
3080 | 3080 | } |
3081 | 3081 | |
@@ -3083,7 +3083,7 @@ discard block |
||
3083 | 3083 | * Check if the free trial is a result of a discount. |
3084 | 3084 | */ |
3085 | 3085 | public function is_free_trial_from_discount() { |
3086 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3086 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3087 | 3087 | } |
3088 | 3088 | |
3089 | 3089 | /** |
@@ -3092,17 +3092,17 @@ discard block |
||
3092 | 3092 | public function discount_first_payment_only() { |
3093 | 3093 | |
3094 | 3094 | $discount_code = $this->get_discount_code(); |
3095 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
3095 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
3096 | 3096 | return true; |
3097 | 3097 | } |
3098 | 3098 | |
3099 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3099 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3100 | 3100 | |
3101 | - if ( ! $discount || ! $discount->exists() ) { |
|
3101 | + if (!$discount || !$discount->exists()) { |
|
3102 | 3102 | return true; |
3103 | 3103 | } |
3104 | 3104 | |
3105 | - return ! $discount->get_is_recurring(); |
|
3105 | + return !$discount->get_is_recurring(); |
|
3106 | 3106 | } |
3107 | 3107 | |
3108 | 3108 | /* |
@@ -3120,27 +3120,27 @@ discard block |
||
3120 | 3120 | * @param GetPaid_Form_Item|array $item |
3121 | 3121 | * @return WP_Error|Bool |
3122 | 3122 | */ |
3123 | - public function add_item( $item ) { |
|
3123 | + public function add_item($item) { |
|
3124 | 3124 | |
3125 | - if ( is_array( $item ) ) { |
|
3126 | - $item = $this->process_array_item( $item ); |
|
3125 | + if (is_array($item)) { |
|
3126 | + $item = $this->process_array_item($item); |
|
3127 | 3127 | } |
3128 | 3128 | |
3129 | - if ( is_numeric( $item ) ) { |
|
3130 | - $item = new GetPaid_Form_Item( $item ); |
|
3129 | + if (is_numeric($item)) { |
|
3130 | + $item = new GetPaid_Form_Item($item); |
|
3131 | 3131 | } |
3132 | 3132 | |
3133 | 3133 | // Make sure that it is available for purchase. |
3134 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3135 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3134 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3135 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3136 | 3136 | } |
3137 | 3137 | |
3138 | 3138 | // Do we have a recurring item? |
3139 | - if ( $item->is_recurring() ) { |
|
3139 | + if ($item->is_recurring()) { |
|
3140 | 3140 | |
3141 | 3141 | // An invoice can only contain one recurring item. |
3142 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
3143 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
3142 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
3143 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
3144 | 3144 | } |
3145 | 3145 | |
3146 | 3146 | $this->recurring_item = $item->get_id(); |
@@ -3151,9 +3151,9 @@ discard block |
||
3151 | 3151 | |
3152 | 3152 | // Retrieve all items. |
3153 | 3153 | $items = $this->get_items(); |
3154 | - $items[ (int) $item->get_id() ] = $item; |
|
3154 | + $items[(int) $item->get_id()] = $item; |
|
3155 | 3155 | |
3156 | - $this->set_prop( 'items', $items ); |
|
3156 | + $this->set_prop('items', $items); |
|
3157 | 3157 | return true; |
3158 | 3158 | } |
3159 | 3159 | |
@@ -3163,26 +3163,26 @@ discard block |
||
3163 | 3163 | * @since 1.0.19 |
3164 | 3164 | * @return GetPaid_Form_Item |
3165 | 3165 | */ |
3166 | - protected function process_array_item( $array ) { |
|
3166 | + protected function process_array_item($array) { |
|
3167 | 3167 | |
3168 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3169 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3168 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3169 | + $item = new GetPaid_Form_Item($item_id); |
|
3170 | 3170 | |
3171 | 3171 | // Set item data. |
3172 | - foreach( array( 'name', 'price', 'description' ) as $key ) { |
|
3173 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3172 | + foreach (array('name', 'price', 'description') as $key) { |
|
3173 | + if (isset($array["item_$key"])) { |
|
3174 | 3174 | $method = "set_$key"; |
3175 | - $item->$method( $array[ "item_$key" ] ); |
|
3175 | + $item->$method($array["item_$key"]); |
|
3176 | 3176 | } |
3177 | 3177 | } |
3178 | 3178 | |
3179 | - if ( isset( $array['quantity'] ) ) { |
|
3180 | - $item->set_quantity( $array['quantity'] ); |
|
3179 | + if (isset($array['quantity'])) { |
|
3180 | + $item->set_quantity($array['quantity']); |
|
3181 | 3181 | } |
3182 | 3182 | |
3183 | 3183 | // Set item meta. |
3184 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3185 | - $item->set_item_meta( $array['meta'] ); |
|
3184 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3185 | + $item->set_item_meta($array['meta']); |
|
3186 | 3186 | } |
3187 | 3187 | |
3188 | 3188 | return $item; |
@@ -3194,10 +3194,10 @@ discard block |
||
3194 | 3194 | * |
3195 | 3195 | * @since 1.0.19 |
3196 | 3196 | */ |
3197 | - public function get_item( $item_id ) { |
|
3197 | + public function get_item($item_id) { |
|
3198 | 3198 | $items = $this->get_items(); |
3199 | 3199 | $item_id = (int) $item_id; |
3200 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3200 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
3201 | 3201 | } |
3202 | 3202 | |
3203 | 3203 | /** |
@@ -3205,17 +3205,17 @@ discard block |
||
3205 | 3205 | * |
3206 | 3206 | * @since 1.0.19 |
3207 | 3207 | */ |
3208 | - public function remove_item( $item_id ) { |
|
3208 | + public function remove_item($item_id) { |
|
3209 | 3209 | $items = $this->get_items(); |
3210 | 3210 | $item_id = (int) $item_id; |
3211 | 3211 | |
3212 | - if ( $item_id == $this->recurring_item ) { |
|
3212 | + if ($item_id == $this->recurring_item) { |
|
3213 | 3213 | $this->recurring_item = null; |
3214 | 3214 | } |
3215 | 3215 | |
3216 | - if ( isset( $items[ $item_id ] ) ) { |
|
3217 | - unset( $items[ $item_id ] ); |
|
3218 | - $this->set_prop( 'items', $items ); |
|
3216 | + if (isset($items[$item_id])) { |
|
3217 | + unset($items[$item_id]); |
|
3218 | + $this->set_prop('items', $items); |
|
3219 | 3219 | } |
3220 | 3220 | } |
3221 | 3221 | |
@@ -3226,27 +3226,27 @@ discard block |
||
3226 | 3226 | * @param float $value |
3227 | 3227 | * @return WP_Error|Bool |
3228 | 3228 | */ |
3229 | - public function add_fee( $fee, $value, $recurring = false ) { |
|
3229 | + public function add_fee($fee, $value, $recurring = false) { |
|
3230 | 3230 | |
3231 | - $amount = wpinv_sanitize_amount( $value ); |
|
3231 | + $amount = wpinv_sanitize_amount($value); |
|
3232 | 3232 | $fees = $this->get_fees(); |
3233 | 3233 | |
3234 | - if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
|
3234 | + if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) { |
|
3235 | 3235 | |
3236 | - $amount = $fees[ $fee ]['amount'] += $amount; |
|
3237 | - $fees[ $fee ] = array( |
|
3236 | + $amount = $fees[$fee]['amount'] += $amount; |
|
3237 | + $fees[$fee] = array( |
|
3238 | 3238 | 'amount' => $amount, |
3239 | 3239 | 'recurring' => (bool) $recurring, |
3240 | 3240 | ); |
3241 | 3241 | |
3242 | 3242 | } else { |
3243 | - $fees[ $fee ] = array( |
|
3243 | + $fees[$fee] = array( |
|
3244 | 3244 | 'amount' => $amount, |
3245 | 3245 | 'recurring' => (bool) $recurring, |
3246 | 3246 | ); |
3247 | 3247 | } |
3248 | 3248 | |
3249 | - $this->set_prop( 'fees', $fee ); |
|
3249 | + $this->set_prop('fees', $fee); |
|
3250 | 3250 | |
3251 | 3251 | } |
3252 | 3252 | |
@@ -3255,9 +3255,9 @@ discard block |
||
3255 | 3255 | * |
3256 | 3256 | * @since 1.0.19 |
3257 | 3257 | */ |
3258 | - public function get_fee( $fee ) { |
|
3258 | + public function get_fee($fee) { |
|
3259 | 3259 | $fees = $this->get_fees(); |
3260 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3260 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3261 | 3261 | } |
3262 | 3262 | |
3263 | 3263 | /** |
@@ -3265,11 +3265,11 @@ discard block |
||
3265 | 3265 | * |
3266 | 3266 | * @since 1.0.19 |
3267 | 3267 | */ |
3268 | - public function remove_fee( $fee ) { |
|
3268 | + public function remove_fee($fee) { |
|
3269 | 3269 | $fees = $this->get_fees(); |
3270 | - if ( isset( $fees[ $fee ] ) ) { |
|
3271 | - unset( $fees[ $fee ] ); |
|
3272 | - $this->set_prop( 'fees', $fees ); |
|
3270 | + if (isset($fees[$fee])) { |
|
3271 | + unset($fees[$fee]); |
|
3272 | + $this->set_prop('fees', $fees); |
|
3273 | 3273 | } |
3274 | 3274 | } |
3275 | 3275 | |
@@ -3280,27 +3280,27 @@ discard block |
||
3280 | 3280 | * @param float $value |
3281 | 3281 | * @return WP_Error|Bool |
3282 | 3282 | */ |
3283 | - public function add_discount( $discount, $value, $recurring = false ) { |
|
3283 | + public function add_discount($discount, $value, $recurring = false) { |
|
3284 | 3284 | |
3285 | - $amount = wpinv_sanitize_amount( $value ); |
|
3285 | + $amount = wpinv_sanitize_amount($value); |
|
3286 | 3286 | $discounts = $this->get_discounts(); |
3287 | 3287 | |
3288 | - if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
|
3288 | + if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) { |
|
3289 | 3289 | |
3290 | - $amount = $discounts[ $discount ]['amount'] += $amount; |
|
3291 | - $discounts[ $discount ] = array( |
|
3290 | + $amount = $discounts[$discount]['amount'] += $amount; |
|
3291 | + $discounts[$discount] = array( |
|
3292 | 3292 | 'amount' => $amount, |
3293 | 3293 | 'recurring' => (bool) $recurring, |
3294 | 3294 | ); |
3295 | 3295 | |
3296 | 3296 | } else { |
3297 | - $discounts[ $discount ] = array( |
|
3297 | + $discounts[$discount] = array( |
|
3298 | 3298 | 'amount' => $amount, |
3299 | 3299 | 'recurring' => (bool) $recurring, |
3300 | 3300 | ); |
3301 | 3301 | } |
3302 | 3302 | |
3303 | - $this->set_prop( 'discounts', $discount ); |
|
3303 | + $this->set_prop('discounts', $discount); |
|
3304 | 3304 | |
3305 | 3305 | } |
3306 | 3306 | |
@@ -3309,15 +3309,15 @@ discard block |
||
3309 | 3309 | * |
3310 | 3310 | * @since 1.0.19 |
3311 | 3311 | */ |
3312 | - public function get_discount( $discount = false ) { |
|
3312 | + public function get_discount($discount = false) { |
|
3313 | 3313 | |
3314 | 3314 | // Backwards compatibilty. |
3315 | - if ( empty( $discount ) ) { |
|
3315 | + if (empty($discount)) { |
|
3316 | 3316 | return $this->get_total_discount(); |
3317 | 3317 | } |
3318 | 3318 | |
3319 | 3319 | $discounts = $this->get_discounts(); |
3320 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3320 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3321 | 3321 | } |
3322 | 3322 | |
3323 | 3323 | /** |
@@ -3325,11 +3325,11 @@ discard block |
||
3325 | 3325 | * |
3326 | 3326 | * @since 1.0.19 |
3327 | 3327 | */ |
3328 | - public function remove_discount( $discount ) { |
|
3328 | + public function remove_discount($discount) { |
|
3329 | 3329 | $discounts = $this->get_discounts(); |
3330 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3331 | - unset( $discounts[ $discount ] ); |
|
3332 | - $this->set_prop( 'discounts', $discounts ); |
|
3330 | + if (isset($discounts[$discount])) { |
|
3331 | + unset($discounts[$discount]); |
|
3332 | + $this->set_prop('discounts', $discounts); |
|
3333 | 3333 | } |
3334 | 3334 | } |
3335 | 3335 | |
@@ -3339,31 +3339,31 @@ discard block |
||
3339 | 3339 | * @param string $tax |
3340 | 3340 | * @param float $value |
3341 | 3341 | */ |
3342 | - public function add_tax( $tax, $value, $recurring = true ) { |
|
3342 | + public function add_tax($tax, $value, $recurring = true) { |
|
3343 | 3343 | |
3344 | - if ( ! $this->is_taxable() ) { |
|
3344 | + if (!$this->is_taxable()) { |
|
3345 | 3345 | return; |
3346 | 3346 | } |
3347 | 3347 | |
3348 | - $amount = wpinv_sanitize_amount( $value ); |
|
3348 | + $amount = wpinv_sanitize_amount($value); |
|
3349 | 3349 | $taxes = $this->get_taxes(); |
3350 | 3350 | |
3351 | - if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
|
3351 | + if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) { |
|
3352 | 3352 | |
3353 | - $amount = $taxes[ $tax ]['amount'] += $amount; |
|
3354 | - $taxes[ $tax ] = array( |
|
3353 | + $amount = $taxes[$tax]['amount'] += $amount; |
|
3354 | + $taxes[$tax] = array( |
|
3355 | 3355 | 'amount' => $amount, |
3356 | 3356 | 'recurring' => (bool) $recurring, |
3357 | 3357 | ); |
3358 | 3358 | |
3359 | 3359 | } else { |
3360 | - $taxes[ $tax ] = array( |
|
3360 | + $taxes[$tax] = array( |
|
3361 | 3361 | 'amount' => $amount, |
3362 | 3362 | 'recurring' => (bool) $recurring, |
3363 | 3363 | ); |
3364 | 3364 | } |
3365 | 3365 | |
3366 | - $this->set_prop( 'taxes', $tax ); |
|
3366 | + $this->set_prop('taxes', $tax); |
|
3367 | 3367 | |
3368 | 3368 | } |
3369 | 3369 | |
@@ -3372,15 +3372,15 @@ discard block |
||
3372 | 3372 | * |
3373 | 3373 | * @since 1.0.19 |
3374 | 3374 | */ |
3375 | - public function get_tax( $tax = null ) { |
|
3375 | + public function get_tax($tax = null) { |
|
3376 | 3376 | |
3377 | 3377 | // Backwards compatility. |
3378 | - if ( empty( $tax ) ) { |
|
3378 | + if (empty($tax)) { |
|
3379 | 3379 | return $this->get_total_tax(); |
3380 | 3380 | } |
3381 | 3381 | |
3382 | 3382 | $taxes = $this->get_taxes(); |
3383 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3383 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3384 | 3384 | } |
3385 | 3385 | |
3386 | 3386 | /** |
@@ -3388,11 +3388,11 @@ discard block |
||
3388 | 3388 | * |
3389 | 3389 | * @since 1.0.19 |
3390 | 3390 | */ |
3391 | - public function remove_tax( $tax ) { |
|
3391 | + public function remove_tax($tax) { |
|
3392 | 3392 | $taxes = $this->get_discounts(); |
3393 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3394 | - unset( $taxes[ $tax ] ); |
|
3395 | - $this->set_prop( 'taxes', $taxes ); |
|
3393 | + if (isset($taxes[$tax])) { |
|
3394 | + unset($taxes[$tax]); |
|
3395 | + $this->set_prop('taxes', $taxes); |
|
3396 | 3396 | } |
3397 | 3397 | } |
3398 | 3398 | |
@@ -3403,19 +3403,19 @@ discard block |
||
3403 | 3403 | * @return float The recalculated subtotal |
3404 | 3404 | */ |
3405 | 3405 | public function recalculate_subtotal() { |
3406 | - $items = $this->get_items(); |
|
3406 | + $items = $this->get_items(); |
|
3407 | 3407 | $subtotal = 0; |
3408 | 3408 | $recurring = 0; |
3409 | 3409 | |
3410 | - foreach ( $items as $item ) { |
|
3410 | + foreach ($items as $item) { |
|
3411 | 3411 | $subtotal += $item->get_sub_total(); |
3412 | 3412 | $recurring += $item->get_recurring_sub_total(); |
3413 | 3413 | } |
3414 | 3414 | |
3415 | - if ( $this->is_renewal() ) { |
|
3416 | - $this->set_subtotal( $recurring ); |
|
3415 | + if ($this->is_renewal()) { |
|
3416 | + $this->set_subtotal($recurring); |
|
3417 | 3417 | } else { |
3418 | - $this->set_subtotal( $subtotal ); |
|
3418 | + $this->set_subtotal($subtotal); |
|
3419 | 3419 | } |
3420 | 3420 | |
3421 | 3421 | $this->totals['subtotal'] = array( |
@@ -3437,9 +3437,9 @@ discard block |
||
3437 | 3437 | $discount = 0; |
3438 | 3438 | $recurring = 0; |
3439 | 3439 | |
3440 | - foreach ( $discounts as $data ) { |
|
3440 | + foreach ($discounts as $data) { |
|
3441 | 3441 | |
3442 | - if ( $data['recurring'] ) { |
|
3442 | + if ($data['recurring']) { |
|
3443 | 3443 | $recurring += $data['amount']; |
3444 | 3444 | } else { |
3445 | 3445 | $discount += $data['amount']; |
@@ -3447,10 +3447,10 @@ discard block |
||
3447 | 3447 | |
3448 | 3448 | } |
3449 | 3449 | |
3450 | - if ( $this->is_renewal() ) { |
|
3451 | - $this->set_total_discount( $recurring ); |
|
3450 | + if ($this->is_renewal()) { |
|
3451 | + $this->set_total_discount($recurring); |
|
3452 | 3452 | } else { |
3453 | - $this->set_total_discount( $discount ); |
|
3453 | + $this->set_total_discount($discount); |
|
3454 | 3454 | } |
3455 | 3455 | |
3456 | 3456 | $this->totals['discount'] = array( |
@@ -3469,13 +3469,13 @@ discard block |
||
3469 | 3469 | * @return float The recalculated tax |
3470 | 3470 | */ |
3471 | 3471 | public function recalculate_total_tax() { |
3472 | - $taxes = $this->get_taxes(); |
|
3472 | + $taxes = $this->get_taxes(); |
|
3473 | 3473 | $tax = 0; |
3474 | 3474 | $recurring = 0; |
3475 | 3475 | |
3476 | - foreach ( $taxes as $data ) { |
|
3476 | + foreach ($taxes as $data) { |
|
3477 | 3477 | |
3478 | - if ( $data['recurring'] ) { |
|
3478 | + if ($data['recurring']) { |
|
3479 | 3479 | $recurring += $data['amount']; |
3480 | 3480 | } else { |
3481 | 3481 | $tax += $data['amount']; |
@@ -3483,10 +3483,10 @@ discard block |
||
3483 | 3483 | |
3484 | 3484 | } |
3485 | 3485 | |
3486 | - if ( $this->is_renewal() ) { |
|
3487 | - $this->set_total_tax( $recurring ); |
|
3486 | + if ($this->is_renewal()) { |
|
3487 | + $this->set_total_tax($recurring); |
|
3488 | 3488 | } else { |
3489 | - $this->set_total_tax( $tax ); |
|
3489 | + $this->set_total_tax($tax); |
|
3490 | 3490 | } |
3491 | 3491 | |
3492 | 3492 | $this->totals['tax'] = array( |
@@ -3509,9 +3509,9 @@ discard block |
||
3509 | 3509 | $fee = 0; |
3510 | 3510 | $recurring = 0; |
3511 | 3511 | |
3512 | - foreach ( $fees as $data ) { |
|
3512 | + foreach ($fees as $data) { |
|
3513 | 3513 | |
3514 | - if ( $data['recurring'] ) { |
|
3514 | + if ($data['recurring']) { |
|
3515 | 3515 | $recurring += $data['amount']; |
3516 | 3516 | } else { |
3517 | 3517 | $fee += $data['amount']; |
@@ -3519,10 +3519,10 @@ discard block |
||
3519 | 3519 | |
3520 | 3520 | } |
3521 | 3521 | |
3522 | - if ( $this->is_renewal() ) { |
|
3523 | - $this->set_total_fees( $recurring ); |
|
3522 | + if ($this->is_renewal()) { |
|
3523 | + $this->set_total_fees($recurring); |
|
3524 | 3524 | } else { |
3525 | - $this->set_total_fees( $fee ); |
|
3525 | + $this->set_total_fees($fee); |
|
3526 | 3526 | } |
3527 | 3527 | |
3528 | 3528 | $this->totals['fee'] = array( |
@@ -3530,7 +3530,7 @@ discard block |
||
3530 | 3530 | 'recurring' => $recurring, |
3531 | 3531 | ); |
3532 | 3532 | |
3533 | - $this->set_total_fees( $fee ); |
|
3533 | + $this->set_total_fees($fee); |
|
3534 | 3534 | return $this->is_renewal() ? $recurring : $fee; |
3535 | 3535 | } |
3536 | 3536 | |
@@ -3551,9 +3551,9 @@ discard block |
||
3551 | 3551 | /** |
3552 | 3552 | * @deprecated |
3553 | 3553 | */ |
3554 | - public function recalculate_totals( $temp = false ) { |
|
3555 | - $this->update_items( $temp ); |
|
3556 | - $this->save( true ); |
|
3554 | + public function recalculate_totals($temp = false) { |
|
3555 | + $this->update_items($temp); |
|
3556 | + $this->save(true); |
|
3557 | 3557 | return $this; |
3558 | 3558 | } |
3559 | 3559 | |
@@ -3571,36 +3571,36 @@ discard block |
||
3571 | 3571 | * @return int|false The new note's ID on success, false on failure. |
3572 | 3572 | * |
3573 | 3573 | */ |
3574 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3574 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3575 | 3575 | |
3576 | 3576 | // Bail if no note specified or this invoice is not yet saved. |
3577 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3577 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3578 | 3578 | return false; |
3579 | 3579 | } |
3580 | 3580 | |
3581 | 3581 | // If this is an admin comment or it has been added by the user. |
3582 | - if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) { |
|
3583 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3582 | + if (is_user_logged_in() && (wpinv_current_user_can_manage_invoicing() || $added_by_user)) { |
|
3583 | + $user = get_user_by('id', get_current_user_id()); |
|
3584 | 3584 | $author = $user->display_name; |
3585 | 3585 | $author_email = $user->user_email; |
3586 | 3586 | } |
3587 | 3587 | |
3588 | - if ( $system ) { |
|
3589 | - $author = 'System'; |
|
3588 | + if ($system) { |
|
3589 | + $author = 'System'; |
|
3590 | 3590 | $author_email = '[email protected]'; |
3591 | 3591 | } |
3592 | 3592 | |
3593 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3593 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3594 | 3594 | |
3595 | 3595 | } |
3596 | 3596 | |
3597 | 3597 | /** |
3598 | 3598 | * Generates a unique key for the invoice. |
3599 | 3599 | */ |
3600 | - public function generate_key( $string = '' ) { |
|
3601 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3600 | + public function generate_key($string = '') { |
|
3601 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3602 | 3602 | return strtolower( |
3603 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3603 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3604 | 3604 | ); |
3605 | 3605 | } |
3606 | 3606 | |
@@ -3610,11 +3610,11 @@ discard block |
||
3610 | 3610 | public function generate_number() { |
3611 | 3611 | $number = $this->get_id(); |
3612 | 3612 | |
3613 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3614 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3613 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3614 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3615 | 3615 | } |
3616 | 3616 | |
3617 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3617 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3618 | 3618 | |
3619 | 3619 | } |
3620 | 3620 | |
@@ -3627,47 +3627,47 @@ discard block |
||
3627 | 3627 | // Reset status transition variable. |
3628 | 3628 | $this->status_transition = false; |
3629 | 3629 | |
3630 | - if ( $status_transition ) { |
|
3630 | + if ($status_transition) { |
|
3631 | 3631 | try { |
3632 | 3632 | |
3633 | 3633 | // Fire a hook for the status change. |
3634 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3634 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3635 | 3635 | |
3636 | 3636 | // @deprecated this is deprecated and will be removed in the future. |
3637 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3637 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3638 | 3638 | |
3639 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3639 | + if (!empty($status_transition['from'])) { |
|
3640 | 3640 | |
3641 | 3641 | /* translators: 1: old invoice status 2: new invoice status */ |
3642 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3642 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
3643 | 3643 | |
3644 | 3644 | // Fire another hook. |
3645 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3646 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3645 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3646 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3647 | 3647 | |
3648 | 3648 | // @deprecated this is deprecated and will be removed in the future. |
3649 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3649 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3650 | 3650 | |
3651 | 3651 | // Note the transition occurred. |
3652 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3652 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3653 | 3653 | |
3654 | 3654 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3655 | 3655 | if ( |
3656 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
3657 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3656 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true) |
|
3657 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3658 | 3658 | ) { |
3659 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3659 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3660 | 3660 | } |
3661 | 3661 | } else { |
3662 | 3662 | /* translators: %s: new invoice status */ |
3663 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3663 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
3664 | 3664 | |
3665 | 3665 | // Note the transition occurred. |
3666 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3666 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3667 | 3667 | |
3668 | 3668 | } |
3669 | - } catch ( Exception $e ) { |
|
3670 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3669 | + } catch (Exception $e) { |
|
3670 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3671 | 3671 | } |
3672 | 3672 | } |
3673 | 3673 | } |
@@ -3675,13 +3675,13 @@ discard block |
||
3675 | 3675 | /** |
3676 | 3676 | * Updates an invoice status. |
3677 | 3677 | */ |
3678 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3678 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3679 | 3679 | |
3680 | 3680 | // Fires before updating a status. |
3681 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3681 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3682 | 3682 | |
3683 | 3683 | // Update the status. |
3684 | - $this->set_status( $new_status, $note, $manual ); |
|
3684 | + $this->set_status($new_status, $note, $manual); |
|
3685 | 3685 | |
3686 | 3686 | // Save the order. |
3687 | 3687 | return $this->save(); |
@@ -3692,18 +3692,18 @@ discard block |
||
3692 | 3692 | * @deprecated |
3693 | 3693 | */ |
3694 | 3694 | public function refresh_item_ids() { |
3695 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
3696 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3695 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
3696 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3697 | 3697 | } |
3698 | 3698 | |
3699 | 3699 | /** |
3700 | 3700 | * @deprecated |
3701 | 3701 | */ |
3702 | - public function update_items( $temp = false ) { |
|
3702 | + public function update_items($temp = false) { |
|
3703 | 3703 | |
3704 | - $this->set_items( $this->get_items() ); |
|
3704 | + $this->set_items($this->get_items()); |
|
3705 | 3705 | |
3706 | - if ( ! $temp ) { |
|
3706 | + if (!$temp) { |
|
3707 | 3707 | $this->save(); |
3708 | 3708 | } |
3709 | 3709 | |
@@ -3717,11 +3717,11 @@ discard block |
||
3717 | 3717 | |
3718 | 3718 | $discount_code = $this->get_discount_code(); |
3719 | 3719 | |
3720 | - if ( empty( $discount_code ) ) { |
|
3720 | + if (empty($discount_code)) { |
|
3721 | 3721 | return false; |
3722 | 3722 | } |
3723 | 3723 | |
3724 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3724 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3725 | 3725 | |
3726 | 3726 | // Ensure it is active. |
3727 | 3727 | return $discount->exists(); |
@@ -3732,7 +3732,7 @@ discard block |
||
3732 | 3732 | * Refunds an invoice. |
3733 | 3733 | */ |
3734 | 3734 | public function refund() { |
3735 | - $this->set_status( 'wpi-refunded' ); |
|
3735 | + $this->set_status('wpi-refunded'); |
|
3736 | 3736 | $this->save(); |
3737 | 3737 | } |
3738 | 3738 | |
@@ -3741,56 +3741,56 @@ discard block |
||
3741 | 3741 | * |
3742 | 3742 | * @param string $transaction_id |
3743 | 3743 | */ |
3744 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3744 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3745 | 3745 | |
3746 | 3746 | // Set the transaction id. |
3747 | - if ( empty( $transaction_id ) ) { |
|
3747 | + if (empty($transaction_id)) { |
|
3748 | 3748 | $transaction_id = $this->generate_key('trans_'); |
3749 | 3749 | } |
3750 | 3750 | |
3751 | - if ( ! $this->get_transaction_id() ) { |
|
3752 | - $this->set_transaction_id( $transaction_id ); |
|
3751 | + if (!$this->get_transaction_id()) { |
|
3752 | + $this->set_transaction_id($transaction_id); |
|
3753 | 3753 | } |
3754 | 3754 | |
3755 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3755 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3756 | 3756 | return $this->save(); |
3757 | 3757 | } |
3758 | 3758 | |
3759 | 3759 | // Set the completed date. |
3760 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3760 | + $this->set_date_completed(current_time('mysql')); |
|
3761 | 3761 | |
3762 | 3762 | // Set the new status. |
3763 | - if ( $this->is_renewal() ) { |
|
3763 | + if ($this->is_renewal()) { |
|
3764 | 3764 | |
3765 | 3765 | $_note = sprintf( |
3766 | - __( 'Renewed via %s', 'invoicing' ), |
|
3767 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3766 | + __('Renewed via %s', 'invoicing'), |
|
3767 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3768 | 3768 | ); |
3769 | 3769 | |
3770 | - if ( 'none' == $this->get_gateway() ) { |
|
3770 | + if ('none' == $this->get_gateway()) { |
|
3771 | 3771 | $_note = $note; |
3772 | 3772 | } |
3773 | 3773 | |
3774 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3774 | + $this->set_status('wpi-renewal', $_note); |
|
3775 | 3775 | |
3776 | 3776 | } else { |
3777 | 3777 | |
3778 | 3778 | $_note = sprintf( |
3779 | - __( 'Paid via %s', 'invoicing' ), |
|
3780 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3779 | + __('Paid via %s', 'invoicing'), |
|
3780 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3781 | 3781 | ); |
3782 | 3782 | |
3783 | - if ( 'none' == $this->get_gateway() ) { |
|
3783 | + if ('none' == $this->get_gateway()) { |
|
3784 | 3784 | $_note = $note; |
3785 | 3785 | } |
3786 | 3786 | |
3787 | - $this->set_status( 'publish',$_note ); |
|
3787 | + $this->set_status('publish', $_note); |
|
3788 | 3788 | |
3789 | 3789 | } |
3790 | 3790 | |
3791 | 3791 | // Set checkout mode. |
3792 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3793 | - $this->set_mode( $mode ); |
|
3792 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3793 | + $this->set_mode($mode); |
|
3794 | 3794 | |
3795 | 3795 | // Save the invoice. |
3796 | 3796 | $this->save(); |
@@ -3816,9 +3816,9 @@ discard block |
||
3816 | 3816 | * Clears the subscription's cache. |
3817 | 3817 | */ |
3818 | 3818 | public function clear_cache() { |
3819 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
3820 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
3821 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
3819 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
3820 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
3821 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
3822 | 3822 | } |
3823 | 3823 | |
3824 | 3824 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Metaboxes Admin Class |
@@ -25,89 +25,89 @@ discard block |
||
25 | 25 | public static function init() { |
26 | 26 | |
27 | 27 | // Register metaboxes. |
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
28 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2); |
|
29 | 29 | |
30 | 30 | // Remove metaboxes. |
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
31 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30); |
|
32 | 32 | |
33 | 33 | // Rename metaboxes. |
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
34 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45); |
|
35 | 35 | |
36 | 36 | // Save metaboxes. |
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
37 | + add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register core metaboxes. |
42 | 42 | */ |
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
43 | + public static function add_meta_boxes($post_type, $post) { |
|
44 | 44 | global $wpinv_euvat; |
45 | 45 | |
46 | 46 | // For invoices... |
47 | - if ( $post_type == 'wpi_invoice' ) { |
|
48 | - $invoice = new WPInv_Invoice( $post ); |
|
47 | + if ($post_type == 'wpi_invoice') { |
|
48 | + $invoice = new WPInv_Invoice($post); |
|
49 | 49 | |
50 | 50 | // Resend invoice. |
51 | - if ( ! $invoice->is_draft() ) { |
|
52 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low' ); |
|
51 | + if (!$invoice->is_draft()) { |
|
52 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // Subscriptions. |
56 | - if ( $invoice->is_recurring() ) { |
|
57 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' ); |
|
56 | + if ($invoice->is_recurring()) { |
|
57 | + add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Invoice details. |
61 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
61 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default'); |
|
62 | 62 | |
63 | 63 | // Payment details. |
64 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' ); |
|
64 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default'); |
|
65 | 65 | |
66 | 66 | // Billing details. |
67 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' ); |
|
67 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high'); |
|
68 | 68 | |
69 | 69 | // Invoice items. |
70 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
70 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
71 | 71 | |
72 | 72 | // Invoice notes. |
73 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
73 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
74 | 74 | |
75 | 75 | // Payment form information. |
76 | - if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) { |
|
77 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' ); |
|
76 | + if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) { |
|
77 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high'); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | 81 | // For payment forms. |
82 | - if ( $post_type == 'wpi_payment_form' ) { |
|
82 | + if ($post_type == 'wpi_payment_form') { |
|
83 | 83 | |
84 | 84 | // Design payment form. |
85 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
85 | + add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal'); |
|
86 | 86 | |
87 | 87 | // Payment form information. |
88 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
88 | + add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side'); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | 92 | // For invoice items. |
93 | - if ( $post_type == 'wpi_item' ) { |
|
93 | + if ($post_type == 'wpi_item') { |
|
94 | 94 | |
95 | 95 | // Item details. |
96 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
96 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
97 | 97 | |
98 | 98 | // If taxes are enabled, register the tax metabox. |
99 | - if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) { |
|
100 | - add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
99 | + if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) { |
|
100 | + add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Item info. |
104 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
104 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | |
108 | 108 | // For invoice discounts. |
109 | - if ( $post_type == 'wpi_discount' ) { |
|
110 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
109 | + if ($post_type == 'wpi_discount') { |
|
110 | + add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high'); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * Remove some metaboxes. |
118 | 118 | */ |
119 | 119 | public static function remove_meta_boxes() { |
120 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
120 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -133,36 +133,36 @@ discard block |
||
133 | 133 | * @param int $post_id Post ID. |
134 | 134 | * @param object $post Post object. |
135 | 135 | */ |
136 | - public static function save_meta_boxes( $post_id, $post ) { |
|
137 | - $post_id = absint( $post_id ); |
|
136 | + public static function save_meta_boxes($post_id, $post) { |
|
137 | + $post_id = absint($post_id); |
|
138 | 138 | |
139 | 139 | // Do not save for ajax requests. |
140 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
140 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | 144 | // $post_id and $post are required |
145 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
145 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | 149 | // Dont' save meta boxes for revisions or autosaves. |
150 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
150 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | 154 | // Check the nonce. |
155 | - if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) { |
|
155 | + if (empty($_POST['getpaid_meta_nonce']) || !wp_verify_nonce(wp_unslash($_POST['getpaid_meta_nonce']), 'getpaid_meta_nonce')) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
160 | - if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) { |
|
160 | + if (empty($_POST['post_ID']) || absint($_POST['post_ID']) !== $post_id) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | // Check user has permission to edit. |
165 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
165 | + if (!current_user_can('edit_post', $post_id)) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | ); |
177 | 177 | |
178 | 178 | // Is this our post type? |
179 | - if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
179 | + if (empty($post->post_type) || !isset($post_types_map[$post->post_type])) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | self::$saved_meta_boxes = true; |
185 | 185 | |
186 | 186 | // Save the post. |
187 | - $class = $post_types_map[ $post->post_type ]; |
|
188 | - $class::save( $post_id, $_POST, $post ); |
|
187 | + $class = $post_types_map[$post->post_type]; |
|
188 | + $class::save($post_id, $_POST, $post); |
|
189 | 189 | |
190 | 190 | } |
191 | 191 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
74 | 74 | */ |
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
75 | + public function __construct($form = 0) { |
|
76 | + parent::__construct($form); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if (is_numeric($form) && $form > 0) { |
|
79 | + $this->set_id($form); |
|
80 | + } elseif ($form instanceof self) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
82 | + $this->set_id($form->get_id()); |
|
83 | 83 | $this->invoice = $form->invoice; |
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
85 | + } elseif (!empty($form->ID)) { |
|
86 | + $this->set_id($form->ID); |
|
87 | 87 | } else { |
88 | - $this->set_object_read( true ); |
|
88 | + $this->set_object_read(true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
95 | - $this->post = get_post( $this->get_id() ); |
|
96 | - $this->data_store->read( $this ); |
|
94 | + if ($this->get_id() > 0) { |
|
95 | + $this->post = get_post($this->get_id()); |
|
96 | + $this->data_store->read($this); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param string $context View or edit context. |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
123 | + public function get_version($context = 'view') { |
|
124 | + return $this->get_prop('version', $context); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $context View or edit context. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
134 | + public function get_date_created($context = 'view') { |
|
135 | + return $this->get_prop('date_created', $context); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param string $context View or edit context. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
146 | - $date = $this->get_date_created( $context ); |
|
145 | + public function get_date_created_gmt($context = 'view') { |
|
146 | + $date = $this->get_date_created($context); |
|
147 | 147 | |
148 | - if ( $date ) { |
|
149 | - $date = get_gmt_from_date( $date ); |
|
148 | + if ($date) { |
|
149 | + $date = get_gmt_from_date($date); |
|
150 | 150 | } |
151 | 151 | return $date; |
152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $context View or edit context. |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
161 | + public function get_date_modified($context = 'view') { |
|
162 | + return $this->get_prop('date_modified', $context); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $context View or edit context. |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | - $date = $this->get_date_modified( $context ); |
|
172 | + public function get_date_modified_gmt($context = 'view') { |
|
173 | + $date = $this->get_date_modified($context); |
|
174 | 174 | |
175 | - if ( $date ) { |
|
176 | - $date = get_gmt_from_date( $date ); |
|
175 | + if ($date) { |
|
176 | + $date = get_gmt_from_date($date); |
|
177 | 177 | } |
178 | 178 | return $date; |
179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param string $context View or edit context. |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
188 | + public function get_name($context = 'view') { |
|
189 | + return $this->get_prop('name', $context); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @param string $context View or edit context. |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
199 | + public function get_title($context = 'view') { |
|
200 | + return $this->get_name($context); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param string $context View or edit context. |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
210 | + public function get_author($context = 'view') { |
|
211 | + return (int) $this->get_prop('author', $context); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
221 | + public function get_elements($context = 'view') { |
|
222 | + $elements = $this->get_prop('elements', $context); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
224 | + if (empty($elements) || !is_array($elements)) { |
|
225 | + return wpinv_get_data('sample-payment-form'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Ensure that all required elements exist. |
229 | 229 | $_elements = array(); |
230 | - foreach ( $elements as $element ) { |
|
230 | + foreach ($elements as $element) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
233 | 233 | |
234 | 234 | $_elements[] = array( |
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
236 | 236 | 'id' => 'gtscicd', |
237 | 237 | 'name' => 'gtscicd', |
238 | 238 | 'type' => 'gateway_select', |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | * @param string $return objects or arrays. |
258 | 258 | * @return GetPaid_Form_Item[] |
259 | 259 | */ |
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
260 | + public function get_items($context = 'view', $return = 'objects') { |
|
261 | + $items = $this->get_prop('items', $context); |
|
262 | 262 | |
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
263 | + if (empty($items) || !is_array($items)) { |
|
264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Convert the items. |
268 | 268 | $prepared = array(); |
269 | 269 | |
270 | - foreach ( $items as $key => $value ) { |
|
270 | + foreach ($items as $key => $value) { |
|
271 | 271 | |
272 | 272 | //Form items. |
273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
273 | + if ($value instanceof GetPaid_Form_Item) { |
|
274 | 274 | |
275 | - if ( $value->can_purchase() ) { |
|
275 | + if ($value->can_purchase()) { |
|
276 | 276 | $prepared[] = $value; |
277 | 277 | } |
278 | 278 | |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // $item_id => $quantity |
284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | - $item = new GetPaid_Form_Item( $key ); |
|
284 | + if (is_numeric($key) && is_numeric($value)) { |
|
285 | + $item = new GetPaid_Form_Item($key); |
|
286 | 286 | |
287 | - if ( $item->can_purchase() ) { |
|
288 | - $item->set_quantity( $value ); |
|
287 | + if ($item->can_purchase()) { |
|
288 | + $item->set_quantity($value); |
|
289 | 289 | $prepared[] = $item; |
290 | 290 | } |
291 | 291 | |
@@ -293,47 +293,47 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | // $item_id => array( 'price' => 10 ) |
296 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
297 | - $item = new GetPaid_Form_Item( $key ); |
|
296 | + if (is_numeric($key) && is_array($value)) { |
|
297 | + $item = new GetPaid_Form_Item($key); |
|
298 | 298 | |
299 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
300 | - $item->set_price( $value['price'] ); |
|
299 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
300 | + $item->set_price($value['price']); |
|
301 | 301 | } |
302 | 302 | |
303 | - if ( $item->can_purchase() ) { |
|
303 | + if ($item->can_purchase()) { |
|
304 | 304 | $prepared[] = $item; |
305 | 305 | } |
306 | 306 | |
307 | 307 | continue; |
308 | 308 | } |
309 | 309 | |
310 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
310 | + if (is_array($value) && isset($value['id'])) { |
|
311 | 311 | |
312 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
312 | + $item = new GetPaid_Form_Item($value['id']); |
|
313 | 313 | |
314 | - if ( ! $item->can_purchase() ) { |
|
314 | + if (!$item->can_purchase()) { |
|
315 | 315 | continue; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Sub-total (Cart items). |
319 | - if ( isset( $value['subtotal'] ) ) { |
|
320 | - $item->set_price( $value['subtotal'] ); |
|
319 | + if (isset($value['subtotal'])) { |
|
320 | + $item->set_price($value['subtotal']); |
|
321 | 321 | } |
322 | 322 | |
323 | - if ( isset( $value['quantity'] ) ) { |
|
324 | - $item->set_quantity( $value['quantity'] ); |
|
323 | + if (isset($value['quantity'])) { |
|
324 | + $item->set_quantity($value['quantity']); |
|
325 | 325 | } |
326 | 326 | |
327 | - if ( isset( $value['allow_quantities'] ) ) { |
|
328 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
327 | + if (isset($value['allow_quantities'])) { |
|
328 | + $item->set_allow_quantities($value['allow_quantities']); |
|
329 | 329 | } |
330 | 330 | |
331 | - if ( isset( $value['required'] ) ) { |
|
332 | - $item->set_is_required( $value['required'] ); |
|
331 | + if (isset($value['required'])) { |
|
332 | + $item->set_is_required($value['required']); |
|
333 | 333 | } |
334 | 334 | |
335 | - if ( isset( $value['description'] ) ) { |
|
336 | - $item->set_custom_description( $value['description'] ); |
|
335 | + if (isset($value['description'])) { |
|
336 | + $item->set_custom_description($value['description']); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | $prepared[] = $item; |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - if ( 'objects' == $return && 'view' == $context ) { |
|
345 | + if ('objects' == $return && 'view' == $context) { |
|
346 | 346 | return $prepared; |
347 | 347 | } |
348 | 348 | |
349 | 349 | $items = array(); |
350 | - foreach ( $prepared as $item ) { |
|
350 | + foreach ($prepared as $item) { |
|
351 | 351 | $items[] = $item->prepare_data_for_use(); |
352 | 352 | } |
353 | 353 | |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | * @param int $item_id The item id to return. |
362 | 362 | * @return GetPaid_Form_Item|bool |
363 | 363 | */ |
364 | - public function get_item( $item_id ) { |
|
364 | + public function get_item($item_id) { |
|
365 | 365 | |
366 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
366 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
367 | 367 | return false; |
368 | 368 | } |
369 | 369 | |
370 | - foreach( $this->get_items() as $item ) { |
|
371 | - if ( $item->get_id() == (int) $item_id ) { |
|
370 | + foreach ($this->get_items() as $item) { |
|
371 | + if ($item->get_id() == (int) $item_id) { |
|
372 | 372 | return $item; |
373 | 373 | } |
374 | 374 | } |
@@ -384,15 +384,15 @@ discard block |
||
384 | 384 | * @param string $element_type The element type to return. |
385 | 385 | * @return array|bool |
386 | 386 | */ |
387 | - public function get_element_type( $element_type ) { |
|
387 | + public function get_element_type($element_type) { |
|
388 | 388 | |
389 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
389 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | |
393 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
393 | + foreach ($this->get_prop('elements') as $element) { |
|
394 | 394 | |
395 | - if ( $element['type'] == $element_type ) { |
|
395 | + if ($element['type'] == $element_type) { |
|
396 | 396 | return $element; |
397 | 397 | } |
398 | 398 | |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | * @param string $context View or edit context. |
410 | 410 | * @return array |
411 | 411 | */ |
412 | - public function get_earned( $context = 'view' ) { |
|
413 | - return $this->get_prop( 'earned', $context ); |
|
412 | + public function get_earned($context = 'view') { |
|
413 | + return $this->get_prop('earned', $context); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | * @param string $context View or edit context. |
421 | 421 | * @return array |
422 | 422 | */ |
423 | - public function get_refunded( $context = 'view' ) { |
|
424 | - return $this->get_prop( 'refunded', $context ); |
|
423 | + public function get_refunded($context = 'view') { |
|
424 | + return $this->get_prop('refunded', $context); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @param string $context View or edit context. |
432 | 432 | * @return array |
433 | 433 | */ |
434 | - public function get_cancelled( $context = 'view' ) { |
|
435 | - return $this->get_prop( 'cancelled', $context ); |
|
434 | + public function get_cancelled($context = 'view') { |
|
435 | + return $this->get_prop('cancelled', $context); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * @param string $context View or edit context. |
443 | 443 | * @return array |
444 | 444 | */ |
445 | - public function get_failed( $context = 'view' ) { |
|
446 | - return $this->get_prop( 'failed', $context ); |
|
445 | + public function get_failed($context = 'view') { |
|
446 | + return $this->get_prop('failed', $context); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @return string |
455 | 455 | */ |
456 | 456 | public function get_currency() { |
457 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
458 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
457 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
458 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /* |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @since 1.0.19 |
475 | 475 | */ |
476 | - public function set_version( $value ) { |
|
477 | - $this->set_prop( 'version', $value ); |
|
476 | + public function set_version($value) { |
|
477 | + $this->set_prop('version', $value); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
@@ -484,11 +484,11 @@ discard block |
||
484 | 484 | * @param string $value Value to set. |
485 | 485 | * @return bool Whether or not the date was set. |
486 | 486 | */ |
487 | - public function set_date_created( $value ) { |
|
488 | - $date = strtotime( $value ); |
|
487 | + public function set_date_created($value) { |
|
488 | + $date = strtotime($value); |
|
489 | 489 | |
490 | - if ( $date ) { |
|
491 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
490 | + if ($date) { |
|
491 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
492 | 492 | return true; |
493 | 493 | } |
494 | 494 | |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | * @param string $value Value to set. |
504 | 504 | * @return bool Whether or not the date was set. |
505 | 505 | */ |
506 | - public function set_date_modified( $value ) { |
|
507 | - $date = strtotime( $value ); |
|
506 | + public function set_date_modified($value) { |
|
507 | + $date = strtotime($value); |
|
508 | 508 | |
509 | - if ( $date ) { |
|
510 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
509 | + if ($date) { |
|
510 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
511 | 511 | return true; |
512 | 512 | } |
513 | 513 | |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | * @since 1.0.19 |
522 | 522 | * @param string $value New name. |
523 | 523 | */ |
524 | - public function set_name( $value ) { |
|
525 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
524 | + public function set_name($value) { |
|
525 | + $this->set_prop('name', sanitize_text_field($value)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | * @since 1.0.19 |
532 | 532 | * @param string $value New name. |
533 | 533 | */ |
534 | - public function set_title( $value ) { |
|
535 | - $this->set_name( $value ); |
|
534 | + public function set_title($value) { |
|
535 | + $this->set_name($value); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | * @since 1.0.19 |
542 | 542 | * @param int $value New author. |
543 | 543 | */ |
544 | - public function set_author( $value ) { |
|
545 | - $this->set_prop( 'author', (int) $value ); |
|
544 | + public function set_author($value) { |
|
545 | + $this->set_prop('author', (int) $value); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -551,9 +551,9 @@ discard block |
||
551 | 551 | * @since 1.0.19 |
552 | 552 | * @param array $value Form elements. |
553 | 553 | */ |
554 | - public function set_elements( $value ) { |
|
555 | - if ( is_array( $value ) ) { |
|
556 | - $this->set_prop( 'elements', $value ); |
|
554 | + public function set_elements($value) { |
|
555 | + if (is_array($value)) { |
|
556 | + $this->set_prop('elements', $value); |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * @since 1.0.19 |
564 | 564 | * @param array $value Form elements. |
565 | 565 | */ |
566 | - public function set_items( $value ) { |
|
567 | - if ( is_array( $value ) ) { |
|
568 | - $this->set_prop( 'items', $value ); |
|
566 | + public function set_items($value) { |
|
567 | + if (is_array($value)) { |
|
568 | + $this->set_prop('items', $value); |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
@@ -576,8 +576,8 @@ discard block |
||
576 | 576 | * @param float $value Amount earned. |
577 | 577 | * @return array |
578 | 578 | */ |
579 | - public function set_earned( $value ) { |
|
580 | - return $this->set_prop( 'earned', (float) $value ); |
|
579 | + public function set_earned($value) { |
|
580 | + return $this->set_prop('earned', (float) $value); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | * @param float $value Amount refunded. |
588 | 588 | * @return array |
589 | 589 | */ |
590 | - public function set_refunded( $value ) { |
|
591 | - return $this->set_prop( 'refunded', (float) $value ); |
|
590 | + public function set_refunded($value) { |
|
591 | + return $this->set_prop('refunded', (float) $value); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -598,8 +598,8 @@ discard block |
||
598 | 598 | * @param float $value Amount cancelled. |
599 | 599 | * @return array |
600 | 600 | */ |
601 | - public function set_cancelled( $value ) { |
|
602 | - return $this->set_prop( 'cancelled', (float) $value ); |
|
601 | + public function set_cancelled($value) { |
|
602 | + return $this->set_prop('cancelled', (float) $value); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | * @param float $value Amount cancelled. |
610 | 610 | * @return array |
611 | 611 | */ |
612 | - public function set_failed( $value ) { |
|
613 | - return $this->set_prop( 'failed', (float) $value ); |
|
612 | + public function set_failed($value) { |
|
613 | + return $this->set_prop('failed', (float) $value); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | * @deprecated |
620 | 620 | * @return int item id |
621 | 621 | */ |
622 | - public function create( $data = array() ) { |
|
622 | + public function create($data = array()) { |
|
623 | 623 | |
624 | 624 | // Set the properties. |
625 | - if ( is_array( $data ) ) { |
|
626 | - $this->set_props( $data ); |
|
625 | + if (is_array($data)) { |
|
626 | + $this->set_props($data); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | // Save the item. |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | * @deprecated |
638 | 638 | * @return int item id |
639 | 639 | */ |
640 | - public function update( $data = array() ) { |
|
641 | - return $this->create( $data ); |
|
640 | + public function update($data = array()) { |
|
641 | + return $this->create($data); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /* |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | */ |
659 | 659 | public function is_default() { |
660 | 660 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
661 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
661 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -670,11 +670,11 @@ discard block |
||
670 | 670 | public function is_active() { |
671 | 671 | $is_active = 0 !== (int) $this->get_id(); |
672 | 672 | |
673 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
673 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
674 | 674 | $is_active = false; |
675 | 675 | } |
676 | 676 | |
677 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
677 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | * @since 1.0.19 |
684 | 684 | * @return bool |
685 | 685 | */ |
686 | - public function has_item( $item_id ) { |
|
687 | - return false !== $this->get_item( $item_id ); |
|
686 | + public function has_item($item_id) { |
|
687 | + return false !== $this->get_item($item_id); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * @since 1.0.19 |
694 | 694 | * @return bool |
695 | 695 | */ |
696 | - public function has_element_type( $element_type ) { |
|
697 | - return false !== $this->get_element_type( $element_type ); |
|
696 | + public function has_element_type($element_type) { |
|
697 | + return false !== $this->get_element_type($element_type); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -705,13 +705,13 @@ discard block |
||
705 | 705 | */ |
706 | 706 | public function is_recurring() { |
707 | 707 | |
708 | - if ( ! empty( $this->invoice ) ) { |
|
708 | + if (!empty($this->invoice)) { |
|
709 | 709 | return $this->invoice->is_recurring(); |
710 | 710 | } |
711 | 711 | |
712 | - foreach ( $this->get_items() as $item ) { |
|
712 | + foreach ($this->get_items() as $item) { |
|
713 | 713 | |
714 | - if ( $item->is_recurring() ) { |
|
714 | + if ($item->is_recurring()) { |
|
715 | 715 | return true; |
716 | 716 | } |
717 | 717 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | public function get_html() { |
729 | 729 | |
730 | 730 | // Return the HTML. |
731 | - return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) ); |
|
731 | + return wpinv_get_template_html('payment-forms/form.php', array('form' => $this)); |
|
732 | 732 | |
733 | 733 | } |
734 | 734 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -9,42 +9,42 @@ discard block |
||
9 | 9 | |
10 | 10 | public function __construct() { |
11 | 11 | |
12 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
13 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
12 | + if (!defined('WPINV_BP_SLUG')) { |
|
13 | + define('WPINV_BP_SLUG', 'invoices'); |
|
14 | 14 | } |
15 | 15 | |
16 | - add_action( 'wp_ajax_invoicing_filter', array( $this, 'invoices_content' ) ); |
|
17 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $this, 'invoices_content' ) ); |
|
18 | - add_filter( 'wpinv_settings_sections_general', array( $this, 'bp_section' ), 10, 1 ); |
|
19 | - add_filter( 'wpinv_settings_general', array( $this, 'bp_settings' ), 10, 1 ); |
|
20 | - add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 ); |
|
16 | + add_action('wp_ajax_invoicing_filter', array($this, 'invoices_content')); |
|
17 | + add_action('wp_ajax_nopriv_invoicing_filter', array($this, 'invoices_content')); |
|
18 | + add_filter('wpinv_settings_sections_general', array($this, 'bp_section'), 10, 1); |
|
19 | + add_filter('wpinv_settings_general', array($this, 'bp_settings'), 10, 1); |
|
20 | + add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects'), 10, 2); |
|
21 | 21 | add_action('bp_setup_nav', array($this, 'setup_nav'), 15); |
22 | 22 | |
23 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
23 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
24 | 24 | $position = $position !== '' && $position !== false ? $position : 91; |
25 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
26 | - $this->id = WPINV_BP_SLUG; |
|
25 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
26 | + $this->id = WPINV_BP_SLUG; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function setup_nav() { |
30 | 30 | |
31 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) || !is_user_logged_in()) { |
|
31 | + if (wpinv_get_option('wpinv_bp_hide_menu') || !is_user_logged_in()) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | - if(bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')){ |
|
35 | + if (bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $count = $this->get_invoice_count(); |
40 | - $class = ( 0 === $count ) ? 'no-count' : 'count'; |
|
40 | + $class = (0 === $count) ? 'no-count' : 'count'; |
|
41 | 41 | |
42 | 42 | $main_nav_name = sprintf( |
43 | - __( 'My Invoices %s', 'invoicing' ), |
|
43 | + __('My Invoices %s', 'invoicing'), |
|
44 | 44 | sprintf( |
45 | 45 | '<span class="%s">%s</span>', |
46 | - esc_attr( $class ), |
|
47 | - bp_core_number_format( $count ) |
|
46 | + esc_attr($class), |
|
47 | + bp_core_number_format($count) |
|
48 | 48 | ) |
49 | 49 | ); |
50 | 50 | |
@@ -52,31 +52,31 @@ discard block |
||
52 | 52 | 'name' => $main_nav_name, |
53 | 53 | 'slug' => WPINV_BP_SLUG, |
54 | 54 | 'position' => $this->position, |
55 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
55 | + 'screen_function' => array($this, 'invoices_screen'), |
|
56 | 56 | 'default_subnav_slug' => 'invoices', |
57 | 57 | 'item_css_id' => $this->id |
58 | 58 | ); |
59 | 59 | |
60 | - bp_core_new_nav_item( $main_nav ); |
|
60 | + bp_core_new_nav_item($main_nav); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function invoices_screen() { |
64 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
64 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
68 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
69 | 69 | |
70 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
70 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
71 | 71 | |
72 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
72 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public function invoices_content() { |
76 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
76 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
77 | 77 | global $invoices_template; |
78 | 78 | |
79 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
79 | + do_action('wpinv_bp_invoices_before_content'); |
|
80 | 80 | ?> |
81 | 81 | <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative"> |
82 | 82 | <div id="pag-top" class="pagination"> |
@@ -90,61 +90,61 @@ discard block |
||
90 | 90 | <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0"> |
91 | 91 | <thead> |
92 | 92 | <tr> |
93 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
94 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
93 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
94 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
95 | 95 | <?php endforeach; ?> |
96 | 96 | </tr> |
97 | 97 | </thead> |
98 | 98 | <tbody> |
99 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
99 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
100 | 100 | ?> |
101 | 101 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
102 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
103 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
104 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
105 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
106 | - |
|
107 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
108 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
109 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
102 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
103 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
104 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
105 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
106 | + |
|
107 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
108 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
109 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
110 | 110 | </a> |
111 | 111 | |
112 | - <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
113 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
112 | + <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
113 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
114 | 114 | |
115 | - <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?> |
|
116 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
115 | + <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?> |
|
116 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
117 | 117 | |
118 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
119 | - <?php echo $invoice->get_status_label_html() ; ?> |
|
118 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
119 | + <?php echo $invoice->get_status_label_html(); ?> |
|
120 | 120 | |
121 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
122 | - <?php echo $invoice->get_total( true ); ?> |
|
121 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
122 | + <?php echo $invoice->get_total(true); ?> |
|
123 | 123 | |
124 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
124 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
125 | 125 | <?php |
126 | 126 | $actions = array( |
127 | 127 | 'pay' => array( |
128 | 128 | 'url' => $invoice->get_checkout_payment_url(), |
129 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
129 | + 'name' => __('Pay Now', 'invoicing'), |
|
130 | 130 | 'class' => 'btn-success' |
131 | 131 | ), |
132 | 132 | 'print' => array( |
133 | 133 | 'url' => $invoice->get_view_url(), |
134 | - 'name' => __( 'Print', 'invoicing' ), |
|
134 | + 'name' => __('Print', 'invoicing'), |
|
135 | 135 | 'class' => 'btn-primary', |
136 | 136 | 'attrs' => 'target="_blank"' |
137 | 137 | ) |
138 | 138 | ); |
139 | 139 | |
140 | - if ( ! $invoice->needs_payment() ) { |
|
141 | - unset( $actions['pay'] ); |
|
140 | + if (!$invoice->needs_payment()) { |
|
141 | + unset($actions['pay']); |
|
142 | 142 | } |
143 | 143 | |
144 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
145 | - foreach ( $actions as $key => $action ) { |
|
144 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
145 | + foreach ($actions as $key => $action) { |
|
146 | 146 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
147 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
147 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | ?> |
@@ -172,64 +172,64 @@ discard block |
||
172 | 172 | </div> |
173 | 173 | <?php |
174 | 174 | |
175 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
175 | + do_action('wpinv_bp_invoices_after_content'); |
|
176 | 176 | } else { |
177 | 177 | ?> |
178 | 178 | <div id="message" class="info"> |
179 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
179 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
180 | 180 | </div> |
181 | 181 | <?php |
182 | 182 | } |
183 | 183 | |
184 | - if ( defined( 'DOING_AJAX' ) ) { |
|
184 | + if (defined('DOING_AJAX')) { |
|
185 | 185 | exit; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - public function has_invoices( $args = '' ) { |
|
189 | + public function has_invoices($args = '') { |
|
190 | 190 | global $invoices_template; |
191 | 191 | |
192 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
192 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
193 | 193 | // Parse arguments. |
194 | - $r = bp_parse_args( $args, array( |
|
194 | + $r = bp_parse_args($args, array( |
|
195 | 195 | 'status' => 'all', |
196 | 196 | 'page_arg' => 'bpage', |
197 | 197 | 'page' => 1, |
198 | 198 | 'per_page' => $per_page > 0 ? $per_page : 20, |
199 | 199 | 'max' => false, |
200 | 200 | 'user_id' => bp_displayed_user_id(), |
201 | - ), 'has_invoices' ); |
|
201 | + ), 'has_invoices'); |
|
202 | 202 | |
203 | 203 | |
204 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
205 | - $r['per_page'] = (int)$r['max']; |
|
204 | + if (!empty($r['max']) && ((int) $r['per_page'] > (int) $r['max'])) { |
|
205 | + $r['per_page'] = (int) $r['max']; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | // Get the invoices. |
209 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
209 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
210 | 210 | |
211 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
211 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | public function get_invoice_count() { |
215 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'status' => 'all','user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
216 | - $invoices = wpinv_get_invoices( $query ); |
|
215 | + $query = apply_filters('wpinv_user_invoices_count_query', array('status' => 'all', 'user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
216 | + $invoices = wpinv_get_invoices($query); |
|
217 | 217 | |
218 | - return !empty( $invoices ) ? count( $invoices ) : 0; |
|
218 | + return !empty($invoices) ? count($invoices) : 0; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | public function pagination_count() { |
222 | 222 | global $invoices_template; |
223 | 223 | |
224 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
225 | - $from_num = bp_core_number_format( $start_num ); |
|
226 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
227 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
224 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
225 | + $from_num = bp_core_number_format($start_num); |
|
226 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
227 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
228 | 228 | |
229 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
230 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
229 | + if (1 == $invoices_template->total_invoice_count) { |
|
230 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
231 | 231 | } else { |
232 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
232 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | return $message; |
@@ -238,32 +238,32 @@ discard block |
||
238 | 238 | function pagination_links() { |
239 | 239 | global $invoices_template; |
240 | 240 | |
241 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
241 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
242 | 242 | } |
243 | 243 | |
244 | - public function bp_section( $settings = array() ) { |
|
245 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
244 | + public function bp_section($settings = array()) { |
|
245 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
246 | 246 | return $settings; |
247 | 247 | } |
248 | 248 | |
249 | - public function bp_settings( $settings = array() ) { |
|
249 | + public function bp_settings($settings = array()) { |
|
250 | 250 | $settings['wpinv_bp'] = array( |
251 | 251 | 'wpinv_bp_labels' => array( |
252 | 252 | 'id' => 'wpinv_bp_settings', |
253 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
253 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
254 | 254 | 'desc' => '', |
255 | 255 | 'type' => 'header', |
256 | 256 | ), |
257 | 257 | 'wpinv_bp_hide_menu' => array( |
258 | 258 | 'id' => 'wpinv_bp_hide_menu', |
259 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
260 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
259 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
260 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
261 | 261 | 'type' => 'checkbox', |
262 | 262 | ), |
263 | 263 | 'wpinv_menu_position' => array( |
264 | 264 | 'id' => 'wpinv_menu_position', |
265 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
266 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
265 | + 'name' => __('Menu position', 'invoicing'), |
|
266 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
267 | 267 | 'type' => 'number', |
268 | 268 | 'size' => 'small', |
269 | 269 | 'min' => '1', |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | ), |
274 | 274 | 'wpinv_bp_per_page' => array( |
275 | 275 | 'id' => 'wpinv_bp_per_page', |
276 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
277 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
276 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
277 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
278 | 278 | 'type' => 'number', |
279 | 279 | 'size' => 'small', |
280 | 280 | 'min' => '1', |
@@ -287,20 +287,20 @@ discard block |
||
287 | 287 | return $settings; |
288 | 288 | } |
289 | 289 | |
290 | - public function wp_nav_menu_objects($items, $args){ |
|
291 | - if(!is_user_logged_in()){ |
|
290 | + public function wp_nav_menu_objects($items, $args) { |
|
291 | + if (!is_user_logged_in()) { |
|
292 | 292 | return $items; |
293 | 293 | } |
294 | 294 | |
295 | - if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){ |
|
295 | + if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) { |
|
296 | 296 | return $items; |
297 | 297 | } |
298 | 298 | |
299 | 299 | $user_id = get_current_user_id(); |
300 | - $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG; |
|
300 | + $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG; |
|
301 | 301 | $history_link = wpinv_get_history_page_uri(); |
302 | - foreach ( $items as $item ) { |
|
303 | - $item->url = str_replace( $history_link, $link, $item->url ); |
|
302 | + foreach ($items as $item) { |
|
303 | + $item->url = str_replace($history_link, $link, $item->url); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | return $items; |
@@ -318,78 +318,78 @@ discard block |
||
318 | 318 | public $pag_links = ''; |
319 | 319 | public $total_invoice_count = 0; |
320 | 320 | |
321 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
322 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
321 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
322 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
323 | 323 | |
324 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
325 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
326 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
324 | + $this->pag_arg = sanitize_key($page_arg); |
|
325 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
326 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
327 | 327 | |
328 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
329 | - if ( !empty( $status ) && $status != 'all' ) { |
|
328 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
329 | + if (!empty($status) && $status != 'all') { |
|
330 | 330 | $query_args['status'] = $status; |
331 | 331 | } |
332 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
332 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
333 | 333 | |
334 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
335 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
334 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
335 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
336 | 336 | $this->invoices['total'] = $invoices->found_posts; |
337 | 337 | } |
338 | 338 | |
339 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
340 | - $this->total_invoice_count = (int)$this->invoices['total']; |
|
339 | + if (empty($max) || ($max >= (int) $this->invoices['total'])) { |
|
340 | + $this->total_invoice_count = (int) $this->invoices['total']; |
|
341 | 341 | } else { |
342 | - $this->total_invoice_count = (int)$max; |
|
342 | + $this->total_invoice_count = (int) $max; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $this->invoices = $this->invoices['invoices']; |
346 | 346 | |
347 | - $invoice_count = count( $this->invoices ); |
|
347 | + $invoice_count = count($this->invoices); |
|
348 | 348 | |
349 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
350 | - $this->invoice_count = (int)$invoice_count; |
|
349 | + if (empty($max) || ($max >= (int) $invoice_count)) { |
|
350 | + $this->invoice_count = (int) $invoice_count; |
|
351 | 351 | } else { |
352 | - $this->invoice_count = (int)$max; |
|
352 | + $this->invoice_count = (int) $max; |
|
353 | 353 | } |
354 | 354 | |
355 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
356 | - $this->pag_links = paginate_links( array( |
|
357 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
355 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
356 | + $this->pag_links = paginate_links(array( |
|
357 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
358 | 358 | 'format' => '', |
359 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
360 | - 'current' => (int)$this->pag_page, |
|
361 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
362 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
359 | + 'total' => ceil((int) $this->total_invoice_count / (int) $this->pag_num), |
|
360 | + 'current' => (int) $this->pag_page, |
|
361 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
362 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
363 | 363 | 'mid_size' => 1, |
364 | 364 | 'add_args' => array(), |
365 | - ) ); |
|
365 | + )); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | 369 | public function has_invoices() { |
370 | - return (bool) ! empty( $this->invoice_count ); |
|
370 | + return (bool) !empty($this->invoice_count); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | public function next_invoice() { |
374 | 374 | $this->current_invoice++; |
375 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
375 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
376 | 376 | |
377 | 377 | return $this->invoice; |
378 | 378 | } |
379 | 379 | |
380 | 380 | public function rewind_invoices() { |
381 | 381 | $this->current_invoice = -1; |
382 | - if ( $this->invoice_count > 0 ) { |
|
382 | + if ($this->invoice_count > 0) { |
|
383 | 383 | $this->invoice = $this->invoices[0]; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | 387 | public function invoices() { |
388 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
388 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
389 | 389 | return true; |
390 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
390 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
391 | 391 | |
392 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
392 | + do_action('wpinv_bp_invoice_loop_end'); |
|
393 | 393 | |
394 | 394 | $this->rewind_invoices(); |
395 | 395 | } |
@@ -403,19 +403,19 @@ discard block |
||
403 | 403 | $this->in_the_loop = true; |
404 | 404 | $this->invoice = $this->next_invoice(); |
405 | 405 | |
406 | - if ( 0 === $this->current_invoice ) { |
|
407 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
406 | + if (0 === $this->current_invoice) { |
|
407 | + do_action('wpinv_bp_invoice_loop_start'); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
412 | 412 | function wpinv_bp_setup_component() { |
413 | 413 | |
414 | - if(!class_exists( 'BuddyPress' )){ |
|
414 | + if (!class_exists('BuddyPress')) { |
|
415 | 415 | return; |
416 | 416 | } |
417 | 417 | |
418 | 418 | new WPInv_BP_Component(); |
419 | 419 | |
420 | 420 | } |
421 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
422 | 421 | \ No newline at end of file |
422 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
423 | 423 | \ No newline at end of file |
@@ -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(); |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | /** |
481 | 481 | * @deprecated |
482 | 482 | */ |
483 | -function wpinv_send_to_gateway( $gateway, $payment_data ) { |
|
483 | +function wpinv_send_to_gateway($gateway, $payment_data) { |
|
484 | 484 | $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway'); |
485 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
485 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -495,10 +495,10 @@ discard block |
||
495 | 495 | /** |
496 | 496 | * @deprecated |
497 | 497 | */ |
498 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
499 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
500 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
501 | - wp_die( $message, $title, array( 'response' => $status )); |
|
498 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
499 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
500 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
501 | + wp_die($message, $title, array('response' => $status)); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | /** |
@@ -616,14 +616,14 @@ discard block |
||
616 | 616 | /** |
617 | 617 | * @deprecated |
618 | 618 | */ |
619 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
620 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
619 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
620 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
624 | 624 | * @deprecated |
625 | 625 | */ |
626 | -function wpinv_clean_invoice_number( $number ) { |
|
626 | +function wpinv_clean_invoice_number($number) { |
|
627 | 627 | return $number; |
628 | 628 | } |
629 | 629 |
@@ -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 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -103,36 +103,36 @@ discard block |
||
103 | 103 | 'ip_geolocation' => true, |
104 | 104 | ); |
105 | 105 | |
106 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
107 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
108 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
106 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
107 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
108 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
109 | 109 | |
110 | - if ( $nopriv ) { |
|
111 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
112 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
113 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
110 | + if ($nopriv) { |
|
111 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
113 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | public static function add_note() { |
119 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
119 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
120 | 120 | |
121 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
121 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
122 | 122 | die(-1); |
123 | 123 | } |
124 | 124 | |
125 | - $post_id = absint( $_POST['post_id'] ); |
|
126 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
127 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
125 | + $post_id = absint($_POST['post_id']); |
|
126 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
127 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
128 | 128 | |
129 | 129 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
130 | 130 | |
131 | - if ( $post_id > 0 ) { |
|
132 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
131 | + if ($post_id > 0) { |
|
132 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
133 | 133 | |
134 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
135 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
134 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
135 | + wpinv_get_invoice_note_line_item($note_id); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | public static function delete_note() { |
143 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
143 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
144 | 144 | |
145 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
145 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
146 | 146 | die(-1); |
147 | 147 | } |
148 | 148 | |
149 | - $note_id = (int)$_POST['note_id']; |
|
149 | + $note_id = (int) $_POST['note_id']; |
|
150 | 150 | |
151 | - if ( $note_id > 0 ) { |
|
152 | - wp_delete_comment( $note_id, true ); |
|
151 | + if ($note_id > 0) { |
|
152 | + wp_delete_comment($note_id, true); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | die(); |
@@ -167,34 +167,34 @@ discard block |
||
167 | 167 | public static function get_billing_details() { |
168 | 168 | |
169 | 169 | // Verify nonce. |
170 | - check_ajax_referer( 'wpinv-nonce' ); |
|
170 | + check_ajax_referer('wpinv-nonce'); |
|
171 | 171 | |
172 | 172 | // Can the user manage the plugin? |
173 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
173 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
174 | 174 | die(-1); |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Do we have a user id? |
178 | 178 | $user_id = $_GET['user_id']; |
179 | 179 | |
180 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
180 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
181 | 181 | die(-1); |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Fetch the billing details. |
185 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
186 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
185 | + $billing_details = wpinv_get_user_address($user_id); |
|
186 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
187 | 187 | |
188 | 188 | // unset the user id and email. |
189 | - $to_ignore = array( 'user_id', 'email' ); |
|
189 | + $to_ignore = array('user_id', 'email'); |
|
190 | 190 | |
191 | - foreach ( $to_ignore as $key ) { |
|
192 | - if ( isset( $billing_details[ $key ] ) ) { |
|
193 | - unset( $billing_details[ $key ] ); |
|
191 | + foreach ($to_ignore as $key) { |
|
192 | + if (isset($billing_details[$key])) { |
|
193 | + unset($billing_details[$key]); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - wp_send_json_success( $billing_details ); |
|
197 | + wp_send_json_success($billing_details); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -204,47 +204,47 @@ discard block |
||
204 | 204 | public static function check_new_user_email() { |
205 | 205 | |
206 | 206 | // Verify nonce. |
207 | - check_ajax_referer( 'wpinv-nonce' ); |
|
207 | + check_ajax_referer('wpinv-nonce'); |
|
208 | 208 | |
209 | 209 | // Can the user manage the plugin? |
210 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
210 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
211 | 211 | die(-1); |
212 | 212 | } |
213 | 213 | |
214 | 214 | // We need an email address. |
215 | - if ( empty( $_GET['email'] ) ) { |
|
216 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
215 | + if (empty($_GET['email'])) { |
|
216 | + _e("Provide the new user's email address", 'invoicing'); |
|
217 | 217 | exit; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Ensure the email is valid. |
221 | - $email = sanitize_text_field( $_GET['email'] ); |
|
222 | - if ( ! is_email( $email ) ) { |
|
223 | - _e( 'Invalid email address', 'invoicing' ); |
|
221 | + $email = sanitize_text_field($_GET['email']); |
|
222 | + if (!is_email($email)) { |
|
223 | + _e('Invalid email address', 'invoicing'); |
|
224 | 224 | exit; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // And it does not exist. |
228 | - if ( email_exists( $email ) ) { |
|
229 | - _e( 'A user with this email address already exists', 'invoicing' ); |
|
228 | + if (email_exists($email)) { |
|
229 | + _e('A user with this email address already exists', 'invoicing'); |
|
230 | 230 | exit; |
231 | 231 | } |
232 | 232 | |
233 | - wp_send_json_success( true ); |
|
233 | + wp_send_json_success(true); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | public static function run_tool() { |
237 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
238 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
237 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
238 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
239 | 239 | die(-1); |
240 | 240 | } |
241 | 241 | |
242 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
242 | + $tool = sanitize_text_field($_POST['tool']); |
|
243 | 243 | |
244 | - do_action( 'wpinv_run_tool' ); |
|
244 | + do_action('wpinv_run_tool'); |
|
245 | 245 | |
246 | - if ( !empty( $tool ) ) { |
|
247 | - do_action( 'wpinv_tool_' . $tool ); |
|
246 | + if (!empty($tool)) { |
|
247 | + do_action('wpinv_tool_' . $tool); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | public static function get_payment_form() { |
255 | 255 | |
256 | 256 | // Check nonce. |
257 | - if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) { |
|
258 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
257 | + if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) { |
|
258 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
259 | 259 | exit; |
260 | 260 | } |
261 | 261 | |
262 | 262 | // Is the request set up correctly? |
263 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
263 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
264 | 264 | echo aui()->alert( |
265 | 265 | array( |
266 | 266 | 'type' => 'warning', |
267 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
267 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
268 | 268 | ) |
269 | 269 | ); |
270 | 270 | exit; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Payment form or button? |
274 | - if ( ! empty( $_GET['form'] ) ) { |
|
275 | - getpaid_display_payment_form( $_GET['form'] ); |
|
276 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
277 | - echo getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
274 | + if (!empty($_GET['form'])) { |
|
275 | + getpaid_display_payment_form($_GET['form']); |
|
276 | + } else if (!empty($_GET['invoice'])) { |
|
277 | + echo getpaid_display_invoice_payment_form($_GET['invoice']); |
|
278 | 278 | } else { |
279 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
280 | - getpaid_display_item_payment_form( $items ); |
|
279 | + $items = getpaid_convert_items_to_array($_GET['item']); |
|
280 | + getpaid_display_item_payment_form($items); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | exit; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | global $invoicing; |
294 | 294 | |
295 | 295 | // Check nonce. |
296 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
296 | + check_ajax_referer('getpaid_form_nonce'); |
|
297 | 297 | |
298 | 298 | // ... form fields... |
299 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
300 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
299 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
300 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
301 | 301 | exit; |
302 | 302 | } |
303 | 303 | |
@@ -305,66 +305,66 @@ discard block |
||
305 | 305 | $submission = new GetPaid_Payment_Form_Submission(); |
306 | 306 | |
307 | 307 | // Do we have an error? |
308 | - if ( ! empty( $submission->last_error ) ) { |
|
308 | + if (!empty($submission->last_error)) { |
|
309 | 309 | echo $submission->last_error; |
310 | 310 | exit; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // We need a billing email. |
314 | - if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) { |
|
315 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
314 | + if (!$submission->has_billing_email() || !is_email($submission->get_billing_email())) { |
|
315 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | // Clear any checkout errors. |
319 | 319 | wpinv_clear_errors(); |
320 | 320 | |
321 | 321 | // Validate the gateway. |
322 | - wpinv_checkout_validate_gateway( $submission ); |
|
322 | + wpinv_checkout_validate_gateway($submission); |
|
323 | 323 | |
324 | 324 | // Allow themes and plugins to hook to errors |
325 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
325 | + do_action('getpaid_checkout_error_checks', $submission); |
|
326 | 326 | |
327 | 327 | // Do we have any errors? |
328 | - if ( wpinv_get_errors() ) { |
|
329 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
328 | + if (wpinv_get_errors()) { |
|
329 | + wp_send_json_error(getpaid_get_errors_html()); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // Prepare items. |
333 | 333 | $items = $submission->get_items(); |
334 | 334 | |
335 | 335 | // Ensure that we have items. |
336 | - if ( empty( $items ) && 0 == count( $submission->get_fees() ) ) { |
|
337 | - wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) ); |
|
336 | + if (empty($items) && 0 == count($submission->get_fees())) { |
|
337 | + wp_send_json_error(__('You have not selected any items.', 'invoicing')); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // Prepare the invoice. |
341 | - if ( ! $submission->has_invoice() ) { |
|
341 | + if (!$submission->has_invoice()) { |
|
342 | 342 | $invoice = new WPInv_Invoice(); |
343 | 343 | } else { |
344 | 344 | $invoice = $submission->get_invoice(); |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Make sure that it is neither paid or refunded. |
348 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
349 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
348 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
349 | + wp_send_json_error(__('This invoice has already been paid for.', 'invoicing')); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | // Set the billing email. |
353 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
353 | + $invoice->set_email(sanitize_email($submission->get_billing_email())); |
|
354 | 354 | |
355 | 355 | // Payment form. |
356 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
356 | + $invoice->set_payment_form(absint($submission->get_payment_form()->get_id())); |
|
357 | 357 | |
358 | 358 | // Discount code. |
359 | - if ( $submission->has_discount_code() ) { |
|
360 | - $invoice->set_discount_code( $submission->get_discount_code() ); |
|
359 | + if ($submission->has_discount_code()) { |
|
360 | + $invoice->set_discount_code($submission->get_discount_code()); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | // Items, Fees, taxes and discounts. |
364 | - $invoice->set_items( $items ); |
|
365 | - $invoice->set_fees( $submission->get_fees() ); |
|
366 | - $invoice->set_taxes( $submission->get_taxes() ); |
|
367 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
364 | + $invoice->set_items($items); |
|
365 | + $invoice->set_fees($submission->get_fees()); |
|
366 | + $invoice->set_taxes($submission->get_taxes()); |
|
367 | + $invoice->set_discounts($submission->get_discounts()); |
|
368 | 368 | |
369 | 369 | // Prepared submission details. |
370 | 370 | $prepared = array(); |
@@ -373,48 +373,48 @@ discard block |
||
373 | 373 | $data = $submission->get_data(); |
374 | 374 | |
375 | 375 | // Loop throught the submitted details. |
376 | - foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
|
376 | + foreach ($submission->get_payment_form()->get_elements() as $field) { |
|
377 | 377 | |
378 | - if ( ! empty( $field['premade'] ) ) { |
|
378 | + if (!empty($field['premade'])) { |
|
379 | 379 | continue; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // If it is required and not set, abort. |
383 | - if ( ! $submission->is_required_field_set( $field ) ) { |
|
384 | - wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) ); |
|
383 | + if (!$submission->is_required_field_set($field)) { |
|
384 | + wp_send_json_error(__('Some required fields are not set.', 'invoicing')); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | // Handle address fields. |
388 | - if ( $field['type'] == 'address' ) { |
|
388 | + if ($field['type'] == 'address') { |
|
389 | 389 | |
390 | - foreach ( $field['fields'] as $address_field ) { |
|
390 | + foreach ($field['fields'] as $address_field) { |
|
391 | 391 | |
392 | 392 | // skip if it is not visible. |
393 | - if ( empty( $address_field['visible'] ) ) { |
|
393 | + if (empty($address_field['visible'])) { |
|
394 | 394 | continue; |
395 | 395 | } |
396 | 396 | |
397 | 397 | // If it is required and not set, abort |
398 | - if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) { |
|
399 | - wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) ); |
|
398 | + if (!empty($address_field['required']) && empty($data[$address_field['name']])) { |
|
399 | + wp_send_json_error(__('Some required fields are not set.', 'invoicing')); |
|
400 | 400 | } |
401 | 401 | |
402 | - if ( isset( $data[ $address_field['name'] ] ) ) { |
|
403 | - $name = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
402 | + if (isset($data[$address_field['name']])) { |
|
403 | + $name = str_replace('wpinv_', '', $address_field['name']); |
|
404 | 404 | $method = "set_$name"; |
405 | - $invoice->$method( wpinv_clean( $data[ $address_field['name'] ] ) ); |
|
405 | + $invoice->$method(wpinv_clean($data[$address_field['name']])); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | } |
409 | 409 | |
410 | - } else if ( isset( $data[ $field['id'] ] ) ) { |
|
410 | + } else if (isset($data[$field['id']])) { |
|
411 | 411 | $label = $field['id']; |
412 | 412 | |
413 | - if ( isset( $field['label'] ) ) { |
|
413 | + if (isset($field['label'])) { |
|
414 | 414 | $label = $field['label']; |
415 | 415 | } |
416 | 416 | |
417 | - $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] ); |
|
417 | + $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | } |
@@ -422,41 +422,41 @@ discard block |
||
422 | 422 | // (Maybe) create the user. |
423 | 423 | $user = get_current_user_id(); |
424 | 424 | |
425 | - if ( empty( $user ) ) { |
|
426 | - $user = get_user_by( 'email', $submission->get_billing_email() ); |
|
425 | + if (empty($user)) { |
|
426 | + $user = get_user_by('email', $submission->get_billing_email()); |
|
427 | 427 | } |
428 | 428 | |
429 | - if ( empty( $user ) ) { |
|
430 | - $user = wpinv_create_user( $submission->get_billing_email() ); |
|
429 | + if (empty($user)) { |
|
430 | + $user = wpinv_create_user($submission->get_billing_email()); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( is_wp_error( $user ) ) { |
|
434 | - wp_send_json_error( $user->get_error_message() ); |
|
433 | + if (is_wp_error($user)) { |
|
434 | + wp_send_json_error($user->get_error_message()); |
|
435 | 435 | } |
436 | 436 | |
437 | - if ( is_numeric( $user ) ) { |
|
438 | - $user = get_user_by( 'id', $user ); |
|
437 | + if (is_numeric($user)) { |
|
438 | + $user = get_user_by('id', $user); |
|
439 | 439 | } |
440 | 440 | |
441 | - $invoice->set_user_id( $user->ID ); |
|
441 | + $invoice->set_user_id($user->ID); |
|
442 | 442 | |
443 | 443 | // User address. |
444 | - $address_fields = wpinv_get_user_address( $user->ID ); |
|
444 | + $address_fields = wpinv_get_user_address($user->ID); |
|
445 | 445 | |
446 | - foreach ( $address_fields as $key => $value ) { |
|
446 | + foreach ($address_fields as $key => $value) { |
|
447 | 447 | |
448 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
449 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
448 | + if (is_callable($invoice, "get_$key")) { |
|
449 | + $current = call_user_func(array($invoice, "get_$key")); |
|
450 | 450 | |
451 | - if ( empty( $current ) ) { |
|
451 | + if (empty($current)) { |
|
452 | 452 | $method = "set_$key"; |
453 | - $invoice->$method( $value ); |
|
453 | + $invoice->$method($value); |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | 457 | } |
458 | 458 | // Set gateway. |
459 | - $invoice->set_gateway( $data['wpi-gateway'] ); |
|
459 | + $invoice->set_gateway($data['wpi-gateway']); |
|
460 | 460 | |
461 | 461 | $invoice->recalculate_total(); |
462 | 462 | |
@@ -464,20 +464,20 @@ discard block |
||
464 | 464 | $invoice->save(); |
465 | 465 | |
466 | 466 | // Was it saved successfully: |
467 | - if ( $invoice->get_id() == 0 ) { |
|
468 | - wp_send_json_error( __( 'An error occured while saving your invoice.', 'invoicing' ) ); |
|
467 | + if ($invoice->get_id() == 0) { |
|
468 | + wp_send_json_error(__('An error occured while saving your invoice.', 'invoicing')); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | // Save payment form data. |
472 | - if ( ! empty( $prepared ) ) { |
|
473 | - update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared ); |
|
472 | + if (!empty($prepared)) { |
|
473 | + update_post_meta($invoice->get_id(), 'payment_form_data', $prepared); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | // Process the checkout. |
477 | - add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) ); |
|
478 | - add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) ); |
|
477 | + add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response')); |
|
478 | + add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error')); |
|
479 | 479 | |
480 | - wpinv_process_checkout( $invoice, $submission ); |
|
480 | + wpinv_process_checkout($invoice, $submission); |
|
481 | 481 | |
482 | 482 | // If we are here, there was an error. |
483 | 483 | $invoicing->form_elements->checkout_error(); |
@@ -493,51 +493,51 @@ discard block |
||
493 | 493 | public static function get_payment_form_states_field() { |
494 | 494 | global $invoicing; |
495 | 495 | |
496 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
496 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
497 | 497 | exit; |
498 | 498 | } |
499 | 499 | |
500 | - $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] ); |
|
500 | + $elements = $invoicing->form_elements->get_form_elements($_GET['form']); |
|
501 | 501 | |
502 | - if ( empty( $elements ) ) { |
|
502 | + if (empty($elements)) { |
|
503 | 503 | exit; |
504 | 504 | } |
505 | 505 | |
506 | 506 | $address_fields = array(); |
507 | - foreach ( $elements as $element ) { |
|
508 | - if ( 'address' === $element['type'] ) { |
|
507 | + foreach ($elements as $element) { |
|
508 | + if ('address' === $element['type']) { |
|
509 | 509 | $address_fields = $element; |
510 | 510 | break; |
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | - if ( empty( $address_fields ) ) { |
|
514 | + if (empty($address_fields)) { |
|
515 | 515 | exit; |
516 | 516 | } |
517 | 517 | |
518 | - foreach( $address_fields['fields'] as $address_field ) { |
|
518 | + foreach ($address_fields['fields'] as $address_field) { |
|
519 | 519 | |
520 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
520 | + if ('wpinv_state' == $address_field['name']) { |
|
521 | 521 | |
522 | 522 | $label = $address_field['label']; |
523 | 523 | |
524 | - if ( ! empty( $address_field['required'] ) ) { |
|
524 | + if (!empty($address_field['required'])) { |
|
525 | 525 | $label .= "<span class='text-danger'> *</span>"; |
526 | 526 | } |
527 | 527 | |
528 | - $states = wpinv_get_country_states( $_GET['country'] ); |
|
528 | + $states = wpinv_get_country_states($_GET['country']); |
|
529 | 529 | |
530 | - if ( ! empty( $states ) ) { |
|
530 | + if (!empty($states)) { |
|
531 | 531 | |
532 | 532 | $html = aui()->select( |
533 | 533 | array( |
534 | 534 | 'options' => $states, |
535 | - 'name' => esc_attr( $address_field['name'] ), |
|
536 | - 'id' => esc_attr( $address_field['name'] ), |
|
537 | - 'placeholder' => esc_attr( $address_field['placeholder'] ), |
|
535 | + 'name' => esc_attr($address_field['name']), |
|
536 | + 'id' => esc_attr($address_field['name']), |
|
537 | + 'placeholder' => esc_attr($address_field['placeholder']), |
|
538 | 538 | 'required' => (bool) $address_field['required'], |
539 | 539 | 'no_wrap' => true, |
540 | - 'label' => wp_kses_post( $label ), |
|
540 | + 'label' => wp_kses_post($label), |
|
541 | 541 | 'select2' => false, |
542 | 542 | ) |
543 | 543 | ); |
@@ -546,10 +546,10 @@ discard block |
||
546 | 546 | |
547 | 547 | $html = aui()->input( |
548 | 548 | array( |
549 | - 'name' => esc_attr( $address_field['name'] ), |
|
550 | - 'id' => esc_attr( $address_field['name'] ), |
|
549 | + 'name' => esc_attr($address_field['name']), |
|
550 | + 'id' => esc_attr($address_field['name']), |
|
551 | 551 | 'required' => (bool) $address_field['required'], |
552 | - 'label' => wp_kses_post( $label ), |
|
552 | + 'label' => wp_kses_post($label), |
|
553 | 553 | 'no_wrap' => true, |
554 | 554 | 'type' => 'text', |
555 | 555 | ) |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | } |
559 | 559 | |
560 | - wp_send_json_success( str_replace( 'sr-only', '', $html ) ); |
|
560 | + wp_send_json_success(str_replace('sr-only', '', $html)); |
|
561 | 561 | exit; |
562 | 562 | |
563 | 563 | } |
@@ -573,56 +573,56 @@ discard block |
||
573 | 573 | public static function recalculate_invoice_totals() { |
574 | 574 | |
575 | 575 | // Verify nonce. |
576 | - check_ajax_referer( 'wpinv-nonce' ); |
|
576 | + check_ajax_referer('wpinv-nonce'); |
|
577 | 577 | |
578 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
578 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
579 | 579 | exit; |
580 | 580 | } |
581 | 581 | |
582 | 582 | // We need an invoice. |
583 | - if ( empty( $_POST['post_id'] ) ) { |
|
583 | + if (empty($_POST['post_id'])) { |
|
584 | 584 | exit; |
585 | 585 | } |
586 | 586 | |
587 | 587 | // Fetch the invoice. |
588 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
588 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
589 | 589 | |
590 | 590 | // Ensure it exists. |
591 | - if ( ! $invoice->get_id() ) { |
|
591 | + if (!$invoice->get_id()) { |
|
592 | 592 | exit; |
593 | 593 | } |
594 | 594 | |
595 | 595 | // Maybe set the country, state, currency. |
596 | - foreach ( array( 'country', 'state', 'currency' ) as $key ) { |
|
597 | - if ( isset( $_POST[ $key ] ) ) { |
|
596 | + foreach (array('country', 'state', 'currency') as $key) { |
|
597 | + if (isset($_POST[$key])) { |
|
598 | 598 | $method = "set_$key"; |
599 | - $invoice->$method( $_POST[ $key ] ); |
|
599 | + $invoice->$method($_POST[$key]); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | |
603 | 603 | // Maybe disable taxes. |
604 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
604 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
605 | 605 | |
606 | 606 | // Recalculate totals. |
607 | 607 | $invoice->recalculate_total(); |
608 | 608 | |
609 | - $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
609 | + $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
610 | 610 | |
611 | - if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
612 | - $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() ); |
|
613 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
611 | + if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
612 | + $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency()); |
|
613 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | $totals = array( |
617 | - 'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ), |
|
618 | - 'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ), |
|
619 | - 'tax' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ), |
|
617 | + 'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()), |
|
618 | + 'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()), |
|
619 | + 'tax' => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()), |
|
620 | 620 | 'total' => $total, |
621 | 621 | ); |
622 | 622 | |
623 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
623 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
624 | 624 | |
625 | - wp_send_json_success( compact( 'totals' ) ); |
|
625 | + wp_send_json_success(compact('totals')); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -631,33 +631,33 @@ discard block |
||
631 | 631 | public static function get_invoice_items() { |
632 | 632 | |
633 | 633 | // Verify nonce. |
634 | - check_ajax_referer( 'wpinv-nonce' ); |
|
634 | + check_ajax_referer('wpinv-nonce'); |
|
635 | 635 | |
636 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
636 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
637 | 637 | exit; |
638 | 638 | } |
639 | 639 | |
640 | 640 | // We need an invoice and items. |
641 | - if ( empty( $_POST['post_id'] ) ) { |
|
641 | + if (empty($_POST['post_id'])) { |
|
642 | 642 | exit; |
643 | 643 | } |
644 | 644 | |
645 | 645 | // Fetch the invoice. |
646 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
646 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
647 | 647 | |
648 | 648 | // Ensure it exists. |
649 | - if ( ! $invoice->get_id() ) { |
|
649 | + if (!$invoice->get_id()) { |
|
650 | 650 | exit; |
651 | 651 | } |
652 | 652 | |
653 | 653 | // Return an array of invoice items. |
654 | 654 | $items = array(); |
655 | 655 | |
656 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
657 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
656 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
657 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
658 | 658 | } |
659 | 659 | |
660 | - wp_send_json_success( compact( 'items' ) ); |
|
660 | + wp_send_json_success(compact('items')); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -666,50 +666,50 @@ discard block |
||
666 | 666 | public static function edit_invoice_item() { |
667 | 667 | |
668 | 668 | // Verify nonce. |
669 | - check_ajax_referer( 'wpinv-nonce' ); |
|
669 | + check_ajax_referer('wpinv-nonce'); |
|
670 | 670 | |
671 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
671 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
672 | 672 | exit; |
673 | 673 | } |
674 | 674 | |
675 | 675 | // We need an invoice and item details. |
676 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
676 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
677 | 677 | exit; |
678 | 678 | } |
679 | 679 | |
680 | 680 | // Fetch the invoice. |
681 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
681 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
682 | 682 | |
683 | 683 | // Ensure it exists and its not been paid for. |
684 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
684 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
685 | 685 | exit; |
686 | 686 | } |
687 | 687 | |
688 | 688 | // Format the data. |
689 | - $data = wp_list_pluck( $_POST['data'], 'value', 'field' ); |
|
689 | + $data = wp_list_pluck($_POST['data'], 'value', 'field'); |
|
690 | 690 | |
691 | 691 | // Ensure that we have an item id. |
692 | - if ( empty( $data['id'] ) ) { |
|
692 | + if (empty($data['id'])) { |
|
693 | 693 | exit; |
694 | 694 | } |
695 | 695 | |
696 | 696 | // Abort if the invoice does not have the specified item. |
697 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
697 | + $item = $invoice->get_item((int) $data['id']); |
|
698 | 698 | |
699 | - if ( empty( $item ) ) { |
|
699 | + if (empty($item)) { |
|
700 | 700 | exit; |
701 | 701 | } |
702 | 702 | |
703 | 703 | // Update the item. |
704 | - $item->set_price( $data['price'] ); |
|
705 | - $item->set_name( $data['name'] ); |
|
706 | - $item->set_description( $data['description'] ); |
|
707 | - $item->set_quantity( $data['quantity'] ); |
|
704 | + $item->set_price($data['price']); |
|
705 | + $item->set_name($data['name']); |
|
706 | + $item->set_description($data['description']); |
|
707 | + $item->set_quantity($data['quantity']); |
|
708 | 708 | |
709 | 709 | // Add it to the invoice. |
710 | - $error = $invoice->add_item( $item ); |
|
710 | + $error = $invoice->add_item($item); |
|
711 | 711 | $alert = false; |
712 | - if ( is_wp_error( $error ) ) { |
|
712 | + if (is_wp_error($error)) { |
|
713 | 713 | $alert = $error->get_error_message(); |
714 | 714 | } |
715 | 715 | |
@@ -722,11 +722,11 @@ discard block |
||
722 | 722 | // Return an array of invoice items. |
723 | 723 | $items = array(); |
724 | 724 | |
725 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
726 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
725 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
726 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
727 | 727 | } |
728 | 728 | |
729 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
729 | + wp_send_json_success(compact('items', 'alert')); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -735,33 +735,33 @@ discard block |
||
735 | 735 | public static function remove_invoice_item() { |
736 | 736 | |
737 | 737 | // Verify nonce. |
738 | - check_ajax_referer( 'wpinv-nonce' ); |
|
738 | + check_ajax_referer('wpinv-nonce'); |
|
739 | 739 | |
740 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
740 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
741 | 741 | exit; |
742 | 742 | } |
743 | 743 | |
744 | 744 | // We need an invoice and an item. |
745 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
745 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
746 | 746 | exit; |
747 | 747 | } |
748 | 748 | |
749 | 749 | // Fetch the invoice. |
750 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
750 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
751 | 751 | |
752 | 752 | // Ensure it exists and its not been paid for. |
753 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
753 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
754 | 754 | exit; |
755 | 755 | } |
756 | 756 | |
757 | 757 | // Abort if the invoice does not have the specified item. |
758 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
758 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
759 | 759 | |
760 | - if ( empty( $item ) ) { |
|
760 | + if (empty($item)) { |
|
761 | 761 | exit; |
762 | 762 | } |
763 | 763 | |
764 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
764 | + $invoice->remove_item((int) $_POST['item_id']); |
|
765 | 765 | |
766 | 766 | // Update totals. |
767 | 767 | $invoice->recalculate_total(); |
@@ -772,11 +772,11 @@ discard block |
||
772 | 772 | // Return an array of invoice items. |
773 | 773 | $items = array(); |
774 | 774 | |
775 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
776 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
775 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
776 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
777 | 777 | } |
778 | 778 | |
779 | - wp_send_json_success( compact( 'items' ) ); |
|
779 | + wp_send_json_success(compact('items')); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
@@ -785,39 +785,39 @@ discard block |
||
785 | 785 | public static function add_invoice_items() { |
786 | 786 | |
787 | 787 | // Verify nonce. |
788 | - check_ajax_referer( 'wpinv-nonce' ); |
|
788 | + check_ajax_referer('wpinv-nonce'); |
|
789 | 789 | |
790 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
790 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
791 | 791 | exit; |
792 | 792 | } |
793 | 793 | |
794 | 794 | // We need an invoice and items. |
795 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
795 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
796 | 796 | exit; |
797 | 797 | } |
798 | 798 | |
799 | 799 | // Fetch the invoice. |
800 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
800 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
801 | 801 | $alert = false; |
802 | 802 | |
803 | 803 | // Ensure it exists and its not been paid for. |
804 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
804 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
805 | 805 | exit; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Add the items. |
809 | - foreach ( $_POST['items'] as $data ) { |
|
809 | + foreach ($_POST['items'] as $data) { |
|
810 | 810 | |
811 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
811 | + $item = new GetPaid_Form_Item($data['id']); |
|
812 | 812 | |
813 | - if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) { |
|
814 | - $item->set_quantity( $data[ 'qty' ] ); |
|
813 | + if (is_numeric($data['qty']) && (int) $data['qty'] > 0) { |
|
814 | + $item->set_quantity($data['qty']); |
|
815 | 815 | } |
816 | 816 | |
817 | - if ( $item->get_id() > 0 ) { |
|
818 | - $error = $invoice->add_item( $item ); |
|
817 | + if ($item->get_id() > 0) { |
|
818 | + $error = $invoice->add_item($item); |
|
819 | 819 | |
820 | - if ( is_wp_error( $error ) ) { |
|
820 | + if (is_wp_error($error)) { |
|
821 | 821 | $alert = $error->get_error_message(); |
822 | 822 | } |
823 | 823 | |
@@ -832,11 +832,11 @@ discard block |
||
832 | 832 | // Return an array of invoice items. |
833 | 833 | $items = array(); |
834 | 834 | |
835 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
836 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
835 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
836 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
837 | 837 | } |
838 | 838 | |
839 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
839 | + wp_send_json_success(compact('items', 'alert')); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -845,15 +845,15 @@ discard block |
||
845 | 845 | public static function get_invoicing_items() { |
846 | 846 | |
847 | 847 | // Verify nonce. |
848 | - check_ajax_referer( 'wpinv-nonce' ); |
|
848 | + check_ajax_referer('wpinv-nonce'); |
|
849 | 849 | |
850 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
850 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
851 | 851 | exit; |
852 | 852 | } |
853 | 853 | |
854 | 854 | // We need a search term. |
855 | - if ( empty( $_GET['search'] ) ) { |
|
856 | - wp_send_json_success( array() ); |
|
855 | + if (empty($_GET['search'])) { |
|
856 | + wp_send_json_success(array()); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | // Retrieve items. |
@@ -862,8 +862,8 @@ discard block |
||
862 | 862 | 'orderby' => 'title', |
863 | 863 | 'order' => 'ASC', |
864 | 864 | 'posts_per_page' => -1, |
865 | - 'post_status' => array( 'publish' ), |
|
866 | - 's' => trim( $_GET['search'] ), |
|
865 | + 'post_status' => array('publish'), |
|
866 | + 's' => trim($_GET['search']), |
|
867 | 867 | 'meta_query' => array( |
868 | 868 | array( |
869 | 869 | 'key' => '_wpinv_type', |
@@ -873,18 +873,18 @@ discard block |
||
873 | 873 | ) |
874 | 874 | ); |
875 | 875 | |
876 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
876 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
877 | 877 | $data = array(); |
878 | 878 | |
879 | - foreach ( $items as $item ) { |
|
880 | - $item = new GetPaid_Form_Item( $item ); |
|
879 | + foreach ($items as $item) { |
|
880 | + $item = new GetPaid_Form_Item($item); |
|
881 | 881 | $data[] = array( |
882 | 882 | 'id' => $item->get_id(), |
883 | 883 | 'text' => $item->get_name() |
884 | 884 | ); |
885 | 885 | } |
886 | 886 | |
887 | - wp_send_json_success( $data ); |
|
887 | + wp_send_json_success($data); |
|
888 | 888 | |
889 | 889 | } |
890 | 890 | |
@@ -894,24 +894,24 @@ discard block |
||
894 | 894 | public static function get_aui_states_field() { |
895 | 895 | |
896 | 896 | // Verify nonce. |
897 | - check_ajax_referer( 'wpinv-nonce' ); |
|
897 | + check_ajax_referer('wpinv-nonce'); |
|
898 | 898 | |
899 | 899 | // We need a country. |
900 | - if ( empty( $_GET['country'] ) ) { |
|
900 | + if (empty($_GET['country'])) { |
|
901 | 901 | exit; |
902 | 902 | } |
903 | 903 | |
904 | - $states = wpinv_get_country_states( trim( $_GET['country'] ) ); |
|
905 | - $state = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state(); |
|
904 | + $states = wpinv_get_country_states(trim($_GET['country'])); |
|
905 | + $state = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state(); |
|
906 | 906 | |
907 | - if ( empty( $states ) ) { |
|
907 | + if (empty($states)) { |
|
908 | 908 | |
909 | 909 | $html = aui()->input( |
910 | 910 | array( |
911 | 911 | 'type' => 'text', |
912 | 912 | 'id' => 'wpinv_state', |
913 | 913 | 'name' => 'wpinv_state', |
914 | - 'label' => __( 'State', 'invoicing' ), |
|
914 | + 'label' => __('State', 'invoicing'), |
|
915 | 915 | 'label_type' => 'vertical', |
916 | 916 | 'placeholder' => 'Liège', |
917 | 917 | 'class' => 'form-control-sm', |
@@ -925,9 +925,9 @@ discard block |
||
925 | 925 | array( |
926 | 926 | 'id' => 'wpinv_state', |
927 | 927 | 'name' => 'wpinv_state', |
928 | - 'label' => __( 'State', 'invoicing' ), |
|
928 | + 'label' => __('State', 'invoicing'), |
|
929 | 929 | 'label_type' => 'vertical', |
930 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
930 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
931 | 931 | 'class' => 'form-control-sm', |
932 | 932 | 'value' => $state, |
933 | 933 | 'options' => $states, |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | wp_send_json_success( |
942 | 942 | array( |
943 | 943 | 'html' => $html, |
944 | - 'select' => ! empty ( $states ) |
|
944 | + 'select' => !empty ($states) |
|
945 | 945 | ) |
946 | 946 | ); |
947 | 947 | |
@@ -955,46 +955,46 @@ discard block |
||
955 | 955 | public static function ip_geolocation() { |
956 | 956 | |
957 | 957 | // Check nonce. |
958 | - check_ajax_referer( 'getpaid-ip-location' ); |
|
958 | + check_ajax_referer('getpaid-ip-location'); |
|
959 | 959 | |
960 | 960 | // IP address. |
961 | - if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) { |
|
962 | - _e( 'Invalid IP Address.', 'invoicing' ); |
|
961 | + if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) { |
|
962 | + _e('Invalid IP Address.', 'invoicing'); |
|
963 | 963 | exit; |
964 | 964 | } |
965 | 965 | |
966 | 966 | // Retrieve location info. |
967 | - $location = getpaid_geolocate_ip_address( $_GET['ip'] ); |
|
967 | + $location = getpaid_geolocate_ip_address($_GET['ip']); |
|
968 | 968 | |
969 | - if ( empty( $location ) ) { |
|
970 | - _e( 'Unable to find geolocation for the IP Address.', 'invoicing' ); |
|
969 | + if (empty($location)) { |
|
970 | + _e('Unable to find geolocation for the IP Address.', 'invoicing'); |
|
971 | 971 | exit; |
972 | 972 | } |
973 | 973 | |
974 | 974 | // Sorry. |
975 | - extract( $location ); |
|
975 | + extract($location); |
|
976 | 976 | |
977 | 977 | // Prepare the address. |
978 | 978 | $content = ''; |
979 | 979 | |
980 | - if ( ! empty( $location['city'] ) ) { |
|
981 | - $content .= $location['city'] . ', '; |
|
980 | + if (!empty($location['city'])) { |
|
981 | + $content .= $location['city'] . ', '; |
|
982 | 982 | } |
983 | 983 | |
984 | - if ( ! empty( $location['region'] ) ) { |
|
985 | - $content .= $location['region'] . ', '; |
|
984 | + if (!empty($location['region'])) { |
|
985 | + $content .= $location['region'] . ', '; |
|
986 | 986 | } |
987 | 987 | |
988 | - $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
988 | + $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
989 | 989 | |
990 | 990 | $location['address'] = $content; |
991 | 991 | |
992 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>'; |
|
993 | - $content .= '<p>'. $location['credit'] . '</p>'; |
|
992 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>'; |
|
993 | + $content .= '<p>' . $location['credit'] . '</p>'; |
|
994 | 994 | |
995 | 995 | $location['content'] = $content; |
996 | 996 | |
997 | - wpinv_get_template( 'geolocation.php', $location ); |
|
997 | + wpinv_get_template('geolocation.php', $location); |
|
998 | 998 | |
999 | 999 | exit; |
1000 | 1000 | } |
@@ -1007,11 +1007,11 @@ discard block |
||
1007 | 1007 | public static function payment_form_refresh_prices() { |
1008 | 1008 | |
1009 | 1009 | // Check nonce. |
1010 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
1010 | + check_ajax_referer('getpaid_form_nonce'); |
|
1011 | 1011 | |
1012 | 1012 | // ... form fields... |
1013 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
1014 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
1013 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
1014 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
1015 | 1015 | exit; |
1016 | 1016 | } |
1017 | 1017 | |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | $submission = new GetPaid_Payment_Form_Submission(); |
1020 | 1020 | |
1021 | 1021 | // Do we have an error? |
1022 | - if ( ! empty( $submission->last_error ) ) { |
|
1022 | + if (!empty($submission->last_error)) { |
|
1023 | 1023 | echo $submission->last_error; |
1024 | 1024 | exit; |
1025 | 1025 | } |
@@ -1032,43 +1032,43 @@ discard block |
||
1032 | 1032 | 'is_free' => $submission->get_payment_details(), |
1033 | 1033 | |
1034 | 1034 | 'totals' => array( |
1035 | - 'subtotal' => wpinv_price( wpinv_format_amount( $submission->subtotal_amount ), $submission->get_currency() ), |
|
1036 | - 'discount' => wpinv_price( wpinv_format_amount( $submission->get_total_discount() ), $submission->get_currency() ), |
|
1037 | - 'fees' => wpinv_price( wpinv_format_amount( $submission->get_total_fees() ), $submission->get_currency() ), |
|
1038 | - 'tax' => wpinv_price( wpinv_format_amount( $submission->get_total_tax() ), $submission->get_currency() ), |
|
1039 | - 'total' => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ), |
|
1035 | + 'subtotal' => wpinv_price(wpinv_format_amount($submission->subtotal_amount), $submission->get_currency()), |
|
1036 | + 'discount' => wpinv_price(wpinv_format_amount($submission->get_total_discount()), $submission->get_currency()), |
|
1037 | + 'fees' => wpinv_price(wpinv_format_amount($submission->get_total_fees()), $submission->get_currency()), |
|
1038 | + 'tax' => wpinv_price(wpinv_format_amount($submission->get_total_tax()), $submission->get_currency()), |
|
1039 | + 'total' => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()), |
|
1040 | 1040 | ), |
1041 | 1041 | |
1042 | 1042 | 'texts' => array( |
1043 | - '.getpaid-checkout-total-payable' => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ), |
|
1043 | + '.getpaid-checkout-total-payable' => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()), |
|
1044 | 1044 | ) |
1045 | 1045 | |
1046 | 1046 | ); |
1047 | 1047 | |
1048 | 1048 | // Add items. |
1049 | 1049 | $items = $submission->get_items(); |
1050 | - if ( ! empty( $items ) ) { |
|
1050 | + if (!empty($items)) { |
|
1051 | 1051 | $result['items'] = array(); |
1052 | 1052 | |
1053 | - foreach( $items as $item_id => $item ) { |
|
1054 | - $result['items']["$item_id"] = wpinv_price( wpinv_format_amount( $item->get_price() * $item->get_quantity() ) ); |
|
1053 | + foreach ($items as $item_id => $item) { |
|
1054 | + $result['items']["$item_id"] = wpinv_price(wpinv_format_amount($item->get_price() * $item->get_quantity())); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | // Add invoice. |
1059 | - if ( $submission->has_invoice() ) { |
|
1059 | + if ($submission->has_invoice()) { |
|
1060 | 1060 | $result['invoice'] = $submission->get_invoice()->ID; |
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | // Add discount code. |
1064 | - if ( $submission->has_discount_code() ) { |
|
1064 | + if ($submission->has_discount_code()) { |
|
1065 | 1065 | $result['discount_code'] = $submission->get_discount_code(); |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | // Filter the result. |
1069 | - $result = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $result, $submission ); |
|
1069 | + $result = apply_filters('getpaid_payment_form_ajax_refresh_prices', $result, $submission); |
|
1070 | 1070 | |
1071 | - wp_send_json_success( $result ); |
|
1071 | + wp_send_json_success($result); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | /** |
@@ -1079,53 +1079,53 @@ discard block |
||
1079 | 1079 | public static function buy_items() { |
1080 | 1080 | $user_id = get_current_user_id(); |
1081 | 1081 | |
1082 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
1083 | - wp_send_json( array( |
|
1084 | - 'success' => wp_login_url( wp_get_referer() ) |
|
1085 | - ) ); |
|
1082 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
1083 | + wp_send_json(array( |
|
1084 | + 'success' => wp_login_url(wp_get_referer()) |
|
1085 | + )); |
|
1086 | 1086 | } else { |
1087 | 1087 | // Only check nonce if logged in as it could be cached when logged out. |
1088 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
1089 | - wp_send_json( array( |
|
1090 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
1091 | - ) ); |
|
1088 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
1089 | + wp_send_json(array( |
|
1090 | + 'error' => __('Security checks failed.', 'invoicing') |
|
1091 | + )); |
|
1092 | 1092 | wp_die(); |
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | // allow to set a custom price through post_id |
1096 | 1096 | $items = $_POST['items']; |
1097 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
1098 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
1097 | + $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; |
|
1098 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
1099 | 1099 | |
1100 | 1100 | $cart_items = array(); |
1101 | - if ( $items ) { |
|
1102 | - $items = explode( ',', $items ); |
|
1101 | + if ($items) { |
|
1102 | + $items = explode(',', $items); |
|
1103 | 1103 | |
1104 | - foreach( $items as $item ) { |
|
1104 | + foreach ($items as $item) { |
|
1105 | 1105 | $item_id = $item; |
1106 | 1106 | $quantity = 1; |
1107 | 1107 | |
1108 | - if ( strpos( $item, '|' ) !== false ) { |
|
1109 | - $item_parts = explode( '|', $item ); |
|
1108 | + if (strpos($item, '|') !== false) { |
|
1109 | + $item_parts = explode('|', $item); |
|
1110 | 1110 | $item_id = $item_parts[0]; |
1111 | 1111 | $quantity = $item_parts[1]; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - if ( $item_id && $quantity ) { |
|
1114 | + if ($item_id && $quantity) { |
|
1115 | 1115 | $cart_items_arr = array( |
1116 | - 'id' => (int)$item_id, |
|
1117 | - 'quantity' => (int)$quantity |
|
1116 | + 'id' => (int) $item_id, |
|
1117 | + 'quantity' => (int) $quantity |
|
1118 | 1118 | ); |
1119 | 1119 | |
1120 | 1120 | // If there is a related post id then add it to meta |
1121 | - if ( $related_post_id ) { |
|
1121 | + if ($related_post_id) { |
|
1122 | 1122 | $cart_items_arr['meta'] = array( |
1123 | 1123 | 'post_id' => $related_post_id |
1124 | 1124 | ); |
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | // If there is a custom price then set it. |
1128 | - if ( $custom_item_price ) { |
|
1128 | + if ($custom_item_price) { |
|
1129 | 1129 | $cart_items_arr['custom_price'] = $custom_item_price; |
1130 | 1130 | } |
1131 | 1131 | |
@@ -1141,37 +1141,37 @@ discard block |
||
1141 | 1141 | * @param int $related_post_id The related post id if any. |
1142 | 1142 | * @since 1.0.0 |
1143 | 1143 | */ |
1144 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
1144 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
1145 | 1145 | |
1146 | 1146 | // Make sure its not in the cart already, if it is then redirect to checkout. |
1147 | 1147 | $cart_invoice = wpinv_get_invoice_cart(); |
1148 | 1148 | |
1149 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
1150 | - wp_send_json( array( |
|
1149 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
1150 | + wp_send_json(array( |
|
1151 | 1151 | 'success' => $cart_invoice->get_checkout_payment_url() |
1152 | - ) ); |
|
1152 | + )); |
|
1153 | 1153 | wp_die(); |
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | // Check if user has invoice with same items waiting to be paid. |
1157 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
1158 | - if ( !empty( $user_invoices ) ) { |
|
1159 | - foreach( $user_invoices as $user_invoice ) { |
|
1157 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
1158 | + if (!empty($user_invoices)) { |
|
1159 | + foreach ($user_invoices as $user_invoice) { |
|
1160 | 1160 | $user_cart_details = array(); |
1161 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
1161 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
1162 | 1162 | $cart_details = $invoice->get_cart_details(); |
1163 | 1163 | |
1164 | - if ( !empty( $cart_details ) ) { |
|
1165 | - foreach ( $cart_details as $invoice_item ) { |
|
1164 | + if (!empty($cart_details)) { |
|
1165 | + foreach ($cart_details as $invoice_item) { |
|
1166 | 1166 | $ii_arr = array(); |
1167 | - $ii_arr['id'] = (int)$invoice_item['id']; |
|
1168 | - $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
|
1167 | + $ii_arr['id'] = (int) $invoice_item['id']; |
|
1168 | + $ii_arr['quantity'] = (int) $invoice_item['quantity']; |
|
1169 | 1169 | |
1170 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
1170 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
1171 | 1171 | $ii_arr['meta'] = $invoice_item['meta']; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
1174 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
1175 | 1175 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
1176 | 1176 | } |
1177 | 1177 | |
@@ -1179,17 +1179,17 @@ discard block |
||
1179 | 1179 | } |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
1183 | - wp_send_json( array( |
|
1182 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
1183 | + wp_send_json(array( |
|
1184 | 1184 | 'success' => $invoice->get_checkout_payment_url() |
1185 | - ) ); |
|
1185 | + )); |
|
1186 | 1186 | wp_die(); |
1187 | 1187 | } |
1188 | 1188 | } |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | // Create invoice and send user to checkout |
1192 | - if ( !empty( $cart_items ) ) { |
|
1192 | + if (!empty($cart_items)) { |
|
1193 | 1193 | $invoice_data = array( |
1194 | 1194 | 'status' => 'wpi-pending', |
1195 | 1195 | 'created_via' => 'wpi', |
@@ -1197,21 +1197,21 @@ discard block |
||
1197 | 1197 | 'cart_details' => $cart_items, |
1198 | 1198 | ); |
1199 | 1199 | |
1200 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
1200 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
1201 | 1201 | |
1202 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
1203 | - wp_send_json( array( |
|
1202 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
1203 | + wp_send_json(array( |
|
1204 | 1204 | 'success' => $invoice->get_checkout_payment_url() |
1205 | - ) ); |
|
1205 | + )); |
|
1206 | 1206 | } else { |
1207 | - wp_send_json( array( |
|
1208 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
1209 | - ) ); |
|
1207 | + wp_send_json(array( |
|
1208 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
1209 | + )); |
|
1210 | 1210 | } |
1211 | 1211 | } else { |
1212 | - wp_send_json( array( |
|
1213 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
1214 | - ) ); |
|
1212 | + wp_send_json(array( |
|
1213 | + 'error' => __('Items not valid.', 'invoicing') |
|
1214 | + )); |
|
1215 | 1215 | } |
1216 | 1216 | } |
1217 | 1217 |
@@ -8,201 +8,201 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$pages = wpinv_get_pages( true ); |
|
13 | +$pages = wpinv_get_pages(true); |
|
14 | 14 | |
15 | 15 | $currencies = wpinv_get_currencies(); |
16 | 16 | |
17 | 17 | $currency_code_options = array(); |
18 | -foreach ( $currencies as $code => $name ) { |
|
19 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
18 | +foreach ($currencies as $code => $name) { |
|
19 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | $due_payment_options = array(); |
23 | -$due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
24 | -for ( $i = 1; $i <= 30; $i++ ) { |
|
23 | +$due_payment_options[0] = __('Now', 'invoicing'); |
|
24 | +for ($i = 1; $i <= 30; $i++) { |
|
25 | 25 | $due_payment_options[$i] = $i; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $invoice_number_padd_options = array(); |
29 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
29 | +for ($i = 0; $i <= 20; $i++) { |
|
30 | 30 | $invoice_number_padd_options[$i] = $i; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $currency_symbol = wpinv_currency_symbol(); |
34 | 34 | |
35 | 35 | $last_number = $reset_number = ''; |
36 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
37 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
36 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
37 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
38 | 38 | |
39 | - if ( !empty( $last_invoice_number ) ) { |
|
40 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
39 | + if (!empty($last_invoice_number)) { |
|
40 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $nonce = wp_create_nonce('reset_invoice_count'); |
44 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
44 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $alert_wrapper_start = '<p style="color: #F00">'; |
48 | 48 | $alert_wrapper_close = '</p>'; |
49 | 49 | |
50 | 50 | return array( |
51 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
51 | + 'general' => apply_filters('wpinv_settings_general', |
|
52 | 52 | array( |
53 | 53 | 'main' => array( |
54 | 54 | 'location_settings' => array( |
55 | 55 | 'id' => 'location_settings', |
56 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
56 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
57 | 57 | 'desc' => '', |
58 | 58 | 'type' => 'header', |
59 | 59 | ), |
60 | 60 | 'default_country' => array( |
61 | 61 | 'id' => 'default_country', |
62 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
63 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
62 | + 'name' => __('Default Country', 'invoicing'), |
|
63 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
64 | 64 | 'type' => 'select', |
65 | 65 | 'options' => wpinv_get_country_list(), |
66 | 66 | 'std' => 'GB', |
67 | 67 | 'class' => 'wpi_select2', |
68 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
68 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
69 | 69 | ), |
70 | 70 | 'default_state' => array( |
71 | 71 | 'id' => 'default_state', |
72 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
73 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
72 | + 'name' => __('Default State / Province', 'invoicing'), |
|
73 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
74 | 74 | 'type' => 'country_states', |
75 | 75 | 'class' => 'wpi_select2', |
76 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
76 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
77 | 77 | ), |
78 | 78 | 'store_name' => array( |
79 | 79 | 'id' => 'store_name', |
80 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
81 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
80 | + 'name' => __('Store Name', 'invoicing'), |
|
81 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
82 | 82 | 'std' => get_option('blogname'), |
83 | 83 | 'type' => 'text', |
84 | 84 | ), |
85 | 85 | 'logo' => array( |
86 | 86 | 'id' => 'logo', |
87 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
88 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
87 | + 'name' => __('Logo URL', 'invoicing'), |
|
88 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
89 | 89 | 'type' => 'text', |
90 | 90 | ), |
91 | 91 | 'store_address' => array( |
92 | 92 | 'id' => 'store_address', |
93 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
94 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
93 | + 'name' => __('Store Address', 'invoicing'), |
|
94 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
95 | 95 | 'type' => 'textarea', |
96 | 96 | ), |
97 | 97 | 'page_settings' => array( |
98 | 98 | 'id' => 'page_settings', |
99 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
99 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
100 | 100 | 'desc' => '', |
101 | 101 | 'type' => 'header', |
102 | 102 | ), |
103 | 103 | 'checkout_page' => array( |
104 | 104 | 'id' => 'checkout_page', |
105 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
106 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
105 | + 'name' => __('Checkout Page', 'invoicing'), |
|
106 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
107 | 107 | 'type' => 'select', |
108 | 108 | 'options' => $pages, |
109 | 109 | 'class' => 'wpi_select2', |
110 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
110 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
111 | 111 | ), |
112 | 112 | 'tandc_page' => array( |
113 | 113 | 'id' => 'tandc_page', |
114 | - 'name' => __( 'Terms & Conditions', 'invoicing' ), |
|
115 | - 'desc' => __( 'If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing' ), |
|
114 | + 'name' => __('Terms & Conditions', 'invoicing'), |
|
115 | + 'desc' => __('If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing'), |
|
116 | 116 | 'type' => 'select', |
117 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
117 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
118 | 118 | 'class' => 'wpi_select2', |
119 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
119 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
120 | 120 | ), |
121 | 121 | 'success_page' => array( |
122 | 122 | 'id' => 'success_page', |
123 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
124 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
123 | + 'name' => __('Success Page', 'invoicing'), |
|
124 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
125 | 125 | 'type' => 'select', |
126 | 126 | 'options' => $pages, |
127 | 127 | 'class' => 'wpi_select2', |
128 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
128 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
129 | 129 | ), |
130 | 130 | 'failure_page' => array( |
131 | 131 | 'id' => 'failure_page', |
132 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
133 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
132 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
133 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
134 | 134 | 'type' => 'select', |
135 | 135 | 'options' => $pages, |
136 | 136 | 'class' => 'wpi_select2', |
137 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
137 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
138 | 138 | ), |
139 | 139 | 'invoice_history_page' => array( |
140 | 140 | 'id' => 'invoice_history_page', |
141 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
142 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
141 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
142 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
143 | 143 | 'type' => 'select', |
144 | 144 | 'options' => $pages, |
145 | 145 | 'class' => 'wpi_select2', |
146 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
146 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
147 | 147 | ), |
148 | 148 | 'invoice_subscription_page' => array( |
149 | 149 | 'id' => 'invoice_subscription_page', |
150 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
151 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
150 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
151 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
152 | 152 | 'type' => 'select', |
153 | 153 | 'options' => $pages, |
154 | 154 | 'class' => 'wpi_select2', |
155 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
155 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
156 | 156 | ), |
157 | 157 | ), |
158 | 158 | 'currency_section' => array( |
159 | 159 | 'currency_settings' => array( |
160 | 160 | 'id' => 'currency_settings', |
161 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
161 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
162 | 162 | 'desc' => '', |
163 | 163 | 'type' => 'header', |
164 | 164 | ), |
165 | 165 | 'currency' => array( |
166 | 166 | 'id' => 'currency', |
167 | - 'name' => __( 'Currency', 'invoicing' ), |
|
168 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
167 | + 'name' => __('Currency', 'invoicing'), |
|
168 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
169 | 169 | 'type' => 'select', |
170 | 170 | 'class' => 'wpi_select2', |
171 | 171 | 'options' => $currency_code_options, |
172 | 172 | ), |
173 | 173 | 'currency_position' => array( |
174 | 174 | 'id' => 'currency_position', |
175 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
176 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
175 | + 'name' => __('Currency Position', 'invoicing'), |
|
176 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
177 | 177 | 'type' => 'select', |
178 | 178 | 'class' => 'wpi_select2', |
179 | 179 | 'options' => array( |
180 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
181 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
182 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
183 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
180 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
181 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
182 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
183 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
184 | 184 | ) |
185 | 185 | ), |
186 | 186 | 'thousands_separator' => array( |
187 | 187 | 'id' => 'thousands_separator', |
188 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
189 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
188 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
189 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
190 | 190 | 'type' => 'text', |
191 | 191 | 'size' => 'small', |
192 | 192 | 'std' => ',', |
193 | 193 | ), |
194 | 194 | 'decimal_separator' => array( |
195 | 195 | 'id' => 'decimal_separator', |
196 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
197 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
196 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
197 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
198 | 198 | 'type' => 'text', |
199 | 199 | 'size' => 'small', |
200 | 200 | 'std' => '.', |
201 | 201 | ), |
202 | 202 | 'decimals' => array( |
203 | 203 | 'id' => 'decimals', |
204 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
205 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
204 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
205 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
206 | 206 | 'type' => 'number', |
207 | 207 | 'size' => 'small', |
208 | 208 | 'std' => '2', |
@@ -214,29 +214,29 @@ discard block |
||
214 | 214 | 'labels' => array( |
215 | 215 | 'labels' => array( |
216 | 216 | 'id' => 'labels_settings', |
217 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
217 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
218 | 218 | 'desc' => '', |
219 | 219 | 'type' => 'header', |
220 | 220 | ), |
221 | 221 | 'vat_name' => array( |
222 | 222 | 'id' => 'vat_name', |
223 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
224 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
223 | + 'name' => __('VAT Name', 'invoicing'), |
|
224 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
225 | 225 | 'type' => 'text', |
226 | 226 | 'size' => 'regular', |
227 | - 'std' => __( 'VAT', 'invoicing' ), |
|
227 | + 'std' => __('VAT', 'invoicing'), |
|
228 | 228 | ), |
229 | 229 | 'vat_invoice_notice_label' => array( |
230 | 230 | 'id' => 'vat_invoice_notice_label', |
231 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
232 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
231 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
232 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
233 | 233 | 'type' => 'text', |
234 | 234 | 'size' => 'regular', |
235 | 235 | ), |
236 | 236 | 'vat_invoice_notice' => array( |
237 | 237 | 'id' => 'vat_invoice_notice', |
238 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
239 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
238 | + 'name' => __('Invoice notice', 'invoicing'), |
|
239 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
240 | 240 | 'type' => 'text', |
241 | 241 | 'size' => 'regular', |
242 | 242 | ), |
@@ -248,22 +248,22 @@ discard block |
||
248 | 248 | 'main' => array( |
249 | 249 | 'gateway_settings' => array( |
250 | 250 | 'id' => 'api_header', |
251 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
251 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
252 | 252 | 'desc' => '', |
253 | 253 | 'type' => 'header', |
254 | 254 | ), |
255 | 255 | 'gateways' => array( |
256 | 256 | 'id' => 'gateways', |
257 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
258 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
257 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
258 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
259 | 259 | 'type' => 'gateways', |
260 | 260 | 'std' => array('manual'=>1), |
261 | 261 | 'options' => wpinv_get_payment_gateways(), |
262 | 262 | ), |
263 | 263 | 'default_gateway' => array( |
264 | 264 | 'id' => 'default_gateway', |
265 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
266 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
265 | + 'name' => __('Default Gateway', 'invoicing'), |
|
266 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
267 | 267 | 'type' => 'gateway_select', |
268 | 268 | 'std' => 'manual', |
269 | 269 | 'class' => 'wpi_select2', |
@@ -278,19 +278,19 @@ discard block |
||
278 | 278 | 'main' => array( |
279 | 279 | 'tax_settings' => array( |
280 | 280 | 'id' => 'tax_settings', |
281 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
281 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
282 | 282 | 'type' => 'header', |
283 | 283 | ), |
284 | 284 | 'enable_taxes' => array( |
285 | 285 | 'id' => 'enable_taxes', |
286 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
287 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
286 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
287 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
288 | 288 | 'type' => 'checkbox', |
289 | 289 | ), |
290 | 290 | 'tax_rate' => array( |
291 | 291 | 'id' => 'tax_rate', |
292 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
293 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
292 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
293 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
294 | 294 | 'type' => 'number', |
295 | 295 | 'size' => 'small', |
296 | 296 | 'min' => '0', |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | 'rates' => array( |
303 | 303 | 'tax_rates' => array( |
304 | 304 | 'id' => 'tax_rates', |
305 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
306 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
305 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
306 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
307 | 307 | 'type' => 'tax_rates', |
308 | 308 | ), |
309 | 309 | ) |
@@ -315,68 +315,68 @@ discard block |
||
315 | 315 | 'main' => array( |
316 | 316 | 'email_settings_header' => array( |
317 | 317 | 'id' => 'email_settings_header', |
318 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
318 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
319 | 319 | 'type' => 'header', |
320 | 320 | ), |
321 | 321 | 'email_from_name' => array( |
322 | 322 | 'id' => 'email_from_name', |
323 | - 'name' => __( 'From Name', 'invoicing' ), |
|
324 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
325 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
323 | + 'name' => __('From Name', 'invoicing'), |
|
324 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
325 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
326 | 326 | 'type' => 'text', |
327 | 327 | ), |
328 | 328 | 'email_from' => array( |
329 | 329 | 'id' => 'email_from', |
330 | - 'name' => __( 'From Email', 'invoicing' ), |
|
331 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
332 | - 'std' => get_option( 'admin_email' ), |
|
330 | + 'name' => __('From Email', 'invoicing'), |
|
331 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
332 | + 'std' => get_option('admin_email'), |
|
333 | 333 | 'type' => 'text', |
334 | 334 | ), |
335 | 335 | 'admin_email' => array( |
336 | 336 | 'id' => 'admin_email', |
337 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
338 | - 'desc' => __( 'Where should we send admin notifications?', 'invoicing' ), |
|
339 | - 'std' => get_option( 'admin_email' ), |
|
337 | + 'name' => __('Admin Email', 'invoicing'), |
|
338 | + 'desc' => __('Where should we send admin notifications?', 'invoicing'), |
|
339 | + 'std' => get_option('admin_email'), |
|
340 | 340 | 'type' => 'text', |
341 | 341 | ), |
342 | 342 | 'overdue_settings_header' => array( |
343 | 343 | 'id' => 'overdue_settings_header', |
344 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
344 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
345 | 345 | 'type' => 'header', |
346 | 346 | ), |
347 | 347 | 'overdue_active' => array( |
348 | 348 | 'id' => 'overdue_active', |
349 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
350 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
349 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
350 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
351 | 351 | 'type' => 'checkbox', |
352 | 352 | 'std' => false, |
353 | 353 | ), |
354 | 354 | 'overdue_days' => array( |
355 | 355 | 'id' => 'overdue_days', |
356 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
357 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
356 | + 'name' => __('Default Due Date', 'invoicing'), |
|
357 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
358 | 358 | 'type' => 'select', |
359 | 359 | 'options' => $due_payment_options, |
360 | 360 | 'std' => 0, |
361 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
361 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
362 | 362 | ), |
363 | 363 | 'email_template_header' => array( |
364 | 364 | 'id' => 'email_template_header', |
365 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
365 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
366 | 366 | 'type' => 'header', |
367 | 367 | ), |
368 | 368 | 'email_header_image' => array( |
369 | 369 | 'id' => 'email_header_image', |
370 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
371 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
370 | + 'name' => __('Header Image', 'invoicing'), |
|
371 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
372 | 372 | 'std' => '', |
373 | 373 | 'type' => 'text', |
374 | 374 | ), |
375 | 375 | 'email_footer_text' => array( |
376 | 376 | 'id' => 'email_footer_text', |
377 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
378 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
379 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
377 | + 'name' => __('Footer Text', 'invoicing'), |
|
378 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
379 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
380 | 380 | 'type' => 'textarea', |
381 | 381 | 'class' => 'regular-text', |
382 | 382 | 'rows' => 2, |
@@ -384,29 +384,29 @@ discard block |
||
384 | 384 | ), |
385 | 385 | 'email_base_color' => array( |
386 | 386 | 'id' => 'email_base_color', |
387 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
388 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
387 | + 'name' => __('Base Color', 'invoicing'), |
|
388 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
389 | 389 | 'std' => '#557da2', |
390 | 390 | 'type' => 'color', |
391 | 391 | ), |
392 | 392 | 'email_background_color' => array( |
393 | 393 | 'id' => 'email_background_color', |
394 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
395 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
394 | + 'name' => __('Background Color', 'invoicing'), |
|
395 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
396 | 396 | 'std' => '#f5f5f5', |
397 | 397 | 'type' => 'color', |
398 | 398 | ), |
399 | 399 | 'email_body_background_color' => array( |
400 | 400 | 'id' => 'email_body_background_color', |
401 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
402 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
401 | + 'name' => __('Body Background Color', 'invoicing'), |
|
402 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
403 | 403 | 'std' => '#fdfdfd', |
404 | 404 | 'type' => 'color', |
405 | 405 | ), |
406 | 406 | 'email_text_color' => array( |
407 | 407 | 'id' => 'email_text_color', |
408 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
409 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
408 | + 'name' => __('Body Text Color', 'invoicing'), |
|
409 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
410 | 410 | 'std' => '#505050', |
411 | 411 | 'type' => 'color', |
412 | 412 | ), |
@@ -425,17 +425,17 @@ discard block |
||
425 | 425 | 'main' => array( |
426 | 426 | 'invoicing_privacy_policy_settings' => array( |
427 | 427 | 'id' => 'invoicing_privacy_policy_settings', |
428 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
428 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
429 | 429 | 'type' => 'header', |
430 | 430 | ), |
431 | 431 | 'privacy_page' => array( |
432 | 432 | 'id' => 'privacy_page', |
433 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
434 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
433 | + 'name' => __('Privacy Page', 'invoicing'), |
|
434 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
435 | 435 | 'type' => 'select', |
436 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
436 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
437 | 437 | 'class' => 'wpi_select2', |
438 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
438 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
439 | 439 | ), |
440 | 440 | ), |
441 | 441 | ) |
@@ -446,19 +446,19 @@ discard block |
||
446 | 446 | 'main' => array( |
447 | 447 | 'invoice_number_format_settings' => array( |
448 | 448 | 'id' => 'invoice_number_format_settings', |
449 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
449 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
450 | 450 | 'type' => 'header', |
451 | 451 | ), |
452 | 452 | 'sequential_invoice_number' => array( |
453 | 453 | 'id' => 'sequential_invoice_number', |
454 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
455 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
454 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
455 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
456 | 456 | 'type' => 'checkbox', |
457 | 457 | ), |
458 | 458 | 'invoice_sequence_start' => array( |
459 | 459 | 'id' => 'invoice_sequence_start', |
460 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
461 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
460 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
461 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
462 | 462 | 'type' => 'number', |
463 | 463 | 'size' => 'small', |
464 | 464 | 'std' => '1', |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | ), |
467 | 467 | 'invoice_number_padd' => array( |
468 | 468 | 'id' => 'invoice_number_padd', |
469 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
470 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
469 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
470 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
471 | 471 | 'type' => 'select', |
472 | 472 | 'options' => $invoice_number_padd_options, |
473 | 473 | 'std' => 5, |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | ), |
476 | 476 | 'invoice_number_prefix' => array( |
477 | 477 | 'id' => 'invoice_number_prefix', |
478 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
479 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
478 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
479 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
480 | 480 | 'type' => 'text', |
481 | 481 | 'size' => 'regular', |
482 | 482 | 'std' => 'INV-', |
@@ -484,32 +484,32 @@ discard block |
||
484 | 484 | ), |
485 | 485 | 'invoice_number_postfix' => array( |
486 | 486 | 'id' => 'invoice_number_postfix', |
487 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
488 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
487 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
488 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
489 | 489 | 'type' => 'text', |
490 | 490 | 'size' => 'regular', |
491 | 491 | 'std' => '' |
492 | 492 | ), |
493 | 493 | 'checkout_settings' => array( |
494 | 494 | 'id' => 'checkout_settings', |
495 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
495 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
496 | 496 | 'type' => 'header', |
497 | 497 | ), |
498 | 498 | 'login_to_checkout' => array( |
499 | 499 | 'id' => 'login_to_checkout', |
500 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
501 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
500 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
501 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
502 | 502 | 'type' => 'checkbox', |
503 | 503 | ), |
504 | 504 | 'uninstall_settings' => array( |
505 | 505 | 'id' => 'uninstall_settings', |
506 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
506 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
507 | 507 | 'type' => 'header', |
508 | 508 | ), |
509 | 509 | 'remove_data_on_unistall' => array( |
510 | 510 | 'id' => 'remove_data_on_unistall', |
511 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
512 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
511 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
512 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
513 | 513 | 'type' => 'checkbox', |
514 | 514 | 'std' => '' |
515 | 515 | ), |
@@ -517,20 +517,20 @@ discard block |
||
517 | 517 | 'fields' => array( |
518 | 518 | 'address_autofill_settings' => array( |
519 | 519 | 'id' => 'address_autofill_settings', |
520 | - 'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>', |
|
520 | + 'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>', |
|
521 | 521 | 'type' => 'header', |
522 | 522 | ), |
523 | 523 | 'address_autofill_active' => array( |
524 | 524 | 'id' => 'address_autofill_active', |
525 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
526 | - 'desc' => __( 'Enable google address auto complete', 'invoicing' ), |
|
525 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
526 | + 'desc' => __('Enable google address auto complete', 'invoicing'), |
|
527 | 527 | 'type' => 'checkbox', |
528 | 528 | 'std' => 0 |
529 | 529 | ), |
530 | 530 | 'address_autofill_api' => array( |
531 | 531 | 'id' => 'address_autofill_api', |
532 | - 'name' => __( 'Google Place API Key', 'invoicing' ), |
|
533 | - 'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ), |
|
532 | + 'name' => __('Google Place API Key', 'invoicing'), |
|
533 | + 'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'), |
|
534 | 534 | 'type' => 'text', |
535 | 535 | 'size' => 'regular', |
536 | 536 | 'std' => '' |
@@ -539,13 +539,13 @@ discard block |
||
539 | 539 | 'custom-css' => array( |
540 | 540 | 'css_settings' => array( |
541 | 541 | 'id' => 'css_settings', |
542 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
542 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
543 | 543 | 'type' => 'header', |
544 | 544 | ), |
545 | 545 | 'template_custom_css' => array( |
546 | 546 | 'id' => 'template_custom_css', |
547 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
548 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
547 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
548 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
549 | 549 | 'type' => 'textarea', |
550 | 550 | 'class'=> 'regular-text', |
551 | 551 | 'rows' => 10, |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | 'main' => array( |
560 | 560 | 'tool_settings' => array( |
561 | 561 | 'id' => 'tool_settings', |
562 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
563 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
562 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
563 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
564 | 564 | 'type' => 'tools', |
565 | 565 | ), |
566 | 566 | ), |