@@ -64,8 +64,8 @@ |
||
64 | 64 | $description = wpinv_get_gateway_description( $gateway ); |
65 | 65 | |
66 | 66 | if ( wpinv_is_test_mode( $gateway ) ) { |
67 | - $sandbox_notice = apply_filters( "getpaid_{$gateway}_sandbox_notice", __( 'SANDBOX ENABLED: No real payments will occur.', 'invoicing' ) ); |
|
68 | - $description = "$description $sandbox_notice"; |
|
67 | + $sandbox_notice = apply_filters( "getpaid_{$gateway}_sandbox_notice", __( 'SANDBOX ENABLED: No real payments will occur.', 'invoicing' ) ); |
|
68 | + $description = "$description $sandbox_notice"; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | echo wp_kses_post( wpautop( $description ) ); |
@@ -11,26 +11,26 @@ discard block |
||
11 | 11 | |
12 | 12 | // Totals rows. |
13 | 13 | $totals = apply_filters( |
14 | - 'getpaid_payment_form_cart_table_totals', |
|
15 | - array( |
|
16 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
17 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
18 | - 'fees' => __( 'Fee', 'invoicing' ), |
|
19 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
20 | - 'total' => __( 'Total', 'invoicing' ), |
|
21 | - ), |
|
22 | - $form |
|
14 | + 'getpaid_payment_form_cart_table_totals', |
|
15 | + array( |
|
16 | + 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
17 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
18 | + 'fees' => __( 'Fee', 'invoicing' ), |
|
19 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
20 | + 'total' => __( 'Total', 'invoicing' ), |
|
21 | + ), |
|
22 | + $form |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $currency = $form->get_currency(); |
26 | 26 | $country = wpinv_get_default_country(); |
27 | 27 | |
28 | 28 | if ( ! empty( $form->invoice ) ) { |
29 | - $country = $form->invoice->get_country(); |
|
29 | + $country = $form->invoice->get_country(); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) { |
33 | - unset( $totals['tax'] ); |
|
33 | + unset( $totals['tax'] ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | do_action( 'getpaid_before_payment_form_cart_totals', $form, $totals ); |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | |
62 | 62 | <?php |
63 | 63 | |
64 | - // Total tax. |
|
65 | - if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ) ) ) { |
|
66 | - wpinv_the_price( 0, $currency ); |
|
67 | - } |
|
64 | + // Total tax. |
|
65 | + if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ) ) ) { |
|
66 | + wpinv_the_price( 0, $currency ); |
|
67 | + } |
|
68 | 68 | |
69 | - do_action( "getpaid_payment_form_cart_totals_$key", $form ); |
|
70 | - ?> |
|
69 | + do_action( "getpaid_payment_form_cart_totals_$key", $form ); |
|
70 | + ?> |
|
71 | 71 | |
72 | 72 | </div> |
73 | 73 |
@@ -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. |
@@ -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 | } |
@@ -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 | ?> |
@@ -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 | } |
@@ -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 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -175,125 +175,125 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
179 | 179 | |
180 | - // Setup possible parts |
|
181 | - $templates = array(); |
|
182 | - if ( isset( $name ) ) { |
|
183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
180 | + // Setup possible parts |
|
181 | + $templates = array(); |
|
182 | + if ( isset( $name ) ) { |
|
183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
184 | 184 | } |
185 | - $templates[] = $slug . '.php'; |
|
185 | + $templates[] = $slug . '.php'; |
|
186 | 186 | |
187 | - // Allow template parts to be filtered |
|
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + // Allow template parts to be filtered |
|
188 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
189 | 189 | |
190 | - // Return the part that is found |
|
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + // Return the part that is found |
|
191 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
195 | - // No file found yet |
|
196 | - $located = false; |
|
195 | + // No file found yet |
|
196 | + $located = false; |
|
197 | 197 | |
198 | - // Try to find a template file |
|
199 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + // Try to find a template file |
|
199 | + foreach ( (array)$template_names as $template_name ) { |
|
200 | 200 | |
201 | - // Continue if template is empty |
|
202 | - if ( empty( $template_name ) ) { |
|
203 | - continue; |
|
201 | + // Continue if template is empty |
|
202 | + if ( empty( $template_name ) ) { |
|
203 | + continue; |
|
204 | 204 | } |
205 | 205 | |
206 | - // Trim off any slashes from the template name |
|
207 | - $template_name = ltrim( $template_name, '/' ); |
|
206 | + // Trim off any slashes from the template name |
|
207 | + $template_name = ltrim( $template_name, '/' ); |
|
208 | 208 | |
209 | - // try locating this template file by looping through the template paths |
|
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
209 | + // try locating this template file by looping through the template paths |
|
210 | + foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
213 | - $located = $template_path . $template_name; |
|
214 | - break; |
|
215 | - } |
|
216 | - } |
|
212 | + if ( file_exists( $template_path . $template_name ) ) { |
|
213 | + $located = $template_path . $template_name; |
|
214 | + break; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
219 | - break; |
|
220 | - } |
|
221 | - } |
|
218 | + if ( ! empty( $located ) ) { |
|
219 | + break; |
|
220 | + } |
|
221 | + } |
|
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | + load_template( $located, $require_once ); |
|
225 | 225 | } |
226 | 226 | |
227 | - return $located; |
|
227 | + return $located; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | function wpinv_get_theme_template_paths() { |
231 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
231 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
232 | 232 | |
233 | - $file_paths = array( |
|
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
236 | - 100 => wpinv_get_templates_dir(), |
|
237 | - ); |
|
233 | + $file_paths = array( |
|
234 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
236 | + 100 => wpinv_get_templates_dir(), |
|
237 | + ); |
|
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
240 | 240 | |
241 | - // sort the file paths based on priority |
|
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
241 | + // sort the file paths based on priority |
|
242 | + ksort( $file_paths, SORT_NUMERIC ); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map( 'trailingslashit', $file_paths ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | - $pages = array(); |
|
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
249 | + $pages = array(); |
|
250 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
256 | - return; |
|
257 | - } |
|
255 | + if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
256 | + return; |
|
257 | + } |
|
258 | 258 | |
259 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
259 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
260 | 260 | } |
261 | 261 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
262 | 262 | |
263 | 263 | function wpinv_add_body_classes( $class ) { |
264 | - $classes = (array)$class; |
|
264 | + $classes = (array)$class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
267 | - $classes[] = 'wpinv-checkout'; |
|
268 | - $classes[] = 'wpinv-page'; |
|
269 | - } |
|
266 | + if ( wpinv_is_checkout() ) { |
|
267 | + $classes[] = 'wpinv-checkout'; |
|
268 | + $classes[] = 'wpinv-page'; |
|
269 | + } |
|
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
272 | - $classes[] = 'wpinv-success'; |
|
273 | - $classes[] = 'wpinv-page'; |
|
274 | - } |
|
271 | + if ( wpinv_is_success_page() ) { |
|
272 | + $classes[] = 'wpinv-success'; |
|
273 | + $classes[] = 'wpinv-page'; |
|
274 | + } |
|
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
277 | - $classes[] = 'wpinv-failed-transaction'; |
|
278 | - $classes[] = 'wpinv-page'; |
|
279 | - } |
|
276 | + if ( wpinv_is_failed_transaction_page() ) { |
|
277 | + $classes[] = 'wpinv-failed-transaction'; |
|
278 | + $classes[] = 'wpinv-page'; |
|
279 | + } |
|
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
282 | - $classes[] = 'wpinv-history'; |
|
283 | - $classes[] = 'wpinv-page'; |
|
284 | - } |
|
281 | + if ( wpinv_is_invoice_history_page() ) { |
|
282 | + $classes[] = 'wpinv-history'; |
|
283 | + $classes[] = 'wpinv-page'; |
|
284 | + } |
|
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
287 | - $classes[] = 'wpinv-subscription'; |
|
288 | - $classes[] = 'wpinv-page'; |
|
289 | - } |
|
286 | + if ( wpinv_is_subscriptions_history_page() ) { |
|
287 | + $classes[] = 'wpinv-subscription'; |
|
288 | + $classes[] = 'wpinv-page'; |
|
289 | + } |
|
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
292 | - $classes[] = 'wpinv-test-mode'; |
|
293 | - $classes[] = 'wpinv-page'; |
|
294 | - } |
|
291 | + if ( wpinv_is_test_mode() ) { |
|
292 | + $classes[] = 'wpinv-test-mode'; |
|
293 | + $classes[] = 'wpinv-page'; |
|
294 | + } |
|
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique( $classes ); |
|
297 | 297 | } |
298 | 298 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
299 | 299 | |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | |
459 | 459 | wpinv_html_select( |
460 | 460 | array( |
461 | - 'name' => $args['name'], |
|
462 | - 'selected' => $args['selected'], |
|
463 | - 'id' => $args['id'], |
|
464 | - 'class' => $args['class'], |
|
465 | - 'options' => $options, |
|
466 | - 'multiple' => $args['multiple'], |
|
467 | - 'placeholder' => $args['placeholder'], |
|
468 | - 'show_option_all' => $args['show_option_all'], |
|
469 | - 'show_option_none' => $args['show_option_none'], |
|
470 | - 'data' => $args['data'], |
|
461 | + 'name' => $args['name'], |
|
462 | + 'selected' => $args['selected'], |
|
463 | + 'id' => $args['id'], |
|
464 | + 'class' => $args['class'], |
|
465 | + 'options' => $options, |
|
466 | + 'multiple' => $args['multiple'], |
|
467 | + 'placeholder' => $args['placeholder'], |
|
468 | + 'show_option_all' => $args['show_option_all'], |
|
469 | + 'show_option_none' => $args['show_option_none'], |
|
470 | + 'data' => $args['data'], |
|
471 | 471 | ) |
472 | 472 | ); |
473 | 473 | |
@@ -767,21 +767,21 @@ discard block |
||
767 | 767 | |
768 | 768 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
769 | 769 | |
770 | - // Remove unavailable tags. |
|
770 | + // Remove unavailable tags. |
|
771 | 771 | $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
772 | 772 | |
773 | 773 | // Clean up white space. |
774 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
774 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
775 | 775 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
776 | 776 | |
777 | 777 | // Break newlines apart and remove empty lines/trim commas and white space. |
778 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
778 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
779 | 779 | |
780 | 780 | // Add html breaks. |
781 | - $formatted_address = implode( $separator, $formatted_address ); |
|
781 | + $formatted_address = implode( $separator, $formatted_address ); |
|
782 | 782 | |
783 | - // We're done! |
|
784 | - return $formatted_address; |
|
783 | + // We're done! |
|
784 | + return $formatted_address; |
|
785 | 785 | |
786 | 786 | } |
787 | 787 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | function getpaid_display_invoice_subscriptions( $invoice ) { |
828 | 828 | |
829 | 829 | // Subscriptions. |
830 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
830 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
831 | 831 | |
832 | 832 | if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
833 | 833 | return; |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | function wpinv_empty_cart_message() { |
1042 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1042 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | /** |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | if ( 0 == count( $form->get_items() ) ) { |
1239 | 1239 | aui()->alert( |
1240 | - array( |
|
1241 | - 'type' => 'warning', |
|
1242 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1240 | + array( |
|
1241 | + 'type' => 'warning', |
|
1242 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
1243 | 1243 | ), |
1244 | 1244 | true |
1245 | 1245 | ); |
@@ -1262,10 +1262,10 @@ discard block |
||
1262 | 1262 | $invoice = wpinv_get_invoice( $invoice_id ); |
1263 | 1263 | |
1264 | 1264 | if ( empty( $invoice ) ) { |
1265 | - aui()->alert( |
|
1266 | - array( |
|
1267 | - 'type' => 'warning', |
|
1268 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1265 | + aui()->alert( |
|
1266 | + array( |
|
1267 | + 'type' => 'warning', |
|
1268 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1269 | 1269 | ), |
1270 | 1270 | true |
1271 | 1271 | ); |
@@ -1273,10 +1273,10 @@ discard block |
||
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | if ( $invoice->is_paid() ) { |
1276 | - aui()->alert( |
|
1277 | - array( |
|
1278 | - 'type' => 'warning', |
|
1279 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1276 | + aui()->alert( |
|
1277 | + array( |
|
1278 | + 'type' => 'warning', |
|
1279 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1280 | 1280 | ), |
1281 | 1281 | true |
1282 | 1282 | ); |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1341 | 1341 | } |
1342 | 1342 | |
1343 | - if ( ! empty( $items ) ) { |
|
1343 | + if ( ! empty( $items ) ) { |
|
1344 | 1344 | $items = esc_attr( $items ); |
1345 | 1345 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1346 | 1346 | } |
@@ -1526,21 +1526,21 @@ discard block |
||
1526 | 1526 | |
1527 | 1527 | return aui()->select( |
1528 | 1528 | array( |
1529 | - 'options' => $states, |
|
1530 | - 'name' => esc_attr( $field_name ), |
|
1531 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1532 | - 'value' => sanitize_text_field( $state ), |
|
1533 | - 'placeholder' => $placeholder, |
|
1534 | - 'required' => $required, |
|
1535 | - 'label' => wp_kses_post( $label ), |
|
1536 | - 'label_type' => 'vertical', |
|
1537 | - 'help_text' => $help_text, |
|
1538 | - 'class' => 'getpaid-address-field wpinv_state', |
|
1539 | - 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1540 | - 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1541 | - 'extra_attributes' => array( |
|
1542 | - 'autocomplete' => 'address-level1', |
|
1543 | - ), |
|
1529 | + 'options' => $states, |
|
1530 | + 'name' => esc_attr( $field_name ), |
|
1531 | + 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1532 | + 'value' => sanitize_text_field( $state ), |
|
1533 | + 'placeholder' => $placeholder, |
|
1534 | + 'required' => $required, |
|
1535 | + 'label' => wp_kses_post( $label ), |
|
1536 | + 'label_type' => 'vertical', |
|
1537 | + 'help_text' => $help_text, |
|
1538 | + 'class' => 'getpaid-address-field wpinv_state', |
|
1539 | + 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1540 | + 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1541 | + 'extra_attributes' => array( |
|
1542 | + 'autocomplete' => 'address-level1', |
|
1543 | + ), |
|
1544 | 1544 | ), |
1545 | 1545 | $echo |
1546 | 1546 | ); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - aui()->alert( |
|
28 | + aui()->alert( |
|
29 | 29 | array( |
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ), |
|
33 | - true |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ), |
|
33 | + true |
|
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
37 | 37 | |
38 | - // Display a single subscription. |
|
39 | - wpinv_recurring_subscription_details(); |
|
40 | - } else { |
|
38 | + // Display a single subscription. |
|
39 | + wpinv_recurring_subscription_details(); |
|
40 | + } else { |
|
41 | 41 | |
42 | - // Display a list of available subscriptions. |
|
43 | - getpaid_print_subscriptions_list(); |
|
44 | - } |
|
42 | + // Display a list of available subscriptions. |
|
43 | + getpaid_print_subscriptions_list(); |
|
44 | + } |
|
45 | 45 | |
46 | - ?> |
|
46 | + ?> |
|
47 | 47 | |
48 | 48 | </div> |
49 | 49 | </div> |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function getpaid_print_subscriptions_list() { |
62 | 62 | |
63 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | - $subscribers_table->prepare_items(); |
|
63 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | + $subscribers_table->prepare_items(); |
|
65 | 65 | |
66 | - ?> |
|
66 | + ?> |
|
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -82,42 +82,42 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | - // Fetch the subscription. |
|
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
85 | + // Fetch the subscription. |
|
86 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | + if ( ! $sub->exists() ) { |
|
88 | 88 | |
89 | - aui()->alert( |
|
90 | - array( |
|
91 | - 'type' => 'danger', |
|
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | - ), |
|
94 | - true |
|
95 | - ); |
|
89 | + aui()->alert( |
|
90 | + array( |
|
91 | + 'type' => 'danger', |
|
92 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | + ), |
|
94 | + true |
|
95 | + ); |
|
96 | 96 | |
97 | - return; |
|
98 | - } |
|
97 | + return; |
|
98 | + } |
|
99 | 99 | |
100 | - // Use metaboxes to display the subscription details. |
|
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | + // Use metaboxes to display the subscription details. |
|
101 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
103 | 103 | |
104 | - $subscription_id = $sub->get_id(); |
|
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
104 | + $subscription_id = $sub->get_id(); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | - } |
|
108 | + if ( 1 < count( $subscription_groups ) ) { |
|
109 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | + } |
|
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | - } |
|
112 | + if ( ! empty( $subscription_group ) ) { |
|
113 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | + } |
|
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
119 | 119 | |
120 | - ?> |
|
120 | + ?> |
|
121 | 121 | |
122 | 122 | <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
123 | 123 | |
@@ -157,44 +157,44 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function getpaid_admin_subscription_details_metabox( $sub ) { |
159 | 159 | |
160 | - // Subscription items. |
|
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | - |
|
164 | - // Prepare subscription detail columns. |
|
165 | - $fields = apply_filters( |
|
166 | - 'getpaid_subscription_admin_page_fields', |
|
167 | - array( |
|
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
178 | - ) |
|
179 | - ); |
|
180 | - |
|
181 | - if ( ! $sub->is_active() ) { |
|
182 | - |
|
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
185 | - } |
|
186 | - |
|
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
189 | - } |
|
160 | + // Subscription items. |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | + |
|
164 | + // Prepare subscription detail columns. |
|
165 | + $fields = apply_filters( |
|
166 | + 'getpaid_subscription_admin_page_fields', |
|
167 | + array( |
|
168 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | + 'status' => __( 'Status', 'invoicing' ), |
|
178 | + ) |
|
179 | + ); |
|
180 | + |
|
181 | + if ( ! $sub->is_active() ) { |
|
182 | + |
|
183 | + if ( isset( $fields['renews_on'] ) ) { |
|
184 | + unset( $fields['renews_on'] ); |
|
185 | + } |
|
186 | + |
|
187 | + if ( isset( $fields['gateway'] ) ) { |
|
188 | + unset( $fields['gateway'] ); |
|
189 | + } |
|
190 | 190 | } |
191 | 191 | |
192 | - $profile_id = $sub->get_profile_id(); |
|
193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | - unset( $fields['profile_id'] ); |
|
195 | - } |
|
192 | + $profile_id = $sub->get_profile_id(); |
|
193 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | + unset( $fields['profile_id'] ); |
|
195 | + } |
|
196 | 196 | |
197 | - ?> |
|
197 | + ?> |
|
198 | 198 | |
199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
200 | 200 | <tbody> |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | */ |
229 | 229 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
230 | 230 | |
231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
231 | + $username = __( '(Missing User)', 'invoicing' ); |
|
232 | 232 | |
233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | - if ( $user ) { |
|
233 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | + if ( $user ) { |
|
235 | 235 | |
236 | - $username = sprintf( |
|
237 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | - absint( $user->ID ), |
|
239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | - ); |
|
236 | + $username = sprintf( |
|
237 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | + absint( $user->ID ), |
|
239 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | + ); |
|
241 | 241 | |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - echo wp_kses_post( $username ); |
|
244 | + echo wp_kses_post( $username ); |
|
245 | 245 | } |
246 | 246 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
247 | 247 | |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @param WPInv_Subscription $subscription |
252 | 252 | */ |
253 | 253 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
254 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
256 | 256 | } |
257 | 257 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
258 | 258 | |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
265 | 265 | |
266 | - printf( |
|
267 | - '<a href="%s">#%s</a>', |
|
268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | - absint( $subscription->get_id() ) |
|
270 | - ); |
|
266 | + printf( |
|
267 | + '<a href="%s">#%s</a>', |
|
268 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | + absint( $subscription->get_id() ) |
|
270 | + ); |
|
271 | 271 | |
272 | 272 | } |
273 | 273 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | 280 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
281 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
281 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
282 | 282 | } |
283 | 283 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
284 | 284 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | 290 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
291 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
291 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
292 | 292 | } |
293 | 293 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
294 | 294 | |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | 300 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
301 | - $max_bills = $subscription->get_bill_times(); |
|
302 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
301 | + $max_bills = $subscription->get_bill_times(); |
|
302 | + echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
303 | 303 | } |
304 | 304 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
305 | 305 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
312 | 312 | |
313 | - if ( empty( $subscription_group ) ) { |
|
314 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
315 | - return; |
|
316 | - } |
|
313 | + if ( empty( $subscription_group ) ) { |
|
314 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
315 | + return; |
|
316 | + } |
|
317 | 317 | |
318 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
330 | 330 | |
331 | - $gateway = $subscription->get_gateway(); |
|
331 | + $gateway = $subscription->get_gateway(); |
|
332 | 332 | |
333 | - if ( ! empty( $gateway ) ) { |
|
334 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | - } else { |
|
336 | - echo '—'; |
|
337 | - } |
|
333 | + if ( ! empty( $gateway ) ) { |
|
334 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | + } else { |
|
336 | + echo '—'; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param WPInv_Subscription $subscription |
346 | 346 | */ |
347 | 347 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
348 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
348 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
349 | 349 | } |
350 | 350 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
351 | 351 | |
@@ -356,27 +356,27 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
358 | 358 | |
359 | - $profile_id = $subscription->get_profile_id(); |
|
360 | - |
|
361 | - aui()->input( |
|
362 | - array( |
|
363 | - 'type' => 'text', |
|
364 | - 'id' => 'wpinv_subscription_profile_id', |
|
365 | - 'name' => 'wpinv_subscription_profile_id', |
|
366 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'label_type' => 'hidden', |
|
368 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | - 'value' => esc_attr( $profile_id ), |
|
370 | - 'input_group_right' => '', |
|
371 | - 'no_wrap' => true, |
|
372 | - ), |
|
373 | - true |
|
374 | - ); |
|
375 | - |
|
376 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | - if ( ! empty( $url ) ) { |
|
378 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | - } |
|
359 | + $profile_id = $subscription->get_profile_id(); |
|
360 | + |
|
361 | + aui()->input( |
|
362 | + array( |
|
363 | + 'type' => 'text', |
|
364 | + 'id' => 'wpinv_subscription_profile_id', |
|
365 | + 'name' => 'wpinv_subscription_profile_id', |
|
366 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | + 'label_type' => 'hidden', |
|
368 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | + 'value' => esc_attr( $profile_id ), |
|
370 | + 'input_group_right' => '', |
|
371 | + 'no_wrap' => true, |
|
372 | + ), |
|
373 | + true |
|
374 | + ); |
|
375 | + |
|
376 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | + if ( ! empty( $url ) ) { |
|
378 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } |
382 | 382 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -388,40 +388,40 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
390 | 390 | |
391 | - ?> |
|
391 | + ?> |
|
392 | 392 | <div class="mt-3"> |
393 | 393 | |
394 | 394 | <?php |
395 | - aui()->select( |
|
396 | - array( |
|
397 | - 'options' => getpaid_get_subscription_statuses(), |
|
398 | - 'name' => 'subscription_status', |
|
399 | - 'id' => 'subscription_status_update_select', |
|
400 | - 'required' => true, |
|
401 | - 'no_wrap' => false, |
|
402 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | - 'select2' => true, |
|
405 | - 'value' => $subscription->get_status( 'edit' ), |
|
406 | - ), |
|
407 | - true |
|
408 | - ); |
|
409 | - ?> |
|
395 | + aui()->select( |
|
396 | + array( |
|
397 | + 'options' => getpaid_get_subscription_statuses(), |
|
398 | + 'name' => 'subscription_status', |
|
399 | + 'id' => 'subscription_status_update_select', |
|
400 | + 'required' => true, |
|
401 | + 'no_wrap' => false, |
|
402 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | + 'select2' => true, |
|
405 | + 'value' => $subscription->get_status( 'edit' ), |
|
406 | + ), |
|
407 | + true |
|
408 | + ); |
|
409 | + ?> |
|
410 | 410 | |
411 | 411 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
412 | 412 | |
413 | 413 | <?php |
414 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
414 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
415 | 415 | |
416 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
416 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
419 | 419 | |
420 | - if ( $subscription->is_active() ) { |
|
421 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
422 | - } |
|
420 | + if ( $subscription->is_active() ) { |
|
421 | + echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
422 | + } |
|
423 | 423 | |
424 | - echo '</div></div>'; |
|
424 | + echo '</div></div>'; |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -432,33 +432,33 @@ discard block |
||
432 | 432 | */ |
433 | 433 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
434 | 434 | |
435 | - $columns = apply_filters( |
|
436 | - 'getpaid_subscription_related_invoices_columns', |
|
437 | - array( |
|
438 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | - 'date' => __( 'Date', 'invoicing' ), |
|
441 | - 'status' => __( 'Status', 'invoicing' ), |
|
442 | - 'total' => __( 'Total', 'invoicing' ), |
|
443 | - ), |
|
444 | - $subscription |
|
445 | - ); |
|
446 | - |
|
447 | - // Prepare the invoices. |
|
448 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
449 | - $parent = $subscription->get_parent_invoice(); |
|
450 | - |
|
451 | - if ( $parent->exists() ) { |
|
452 | - $payments = array_merge( array( $parent ), $payments ); |
|
453 | - } |
|
454 | - |
|
455 | - $table_class = 'w-100 bg-white'; |
|
456 | - |
|
457 | - if ( ! is_admin() ) { |
|
458 | - $table_class = 'table table-bordered'; |
|
459 | - } |
|
460 | - |
|
461 | - ?> |
|
435 | + $columns = apply_filters( |
|
436 | + 'getpaid_subscription_related_invoices_columns', |
|
437 | + array( |
|
438 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | + 'date' => __( 'Date', 'invoicing' ), |
|
441 | + 'status' => __( 'Status', 'invoicing' ), |
|
442 | + 'total' => __( 'Total', 'invoicing' ), |
|
443 | + ), |
|
444 | + $subscription |
|
445 | + ); |
|
446 | + |
|
447 | + // Prepare the invoices. |
|
448 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
449 | + $parent = $subscription->get_parent_invoice(); |
|
450 | + |
|
451 | + if ( $parent->exists() ) { |
|
452 | + $payments = array_merge( array( $parent ), $payments ); |
|
453 | + } |
|
454 | + |
|
455 | + $table_class = 'w-100 bg-white'; |
|
456 | + |
|
457 | + if ( ! is_admin() ) { |
|
458 | + $table_class = 'table table-bordered'; |
|
459 | + } |
|
460 | + |
|
461 | + ?> |
|
462 | 462 | <div class="m-0" style="overflow: auto;"> |
463 | 463 | |
464 | 464 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | <thead> |
467 | 467 | <tr> |
468 | 468 | <?php |
469 | - foreach ( $columns as $key => $label ) { |
|
470 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
471 | - } |
|
472 | - ?> |
|
469 | + foreach ( $columns as $key => $label ) { |
|
470 | + echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
471 | + } |
|
472 | + ?> |
|
473 | 473 | </tr> |
474 | 474 | </thead> |
475 | 475 | |
@@ -485,72 +485,72 @@ discard block |
||
485 | 485 | |
486 | 486 | <?php |
487 | 487 | |
488 | - foreach ( $payments as $payment ) : |
|
488 | + foreach ( $payments as $payment ) : |
|
489 | 489 | |
490 | - // Ensure that we have an invoice. |
|
491 | - $payment = new WPInv_Invoice( $payment ); |
|
490 | + // Ensure that we have an invoice. |
|
491 | + $payment = new WPInv_Invoice( $payment ); |
|
492 | 492 | |
493 | - // Abort if the invoice is invalid... |
|
494 | - if ( ! $payment->exists() ) { |
|
495 | - continue; |
|
496 | - } |
|
493 | + // Abort if the invoice is invalid... |
|
494 | + if ( ! $payment->exists() ) { |
|
495 | + continue; |
|
496 | + } |
|
497 | 497 | |
498 | - // ... or belongs to a different subscription. |
|
499 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
500 | - continue; |
|
501 | - } |
|
498 | + // ... or belongs to a different subscription. |
|
499 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
500 | + continue; |
|
501 | + } |
|
502 | 502 | |
503 | - echo '<tr>'; |
|
503 | + echo '<tr>'; |
|
504 | 504 | |
505 | - foreach ( array_keys( $columns ) as $key ) { |
|
505 | + foreach ( array_keys( $columns ) as $key ) { |
|
506 | 506 | |
507 | - echo "<td class='p-2 text-left'>"; |
|
507 | + echo "<td class='p-2 text-left'>"; |
|
508 | 508 | |
509 | - switch ( $key ) { |
|
509 | + switch ( $key ) { |
|
510 | 510 | |
511 | - case 'total': |
|
512 | - echo '<strong>'; |
|
513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | - echo '</strong>'; |
|
515 | - break; |
|
511 | + case 'total': |
|
512 | + echo '<strong>'; |
|
513 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | + echo '</strong>'; |
|
515 | + break; |
|
516 | 516 | |
517 | - case 'relationship': |
|
518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | - break; |
|
517 | + case 'relationship': |
|
518 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | + break; |
|
520 | 520 | |
521 | - case 'date': |
|
522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | - break; |
|
521 | + case 'date': |
|
522 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | + break; |
|
524 | 524 | |
525 | - case 'status': |
|
526 | - $status = $payment->get_status_nicename(); |
|
527 | - if ( is_admin() ) { |
|
528 | - $status = $payment->get_status_label_html(); |
|
529 | - } |
|
525 | + case 'status': |
|
526 | + $status = $payment->get_status_nicename(); |
|
527 | + if ( is_admin() ) { |
|
528 | + $status = $payment->get_status_label_html(); |
|
529 | + } |
|
530 | 530 | |
531 | - echo wp_kses_post( $status ); |
|
532 | - break; |
|
531 | + echo wp_kses_post( $status ); |
|
532 | + break; |
|
533 | 533 | |
534 | - case 'invoice': |
|
535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
534 | + case 'invoice': |
|
535 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | 536 | |
537 | - if ( ! is_admin() ) { |
|
538 | - $link = esc_url( $payment->get_view_url() ); |
|
539 | - } |
|
537 | + if ( ! is_admin() ) { |
|
538 | + $link = esc_url( $payment->get_view_url() ); |
|
539 | + } |
|
540 | 540 | |
541 | - $invoice = esc_html( $payment->get_number() ); |
|
542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | - break; |
|
544 | - } |
|
541 | + $invoice = esc_html( $payment->get_number() ); |
|
542 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | + break; |
|
544 | + } |
|
545 | 545 | |
546 | - echo '</td>'; |
|
546 | + echo '</td>'; |
|
547 | 547 | |
548 | - } |
|
548 | + } |
|
549 | 549 | |
550 | - echo '</tr>'; |
|
550 | + echo '</tr>'; |
|
551 | 551 | |
552 | - endforeach; |
|
553 | - ?> |
|
552 | + endforeach; |
|
553 | + ?> |
|
554 | 554 | |
555 | 555 | </tbody> |
556 | 556 | |
@@ -568,42 +568,42 @@ discard block |
||
568 | 568 | */ |
569 | 569 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
570 | 570 | |
571 | - // Fetch the subscription group. |
|
572 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
571 | + // Fetch the subscription group. |
|
572 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
573 | 573 | |
574 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
575 | - return; |
|
576 | - } |
|
574 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
575 | + return; |
|
576 | + } |
|
577 | 577 | |
578 | - // Prepare table columns. |
|
579 | - $columns = apply_filters( |
|
580 | - 'getpaid_subscription_item_details_columns', |
|
581 | - array( |
|
582 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | - 'price' => __( 'Price', 'invoicing' ), |
|
584 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
586 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
587 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
588 | - ), |
|
589 | - $subscription |
|
590 | - ); |
|
578 | + // Prepare table columns. |
|
579 | + $columns = apply_filters( |
|
580 | + 'getpaid_subscription_item_details_columns', |
|
581 | + array( |
|
582 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | + 'price' => __( 'Price', 'invoicing' ), |
|
584 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
586 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
587 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
588 | + ), |
|
589 | + $subscription |
|
590 | + ); |
|
591 | 591 | |
592 | - // Prepare the invoices. |
|
592 | + // Prepare the invoices. |
|
593 | 593 | |
594 | - $invoice = $subscription->get_parent_invoice(); |
|
594 | + $invoice = $subscription->get_parent_invoice(); |
|
595 | 595 | |
596 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | - unset( $columns['tax'] ); |
|
598 | - } |
|
596 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | + unset( $columns['tax'] ); |
|
598 | + } |
|
599 | 599 | |
600 | - $table_class = 'w-100 bg-white'; |
|
600 | + $table_class = 'w-100 bg-white'; |
|
601 | 601 | |
602 | - if ( ! is_admin() ) { |
|
603 | - $table_class = 'table table-bordered'; |
|
604 | - } |
|
602 | + if ( ! is_admin() ) { |
|
603 | + $table_class = 'table table-bordered'; |
|
604 | + } |
|
605 | 605 | |
606 | - ?> |
|
606 | + ?> |
|
607 | 607 | <div class="m-0" style="overflow: auto;"> |
608 | 608 | |
609 | 609 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | <tr> |
613 | 613 | <?php |
614 | 614 | |
615 | - foreach ( $columns as $key => $label ) { |
|
616 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
617 | - } |
|
618 | - ?> |
|
615 | + foreach ( $columns as $key => $label ) { |
|
616 | + echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
617 | + } |
|
618 | + ?> |
|
619 | 619 | </tr> |
620 | 620 | </thead> |
621 | 621 | |
@@ -623,106 +623,106 @@ discard block |
||
623 | 623 | |
624 | 624 | <?php |
625 | 625 | |
626 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
626 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
627 | 627 | |
628 | - echo '<tr>'; |
|
628 | + echo '<tr>'; |
|
629 | 629 | |
630 | - foreach ( array_keys( $columns ) as $key ) { |
|
630 | + foreach ( array_keys( $columns ) as $key ) { |
|
631 | 631 | |
632 | - $class = 'text-left'; |
|
632 | + $class = 'text-left'; |
|
633 | 633 | |
634 | - echo "<td class='p-2 text-left'>"; |
|
634 | + echo "<td class='p-2 text-left'>"; |
|
635 | 635 | |
636 | - switch ( $key ) { |
|
636 | + switch ( $key ) { |
|
637 | 637 | |
638 | - case 'item_name': |
|
639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
638 | + case 'item_name': |
|
639 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | 641 | |
642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | - echo esc_html( $item_name ); |
|
644 | - } else { |
|
645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | - } |
|
642 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | + echo esc_html( $item_name ); |
|
644 | + } else { |
|
645 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | + } |
|
647 | 647 | |
648 | - break; |
|
648 | + break; |
|
649 | 649 | |
650 | - case 'price': |
|
651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | - break; |
|
650 | + case 'price': |
|
651 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | + break; |
|
653 | 653 | |
654 | - case 'tax': |
|
655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | - break; |
|
654 | + case 'tax': |
|
655 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | + break; |
|
657 | 657 | |
658 | - case 'discount': |
|
659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | - break; |
|
658 | + case 'discount': |
|
659 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | + break; |
|
661 | 661 | |
662 | - case 'initial': |
|
663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | - break; |
|
662 | + case 'initial': |
|
663 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | + break; |
|
665 | 665 | |
666 | - case 'recurring': |
|
667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | - break; |
|
666 | + case 'recurring': |
|
667 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | + break; |
|
669 | 669 | |
670 | - } |
|
670 | + } |
|
671 | 671 | |
672 | - echo '</td>'; |
|
672 | + echo '</td>'; |
|
673 | 673 | |
674 | - } |
|
674 | + } |
|
675 | 675 | |
676 | - echo '</tr>'; |
|
676 | + echo '</tr>'; |
|
677 | 677 | |
678 | - endforeach; |
|
678 | + endforeach; |
|
679 | 679 | |
680 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
680 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
681 | 681 | |
682 | - echo '<tr>'; |
|
682 | + echo '<tr>'; |
|
683 | 683 | |
684 | - foreach ( array_keys( $columns ) as $key ) { |
|
684 | + foreach ( array_keys( $columns ) as $key ) { |
|
685 | 685 | |
686 | - $class = 'text-left'; |
|
686 | + $class = 'text-left'; |
|
687 | 687 | |
688 | - echo "<td class='p-2 text-left'>"; |
|
688 | + echo "<td class='p-2 text-left'>"; |
|
689 | 689 | |
690 | - switch ( $key ) { |
|
690 | + switch ( $key ) { |
|
691 | 691 | |
692 | - case 'item_name': |
|
693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
694 | - break; |
|
692 | + case 'item_name': |
|
693 | + echo esc_html( $subscription_group_fee['name'] ); |
|
694 | + break; |
|
695 | 695 | |
696 | - case 'price': |
|
697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | - break; |
|
696 | + case 'price': |
|
697 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | + break; |
|
699 | 699 | |
700 | - case 'tax': |
|
701 | - echo '—'; |
|
702 | - break; |
|
700 | + case 'tax': |
|
701 | + echo '—'; |
|
702 | + break; |
|
703 | 703 | |
704 | - case 'discount': |
|
705 | - echo '—'; |
|
706 | - break; |
|
704 | + case 'discount': |
|
705 | + echo '—'; |
|
706 | + break; |
|
707 | 707 | |
708 | - case 'initial': |
|
709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | - break; |
|
708 | + case 'initial': |
|
709 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | + break; |
|
711 | 711 | |
712 | - case 'recurring': |
|
713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | - break; |
|
712 | + case 'recurring': |
|
713 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | + break; |
|
715 | 715 | |
716 | - } |
|
716 | + } |
|
717 | 717 | |
718 | - echo '</td>'; |
|
718 | + echo '</td>'; |
|
719 | 719 | |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | - echo '</tr>'; |
|
722 | + echo '</tr>'; |
|
723 | 723 | |
724 | - endforeach; |
|
725 | - ?> |
|
724 | + endforeach; |
|
725 | + ?> |
|
726 | 726 | |
727 | 727 | </tbody> |
728 | 728 | |
@@ -741,38 +741,38 @@ discard block |
||
741 | 741 | */ |
742 | 742 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
743 | 743 | |
744 | - // Fetch the subscription groups. |
|
745 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
746 | - |
|
747 | - if ( empty( $subscription_groups ) ) { |
|
748 | - return; |
|
749 | - } |
|
750 | - |
|
751 | - // Prepare table columns. |
|
752 | - $columns = apply_filters( |
|
753 | - 'getpaid_subscription_related_subscriptions_columns', |
|
754 | - array( |
|
755 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | - 'item' => __( 'Items', 'invoicing' ), |
|
760 | - 'status' => __( 'Status', 'invoicing' ), |
|
761 | - ), |
|
762 | - $subscription |
|
763 | - ); |
|
764 | - |
|
765 | - if ( $subscription->get_status() == 'pending' ) { |
|
766 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | - } |
|
768 | - |
|
769 | - $table_class = 'w-100 bg-white'; |
|
770 | - |
|
771 | - if ( ! is_admin() ) { |
|
772 | - $table_class = 'table table-bordered'; |
|
773 | - } |
|
774 | - |
|
775 | - ?> |
|
744 | + // Fetch the subscription groups. |
|
745 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
746 | + |
|
747 | + if ( empty( $subscription_groups ) ) { |
|
748 | + return; |
|
749 | + } |
|
750 | + |
|
751 | + // Prepare table columns. |
|
752 | + $columns = apply_filters( |
|
753 | + 'getpaid_subscription_related_subscriptions_columns', |
|
754 | + array( |
|
755 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | + 'item' => __( 'Items', 'invoicing' ), |
|
760 | + 'status' => __( 'Status', 'invoicing' ), |
|
761 | + ), |
|
762 | + $subscription |
|
763 | + ); |
|
764 | + |
|
765 | + if ( $subscription->get_status() == 'pending' ) { |
|
766 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | + } |
|
768 | + |
|
769 | + $table_class = 'w-100 bg-white'; |
|
770 | + |
|
771 | + if ( ! is_admin() ) { |
|
772 | + $table_class = 'table table-bordered'; |
|
773 | + } |
|
774 | + |
|
775 | + ?> |
|
776 | 776 | <div class="m-0" style="overflow: auto;"> |
777 | 777 | |
778 | 778 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | <tr> |
782 | 782 | <?php |
783 | 783 | |
784 | - foreach ( $columns as $key => $label ) { |
|
785 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
786 | - } |
|
787 | - ?> |
|
784 | + foreach ( $columns as $key => $label ) { |
|
785 | + echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
786 | + } |
|
787 | + ?> |
|
788 | 788 | </tr> |
789 | 789 | </thead> |
790 | 790 | |
@@ -792,74 +792,74 @@ discard block |
||
792 | 792 | |
793 | 793 | <?php |
794 | 794 | |
795 | - foreach ( $subscription_groups as $subscription_group ) : |
|
795 | + foreach ( $subscription_groups as $subscription_group ) : |
|
796 | 796 | |
797 | - // Do not list current subscription. |
|
798 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
799 | - continue; |
|
800 | - } |
|
797 | + // Do not list current subscription. |
|
798 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
799 | + continue; |
|
800 | + } |
|
801 | 801 | |
802 | - // Ensure the subscription exists. |
|
803 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
802 | + // Ensure the subscription exists. |
|
803 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
804 | 804 | |
805 | - if ( ! $_suscription->exists() ) { |
|
806 | - continue; |
|
807 | - } |
|
805 | + if ( ! $_suscription->exists() ) { |
|
806 | + continue; |
|
807 | + } |
|
808 | 808 | |
809 | - echo '<tr>'; |
|
809 | + echo '<tr>'; |
|
810 | 810 | |
811 | - foreach ( array_keys( $columns ) as $key ) { |
|
811 | + foreach ( array_keys( $columns ) as $key ) { |
|
812 | 812 | |
813 | - $class = 'text-left'; |
|
813 | + $class = 'text-left'; |
|
814 | 814 | |
815 | - echo "<td class='p-2 text-left'>"; |
|
815 | + echo "<td class='p-2 text-left'>"; |
|
816 | 816 | |
817 | - switch ( $key ) { |
|
817 | + switch ( $key ) { |
|
818 | 818 | |
819 | - case 'status': |
|
820 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
821 | - break; |
|
819 | + case 'status': |
|
820 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
821 | + break; |
|
822 | 822 | |
823 | - case 'item': |
|
824 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
825 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
826 | - break; |
|
823 | + case 'item': |
|
824 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
825 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
826 | + break; |
|
827 | 827 | |
828 | - case 'renewals': |
|
829 | - $max_bills = $_suscription->get_bill_times(); |
|
830 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
831 | - break; |
|
828 | + case 'renewals': |
|
829 | + $max_bills = $_suscription->get_bill_times(); |
|
830 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
831 | + break; |
|
832 | 832 | |
833 | - case 'renewal_date': |
|
834 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
835 | - break; |
|
833 | + case 'renewal_date': |
|
834 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
835 | + break; |
|
836 | 836 | |
837 | - case 'start_date': |
|
838 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
839 | - break; |
|
837 | + case 'start_date': |
|
838 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
839 | + break; |
|
840 | 840 | |
841 | - case 'subscription': |
|
842 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
843 | - printf( |
|
841 | + case 'subscription': |
|
842 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
843 | + printf( |
|
844 | 844 | '%1$s#%2$s%3$s', |
845 | 845 | '<a href="' . esc_url( $url ) . '">', |
846 | 846 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
847 | - '</a>' |
|
847 | + '</a>' |
|
848 | 848 | ); |
849 | 849 | |
850 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
851 | - break; |
|
850 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
851 | + break; |
|
852 | 852 | |
853 | - } |
|
853 | + } |
|
854 | 854 | |
855 | - echo '</td>'; |
|
855 | + echo '</td>'; |
|
856 | 856 | |
857 | - } |
|
857 | + } |
|
858 | 858 | |
859 | - echo '</tr>'; |
|
859 | + echo '</tr>'; |
|
860 | 860 | |
861 | - endforeach; |
|
862 | - ?> |
|
861 | + endforeach; |
|
862 | + ?> |
|
863 | 863 | |
864 | 864 | </tbody> |
865 | 865 |