@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | - die( '-1' ); |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | + die('-1'); |
|
5 | 5 | } |
6 | 6 | |
7 | -$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text', get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ) ) ); |
|
8 | -$email_footer = $email_footer ? wp_kses_post( wpautop( wptexturize( $email_footer ) ) ) : ''; |
|
7 | +$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text', get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'))); |
|
8 | +$email_footer = $email_footer ? wp_kses_post(wpautop(wptexturize($email_footer))) : ''; |
|
9 | 9 | ?> |
10 | 10 | </div> |
11 | 11 | </td> |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | <table border="0" cellpadding="10" cellspacing="0" width="100%"> |
28 | 28 | <tr> |
29 | 29 | <td colspan="2" valign="middle" id="credit"> |
30 | - <?php echo wp_kses_post( $email_footer ); ?> |
|
30 | + <?php echo wp_kses_post($email_footer); ?> |
|
31 | 31 | </td> |
32 | 32 | </tr> |
33 | 33 | </table> |
@@ -8,22 +8,22 @@ discard block |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | // Totals rows. |
14 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
14 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
15 | 15 | |
16 | -do_action( 'getpaid_before_email_line_totals', $invoice, $totals ); |
|
16 | +do_action('getpaid_before_email_line_totals', $invoice, $totals); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | |
20 | 20 | |
21 | -<?php if ( has_action( 'wpinv_email_footer_buttons' ) ) : ?> |
|
21 | +<?php if (has_action('wpinv_email_footer_buttons')) : ?> |
|
22 | 22 | |
23 | 23 | <tr class="wpinv_cart_footer_row"> |
24 | 24 | |
25 | - <td colspan="<?php echo ( (int) $column_count ); ?>"> |
|
26 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
25 | + <td colspan="<?php echo ((int) $column_count); ?>"> |
|
26 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
27 | 27 | </td> |
28 | 28 | |
29 | 29 | </tr> |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | <?php endif; ?> |
32 | 32 | |
33 | 33 | |
34 | -<?php foreach ( $totals as $key => $label ) : ?> |
|
34 | +<?php foreach ($totals as $key => $label) : ?> |
|
35 | 35 | |
36 | - <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo esc_html( $key ); ?>_row"> |
|
36 | + <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo esc_html($key); ?>_row"> |
|
37 | 37 | |
38 | - <td colspan="<?php echo absint( ( $column_count - 1 ) ); ?>" class="wpinv_cart_<?php echo esc_html( $key ); ?>_label text-right"> |
|
39 | - <strong><?php echo esc_html( $label ); ?>:</strong> |
|
38 | + <td colspan="<?php echo absint(($column_count - 1)); ?>" class="wpinv_cart_<?php echo esc_html($key); ?>_label text-right"> |
|
39 | + <strong><?php echo esc_html($label); ?>:</strong> |
|
40 | 40 | </td> |
41 | 41 | |
42 | - <td class="wpinv_cart_<?php echo esc_html( $key ); ?> text-right"> |
|
42 | + <td class="wpinv_cart_<?php echo esc_html($key); ?> text-right"> |
|
43 | 43 | |
44 | 44 | <?php |
45 | 45 | |
46 | 46 | // Total tax. |
47 | - if ( 'tax' == $key ) { |
|
48 | - wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() ); |
|
47 | + if ('tax' == $key) { |
|
48 | + wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); |
|
49 | 49 | } |
50 | 50 | |
51 | - if ( 'fee' == $key ) { |
|
52 | - wpinv_the_price( $invoice->get_total_fees(), $invoice->get_currency() ); |
|
51 | + if ('fee' == $key) { |
|
52 | + wpinv_the_price($invoice->get_total_fees(), $invoice->get_currency()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // Total discount. |
56 | - if ( 'discount' == $key ) { |
|
57 | - wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() ); |
|
56 | + if ('discount' == $key) { |
|
57 | + wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Sub total. |
61 | - if ( 'subtotal' == $key ) { |
|
62 | - wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() ); |
|
61 | + if ('subtotal' == $key) { |
|
62 | + wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Total. |
66 | - if ( 'total' == $key ) { |
|
67 | - wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); |
|
66 | + if ('total' == $key) { |
|
67 | + wpinv_the_price($invoice->get_total(), $invoice->get_currency()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Fires when printing a cart total in an email. |
71 | - do_action( "getpaid_email_cart_totals_$key", $invoice ); |
|
71 | + do_action("getpaid_email_cart_totals_$key", $invoice); |
|
72 | 72 | |
73 | 73 | ?> |
74 | 74 | |
@@ -80,4 +80,4 @@ discard block |
||
80 | 80 | |
81 | 81 | <?php |
82 | 82 | |
83 | - do_action( 'getpaid_after_email_line_totals', $invoice, $totals ); |
|
83 | + do_action('getpaid_after_email_line_totals', $invoice, $totals); |
@@ -30,40 +30,40 @@ |
||
30 | 30 | // Item name. |
31 | 31 | if ( 'name' == $column ) { |
32 | 32 | |
33 | - // Display the name. |
|
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $item->get_name() ) . '</div>'; |
|
33 | + // Display the name. |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html( $item->get_name() ) . '</div>'; |
|
35 | 35 | |
36 | - // And an optional description. |
|
37 | - $description = $item->get_description(); |
|
36 | + // And an optional description. |
|
37 | + $description = $item->get_description(); |
|
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - echo "<p class='small'>" . wp_kses_post( $description ) . "</p>"; |
|
39 | + if ( ! empty( $description ) ) { |
|
40 | + echo "<p class='small'>" . wp_kses_post( $description ) . "</p>"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Item price. |
45 | 45 | if ( 'price' == $column ) { |
46 | 46 | |
47 | - // Display the item price (or recurring price if this is a renewal invoice) |
|
48 | - $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
|
49 | - wpinv_the_price( $price, $invoice->get_currency() ); |
|
47 | + // Display the item price (or recurring price if this is a renewal invoice) |
|
48 | + $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
|
49 | + wpinv_the_price( $price, $invoice->get_currency() ); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Item quantity. |
54 | 54 | if ( 'quantity' == $column ) { |
55 | - echo (float) $item->get_quantity(); |
|
55 | + echo (float) $item->get_quantity(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Tax rate. |
59 | 59 | if ( 'tax_rate' == $column ) { |
60 | - echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
60 | + echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | 64 | if ( 'subtotal' == $column ) { |
65 | - $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
|
66 | - wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
65 | + $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
|
66 | + wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Fires when printing a line item column. |
@@ -10,64 +10,64 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
18 | 18 | |
19 | -<tr class="wpinv_cart_item item-type-<?php echo esc_attr( $item->get_type() ); ?>"> |
|
19 | +<tr class="wpinv_cart_item item-type-<?php echo esc_attr($item->get_type()); ?>"> |
|
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
21 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo esc_attr( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo esc_attr($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
28 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - echo "<p class='small'>" . wp_kses_post( $description ) . "</p>"; |
|
39 | + if (!empty($description)) { |
|
40 | + echo "<p class='small'>" . wp_kses_post($description) . "</p>"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Item price. |
45 | - if ( 'price' == $column ) { |
|
45 | + if ('price' == $column) { |
|
46 | 46 | |
47 | 47 | // Display the item price (or recurring price if this is a renewal invoice) |
48 | 48 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
49 | - wpinv_the_price( $price, $invoice->get_currency() ); |
|
49 | + wpinv_the_price($price, $invoice->get_currency()); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Item quantity. |
54 | - if ( 'quantity' == $column ) { |
|
54 | + if ('quantity' == $column) { |
|
55 | 55 | echo (float) $item->get_quantity(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Tax rate. |
59 | - if ( 'tax_rate' == $column ) { |
|
60 | - echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
59 | + if ('tax_rate' == $column) { |
|
60 | + echo floatval(round(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | - if ( 'subtotal' == $column ) { |
|
64 | + if ('subtotal' == $column) { |
|
65 | 65 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
66 | - wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
66 | + wpinv_the_price($subtotal, $invoice->get_currency()); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Fires when printing a line item column. |
70 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
70 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
71 | 71 | |
72 | 72 | ?> |
73 | 73 | |
@@ -77,4 +77,4 @@ discard block |
||
77 | 77 | |
78 | 78 | </tr> |
79 | 79 | |
80 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
80 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -7,21 +7,21 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
12 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
13 | 13 | |
14 | -do_action( 'wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
14 | +do_action('wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
15 | 15 | |
16 | 16 | // Generate the custom message body. |
17 | -echo wp_kses_post( wptexturize( str_replace( '{customer_note}', $customer_note, $message_body ) ) ); |
|
17 | +echo wp_kses_post(wptexturize(str_replace('{customer_note}', $customer_note, $message_body))); |
|
18 | 18 | |
19 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
19 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
20 | 20 | |
21 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
21 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
22 | 22 | |
23 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
23 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
24 | 24 | |
25 | -do_action( 'wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
25 | +do_action('wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
26 | 26 | |
27 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
27 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | // Item name. |
31 | 31 | if ( 'name' == $column ) { |
32 | 32 | |
33 | - // Display the name. |
|
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $fee['name'] ) . '</div>'; |
|
33 | + // Display the name. |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html( $fee['name'] ) . '</div>'; |
|
35 | 35 | |
36 | - // And an optional description. |
|
37 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | - echo wp_kses_post( "<p class='small'>$description</p>" ); |
|
36 | + // And an optional description. |
|
37 | + $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | + echo wp_kses_post( "<p class='small'>$description</p>" ); |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item price. |
43 | 43 | if ( 'price' == $column ) { |
44 | 44 | |
45 | - // Display the item price (or recurring price if this is a renewal invoice) |
|
46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
45 | + // Display the item price (or recurring price if this is a renewal invoice) |
|
46 | + if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | + wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
48 | 48 | } else { |
49 | 49 | wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
50 | 50 | } |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | |
53 | 53 | // Item quantity. |
54 | 54 | if ( 'quantity' == $column ) { |
55 | - echo '—'; |
|
55 | + echo '—'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Item tax. |
59 | 59 | if ( 'tax_rate' == $column ) { |
60 | - echo '—'; |
|
60 | + echo '—'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | 64 | if ( 'subtotal' == $column ) { |
65 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
66 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
65 | + if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
66 | + wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
67 | 67 | } else { |
68 | 68 | wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
69 | 69 | } |
@@ -10,67 +10,67 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?> |
|
17 | +<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?> |
|
18 | 18 | |
19 | 19 | <tr class="wpinv_cart_item item-fee"> |
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
21 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo esc_attr( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right'; ?> wpinv_cart_item_<?php echo esc_attr($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a fee item column. |
28 | - do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice ); |
|
28 | + do_action("getpaid_email_fee_item_before_$column", $fee, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . esc_html( $fee['name'] ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . esc_html($fee['name']) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | - echo wp_kses_post( "<p class='small'>$description</p>" ); |
|
37 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
38 | + echo wp_kses_post("<p class='small'>$description</p>"); |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item price. |
43 | - if ( 'price' == $column ) { |
|
43 | + if ('price' == $column) { |
|
44 | 44 | |
45 | 45 | // Display the item price (or recurring price if this is a renewal invoice) |
46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
46 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
47 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
48 | 48 | } else { |
49 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
49 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Item quantity. |
54 | - if ( 'quantity' == $column ) { |
|
54 | + if ('quantity' == $column) { |
|
55 | 55 | echo '—'; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Item tax. |
59 | - if ( 'tax_rate' == $column ) { |
|
59 | + if ('tax_rate' == $column) { |
|
60 | 60 | echo '—'; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Item sub total. |
64 | - if ( 'subtotal' == $column ) { |
|
65 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
66 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
64 | + if ('subtotal' == $column) { |
|
65 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
66 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
67 | 67 | } else { |
68 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
68 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Fires when printing a line item column. |
73 | - do_action( "getpaid_email_fee_item_$column", $fee, $invoice ); |
|
73 | + do_action("getpaid_email_fee_item_$column", $fee, $invoice); |
|
74 | 74 | |
75 | 75 | ?> |
76 | 76 | |
@@ -80,4 +80,4 @@ discard block |
||
80 | 80 | |
81 | 81 | </tr> |
82 | 82 | |
83 | -<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?> |
|
83 | +<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?> |
@@ -126,25 +126,25 @@ |
||
126 | 126 | |
127 | 127 | if ( ! empty( $invoice_actions ) ) { |
128 | 128 | |
129 | - echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
|
129 | + echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
|
130 | 130 | |
131 | - foreach ( $invoice_actions as $key => $invoice_action ) { |
|
131 | + foreach ( $invoice_actions as $key => $invoice_action ) { |
|
132 | 132 | |
133 | - $key = sanitize_html_class( $key ); |
|
134 | - $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
135 | - $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
136 | - $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
137 | - $anchor = esc_html( $invoice_action['name'] ); |
|
133 | + $key = sanitize_html_class( $key ); |
|
134 | + $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
135 | + $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
136 | + $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
137 | + $anchor = esc_html( $invoice_action['name'] ); |
|
138 | 138 | |
139 | - echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
139 | + echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
140 | 140 | } |
141 | 141 | |
142 | - echo '</div>'; |
|
142 | + echo '</div>'; |
|
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | 146 | if ( ! empty( $alert ) ) { |
147 | - echo wp_kses_post( $alert ); |
|
147 | + echo wp_kses_post( $alert ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | ?> |
@@ -7,64 +7,64 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Fetch the invoice. |
13 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | +$invoice = new WPInv_Invoice($invoice); |
|
14 | 14 | |
15 | 15 | // @deprecated |
16 | -do_action( 'wpinv_success_content_before', $invoice ); |
|
17 | -do_action( 'wpinv_before_receipt', $invoice ); |
|
16 | +do_action('wpinv_success_content_before', $invoice); |
|
17 | +do_action('wpinv_before_receipt', $invoice); |
|
18 | 18 | |
19 | 19 | wpinv_print_errors(); |
20 | 20 | |
21 | 21 | // Prepare header text. |
22 | -if ( $invoice->is_paid() ) { |
|
22 | +if ($invoice->is_paid()) { |
|
23 | 23 | |
24 | 24 | $alert = aui()->alert( |
25 | 25 | array( |
26 | 26 | 'type' => 'success', |
27 | - 'content' => __( 'Thank you for your payment!', 'invoicing' ), |
|
27 | + 'content' => __('Thank you for your payment!', 'invoicing'), |
|
28 | 28 | ) |
29 | 29 | ); |
30 | 30 | |
31 | -} elseif ( $invoice->is_refunded() ) { |
|
31 | +} elseif ($invoice->is_refunded()) { |
|
32 | 32 | |
33 | 33 | $alert = aui()->alert( |
34 | 34 | array( |
35 | 35 | 'type' => 'info', |
36 | - 'content' => __( 'This invoice was refunded.', 'invoicing' ), |
|
36 | + 'content' => __('This invoice was refunded.', 'invoicing'), |
|
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | |
40 | -} elseif ( $invoice->is_held() ) { |
|
40 | +} elseif ($invoice->is_held()) { |
|
41 | 41 | |
42 | 42 | $alert = aui()->alert( |
43 | 43 | array( |
44 | 44 | 'type' => 'info', |
45 | - 'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ), |
|
45 | + 'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'), |
|
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | |
49 | -} elseif ( $invoice->needs_payment() ) { |
|
49 | +} elseif ($invoice->needs_payment()) { |
|
50 | 50 | |
51 | - if ( ! empty( $_GET['token'] ) ) { |
|
51 | + if (!empty($_GET['token'])) { |
|
52 | 52 | |
53 | 53 | $alert = aui()->alert( |
54 | 54 | array( |
55 | 55 | 'type' => 'info', |
56 | - 'content' => __( "Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing' ), |
|
56 | + 'content' => __("Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing'), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - } elseif ( $invoice->is_due() ) { |
|
60 | + } elseif ($invoice->is_due()) { |
|
61 | 61 | |
62 | 62 | $alert = aui()->alert( |
63 | 63 | array( |
64 | 64 | 'type' => 'danger', |
65 | 65 | 'content' => sprintf( |
66 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
67 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
66 | + __('This invoice was due on %.', 'invoicing'), |
|
67 | + getpaid_format_date_value($invoice->get_due_date()) |
|
68 | 68 | ), |
69 | 69 | ) |
70 | 70 | ); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $alert = aui()->alert( |
75 | 75 | array( |
76 | 76 | 'type' => 'warning', |
77 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
77 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
78 | 78 | ) |
79 | 79 | ); |
80 | 80 | |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | |
89 | 89 | 'pay' => array( |
90 | 90 | 'url' => $invoice->get_checkout_payment_url(), |
91 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
91 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
92 | 92 | 'class' => 'btn-success', |
93 | 93 | ), |
94 | 94 | |
95 | 95 | 'view' => array( |
96 | 96 | 'url' => $invoice->get_view_url(), |
97 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
97 | + 'name' => __('View Invoice', 'invoicing'), |
|
98 | 98 | 'class' => 'btn-primary', |
99 | 99 | ), |
100 | 100 | |
101 | 101 | 'history' => array( |
102 | 102 | 'url' => wpinv_get_history_page_uri(), |
103 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
103 | + 'name' => __('Invoice History', 'invoicing'), |
|
104 | 104 | 'class' => 'btn-warning', |
105 | 105 | ), |
106 | 106 | |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | $invoice |
109 | 109 | ); |
110 | 110 | |
111 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $invoice_actions['pay'] ) ) { |
|
112 | - unset( $invoice_actions['pay'] ); |
|
111 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($invoice_actions['pay'])) { |
|
112 | + unset($invoice_actions['pay']); |
|
113 | 113 | } |
114 | 114 | |
115 | -if ( ! is_user_logged_in() && isset( $invoice_actions['history'] ) ) { |
|
116 | - unset( $invoice_actions['history'] ); |
|
115 | +if (!is_user_logged_in() && isset($invoice_actions['history'])) { |
|
116 | + unset($invoice_actions['history']); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | ?> |
@@ -122,29 +122,29 @@ discard block |
||
122 | 122 | |
123 | 123 | <?php |
124 | 124 | |
125 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
125 | + do_action('wpinv_receipt_start', $invoice); |
|
126 | 126 | |
127 | - if ( ! empty( $invoice_actions ) ) { |
|
127 | + if (!empty($invoice_actions)) { |
|
128 | 128 | |
129 | 129 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
130 | 130 | |
131 | - foreach ( $invoice_actions as $key => $invoice_action ) { |
|
131 | + foreach ($invoice_actions as $key => $invoice_action) { |
|
132 | 132 | |
133 | - $key = sanitize_html_class( $key ); |
|
134 | - $class = empty( $invoice_action['class'] ) ? 'btn-dark' : sanitize_html_class( $invoice_action['class'] ); |
|
135 | - $url = empty( $invoice_action['url'] ) ? '#' : esc_url( $invoice_action['url'] ); |
|
136 | - $attrs = empty( $invoice_action['attrs'] ) ? '' : $invoice_action['attrs']; |
|
137 | - $anchor = esc_html( $invoice_action['name'] ); |
|
133 | + $key = sanitize_html_class($key); |
|
134 | + $class = empty($invoice_action['class']) ? 'btn-dark' : sanitize_html_class($invoice_action['class']); |
|
135 | + $url = empty($invoice_action['url']) ? '#' : esc_url($invoice_action['url']); |
|
136 | + $attrs = empty($invoice_action['attrs']) ? '' : $invoice_action['attrs']; |
|
137 | + $anchor = esc_html($invoice_action['name']); |
|
138 | 138 | |
139 | - echo wp_kses_post( "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>" ); |
|
139 | + echo wp_kses_post("<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | echo '</div>'; |
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | - if ( ! empty( $alert ) ) { |
|
147 | - echo wp_kses_post( $alert ); |
|
146 | + if (!empty($alert)) { |
|
147 | + echo wp_kses_post($alert); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | ?> |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | <div class="wpinv-receipt-details"> |
153 | 153 | |
154 | 154 | <h4 class="wpinv-details-t mb-3 mt-3"> |
155 | - <?php echo esc_html( apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ) ); ?> |
|
155 | + <?php echo esc_html(apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice)); ?> |
|
156 | 156 | </h4> |
157 | 157 | |
158 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
158 | + <?php getpaid_invoice_meta($invoice); ?> |
|
159 | 159 | |
160 | 160 | </div> |
161 | 161 | |
162 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
162 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
163 | 163 | |
164 | 164 | </div> |
165 | 165 | |
166 | 166 | <?php |
167 | 167 | |
168 | 168 | // @deprecated |
169 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
170 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
169 | +do_action('wpinv_success_content_after', $invoice); |
|
170 | +do_action('wpinv_after_receipt', $invoice); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPInv_Admin_Users ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) { |
|
19 | 19 | self::$instance = new WPInv_Admin_Users(); |
20 | 20 | } |
21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public function __construct() { |
26 | - add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column' ) ); |
|
27 | - add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content' ), 10, 3 ); |
|
26 | + add_filter('manage_users_columns', array($this, 'wpinv_add_user_column')); |
|
27 | + add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return mixed |
36 | 36 | */ |
37 | - public function wpinv_add_user_column( $column ) { |
|
38 | - $column['wpinvoicing'] = __( 'Invoicing', 'invoicing' ); |
|
37 | + public function wpinv_add_user_column($column) { |
|
38 | + $column['wpinvoicing'] = __('Invoicing', 'invoicing'); |
|
39 | 39 | return $column; |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public function wpinv_user_column_content( $val, $column_name, $user_id ) { |
|
52 | - switch ( $column_name ) { |
|
51 | + public function wpinv_user_column_content($val, $column_name, $user_id) { |
|
52 | + switch ($column_name) { |
|
53 | 53 | case 'wpinvoicing': |
54 | - return $this->get_user_invoices( $user_id ); |
|
54 | + return $this->get_user_invoices($user_id); |
|
55 | 55 | break; |
56 | 56 | default: |
57 | 57 | } |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function get_user_invoices( $user_id ) { |
|
68 | + public function get_user_invoices($user_id) { |
|
69 | 69 | $output = ''; |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_invoice', |
72 | - 'post_status' => array( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal' ), |
|
72 | + 'post_status' => array('wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-cancelled', 'wpi-failed', 'wpi-renewal'), |
|
73 | 73 | 'posts_per_page' => -1, |
74 | 74 | 'fields' => 'ids', |
75 | 75 | 'author' => $user_id, |
76 | 76 | ); |
77 | 77 | |
78 | - $wp_query_args = apply_filters( 'wpinv_get_user_invoices_args', $wp_query_args, $user_id ); |
|
78 | + $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id); |
|
79 | 79 | |
80 | - $invoices = new WP_Query( $wp_query_args ); |
|
81 | - $count = absint( $invoices->found_posts ); |
|
80 | + $invoices = new WP_Query($wp_query_args); |
|
81 | + $count = absint($invoices->found_posts); |
|
82 | 82 | |
83 | - if ( empty( $count ) ) { |
|
84 | - $output .= __( 'No Invoice(s)', 'invoicing' ); |
|
83 | + if (empty($count)) { |
|
84 | + $output .= __('No Invoice(s)', 'invoicing'); |
|
85 | 85 | } else { |
86 | - $link_url = admin_url( 'edit.php?post_type=wpi_invoice&author=' . absint( $user_id ) ); |
|
87 | - $link_text = sprintf( __( 'Invoices ( %d )', 'invoicing' ), $count ); |
|
86 | + $link_url = admin_url('edit.php?post_type=wpi_invoice&author=' . absint($user_id)); |
|
87 | + $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count); |
|
88 | 88 | $output .= "<a href='$link_url' >$link_text</a>"; |
89 | 89 | } |
90 | 90 | |
91 | - return apply_filters( 'wpinv_user_invoice_content', $output, $user_id ); |
|
91 | + return apply_filters('wpinv_user_invoice_content', $output, $user_id); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Invoice_Address { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the invoice. |
@@ -225,37 +225,37 @@ discard block |
||
225 | 225 | |
226 | 226 | if ( empty( $states ) ) { |
227 | 227 | |
228 | - aui()->input( |
|
229 | - array( |
|
230 | - 'type' => 'text', |
|
231 | - 'id' => 'wpinv_state', |
|
232 | - 'name' => 'wpinv_state', |
|
233 | - 'label' => __( 'State', 'invoicing' ), |
|
234 | - 'label_type' => 'vertical', |
|
235 | - 'placeholder' => '', |
|
236 | - 'class' => 'form-control-sm', |
|
237 | - 'value' => $invoice->get_state( 'edit' ), |
|
238 | - ), |
|
239 | - true |
|
240 | - ); |
|
228 | + aui()->input( |
|
229 | + array( |
|
230 | + 'type' => 'text', |
|
231 | + 'id' => 'wpinv_state', |
|
232 | + 'name' => 'wpinv_state', |
|
233 | + 'label' => __( 'State', 'invoicing' ), |
|
234 | + 'label_type' => 'vertical', |
|
235 | + 'placeholder' => '', |
|
236 | + 'class' => 'form-control-sm', |
|
237 | + 'value' => $invoice->get_state( 'edit' ), |
|
238 | + ), |
|
239 | + true |
|
240 | + ); |
|
241 | 241 | |
242 | 242 | } else { |
243 | 243 | |
244 | - aui()->select( |
|
245 | - array( |
|
246 | - 'id' => 'wpinv_state', |
|
247 | - 'name' => 'wpinv_state', |
|
248 | - 'label' => __( 'State', 'invoicing' ), |
|
249 | - 'label_type' => 'vertical', |
|
250 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
251 | - 'class' => 'form-control-sm', |
|
252 | - 'value' => $invoice->get_state( 'edit' ), |
|
253 | - 'options' => $states, |
|
254 | - 'data-allow-clear' => 'false', |
|
255 | - 'select2' => true, |
|
256 | - ), |
|
257 | - true |
|
258 | - ); |
|
244 | + aui()->select( |
|
245 | + array( |
|
246 | + 'id' => 'wpinv_state', |
|
247 | + 'name' => 'wpinv_state', |
|
248 | + 'label' => __( 'State', 'invoicing' ), |
|
249 | + 'label_type' => 'vertical', |
|
250 | + 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
251 | + 'class' => 'form-control-sm', |
|
252 | + 'value' => $invoice->get_state( 'edit' ), |
|
253 | + 'options' => $states, |
|
254 | + 'data-allow-clear' => 'false', |
|
255 | + 'select2' => true, |
|
256 | + ), |
|
257 | + true |
|
258 | + ); |
|
259 | 259 | |
260 | 260 | } |
261 | 261 | |
@@ -381,18 +381,18 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
384 | - * Save meta box data. |
|
385 | - * |
|
386 | - * @param int $post_id |
|
387 | - */ |
|
388 | - public static function save( $post_id ) { |
|
384 | + * Save meta box data. |
|
385 | + * |
|
386 | + * @param int $post_id |
|
387 | + */ |
|
388 | + public static function save( $post_id ) { |
|
389 | 389 | |
390 | 390 | // Prepare the invoice. |
391 | 391 | $invoice = new WPInv_Invoice( $post_id ); |
392 | 392 | |
393 | 393 | // Load new data. |
394 | 394 | $invoice->set_props( |
395 | - array( |
|
395 | + array( |
|
396 | 396 | 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
397 | 397 | 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
398 | 398 | 'disable_taxes' => ! empty( $_POST['disable_taxes'] ), |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
416 | 416 | 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
417 | 417 | 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
418 | - ) |
|
418 | + ) |
|
419 | 419 | ); |
420 | 420 | |
421 | 421 | // Discount code. |
@@ -471,6 +471,6 @@ discard block |
||
471 | 471 | } |
472 | 472 | |
473 | 473 | // Fires after an invoice is saved. |
474 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
475 | - } |
|
474 | + do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
475 | + } |
|
476 | 476 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
29 | - $customer = new WP_User( $customer ); |
|
30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | + $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id(); |
|
29 | + $customer = new WP_User($customer); |
|
30 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email); |
|
31 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
32 | 32 | |
33 | 33 | ?> |
34 | 34 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | <div class="col-12 col-sm-6"> |
44 | 44 | <div id="getpaid-invoice-user-id-wrapper" class="form-group mb-3"> |
45 | 45 | <div> |
46 | - <label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' ); ?></label> |
|
46 | + <label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label> |
|
47 | 47 | </div> |
48 | 48 | <div> |
49 | - <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>"> |
|
50 | - <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>) |
|
49 | + <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>"> |
|
50 | + <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>) |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | </div> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'type' => 'text', |
61 | 61 | 'id' => 'getpaid-invoice-new-user-email', |
62 | 62 | 'name' => 'wpinv_email', |
63 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
63 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
64 | 64 | 'label_type' => 'vertical', |
65 | 65 | 'placeholder' => '[email protected]', |
66 | 66 | 'class' => 'form-control-sm', |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | <div class="col-12 col-sm-6 form-group mb-3 mt-sm-4"> |
74 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
74 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
75 | 75 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
76 | 76 | <i aria-hidden="true" class="fa fa-refresh"></i> |
77 | - <?php esc_html_e( 'Fill User Details', 'invoicing' ); ?> |
|
77 | + <?php esc_html_e('Fill User Details', 'invoicing'); ?> |
|
78 | 78 | </a> |
79 | 79 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
80 | 80 | <i aria-hidden="true" class="fa fa-plus"></i> |
81 | - <?php esc_html_e( 'Add New User', 'invoicing' ); ?> |
|
81 | + <?php esc_html_e('Add New User', 'invoicing'); ?> |
|
82 | 82 | </a> |
83 | 83 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
84 | 84 | <i aria-hidden="true" class="fa fa-close"></i> |
85 | - <?php esc_html_e( 'Cancel', 'invoicing' ); ?> |
|
85 | + <?php esc_html_e('Cancel', 'invoicing'); ?> |
|
86 | 86 | </a> |
87 | 87 | <?php endif; ?> |
88 | 88 | </div> |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | 'type' => 'text', |
96 | 96 | 'id' => 'wpinv_first_name', |
97 | 97 | 'name' => 'wpinv_first_name', |
98 | - 'label' => __( 'First Name', 'invoicing' ), |
|
98 | + 'label' => __('First Name', 'invoicing'), |
|
99 | 99 | 'label_type' => 'vertical', |
100 | 100 | 'placeholder' => '', |
101 | 101 | 'class' => 'form-control-sm', |
102 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
102 | + 'value' => $invoice->get_first_name('edit'), |
|
103 | 103 | ), |
104 | 104 | true |
105 | 105 | ); |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | 'type' => 'text', |
113 | 113 | 'id' => 'wpinv_last_name', |
114 | 114 | 'name' => 'wpinv_last_name', |
115 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
115 | + 'label' => __('Last Name', 'invoicing'), |
|
116 | 116 | 'label_type' => 'vertical', |
117 | 117 | 'placeholder' => '', |
118 | 118 | 'class' => 'form-control-sm', |
119 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
119 | + 'value' => $invoice->get_last_name('edit'), |
|
120 | 120 | ), |
121 | 121 | true |
122 | 122 | ); |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | 'type' => 'text', |
133 | 133 | 'id' => 'wpinv_company', |
134 | 134 | 'name' => 'wpinv_company', |
135 | - 'label' => __( 'Company', 'invoicing' ), |
|
135 | + 'label' => __('Company', 'invoicing'), |
|
136 | 136 | 'label_type' => 'vertical', |
137 | 137 | 'placeholder' => '', |
138 | 138 | 'class' => 'form-control-sm', |
139 | - 'value' => $invoice->get_company( 'edit' ), |
|
139 | + 'value' => $invoice->get_company('edit'), |
|
140 | 140 | ), |
141 | 141 | true |
142 | 142 | ); |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | 'type' => 'text', |
150 | 150 | 'id' => 'wpinv_vat_number', |
151 | 151 | 'name' => 'wpinv_vat_number', |
152 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
152 | + 'label' => __('Vat Number', 'invoicing'), |
|
153 | 153 | 'label_type' => 'vertical', |
154 | 154 | 'placeholder' => '', |
155 | 155 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
156 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
156 | + 'value' => $invoice->get_vat_number('edit'), |
|
157 | 157 | ), |
158 | 158 | true |
159 | 159 | ); |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | 'type' => 'text', |
170 | 170 | 'id' => 'wpinv_address', |
171 | 171 | 'name' => 'wpinv_address', |
172 | - 'label' => __( 'Address', 'invoicing' ), |
|
172 | + 'label' => __('Address', 'invoicing'), |
|
173 | 173 | 'label_type' => 'vertical', |
174 | 174 | 'placeholder' => '', |
175 | 175 | 'class' => 'form-control-sm', |
176 | - 'value' => $invoice->get_address( 'edit' ), |
|
176 | + 'value' => $invoice->get_address('edit'), |
|
177 | 177 | ), |
178 | 178 | true |
179 | 179 | ); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | 'type' => 'text', |
187 | 187 | 'id' => 'wpinv_city', |
188 | 188 | 'name' => 'wpinv_city', |
189 | - 'label' => __( 'City', 'invoicing' ), |
|
189 | + 'label' => __('City', 'invoicing'), |
|
190 | 190 | 'label_type' => 'vertical', |
191 | 191 | 'placeholder' => '', |
192 | 192 | 'class' => 'form-control-sm', |
193 | - 'value' => $invoice->get_city( 'edit' ), |
|
193 | + 'value' => $invoice->get_city('edit'), |
|
194 | 194 | ), |
195 | 195 | true |
196 | 196 | ); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | array( |
206 | 206 | 'id' => 'wpinv_country', |
207 | 207 | 'name' => 'wpinv_country', |
208 | - 'label' => __( 'Country', 'invoicing' ), |
|
208 | + 'label' => __('Country', 'invoicing'), |
|
209 | 209 | 'label_type' => 'vertical', |
210 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
210 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
211 | 211 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
212 | - 'value' => $invoice->get_country( 'edit' ), |
|
212 | + 'value' => $invoice->get_country('edit'), |
|
213 | 213 | 'options' => wpinv_get_country_list(), |
214 | 214 | 'data-allow-clear' => 'false', |
215 | 215 | 'select2' => true, |
@@ -221,20 +221,20 @@ discard block |
||
221 | 221 | <div class="col-12 col-sm-6"> |
222 | 222 | <?php |
223 | 223 | |
224 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
224 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
225 | 225 | |
226 | - if ( empty( $states ) ) { |
|
226 | + if (empty($states)) { |
|
227 | 227 | |
228 | 228 | aui()->input( |
229 | 229 | array( |
230 | 230 | 'type' => 'text', |
231 | 231 | 'id' => 'wpinv_state', |
232 | 232 | 'name' => 'wpinv_state', |
233 | - 'label' => __( 'State', 'invoicing' ), |
|
233 | + 'label' => __('State', 'invoicing'), |
|
234 | 234 | 'label_type' => 'vertical', |
235 | 235 | 'placeholder' => '', |
236 | 236 | 'class' => 'form-control-sm', |
237 | - 'value' => $invoice->get_state( 'edit' ), |
|
237 | + 'value' => $invoice->get_state('edit'), |
|
238 | 238 | ), |
239 | 239 | true |
240 | 240 | ); |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | array( |
246 | 246 | 'id' => 'wpinv_state', |
247 | 247 | 'name' => 'wpinv_state', |
248 | - 'label' => __( 'State', 'invoicing' ), |
|
248 | + 'label' => __('State', 'invoicing'), |
|
249 | 249 | 'label_type' => 'vertical', |
250 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
250 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
251 | 251 | 'class' => 'form-control-sm', |
252 | - 'value' => $invoice->get_state( 'edit' ), |
|
252 | + 'value' => $invoice->get_state('edit'), |
|
253 | 253 | 'options' => $states, |
254 | 254 | 'data-allow-clear' => 'false', |
255 | 255 | 'select2' => true, |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | 'type' => 'text', |
272 | 272 | 'id' => 'wpinv_zip', |
273 | 273 | 'name' => 'wpinv_zip', |
274 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
274 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
275 | 275 | 'label_type' => 'vertical', |
276 | 276 | 'placeholder' => '', |
277 | 277 | 'class' => 'form-control-sm', |
278 | - 'value' => $invoice->get_zip( 'edit' ), |
|
278 | + 'value' => $invoice->get_zip('edit'), |
|
279 | 279 | ), |
280 | 280 | true |
281 | 281 | ); |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | 'type' => 'text', |
289 | 289 | 'id' => 'wpinv_phone', |
290 | 290 | 'name' => 'wpinv_phone', |
291 | - 'label' => __( 'Phone', 'invoicing' ), |
|
291 | + 'label' => __('Phone', 'invoicing'), |
|
292 | 292 | 'label_type' => 'vertical', |
293 | 293 | 'placeholder' => '', |
294 | 294 | 'class' => 'form-control-sm', |
295 | - 'value' => $invoice->get_phone( 'edit' ), |
|
295 | + 'value' => $invoice->get_phone('edit'), |
|
296 | 296 | ), |
297 | 297 | true |
298 | 298 | ); |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | </div> |
301 | 301 | </div> |
302 | 302 | |
303 | - <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?> |
|
304 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
303 | + <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?> |
|
304 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
305 | 305 | |
306 | 306 | <div class="row"> |
307 | 307 | <div class="col-12 col-sm-6"> |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | array( |
311 | 311 | 'id' => 'wpinv_template', |
312 | 312 | 'name' => 'wpinv_template', |
313 | - 'label' => __( 'Template', 'invoicing' ), |
|
313 | + 'label' => __('Template', 'invoicing'), |
|
314 | 314 | 'label_type' => 'vertical', |
315 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
315 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
316 | 316 | 'class' => 'form-control-sm', |
317 | - 'value' => $invoice->get_template( 'edit' ), |
|
317 | + 'value' => $invoice->get_template('edit'), |
|
318 | 318 | 'options' => array( |
319 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
320 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
319 | + 'quantity' => __('Quantity', 'invoicing'), |
|
320 | + 'hours' => __('Hours', 'invoicing'), |
|
321 | 321 | //'amount' => __( 'Amount Only', 'invoicing' ), |
322 | 322 | ), |
323 | 323 | 'data-allow-clear' => 'false', |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | array( |
336 | 336 | 'id' => 'wpinv_currency', |
337 | 337 | 'name' => 'wpinv_currency', |
338 | - 'label' => __( 'Currency', 'invoicing' ), |
|
338 | + 'label' => __('Currency', 'invoicing'), |
|
339 | 339 | 'label_type' => 'vertical', |
340 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
340 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
341 | 341 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
342 | - 'value' => $invoice->get_currency( 'edit' ), |
|
342 | + 'value' => $invoice->get_currency('edit'), |
|
343 | 343 | 'required' => false, |
344 | 344 | 'data-allow-clear' => 'false', |
345 | 345 | 'select2' => true, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | </div> |
353 | 353 | </div> |
354 | 354 | |
355 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
355 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
356 | 356 | <?php endif; ?> |
357 | 357 | |
358 | 358 | <div class="row"> |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | 'type' => 'text', |
364 | 364 | 'id' => 'wpinv_company_id', |
365 | 365 | 'name' => 'wpinv_company_id', |
366 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
366 | + 'label' => __('Company ID', 'invoicing'), |
|
367 | 367 | 'label_type' => 'vertical', |
368 | 368 | 'placeholder' => '', |
369 | 369 | 'class' => 'form-control-sm', |
370 | - 'value' => $invoice->get_company_id( 'edit' ), |
|
370 | + 'value' => $invoice->get_company_id('edit'), |
|
371 | 371 | ), |
372 | 372 | true |
373 | 373 | ); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | </div> |
376 | 376 | </div> |
377 | 377 | |
378 | - <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
|
378 | + <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?> |
|
379 | 379 | </div> |
380 | 380 | <?php |
381 | 381 | } |
@@ -385,51 +385,51 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @param int $post_id |
387 | 387 | */ |
388 | - public static function save( $post_id ) { |
|
388 | + public static function save($post_id) { |
|
389 | 389 | |
390 | 390 | // Prepare the invoice. |
391 | - $invoice = new WPInv_Invoice( $post_id ); |
|
391 | + $invoice = new WPInv_Invoice($post_id); |
|
392 | 392 | |
393 | 393 | // Load new data. |
394 | 394 | $invoice->set_props( |
395 | 395 | array( |
396 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
397 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
398 | - 'disable_taxes' => ! empty( $_POST['disable_taxes'] ), |
|
399 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
400 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
401 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
402 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
403 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
404 | - 'company_id' => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null, |
|
405 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
406 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
407 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
408 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
409 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
410 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
411 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
412 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
413 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
414 | - 'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null, |
|
415 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
416 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
417 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
396 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
397 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
398 | + 'disable_taxes' => !empty($_POST['disable_taxes']), |
|
399 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
400 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
401 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
402 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
403 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
404 | + 'company_id' => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null, |
|
405 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
406 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
407 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
408 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
409 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
410 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
411 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
412 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
413 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
414 | + 'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null, |
|
415 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
416 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
417 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
418 | 418 | ) |
419 | 419 | ); |
420 | 420 | |
421 | 421 | // Discount code. |
422 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
422 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
423 | 423 | |
424 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
425 | - $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) ); |
|
424 | + if (isset($_POST['wpinv_discount_code'])) { |
|
425 | + $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code'])); |
|
426 | 426 | } |
427 | 427 | |
428 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
429 | - if ( $discount->exists() ) { |
|
430 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
428 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
429 | + if ($discount->exists()) { |
|
430 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
431 | 431 | } else { |
432 | - $invoice->remove_discount( 'discount_code' ); |
|
432 | + $invoice->remove_discount('discount_code'); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | // Recalculate totals. |
@@ -438,16 +438,16 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | // If we're creating a new user... |
441 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) { |
|
441 | + if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) { |
|
442 | 442 | |
443 | 443 | // Attempt to create the user. |
444 | - $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() ); |
|
444 | + $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])), $invoice->get_first_name() . $invoice->get_last_name()); |
|
445 | 445 | |
446 | 446 | // If successful, update the invoice author. |
447 | - if ( is_numeric( $user ) ) { |
|
448 | - $invoice->set_author( $user ); |
|
447 | + if (is_numeric($user)) { |
|
448 | + $invoice->set_author($user); |
|
449 | 449 | } else { |
450 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
450 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
@@ -461,16 +461,16 @@ discard block |
||
461 | 461 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
462 | 462 | |
463 | 463 | // (Maybe) send new user notification. |
464 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
465 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
466 | - wp_send_new_user_notifications( $user, 'user' ); |
|
464 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
465 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) { |
|
466 | + wp_send_new_user_notifications($user, 'user'); |
|
467 | 467 | } |
468 | 468 | |
469 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
470 | - getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
469 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
470 | + getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | // Fires after an invoice is saved. |
474 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
474 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
475 | 475 | } |
476 | 476 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function wpinv_sanitize_country( $country ) { |
38 | 38 | |
39 | - // Enure the country is specified |
|
39 | + // Enure the country is specified |
|
40 | 40 | if ( empty( $country ) ) { |
41 | 41 | $country = wpinv_get_default_country(); |
42 | 42 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_get_default_state() { |
69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
69 | + $state = wpinv_get_option( 'default_state', '' ); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
71 | + return apply_filters( 'wpinv_default_state', $state ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | |
304 | 304 | $country = wpinv_sanitize_country( $country ); |
305 | 305 | |
306 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
307 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
308 | - return $continent_code; |
|
309 | - } |
|
310 | - } |
|
306 | + foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
307 | + if ( false !== array_search( $country, $countries, true ) ) { |
|
308 | + return $continent_code; |
|
309 | + } |
|
310 | + } |
|
311 | 311 | |
312 | 312 | return ''; |
313 | 313 | |
@@ -599,31 +599,31 @@ discard block |
||
599 | 599 | } |
600 | 600 | |
601 | 601 | function wpinv_get_states_field() { |
602 | - if ( empty( $_POST['country'] ) ) { |
|
603 | - $_POST['country'] = wpinv_get_default_country(); |
|
604 | - } |
|
605 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
602 | + if ( empty( $_POST['country'] ) ) { |
|
603 | + $_POST['country'] = wpinv_get_default_country(); |
|
604 | + } |
|
605 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
606 | 606 | |
607 | - if ( ! empty( $states ) ) { |
|
608 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
607 | + if ( ! empty( $states ) ) { |
|
608 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
609 | 609 | |
610 | 610 | $class = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : ''; |
611 | 611 | $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2"; |
612 | 612 | |
613 | 613 | $args = array( |
614 | - 'name' => $sanitized_field_name, |
|
615 | - 'id' => $sanitized_field_name, |
|
616 | - 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
617 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
618 | - 'show_option_all' => false, |
|
619 | - 'show_option_none' => false, |
|
620 | - ); |
|
621 | - |
|
622 | - wpinv_html_select( $args ); |
|
623 | - |
|
624 | - } else { |
|
625 | - echo 'nostates'; |
|
626 | - } |
|
614 | + 'name' => $sanitized_field_name, |
|
615 | + 'id' => $sanitized_field_name, |
|
616 | + 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
617 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
618 | + 'show_option_all' => false, |
|
619 | + 'show_option_none' => false, |
|
620 | + ); |
|
621 | + |
|
622 | + wpinv_html_select( $args ); |
|
623 | + |
|
624 | + } else { |
|
625 | + echo 'nostates'; |
|
626 | + } |
|
627 | 627 | |
628 | 628 | } |
629 | 629 | |
@@ -642,47 +642,47 @@ discard block |
||
642 | 642 | */ |
643 | 643 | function wpinv_get_address_formats() { |
644 | 644 | |
645 | - return apply_filters( |
|
645 | + return apply_filters( |
|
646 | 646 | 'wpinv_localisation_address_formats', |
647 | - array( |
|
648 | - 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
|
649 | - 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
|
650 | - 'AT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
651 | - 'BE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
652 | - 'CA' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}} {{zip}}\n{{country}}", |
|
653 | - 'CH' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
654 | - 'CL' => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}", |
|
655 | - 'CN' => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}", |
|
656 | - 'CZ' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
657 | - 'DE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
658 | - 'EE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
659 | - 'FI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
660 | - 'DK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
661 | - 'FR' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}", |
|
662 | - 'HK' => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}", |
|
663 | - 'HU' => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}", |
|
664 | - 'IN' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}", |
|
665 | - 'IS' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
666 | - 'IT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}", |
|
667 | - 'JP' => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}", |
|
668 | - 'TW' => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}", |
|
669 | - 'LI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
670 | - 'NL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
671 | - 'NZ' => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}", |
|
672 | - 'NO' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
673 | - 'PL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
674 | - 'PT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
675 | - 'SK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
676 | - 'RS' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
677 | - 'SI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
678 | - 'ES' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}", |
|
679 | - 'SE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
680 | - 'TR' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}", |
|
681 | - 'UG' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}", |
|
682 | - 'US' => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}", |
|
683 | - 'VN' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}", |
|
684 | - ) |
|
685 | - ); |
|
647 | + array( |
|
648 | + 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
|
649 | + 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
|
650 | + 'AT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
651 | + 'BE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
652 | + 'CA' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}} {{zip}}\n{{country}}", |
|
653 | + 'CH' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
654 | + 'CL' => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}", |
|
655 | + 'CN' => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}", |
|
656 | + 'CZ' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
657 | + 'DE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
658 | + 'EE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
659 | + 'FI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
660 | + 'DK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
661 | + 'FR' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}", |
|
662 | + 'HK' => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}", |
|
663 | + 'HU' => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}", |
|
664 | + 'IN' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}", |
|
665 | + 'IS' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
666 | + 'IT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}", |
|
667 | + 'JP' => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}", |
|
668 | + 'TW' => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}", |
|
669 | + 'LI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
670 | + 'NL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
671 | + 'NZ' => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}", |
|
672 | + 'NO' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
673 | + 'PL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
674 | + 'PT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
675 | + 'SK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
676 | + 'RS' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
677 | + 'SI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
678 | + 'ES' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}", |
|
679 | + 'SE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
680 | + 'TR' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}", |
|
681 | + 'UG' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}", |
|
682 | + 'US' => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}", |
|
683 | + 'VN' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}", |
|
684 | + ) |
|
685 | + ); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -699,21 +699,21 @@ discard block |
||
699 | 699 | } |
700 | 700 | |
701 | 701 | // Get all formats. |
702 | - $formats = wpinv_get_address_formats(); |
|
702 | + $formats = wpinv_get_address_formats(); |
|
703 | 703 | |
704 | - // Get format for the specified country. |
|
705 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
704 | + // Get format for the specified country. |
|
705 | + $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
706 | 706 | |
707 | 707 | /** |
708 | - * Filters the address format to use on Invoices. |
|
708 | + * Filters the address format to use on Invoices. |
|
709 | 709 | * |
710 | 710 | * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed. |
711 | - * |
|
712 | - * @since 1.0.13 |
|
713 | - * |
|
714 | - * @param string $format The address format to use. |
|
711 | + * |
|
712 | + * @since 1.0.13 |
|
713 | + * |
|
714 | + * @param string $format The address format to use. |
|
715 | 715 | * @param string $country The country who's address format is being retrieved. |
716 | - */ |
|
716 | + */ |
|
717 | 717 | return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
718 | 718 | } |
719 | 719 | |
@@ -734,8 +734,8 @@ discard block |
||
734 | 734 | 'country' => '', |
735 | 735 | 'zip' => '', |
736 | 736 | 'first_name' => '', |
737 | - 'last_name' => '', |
|
738 | - 'company' => '', |
|
737 | + 'last_name' => '', |
|
738 | + 'company' => '', |
|
739 | 739 | ); |
740 | 740 | |
741 | 741 | $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
@@ -756,14 +756,14 @@ discard block |
||
756 | 756 | $args['country_code'] = $country; |
757 | 757 | |
758 | 758 | /** |
759 | - * Filters the address format replacements to use on Invoices. |
|
759 | + * Filters the address format replacements to use on Invoices. |
|
760 | + * |
|
761 | + * |
|
762 | + * @since 1.0.13 |
|
760 | 763 | * |
761 | - * |
|
762 | - * @since 1.0.13 |
|
763 | - * |
|
764 | - * @param array $replacements The address replacements to use. |
|
764 | + * @param array $replacements The address replacements to use. |
|
765 | 765 | * @param array $billing_details The billing details to use. |
766 | - */ |
|
766 | + */ |
|
767 | 767 | $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
768 | 768 | |
769 | 769 | $return = array(); |
@@ -786,5 +786,5 @@ discard block |
||
786 | 786 | * @return string |
787 | 787 | */ |
788 | 788 | function wpinv_trim_formatted_address_line( $line ) { |
789 | - return trim( $line, ', ' ); |
|
789 | + return trim( $line, ', ' ); |
|
790 | 790 | } |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters('wpinv_default_country', $country); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string |
25 | 25 | */ |
26 | -function getpaid_get_ip_country( $ip_address = '' ) { |
|
27 | - $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true ); |
|
26 | +function getpaid_get_ip_country($ip_address = '') { |
|
27 | + $country = GetPaid_Geolocation::geolocate_ip($ip_address, true); |
|
28 | 28 | return $country['country']; |
29 | 29 | } |
30 | 30 | |
@@ -34,59 +34,59 @@ discard block |
||
34 | 34 | * @param string $country The country code to sanitize |
35 | 35 | * @return array |
36 | 36 | */ |
37 | -function wpinv_sanitize_country( $country ) { |
|
37 | +function wpinv_sanitize_country($country) { |
|
38 | 38 | |
39 | 39 | // Enure the country is specified |
40 | - if ( empty( $country ) ) { |
|
40 | + if (empty($country)) { |
|
41 | 41 | $country = wpinv_get_default_country(); |
42 | 42 | } |
43 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
43 | + return trim(wpinv_utf8_strtoupper($country)); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_is_base_country( $country ) { |
|
47 | +function wpinv_is_base_country($country) { |
|
48 | 48 | $base_country = wpinv_get_default_country(); |
49 | 49 | |
50 | - if ( $base_country === 'UK' ) { |
|
50 | + if ($base_country === 'UK') { |
|
51 | 51 | $base_country = 'GB'; |
52 | 52 | } |
53 | - if ( $country == 'UK' ) { |
|
53 | + if ($country == 'UK') { |
|
54 | 54 | $country = 'GB'; |
55 | 55 | } |
56 | 56 | |
57 | - return ( $country && $country === $base_country ) ? true : false; |
|
57 | + return ($country && $country === $base_country) ? true : false; |
|
58 | 58 | } |
59 | 59 | |
60 | -function wpinv_country_name( $country_code = '' ) { |
|
60 | +function wpinv_country_name($country_code = '') { |
|
61 | 61 | $countries = wpinv_get_country_list(); |
62 | 62 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
63 | - $country = isset( $countries[ $country_code ] ) ? $countries[ $country_code ] : $country_code; |
|
63 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
64 | 64 | |
65 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
65 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_get_default_state() { |
69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
69 | + $state = wpinv_get_option('default_state', ''); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
71 | + return apply_filters('wpinv_default_state', $state); |
|
72 | 72 | } |
73 | 73 | |
74 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
74 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
75 | 75 | $state = $state_code; |
76 | 76 | |
77 | - if ( ! empty( $country_code ) ) { |
|
78 | - $states = wpinv_get_country_states( $country_code ); |
|
77 | + if (!empty($country_code)) { |
|
78 | + $states = wpinv_get_country_states($country_code); |
|
79 | 79 | |
80 | - $state = ! empty( $states ) && isset( $states[ $state_code ] ) ? $states[ $state_code ] : $state; |
|
80 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
81 | 81 | } |
82 | 82 | |
83 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
83 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | function wpinv_store_address() { |
87 | - $address = wpinv_get_option( 'store_address', '' ); |
|
87 | + $address = wpinv_get_option('store_address', ''); |
|
88 | 88 | |
89 | - return apply_filters( 'wpinv_store_address', $address ); |
|
89 | + return apply_filters('wpinv_store_address', $address); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param WPInv_Invoice $invoice |
96 | 96 | */ |
97 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
97 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
98 | 98 | |
99 | 99 | $user_id = $invoice->get_user_id(); |
100 | 100 | |
101 | 101 | // Abort if the invoice belongs to no one. |
102 | - if ( empty( $user_id ) ) { |
|
102 | + if (empty($user_id)) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Fill in defaults whenever necessary. |
107 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
107 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
108 | 108 | |
109 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
110 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
109 | + if (is_callable($invoice, "get_$key")) { |
|
110 | + $current = call_user_func(array($invoice, "get_$key")); |
|
111 | 111 | |
112 | - if ( empty( $current ) ) { |
|
112 | + if (empty($current)) { |
|
113 | 113 | $method = "set_$key"; |
114 | - $invoice->$method( $value ); |
|
114 | + $invoice->$method($value); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | $address_fields = apply_filters( |
129 | 129 | 'getpaid_user_address_fields', |
130 | 130 | array( |
131 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
132 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
133 | - 'address' => __( 'Address', 'invoicing' ), |
|
134 | - 'city' => __( 'City', 'invoicing' ), |
|
135 | - 'country' => __( 'Country', 'invoicing' ), |
|
136 | - 'state' => __( 'State', 'invoicing' ), |
|
137 | - 'zip' => __( 'Zip/Postal Code', 'invoicing' ), |
|
138 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
139 | - 'company' => __( 'Company', 'invoicing' ), |
|
140 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
141 | - 'vat_number' => __( 'VAT Number', 'invoicing' ), |
|
131 | + 'first_name' => __('First Name', 'invoicing'), |
|
132 | + 'last_name' => __('Last Name', 'invoicing'), |
|
133 | + 'address' => __('Address', 'invoicing'), |
|
134 | + 'city' => __('City', 'invoicing'), |
|
135 | + 'country' => __('Country', 'invoicing'), |
|
136 | + 'state' => __('State', 'invoicing'), |
|
137 | + 'zip' => __('Zip/Postal Code', 'invoicing'), |
|
138 | + 'phone' => __('Phone Number', 'invoicing'), |
|
139 | + 'company' => __('Company', 'invoicing'), |
|
140 | + 'company_id' => __('Company ID', 'invoicing'), |
|
141 | + 'vat_number' => __('VAT Number', 'invoicing'), |
|
142 | 142 | ) |
143 | 143 | ); |
144 | 144 | |
145 | - if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) && ! wp_doing_ajax() ) { |
|
146 | - unset( $address_fields['vat_number'] ); |
|
145 | + if (!wpinv_use_taxes() && isset($address_fields['vat_number']) && !wp_doing_ajax()) { |
|
146 | + unset($address_fields['vat_number']); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $address_fields; |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | -function getpaid_is_address_field_whitelisted( $key ) { |
|
158 | - return array_key_exists( $key, getpaid_user_address_fields() ); |
|
157 | +function getpaid_is_address_field_whitelisted($key) { |
|
158 | + return array_key_exists($key, getpaid_user_address_fields()); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -165,30 +165,30 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param WPInv_Invoice $invoice |
167 | 167 | */ |
168 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
168 | +function getpaid_save_invoice_user_address($invoice) { |
|
169 | 169 | |
170 | 170 | // Retrieve the invoice. |
171 | - $invoice = wpinv_get_invoice( $invoice ); |
|
171 | + $invoice = wpinv_get_invoice($invoice); |
|
172 | 172 | |
173 | 173 | // Abort if it does not exist. |
174 | - if ( empty( $invoice ) || $invoice->is_renewal() ) { |
|
174 | + if (empty($invoice) || $invoice->is_renewal()) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
178 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
178 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
179 | 179 | |
180 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
181 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
180 | + if (is_callable(array($invoice, "get_$field"))) { |
|
181 | + $value = call_user_func(array($invoice, "get_$field")); |
|
182 | 182 | |
183 | 183 | // Only save if it is not empty. |
184 | - if ( ! empty( $value ) ) { |
|
185 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
184 | + if (!empty($value)) { |
|
185 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
191 | -add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' ); |
|
191 | +add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Retrieves a saved user address. |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | * @param int $user_id The user id whose address we should get. Defaults to the current user id. |
197 | 197 | * @return array |
198 | 198 | */ |
199 | -function wpinv_get_user_address( $user_id = 0 ) { |
|
199 | +function wpinv_get_user_address($user_id = 0) { |
|
200 | 200 | |
201 | 201 | // Prepare the user id. |
202 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
203 | - $user_info = get_userdata( $user_id ); |
|
202 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
203 | + $user_info = get_userdata($user_id); |
|
204 | 204 | |
205 | 205 | // Abort if non exists. |
206 | - if ( empty( $user_info ) ) { |
|
206 | + if (empty($user_info)) { |
|
207 | 207 | return array(); |
208 | 208 | } |
209 | 209 | |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | 'display_name' => $user_info->display_name, |
215 | 215 | ); |
216 | 216 | |
217 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
218 | - $address[ $field ] = getpaid_get_user_address_field( $user_id, $field ); |
|
217 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
218 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
219 | 219 | } |
220 | 220 | |
221 | - $address = array_filter( $address ); |
|
221 | + $address = array_filter($address); |
|
222 | 222 | |
223 | 223 | $defaults = array( |
224 | 224 | 'first_name' => $user_info->first_name, |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'country' => wpinv_get_default_country(), |
228 | 228 | ); |
229 | 229 | |
230 | - return getpaid_array_merge_if_empty( $address, $defaults ); |
|
230 | + return getpaid_array_merge_if_empty($address, $defaults); |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param string $field The field to use. |
239 | 239 | * @return string|null |
240 | 240 | */ |
241 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
241 | +function getpaid_get_user_address_field($user_id, $field) { |
|
242 | 242 | |
243 | 243 | $prefixes = array( |
244 | 244 | '_wpinv_', |
@@ -246,15 +246,15 @@ discard block |
||
246 | 246 | '', |
247 | 247 | ); |
248 | 248 | |
249 | - foreach ( $prefixes as $prefix ) { |
|
249 | + foreach ($prefixes as $prefix) { |
|
250 | 250 | |
251 | 251 | // Meta table. |
252 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
252 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
253 | 253 | |
254 | 254 | // UWP table. |
255 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
255 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
256 | 256 | |
257 | - if ( ! empty( $value ) ) { |
|
257 | + if (!empty($value)) { |
|
258 | 258 | return $value; |
259 | 259 | } |
260 | 260 | } |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | * @param string $return What to return. |
271 | 271 | * @return array |
272 | 272 | */ |
273 | -function wpinv_get_continents( $return = 'all' ) { |
|
273 | +function wpinv_get_continents($return = 'all') { |
|
274 | 274 | |
275 | - $continents = wpinv_get_data( 'continents' ); |
|
275 | + $continents = wpinv_get_data('continents'); |
|
276 | 276 | |
277 | - switch ( $return ) { |
|
277 | + switch ($return) { |
|
278 | 278 | case 'name': |
279 | - return wp_list_pluck( $continents, 'name' ); |
|
279 | + return wp_list_pluck($continents, 'name'); |
|
280 | 280 | break; |
281 | 281 | case 'countries': |
282 | - return wp_list_pluck( $continents, 'countries' ); |
|
282 | + return wp_list_pluck($continents, 'countries'); |
|
283 | 283 | break; |
284 | 284 | default: |
285 | 285 | return $continents; |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | * @param string $country Country code. If no code is specified, defaults to the default country. |
296 | 296 | * @return string |
297 | 297 | */ |
298 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
298 | +function wpinv_get_continent_code_for_country($country = false) { |
|
299 | 299 | |
300 | - $country = wpinv_sanitize_country( $country ); |
|
300 | + $country = wpinv_sanitize_country($country); |
|
301 | 301 | |
302 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
303 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
302 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
303 | + if (false !== array_search($country, $countries, true)) { |
|
304 | 304 | return $continent_code; |
305 | 305 | } |
306 | 306 | } |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * @param string $country Country code. If no code is specified, defaults to the default country. |
317 | 317 | * @return array |
318 | 318 | */ |
319 | -function wpinv_get_country_calling_code( $country = null ) { |
|
319 | +function wpinv_get_country_calling_code($country = null) { |
|
320 | 320 | |
321 | - $country = wpinv_sanitize_country( $country ); |
|
322 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
323 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
321 | + $country = wpinv_sanitize_country($country); |
|
322 | + $codes = wpinv_get_data('phone-codes'); |
|
323 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
324 | 324 | |
325 | - if ( is_array( $code ) ) { |
|
325 | + if (is_array($code)) { |
|
326 | 326 | return $code[0]; |
327 | 327 | } |
328 | 328 | return $code; |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | * @param bool $first_empty Whether or not the first item in the list should be empty |
336 | 336 | * @return array |
337 | 337 | */ |
338 | -function wpinv_get_country_list( $first_empty = false ) { |
|
339 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
338 | +function wpinv_get_country_list($first_empty = false) { |
|
339 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | * @param bool $first_empty Whether or not the first item in the list should be empty |
347 | 347 | * @return array |
348 | 348 | */ |
349 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
349 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
350 | 350 | |
351 | 351 | // Prepare the country. |
352 | - $country = wpinv_sanitize_country( $country ); |
|
352 | + $country = wpinv_sanitize_country($country); |
|
353 | 353 | |
354 | 354 | // Fetch all states. |
355 | - $all_states = wpinv_get_data( 'states' ); |
|
355 | + $all_states = wpinv_get_data('states'); |
|
356 | 356 | |
357 | 357 | // Fetch the specified country's states. |
358 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array(); |
|
359 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
360 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
358 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
359 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
360 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
361 | 361 | |
362 | - asort( $states ); |
|
362 | + asort($states); |
|
363 | 363 | |
364 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
364 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return array |
372 | 372 | */ |
373 | 373 | function wpinv_get_us_states_list() { |
374 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
374 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * @return array |
382 | 382 | */ |
383 | 383 | function wpinv_get_canada_states_list() { |
384 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
384 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @return array |
392 | 392 | */ |
393 | 393 | function wpinv_get_australia_states_list() { |
394 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
394 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return array |
402 | 402 | */ |
403 | 403 | function wpinv_get_bangladesh_states_list() { |
404 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
404 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @return array |
412 | 412 | */ |
413 | 413 | function wpinv_get_brazil_states_list() { |
414 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
414 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * @return array |
422 | 422 | */ |
423 | 423 | function wpinv_get_bulgaria_states_list() { |
424 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
424 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @return array |
432 | 432 | */ |
433 | 433 | function wpinv_get_hong_kong_states_list() { |
434 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
434 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @return array |
442 | 442 | */ |
443 | 443 | function wpinv_get_hungary_states_list() { |
444 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
444 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * @return array |
452 | 452 | */ |
453 | 453 | function wpinv_get_japan_states_list() { |
454 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
454 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @return array |
462 | 462 | */ |
463 | 463 | function wpinv_get_china_states_list() { |
464 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
464 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @return array |
472 | 472 | */ |
473 | 473 | function wpinv_get_new_zealand_states_list() { |
474 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
474 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | * @return array |
482 | 482 | */ |
483 | 483 | function wpinv_get_peru_states_list() { |
484 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
484 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * @return array |
492 | 492 | */ |
493 | 493 | function wpinv_get_indonesia_states_list() { |
494 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
494 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @return array |
502 | 502 | */ |
503 | 503 | function wpinv_get_india_states_list() { |
504 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
504 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @return array |
512 | 512 | */ |
513 | 513 | function wpinv_get_iran_states_list() { |
514 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
514 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @return array |
522 | 522 | */ |
523 | 523 | function wpinv_get_italy_states_list() { |
524 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
524 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | * @return array |
532 | 532 | */ |
533 | 533 | function wpinv_get_malaysia_states_list() { |
534 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
534 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * @return array |
542 | 542 | */ |
543 | 543 | function wpinv_get_mexico_states_list() { |
544 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
544 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | * @return array |
552 | 552 | */ |
553 | 553 | function wpinv_get_nepal_states_list() { |
554 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
554 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @return array |
562 | 562 | */ |
563 | 563 | function wpinv_get_south_africa_states_list() { |
564 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
564 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * @return array |
572 | 572 | */ |
573 | 573 | function wpinv_get_thailand_states_list() { |
574 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
574 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return array |
582 | 582 | */ |
583 | 583 | function wpinv_get_turkey_states_list() { |
584 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
584 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -591,31 +591,31 @@ discard block |
||
591 | 591 | * @return array |
592 | 592 | */ |
593 | 593 | function wpinv_get_spain_states_list() { |
594 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
594 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | function wpinv_get_states_field() { |
598 | - if ( empty( $_POST['country'] ) ) { |
|
598 | + if (empty($_POST['country'])) { |
|
599 | 599 | $_POST['country'] = wpinv_get_default_country(); |
600 | 600 | } |
601 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
601 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
602 | 602 | |
603 | - if ( ! empty( $states ) ) { |
|
604 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
603 | + if (!empty($states)) { |
|
604 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
605 | 605 | |
606 | - $class = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : ''; |
|
606 | + $class = isset($_POST['class']) ? esc_attr(sanitize_text_field($_POST['class'])) : ''; |
|
607 | 607 | $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2"; |
608 | 608 | |
609 | - $args = array( |
|
609 | + $args = array( |
|
610 | 610 | 'name' => $sanitized_field_name, |
611 | 611 | 'id' => $sanitized_field_name, |
612 | - 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
613 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
612 | + 'class' => implode(' ', array_unique(explode(' ', $class))), |
|
613 | + 'options' => array_merge(array('' => ''), $states), |
|
614 | 614 | 'show_option_all' => false, |
615 | 615 | 'show_option_none' => false, |
616 | 616 | ); |
617 | 617 | |
618 | - wpinv_html_select( $args ); |
|
618 | + wpinv_html_select($args); |
|
619 | 619 | |
620 | 620 | } else { |
621 | 621 | echo 'nostates'; |
@@ -623,10 +623,10 @@ discard block |
||
623 | 623 | |
624 | 624 | } |
625 | 625 | |
626 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
627 | - $country = ! empty( $country ) ? $country : wpinv_get_default_country(); |
|
626 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
627 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
628 | 628 | |
629 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
629 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
@@ -688,9 +688,9 @@ discard block |
||
688 | 688 | * @see `wpinv_get_invoice_address_replacements` |
689 | 689 | * @return string |
690 | 690 | */ |
691 | -function wpinv_get_full_address_format( $country = false ) { |
|
691 | +function wpinv_get_full_address_format($country = false) { |
|
692 | 692 | |
693 | - if ( empty( $country ) ) { |
|
693 | + if (empty($country)) { |
|
694 | 694 | $country = wpinv_get_default_country(); |
695 | 695 | } |
696 | 696 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | $formats = wpinv_get_address_formats(); |
699 | 699 | |
700 | 700 | // Get format for the specified country. |
701 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
701 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
702 | 702 | |
703 | 703 | /** |
704 | 704 | * Filters the address format to use on Invoices. |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | * @param string $format The address format to use. |
711 | 711 | * @param string $country The country who's address format is being retrieved. |
712 | 712 | */ |
713 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
713 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | * @param array $billing_details customer's billing details |
722 | 722 | * @return array |
723 | 723 | */ |
724 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
724 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
725 | 725 | |
726 | 726 | $default_args = array( |
727 | 727 | 'address' => '', |
@@ -734,15 +734,15 @@ discard block |
||
734 | 734 | 'company' => '', |
735 | 735 | ); |
736 | 736 | |
737 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
737 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
738 | 738 | $state = $args['state']; |
739 | 739 | $country = $args['country']; |
740 | 740 | |
741 | 741 | // Handle full country name. |
742 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
742 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
743 | 743 | |
744 | 744 | // Handle full state name. |
745 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
745 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
746 | 746 | |
747 | 747 | $args['postcode'] = $args['zip']; |
748 | 748 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
@@ -760,14 +760,14 @@ discard block |
||
760 | 760 | * @param array $replacements The address replacements to use. |
761 | 761 | * @param array $billing_details The billing details to use. |
762 | 762 | */ |
763 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
763 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
764 | 764 | |
765 | 765 | $return = array(); |
766 | 766 | |
767 | - foreach ( $replacements as $key => $value ) { |
|
768 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
769 | - $return[ '{{' . $key . '}}' ] = $value; |
|
770 | - $return[ '{{' . $key . '_upper}}' ] = wpinv_utf8_strtoupper( $value ); |
|
767 | + foreach ($replacements as $key => $value) { |
|
768 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
769 | + $return['{{' . $key . '}}'] = $value; |
|
770 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | return $return; |
@@ -781,6 +781,6 @@ discard block |
||
781 | 781 | * @since 1.0.14 |
782 | 782 | * @return string |
783 | 783 | */ |
784 | -function wpinv_trim_formatted_address_line( $line ) { |
|
785 | - return trim( $line, ', ' ); |
|
784 | +function wpinv_trim_formatted_address_line($line) { |
|
785 | + return trim($line, ', '); |
|
786 | 786 | } |