@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -add_action( 'wpinv_manual_cc_form', '__return_false' ); |
|
5 | +add_action('wpinv_manual_cc_form', '__return_false'); |
|
6 | 6 | |
7 | -function wpinv_process_manual_payment( $purchase_data ) { |
|
8 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
9 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
7 | +function wpinv_process_manual_payment($purchase_data) { |
|
8 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
9 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /* |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | ); |
42 | 42 | |
43 | 43 | // Record the pending payment |
44 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
44 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
45 | 45 | |
46 | - if ( !empty( $invoice ) ) { |
|
47 | - wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() ); |
|
48 | - wpinv_update_payment_status( $invoice, 'publish' ); |
|
46 | + if (!empty($invoice)) { |
|
47 | + wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key()); |
|
48 | + wpinv_update_payment_status($invoice, 'publish'); |
|
49 | 49 | |
50 | 50 | // Empty the shopping cart |
51 | 51 | wpinv_empty_cart(); |
52 | 52 | |
53 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
53 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
54 | 54 | } else { |
55 | - wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice ); |
|
55 | + wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice); |
|
56 | 56 | // If errors are present, send the user back to the purchase page so they can be corrected |
57 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
57 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
58 | 58 | } |
59 | 59 | } |
60 | -add_action( 'wpinv_gateway_manual', 'wpinv_process_manual_payment' ); |
|
61 | 60 | \ No newline at end of file |
61 | +add_action('wpinv_gateway_manual', 'wpinv_process_manual_payment'); |
|
62 | 62 | \ No newline at end of file |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -add_action( 'wpinv_bank_transfer_cc_form', '__return_false' ); |
|
5 | +add_action('wpinv_bank_transfer_cc_form', '__return_false'); |
|
6 | 6 | |
7 | -function wpinv_process_bank_transfer_payment( $purchase_data ) { |
|
8 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
9 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
7 | +function wpinv_process_bank_transfer_payment($purchase_data) { |
|
8 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
9 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | // Collect payment data |
@@ -24,37 +24,37 @@ discard block |
||
24 | 24 | ); |
25 | 25 | |
26 | 26 | // Record the pending payment |
27 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
27 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
28 | 28 | |
29 | - if ( !empty( $invoice ) ) { |
|
30 | - wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() ); |
|
31 | - wpinv_update_payment_status( $invoice, 'pending' ); |
|
29 | + if (!empty($invoice)) { |
|
30 | + wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key()); |
|
31 | + wpinv_update_payment_status($invoice, 'pending'); |
|
32 | 32 | |
33 | 33 | // Empty the shopping cart |
34 | 34 | wpinv_empty_cart(); |
35 | 35 | |
36 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
36 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
37 | 37 | } else { |
38 | - wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice ); |
|
38 | + wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice); |
|
39 | 39 | // If errors are present, send the user back to the purchase page so they can be corrected |
40 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
40 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
41 | 41 | } |
42 | 42 | } |
43 | -add_action( 'wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment' ); |
|
43 | +add_action('wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment'); |
|
44 | 44 | |
45 | -function wpinv_show_bank_info( $invoice ) { |
|
46 | - if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending' ) { |
|
47 | - $bank_info = wpinv_get_bank_info( true ); |
|
45 | +function wpinv_show_bank_info($invoice) { |
|
46 | + if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending') { |
|
47 | + $bank_info = wpinv_get_bank_info(true); |
|
48 | 48 | ?> |
49 | 49 | <div class="wpinv-bank-details"> |
50 | - <?php if ( $instructions = wpinv_get_bank_instructions() ) { ?> |
|
51 | - <div class="alert bg-info"><?php echo wpautop( wp_kses_post( $instructions ) ); ?></div> |
|
50 | + <?php if ($instructions = wpinv_get_bank_instructions()) { ?> |
|
51 | + <div class="alert bg-info"><?php echo wpautop(wp_kses_post($instructions)); ?></div> |
|
52 | 52 | <?php } ?> |
53 | - <?php if ( !empty( $bank_info ) ) { ?> |
|
54 | - <h3 class="wpinv-bank-t"><?php echo apply_filters( 'wpinv_receipt_bank_details_title', __( 'Our Bank Details', 'invoicing' ) ); ?></h3> |
|
53 | + <?php if (!empty($bank_info)) { ?> |
|
54 | + <h3 class="wpinv-bank-t"><?php echo apply_filters('wpinv_receipt_bank_details_title', __('Our Bank Details', 'invoicing')); ?></h3> |
|
55 | 55 | <table class="table table-bordered table-sm wpi-bank-details"> |
56 | - <?php foreach ( $bank_info as $key => $info ) { ?> |
|
57 | - <tr class="wpi-<?php echo sanitize_html_class( $key );?>"><th class="text-left"><?php echo $info['label'] ;?></th><td><?php echo $info['value'] ;?></td></tr> |
|
56 | + <?php foreach ($bank_info as $key => $info) { ?> |
|
57 | + <tr class="wpi-<?php echo sanitize_html_class($key); ?>"><th class="text-left"><?php echo $info['label']; ?></th><td><?php echo $info['value']; ?></td></tr> |
|
58 | 58 | <?php } ?> |
59 | 59 | </table> |
60 | 60 | <?php } ?> |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | <?php |
63 | 63 | } |
64 | 64 | } |
65 | -add_action( 'wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1 ); |
|
65 | +add_action('wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1); |
|
66 | 66 | |
67 | -function wpinv_invoice_print_bank_info( $invoice ) { |
|
68 | - if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending' ) { |
|
67 | +function wpinv_invoice_print_bank_info($invoice) { |
|
68 | + if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending') { |
|
69 | 69 | ?> |
70 | 70 | <div class="row wpinv-bank-info"> |
71 | - <?php echo wpinv_show_bank_info( $invoice ); ?> |
|
71 | + <?php echo wpinv_show_bank_info($invoice); ?> |
|
72 | 72 | </div> |
73 | 73 | <?php |
74 | 74 | } |
75 | 75 | } |
76 | -add_action( 'wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1 ); |
|
77 | 76 | \ No newline at end of file |
77 | +add_action('wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1); |
|
78 | 78 | \ No newline at end of file |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -add_action( 'wpinv_paypal_cc_form', '__return_false' ); |
|
6 | -add_filter( 'wpinv_paypal_support_subscription', '__return_true' ); |
|
5 | +add_action('wpinv_paypal_cc_form', '__return_false'); |
|
6 | +add_filter('wpinv_paypal_support_subscription', '__return_true'); |
|
7 | 7 | |
8 | -function wpinv_process_paypal_payment( $purchase_data ) { |
|
9 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
10 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
8 | +function wpinv_process_paypal_payment($purchase_data) { |
|
9 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
10 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | // Collect payment data |
@@ -21,34 +21,34 @@ discard block |
||
21 | 21 | 'user_info' => $purchase_data['user_info'], |
22 | 22 | 'cart_details' => $purchase_data['cart_details'], |
23 | 23 | 'gateway' => 'paypal', |
24 | - 'status' => !empty( $purchase_data['buy_now'] ) ? 'private' : 'pending' |
|
24 | + 'status' => !empty($purchase_data['buy_now']) ? 'private' : 'pending' |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | // Record the pending payment |
28 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
28 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
29 | 29 | |
30 | 30 | // Check payment |
31 | - if ( ! $invoice ) { |
|
31 | + if (!$invoice) { |
|
32 | 32 | // Record the error |
33 | - wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $payment ); |
|
33 | + wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $payment); |
|
34 | 34 | // Problems? send back |
35 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
35 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
36 | 36 | } else { |
37 | 37 | // Only send to PayPal if the pending payment is created successfully |
38 | - $listener_url = wpinv_get_ipn_url( 'paypal' ); |
|
38 | + $listener_url = wpinv_get_ipn_url('paypal'); |
|
39 | 39 | |
40 | 40 | // Get the success url |
41 | - $return_url = add_query_arg( array( |
|
41 | + $return_url = add_query_arg(array( |
|
42 | 42 | 'payment-confirm' => 'paypal', |
43 | 43 | 'invoice-id' => $invoice->ID |
44 | - ), get_permalink( wpinv_get_option( 'success_page', false ) ) ); |
|
44 | + ), get_permalink(wpinv_get_option('success_page', false))); |
|
45 | 45 | |
46 | 46 | // Get the PayPal redirect uri |
47 | - $paypal_redirect = trailingslashit( wpinv_get_paypal_redirect() ) . '?'; |
|
47 | + $paypal_redirect = trailingslashit(wpinv_get_paypal_redirect()) . '?'; |
|
48 | 48 | |
49 | 49 | // Setup PayPal arguments |
50 | 50 | $paypal_args = array( |
51 | - 'business' => wpinv_get_option( 'paypal_email', false ), |
|
51 | + 'business' => wpinv_get_option('paypal_email', false), |
|
52 | 52 | 'email' => $invoice->get_email(), |
53 | 53 | 'first_name' => $invoice->get_first_name(), |
54 | 54 | 'last_name' => $invoice->get_last_name(), |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | 'shipping' => '0', |
58 | 58 | 'no_note' => '1', |
59 | 59 | 'currency_code' => wpinv_get_currency(), |
60 | - 'charset' => get_bloginfo( 'charset' ), |
|
60 | + 'charset' => get_bloginfo('charset'), |
|
61 | 61 | 'custom' => $invoice->ID, |
62 | 62 | 'rm' => '2', |
63 | 63 | 'return' => $return_url, |
64 | - 'cancel_return' => wpinv_get_failed_transaction_uri( '?invoice-id=' . $invoice->ID ), |
|
64 | + 'cancel_return' => wpinv_get_failed_transaction_uri('?invoice-id=' . $invoice->ID), |
|
65 | 65 | 'notify_url' => $listener_url, |
66 | - 'cbt' => get_bloginfo( 'name' ), |
|
66 | + 'cbt' => get_bloginfo('name'), |
|
67 | 67 | 'bn' => 'WPInvoicing_SP', |
68 | 68 | 'lc' => 'US' // this will force paypal site to english |
69 | 69 | ); |
@@ -79,57 +79,57 @@ discard block |
||
79 | 79 | 'upload' => '1' |
80 | 80 | ); |
81 | 81 | |
82 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
82 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
83 | 83 | |
84 | 84 | // Add cart items |
85 | 85 | $i = 1; |
86 | - if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) { |
|
87 | - foreach ( $purchase_data['cart_details'] as $item ) { |
|
86 | + if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) { |
|
87 | + foreach ($purchase_data['cart_details'] as $item) { |
|
88 | 88 | $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1; |
89 | - $item_amount = round( $item['subtotal'] / $item['quantity'], 2 ); |
|
89 | + $item_amount = round($item['subtotal'] / $item['quantity'], 2); |
|
90 | 90 | |
91 | - if ( $item_amount <= 0 ) { |
|
91 | + if ($item_amount <= 0) { |
|
92 | 92 | $item_amount = 0; |
93 | 93 | } |
94 | 94 | |
95 | - $paypal_args['item_number_' . $i ] = $item['id']; |
|
96 | - $paypal_args['item_name_' . $i ] = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) ); |
|
97 | - $paypal_args['quantity_' . $i ] = $item['quantity']; |
|
98 | - $paypal_args['amount_' . $i ] = $item_amount; |
|
99 | - $paypal_args['discount_amount_' . $i ] = $item['discount']; |
|
95 | + $paypal_args['item_number_' . $i] = $item['id']; |
|
96 | + $paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8')); |
|
97 | + $paypal_args['quantity_' . $i] = $item['quantity']; |
|
98 | + $paypal_args['amount_' . $i] = $item_amount; |
|
99 | + $paypal_args['discount_amount_' . $i] = $item['discount']; |
|
100 | 100 | |
101 | 101 | $i++; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Add taxes to the cart |
106 | - if ( wpinv_use_taxes() ) { |
|
107 | - $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float)$invoice->get_tax() ); |
|
106 | + if (wpinv_use_taxes()) { |
|
107 | + $paypal_args['tax_cart'] = wpinv_sanitize_amount((float)$invoice->get_tax()); |
|
108 | 108 | } |
109 | 109 | |
110 | - $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice ); |
|
110 | + $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice); |
|
111 | 111 | |
112 | 112 | // Build query |
113 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
113 | + $paypal_redirect .= http_build_query($paypal_args); |
|
114 | 114 | |
115 | 115 | // Fix for some sites that encode the entities |
116 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
116 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
117 | 117 | |
118 | 118 | // Get rid of cart contents |
119 | 119 | wpinv_empty_cart(); |
120 | 120 | |
121 | 121 | // Redirect to PayPal |
122 | - wp_redirect( $paypal_redirect ); |
|
122 | + wp_redirect($paypal_redirect); |
|
123 | 123 | exit; |
124 | 124 | } |
125 | 125 | } |
126 | -add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' ); |
|
126 | +add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment'); |
|
127 | 127 | |
128 | -function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) { |
|
129 | - if ( $invoice->is_recurring() && $item_id = $invoice->get_recurring() ) { |
|
130 | - $item = new WPInv_Item( $item_id ); |
|
128 | +function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) { |
|
129 | + if ($invoice->is_recurring() && $item_id = $invoice->get_recurring()) { |
|
130 | + $item = new WPInv_Item($item_id); |
|
131 | 131 | |
132 | - if ( empty( $item ) ) { |
|
132 | + if (empty($item)) { |
|
133 | 133 | return $paypal_args; |
134 | 134 | } |
135 | 135 | |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | $interval = $item->get_recurring_interval(); |
138 | 138 | $bill_times = (int)$item->get_recurring_limit(); |
139 | 139 | |
140 | - $initial_amount = wpinv_format_amount( $invoice->get_total() ); |
|
141 | - $recurring_amount = wpinv_format_amount( $invoice->get_recurring_details( 'total' ) ); |
|
140 | + $initial_amount = wpinv_format_amount($invoice->get_total()); |
|
141 | + $recurring_amount = wpinv_format_amount($invoice->get_recurring_details('total')); |
|
142 | 142 | |
143 | 143 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
144 | 144 | $paypal_args['sra'] = '1'; |
145 | 145 | $paypal_args['src'] = '1'; |
146 | 146 | |
147 | 147 | // Set item description |
148 | - $paypal_args['item_name'] = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( array( 'id' => $item->ID ) ), ENT_COMPAT, 'UTF-8' ) ); |
|
148 | + $paypal_args['item_name'] = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name(array('id' => $item->ID)), ENT_COMPAT, 'UTF-8')); |
|
149 | 149 | |
150 | - if ( $invoice->is_free_trial() && $item->has_free_trial() ) { |
|
150 | + if ($invoice->is_free_trial() && $item->has_free_trial()) { |
|
151 | 151 | $paypal_args['a1'] = $initial_amount; |
152 | 152 | $paypal_args['p1'] = $item->get_trial_interval(); |
153 | 153 | $paypal_args['t1'] = $item->get_trial_period(); |
154 | 154 | |
155 | 155 | // Set the recurring amount |
156 | 156 | $paypal_args['a3'] = $recurring_amount; |
157 | - } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) { |
|
157 | + } else if ($initial_amount != $recurring_amount && $bill_times != 1) { |
|
158 | 158 | $paypal_args['a1'] = $initial_amount; |
159 | 159 | $paypal_args['p1'] = $interval; |
160 | 160 | $paypal_args['t1'] = $period; |
@@ -162,63 +162,63 @@ discard block |
||
162 | 162 | // Set the recurring amount |
163 | 163 | $paypal_args['a3'] = $recurring_amount; |
164 | 164 | |
165 | - if ( $bill_times > 1 ) { |
|
165 | + if ($bill_times > 1) { |
|
166 | 166 | $bill_times--; |
167 | 167 | } |
168 | 168 | } else { |
169 | - $paypal_args['a3'] = $initial_amount; |
|
169 | + $paypal_args['a3'] = $initial_amount; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $paypal_args['p3'] = $interval; |
173 | 173 | $paypal_args['t3'] = $period; |
174 | 174 | |
175 | - if ( $bill_times > 1 ) { |
|
175 | + if ($bill_times > 1) { |
|
176 | 176 | // Make sure it's not over the max of 52 |
177 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
177 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Remove cart items |
181 | 181 | $i = 1; |
182 | - if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) { |
|
183 | - foreach ( $purchase_data['cart_details'] as $item ) { |
|
184 | - if ( isset( $paypal_args['item_number_' . $i] ) ) { |
|
185 | - unset( $paypal_args['item_number_' . $i] ); |
|
182 | + if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) { |
|
183 | + foreach ($purchase_data['cart_details'] as $item) { |
|
184 | + if (isset($paypal_args['item_number_' . $i])) { |
|
185 | + unset($paypal_args['item_number_' . $i]); |
|
186 | 186 | } |
187 | - if ( isset( $paypal_args['item_name_' . $i] ) ) { |
|
188 | - unset( $paypal_args['item_name_' . $i] ); |
|
187 | + if (isset($paypal_args['item_name_' . $i])) { |
|
188 | + unset($paypal_args['item_name_' . $i]); |
|
189 | 189 | } |
190 | - if ( isset( $paypal_args['quantity_' . $i] ) ) { |
|
191 | - unset( $paypal_args['quantity_' . $i] ); |
|
190 | + if (isset($paypal_args['quantity_' . $i])) { |
|
191 | + unset($paypal_args['quantity_' . $i]); |
|
192 | 192 | } |
193 | - if ( isset( $paypal_args['amount_' . $i] ) ) { |
|
194 | - unset( $paypal_args['amount_' . $i] ); |
|
193 | + if (isset($paypal_args['amount_' . $i])) { |
|
194 | + unset($paypal_args['amount_' . $i]); |
|
195 | 195 | } |
196 | - if ( isset( $paypal_args['discount_amount_' . $i] ) ) { |
|
197 | - unset( $paypal_args['discount_amount_' . $i] ); |
|
196 | + if (isset($paypal_args['discount_amount_' . $i])) { |
|
197 | + unset($paypal_args['discount_amount_' . $i]); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $i++; |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - if ( isset( $paypal_args['tax_cart'] ) ) { |
|
205 | - unset( $paypal_args['tax_cart'] ); |
|
204 | + if (isset($paypal_args['tax_cart'])) { |
|
205 | + unset($paypal_args['tax_cart']); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( isset( $paypal_args['upload'] ) ) { |
|
209 | - unset( $paypal_args['upload'] ); |
|
208 | + if (isset($paypal_args['upload'])) { |
|
209 | + unset($paypal_args['upload']); |
|
210 | 210 | } |
211 | 211 | |
212 | - $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice ); |
|
212 | + $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | return $paypal_args; |
216 | 216 | } |
217 | -add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 ); |
|
217 | +add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3); |
|
218 | 218 | |
219 | 219 | function wpinv_process_paypal_ipn() { |
220 | 220 | // Check the request method is POST |
221 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
221 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | $post_data = ''; |
227 | 227 | |
228 | 228 | // Fallback just in case post_max_size is lower than needed |
229 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
230 | - $post_data = file_get_contents( 'php://input' ); |
|
229 | + if (ini_get('allow_url_fopen')) { |
|
230 | + $post_data = file_get_contents('php://input'); |
|
231 | 231 | } else { |
232 | 232 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
233 | - ini_set( 'post_max_size', '12M' ); |
|
233 | + ini_set('post_max_size', '12M'); |
|
234 | 234 | } |
235 | 235 | // Start the encoded data collection with notification command |
236 | 236 | $encoded_data = 'cmd=_notify-validate'; |
@@ -239,43 +239,43 @@ discard block |
||
239 | 239 | $arg_separator = wpinv_get_php_arg_separator_output(); |
240 | 240 | |
241 | 241 | // Verify there is a post_data |
242 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
242 | + if ($post_data || strlen($post_data) > 0) { |
|
243 | 243 | // Append the data |
244 | - $encoded_data .= $arg_separator.$post_data; |
|
244 | + $encoded_data .= $arg_separator . $post_data; |
|
245 | 245 | } else { |
246 | 246 | // Check if POST is empty |
247 | - if ( empty( $_POST ) ) { |
|
247 | + if (empty($_POST)) { |
|
248 | 248 | // Nothing to do |
249 | 249 | return; |
250 | 250 | } else { |
251 | 251 | // Loop through each POST |
252 | - foreach ( $_POST as $key => $value ) { |
|
252 | + foreach ($_POST as $key => $value) { |
|
253 | 253 | // Encode the value and append the data |
254 | - $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
254 | + $encoded_data .= $arg_separator . "$key=" . urlencode($value); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | 259 | // Convert collected post data to an array |
260 | - parse_str( $encoded_data, $encoded_data_array ); |
|
260 | + parse_str($encoded_data, $encoded_data_array); |
|
261 | 261 | |
262 | - foreach ( $encoded_data_array as $key => $value ) { |
|
263 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
264 | - $new_key = str_replace( '&', '&', $key ); |
|
265 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
262 | + foreach ($encoded_data_array as $key => $value) { |
|
263 | + if (false !== strpos($key, 'amp;')) { |
|
264 | + $new_key = str_replace('&', '&', $key); |
|
265 | + $new_key = str_replace('amp;', '&', $new_key); |
|
266 | 266 | |
267 | - unset( $encoded_data_array[ $key ] ); |
|
268 | - $encoded_data_array[ $new_key ] = $value; |
|
267 | + unset($encoded_data_array[$key]); |
|
268 | + $encoded_data_array[$new_key] = $value; |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Get the PayPal redirect uri |
273 | - $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
273 | + $paypal_redirect = wpinv_get_paypal_redirect(true); |
|
274 | 274 | |
275 | - if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
275 | + if (!wpinv_get_option('disable_paypal_verification', false)) { |
|
276 | 276 | // Validate the IPN |
277 | 277 | |
278 | - $remote_post_vars = array( |
|
278 | + $remote_post_vars = array( |
|
279 | 279 | 'method' => 'POST', |
280 | 280 | 'timeout' => 45, |
281 | 281 | 'redirection' => 5, |
@@ -293,21 +293,21 @@ discard block |
||
293 | 293 | ); |
294 | 294 | |
295 | 295 | // Get response |
296 | - $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
296 | + $api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars); |
|
297 | 297 | |
298 | - if ( is_wp_error( $api_response ) ) { |
|
299 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
298 | + if (is_wp_error($api_response)) { |
|
299 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response))); |
|
300 | 300 | return; // Something went wrong |
301 | 301 | } |
302 | 302 | |
303 | - if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
304 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
303 | + if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) { |
|
304 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response))); |
|
305 | 305 | return; // Response not okay |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | // Check if $post_data_array has been populated |
310 | - if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
310 | + if (!is_array($encoded_data_array) && !empty($encoded_data_array)) |
|
311 | 311 | return; |
312 | 312 | |
313 | 313 | $defaults = array( |
@@ -315,215 +315,215 @@ discard block |
||
315 | 315 | 'payment_status' => '' |
316 | 316 | ); |
317 | 317 | |
318 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
318 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
319 | 319 | |
320 | - $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
320 | + $invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
321 | 321 | |
322 | - wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ ); |
|
322 | + wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__); |
|
323 | 323 | |
324 | - if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
324 | + if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) { |
|
325 | 325 | // Allow PayPal IPN types to be processed separately |
326 | - do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
326 | + do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id); |
|
327 | 327 | } else { |
328 | 328 | // Fallback to web accept just in case the txn_type isn't present |
329 | - do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id ); |
|
329 | + do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id); |
|
330 | 330 | } |
331 | 331 | exit; |
332 | 332 | } |
333 | -add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' ); |
|
333 | +add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn'); |
|
334 | 334 | |
335 | -function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) { |
|
336 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
335 | +function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) { |
|
336 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
337 | 337 | return; |
338 | 338 | } |
339 | 339 | |
340 | - if( empty( $invoice_id ) ) { |
|
340 | + if (empty($invoice_id)) { |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Collect payment details |
345 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
345 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
346 | 346 | $paypal_amount = $data['mc_gross']; |
347 | - $payment_status = strtolower( $data['payment_status'] ); |
|
348 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
349 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
350 | - $payment_meta = wpinv_get_invoice_meta( $invoice_id ); |
|
347 | + $payment_status = strtolower($data['payment_status']); |
|
348 | + $currency_code = strtolower($data['mc_currency']); |
|
349 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
350 | + $payment_meta = wpinv_get_invoice_meta($invoice_id); |
|
351 | 351 | |
352 | - if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
352 | + if (wpinv_get_payment_gateway($invoice_id) != 'paypal') { |
|
353 | 353 | return; // this isn't a PayPal standard IPN |
354 | 354 | } |
355 | 355 | |
356 | 356 | // Verify payment recipient |
357 | - if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) { |
|
358 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
359 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
360 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
357 | + if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) { |
|
358 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
359 | + wpinv_update_payment_status($invoice_id, 'failed'); |
|
360 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing')); |
|
361 | 361 | return; |
362 | 362 | } |
363 | 363 | |
364 | 364 | // Verify payment currency |
365 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
366 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
367 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
368 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
365 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
366 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
367 | + wpinv_update_payment_status($invoice_id, 'failed'); |
|
368 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing')); |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | - if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
372 | + if (!wpinv_get_payment_user_email($invoice_id)) { |
|
373 | 373 | // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
374 | 374 | // No email associated with purchase, so store from PayPal |
375 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
375 | + wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']); |
|
376 | 376 | |
377 | 377 | // Setup and store the customer's details |
378 | 378 | $user_info = array( |
379 | 379 | 'user_id' => '-1', |
380 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
381 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
382 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
380 | + 'email' => sanitize_text_field($data['payer_email']), |
|
381 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
382 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
383 | 383 | 'discount' => '', |
384 | 384 | ); |
385 | - $user_info['address'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
386 | - $user_info['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
387 | - $user_info['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
388 | - $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
389 | - $user_info['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
385 | + $user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
386 | + $user_info['city'] = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
387 | + $user_info['state'] = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
388 | + $user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
389 | + $user_info['zip'] = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
390 | 390 | |
391 | 391 | $payment_meta['user_info'] = $user_info; |
392 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
392 | + wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta); |
|
393 | 393 | } |
394 | 394 | |
395 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
395 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
396 | 396 | // Process a refund |
397 | - wpinv_process_paypal_refund( $data, $invoice_id ); |
|
397 | + wpinv_process_paypal_refund($data, $invoice_id); |
|
398 | 398 | } else { |
399 | - if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
399 | + if (get_post_status($invoice_id) == 'publish') { |
|
400 | 400 | return; // Only paid payments once |
401 | 401 | } |
402 | 402 | |
403 | 403 | // Retrieve the total purchase amount (before PayPal) |
404 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
404 | + $payment_amount = wpinv_payment_total($invoice_id); |
|
405 | 405 | |
406 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
406 | + if (number_format((float)$paypal_amount, 2) < number_format((float)$payment_amount, 2)) { |
|
407 | 407 | // The prices don't match |
408 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
409 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
410 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
408 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
409 | + wpinv_update_payment_status($invoice_id, 'failed'); |
|
410 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing')); |
|
411 | 411 | return; |
412 | 412 | } |
413 | - if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
413 | + if ($purchase_key != wpinv_get_payment_key($invoice_id)) { |
|
414 | 414 | // Purchase keys don't match |
415 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
416 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
417 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
415 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
416 | + wpinv_update_payment_status($invoice_id, 'failed'); |
|
417 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing')); |
|
418 | 418 | return; |
419 | 419 | } |
420 | 420 | |
421 | - if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) { |
|
422 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ) ); |
|
423 | - wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] ); |
|
424 | - wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
425 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
421 | + if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) { |
|
422 | + wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id'])); |
|
423 | + wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']); |
|
424 | + wpinv_update_payment_status($invoice_id, 'publish'); |
|
425 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
426 | 426 | // Look for possible pending reasons, such as an echeck |
427 | 427 | $note = ''; |
428 | 428 | |
429 | - switch( strtolower( $data['pending_reason'] ) ) { |
|
429 | + switch (strtolower($data['pending_reason'])) { |
|
430 | 430 | case 'echeck' : |
431 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
431 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing'); |
|
432 | 432 | break; |
433 | 433 | |
434 | 434 | case 'address' : |
435 | - $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
435 | + $note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing'); |
|
436 | 436 | break; |
437 | 437 | |
438 | 438 | case 'intl' : |
439 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
439 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing'); |
|
440 | 440 | break; |
441 | 441 | |
442 | 442 | case 'multi-currency' : |
443 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' ); |
|
443 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing'); |
|
444 | 444 | break; |
445 | 445 | |
446 | 446 | case 'paymentreview' : |
447 | 447 | case 'regulatory_review' : |
448 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' ); |
|
448 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing'); |
|
449 | 449 | break; |
450 | 450 | |
451 | 451 | case 'unilateral' : |
452 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
452 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing'); |
|
453 | 453 | break; |
454 | 454 | |
455 | 455 | case 'upgrade' : |
456 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
456 | + $note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing'); |
|
457 | 457 | break; |
458 | 458 | |
459 | 459 | case 'verify' : |
460 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
460 | + $note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing'); |
|
461 | 461 | break; |
462 | 462 | |
463 | 463 | case 'other' : |
464 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
464 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing'); |
|
465 | 465 | break; |
466 | 466 | } |
467 | 467 | |
468 | - if ( ! empty( $note ) ) { |
|
469 | - wpinv_insert_payment_note( $invoice_id, $note ); |
|
468 | + if (!empty($note)) { |
|
469 | + wpinv_insert_payment_note($invoice_id, $note); |
|
470 | 470 | } |
471 | 471 | } else { |
472 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
472 | + wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status)); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | } |
476 | -add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 ); |
|
476 | +add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2); |
|
477 | 477 | |
478 | 478 | // Process PayPal subscription sign ups |
479 | -add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' ); |
|
479 | +add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup'); |
|
480 | 480 | |
481 | 481 | // Process PayPal subscription payments |
482 | -add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' ); |
|
482 | +add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment'); |
|
483 | 483 | |
484 | 484 | // Process PayPal subscription cancellations |
485 | -add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' ); |
|
485 | +add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel'); |
|
486 | 486 | |
487 | 487 | // Process PayPal subscription end of term notices |
488 | -add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' ); |
|
488 | +add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot'); |
|
489 | 489 | |
490 | 490 | // Process PayPal payment failed |
491 | -add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' ); |
|
491 | +add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed'); |
|
492 | 492 | |
493 | 493 | |
494 | 494 | /** |
495 | 495 | * Process the subscription started IPN. |
496 | 496 | */ |
497 | -function wpinv_process_paypal_subscr_signup( $ipn_data ) { |
|
498 | - $parent_invoice_id = absint( $ipn_data['custom'] ); |
|
499 | - if( empty( $parent_invoice_id ) ) { |
|
497 | +function wpinv_process_paypal_subscr_signup($ipn_data) { |
|
498 | + $parent_invoice_id = absint($ipn_data['custom']); |
|
499 | + if (empty($parent_invoice_id)) { |
|
500 | 500 | return; |
501 | 501 | } |
502 | 502 | |
503 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
504 | - if ( empty( $invoice ) ) { |
|
503 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
504 | + if (empty($invoice)) { |
|
505 | 505 | return; |
506 | 506 | } |
507 | 507 | |
508 | - if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) { |
|
509 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ) ); |
|
510 | - wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['invoice'] ); |
|
508 | + if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) { |
|
509 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice'])); |
|
510 | + wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['invoice']); |
|
511 | 511 | } |
512 | 512 | |
513 | - wpinv_update_payment_status( $parent_invoice_id, 'publish' ); |
|
513 | + wpinv_update_payment_status($parent_invoice_id, 'publish'); |
|
514 | 514 | sleep(1); |
515 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ) ); |
|
515 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id'])); |
|
516 | 516 | |
517 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
518 | - if ( false === $subscription ) { |
|
517 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
518 | + if (false === $subscription) { |
|
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | - $cart_details = $invoice->cart_details; |
|
522 | + $cart_details = $invoice->cart_details; |
|
523 | 523 | |
524 | - if ( !empty( $cart_details ) ) { |
|
525 | - foreach ( $cart_details as $cart_item ) { |
|
526 | - $item = new WPInv_Item( $cart_item['id'] ); |
|
524 | + if (!empty($cart_details)) { |
|
525 | + foreach ($cart_details as $cart_item) { |
|
526 | + $item = new WPInv_Item($cart_item['id']); |
|
527 | 527 | |
528 | 528 | $status = $invoice->is_free_trial() && $item->has_free_trial() ? 'trialing' : 'active'; |
529 | 529 | |
@@ -532,15 +532,15 @@ discard block |
||
532 | 532 | 'status' => $status, |
533 | 533 | 'period' => $item->get_recurring_period(), |
534 | 534 | 'initial_amount' => $invoice->get_total(), |
535 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
535 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
536 | 536 | 'interval' => $item->get_recurring_interval(), |
537 | 537 | 'bill_times' => $item->get_recurring_limit(), |
538 | - 'expiration' => $invoice->get_new_expiration( $cart_item['id'] ), |
|
538 | + 'expiration' => $invoice->get_new_expiration($cart_item['id']), |
|
539 | 539 | 'profile_id' => $ipn_data['subscr_id'], |
540 | - 'created' => date_i18n( 'Y-m-d H:i:s', strtotime( $ipn_data['subscr_date'] ) ) |
|
540 | + 'created' => date_i18n('Y-m-d H:i:s', strtotime($ipn_data['subscr_date'])) |
|
541 | 541 | ); |
542 | 542 | |
543 | - if ( $item->has_free_trial() ) { |
|
543 | + if ($item->has_free_trial()) { |
|
544 | 544 | $args['trial_period'] = $item->get_trial_period(); |
545 | 545 | $args['trial_interval'] = $item->get_trial_interval(); |
546 | 546 | } else { |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | |
551 | 551 | |
552 | - $subscription->update_subscription( $args ); |
|
552 | + $subscription->update_subscription($args); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
@@ -557,39 +557,39 @@ discard block |
||
557 | 557 | /** |
558 | 558 | * Process the subscription payment received IPN. |
559 | 559 | */ |
560 | -function wpinv_process_paypal_subscr_payment( $ipn_data ) { |
|
561 | - $parent_invoice_id = absint( $ipn_data['custom'] ); |
|
560 | +function wpinv_process_paypal_subscr_payment($ipn_data) { |
|
561 | + $parent_invoice_id = absint($ipn_data['custom']); |
|
562 | 562 | |
563 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
564 | - if ( false === $subscription ) { |
|
563 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
564 | + if (false === $subscription) { |
|
565 | 565 | return; |
566 | 566 | } |
567 | 567 | |
568 | - $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id ); |
|
569 | - $signup_date = strtotime( $subscription->get_subscription_created() ); |
|
570 | - $today = date_i18n( 'Y-m-d', $signup_date ) == date_i18n( 'Y-m-d', strtotime( $ipn_data['payment_date'] ) ); |
|
568 | + $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id); |
|
569 | + $signup_date = strtotime($subscription->get_subscription_created()); |
|
570 | + $today = date_i18n('Y-m-d', $signup_date) == date_i18n('Y-m-d', strtotime($ipn_data['payment_date'])); |
|
571 | 571 | |
572 | 572 | // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet. |
573 | - if ( $today && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) { |
|
574 | - wpinv_update_payment_status( $parent_invoice_id, 'publish' ); |
|
573 | + if ($today && (!$transaction_id || $transaction_id == $parent_invoice_id)) { |
|
574 | + wpinv_update_payment_status($parent_invoice_id, 'publish'); |
|
575 | 575 | sleep(1); |
576 | 576 | |
577 | 577 | // This is the very first payment |
578 | - wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] ); |
|
579 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ) ); |
|
578 | + wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']); |
|
579 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id'])); |
|
580 | 580 | return; |
581 | 581 | } |
582 | 582 | |
583 | - if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) { |
|
583 | + if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) { |
|
584 | 584 | return; // Payment already recorded |
585 | 585 | } |
586 | 586 | |
587 | - $currency_code = strtolower( $ipn_data['mc_currency'] ); |
|
587 | + $currency_code = strtolower($ipn_data['mc_currency']); |
|
588 | 588 | |
589 | 589 | // verify details |
590 | - if ( $currency_code != strtolower( wpinv_get_currency() ) ) { |
|
590 | + if ($currency_code != strtolower(wpinv_get_currency())) { |
|
591 | 591 | // the currency code is invalid |
592 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) ); |
|
592 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data))); |
|
593 | 593 | return; |
594 | 594 | } |
595 | 595 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | 'transaction_id' => $ipn_data['txn_id'] |
599 | 599 | ); |
600 | 600 | |
601 | - $invoice = wpinv_recurring_add_subscription_payment( $parent_invoice_id, $args ); |
|
601 | + $invoice = wpinv_recurring_add_subscription_payment($parent_invoice_id, $args); |
|
602 | 602 | |
603 | - if ( !empty( $invoice ) ) { |
|
603 | + if (!empty($invoice)) { |
|
604 | 604 | sleep(1); |
605 | - wpinv_insert_payment_note( $invoice->ID, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ) ); |
|
605 | + wpinv_insert_payment_note($invoice->ID, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id'])); |
|
606 | 606 | |
607 | 607 | $invoice->renew_subscription(); |
608 | 608 | } |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | /** |
612 | 612 | * Process the subscription canceled IPN. |
613 | 613 | */ |
614 | -function wpinv_process_paypal_subscr_cancel( $ipn_data ) { |
|
615 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
614 | +function wpinv_process_paypal_subscr_cancel($ipn_data) { |
|
615 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
616 | 616 | |
617 | - if( false === $subscription ) { |
|
617 | + if (false === $subscription) { |
|
618 | 618 | return; |
619 | 619 | } |
620 | 620 | |
@@ -624,10 +624,10 @@ discard block |
||
624 | 624 | /** |
625 | 625 | * Process the subscription expired IPN. |
626 | 626 | */ |
627 | -function wpinv_process_paypal_subscr_eot( $ipn_data ) { |
|
628 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
627 | +function wpinv_process_paypal_subscr_eot($ipn_data) { |
|
628 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
629 | 629 | |
630 | - if( false === $subscription ) { |
|
630 | + if (false === $subscription) { |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | |
@@ -637,45 +637,45 @@ discard block |
||
637 | 637 | /** |
638 | 638 | * Process the subscription payment failed IPN. |
639 | 639 | */ |
640 | -function wpinv_process_paypal_subscr_failed( $ipn_data ) { |
|
641 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
640 | +function wpinv_process_paypal_subscr_failed($ipn_data) { |
|
641 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
642 | 642 | |
643 | - if( false === $subscription ) { |
|
643 | + if (false === $subscription) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | |
647 | 647 | $subscription->failing_subscription(); |
648 | 648 | |
649 | - do_action( 'wpinv_recurring_payment_failed', $subscription ); |
|
649 | + do_action('wpinv_recurring_payment_failed', $subscription); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
653 | 653 | * Retrieve the subscription this IPN notice is for. |
654 | 654 | */ |
655 | -function wpinv_get_paypal_subscription( $ipn_data = array() ) { |
|
656 | - $parent_invoice_id = absint( $ipn_data['custom'] ); |
|
655 | +function wpinv_get_paypal_subscription($ipn_data = array()) { |
|
656 | + $parent_invoice_id = absint($ipn_data['custom']); |
|
657 | 657 | |
658 | - if( empty( $parent_invoice_id ) ) { |
|
658 | + if (empty($parent_invoice_id)) { |
|
659 | 659 | return false; |
660 | 660 | } |
661 | 661 | |
662 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
663 | - if ( empty( $invoice ) ) { |
|
662 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
663 | + if (empty($invoice)) { |
|
664 | 664 | return false; |
665 | 665 | } |
666 | 666 | |
667 | - $subscription = wpinv_get_subscription( $ipn_data['subscr_id'], true ); |
|
667 | + $subscription = wpinv_get_subscription($ipn_data['subscr_id'], true); |
|
668 | 668 | |
669 | - if ( empty( $subscription ) ) { |
|
670 | - $subs = wpinv_get_subscriptions( array( 'parent_invoice_id' => $parent_invoice_id, 'numberposts' => 1 ) ); |
|
671 | - $subscription = reset( $subs ); |
|
669 | + if (empty($subscription)) { |
|
670 | + $subs = wpinv_get_subscriptions(array('parent_invoice_id' => $parent_invoice_id, 'numberposts' => 1)); |
|
671 | + $subscription = reset($subs); |
|
672 | 672 | |
673 | - if ( $subscription && $subscription->ID > 0 ) { |
|
673 | + if ($subscription && $subscription->ID > 0) { |
|
674 | 674 | // Update the profile ID so it is set for future renewals |
675 | - $subscription->update_subscription( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) ); |
|
675 | + $subscription->update_subscription(array('profile_id' => sanitize_text_field($ipn_data['subscr_id']))); |
|
676 | 676 | } else { |
677 | 677 | $subscription = $invoice; |
678 | - $subscription->update_subscription( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) ); |
|
678 | + $subscription->update_subscription(array('profile_id' => sanitize_text_field($ipn_data['subscr_id']))); |
|
679 | 679 | // No subscription found with a matching payment ID, bail |
680 | 680 | //return false; |
681 | 681 | } |
@@ -685,39 +685,39 @@ discard block |
||
685 | 685 | |
686 | 686 | } |
687 | 687 | |
688 | -function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) { |
|
688 | +function wpinv_process_paypal_refund($data, $invoice_id = 0) { |
|
689 | 689 | // Collect payment details |
690 | 690 | |
691 | - if( empty( $invoice_id ) ) { |
|
691 | + if (empty($invoice_id)) { |
|
692 | 692 | return; |
693 | 693 | } |
694 | 694 | |
695 | - if ( get_post_status( $invoice_id ) == 'refunded' ) { |
|
695 | + if (get_post_status($invoice_id) == 'refunded') { |
|
696 | 696 | return; // Only refund payments once |
697 | 697 | } |
698 | 698 | |
699 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
699 | + $payment_amount = wpinv_payment_total($invoice_id); |
|
700 | 700 | $refund_amount = $data['mc_gross'] * -1; |
701 | 701 | |
702 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
703 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Partial PayPal refund processed: %s', 'invoicing' ), $data['parent_txn_id'] ) ); |
|
702 | + if (number_format((float)$refund_amount, 2) < number_format((float)$payment_amount, 2)) { |
|
703 | + wpinv_insert_payment_note($invoice_id, sprintf(__('Partial PayPal refund processed: %s', 'invoicing'), $data['parent_txn_id'])); |
|
704 | 704 | return; // This is a partial refund |
705 | 705 | } |
706 | 706 | |
707 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
708 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ) ); |
|
709 | - wpinv_update_payment_status( $invoice_id, 'refunded' ); |
|
707 | + wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code'])); |
|
708 | + wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id'])); |
|
709 | + wpinv_update_payment_status($invoice_id, 'refunded'); |
|
710 | 710 | } |
711 | 711 | |
712 | -function wpinv_get_paypal_redirect( $ssl_check = false ) { |
|
713 | - if ( is_ssl() || ! $ssl_check ) { |
|
712 | +function wpinv_get_paypal_redirect($ssl_check = false) { |
|
713 | + if (is_ssl() || !$ssl_check) { |
|
714 | 714 | $protocol = 'https://'; |
715 | 715 | } else { |
716 | 716 | $protocol = 'http://'; |
717 | 717 | } |
718 | 718 | |
719 | 719 | // Check the current payment mode |
720 | - if ( wpinv_is_test_mode( 'paypal' ) ) { |
|
720 | + if (wpinv_is_test_mode('paypal')) { |
|
721 | 721 | // Test mode |
722 | 722 | $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
723 | 723 | } else { |
@@ -725,67 +725,67 @@ discard block |
||
725 | 725 | $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
726 | 726 | } |
727 | 727 | |
728 | - return apply_filters( 'wpinv_paypal_uri', $paypal_uri ); |
|
728 | + return apply_filters('wpinv_paypal_uri', $paypal_uri); |
|
729 | 729 | } |
730 | 730 | |
731 | -function wpinv_paypal_success_page_content( $content ) { |
|
731 | +function wpinv_paypal_success_page_content($content) { |
|
732 | 732 | global $wpi_invoice; |
733 | 733 | |
734 | 734 | $session = wpinv_get_checkout_session(); |
735 | 735 | |
736 | - if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] ) ) { |
|
736 | + if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) { |
|
737 | 737 | return $content; |
738 | 738 | } |
739 | 739 | |
740 | - $invoice_id = !empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] ); |
|
740 | + $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']); |
|
741 | 741 | |
742 | - if ( empty( $invoice_id ) ) { |
|
742 | + if (empty($invoice_id)) { |
|
743 | 743 | return $content; |
744 | 744 | } |
745 | 745 | |
746 | - $wpi_invoice = wpinv_get_invoice( $invoice_id ); |
|
746 | + $wpi_invoice = wpinv_get_invoice($invoice_id); |
|
747 | 747 | |
748 | - if ( !empty( $wpi_invoice ) && 'pending' == $wpi_invoice->status ) { |
|
748 | + if (!empty($wpi_invoice) && 'pending' == $wpi_invoice->status) { |
|
749 | 749 | // Payment is still pending so show processing indicator to fix the Race Condition, issue # |
750 | 750 | ob_start(); |
751 | - wpinv_get_template_part( 'wpinv-payment-processing' ); |
|
751 | + wpinv_get_template_part('wpinv-payment-processing'); |
|
752 | 752 | $content = ob_get_clean(); |
753 | 753 | } |
754 | 754 | |
755 | 755 | return $content; |
756 | 756 | } |
757 | -add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' ); |
|
757 | +add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content'); |
|
758 | 758 | |
759 | -function wpinv_paypal_get_transaction_id( $invoice_id ) { |
|
759 | +function wpinv_paypal_get_transaction_id($invoice_id) { |
|
760 | 760 | $transaction_id = ''; |
761 | - $notes = wpinv_get_invoice_notes( $invoice_id ); |
|
761 | + $notes = wpinv_get_invoice_notes($invoice_id); |
|
762 | 762 | |
763 | - foreach ( $notes as $note ) { |
|
764 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
763 | + foreach ($notes as $note) { |
|
764 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
765 | 765 | $transaction_id = $match[1]; |
766 | 766 | continue; |
767 | 767 | } |
768 | 768 | } |
769 | 769 | |
770 | - return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id ); |
|
770 | + return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id); |
|
771 | 771 | } |
772 | -add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 ); |
|
772 | +add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1); |
|
773 | 773 | |
774 | -function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) { |
|
775 | - if ( $invoice->is_free_trial() || $transaction_id == $invoice_id ) { // Free trial does not have transaction at PayPal. |
|
774 | +function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) { |
|
775 | + if ($invoice->is_free_trial() || $transaction_id == $invoice_id) { // Free trial does not have transaction at PayPal. |
|
776 | 776 | $transaction_url = $invoice->get_view_url(); |
777 | 777 | } else { |
778 | - $sandbox = wpinv_is_test_mode( 'paypal' ) ? '.sandbox' : ''; |
|
778 | + $sandbox = wpinv_is_test_mode('paypal') ? '.sandbox' : ''; |
|
779 | 779 | $transaction_url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=' . $transaction_id; |
780 | 780 | } |
781 | 781 | |
782 | - $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
782 | + $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>'; |
|
783 | 783 | |
784 | - return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $invoice ); |
|
784 | + return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $invoice); |
|
785 | 785 | } |
786 | -add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 ); |
|
786 | +add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3); |
|
787 | 787 | |
788 | 788 | function wpinv_gateway_paypal_button_label($label) { |
789 | - return __( 'Proceed to PayPal', 'invoicing' ); |
|
789 | + return __('Proceed to PayPal', 'invoicing'); |
|
790 | 790 | } |
791 | -add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 ); |
|
792 | 791 | \ No newline at end of file |
792 | +add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1); |
|
793 | 793 | \ No newline at end of file |
@@ -7,67 +7,67 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
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 | -function wpinv_is_base_country( $country ) { |
|
21 | +function wpinv_is_base_country($country) { |
|
22 | 22 | $base_country = wpinv_get_default_country(); |
23 | 23 | |
24 | - if ( $base_country === 'UK' ) { |
|
24 | + if ($base_country === 'UK') { |
|
25 | 25 | $base_country = 'GB'; |
26 | 26 | } |
27 | - if ( $country == 'UK' ) { |
|
27 | + if ($country == 'UK') { |
|
28 | 28 | $country = 'GB'; |
29 | 29 | } |
30 | 30 | |
31 | - return ( $country && $country === $base_country ) ? true : false; |
|
31 | + return ($country && $country === $base_country) ? true : false; |
|
32 | 32 | } |
33 | 33 | |
34 | -function wpinv_country_name( $country_code = '' ) { |
|
34 | +function wpinv_country_name($country_code = '') { |
|
35 | 35 | $countries = wpinv_get_country_list(); |
36 | 36 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
37 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
37 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
38 | 38 | |
39 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
39 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | function wpinv_get_default_state() { |
43 | - $state = wpinv_get_option( 'default_state', false ); |
|
43 | + $state = wpinv_get_option('default_state', false); |
|
44 | 44 | |
45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
45 | + return apply_filters('wpinv_default_state', $state); |
|
46 | 46 | } |
47 | 47 | |
48 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
48 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
49 | 49 | $state = $state_code; |
50 | 50 | |
51 | - if ( !empty( $country_code ) ) { |
|
52 | - $states = wpinv_get_country_states( $country_code ); |
|
51 | + if (!empty($country_code)) { |
|
52 | + $states = wpinv_get_country_states($country_code); |
|
53 | 53 | |
54 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
54 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
55 | 55 | } |
56 | 56 | |
57 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
57 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_store_address() { |
61 | - $address = wpinv_get_option( 'store_address', '' ); |
|
61 | + $address = wpinv_get_option('store_address', ''); |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_store_address', $address ); |
|
63 | + return apply_filters('wpinv_store_address', $address); |
|
64 | 64 | } |
65 | 65 | |
66 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
66 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
67 | 67 | global $wpi_userID; |
68 | 68 | |
69 | - if( empty( $user_id ) ) { |
|
70 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : get_current_user_id(); |
|
69 | + if (empty($user_id)) { |
|
70 | + $user_id = !empty($wpi_userID) ? $wpi_userID : get_current_user_id(); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $address_fields = array( |
@@ -85,36 +85,36 @@ discard block |
||
85 | 85 | 'zip', |
86 | 86 | ); |
87 | 87 | |
88 | - $user_info = get_userdata( $user_id ); |
|
88 | + $user_info = get_userdata($user_id); |
|
89 | 89 | |
90 | 90 | $address = array(); |
91 | 91 | $address['user_id'] = $user_id; |
92 | - $address['email'] = !empty( $user_info ) ? $user_info->user_email : ''; |
|
93 | - foreach ( $address_fields as $field ) { |
|
94 | - $address[$field] = get_user_meta( $user_id, '_wpinv_' . $field, true ); |
|
92 | + $address['email'] = !empty($user_info) ? $user_info->user_email : ''; |
|
93 | + foreach ($address_fields as $field) { |
|
94 | + $address[$field] = get_user_meta($user_id, '_wpinv_' . $field, true); |
|
95 | 95 | } |
96 | 96 | |
97 | - if ( !empty( $user_info ) ) { |
|
98 | - if( empty( $address['first_name'] ) ) |
|
97 | + if (!empty($user_info)) { |
|
98 | + if (empty($address['first_name'])) |
|
99 | 99 | $address['first_name'] = $user_info->first_name; |
100 | 100 | |
101 | - if( empty( $address['last_name'] ) ) |
|
101 | + if (empty($address['last_name'])) |
|
102 | 102 | $address['last_name'] = $user_info->last_name; |
103 | 103 | } |
104 | 104 | |
105 | - $address['name'] = trim( trim( $address['first_name'] . ' ' . $address['last_name'] ), "," ); |
|
105 | + $address['name'] = trim(trim($address['first_name'] . ' ' . $address['last_name']), ","); |
|
106 | 106 | |
107 | - if( empty( $address['state'] ) && $with_default ) |
|
107 | + if (empty($address['state']) && $with_default) |
|
108 | 108 | $address['state'] = wpinv_get_default_state(); |
109 | 109 | |
110 | - if( empty( $address['country'] ) && $with_default ) |
|
110 | + if (empty($address['country']) && $with_default) |
|
111 | 111 | $address['country'] = wpinv_get_default_country(); |
112 | 112 | |
113 | 113 | |
114 | 114 | return $address; |
115 | 115 | } |
116 | 116 | |
117 | -function wpinv_get_country_list( $first_empty = false ) { |
|
117 | +function wpinv_get_country_list($first_empty = false) { |
|
118 | 118 | $countries = array( |
119 | 119 | 'US' => __('United States', 'invoicing'), |
120 | 120 | 'CA' => __('Canada', 'invoicing'), |
@@ -370,23 +370,23 @@ discard block |
||
370 | 370 | 'ZW' => __('Zimbabwe', 'invoicing'), |
371 | 371 | ); |
372 | 372 | |
373 | - if ( $first_empty ) { |
|
374 | - $countries = array_merge( array( '' => '' ), $countries ); |
|
373 | + if ($first_empty) { |
|
374 | + $countries = array_merge(array('' => ''), $countries); |
|
375 | 375 | } |
376 | 376 | |
377 | - $countries = apply_filters( 'wpinv_countries', $countries ); |
|
377 | + $countries = apply_filters('wpinv_countries', $countries); |
|
378 | 378 | |
379 | 379 | asort($countries); |
380 | 380 | |
381 | 381 | return $countries; |
382 | 382 | } |
383 | 383 | |
384 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
385 | - if ( empty( $country ) ) { |
|
384 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
385 | + if (empty($country)) { |
|
386 | 386 | $country = wpinv_get_default_country(); |
387 | 387 | } |
388 | 388 | |
389 | - switch( $country ) { |
|
389 | + switch ($country) { |
|
390 | 390 | case 'US' : |
391 | 391 | $states = wpinv_get_us_states_list(); |
392 | 392 | break; |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | break; |
462 | 462 | } |
463 | 463 | |
464 | - if ( !empty( $states ) && $first_empty ) { |
|
465 | - $states = array_merge( array( '' => '' ), $states ); |
|
464 | + if (!empty($states) && $first_empty) { |
|
465 | + $states = array_merge(array('' => ''), $states); |
|
466 | 466 | } |
467 | 467 | |
468 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
468 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
469 | 469 | |
470 | 470 | asort($states); |
471 | 471 | |
@@ -474,1087 +474,1087 @@ discard block |
||
474 | 474 | |
475 | 475 | function wpinv_get_us_states_list() { |
476 | 476 | $states = array( |
477 | - 'AL' => __( 'Alabama', 'invoicing' ), |
|
478 | - 'AK' => __( 'Alaska', 'invoicing' ), |
|
479 | - 'AZ' => __( 'Arizona', 'invoicing' ), |
|
480 | - 'AR' => __( 'Arkansas', 'invoicing' ), |
|
481 | - 'CA' => __( 'California', 'invoicing' ), |
|
482 | - 'CO' => __( 'Colorado', 'invoicing' ), |
|
483 | - 'CT' => __( 'Connecticut', 'invoicing' ), |
|
484 | - 'DE' => __( 'Delaware', 'invoicing' ), |
|
485 | - 'DC' => __( 'District of Columbia', 'invoicing' ), |
|
486 | - 'FL' => __( 'Florida', 'invoicing' ), |
|
487 | - 'GA' => __( 'Georgia', 'invoicing' ), |
|
488 | - 'HI' => __( 'Hawaii', 'invoicing' ), |
|
489 | - 'ID' => __( 'Idaho', 'invoicing' ), |
|
490 | - 'IL' => __( 'Illinois', 'invoicing' ), |
|
491 | - 'IN' => __( 'Indiana', 'invoicing' ), |
|
492 | - 'IA' => __( 'Iowa', 'invoicing' ), |
|
493 | - 'KS' => __( 'Kansas', 'invoicing' ), |
|
494 | - 'KY' => __( 'Kentucky', 'invoicing' ), |
|
495 | - 'LA' => __( 'Louisiana', 'invoicing' ), |
|
496 | - 'ME' => __( 'Maine', 'invoicing' ), |
|
497 | - 'MD' => __( 'Maryland', 'invoicing' ), |
|
498 | - 'MA' => __( 'Massachusetts', 'invoicing' ), |
|
499 | - 'MI' => __( 'Michigan', 'invoicing' ), |
|
500 | - 'MN' => __( 'Minnesota', 'invoicing' ), |
|
501 | - 'MS' => __( 'Mississippi', 'invoicing' ), |
|
502 | - 'MO' => __( 'Missouri', 'invoicing' ), |
|
503 | - 'MT' => __( 'Montana', 'invoicing' ), |
|
504 | - 'NE' => __( 'Nebraska', 'invoicing' ), |
|
505 | - 'NV' => __( 'Nevada', 'invoicing' ), |
|
506 | - 'NH' => __( 'New Hampshire', 'invoicing' ), |
|
507 | - 'NJ' => __( 'New Jersey', 'invoicing' ), |
|
508 | - 'NM' => __( 'New Mexico', 'invoicing' ), |
|
509 | - 'NY' => __( 'New York', 'invoicing' ), |
|
510 | - 'NC' => __( 'North Carolina', 'invoicing' ), |
|
511 | - 'ND' => __( 'North Dakota', 'invoicing' ), |
|
512 | - 'OH' => __( 'Ohio', 'invoicing' ), |
|
513 | - 'OK' => __( 'Oklahoma', 'invoicing' ), |
|
514 | - 'OR' => __( 'Oregon', 'invoicing' ), |
|
515 | - 'PA' => __( 'Pennsylvania', 'invoicing' ), |
|
516 | - 'RI' => __( 'Rhode Island', 'invoicing' ), |
|
517 | - 'SC' => __( 'South Carolina', 'invoicing' ), |
|
518 | - 'SD' => __( 'South Dakota', 'invoicing' ), |
|
519 | - 'TN' => __( 'Tennessee', 'invoicing' ), |
|
520 | - 'TX' => __( 'Texas', 'invoicing' ), |
|
521 | - 'UT' => __( 'Utah', 'invoicing' ), |
|
522 | - 'VT' => __( 'Vermont', 'invoicing' ), |
|
523 | - 'VA' => __( 'Virginia', 'invoicing' ), |
|
524 | - 'WA' => __( 'Washington', 'invoicing' ), |
|
525 | - 'WV' => __( 'West Virginia', 'invoicing' ), |
|
526 | - 'WI' => __( 'Wisconsin', 'invoicing' ), |
|
527 | - 'WY' => __( 'Wyoming', 'invoicing' ), |
|
528 | - 'AS' => __( 'American Samoa', 'invoicing' ), |
|
529 | - 'CZ' => __( 'Canal Zone', 'invoicing' ), |
|
530 | - 'CM' => __( 'Commonwealth of the Northern Mariana Islands', 'invoicing' ), |
|
531 | - 'FM' => __( 'Federated States of Micronesia', 'invoicing' ), |
|
532 | - 'GU' => __( 'Guam', 'invoicing' ), |
|
533 | - 'MH' => __( 'Marshall Islands', 'invoicing' ), |
|
534 | - 'MP' => __( 'Northern Mariana Islands', 'invoicing' ), |
|
535 | - 'PW' => __( 'Palau', 'invoicing' ), |
|
536 | - 'PI' => __( 'Philippine Islands', 'invoicing' ), |
|
537 | - 'PR' => __( 'Puerto Rico', 'invoicing' ), |
|
538 | - 'TT' => __( 'Trust Territory of the Pacific Islands', 'invoicing' ), |
|
539 | - 'VI' => __( 'Virgin Islands', 'invoicing' ), |
|
540 | - 'AA' => __( 'Armed Forces - Americas', 'invoicing' ), |
|
541 | - 'AE' => __( 'Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing' ), |
|
542 | - 'AP' => __( 'Armed Forces - Pacific', 'invoicing' ) |
|
477 | + 'AL' => __('Alabama', 'invoicing'), |
|
478 | + 'AK' => __('Alaska', 'invoicing'), |
|
479 | + 'AZ' => __('Arizona', 'invoicing'), |
|
480 | + 'AR' => __('Arkansas', 'invoicing'), |
|
481 | + 'CA' => __('California', 'invoicing'), |
|
482 | + 'CO' => __('Colorado', 'invoicing'), |
|
483 | + 'CT' => __('Connecticut', 'invoicing'), |
|
484 | + 'DE' => __('Delaware', 'invoicing'), |
|
485 | + 'DC' => __('District of Columbia', 'invoicing'), |
|
486 | + 'FL' => __('Florida', 'invoicing'), |
|
487 | + 'GA' => __('Georgia', 'invoicing'), |
|
488 | + 'HI' => __('Hawaii', 'invoicing'), |
|
489 | + 'ID' => __('Idaho', 'invoicing'), |
|
490 | + 'IL' => __('Illinois', 'invoicing'), |
|
491 | + 'IN' => __('Indiana', 'invoicing'), |
|
492 | + 'IA' => __('Iowa', 'invoicing'), |
|
493 | + 'KS' => __('Kansas', 'invoicing'), |
|
494 | + 'KY' => __('Kentucky', 'invoicing'), |
|
495 | + 'LA' => __('Louisiana', 'invoicing'), |
|
496 | + 'ME' => __('Maine', 'invoicing'), |
|
497 | + 'MD' => __('Maryland', 'invoicing'), |
|
498 | + 'MA' => __('Massachusetts', 'invoicing'), |
|
499 | + 'MI' => __('Michigan', 'invoicing'), |
|
500 | + 'MN' => __('Minnesota', 'invoicing'), |
|
501 | + 'MS' => __('Mississippi', 'invoicing'), |
|
502 | + 'MO' => __('Missouri', 'invoicing'), |
|
503 | + 'MT' => __('Montana', 'invoicing'), |
|
504 | + 'NE' => __('Nebraska', 'invoicing'), |
|
505 | + 'NV' => __('Nevada', 'invoicing'), |
|
506 | + 'NH' => __('New Hampshire', 'invoicing'), |
|
507 | + 'NJ' => __('New Jersey', 'invoicing'), |
|
508 | + 'NM' => __('New Mexico', 'invoicing'), |
|
509 | + 'NY' => __('New York', 'invoicing'), |
|
510 | + 'NC' => __('North Carolina', 'invoicing'), |
|
511 | + 'ND' => __('North Dakota', 'invoicing'), |
|
512 | + 'OH' => __('Ohio', 'invoicing'), |
|
513 | + 'OK' => __('Oklahoma', 'invoicing'), |
|
514 | + 'OR' => __('Oregon', 'invoicing'), |
|
515 | + 'PA' => __('Pennsylvania', 'invoicing'), |
|
516 | + 'RI' => __('Rhode Island', 'invoicing'), |
|
517 | + 'SC' => __('South Carolina', 'invoicing'), |
|
518 | + 'SD' => __('South Dakota', 'invoicing'), |
|
519 | + 'TN' => __('Tennessee', 'invoicing'), |
|
520 | + 'TX' => __('Texas', 'invoicing'), |
|
521 | + 'UT' => __('Utah', 'invoicing'), |
|
522 | + 'VT' => __('Vermont', 'invoicing'), |
|
523 | + 'VA' => __('Virginia', 'invoicing'), |
|
524 | + 'WA' => __('Washington', 'invoicing'), |
|
525 | + 'WV' => __('West Virginia', 'invoicing'), |
|
526 | + 'WI' => __('Wisconsin', 'invoicing'), |
|
527 | + 'WY' => __('Wyoming', 'invoicing'), |
|
528 | + 'AS' => __('American Samoa', 'invoicing'), |
|
529 | + 'CZ' => __('Canal Zone', 'invoicing'), |
|
530 | + 'CM' => __('Commonwealth of the Northern Mariana Islands', 'invoicing'), |
|
531 | + 'FM' => __('Federated States of Micronesia', 'invoicing'), |
|
532 | + 'GU' => __('Guam', 'invoicing'), |
|
533 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
534 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
535 | + 'PW' => __('Palau', 'invoicing'), |
|
536 | + 'PI' => __('Philippine Islands', 'invoicing'), |
|
537 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
538 | + 'TT' => __('Trust Territory of the Pacific Islands', 'invoicing'), |
|
539 | + 'VI' => __('Virgin Islands', 'invoicing'), |
|
540 | + 'AA' => __('Armed Forces - Americas', 'invoicing'), |
|
541 | + 'AE' => __('Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing'), |
|
542 | + 'AP' => __('Armed Forces - Pacific', 'invoicing') |
|
543 | 543 | ); |
544 | 544 | |
545 | - return apply_filters( 'wpinv_us_states', $states ); |
|
545 | + return apply_filters('wpinv_us_states', $states); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | function wpinv_get_canada_states_list() { |
549 | 549 | $states = array( |
550 | - 'AB' => __( 'Alberta', 'invoicing' ), |
|
551 | - 'BC' => __( 'British Columbia', 'invoicing' ), |
|
552 | - 'MB' => __( 'Manitoba', 'invoicing' ), |
|
553 | - 'NB' => __( 'New Brunswick', 'invoicing' ), |
|
554 | - 'NL' => __( 'Newfoundland and Labrador', 'invoicing' ), |
|
555 | - 'NS' => __( 'Nova Scotia', 'invoicing' ), |
|
556 | - 'NT' => __( 'Northwest Territories', 'invoicing' ), |
|
557 | - 'NU' => __( 'Nunavut', 'invoicing' ), |
|
558 | - 'ON' => __( 'Ontario', 'invoicing' ), |
|
559 | - 'PE' => __( 'Prince Edward Island', 'invoicing' ), |
|
560 | - 'QC' => __( 'Quebec', 'invoicing' ), |
|
561 | - 'SK' => __( 'Saskatchewan', 'invoicing' ), |
|
562 | - 'YT' => __( 'Yukon', 'invoicing' ) |
|
550 | + 'AB' => __('Alberta', 'invoicing'), |
|
551 | + 'BC' => __('British Columbia', 'invoicing'), |
|
552 | + 'MB' => __('Manitoba', 'invoicing'), |
|
553 | + 'NB' => __('New Brunswick', 'invoicing'), |
|
554 | + 'NL' => __('Newfoundland and Labrador', 'invoicing'), |
|
555 | + 'NS' => __('Nova Scotia', 'invoicing'), |
|
556 | + 'NT' => __('Northwest Territories', 'invoicing'), |
|
557 | + 'NU' => __('Nunavut', 'invoicing'), |
|
558 | + 'ON' => __('Ontario', 'invoicing'), |
|
559 | + 'PE' => __('Prince Edward Island', 'invoicing'), |
|
560 | + 'QC' => __('Quebec', 'invoicing'), |
|
561 | + 'SK' => __('Saskatchewan', 'invoicing'), |
|
562 | + 'YT' => __('Yukon', 'invoicing') |
|
563 | 563 | ); |
564 | 564 | |
565 | - return apply_filters( 'wpinv_canada_provinces', $states ); |
|
565 | + return apply_filters('wpinv_canada_provinces', $states); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | function wpinv_get_australia_states_list() { |
569 | 569 | $states = array( |
570 | - 'ACT' => __( 'Australian Capital Territory', 'invoicing' ), |
|
571 | - 'NSW' => __( 'New South Wales', 'invoicing' ), |
|
572 | - 'NT' => __( 'Northern Territory', 'invoicing' ), |
|
573 | - 'QLD' => __( 'Queensland', 'invoicing' ), |
|
574 | - 'SA' => __( 'South Australia', 'invoicing' ), |
|
575 | - 'TAS' => __( 'Tasmania', 'invoicing' ), |
|
576 | - 'VIC' => __( 'Victoria', 'invoicing' ), |
|
577 | - 'WA' => __( 'Western Australia', 'invoicing' ) |
|
570 | + 'ACT' => __('Australian Capital Territory', 'invoicing'), |
|
571 | + 'NSW' => __('New South Wales', 'invoicing'), |
|
572 | + 'NT' => __('Northern Territory', 'invoicing'), |
|
573 | + 'QLD' => __('Queensland', 'invoicing'), |
|
574 | + 'SA' => __('South Australia', 'invoicing'), |
|
575 | + 'TAS' => __('Tasmania', 'invoicing'), |
|
576 | + 'VIC' => __('Victoria', 'invoicing'), |
|
577 | + 'WA' => __('Western Australia', 'invoicing') |
|
578 | 578 | ); |
579 | 579 | |
580 | - return apply_filters( 'wpinv_australia_states', $states ); |
|
580 | + return apply_filters('wpinv_australia_states', $states); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | function wpinv_get_bangladesh_states_list() { |
584 | 584 | $states = array( |
585 | - 'BAG' => __( 'Bagerhat', 'invoicing' ), |
|
586 | - 'BAN' => __( 'Bandarban', 'invoicing' ), |
|
587 | - 'BAR' => __( 'Barguna', 'invoicing' ), |
|
588 | - 'BARI'=> __( 'Barisal', 'invoicing' ), |
|
589 | - 'BHO' => __( 'Bhola', 'invoicing' ), |
|
590 | - 'BOG' => __( 'Bogra', 'invoicing' ), |
|
591 | - 'BRA' => __( 'Brahmanbaria', 'invoicing' ), |
|
592 | - 'CHA' => __( 'Chandpur', 'invoicing' ), |
|
593 | - 'CHI' => __( 'Chittagong', 'invoicing' ), |
|
594 | - 'CHU' => __( 'Chuadanga', 'invoicing' ), |
|
595 | - 'COM' => __( 'Comilla', 'invoicing' ), |
|
596 | - 'COX' => __( 'Cox\'s Bazar', 'invoicing' ), |
|
597 | - 'DHA' => __( 'Dhaka', 'invoicing' ), |
|
598 | - 'DIN' => __( 'Dinajpur', 'invoicing' ), |
|
599 | - 'FAR' => __( 'Faridpur', 'invoicing' ), |
|
600 | - 'FEN' => __( 'Feni', 'invoicing' ), |
|
601 | - 'GAI' => __( 'Gaibandha', 'invoicing' ), |
|
602 | - 'GAZI'=> __( 'Gazipur', 'invoicing' ), |
|
603 | - 'GOP' => __( 'Gopalganj', 'invoicing' ), |
|
604 | - 'HAB' => __( 'Habiganj', 'invoicing' ), |
|
605 | - 'JAM' => __( 'Jamalpur', 'invoicing' ), |
|
606 | - 'JES' => __( 'Jessore', 'invoicing' ), |
|
607 | - 'JHA' => __( 'Jhalokati', 'invoicing' ), |
|
608 | - 'JHE' => __( 'Jhenaidah', 'invoicing' ), |
|
609 | - 'JOY' => __( 'Joypurhat', 'invoicing' ), |
|
610 | - 'KHA' => __( 'Khagrachhari', 'invoicing' ), |
|
611 | - 'KHU' => __( 'Khulna', 'invoicing' ), |
|
612 | - 'KIS' => __( 'Kishoreganj', 'invoicing' ), |
|
613 | - 'KUR' => __( 'Kurigram', 'invoicing' ), |
|
614 | - 'KUS' => __( 'Kushtia', 'invoicing' ), |
|
615 | - 'LAK' => __( 'Lakshmipur', 'invoicing' ), |
|
616 | - 'LAL' => __( 'Lalmonirhat', 'invoicing' ), |
|
617 | - 'MAD' => __( 'Madaripur', 'invoicing' ), |
|
618 | - 'MAG' => __( 'Magura', 'invoicing' ), |
|
619 | - 'MAN' => __( 'Manikganj', 'invoicing' ), |
|
620 | - 'MEH' => __( 'Meherpur', 'invoicing' ), |
|
621 | - 'MOU' => __( 'Moulvibazar', 'invoicing' ), |
|
622 | - 'MUN' => __( 'Munshiganj', 'invoicing' ), |
|
623 | - 'MYM' => __( 'Mymensingh', 'invoicing' ), |
|
624 | - 'NAO' => __( 'Naogaon', 'invoicing' ), |
|
625 | - 'NAR' => __( 'Narail', 'invoicing' ), |
|
626 | - 'NARG'=> __( 'Narayanganj', 'invoicing' ), |
|
627 | - 'NARD'=> __( 'Narsingdi', 'invoicing' ), |
|
628 | - 'NAT' => __( 'Natore', 'invoicing' ), |
|
629 | - 'NAW' => __( 'Nawabganj', 'invoicing' ), |
|
630 | - 'NET' => __( 'Netrakona', 'invoicing' ), |
|
631 | - 'NIL' => __( 'Nilphamari', 'invoicing' ), |
|
632 | - 'NOA' => __( 'Noakhali', 'invoicing' ), |
|
633 | - 'PAB' => __( 'Pabna', 'invoicing' ), |
|
634 | - 'PAN' => __( 'Panchagarh', 'invoicing' ), |
|
635 | - 'PAT' => __( 'Patuakhali', 'invoicing' ), |
|
636 | - 'PIR' => __( 'Pirojpur', 'invoicing' ), |
|
637 | - 'RAJB'=> __( 'Rajbari', 'invoicing' ), |
|
638 | - 'RAJ' => __( 'Rajshahi', 'invoicing' ), |
|
639 | - 'RAN' => __( 'Rangamati', 'invoicing' ), |
|
640 | - 'RANP'=> __( 'Rangpur', 'invoicing' ), |
|
641 | - 'SAT' => __( 'Satkhira', 'invoicing' ), |
|
642 | - 'SHA' => __( 'Shariatpur', 'invoicing' ), |
|
643 | - 'SHE' => __( 'Sherpur', 'invoicing' ), |
|
644 | - 'SIR' => __( 'Sirajganj', 'invoicing' ), |
|
645 | - 'SUN' => __( 'Sunamganj', 'invoicing' ), |
|
646 | - 'SYL' => __( 'Sylhet', 'invoicing' ), |
|
647 | - 'TAN' => __( 'Tangail', 'invoicing' ), |
|
648 | - 'THA' => __( 'Thakurgaon', 'invoicing' ) |
|
585 | + 'BAG' => __('Bagerhat', 'invoicing'), |
|
586 | + 'BAN' => __('Bandarban', 'invoicing'), |
|
587 | + 'BAR' => __('Barguna', 'invoicing'), |
|
588 | + 'BARI'=> __('Barisal', 'invoicing'), |
|
589 | + 'BHO' => __('Bhola', 'invoicing'), |
|
590 | + 'BOG' => __('Bogra', 'invoicing'), |
|
591 | + 'BRA' => __('Brahmanbaria', 'invoicing'), |
|
592 | + 'CHA' => __('Chandpur', 'invoicing'), |
|
593 | + 'CHI' => __('Chittagong', 'invoicing'), |
|
594 | + 'CHU' => __('Chuadanga', 'invoicing'), |
|
595 | + 'COM' => __('Comilla', 'invoicing'), |
|
596 | + 'COX' => __('Cox\'s Bazar', 'invoicing'), |
|
597 | + 'DHA' => __('Dhaka', 'invoicing'), |
|
598 | + 'DIN' => __('Dinajpur', 'invoicing'), |
|
599 | + 'FAR' => __('Faridpur', 'invoicing'), |
|
600 | + 'FEN' => __('Feni', 'invoicing'), |
|
601 | + 'GAI' => __('Gaibandha', 'invoicing'), |
|
602 | + 'GAZI'=> __('Gazipur', 'invoicing'), |
|
603 | + 'GOP' => __('Gopalganj', 'invoicing'), |
|
604 | + 'HAB' => __('Habiganj', 'invoicing'), |
|
605 | + 'JAM' => __('Jamalpur', 'invoicing'), |
|
606 | + 'JES' => __('Jessore', 'invoicing'), |
|
607 | + 'JHA' => __('Jhalokati', 'invoicing'), |
|
608 | + 'JHE' => __('Jhenaidah', 'invoicing'), |
|
609 | + 'JOY' => __('Joypurhat', 'invoicing'), |
|
610 | + 'KHA' => __('Khagrachhari', 'invoicing'), |
|
611 | + 'KHU' => __('Khulna', 'invoicing'), |
|
612 | + 'KIS' => __('Kishoreganj', 'invoicing'), |
|
613 | + 'KUR' => __('Kurigram', 'invoicing'), |
|
614 | + 'KUS' => __('Kushtia', 'invoicing'), |
|
615 | + 'LAK' => __('Lakshmipur', 'invoicing'), |
|
616 | + 'LAL' => __('Lalmonirhat', 'invoicing'), |
|
617 | + 'MAD' => __('Madaripur', 'invoicing'), |
|
618 | + 'MAG' => __('Magura', 'invoicing'), |
|
619 | + 'MAN' => __('Manikganj', 'invoicing'), |
|
620 | + 'MEH' => __('Meherpur', 'invoicing'), |
|
621 | + 'MOU' => __('Moulvibazar', 'invoicing'), |
|
622 | + 'MUN' => __('Munshiganj', 'invoicing'), |
|
623 | + 'MYM' => __('Mymensingh', 'invoicing'), |
|
624 | + 'NAO' => __('Naogaon', 'invoicing'), |
|
625 | + 'NAR' => __('Narail', 'invoicing'), |
|
626 | + 'NARG'=> __('Narayanganj', 'invoicing'), |
|
627 | + 'NARD'=> __('Narsingdi', 'invoicing'), |
|
628 | + 'NAT' => __('Natore', 'invoicing'), |
|
629 | + 'NAW' => __('Nawabganj', 'invoicing'), |
|
630 | + 'NET' => __('Netrakona', 'invoicing'), |
|
631 | + 'NIL' => __('Nilphamari', 'invoicing'), |
|
632 | + 'NOA' => __('Noakhali', 'invoicing'), |
|
633 | + 'PAB' => __('Pabna', 'invoicing'), |
|
634 | + 'PAN' => __('Panchagarh', 'invoicing'), |
|
635 | + 'PAT' => __('Patuakhali', 'invoicing'), |
|
636 | + 'PIR' => __('Pirojpur', 'invoicing'), |
|
637 | + 'RAJB'=> __('Rajbari', 'invoicing'), |
|
638 | + 'RAJ' => __('Rajshahi', 'invoicing'), |
|
639 | + 'RAN' => __('Rangamati', 'invoicing'), |
|
640 | + 'RANP'=> __('Rangpur', 'invoicing'), |
|
641 | + 'SAT' => __('Satkhira', 'invoicing'), |
|
642 | + 'SHA' => __('Shariatpur', 'invoicing'), |
|
643 | + 'SHE' => __('Sherpur', 'invoicing'), |
|
644 | + 'SIR' => __('Sirajganj', 'invoicing'), |
|
645 | + 'SUN' => __('Sunamganj', 'invoicing'), |
|
646 | + 'SYL' => __('Sylhet', 'invoicing'), |
|
647 | + 'TAN' => __('Tangail', 'invoicing'), |
|
648 | + 'THA' => __('Thakurgaon', 'invoicing') |
|
649 | 649 | ); |
650 | 650 | |
651 | - return apply_filters( 'wpinv_bangladesh_states', $states ); |
|
651 | + return apply_filters('wpinv_bangladesh_states', $states); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | function wpinv_get_brazil_states_list() { |
655 | 655 | $states = array( |
656 | - 'AC' => __( 'Acre', 'invoicing' ), |
|
657 | - 'AL' => __( 'Alagoas', 'invoicing' ), |
|
658 | - 'AP' => __( 'Amapá', 'invoicing' ), |
|
659 | - 'AM' => __( 'Amazonas', 'invoicing' ), |
|
660 | - 'BA' => __( 'Bahia', 'invoicing' ), |
|
661 | - 'CE' => __( 'Ceará', 'invoicing' ), |
|
662 | - 'DF' => __( 'Distrito Federal', 'invoicing' ), |
|
663 | - 'ES' => __( 'Espírito Santo', 'invoicing' ), |
|
664 | - 'GO' => __( 'Goiás', 'invoicing' ), |
|
665 | - 'MA' => __( 'Maranhão', 'invoicing' ), |
|
666 | - 'MT' => __( 'Mato Grosso', 'invoicing' ), |
|
667 | - 'MS' => __( 'Mato Grosso do Sul', 'invoicing' ), |
|
668 | - 'MG' => __( 'Minas Gerais', 'invoicing' ), |
|
669 | - 'PA' => __( 'Pará', 'invoicing' ), |
|
670 | - 'PB' => __( 'Paraíba', 'invoicing' ), |
|
671 | - 'PR' => __( 'Paraná', 'invoicing' ), |
|
672 | - 'PE' => __( 'Pernambuco', 'invoicing' ), |
|
673 | - 'PI' => __( 'Piauí', 'invoicing' ), |
|
674 | - 'RJ' => __( 'Rio de Janeiro', 'invoicing' ), |
|
675 | - 'RN' => __( 'Rio Grande do Norte', 'invoicing' ), |
|
676 | - 'RS' => __( 'Rio Grande do Sul', 'invoicing' ), |
|
677 | - 'RO' => __( 'Rondônia', 'invoicing' ), |
|
678 | - 'RR' => __( 'Roraima', 'invoicing' ), |
|
679 | - 'SC' => __( 'Santa Catarina', 'invoicing' ), |
|
680 | - 'SP' => __( 'São Paulo', 'invoicing' ), |
|
681 | - 'SE' => __( 'Sergipe', 'invoicing' ), |
|
682 | - 'TO' => __( 'Tocantins', 'invoicing' ) |
|
656 | + 'AC' => __('Acre', 'invoicing'), |
|
657 | + 'AL' => __('Alagoas', 'invoicing'), |
|
658 | + 'AP' => __('Amapá', 'invoicing'), |
|
659 | + 'AM' => __('Amazonas', 'invoicing'), |
|
660 | + 'BA' => __('Bahia', 'invoicing'), |
|
661 | + 'CE' => __('Ceará', 'invoicing'), |
|
662 | + 'DF' => __('Distrito Federal', 'invoicing'), |
|
663 | + 'ES' => __('Espírito Santo', 'invoicing'), |
|
664 | + 'GO' => __('Goiás', 'invoicing'), |
|
665 | + 'MA' => __('Maranhão', 'invoicing'), |
|
666 | + 'MT' => __('Mato Grosso', 'invoicing'), |
|
667 | + 'MS' => __('Mato Grosso do Sul', 'invoicing'), |
|
668 | + 'MG' => __('Minas Gerais', 'invoicing'), |
|
669 | + 'PA' => __('Pará', 'invoicing'), |
|
670 | + 'PB' => __('Paraíba', 'invoicing'), |
|
671 | + 'PR' => __('Paraná', 'invoicing'), |
|
672 | + 'PE' => __('Pernambuco', 'invoicing'), |
|
673 | + 'PI' => __('Piauí', 'invoicing'), |
|
674 | + 'RJ' => __('Rio de Janeiro', 'invoicing'), |
|
675 | + 'RN' => __('Rio Grande do Norte', 'invoicing'), |
|
676 | + 'RS' => __('Rio Grande do Sul', 'invoicing'), |
|
677 | + 'RO' => __('Rondônia', 'invoicing'), |
|
678 | + 'RR' => __('Roraima', 'invoicing'), |
|
679 | + 'SC' => __('Santa Catarina', 'invoicing'), |
|
680 | + 'SP' => __('São Paulo', 'invoicing'), |
|
681 | + 'SE' => __('Sergipe', 'invoicing'), |
|
682 | + 'TO' => __('Tocantins', 'invoicing') |
|
683 | 683 | ); |
684 | 684 | |
685 | - return apply_filters( 'wpinv_brazil_states', $states ); |
|
685 | + return apply_filters('wpinv_brazil_states', $states); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | function wpinv_get_bulgaria_states_list() { |
689 | 689 | $states = array( |
690 | - 'BG-01' => __( 'Blagoevgrad', 'invoicing' ), |
|
691 | - 'BG-02' => __( 'Burgas', 'invoicing' ), |
|
692 | - 'BG-08' => __( 'Dobrich', 'invoicing' ), |
|
693 | - 'BG-07' => __( 'Gabrovo', 'invoicing' ), |
|
694 | - 'BG-26' => __( 'Haskovo', 'invoicing' ), |
|
695 | - 'BG-09' => __( 'Kardzhali', 'invoicing' ), |
|
696 | - 'BG-10' => __( 'Kyustendil', 'invoicing' ), |
|
697 | - 'BG-11' => __( 'Lovech', 'invoicing' ), |
|
698 | - 'BG-12' => __( 'Montana', 'invoicing' ), |
|
699 | - 'BG-13' => __( 'Pazardzhik', 'invoicing' ), |
|
700 | - 'BG-14' => __( 'Pernik', 'invoicing' ), |
|
701 | - 'BG-15' => __( 'Pleven', 'invoicing' ), |
|
702 | - 'BG-16' => __( 'Plovdiv', 'invoicing' ), |
|
703 | - 'BG-17' => __( 'Razgrad', 'invoicing' ), |
|
704 | - 'BG-18' => __( 'Ruse', 'invoicing' ), |
|
705 | - 'BG-27' => __( 'Shumen', 'invoicing' ), |
|
706 | - 'BG-19' => __( 'Silistra', 'invoicing' ), |
|
707 | - 'BG-20' => __( 'Sliven', 'invoicing' ), |
|
708 | - 'BG-21' => __( 'Smolyan', 'invoicing' ), |
|
709 | - 'BG-23' => __( 'Sofia', 'invoicing' ), |
|
710 | - 'BG-22' => __( 'Sofia-Grad', 'invoicing' ), |
|
711 | - 'BG-24' => __( 'Stara Zagora', 'invoicing' ), |
|
712 | - 'BG-25' => __( 'Targovishte', 'invoicing' ), |
|
713 | - 'BG-03' => __( 'Varna', 'invoicing' ), |
|
714 | - 'BG-04' => __( 'Veliko Tarnovo', 'invoicing' ), |
|
715 | - 'BG-05' => __( 'Vidin', 'invoicing' ), |
|
716 | - 'BG-06' => __( 'Vratsa', 'invoicing' ), |
|
717 | - 'BG-28' => __( 'Yambol', 'invoicing' ) |
|
690 | + 'BG-01' => __('Blagoevgrad', 'invoicing'), |
|
691 | + 'BG-02' => __('Burgas', 'invoicing'), |
|
692 | + 'BG-08' => __('Dobrich', 'invoicing'), |
|
693 | + 'BG-07' => __('Gabrovo', 'invoicing'), |
|
694 | + 'BG-26' => __('Haskovo', 'invoicing'), |
|
695 | + 'BG-09' => __('Kardzhali', 'invoicing'), |
|
696 | + 'BG-10' => __('Kyustendil', 'invoicing'), |
|
697 | + 'BG-11' => __('Lovech', 'invoicing'), |
|
698 | + 'BG-12' => __('Montana', 'invoicing'), |
|
699 | + 'BG-13' => __('Pazardzhik', 'invoicing'), |
|
700 | + 'BG-14' => __('Pernik', 'invoicing'), |
|
701 | + 'BG-15' => __('Pleven', 'invoicing'), |
|
702 | + 'BG-16' => __('Plovdiv', 'invoicing'), |
|
703 | + 'BG-17' => __('Razgrad', 'invoicing'), |
|
704 | + 'BG-18' => __('Ruse', 'invoicing'), |
|
705 | + 'BG-27' => __('Shumen', 'invoicing'), |
|
706 | + 'BG-19' => __('Silistra', 'invoicing'), |
|
707 | + 'BG-20' => __('Sliven', 'invoicing'), |
|
708 | + 'BG-21' => __('Smolyan', 'invoicing'), |
|
709 | + 'BG-23' => __('Sofia', 'invoicing'), |
|
710 | + 'BG-22' => __('Sofia-Grad', 'invoicing'), |
|
711 | + 'BG-24' => __('Stara Zagora', 'invoicing'), |
|
712 | + 'BG-25' => __('Targovishte', 'invoicing'), |
|
713 | + 'BG-03' => __('Varna', 'invoicing'), |
|
714 | + 'BG-04' => __('Veliko Tarnovo', 'invoicing'), |
|
715 | + 'BG-05' => __('Vidin', 'invoicing'), |
|
716 | + 'BG-06' => __('Vratsa', 'invoicing'), |
|
717 | + 'BG-28' => __('Yambol', 'invoicing') |
|
718 | 718 | ); |
719 | 719 | |
720 | - return apply_filters( 'wpinv_bulgaria_states', $states ); |
|
720 | + return apply_filters('wpinv_bulgaria_states', $states); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | function wpinv_get_hong_kong_states_list() { |
724 | 724 | $states = array( |
725 | - 'HONG KONG' => __( 'Hong Kong Island', 'invoicing' ), |
|
726 | - 'KOWLOON' => __( 'Kowloon', 'invoicing' ), |
|
727 | - 'NEW TERRITORIES' => __( 'New Territories', 'invoicing' ) |
|
725 | + 'HONG KONG' => __('Hong Kong Island', 'invoicing'), |
|
726 | + 'KOWLOON' => __('Kowloon', 'invoicing'), |
|
727 | + 'NEW TERRITORIES' => __('New Territories', 'invoicing') |
|
728 | 728 | ); |
729 | 729 | |
730 | - return apply_filters( 'wpinv_hong_kong_states', $states ); |
|
730 | + return apply_filters('wpinv_hong_kong_states', $states); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | function wpinv_get_hungary_states_list() { |
734 | 734 | $states = array( |
735 | - 'BK' => __( 'Bács-Kiskun', 'invoicing' ), |
|
736 | - 'BE' => __( 'Békés', 'invoicing' ), |
|
737 | - 'BA' => __( 'Baranya', 'invoicing' ), |
|
738 | - 'BZ' => __( 'Borsod-Abaúj-Zemplén', 'invoicing' ), |
|
739 | - 'BU' => __( 'Budapest', 'invoicing' ), |
|
740 | - 'CS' => __( 'Csongrád', 'invoicing' ), |
|
741 | - 'FE' => __( 'Fejér', 'invoicing' ), |
|
742 | - 'GS' => __( 'Győr-Moson-Sopron', 'invoicing' ), |
|
743 | - 'HB' => __( 'Hajdú-Bihar', 'invoicing' ), |
|
744 | - 'HE' => __( 'Heves', 'invoicing' ), |
|
745 | - 'JN' => __( 'Jász-Nagykun-Szolnok', 'invoicing' ), |
|
746 | - 'KE' => __( 'Komárom-Esztergom', 'invoicing' ), |
|
747 | - 'NO' => __( 'Nógrád', 'invoicing' ), |
|
748 | - 'PE' => __( 'Pest', 'invoicing' ), |
|
749 | - 'SO' => __( 'Somogy', 'invoicing' ), |
|
750 | - 'SZ' => __( 'Szabolcs-Szatmár-Bereg', 'invoicing' ), |
|
751 | - 'TO' => __( 'Tolna', 'invoicing' ), |
|
752 | - 'VA' => __( 'Vas', 'invoicing' ), |
|
753 | - 'VE' => __( 'Veszprém', 'invoicing' ), |
|
754 | - 'ZA' => __( 'Zala', 'invoicing' ) |
|
735 | + 'BK' => __('Bács-Kiskun', 'invoicing'), |
|
736 | + 'BE' => __('Békés', 'invoicing'), |
|
737 | + 'BA' => __('Baranya', 'invoicing'), |
|
738 | + 'BZ' => __('Borsod-Abaúj-Zemplén', 'invoicing'), |
|
739 | + 'BU' => __('Budapest', 'invoicing'), |
|
740 | + 'CS' => __('Csongrád', 'invoicing'), |
|
741 | + 'FE' => __('Fejér', 'invoicing'), |
|
742 | + 'GS' => __('Győr-Moson-Sopron', 'invoicing'), |
|
743 | + 'HB' => __('Hajdú-Bihar', 'invoicing'), |
|
744 | + 'HE' => __('Heves', 'invoicing'), |
|
745 | + 'JN' => __('Jász-Nagykun-Szolnok', 'invoicing'), |
|
746 | + 'KE' => __('Komárom-Esztergom', 'invoicing'), |
|
747 | + 'NO' => __('Nógrád', 'invoicing'), |
|
748 | + 'PE' => __('Pest', 'invoicing'), |
|
749 | + 'SO' => __('Somogy', 'invoicing'), |
|
750 | + 'SZ' => __('Szabolcs-Szatmár-Bereg', 'invoicing'), |
|
751 | + 'TO' => __('Tolna', 'invoicing'), |
|
752 | + 'VA' => __('Vas', 'invoicing'), |
|
753 | + 'VE' => __('Veszprém', 'invoicing'), |
|
754 | + 'ZA' => __('Zala', 'invoicing') |
|
755 | 755 | ); |
756 | 756 | |
757 | - return apply_filters( 'wpinv_hungary_states', $states ); |
|
757 | + return apply_filters('wpinv_hungary_states', $states); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | function wpinv_get_japan_states_list() { |
761 | 761 | $states = array( |
762 | - 'JP01' => __( 'Hokkaido', 'invoicing' ), |
|
763 | - 'JP02' => __( 'Aomori', 'invoicing' ), |
|
764 | - 'JP03' => __( 'Iwate', 'invoicing' ), |
|
765 | - 'JP04' => __( 'Miyagi', 'invoicing' ), |
|
766 | - 'JP05' => __( 'Akita', 'invoicing' ), |
|
767 | - 'JP06' => __( 'Yamagata', 'invoicing' ), |
|
768 | - 'JP07' => __( 'Fukushima', 'invoicing' ), |
|
769 | - 'JP08' => __( 'Ibaraki', 'invoicing' ), |
|
770 | - 'JP09' => __( 'Tochigi', 'invoicing' ), |
|
771 | - 'JP10' => __( 'Gunma', 'invoicing' ), |
|
772 | - 'JP11' => __( 'Saitama', 'invoicing' ), |
|
773 | - 'JP12' => __( 'Chiba', 'invoicing' ), |
|
774 | - 'JP13' => __( 'Tokyo', 'invoicing' ), |
|
775 | - 'JP14' => __( 'Kanagawa', 'invoicing' ), |
|
776 | - 'JP15' => __( 'Niigata', 'invoicing' ), |
|
777 | - 'JP16' => __( 'Toyama', 'invoicing' ), |
|
778 | - 'JP17' => __( 'Ishikawa', 'invoicing' ), |
|
779 | - 'JP18' => __( 'Fukui', 'invoicing' ), |
|
780 | - 'JP19' => __( 'Yamanashi', 'invoicing' ), |
|
781 | - 'JP20' => __( 'Nagano', 'invoicing' ), |
|
782 | - 'JP21' => __( 'Gifu', 'invoicing' ), |
|
783 | - 'JP22' => __( 'Shizuoka', 'invoicing' ), |
|
784 | - 'JP23' => __( 'Aichi', 'invoicing' ), |
|
785 | - 'JP24' => __( 'Mie', 'invoicing' ), |
|
786 | - 'JP25' => __( 'Shiga', 'invoicing' ), |
|
787 | - 'JP26' => __( 'Kyouto', 'invoicing' ), |
|
788 | - 'JP27' => __( 'Osaka', 'invoicing' ), |
|
789 | - 'JP28' => __( 'Hyougo', 'invoicing' ), |
|
790 | - 'JP29' => __( 'Nara', 'invoicing' ), |
|
791 | - 'JP30' => __( 'Wakayama', 'invoicing' ), |
|
792 | - 'JP31' => __( 'Tottori', 'invoicing' ), |
|
793 | - 'JP32' => __( 'Shimane', 'invoicing' ), |
|
794 | - 'JP33' => __( 'Okayama', 'invoicing' ), |
|
795 | - 'JP34' => __( 'Hiroshima', 'invoicing' ), |
|
796 | - 'JP35' => __( 'Yamaguchi', 'invoicing' ), |
|
797 | - 'JP36' => __( 'Tokushima', 'invoicing' ), |
|
798 | - 'JP37' => __( 'Kagawa', 'invoicing' ), |
|
799 | - 'JP38' => __( 'Ehime', 'invoicing' ), |
|
800 | - 'JP39' => __( 'Kochi', 'invoicing' ), |
|
801 | - 'JP40' => __( 'Fukuoka', 'invoicing' ), |
|
802 | - 'JP41' => __( 'Saga', 'invoicing' ), |
|
803 | - 'JP42' => __( 'Nagasaki', 'invoicing' ), |
|
804 | - 'JP43' => __( 'Kumamoto', 'invoicing' ), |
|
805 | - 'JP44' => __( 'Oita', 'invoicing' ), |
|
806 | - 'JP45' => __( 'Miyazaki', 'invoicing' ), |
|
807 | - 'JP46' => __( 'Kagoshima', 'invoicing' ), |
|
808 | - 'JP47' => __( 'Okinawa', 'invoicing' ) |
|
762 | + 'JP01' => __('Hokkaido', 'invoicing'), |
|
763 | + 'JP02' => __('Aomori', 'invoicing'), |
|
764 | + 'JP03' => __('Iwate', 'invoicing'), |
|
765 | + 'JP04' => __('Miyagi', 'invoicing'), |
|
766 | + 'JP05' => __('Akita', 'invoicing'), |
|
767 | + 'JP06' => __('Yamagata', 'invoicing'), |
|
768 | + 'JP07' => __('Fukushima', 'invoicing'), |
|
769 | + 'JP08' => __('Ibaraki', 'invoicing'), |
|
770 | + 'JP09' => __('Tochigi', 'invoicing'), |
|
771 | + 'JP10' => __('Gunma', 'invoicing'), |
|
772 | + 'JP11' => __('Saitama', 'invoicing'), |
|
773 | + 'JP12' => __('Chiba', 'invoicing'), |
|
774 | + 'JP13' => __('Tokyo', 'invoicing'), |
|
775 | + 'JP14' => __('Kanagawa', 'invoicing'), |
|
776 | + 'JP15' => __('Niigata', 'invoicing'), |
|
777 | + 'JP16' => __('Toyama', 'invoicing'), |
|
778 | + 'JP17' => __('Ishikawa', 'invoicing'), |
|
779 | + 'JP18' => __('Fukui', 'invoicing'), |
|
780 | + 'JP19' => __('Yamanashi', 'invoicing'), |
|
781 | + 'JP20' => __('Nagano', 'invoicing'), |
|
782 | + 'JP21' => __('Gifu', 'invoicing'), |
|
783 | + 'JP22' => __('Shizuoka', 'invoicing'), |
|
784 | + 'JP23' => __('Aichi', 'invoicing'), |
|
785 | + 'JP24' => __('Mie', 'invoicing'), |
|
786 | + 'JP25' => __('Shiga', 'invoicing'), |
|
787 | + 'JP26' => __('Kyouto', 'invoicing'), |
|
788 | + 'JP27' => __('Osaka', 'invoicing'), |
|
789 | + 'JP28' => __('Hyougo', 'invoicing'), |
|
790 | + 'JP29' => __('Nara', 'invoicing'), |
|
791 | + 'JP30' => __('Wakayama', 'invoicing'), |
|
792 | + 'JP31' => __('Tottori', 'invoicing'), |
|
793 | + 'JP32' => __('Shimane', 'invoicing'), |
|
794 | + 'JP33' => __('Okayama', 'invoicing'), |
|
795 | + 'JP34' => __('Hiroshima', 'invoicing'), |
|
796 | + 'JP35' => __('Yamaguchi', 'invoicing'), |
|
797 | + 'JP36' => __('Tokushima', 'invoicing'), |
|
798 | + 'JP37' => __('Kagawa', 'invoicing'), |
|
799 | + 'JP38' => __('Ehime', 'invoicing'), |
|
800 | + 'JP39' => __('Kochi', 'invoicing'), |
|
801 | + 'JP40' => __('Fukuoka', 'invoicing'), |
|
802 | + 'JP41' => __('Saga', 'invoicing'), |
|
803 | + 'JP42' => __('Nagasaki', 'invoicing'), |
|
804 | + 'JP43' => __('Kumamoto', 'invoicing'), |
|
805 | + 'JP44' => __('Oita', 'invoicing'), |
|
806 | + 'JP45' => __('Miyazaki', 'invoicing'), |
|
807 | + 'JP46' => __('Kagoshima', 'invoicing'), |
|
808 | + 'JP47' => __('Okinawa', 'invoicing') |
|
809 | 809 | ); |
810 | 810 | |
811 | - return apply_filters( 'wpinv_japan_states', $states ); |
|
811 | + return apply_filters('wpinv_japan_states', $states); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | function wpinv_get_china_states_list() { |
815 | 815 | $states = array( |
816 | - 'CN1' => __( 'Yunnan / 云南', 'invoicing' ), |
|
817 | - 'CN2' => __( 'Beijing / 北京', 'invoicing' ), |
|
818 | - 'CN3' => __( 'Tianjin / 天津', 'invoicing' ), |
|
819 | - 'CN4' => __( 'Hebei / 河北', 'invoicing' ), |
|
820 | - 'CN5' => __( 'Shanxi / 山西', 'invoicing' ), |
|
821 | - 'CN6' => __( 'Inner Mongolia / 內蒙古', 'invoicing' ), |
|
822 | - 'CN7' => __( 'Liaoning / 辽宁', 'invoicing' ), |
|
823 | - 'CN8' => __( 'Jilin / 吉林', 'invoicing' ), |
|
824 | - 'CN9' => __( 'Heilongjiang / 黑龙江', 'invoicing' ), |
|
825 | - 'CN10' => __( 'Shanghai / 上海', 'invoicing' ), |
|
826 | - 'CN11' => __( 'Jiangsu / 江苏', 'invoicing' ), |
|
827 | - 'CN12' => __( 'Zhejiang / 浙江', 'invoicing' ), |
|
828 | - 'CN13' => __( 'Anhui / 安徽', 'invoicing' ), |
|
829 | - 'CN14' => __( 'Fujian / 福建', 'invoicing' ), |
|
830 | - 'CN15' => __( 'Jiangxi / 江西', 'invoicing' ), |
|
831 | - 'CN16' => __( 'Shandong / 山东', 'invoicing' ), |
|
832 | - 'CN17' => __( 'Henan / 河南', 'invoicing' ), |
|
833 | - 'CN18' => __( 'Hubei / 湖北', 'invoicing' ), |
|
834 | - 'CN19' => __( 'Hunan / 湖南', 'invoicing' ), |
|
835 | - 'CN20' => __( 'Guangdong / 广东', 'invoicing' ), |
|
836 | - 'CN21' => __( 'Guangxi Zhuang / 广西壮族', 'invoicing' ), |
|
837 | - 'CN22' => __( 'Hainan / 海南', 'invoicing' ), |
|
838 | - 'CN23' => __( 'Chongqing / 重庆', 'invoicing' ), |
|
839 | - 'CN24' => __( 'Sichuan / 四川', 'invoicing' ), |
|
840 | - 'CN25' => __( 'Guizhou / 贵州', 'invoicing' ), |
|
841 | - 'CN26' => __( 'Shaanxi / 陕西', 'invoicing' ), |
|
842 | - 'CN27' => __( 'Gansu / 甘肃', 'invoicing' ), |
|
843 | - 'CN28' => __( 'Qinghai / 青海', 'invoicing' ), |
|
844 | - 'CN29' => __( 'Ningxia Hui / 宁夏', 'invoicing' ), |
|
845 | - 'CN30' => __( 'Macau / 澳门', 'invoicing' ), |
|
846 | - 'CN31' => __( 'Tibet / 西藏', 'invoicing' ), |
|
847 | - 'CN32' => __( 'Xinjiang / 新疆', 'invoicing' ) |
|
816 | + 'CN1' => __('Yunnan / 云南', 'invoicing'), |
|
817 | + 'CN2' => __('Beijing / 北京', 'invoicing'), |
|
818 | + 'CN3' => __('Tianjin / 天津', 'invoicing'), |
|
819 | + 'CN4' => __('Hebei / 河北', 'invoicing'), |
|
820 | + 'CN5' => __('Shanxi / 山西', 'invoicing'), |
|
821 | + 'CN6' => __('Inner Mongolia / 內蒙古', 'invoicing'), |
|
822 | + 'CN7' => __('Liaoning / 辽宁', 'invoicing'), |
|
823 | + 'CN8' => __('Jilin / 吉林', 'invoicing'), |
|
824 | + 'CN9' => __('Heilongjiang / 黑龙江', 'invoicing'), |
|
825 | + 'CN10' => __('Shanghai / 上海', 'invoicing'), |
|
826 | + 'CN11' => __('Jiangsu / 江苏', 'invoicing'), |
|
827 | + 'CN12' => __('Zhejiang / 浙江', 'invoicing'), |
|
828 | + 'CN13' => __('Anhui / 安徽', 'invoicing'), |
|
829 | + 'CN14' => __('Fujian / 福建', 'invoicing'), |
|
830 | + 'CN15' => __('Jiangxi / 江西', 'invoicing'), |
|
831 | + 'CN16' => __('Shandong / 山东', 'invoicing'), |
|
832 | + 'CN17' => __('Henan / 河南', 'invoicing'), |
|
833 | + 'CN18' => __('Hubei / 湖北', 'invoicing'), |
|
834 | + 'CN19' => __('Hunan / 湖南', 'invoicing'), |
|
835 | + 'CN20' => __('Guangdong / 广东', 'invoicing'), |
|
836 | + 'CN21' => __('Guangxi Zhuang / 广西壮族', 'invoicing'), |
|
837 | + 'CN22' => __('Hainan / 海南', 'invoicing'), |
|
838 | + 'CN23' => __('Chongqing / 重庆', 'invoicing'), |
|
839 | + 'CN24' => __('Sichuan / 四川', 'invoicing'), |
|
840 | + 'CN25' => __('Guizhou / 贵州', 'invoicing'), |
|
841 | + 'CN26' => __('Shaanxi / 陕西', 'invoicing'), |
|
842 | + 'CN27' => __('Gansu / 甘肃', 'invoicing'), |
|
843 | + 'CN28' => __('Qinghai / 青海', 'invoicing'), |
|
844 | + 'CN29' => __('Ningxia Hui / 宁夏', 'invoicing'), |
|
845 | + 'CN30' => __('Macau / 澳门', 'invoicing'), |
|
846 | + 'CN31' => __('Tibet / 西藏', 'invoicing'), |
|
847 | + 'CN32' => __('Xinjiang / 新疆', 'invoicing') |
|
848 | 848 | ); |
849 | 849 | |
850 | - return apply_filters( 'wpinv_china_states', $states ); |
|
850 | + return apply_filters('wpinv_china_states', $states); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | function wpinv_get_new_zealand_states_list() { |
854 | 854 | $states = array( |
855 | - 'AK' => __( 'Auckland', 'invoicing' ), |
|
856 | - 'BP' => __( 'Bay of Plenty', 'invoicing' ), |
|
857 | - 'CT' => __( 'Canterbury', 'invoicing' ), |
|
858 | - 'HB' => __( 'Hawke’s Bay', 'invoicing' ), |
|
859 | - 'MW' => __( 'Manawatu-Wanganui', 'invoicing' ), |
|
860 | - 'MB' => __( 'Marlborough', 'invoicing' ), |
|
861 | - 'NS' => __( 'Nelson', 'invoicing' ), |
|
862 | - 'NL' => __( 'Northland', 'invoicing' ), |
|
863 | - 'OT' => __( 'Otago', 'invoicing' ), |
|
864 | - 'SL' => __( 'Southland', 'invoicing' ), |
|
865 | - 'TK' => __( 'Taranaki', 'invoicing' ), |
|
866 | - 'TM' => __( 'Tasman', 'invoicing' ), |
|
867 | - 'WA' => __( 'Waikato', 'invoicing' ), |
|
868 | - 'WR' => __( 'Wairarapa', 'invoicing' ), |
|
869 | - 'WE' => __( 'Wellington', 'invoicing' ), |
|
870 | - 'WC' => __( 'West Coast', 'invoicing' ) |
|
855 | + 'AK' => __('Auckland', 'invoicing'), |
|
856 | + 'BP' => __('Bay of Plenty', 'invoicing'), |
|
857 | + 'CT' => __('Canterbury', 'invoicing'), |
|
858 | + 'HB' => __('Hawke’s Bay', 'invoicing'), |
|
859 | + 'MW' => __('Manawatu-Wanganui', 'invoicing'), |
|
860 | + 'MB' => __('Marlborough', 'invoicing'), |
|
861 | + 'NS' => __('Nelson', 'invoicing'), |
|
862 | + 'NL' => __('Northland', 'invoicing'), |
|
863 | + 'OT' => __('Otago', 'invoicing'), |
|
864 | + 'SL' => __('Southland', 'invoicing'), |
|
865 | + 'TK' => __('Taranaki', 'invoicing'), |
|
866 | + 'TM' => __('Tasman', 'invoicing'), |
|
867 | + 'WA' => __('Waikato', 'invoicing'), |
|
868 | + 'WR' => __('Wairarapa', 'invoicing'), |
|
869 | + 'WE' => __('Wellington', 'invoicing'), |
|
870 | + 'WC' => __('West Coast', 'invoicing') |
|
871 | 871 | ); |
872 | 872 | |
873 | - return apply_filters( 'wpinv_new_zealand_states', $states ); |
|
873 | + return apply_filters('wpinv_new_zealand_states', $states); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | function wpinv_get_peru_states_list() { |
877 | 877 | $states = array( |
878 | - 'CAL' => __( 'El Callao', 'invoicing' ), |
|
879 | - 'LMA' => __( 'Municipalidad Metropolitana de Lima', 'invoicing' ), |
|
880 | - 'AMA' => __( 'Amazonas', 'invoicing' ), |
|
881 | - 'ANC' => __( 'Ancash', 'invoicing' ), |
|
882 | - 'APU' => __( 'Apurímac', 'invoicing' ), |
|
883 | - 'ARE' => __( 'Arequipa', 'invoicing' ), |
|
884 | - 'AYA' => __( 'Ayacucho', 'invoicing' ), |
|
885 | - 'CAJ' => __( 'Cajamarca', 'invoicing' ), |
|
886 | - 'CUS' => __( 'Cusco', 'invoicing' ), |
|
887 | - 'HUV' => __( 'Huancavelica', 'invoicing' ), |
|
888 | - 'HUC' => __( 'Huánuco', 'invoicing' ), |
|
889 | - 'ICA' => __( 'Ica', 'invoicing' ), |
|
890 | - 'JUN' => __( 'Junín', 'invoicing' ), |
|
891 | - 'LAL' => __( 'La Libertad', 'invoicing' ), |
|
892 | - 'LAM' => __( 'Lambayeque', 'invoicing' ), |
|
893 | - 'LIM' => __( 'Lima', 'invoicing' ), |
|
894 | - 'LOR' => __( 'Loreto', 'invoicing' ), |
|
895 | - 'MDD' => __( 'Madre de Dios', 'invoicing' ), |
|
896 | - 'MOQ' => __( 'Moquegua', 'invoicing' ), |
|
897 | - 'PAS' => __( 'Pasco', 'invoicing' ), |
|
898 | - 'PIU' => __( 'Piura', 'invoicing' ), |
|
899 | - 'PUN' => __( 'Puno', 'invoicing' ), |
|
900 | - 'SAM' => __( 'San Martín', 'invoicing' ), |
|
901 | - 'TAC' => __( 'Tacna', 'invoicing' ), |
|
902 | - 'TUM' => __( 'Tumbes', 'invoicing' ), |
|
903 | - 'UCA' => __( 'Ucayali', 'invoicing' ) |
|
878 | + 'CAL' => __('El Callao', 'invoicing'), |
|
879 | + 'LMA' => __('Municipalidad Metropolitana de Lima', 'invoicing'), |
|
880 | + 'AMA' => __('Amazonas', 'invoicing'), |
|
881 | + 'ANC' => __('Ancash', 'invoicing'), |
|
882 | + 'APU' => __('Apurímac', 'invoicing'), |
|
883 | + 'ARE' => __('Arequipa', 'invoicing'), |
|
884 | + 'AYA' => __('Ayacucho', 'invoicing'), |
|
885 | + 'CAJ' => __('Cajamarca', 'invoicing'), |
|
886 | + 'CUS' => __('Cusco', 'invoicing'), |
|
887 | + 'HUV' => __('Huancavelica', 'invoicing'), |
|
888 | + 'HUC' => __('Huánuco', 'invoicing'), |
|
889 | + 'ICA' => __('Ica', 'invoicing'), |
|
890 | + 'JUN' => __('Junín', 'invoicing'), |
|
891 | + 'LAL' => __('La Libertad', 'invoicing'), |
|
892 | + 'LAM' => __('Lambayeque', 'invoicing'), |
|
893 | + 'LIM' => __('Lima', 'invoicing'), |
|
894 | + 'LOR' => __('Loreto', 'invoicing'), |
|
895 | + 'MDD' => __('Madre de Dios', 'invoicing'), |
|
896 | + 'MOQ' => __('Moquegua', 'invoicing'), |
|
897 | + 'PAS' => __('Pasco', 'invoicing'), |
|
898 | + 'PIU' => __('Piura', 'invoicing'), |
|
899 | + 'PUN' => __('Puno', 'invoicing'), |
|
900 | + 'SAM' => __('San Martín', 'invoicing'), |
|
901 | + 'TAC' => __('Tacna', 'invoicing'), |
|
902 | + 'TUM' => __('Tumbes', 'invoicing'), |
|
903 | + 'UCA' => __('Ucayali', 'invoicing') |
|
904 | 904 | ); |
905 | 905 | |
906 | - return apply_filters( 'wpinv_peru_states', $states ); |
|
906 | + return apply_filters('wpinv_peru_states', $states); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | function wpinv_get_indonesia_states_list() { |
910 | - $states = array( |
|
911 | - 'AC' => __( 'Daerah Istimewa Aceh', 'invoicing' ), |
|
912 | - 'SU' => __( 'Sumatera Utara', 'invoicing' ), |
|
913 | - 'SB' => __( 'Sumatera Barat', 'invoicing' ), |
|
914 | - 'RI' => __( 'Riau', 'invoicing' ), |
|
915 | - 'KR' => __( 'Kepulauan Riau', 'invoicing' ), |
|
916 | - 'JA' => __( 'Jambi', 'invoicing' ), |
|
917 | - 'SS' => __( 'Sumatera Selatan', 'invoicing' ), |
|
918 | - 'BB' => __( 'Bangka Belitung', 'invoicing' ), |
|
919 | - 'BE' => __( 'Bengkulu', 'invoicing' ), |
|
920 | - 'LA' => __( 'Lampung', 'invoicing' ), |
|
921 | - 'JK' => __( 'DKI Jakarta', 'invoicing' ), |
|
922 | - 'JB' => __( 'Jawa Barat', 'invoicing' ), |
|
923 | - 'BT' => __( 'Banten', 'invoicing' ), |
|
924 | - 'JT' => __( 'Jawa Tengah', 'invoicing' ), |
|
925 | - 'JI' => __( 'Jawa Timur', 'invoicing' ), |
|
926 | - 'YO' => __( 'Daerah Istimewa Yogyakarta', 'invoicing' ), |
|
927 | - 'BA' => __( 'Bali', 'invoicing' ), |
|
928 | - 'NB' => __( 'Nusa Tenggara Barat', 'invoicing' ), |
|
929 | - 'NT' => __( 'Nusa Tenggara Timur', 'invoicing' ), |
|
930 | - 'KB' => __( 'Kalimantan Barat', 'invoicing' ), |
|
931 | - 'KT' => __( 'Kalimantan Tengah', 'invoicing' ), |
|
932 | - 'KI' => __( 'Kalimantan Timur', 'invoicing' ), |
|
933 | - 'KS' => __( 'Kalimantan Selatan', 'invoicing' ), |
|
934 | - 'KU' => __( 'Kalimantan Utara', 'invoicing' ), |
|
935 | - 'SA' => __( 'Sulawesi Utara', 'invoicing' ), |
|
936 | - 'ST' => __( 'Sulawesi Tengah', 'invoicing' ), |
|
937 | - 'SG' => __( 'Sulawesi Tenggara', 'invoicing' ), |
|
938 | - 'SR' => __( 'Sulawesi Barat', 'invoicing' ), |
|
939 | - 'SN' => __( 'Sulawesi Selatan', 'invoicing' ), |
|
940 | - 'GO' => __( 'Gorontalo', 'invoicing' ), |
|
941 | - 'MA' => __( 'Maluku', 'invoicing' ), |
|
942 | - 'MU' => __( 'Maluku Utara', 'invoicing' ), |
|
943 | - 'PA' => __( 'Papua', 'invoicing' ), |
|
944 | - 'PB' => __( 'Papua Barat', 'invoicing' ) |
|
910 | + $states = array( |
|
911 | + 'AC' => __('Daerah Istimewa Aceh', 'invoicing'), |
|
912 | + 'SU' => __('Sumatera Utara', 'invoicing'), |
|
913 | + 'SB' => __('Sumatera Barat', 'invoicing'), |
|
914 | + 'RI' => __('Riau', 'invoicing'), |
|
915 | + 'KR' => __('Kepulauan Riau', 'invoicing'), |
|
916 | + 'JA' => __('Jambi', 'invoicing'), |
|
917 | + 'SS' => __('Sumatera Selatan', 'invoicing'), |
|
918 | + 'BB' => __('Bangka Belitung', 'invoicing'), |
|
919 | + 'BE' => __('Bengkulu', 'invoicing'), |
|
920 | + 'LA' => __('Lampung', 'invoicing'), |
|
921 | + 'JK' => __('DKI Jakarta', 'invoicing'), |
|
922 | + 'JB' => __('Jawa Barat', 'invoicing'), |
|
923 | + 'BT' => __('Banten', 'invoicing'), |
|
924 | + 'JT' => __('Jawa Tengah', 'invoicing'), |
|
925 | + 'JI' => __('Jawa Timur', 'invoicing'), |
|
926 | + 'YO' => __('Daerah Istimewa Yogyakarta', 'invoicing'), |
|
927 | + 'BA' => __('Bali', 'invoicing'), |
|
928 | + 'NB' => __('Nusa Tenggara Barat', 'invoicing'), |
|
929 | + 'NT' => __('Nusa Tenggara Timur', 'invoicing'), |
|
930 | + 'KB' => __('Kalimantan Barat', 'invoicing'), |
|
931 | + 'KT' => __('Kalimantan Tengah', 'invoicing'), |
|
932 | + 'KI' => __('Kalimantan Timur', 'invoicing'), |
|
933 | + 'KS' => __('Kalimantan Selatan', 'invoicing'), |
|
934 | + 'KU' => __('Kalimantan Utara', 'invoicing'), |
|
935 | + 'SA' => __('Sulawesi Utara', 'invoicing'), |
|
936 | + 'ST' => __('Sulawesi Tengah', 'invoicing'), |
|
937 | + 'SG' => __('Sulawesi Tenggara', 'invoicing'), |
|
938 | + 'SR' => __('Sulawesi Barat', 'invoicing'), |
|
939 | + 'SN' => __('Sulawesi Selatan', 'invoicing'), |
|
940 | + 'GO' => __('Gorontalo', 'invoicing'), |
|
941 | + 'MA' => __('Maluku', 'invoicing'), |
|
942 | + 'MU' => __('Maluku Utara', 'invoicing'), |
|
943 | + 'PA' => __('Papua', 'invoicing'), |
|
944 | + 'PB' => __('Papua Barat', 'invoicing') |
|
945 | 945 | ); |
946 | 946 | |
947 | - return apply_filters( 'wpinv_indonesia_states', $states ); |
|
947 | + return apply_filters('wpinv_indonesia_states', $states); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | function wpinv_get_india_states_list() { |
951 | 951 | $states = array( |
952 | - 'AP' => __( 'Andhra Pradesh', 'invoicing' ), |
|
953 | - 'AR' => __( 'Arunachal Pradesh', 'invoicing' ), |
|
954 | - 'AS' => __( 'Assam', 'invoicing' ), |
|
955 | - 'BR' => __( 'Bihar', 'invoicing' ), |
|
956 | - 'CT' => __( 'Chhattisgarh', 'invoicing' ), |
|
957 | - 'GA' => __( 'Goa', 'invoicing' ), |
|
958 | - 'GJ' => __( 'Gujarat', 'invoicing' ), |
|
959 | - 'HR' => __( 'Haryana', 'invoicing' ), |
|
960 | - 'HP' => __( 'Himachal Pradesh', 'invoicing' ), |
|
961 | - 'JK' => __( 'Jammu and Kashmir', 'invoicing' ), |
|
962 | - 'JH' => __( 'Jharkhand', 'invoicing' ), |
|
963 | - 'KA' => __( 'Karnataka', 'invoicing' ), |
|
964 | - 'KL' => __( 'Kerala', 'invoicing' ), |
|
965 | - 'MP' => __( 'Madhya Pradesh', 'invoicing' ), |
|
966 | - 'MH' => __( 'Maharashtra', 'invoicing' ), |
|
967 | - 'MN' => __( 'Manipur', 'invoicing' ), |
|
968 | - 'ML' => __( 'Meghalaya', 'invoicing' ), |
|
969 | - 'MZ' => __( 'Mizoram', 'invoicing' ), |
|
970 | - 'NL' => __( 'Nagaland', 'invoicing' ), |
|
971 | - 'OR' => __( 'Orissa', 'invoicing' ), |
|
972 | - 'PB' => __( 'Punjab', 'invoicing' ), |
|
973 | - 'RJ' => __( 'Rajasthan', 'invoicing' ), |
|
974 | - 'SK' => __( 'Sikkim', 'invoicing' ), |
|
975 | - 'TN' => __( 'Tamil Nadu', 'invoicing' ), |
|
976 | - 'TG' => __( 'Telangana', 'invoicing' ), |
|
977 | - 'TR' => __( 'Tripura', 'invoicing' ), |
|
978 | - 'UT' => __( 'Uttarakhand', 'invoicing' ), |
|
979 | - 'UP' => __( 'Uttar Pradesh', 'invoicing' ), |
|
980 | - 'WB' => __( 'West Bengal', 'invoicing' ), |
|
981 | - 'AN' => __( 'Andaman and Nicobar Islands', 'invoicing' ), |
|
982 | - 'CH' => __( 'Chandigarh', 'invoicing' ), |
|
983 | - 'DN' => __( 'Dadar and Nagar Haveli', 'invoicing' ), |
|
984 | - 'DD' => __( 'Daman and Diu', 'invoicing' ), |
|
985 | - 'DL' => __( 'Delhi', 'invoicing' ), |
|
986 | - 'LD' => __( 'Lakshadweep', 'invoicing' ), |
|
987 | - 'PY' => __( 'Pondicherry (Puducherry)', 'invoicing' ) |
|
952 | + 'AP' => __('Andhra Pradesh', 'invoicing'), |
|
953 | + 'AR' => __('Arunachal Pradesh', 'invoicing'), |
|
954 | + 'AS' => __('Assam', 'invoicing'), |
|
955 | + 'BR' => __('Bihar', 'invoicing'), |
|
956 | + 'CT' => __('Chhattisgarh', 'invoicing'), |
|
957 | + 'GA' => __('Goa', 'invoicing'), |
|
958 | + 'GJ' => __('Gujarat', 'invoicing'), |
|
959 | + 'HR' => __('Haryana', 'invoicing'), |
|
960 | + 'HP' => __('Himachal Pradesh', 'invoicing'), |
|
961 | + 'JK' => __('Jammu and Kashmir', 'invoicing'), |
|
962 | + 'JH' => __('Jharkhand', 'invoicing'), |
|
963 | + 'KA' => __('Karnataka', 'invoicing'), |
|
964 | + 'KL' => __('Kerala', 'invoicing'), |
|
965 | + 'MP' => __('Madhya Pradesh', 'invoicing'), |
|
966 | + 'MH' => __('Maharashtra', 'invoicing'), |
|
967 | + 'MN' => __('Manipur', 'invoicing'), |
|
968 | + 'ML' => __('Meghalaya', 'invoicing'), |
|
969 | + 'MZ' => __('Mizoram', 'invoicing'), |
|
970 | + 'NL' => __('Nagaland', 'invoicing'), |
|
971 | + 'OR' => __('Orissa', 'invoicing'), |
|
972 | + 'PB' => __('Punjab', 'invoicing'), |
|
973 | + 'RJ' => __('Rajasthan', 'invoicing'), |
|
974 | + 'SK' => __('Sikkim', 'invoicing'), |
|
975 | + 'TN' => __('Tamil Nadu', 'invoicing'), |
|
976 | + 'TG' => __('Telangana', 'invoicing'), |
|
977 | + 'TR' => __('Tripura', 'invoicing'), |
|
978 | + 'UT' => __('Uttarakhand', 'invoicing'), |
|
979 | + 'UP' => __('Uttar Pradesh', 'invoicing'), |
|
980 | + 'WB' => __('West Bengal', 'invoicing'), |
|
981 | + 'AN' => __('Andaman and Nicobar Islands', 'invoicing'), |
|
982 | + 'CH' => __('Chandigarh', 'invoicing'), |
|
983 | + 'DN' => __('Dadar and Nagar Haveli', 'invoicing'), |
|
984 | + 'DD' => __('Daman and Diu', 'invoicing'), |
|
985 | + 'DL' => __('Delhi', 'invoicing'), |
|
986 | + 'LD' => __('Lakshadweep', 'invoicing'), |
|
987 | + 'PY' => __('Pondicherry (Puducherry)', 'invoicing') |
|
988 | 988 | ); |
989 | 989 | |
990 | - return apply_filters( 'wpinv_india_states', $states ); |
|
990 | + return apply_filters('wpinv_india_states', $states); |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | function wpinv_get_iran_states_list() { |
994 | 994 | $states = array( |
995 | - 'KHZ' => __( 'Khuzestan', 'invoicing' ), |
|
996 | - 'THR' => __( 'Tehran', 'invoicing' ), |
|
997 | - 'ILM' => __( 'Ilaam', 'invoicing' ), |
|
998 | - 'BHR' => __( 'Bushehr', 'invoicing' ), |
|
999 | - 'ADL' => __( 'Ardabil', 'invoicing' ), |
|
1000 | - 'ESF' => __( 'Isfahan', 'invoicing' ), |
|
1001 | - 'YZD' => __( 'Yazd', 'invoicing' ), |
|
1002 | - 'KRH' => __( 'Kermanshah', 'invoicing' ), |
|
1003 | - 'KRN' => __( 'Kerman', 'invoicing' ), |
|
1004 | - 'HDN' => __( 'Hamadan', 'invoicing' ), |
|
1005 | - 'GZN' => __( 'Ghazvin', 'invoicing' ), |
|
1006 | - 'ZJN' => __( 'Zanjan', 'invoicing' ), |
|
1007 | - 'LRS' => __( 'Luristan', 'invoicing' ), |
|
1008 | - 'ABZ' => __( 'Alborz', 'invoicing' ), |
|
1009 | - 'EAZ' => __( 'East Azerbaijan', 'invoicing' ), |
|
1010 | - 'WAZ' => __( 'West Azerbaijan', 'invoicing' ), |
|
1011 | - 'CHB' => __( 'Chaharmahal and Bakhtiari', 'invoicing' ), |
|
1012 | - 'SKH' => __( 'South Khorasan', 'invoicing' ), |
|
1013 | - 'RKH' => __( 'Razavi Khorasan', 'invoicing' ), |
|
1014 | - 'NKH' => __( 'North Khorasan', 'invoicing' ), |
|
1015 | - 'SMN' => __( 'Semnan', 'invoicing' ), |
|
1016 | - 'FRS' => __( 'Fars', 'invoicing' ), |
|
1017 | - 'QHM' => __( 'Qom', 'invoicing' ), |
|
1018 | - 'KRD' => __( 'Kurdistan', 'invoicing' ), |
|
1019 | - 'KBD' => __( 'Kohgiluyeh and BoyerAhmad', 'invoicing' ), |
|
1020 | - 'GLS' => __( 'Golestan', 'invoicing' ), |
|
1021 | - 'GIL' => __( 'Gilan', 'invoicing' ), |
|
1022 | - 'MZN' => __( 'Mazandaran', 'invoicing' ), |
|
1023 | - 'MKZ' => __( 'Markazi', 'invoicing' ), |
|
1024 | - 'HRZ' => __( 'Hormozgan', 'invoicing' ), |
|
1025 | - 'SBN' => __( 'Sistan and Baluchestan', 'invoicing' ) |
|
995 | + 'KHZ' => __('Khuzestan', 'invoicing'), |
|
996 | + 'THR' => __('Tehran', 'invoicing'), |
|
997 | + 'ILM' => __('Ilaam', 'invoicing'), |
|
998 | + 'BHR' => __('Bushehr', 'invoicing'), |
|
999 | + 'ADL' => __('Ardabil', 'invoicing'), |
|
1000 | + 'ESF' => __('Isfahan', 'invoicing'), |
|
1001 | + 'YZD' => __('Yazd', 'invoicing'), |
|
1002 | + 'KRH' => __('Kermanshah', 'invoicing'), |
|
1003 | + 'KRN' => __('Kerman', 'invoicing'), |
|
1004 | + 'HDN' => __('Hamadan', 'invoicing'), |
|
1005 | + 'GZN' => __('Ghazvin', 'invoicing'), |
|
1006 | + 'ZJN' => __('Zanjan', 'invoicing'), |
|
1007 | + 'LRS' => __('Luristan', 'invoicing'), |
|
1008 | + 'ABZ' => __('Alborz', 'invoicing'), |
|
1009 | + 'EAZ' => __('East Azerbaijan', 'invoicing'), |
|
1010 | + 'WAZ' => __('West Azerbaijan', 'invoicing'), |
|
1011 | + 'CHB' => __('Chaharmahal and Bakhtiari', 'invoicing'), |
|
1012 | + 'SKH' => __('South Khorasan', 'invoicing'), |
|
1013 | + 'RKH' => __('Razavi Khorasan', 'invoicing'), |
|
1014 | + 'NKH' => __('North Khorasan', 'invoicing'), |
|
1015 | + 'SMN' => __('Semnan', 'invoicing'), |
|
1016 | + 'FRS' => __('Fars', 'invoicing'), |
|
1017 | + 'QHM' => __('Qom', 'invoicing'), |
|
1018 | + 'KRD' => __('Kurdistan', 'invoicing'), |
|
1019 | + 'KBD' => __('Kohgiluyeh and BoyerAhmad', 'invoicing'), |
|
1020 | + 'GLS' => __('Golestan', 'invoicing'), |
|
1021 | + 'GIL' => __('Gilan', 'invoicing'), |
|
1022 | + 'MZN' => __('Mazandaran', 'invoicing'), |
|
1023 | + 'MKZ' => __('Markazi', 'invoicing'), |
|
1024 | + 'HRZ' => __('Hormozgan', 'invoicing'), |
|
1025 | + 'SBN' => __('Sistan and Baluchestan', 'invoicing') |
|
1026 | 1026 | ); |
1027 | 1027 | |
1028 | - return apply_filters( 'wpinv_iran_states', $states ); |
|
1028 | + return apply_filters('wpinv_iran_states', $states); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | function wpinv_get_italy_states_list() { |
1032 | 1032 | $states = array( |
1033 | - 'AG' => __( 'Agrigento', 'invoicing' ), |
|
1034 | - 'AL' => __( 'Alessandria', 'invoicing' ), |
|
1035 | - 'AN' => __( 'Ancona', 'invoicing' ), |
|
1036 | - 'AO' => __( 'Aosta', 'invoicing' ), |
|
1037 | - 'AR' => __( 'Arezzo', 'invoicing' ), |
|
1038 | - 'AP' => __( 'Ascoli Piceno', 'invoicing' ), |
|
1039 | - 'AT' => __( 'Asti', 'invoicing' ), |
|
1040 | - 'AV' => __( 'Avellino', 'invoicing' ), |
|
1041 | - 'BA' => __( 'Bari', 'invoicing' ), |
|
1042 | - 'BT' => __( 'Barletta-Andria-Trani', 'invoicing' ), |
|
1043 | - 'BL' => __( 'Belluno', 'invoicing' ), |
|
1044 | - 'BN' => __( 'Benevento', 'invoicing' ), |
|
1045 | - 'BG' => __( 'Bergamo', 'invoicing' ), |
|
1046 | - 'BI' => __( 'Biella', 'invoicing' ), |
|
1047 | - 'BO' => __( 'Bologna', 'invoicing' ), |
|
1048 | - 'BZ' => __( 'Bolzano', 'invoicing' ), |
|
1049 | - 'BS' => __( 'Brescia', 'invoicing' ), |
|
1050 | - 'BR' => __( 'Brindisi', 'invoicing' ), |
|
1051 | - 'CA' => __( 'Cagliari', 'invoicing' ), |
|
1052 | - 'CL' => __( 'Caltanissetta', 'invoicing' ), |
|
1053 | - 'CB' => __( 'Campobasso', 'invoicing' ), |
|
1054 | - 'CI' => __( 'Caltanissetta', 'invoicing' ), |
|
1055 | - 'CE' => __( 'Caserta', 'invoicing' ), |
|
1056 | - 'CT' => __( 'Catania', 'invoicing' ), |
|
1057 | - 'CZ' => __( 'Catanzaro', 'invoicing' ), |
|
1058 | - 'CH' => __( 'Chieti', 'invoicing' ), |
|
1059 | - 'CO' => __( 'Como', 'invoicing' ), |
|
1060 | - 'CS' => __( 'Cosenza', 'invoicing' ), |
|
1061 | - 'CR' => __( 'Cremona', 'invoicing' ), |
|
1062 | - 'KR' => __( 'Crotone', 'invoicing' ), |
|
1063 | - 'CN' => __( 'Cuneo', 'invoicing' ), |
|
1064 | - 'EN' => __( 'Enna', 'invoicing' ), |
|
1065 | - 'FM' => __( 'Fermo', 'invoicing' ), |
|
1066 | - 'FE' => __( 'Ferrara', 'invoicing' ), |
|
1067 | - 'FI' => __( 'Firenze', 'invoicing' ), |
|
1068 | - 'FG' => __( 'Foggia', 'invoicing' ), |
|
1069 | - 'FC' => __( 'Forli-Cesena', 'invoicing' ), |
|
1070 | - 'FR' => __( 'Frosinone', 'invoicing' ), |
|
1071 | - 'GE' => __( 'Genova', 'invoicing' ), |
|
1072 | - 'GO' => __( 'Gorizia', 'invoicing' ), |
|
1073 | - 'GR' => __( 'Grosseto', 'invoicing' ), |
|
1074 | - 'IM' => __( 'Imperia', 'invoicing' ), |
|
1075 | - 'IS' => __( 'Isernia', 'invoicing' ), |
|
1076 | - 'SP' => __( 'La Spezia', 'invoicing' ), |
|
1077 | - 'AQ' => __( 'L'Aquila', 'invoicing' ), |
|
1078 | - 'LT' => __( 'Latina', 'invoicing' ), |
|
1079 | - 'LE' => __( 'Lecce', 'invoicing' ), |
|
1080 | - 'LC' => __( 'Lecco', 'invoicing' ), |
|
1081 | - 'LI' => __( 'Livorno', 'invoicing' ), |
|
1082 | - 'LO' => __( 'Lodi', 'invoicing' ), |
|
1083 | - 'LU' => __( 'Lucca', 'invoicing' ), |
|
1084 | - 'MC' => __( 'Macerata', 'invoicing' ), |
|
1085 | - 'MN' => __( 'Mantova', 'invoicing' ), |
|
1086 | - 'MS' => __( 'Massa-Carrara', 'invoicing' ), |
|
1087 | - 'MT' => __( 'Matera', 'invoicing' ), |
|
1088 | - 'ME' => __( 'Messina', 'invoicing' ), |
|
1089 | - 'MI' => __( 'Milano', 'invoicing' ), |
|
1090 | - 'MO' => __( 'Modena', 'invoicing' ), |
|
1091 | - 'MB' => __( 'Monza e della Brianza', 'invoicing' ), |
|
1092 | - 'NA' => __( 'Napoli', 'invoicing' ), |
|
1093 | - 'NO' => __( 'Novara', 'invoicing' ), |
|
1094 | - 'NU' => __( 'Nuoro', 'invoicing' ), |
|
1095 | - 'OT' => __( 'Olbia-Tempio', 'invoicing' ), |
|
1096 | - 'OR' => __( 'Oristano', 'invoicing' ), |
|
1097 | - 'PD' => __( 'Padova', 'invoicing' ), |
|
1098 | - 'PA' => __( 'Palermo', 'invoicing' ), |
|
1099 | - 'PR' => __( 'Parma', 'invoicing' ), |
|
1100 | - 'PV' => __( 'Pavia', 'invoicing' ), |
|
1101 | - 'PG' => __( 'Perugia', 'invoicing' ), |
|
1102 | - 'PU' => __( 'Pesaro e Urbino', 'invoicing' ), |
|
1103 | - 'PE' => __( 'Pescara', 'invoicing' ), |
|
1104 | - 'PC' => __( 'Piacenza', 'invoicing' ), |
|
1105 | - 'PI' => __( 'Pisa', 'invoicing' ), |
|
1106 | - 'PT' => __( 'Pistoia', 'invoicing' ), |
|
1107 | - 'PN' => __( 'Pordenone', 'invoicing' ), |
|
1108 | - 'PZ' => __( 'Potenza', 'invoicing' ), |
|
1109 | - 'PO' => __( 'Prato', 'invoicing' ), |
|
1110 | - 'RG' => __( 'Ragusa', 'invoicing' ), |
|
1111 | - 'RA' => __( 'Ravenna', 'invoicing' ), |
|
1112 | - 'RC' => __( 'Reggio Calabria', 'invoicing' ), |
|
1113 | - 'RE' => __( 'Reggio Emilia', 'invoicing' ), |
|
1114 | - 'RI' => __( 'Rieti', 'invoicing' ), |
|
1115 | - 'RN' => __( 'Rimini', 'invoicing' ), |
|
1116 | - 'RM' => __( 'Roma', 'invoicing' ), |
|
1117 | - 'RO' => __( 'Rovigo', 'invoicing' ), |
|
1118 | - 'SA' => __( 'Salerno', 'invoicing' ), |
|
1119 | - 'VS' => __( 'Medio Campidano', 'invoicing' ), |
|
1120 | - 'SS' => __( 'Sassari', 'invoicing' ), |
|
1121 | - 'SV' => __( 'Savona', 'invoicing' ), |
|
1122 | - 'SI' => __( 'Siena', 'invoicing' ), |
|
1123 | - 'SR' => __( 'Siracusa', 'invoicing' ), |
|
1124 | - 'SO' => __( 'Sondrio', 'invoicing' ), |
|
1125 | - 'TA' => __( 'Taranto', 'invoicing' ), |
|
1126 | - 'TE' => __( 'Teramo', 'invoicing' ), |
|
1127 | - 'TR' => __( 'Terni', 'invoicing' ), |
|
1128 | - 'TO' => __( 'Torino', 'invoicing' ), |
|
1129 | - 'OG' => __( 'Ogliastra', 'invoicing' ), |
|
1130 | - 'TP' => __( 'Trapani', 'invoicing' ), |
|
1131 | - 'TN' => __( 'Trento', 'invoicing' ), |
|
1132 | - 'TV' => __( 'Treviso', 'invoicing' ), |
|
1133 | - 'TS' => __( 'Trieste', 'invoicing' ), |
|
1134 | - 'UD' => __( 'Udine', 'invoicing' ), |
|
1135 | - 'VA' => __( 'Varesa', 'invoicing' ), |
|
1136 | - 'VE' => __( 'Venezia', 'invoicing' ), |
|
1137 | - 'VB' => __( 'Verbano-Cusio-Ossola', 'invoicing' ), |
|
1138 | - 'VC' => __( 'Vercelli', 'invoicing' ), |
|
1139 | - 'VR' => __( 'Verona', 'invoicing' ), |
|
1140 | - 'VV' => __( 'Vibo Valentia', 'invoicing' ), |
|
1141 | - 'VI' => __( 'Vicenza', 'invoicing' ), |
|
1142 | - 'VT' => __( 'Viterbo', 'invoicing' ) |
|
1033 | + 'AG' => __('Agrigento', 'invoicing'), |
|
1034 | + 'AL' => __('Alessandria', 'invoicing'), |
|
1035 | + 'AN' => __('Ancona', 'invoicing'), |
|
1036 | + 'AO' => __('Aosta', 'invoicing'), |
|
1037 | + 'AR' => __('Arezzo', 'invoicing'), |
|
1038 | + 'AP' => __('Ascoli Piceno', 'invoicing'), |
|
1039 | + 'AT' => __('Asti', 'invoicing'), |
|
1040 | + 'AV' => __('Avellino', 'invoicing'), |
|
1041 | + 'BA' => __('Bari', 'invoicing'), |
|
1042 | + 'BT' => __('Barletta-Andria-Trani', 'invoicing'), |
|
1043 | + 'BL' => __('Belluno', 'invoicing'), |
|
1044 | + 'BN' => __('Benevento', 'invoicing'), |
|
1045 | + 'BG' => __('Bergamo', 'invoicing'), |
|
1046 | + 'BI' => __('Biella', 'invoicing'), |
|
1047 | + 'BO' => __('Bologna', 'invoicing'), |
|
1048 | + 'BZ' => __('Bolzano', 'invoicing'), |
|
1049 | + 'BS' => __('Brescia', 'invoicing'), |
|
1050 | + 'BR' => __('Brindisi', 'invoicing'), |
|
1051 | + 'CA' => __('Cagliari', 'invoicing'), |
|
1052 | + 'CL' => __('Caltanissetta', 'invoicing'), |
|
1053 | + 'CB' => __('Campobasso', 'invoicing'), |
|
1054 | + 'CI' => __('Caltanissetta', 'invoicing'), |
|
1055 | + 'CE' => __('Caserta', 'invoicing'), |
|
1056 | + 'CT' => __('Catania', 'invoicing'), |
|
1057 | + 'CZ' => __('Catanzaro', 'invoicing'), |
|
1058 | + 'CH' => __('Chieti', 'invoicing'), |
|
1059 | + 'CO' => __('Como', 'invoicing'), |
|
1060 | + 'CS' => __('Cosenza', 'invoicing'), |
|
1061 | + 'CR' => __('Cremona', 'invoicing'), |
|
1062 | + 'KR' => __('Crotone', 'invoicing'), |
|
1063 | + 'CN' => __('Cuneo', 'invoicing'), |
|
1064 | + 'EN' => __('Enna', 'invoicing'), |
|
1065 | + 'FM' => __('Fermo', 'invoicing'), |
|
1066 | + 'FE' => __('Ferrara', 'invoicing'), |
|
1067 | + 'FI' => __('Firenze', 'invoicing'), |
|
1068 | + 'FG' => __('Foggia', 'invoicing'), |
|
1069 | + 'FC' => __('Forli-Cesena', 'invoicing'), |
|
1070 | + 'FR' => __('Frosinone', 'invoicing'), |
|
1071 | + 'GE' => __('Genova', 'invoicing'), |
|
1072 | + 'GO' => __('Gorizia', 'invoicing'), |
|
1073 | + 'GR' => __('Grosseto', 'invoicing'), |
|
1074 | + 'IM' => __('Imperia', 'invoicing'), |
|
1075 | + 'IS' => __('Isernia', 'invoicing'), |
|
1076 | + 'SP' => __('La Spezia', 'invoicing'), |
|
1077 | + 'AQ' => __('L'Aquila', 'invoicing'), |
|
1078 | + 'LT' => __('Latina', 'invoicing'), |
|
1079 | + 'LE' => __('Lecce', 'invoicing'), |
|
1080 | + 'LC' => __('Lecco', 'invoicing'), |
|
1081 | + 'LI' => __('Livorno', 'invoicing'), |
|
1082 | + 'LO' => __('Lodi', 'invoicing'), |
|
1083 | + 'LU' => __('Lucca', 'invoicing'), |
|
1084 | + 'MC' => __('Macerata', 'invoicing'), |
|
1085 | + 'MN' => __('Mantova', 'invoicing'), |
|
1086 | + 'MS' => __('Massa-Carrara', 'invoicing'), |
|
1087 | + 'MT' => __('Matera', 'invoicing'), |
|
1088 | + 'ME' => __('Messina', 'invoicing'), |
|
1089 | + 'MI' => __('Milano', 'invoicing'), |
|
1090 | + 'MO' => __('Modena', 'invoicing'), |
|
1091 | + 'MB' => __('Monza e della Brianza', 'invoicing'), |
|
1092 | + 'NA' => __('Napoli', 'invoicing'), |
|
1093 | + 'NO' => __('Novara', 'invoicing'), |
|
1094 | + 'NU' => __('Nuoro', 'invoicing'), |
|
1095 | + 'OT' => __('Olbia-Tempio', 'invoicing'), |
|
1096 | + 'OR' => __('Oristano', 'invoicing'), |
|
1097 | + 'PD' => __('Padova', 'invoicing'), |
|
1098 | + 'PA' => __('Palermo', 'invoicing'), |
|
1099 | + 'PR' => __('Parma', 'invoicing'), |
|
1100 | + 'PV' => __('Pavia', 'invoicing'), |
|
1101 | + 'PG' => __('Perugia', 'invoicing'), |
|
1102 | + 'PU' => __('Pesaro e Urbino', 'invoicing'), |
|
1103 | + 'PE' => __('Pescara', 'invoicing'), |
|
1104 | + 'PC' => __('Piacenza', 'invoicing'), |
|
1105 | + 'PI' => __('Pisa', 'invoicing'), |
|
1106 | + 'PT' => __('Pistoia', 'invoicing'), |
|
1107 | + 'PN' => __('Pordenone', 'invoicing'), |
|
1108 | + 'PZ' => __('Potenza', 'invoicing'), |
|
1109 | + 'PO' => __('Prato', 'invoicing'), |
|
1110 | + 'RG' => __('Ragusa', 'invoicing'), |
|
1111 | + 'RA' => __('Ravenna', 'invoicing'), |
|
1112 | + 'RC' => __('Reggio Calabria', 'invoicing'), |
|
1113 | + 'RE' => __('Reggio Emilia', 'invoicing'), |
|
1114 | + 'RI' => __('Rieti', 'invoicing'), |
|
1115 | + 'RN' => __('Rimini', 'invoicing'), |
|
1116 | + 'RM' => __('Roma', 'invoicing'), |
|
1117 | + 'RO' => __('Rovigo', 'invoicing'), |
|
1118 | + 'SA' => __('Salerno', 'invoicing'), |
|
1119 | + 'VS' => __('Medio Campidano', 'invoicing'), |
|
1120 | + 'SS' => __('Sassari', 'invoicing'), |
|
1121 | + 'SV' => __('Savona', 'invoicing'), |
|
1122 | + 'SI' => __('Siena', 'invoicing'), |
|
1123 | + 'SR' => __('Siracusa', 'invoicing'), |
|
1124 | + 'SO' => __('Sondrio', 'invoicing'), |
|
1125 | + 'TA' => __('Taranto', 'invoicing'), |
|
1126 | + 'TE' => __('Teramo', 'invoicing'), |
|
1127 | + 'TR' => __('Terni', 'invoicing'), |
|
1128 | + 'TO' => __('Torino', 'invoicing'), |
|
1129 | + 'OG' => __('Ogliastra', 'invoicing'), |
|
1130 | + 'TP' => __('Trapani', 'invoicing'), |
|
1131 | + 'TN' => __('Trento', 'invoicing'), |
|
1132 | + 'TV' => __('Treviso', 'invoicing'), |
|
1133 | + 'TS' => __('Trieste', 'invoicing'), |
|
1134 | + 'UD' => __('Udine', 'invoicing'), |
|
1135 | + 'VA' => __('Varesa', 'invoicing'), |
|
1136 | + 'VE' => __('Venezia', 'invoicing'), |
|
1137 | + 'VB' => __('Verbano-Cusio-Ossola', 'invoicing'), |
|
1138 | + 'VC' => __('Vercelli', 'invoicing'), |
|
1139 | + 'VR' => __('Verona', 'invoicing'), |
|
1140 | + 'VV' => __('Vibo Valentia', 'invoicing'), |
|
1141 | + 'VI' => __('Vicenza', 'invoicing'), |
|
1142 | + 'VT' => __('Viterbo', 'invoicing') |
|
1143 | 1143 | ); |
1144 | 1144 | |
1145 | - return apply_filters( 'wpinv_italy_states', $states ); |
|
1145 | + return apply_filters('wpinv_italy_states', $states); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | function wpinv_get_malaysia_states_list() { |
1149 | 1149 | $states = array( |
1150 | - 'JHR' => __( 'Johor', 'invoicing' ), |
|
1151 | - 'KDH' => __( 'Kedah', 'invoicing' ), |
|
1152 | - 'KTN' => __( 'Kelantan', 'invoicing' ), |
|
1153 | - 'MLK' => __( 'Melaka', 'invoicing' ), |
|
1154 | - 'NSN' => __( 'Negeri Sembilan', 'invoicing' ), |
|
1155 | - 'PHG' => __( 'Pahang', 'invoicing' ), |
|
1156 | - 'PRK' => __( 'Perak', 'invoicing' ), |
|
1157 | - 'PLS' => __( 'Perlis', 'invoicing' ), |
|
1158 | - 'PNG' => __( 'Pulau Pinang', 'invoicing' ), |
|
1159 | - 'SBH' => __( 'Sabah', 'invoicing' ), |
|
1160 | - 'SWK' => __( 'Sarawak', 'invoicing' ), |
|
1161 | - 'SGR' => __( 'Selangor', 'invoicing' ), |
|
1162 | - 'TRG' => __( 'Terengganu', 'invoicing' ), |
|
1163 | - 'KUL' => __( 'W.P. Kuala Lumpur', 'invoicing' ), |
|
1164 | - 'LBN' => __( 'W.P. Labuan', 'invoicing' ), |
|
1165 | - 'PJY' => __( 'W.P. Putrajaya', 'invoicing' ) |
|
1150 | + 'JHR' => __('Johor', 'invoicing'), |
|
1151 | + 'KDH' => __('Kedah', 'invoicing'), |
|
1152 | + 'KTN' => __('Kelantan', 'invoicing'), |
|
1153 | + 'MLK' => __('Melaka', 'invoicing'), |
|
1154 | + 'NSN' => __('Negeri Sembilan', 'invoicing'), |
|
1155 | + 'PHG' => __('Pahang', 'invoicing'), |
|
1156 | + 'PRK' => __('Perak', 'invoicing'), |
|
1157 | + 'PLS' => __('Perlis', 'invoicing'), |
|
1158 | + 'PNG' => __('Pulau Pinang', 'invoicing'), |
|
1159 | + 'SBH' => __('Sabah', 'invoicing'), |
|
1160 | + 'SWK' => __('Sarawak', 'invoicing'), |
|
1161 | + 'SGR' => __('Selangor', 'invoicing'), |
|
1162 | + 'TRG' => __('Terengganu', 'invoicing'), |
|
1163 | + 'KUL' => __('W.P. Kuala Lumpur', 'invoicing'), |
|
1164 | + 'LBN' => __('W.P. Labuan', 'invoicing'), |
|
1165 | + 'PJY' => __('W.P. Putrajaya', 'invoicing') |
|
1166 | 1166 | ); |
1167 | 1167 | |
1168 | - return apply_filters( 'wpinv_malaysia_states', $states ); |
|
1168 | + return apply_filters('wpinv_malaysia_states', $states); |
|
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | function wpinv_get_mexico_states_list() { |
1172 | 1172 | $states = array( |
1173 | - 'DIF' => __( 'Distrito Federal', 'invoicing' ), |
|
1174 | - 'JAL' => __( 'Jalisco', 'invoicing' ), |
|
1175 | - 'NLE' => __( 'Nuevo León', 'invoicing' ), |
|
1176 | - 'AGU' => __( 'Aguascalientes', 'invoicing' ), |
|
1177 | - 'BCN' => __( 'Baja California Norte', 'invoicing' ), |
|
1178 | - 'BCS' => __( 'Baja California Sur', 'invoicing' ), |
|
1179 | - 'CAM' => __( 'Campeche', 'invoicing' ), |
|
1180 | - 'CHP' => __( 'Chiapas', 'invoicing' ), |
|
1181 | - 'CHH' => __( 'Chihuahua', 'invoicing' ), |
|
1182 | - 'COA' => __( 'Coahuila', 'invoicing' ), |
|
1183 | - 'COL' => __( 'Colima', 'invoicing' ), |
|
1184 | - 'DUR' => __( 'Durango', 'invoicing' ), |
|
1185 | - 'GUA' => __( 'Guanajuato', 'invoicing' ), |
|
1186 | - 'GRO' => __( 'Guerrero', 'invoicing' ), |
|
1187 | - 'HID' => __( 'Hidalgo', 'invoicing' ), |
|
1188 | - 'MEX' => __( 'Edo. de México', 'invoicing' ), |
|
1189 | - 'MIC' => __( 'Michoacán', 'invoicing' ), |
|
1190 | - 'MOR' => __( 'Morelos', 'invoicing' ), |
|
1191 | - 'NAY' => __( 'Nayarit', 'invoicing' ), |
|
1192 | - 'OAX' => __( 'Oaxaca', 'invoicing' ), |
|
1193 | - 'PUE' => __( 'Puebla', 'invoicing' ), |
|
1194 | - 'QUE' => __( 'Querétaro', 'invoicing' ), |
|
1195 | - 'ROO' => __( 'Quintana Roo', 'invoicing' ), |
|
1196 | - 'SLP' => __( 'San Luis Potosí', 'invoicing' ), |
|
1197 | - 'SIN' => __( 'Sinaloa', 'invoicing' ), |
|
1198 | - 'SON' => __( 'Sonora', 'invoicing' ), |
|
1199 | - 'TAB' => __( 'Tabasco', 'invoicing' ), |
|
1200 | - 'TAM' => __( 'Tamaulipas', 'invoicing' ), |
|
1201 | - 'TLA' => __( 'Tlaxcala', 'invoicing' ), |
|
1202 | - 'VER' => __( 'Veracruz', 'invoicing' ), |
|
1203 | - 'YUC' => __( 'Yucatán', 'invoicing' ), |
|
1204 | - 'ZAC' => __( 'Zacatecas', 'invoicing' ) |
|
1173 | + 'DIF' => __('Distrito Federal', 'invoicing'), |
|
1174 | + 'JAL' => __('Jalisco', 'invoicing'), |
|
1175 | + 'NLE' => __('Nuevo León', 'invoicing'), |
|
1176 | + 'AGU' => __('Aguascalientes', 'invoicing'), |
|
1177 | + 'BCN' => __('Baja California Norte', 'invoicing'), |
|
1178 | + 'BCS' => __('Baja California Sur', 'invoicing'), |
|
1179 | + 'CAM' => __('Campeche', 'invoicing'), |
|
1180 | + 'CHP' => __('Chiapas', 'invoicing'), |
|
1181 | + 'CHH' => __('Chihuahua', 'invoicing'), |
|
1182 | + 'COA' => __('Coahuila', 'invoicing'), |
|
1183 | + 'COL' => __('Colima', 'invoicing'), |
|
1184 | + 'DUR' => __('Durango', 'invoicing'), |
|
1185 | + 'GUA' => __('Guanajuato', 'invoicing'), |
|
1186 | + 'GRO' => __('Guerrero', 'invoicing'), |
|
1187 | + 'HID' => __('Hidalgo', 'invoicing'), |
|
1188 | + 'MEX' => __('Edo. de México', 'invoicing'), |
|
1189 | + 'MIC' => __('Michoacán', 'invoicing'), |
|
1190 | + 'MOR' => __('Morelos', 'invoicing'), |
|
1191 | + 'NAY' => __('Nayarit', 'invoicing'), |
|
1192 | + 'OAX' => __('Oaxaca', 'invoicing'), |
|
1193 | + 'PUE' => __('Puebla', 'invoicing'), |
|
1194 | + 'QUE' => __('Querétaro', 'invoicing'), |
|
1195 | + 'ROO' => __('Quintana Roo', 'invoicing'), |
|
1196 | + 'SLP' => __('San Luis Potosí', 'invoicing'), |
|
1197 | + 'SIN' => __('Sinaloa', 'invoicing'), |
|
1198 | + 'SON' => __('Sonora', 'invoicing'), |
|
1199 | + 'TAB' => __('Tabasco', 'invoicing'), |
|
1200 | + 'TAM' => __('Tamaulipas', 'invoicing'), |
|
1201 | + 'TLA' => __('Tlaxcala', 'invoicing'), |
|
1202 | + 'VER' => __('Veracruz', 'invoicing'), |
|
1203 | + 'YUC' => __('Yucatán', 'invoicing'), |
|
1204 | + 'ZAC' => __('Zacatecas', 'invoicing') |
|
1205 | 1205 | ); |
1206 | 1206 | |
1207 | - return apply_filters( 'wpinv_mexico_states', $states ); |
|
1207 | + return apply_filters('wpinv_mexico_states', $states); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | function wpinv_get_nepal_states_list() { |
1211 | 1211 | $states = array( |
1212 | - 'ILL' => __( 'Illam', 'invoicing' ), |
|
1213 | - 'JHA' => __( 'Jhapa', 'invoicing' ), |
|
1214 | - 'PAN' => __( 'Panchthar', 'invoicing' ), |
|
1215 | - 'TAP' => __( 'Taplejung', 'invoicing' ), |
|
1216 | - 'BHO' => __( 'Bhojpur', 'invoicing' ), |
|
1217 | - 'DKA' => __( 'Dhankuta', 'invoicing' ), |
|
1218 | - 'MOR' => __( 'Morang', 'invoicing' ), |
|
1219 | - 'SUN' => __( 'Sunsari', 'invoicing' ), |
|
1220 | - 'SAN' => __( 'Sankhuwa', 'invoicing' ), |
|
1221 | - 'TER' => __( 'Terhathum', 'invoicing' ), |
|
1222 | - 'KHO' => __( 'Khotang', 'invoicing' ), |
|
1223 | - 'OKH' => __( 'Okhaldhunga', 'invoicing' ), |
|
1224 | - 'SAP' => __( 'Saptari', 'invoicing' ), |
|
1225 | - 'SIR' => __( 'Siraha', 'invoicing' ), |
|
1226 | - 'SOL' => __( 'Solukhumbu', 'invoicing' ), |
|
1227 | - 'UDA' => __( 'Udayapur', 'invoicing' ), |
|
1228 | - 'DHA' => __( 'Dhanusa', 'invoicing' ), |
|
1229 | - 'DLK' => __( 'Dolakha', 'invoicing' ), |
|
1230 | - 'MOH' => __( 'Mohottari', 'invoicing' ), |
|
1231 | - 'RAM' => __( 'Ramechha', 'invoicing' ), |
|
1232 | - 'SAR' => __( 'Sarlahi', 'invoicing' ), |
|
1233 | - 'SIN' => __( 'Sindhuli', 'invoicing' ), |
|
1234 | - 'BHA' => __( 'Bhaktapur', 'invoicing' ), |
|
1235 | - 'DHD' => __( 'Dhading', 'invoicing' ), |
|
1236 | - 'KTM' => __( 'Kathmandu', 'invoicing' ), |
|
1237 | - 'KAV' => __( 'Kavrepalanchowk', 'invoicing' ), |
|
1238 | - 'LAL' => __( 'Lalitpur', 'invoicing' ), |
|
1239 | - 'NUW' => __( 'Nuwakot', 'invoicing' ), |
|
1240 | - 'RAS' => __( 'Rasuwa', 'invoicing' ), |
|
1241 | - 'SPC' => __( 'Sindhupalchowk', 'invoicing' ), |
|
1242 | - 'BAR' => __( 'Bara', 'invoicing' ), |
|
1243 | - 'CHI' => __( 'Chitwan', 'invoicing' ), |
|
1244 | - 'MAK' => __( 'Makwanpur', 'invoicing' ), |
|
1245 | - 'PAR' => __( 'Parsa', 'invoicing' ), |
|
1246 | - 'RAU' => __( 'Rautahat', 'invoicing' ), |
|
1247 | - 'GOR' => __( 'Gorkha', 'invoicing' ), |
|
1248 | - 'KAS' => __( 'Kaski', 'invoicing' ), |
|
1249 | - 'LAM' => __( 'Lamjung', 'invoicing' ), |
|
1250 | - 'MAN' => __( 'Manang', 'invoicing' ), |
|
1251 | - 'SYN' => __( 'Syangja', 'invoicing' ), |
|
1252 | - 'TAN' => __( 'Tanahun', 'invoicing' ), |
|
1253 | - 'BAG' => __( 'Baglung', 'invoicing' ), |
|
1254 | - 'PBT' => __( 'Parbat', 'invoicing' ), |
|
1255 | - 'MUS' => __( 'Mustang', 'invoicing' ), |
|
1256 | - 'MYG' => __( 'Myagdi', 'invoicing' ), |
|
1257 | - 'AGR' => __( 'Agrghakanchi', 'invoicing' ), |
|
1258 | - 'GUL' => __( 'Gulmi', 'invoicing' ), |
|
1259 | - 'KAP' => __( 'Kapilbastu', 'invoicing' ), |
|
1260 | - 'NAW' => __( 'Nawalparasi', 'invoicing' ), |
|
1261 | - 'PAL' => __( 'Palpa', 'invoicing' ), |
|
1262 | - 'RUP' => __( 'Rupandehi', 'invoicing' ), |
|
1263 | - 'DAN' => __( 'Dang', 'invoicing' ), |
|
1264 | - 'PYU' => __( 'Pyuthan', 'invoicing' ), |
|
1265 | - 'ROL' => __( 'Rolpa', 'invoicing' ), |
|
1266 | - 'RUK' => __( 'Rukum', 'invoicing' ), |
|
1267 | - 'SAL' => __( 'Salyan', 'invoicing' ), |
|
1268 | - 'BAN' => __( 'Banke', 'invoicing' ), |
|
1269 | - 'BDA' => __( 'Bardiya', 'invoicing' ), |
|
1270 | - 'DAI' => __( 'Dailekh', 'invoicing' ), |
|
1271 | - 'JAJ' => __( 'Jajarkot', 'invoicing' ), |
|
1272 | - 'SUR' => __( 'Surkhet', 'invoicing' ), |
|
1273 | - 'DOL' => __( 'Dolpa', 'invoicing' ), |
|
1274 | - 'HUM' => __( 'Humla', 'invoicing' ), |
|
1275 | - 'JUM' => __( 'Jumla', 'invoicing' ), |
|
1276 | - 'KAL' => __( 'Kalikot', 'invoicing' ), |
|
1277 | - 'MUG' => __( 'Mugu', 'invoicing' ), |
|
1278 | - 'ACH' => __( 'Achham', 'invoicing' ), |
|
1279 | - 'BJH' => __( 'Bajhang', 'invoicing' ), |
|
1280 | - 'BJU' => __( 'Bajura', 'invoicing' ), |
|
1281 | - 'DOT' => __( 'Doti', 'invoicing' ), |
|
1282 | - 'KAI' => __( 'Kailali', 'invoicing' ), |
|
1283 | - 'BAI' => __( 'Baitadi', 'invoicing' ), |
|
1284 | - 'DAD' => __( 'Dadeldhura', 'invoicing' ), |
|
1285 | - 'DAR' => __( 'Darchula', 'invoicing' ), |
|
1286 | - 'KAN' => __( 'Kanchanpur', 'invoicing' ) |
|
1212 | + 'ILL' => __('Illam', 'invoicing'), |
|
1213 | + 'JHA' => __('Jhapa', 'invoicing'), |
|
1214 | + 'PAN' => __('Panchthar', 'invoicing'), |
|
1215 | + 'TAP' => __('Taplejung', 'invoicing'), |
|
1216 | + 'BHO' => __('Bhojpur', 'invoicing'), |
|
1217 | + 'DKA' => __('Dhankuta', 'invoicing'), |
|
1218 | + 'MOR' => __('Morang', 'invoicing'), |
|
1219 | + 'SUN' => __('Sunsari', 'invoicing'), |
|
1220 | + 'SAN' => __('Sankhuwa', 'invoicing'), |
|
1221 | + 'TER' => __('Terhathum', 'invoicing'), |
|
1222 | + 'KHO' => __('Khotang', 'invoicing'), |
|
1223 | + 'OKH' => __('Okhaldhunga', 'invoicing'), |
|
1224 | + 'SAP' => __('Saptari', 'invoicing'), |
|
1225 | + 'SIR' => __('Siraha', 'invoicing'), |
|
1226 | + 'SOL' => __('Solukhumbu', 'invoicing'), |
|
1227 | + 'UDA' => __('Udayapur', 'invoicing'), |
|
1228 | + 'DHA' => __('Dhanusa', 'invoicing'), |
|
1229 | + 'DLK' => __('Dolakha', 'invoicing'), |
|
1230 | + 'MOH' => __('Mohottari', 'invoicing'), |
|
1231 | + 'RAM' => __('Ramechha', 'invoicing'), |
|
1232 | + 'SAR' => __('Sarlahi', 'invoicing'), |
|
1233 | + 'SIN' => __('Sindhuli', 'invoicing'), |
|
1234 | + 'BHA' => __('Bhaktapur', 'invoicing'), |
|
1235 | + 'DHD' => __('Dhading', 'invoicing'), |
|
1236 | + 'KTM' => __('Kathmandu', 'invoicing'), |
|
1237 | + 'KAV' => __('Kavrepalanchowk', 'invoicing'), |
|
1238 | + 'LAL' => __('Lalitpur', 'invoicing'), |
|
1239 | + 'NUW' => __('Nuwakot', 'invoicing'), |
|
1240 | + 'RAS' => __('Rasuwa', 'invoicing'), |
|
1241 | + 'SPC' => __('Sindhupalchowk', 'invoicing'), |
|
1242 | + 'BAR' => __('Bara', 'invoicing'), |
|
1243 | + 'CHI' => __('Chitwan', 'invoicing'), |
|
1244 | + 'MAK' => __('Makwanpur', 'invoicing'), |
|
1245 | + 'PAR' => __('Parsa', 'invoicing'), |
|
1246 | + 'RAU' => __('Rautahat', 'invoicing'), |
|
1247 | + 'GOR' => __('Gorkha', 'invoicing'), |
|
1248 | + 'KAS' => __('Kaski', 'invoicing'), |
|
1249 | + 'LAM' => __('Lamjung', 'invoicing'), |
|
1250 | + 'MAN' => __('Manang', 'invoicing'), |
|
1251 | + 'SYN' => __('Syangja', 'invoicing'), |
|
1252 | + 'TAN' => __('Tanahun', 'invoicing'), |
|
1253 | + 'BAG' => __('Baglung', 'invoicing'), |
|
1254 | + 'PBT' => __('Parbat', 'invoicing'), |
|
1255 | + 'MUS' => __('Mustang', 'invoicing'), |
|
1256 | + 'MYG' => __('Myagdi', 'invoicing'), |
|
1257 | + 'AGR' => __('Agrghakanchi', 'invoicing'), |
|
1258 | + 'GUL' => __('Gulmi', 'invoicing'), |
|
1259 | + 'KAP' => __('Kapilbastu', 'invoicing'), |
|
1260 | + 'NAW' => __('Nawalparasi', 'invoicing'), |
|
1261 | + 'PAL' => __('Palpa', 'invoicing'), |
|
1262 | + 'RUP' => __('Rupandehi', 'invoicing'), |
|
1263 | + 'DAN' => __('Dang', 'invoicing'), |
|
1264 | + 'PYU' => __('Pyuthan', 'invoicing'), |
|
1265 | + 'ROL' => __('Rolpa', 'invoicing'), |
|
1266 | + 'RUK' => __('Rukum', 'invoicing'), |
|
1267 | + 'SAL' => __('Salyan', 'invoicing'), |
|
1268 | + 'BAN' => __('Banke', 'invoicing'), |
|
1269 | + 'BDA' => __('Bardiya', 'invoicing'), |
|
1270 | + 'DAI' => __('Dailekh', 'invoicing'), |
|
1271 | + 'JAJ' => __('Jajarkot', 'invoicing'), |
|
1272 | + 'SUR' => __('Surkhet', 'invoicing'), |
|
1273 | + 'DOL' => __('Dolpa', 'invoicing'), |
|
1274 | + 'HUM' => __('Humla', 'invoicing'), |
|
1275 | + 'JUM' => __('Jumla', 'invoicing'), |
|
1276 | + 'KAL' => __('Kalikot', 'invoicing'), |
|
1277 | + 'MUG' => __('Mugu', 'invoicing'), |
|
1278 | + 'ACH' => __('Achham', 'invoicing'), |
|
1279 | + 'BJH' => __('Bajhang', 'invoicing'), |
|
1280 | + 'BJU' => __('Bajura', 'invoicing'), |
|
1281 | + 'DOT' => __('Doti', 'invoicing'), |
|
1282 | + 'KAI' => __('Kailali', 'invoicing'), |
|
1283 | + 'BAI' => __('Baitadi', 'invoicing'), |
|
1284 | + 'DAD' => __('Dadeldhura', 'invoicing'), |
|
1285 | + 'DAR' => __('Darchula', 'invoicing'), |
|
1286 | + 'KAN' => __('Kanchanpur', 'invoicing') |
|
1287 | 1287 | ); |
1288 | 1288 | |
1289 | - return apply_filters( 'wpinv_nepal_states', $states ); |
|
1289 | + return apply_filters('wpinv_nepal_states', $states); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | function wpinv_get_south_africa_states_list() { |
1293 | 1293 | $states = array( |
1294 | - 'EC' => __( 'Eastern Cape', 'invoicing' ), |
|
1295 | - 'FS' => __( 'Free State', 'invoicing' ), |
|
1296 | - 'GP' => __( 'Gauteng', 'invoicing' ), |
|
1297 | - 'KZN' => __( 'KwaZulu-Natal', 'invoicing' ), |
|
1298 | - 'LP' => __( 'Limpopo', 'invoicing' ), |
|
1299 | - 'MP' => __( 'Mpumalanga', 'invoicing' ), |
|
1300 | - 'NC' => __( 'Northern Cape', 'invoicing' ), |
|
1301 | - 'NW' => __( 'North West', 'invoicing' ), |
|
1302 | - 'WC' => __( 'Western Cape', 'invoicing' ) |
|
1294 | + 'EC' => __('Eastern Cape', 'invoicing'), |
|
1295 | + 'FS' => __('Free State', 'invoicing'), |
|
1296 | + 'GP' => __('Gauteng', 'invoicing'), |
|
1297 | + 'KZN' => __('KwaZulu-Natal', 'invoicing'), |
|
1298 | + 'LP' => __('Limpopo', 'invoicing'), |
|
1299 | + 'MP' => __('Mpumalanga', 'invoicing'), |
|
1300 | + 'NC' => __('Northern Cape', 'invoicing'), |
|
1301 | + 'NW' => __('North West', 'invoicing'), |
|
1302 | + 'WC' => __('Western Cape', 'invoicing') |
|
1303 | 1303 | ); |
1304 | 1304 | |
1305 | - return apply_filters( 'wpinv_south_africa_states', $states ); |
|
1305 | + return apply_filters('wpinv_south_africa_states', $states); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | function wpinv_get_thailand_states_list() { |
1309 | 1309 | $states = array( |
1310 | - 'TH-37' => __( 'Amnat Charoen (อำนาจเจริญ)', 'invoicing' ), |
|
1311 | - 'TH-15' => __( 'Ang Thong (อ่างทอง)', 'invoicing' ), |
|
1312 | - 'TH-14' => __( 'Ayutthaya (พระนครศรีอยุธยา)', 'invoicing' ), |
|
1313 | - 'TH-10' => __( 'Bangkok (กรุงเทพมหานคร)', 'invoicing' ), |
|
1314 | - 'TH-38' => __( 'Bueng Kan (บึงกาฬ)', 'invoicing' ), |
|
1315 | - 'TH-31' => __( 'Buri Ram (บุรีรัมย์)', 'invoicing' ), |
|
1316 | - 'TH-24' => __( 'Chachoengsao (ฉะเชิงเทรา)', 'invoicing' ), |
|
1317 | - 'TH-18' => __( 'Chai Nat (ชัยนาท)', 'invoicing' ), |
|
1318 | - 'TH-36' => __( 'Chaiyaphum (ชัยภูมิ)', 'invoicing' ), |
|
1319 | - 'TH-22' => __( 'Chanthaburi (จันทบุรี)', 'invoicing' ), |
|
1320 | - 'TH-50' => __( 'Chiang Mai (เชียงใหม่)', 'invoicing' ), |
|
1321 | - 'TH-57' => __( 'Chiang Rai (เชียงราย)', 'invoicing' ), |
|
1322 | - 'TH-20' => __( 'Chonburi (ชลบุรี)', 'invoicing' ), |
|
1323 | - 'TH-86' => __( 'Chumphon (ชุมพร)', 'invoicing' ), |
|
1324 | - 'TH-46' => __( 'Kalasin (กาฬสินธุ์)', 'invoicing' ), |
|
1325 | - 'TH-62' => __( 'Kamphaeng Phet (กำแพงเพชร)', 'invoicing' ), |
|
1326 | - 'TH-71' => __( 'Kanchanaburi (กาญจนบุรี)', 'invoicing' ), |
|
1327 | - 'TH-40' => __( 'Khon Kaen (ขอนแก่น)', 'invoicing' ), |
|
1328 | - 'TH-81' => __( 'Krabi (กระบี่)', 'invoicing' ), |
|
1329 | - 'TH-52' => __( 'Lampang (ลำปาง)', 'invoicing' ), |
|
1330 | - 'TH-51' => __( 'Lamphun (ลำพูน)', 'invoicing' ), |
|
1331 | - 'TH-42' => __( 'Loei (เลย)', 'invoicing' ), |
|
1332 | - 'TH-16' => __( 'Lopburi (ลพบุรี)', 'invoicing' ), |
|
1333 | - 'TH-58' => __( 'Mae Hong Son (แม่ฮ่องสอน)', 'invoicing' ), |
|
1334 | - 'TH-44' => __( 'Maha Sarakham (มหาสารคาม)', 'invoicing' ), |
|
1335 | - 'TH-49' => __( 'Mukdahan (มุกดาหาร)', 'invoicing' ), |
|
1336 | - 'TH-26' => __( 'Nakhon Nayok (นครนายก)', 'invoicing' ), |
|
1337 | - 'TH-73' => __( 'Nakhon Pathom (นครปฐม)', 'invoicing' ), |
|
1338 | - 'TH-48' => __( 'Nakhon Phanom (นครพนม)', 'invoicing' ), |
|
1339 | - 'TH-30' => __( 'Nakhon Ratchasima (นครราชสีมา)', 'invoicing' ), |
|
1340 | - 'TH-60' => __( 'Nakhon Sawan (นครสวรรค์)', 'invoicing' ), |
|
1341 | - 'TH-80' => __( 'Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing' ), |
|
1342 | - 'TH-55' => __( 'Nan (น่าน)', 'invoicing' ), |
|
1343 | - 'TH-96' => __( 'Narathiwat (นราธิวาส)', 'invoicing' ), |
|
1344 | - 'TH-39' => __( 'Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing' ), |
|
1345 | - 'TH-43' => __( 'Nong Khai (หนองคาย)', 'invoicing' ), |
|
1346 | - 'TH-12' => __( 'Nonthaburi (นนทบุรี)', 'invoicing' ), |
|
1347 | - 'TH-13' => __( 'Pathum Thani (ปทุมธานี)', 'invoicing' ), |
|
1348 | - 'TH-94' => __( 'Pattani (ปัตตานี)', 'invoicing' ), |
|
1349 | - 'TH-82' => __( 'Phang Nga (พังงา)', 'invoicing' ), |
|
1350 | - 'TH-93' => __( 'Phatthalung (พัทลุง)', 'invoicing' ), |
|
1351 | - 'TH-56' => __( 'Phayao (พะเยา)', 'invoicing' ), |
|
1352 | - 'TH-67' => __( 'Phetchabun (เพชรบูรณ์)', 'invoicing' ), |
|
1353 | - 'TH-76' => __( 'Phetchaburi (เพชรบุรี)', 'invoicing' ), |
|
1354 | - 'TH-66' => __( 'Phichit (พิจิตร)', 'invoicing' ), |
|
1355 | - 'TH-65' => __( 'Phitsanulok (พิษณุโลก)', 'invoicing' ), |
|
1356 | - 'TH-54' => __( 'Phrae (แพร่)', 'invoicing' ), |
|
1357 | - 'TH-83' => __( 'Phuket (ภูเก็ต)', 'invoicing' ), |
|
1358 | - 'TH-25' => __( 'Prachin Buri (ปราจีนบุรี)', 'invoicing' ), |
|
1359 | - 'TH-77' => __( 'Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing' ), |
|
1360 | - 'TH-85' => __( 'Ranong (ระนอง)', 'invoicing' ), |
|
1361 | - 'TH-70' => __( 'Ratchaburi (ราชบุรี)', 'invoicing' ), |
|
1362 | - 'TH-21' => __( 'Rayong (ระยอง)', 'invoicing' ), |
|
1363 | - 'TH-45' => __( 'Roi Et (ร้อยเอ็ด)', 'invoicing' ), |
|
1364 | - 'TH-27' => __( 'Sa Kaeo (สระแก้ว)', 'invoicing' ), |
|
1365 | - 'TH-47' => __( 'Sakon Nakhon (สกลนคร)', 'invoicing' ), |
|
1366 | - 'TH-11' => __( 'Samut Prakan (สมุทรปราการ)', 'invoicing' ), |
|
1367 | - 'TH-74' => __( 'Samut Sakhon (สมุทรสาคร)', 'invoicing' ), |
|
1368 | - 'TH-75' => __( 'Samut Songkhram (สมุทรสงคราม)', 'invoicing' ), |
|
1369 | - 'TH-19' => __( 'Saraburi (สระบุรี)', 'invoicing' ), |
|
1370 | - 'TH-91' => __( 'Satun (สตูล)', 'invoicing' ), |
|
1371 | - 'TH-17' => __( 'Sing Buri (สิงห์บุรี)', 'invoicing' ), |
|
1372 | - 'TH-33' => __( 'Sisaket (ศรีสะเกษ)', 'invoicing' ), |
|
1373 | - 'TH-90' => __( 'Songkhla (สงขลา)', 'invoicing' ), |
|
1374 | - 'TH-64' => __( 'Sukhothai (สุโขทัย)', 'invoicing' ), |
|
1375 | - 'TH-72' => __( 'Suphan Buri (สุพรรณบุรี)', 'invoicing' ), |
|
1376 | - 'TH-84' => __( 'Surat Thani (สุราษฎร์ธานี)', 'invoicing' ), |
|
1377 | - 'TH-32' => __( 'Surin (สุรินทร์)', 'invoicing' ), |
|
1378 | - 'TH-63' => __( 'Tak (ตาก)', 'invoicing' ), |
|
1379 | - 'TH-92' => __( 'Trang (ตรัง)', 'invoicing' ), |
|
1380 | - 'TH-23' => __( 'Trat (ตราด)', 'invoicing' ), |
|
1381 | - 'TH-34' => __( 'Ubon Ratchathani (อุบลราชธานี)', 'invoicing' ), |
|
1382 | - 'TH-41' => __( 'Udon Thani (อุดรธานี)', 'invoicing' ), |
|
1383 | - 'TH-61' => __( 'Uthai Thani (อุทัยธานี)', 'invoicing' ), |
|
1384 | - 'TH-53' => __( 'Uttaradit (อุตรดิตถ์)', 'invoicing' ), |
|
1385 | - 'TH-95' => __( 'Yala (ยะลา)', 'invoicing' ), |
|
1386 | - 'TH-35' => __( 'Yasothon (ยโสธร)', 'invoicing' ) |
|
1310 | + 'TH-37' => __('Amnat Charoen (อำนาจเจริญ)', 'invoicing'), |
|
1311 | + 'TH-15' => __('Ang Thong (อ่างทอง)', 'invoicing'), |
|
1312 | + 'TH-14' => __('Ayutthaya (พระนครศรีอยุธยา)', 'invoicing'), |
|
1313 | + 'TH-10' => __('Bangkok (กรุงเทพมหานคร)', 'invoicing'), |
|
1314 | + 'TH-38' => __('Bueng Kan (บึงกาฬ)', 'invoicing'), |
|
1315 | + 'TH-31' => __('Buri Ram (บุรีรัมย์)', 'invoicing'), |
|
1316 | + 'TH-24' => __('Chachoengsao (ฉะเชิงเทรา)', 'invoicing'), |
|
1317 | + 'TH-18' => __('Chai Nat (ชัยนาท)', 'invoicing'), |
|
1318 | + 'TH-36' => __('Chaiyaphum (ชัยภูมิ)', 'invoicing'), |
|
1319 | + 'TH-22' => __('Chanthaburi (จันทบุรี)', 'invoicing'), |
|
1320 | + 'TH-50' => __('Chiang Mai (เชียงใหม่)', 'invoicing'), |
|
1321 | + 'TH-57' => __('Chiang Rai (เชียงราย)', 'invoicing'), |
|
1322 | + 'TH-20' => __('Chonburi (ชลบุรี)', 'invoicing'), |
|
1323 | + 'TH-86' => __('Chumphon (ชุมพร)', 'invoicing'), |
|
1324 | + 'TH-46' => __('Kalasin (กาฬสินธุ์)', 'invoicing'), |
|
1325 | + 'TH-62' => __('Kamphaeng Phet (กำแพงเพชร)', 'invoicing'), |
|
1326 | + 'TH-71' => __('Kanchanaburi (กาญจนบุรี)', 'invoicing'), |
|
1327 | + 'TH-40' => __('Khon Kaen (ขอนแก่น)', 'invoicing'), |
|
1328 | + 'TH-81' => __('Krabi (กระบี่)', 'invoicing'), |
|
1329 | + 'TH-52' => __('Lampang (ลำปาง)', 'invoicing'), |
|
1330 | + 'TH-51' => __('Lamphun (ลำพูน)', 'invoicing'), |
|
1331 | + 'TH-42' => __('Loei (เลย)', 'invoicing'), |
|
1332 | + 'TH-16' => __('Lopburi (ลพบุรี)', 'invoicing'), |
|
1333 | + 'TH-58' => __('Mae Hong Son (แม่ฮ่องสอน)', 'invoicing'), |
|
1334 | + 'TH-44' => __('Maha Sarakham (มหาสารคาม)', 'invoicing'), |
|
1335 | + 'TH-49' => __('Mukdahan (มุกดาหาร)', 'invoicing'), |
|
1336 | + 'TH-26' => __('Nakhon Nayok (นครนายก)', 'invoicing'), |
|
1337 | + 'TH-73' => __('Nakhon Pathom (นครปฐม)', 'invoicing'), |
|
1338 | + 'TH-48' => __('Nakhon Phanom (นครพนม)', 'invoicing'), |
|
1339 | + 'TH-30' => __('Nakhon Ratchasima (นครราชสีมา)', 'invoicing'), |
|
1340 | + 'TH-60' => __('Nakhon Sawan (นครสวรรค์)', 'invoicing'), |
|
1341 | + 'TH-80' => __('Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing'), |
|
1342 | + 'TH-55' => __('Nan (น่าน)', 'invoicing'), |
|
1343 | + 'TH-96' => __('Narathiwat (นราธิวาส)', 'invoicing'), |
|
1344 | + 'TH-39' => __('Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing'), |
|
1345 | + 'TH-43' => __('Nong Khai (หนองคาย)', 'invoicing'), |
|
1346 | + 'TH-12' => __('Nonthaburi (นนทบุรี)', 'invoicing'), |
|
1347 | + 'TH-13' => __('Pathum Thani (ปทุมธานี)', 'invoicing'), |
|
1348 | + 'TH-94' => __('Pattani (ปัตตานี)', 'invoicing'), |
|
1349 | + 'TH-82' => __('Phang Nga (พังงา)', 'invoicing'), |
|
1350 | + 'TH-93' => __('Phatthalung (พัทลุง)', 'invoicing'), |
|
1351 | + 'TH-56' => __('Phayao (พะเยา)', 'invoicing'), |
|
1352 | + 'TH-67' => __('Phetchabun (เพชรบูรณ์)', 'invoicing'), |
|
1353 | + 'TH-76' => __('Phetchaburi (เพชรบุรี)', 'invoicing'), |
|
1354 | + 'TH-66' => __('Phichit (พิจิตร)', 'invoicing'), |
|
1355 | + 'TH-65' => __('Phitsanulok (พิษณุโลก)', 'invoicing'), |
|
1356 | + 'TH-54' => __('Phrae (แพร่)', 'invoicing'), |
|
1357 | + 'TH-83' => __('Phuket (ภูเก็ต)', 'invoicing'), |
|
1358 | + 'TH-25' => __('Prachin Buri (ปราจีนบุรี)', 'invoicing'), |
|
1359 | + 'TH-77' => __('Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing'), |
|
1360 | + 'TH-85' => __('Ranong (ระนอง)', 'invoicing'), |
|
1361 | + 'TH-70' => __('Ratchaburi (ราชบุรี)', 'invoicing'), |
|
1362 | + 'TH-21' => __('Rayong (ระยอง)', 'invoicing'), |
|
1363 | + 'TH-45' => __('Roi Et (ร้อยเอ็ด)', 'invoicing'), |
|
1364 | + 'TH-27' => __('Sa Kaeo (สระแก้ว)', 'invoicing'), |
|
1365 | + 'TH-47' => __('Sakon Nakhon (สกลนคร)', 'invoicing'), |
|
1366 | + 'TH-11' => __('Samut Prakan (สมุทรปราการ)', 'invoicing'), |
|
1367 | + 'TH-74' => __('Samut Sakhon (สมุทรสาคร)', 'invoicing'), |
|
1368 | + 'TH-75' => __('Samut Songkhram (สมุทรสงคราม)', 'invoicing'), |
|
1369 | + 'TH-19' => __('Saraburi (สระบุรี)', 'invoicing'), |
|
1370 | + 'TH-91' => __('Satun (สตูล)', 'invoicing'), |
|
1371 | + 'TH-17' => __('Sing Buri (สิงห์บุรี)', 'invoicing'), |
|
1372 | + 'TH-33' => __('Sisaket (ศรีสะเกษ)', 'invoicing'), |
|
1373 | + 'TH-90' => __('Songkhla (สงขลา)', 'invoicing'), |
|
1374 | + 'TH-64' => __('Sukhothai (สุโขทัย)', 'invoicing'), |
|
1375 | + 'TH-72' => __('Suphan Buri (สุพรรณบุรี)', 'invoicing'), |
|
1376 | + 'TH-84' => __('Surat Thani (สุราษฎร์ธานี)', 'invoicing'), |
|
1377 | + 'TH-32' => __('Surin (สุรินทร์)', 'invoicing'), |
|
1378 | + 'TH-63' => __('Tak (ตาก)', 'invoicing'), |
|
1379 | + 'TH-92' => __('Trang (ตรัง)', 'invoicing'), |
|
1380 | + 'TH-23' => __('Trat (ตราด)', 'invoicing'), |
|
1381 | + 'TH-34' => __('Ubon Ratchathani (อุบลราชธานี)', 'invoicing'), |
|
1382 | + 'TH-41' => __('Udon Thani (อุดรธานี)', 'invoicing'), |
|
1383 | + 'TH-61' => __('Uthai Thani (อุทัยธานี)', 'invoicing'), |
|
1384 | + 'TH-53' => __('Uttaradit (อุตรดิตถ์)', 'invoicing'), |
|
1385 | + 'TH-95' => __('Yala (ยะลา)', 'invoicing'), |
|
1386 | + 'TH-35' => __('Yasothon (ยโสธร)', 'invoicing') |
|
1387 | 1387 | ); |
1388 | 1388 | |
1389 | - return apply_filters( 'wpinv_thailand_states', $states ); |
|
1389 | + return apply_filters('wpinv_thailand_states', $states); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | function wpinv_get_turkey_states_list() { |
1393 | 1393 | $states = array( |
1394 | - 'TR01' => __( 'Adana', 'invoicing' ), |
|
1395 | - 'TR02' => __( 'Adıyaman', 'invoicing' ), |
|
1396 | - 'TR03' => __( 'Afyon', 'invoicing' ), |
|
1397 | - 'TR04' => __( 'Ağrı', 'invoicing' ), |
|
1398 | - 'TR05' => __( 'Amasya', 'invoicing' ), |
|
1399 | - 'TR06' => __( 'Ankara', 'invoicing' ), |
|
1400 | - 'TR07' => __( 'Antalya', 'invoicing' ), |
|
1401 | - 'TR08' => __( 'Artvin', 'invoicing' ), |
|
1402 | - 'TR09' => __( 'Aydın', 'invoicing' ), |
|
1403 | - 'TR10' => __( 'Balıkesir', 'invoicing' ), |
|
1404 | - 'TR11' => __( 'Bilecik', 'invoicing' ), |
|
1405 | - 'TR12' => __( 'Bingöl', 'invoicing' ), |
|
1406 | - 'TR13' => __( 'Bitlis', 'invoicing' ), |
|
1407 | - 'TR14' => __( 'Bolu', 'invoicing' ), |
|
1408 | - 'TR15' => __( 'Burdur', 'invoicing' ), |
|
1409 | - 'TR16' => __( 'Bursa', 'invoicing' ), |
|
1410 | - 'TR17' => __( 'Çanakkale', 'invoicing' ), |
|
1411 | - 'TR18' => __( 'Çankıkesir', 'invoicing' ), |
|
1412 | - 'TR19' => __( 'Çorum', 'invoicing' ), |
|
1413 | - 'TR20' => __( 'Denizli', 'invoicing' ), |
|
1414 | - 'TR21' => __( 'Diyarbakır', 'invoicing' ), |
|
1415 | - 'TR22' => __( 'Edirne', 'invoicing' ), |
|
1416 | - 'TR23' => __( 'Elazığ', 'invoicing' ), |
|
1417 | - 'TR24' => __( 'Erzincan', 'invoicing' ), |
|
1418 | - 'TR25' => __( 'Erzurum', 'invoicing' ), |
|
1419 | - 'TR26' => __( 'Eskişehir', 'invoicing' ), |
|
1420 | - 'TR27' => __( 'Gaziantep', 'invoicing' ), |
|
1421 | - 'TR28' => __( 'Giresun', 'invoicing' ), |
|
1422 | - 'TR29' => __( 'Gümüşhane', 'invoicing' ), |
|
1423 | - 'TR30' => __( 'Hakkari', 'invoicing' ), |
|
1424 | - 'TR31' => __( 'Hatay', 'invoicing' ), |
|
1425 | - 'TR32' => __( 'Isparta', 'invoicing' ), |
|
1426 | - 'TR33' => __( 'İçel', 'invoicing' ), |
|
1427 | - 'TR34' => __( 'İstanbul', 'invoicing' ), |
|
1428 | - 'TR35' => __( 'İzmir', 'invoicing' ), |
|
1429 | - 'TR36' => __( 'Kars', 'invoicing' ), |
|
1430 | - 'TR37' => __( 'Kastamonu', 'invoicing' ), |
|
1431 | - 'TR38' => __( 'Kayseri', 'invoicing' ), |
|
1432 | - 'TR39' => __( 'Kırklareli', 'invoicing' ), |
|
1433 | - 'TR40' => __( 'Kırşehir', 'invoicing' ), |
|
1434 | - 'TR41' => __( 'Kocaeli', 'invoicing' ), |
|
1435 | - 'TR42' => __( 'Konya', 'invoicing' ), |
|
1436 | - 'TR43' => __( 'Kütahya', 'invoicing' ), |
|
1437 | - 'TR44' => __( 'Malatya', 'invoicing' ), |
|
1438 | - 'TR45' => __( 'Manisa', 'invoicing' ), |
|
1439 | - 'TR46' => __( 'Kahramanmaraş', 'invoicing' ), |
|
1440 | - 'TR47' => __( 'Mardin', 'invoicing' ), |
|
1441 | - 'TR48' => __( 'Muğla', 'invoicing' ), |
|
1442 | - 'TR49' => __( 'Muş', 'invoicing' ), |
|
1443 | - 'TR50' => __( 'Nevşehir', 'invoicing' ), |
|
1444 | - 'TR51' => __( 'Niğde', 'invoicing' ), |
|
1445 | - 'TR52' => __( 'Ordu', 'invoicing' ), |
|
1446 | - 'TR53' => __( 'Rize', 'invoicing' ), |
|
1447 | - 'TR54' => __( 'Sakarya', 'invoicing' ), |
|
1448 | - 'TR55' => __( 'Samsun', 'invoicing' ), |
|
1449 | - 'TR56' => __( 'Siirt', 'invoicing' ), |
|
1450 | - 'TR57' => __( 'Sinop', 'invoicing' ), |
|
1451 | - 'TR58' => __( 'Sivas', 'invoicing' ), |
|
1452 | - 'TR59' => __( 'Tekirdağ', 'invoicing' ), |
|
1453 | - 'TR60' => __( 'Tokat', 'invoicing' ), |
|
1454 | - 'TR61' => __( 'Trabzon', 'invoicing' ), |
|
1455 | - 'TR62' => __( 'Tunceli', 'invoicing' ), |
|
1456 | - 'TR63' => __( 'Şanlıurfa', 'invoicing' ), |
|
1457 | - 'TR64' => __( 'Uşak', 'invoicing' ), |
|
1458 | - 'TR65' => __( 'Van', 'invoicing' ), |
|
1459 | - 'TR66' => __( 'Yozgat', 'invoicing' ), |
|
1460 | - 'TR67' => __( 'Zonguldak', 'invoicing' ), |
|
1461 | - 'TR68' => __( 'Aksaray', 'invoicing' ), |
|
1462 | - 'TR69' => __( 'Bayburt', 'invoicing' ), |
|
1463 | - 'TR70' => __( 'Karaman', 'invoicing' ), |
|
1464 | - 'TR71' => __( 'Kırıkkale', 'invoicing' ), |
|
1465 | - 'TR72' => __( 'Batman', 'invoicing' ), |
|
1466 | - 'TR73' => __( 'Şırnak', 'invoicing' ), |
|
1467 | - 'TR74' => __( 'Bartın', 'invoicing' ), |
|
1468 | - 'TR75' => __( 'Ardahan', 'invoicing' ), |
|
1469 | - 'TR76' => __( 'Iğdır', 'invoicing' ), |
|
1470 | - 'TR77' => __( 'Yalova', 'invoicing' ), |
|
1471 | - 'TR78' => __( 'Karabük', 'invoicing' ), |
|
1472 | - 'TR79' => __( 'Kilis', 'invoicing' ), |
|
1473 | - 'TR80' => __( 'Osmaniye', 'invoicing' ), |
|
1474 | - 'TR81' => __( 'Düzce', 'invoicing' ) |
|
1394 | + 'TR01' => __('Adana', 'invoicing'), |
|
1395 | + 'TR02' => __('Adıyaman', 'invoicing'), |
|
1396 | + 'TR03' => __('Afyon', 'invoicing'), |
|
1397 | + 'TR04' => __('Ağrı', 'invoicing'), |
|
1398 | + 'TR05' => __('Amasya', 'invoicing'), |
|
1399 | + 'TR06' => __('Ankara', 'invoicing'), |
|
1400 | + 'TR07' => __('Antalya', 'invoicing'), |
|
1401 | + 'TR08' => __('Artvin', 'invoicing'), |
|
1402 | + 'TR09' => __('Aydın', 'invoicing'), |
|
1403 | + 'TR10' => __('Balıkesir', 'invoicing'), |
|
1404 | + 'TR11' => __('Bilecik', 'invoicing'), |
|
1405 | + 'TR12' => __('Bingöl', 'invoicing'), |
|
1406 | + 'TR13' => __('Bitlis', 'invoicing'), |
|
1407 | + 'TR14' => __('Bolu', 'invoicing'), |
|
1408 | + 'TR15' => __('Burdur', 'invoicing'), |
|
1409 | + 'TR16' => __('Bursa', 'invoicing'), |
|
1410 | + 'TR17' => __('Çanakkale', 'invoicing'), |
|
1411 | + 'TR18' => __('Çankıkesir', 'invoicing'), |
|
1412 | + 'TR19' => __('Çorum', 'invoicing'), |
|
1413 | + 'TR20' => __('Denizli', 'invoicing'), |
|
1414 | + 'TR21' => __('Diyarbakır', 'invoicing'), |
|
1415 | + 'TR22' => __('Edirne', 'invoicing'), |
|
1416 | + 'TR23' => __('Elazığ', 'invoicing'), |
|
1417 | + 'TR24' => __('Erzincan', 'invoicing'), |
|
1418 | + 'TR25' => __('Erzurum', 'invoicing'), |
|
1419 | + 'TR26' => __('Eskişehir', 'invoicing'), |
|
1420 | + 'TR27' => __('Gaziantep', 'invoicing'), |
|
1421 | + 'TR28' => __('Giresun', 'invoicing'), |
|
1422 | + 'TR29' => __('Gümüşhane', 'invoicing'), |
|
1423 | + 'TR30' => __('Hakkari', 'invoicing'), |
|
1424 | + 'TR31' => __('Hatay', 'invoicing'), |
|
1425 | + 'TR32' => __('Isparta', 'invoicing'), |
|
1426 | + 'TR33' => __('İçel', 'invoicing'), |
|
1427 | + 'TR34' => __('İstanbul', 'invoicing'), |
|
1428 | + 'TR35' => __('İzmir', 'invoicing'), |
|
1429 | + 'TR36' => __('Kars', 'invoicing'), |
|
1430 | + 'TR37' => __('Kastamonu', 'invoicing'), |
|
1431 | + 'TR38' => __('Kayseri', 'invoicing'), |
|
1432 | + 'TR39' => __('Kırklareli', 'invoicing'), |
|
1433 | + 'TR40' => __('Kırşehir', 'invoicing'), |
|
1434 | + 'TR41' => __('Kocaeli', 'invoicing'), |
|
1435 | + 'TR42' => __('Konya', 'invoicing'), |
|
1436 | + 'TR43' => __('Kütahya', 'invoicing'), |
|
1437 | + 'TR44' => __('Malatya', 'invoicing'), |
|
1438 | + 'TR45' => __('Manisa', 'invoicing'), |
|
1439 | + 'TR46' => __('Kahramanmaraş', 'invoicing'), |
|
1440 | + 'TR47' => __('Mardin', 'invoicing'), |
|
1441 | + 'TR48' => __('Muğla', 'invoicing'), |
|
1442 | + 'TR49' => __('Muş', 'invoicing'), |
|
1443 | + 'TR50' => __('Nevşehir', 'invoicing'), |
|
1444 | + 'TR51' => __('Niğde', 'invoicing'), |
|
1445 | + 'TR52' => __('Ordu', 'invoicing'), |
|
1446 | + 'TR53' => __('Rize', 'invoicing'), |
|
1447 | + 'TR54' => __('Sakarya', 'invoicing'), |
|
1448 | + 'TR55' => __('Samsun', 'invoicing'), |
|
1449 | + 'TR56' => __('Siirt', 'invoicing'), |
|
1450 | + 'TR57' => __('Sinop', 'invoicing'), |
|
1451 | + 'TR58' => __('Sivas', 'invoicing'), |
|
1452 | + 'TR59' => __('Tekirdağ', 'invoicing'), |
|
1453 | + 'TR60' => __('Tokat', 'invoicing'), |
|
1454 | + 'TR61' => __('Trabzon', 'invoicing'), |
|
1455 | + 'TR62' => __('Tunceli', 'invoicing'), |
|
1456 | + 'TR63' => __('Şanlıurfa', 'invoicing'), |
|
1457 | + 'TR64' => __('Uşak', 'invoicing'), |
|
1458 | + 'TR65' => __('Van', 'invoicing'), |
|
1459 | + 'TR66' => __('Yozgat', 'invoicing'), |
|
1460 | + 'TR67' => __('Zonguldak', 'invoicing'), |
|
1461 | + 'TR68' => __('Aksaray', 'invoicing'), |
|
1462 | + 'TR69' => __('Bayburt', 'invoicing'), |
|
1463 | + 'TR70' => __('Karaman', 'invoicing'), |
|
1464 | + 'TR71' => __('Kırıkkale', 'invoicing'), |
|
1465 | + 'TR72' => __('Batman', 'invoicing'), |
|
1466 | + 'TR73' => __('Şırnak', 'invoicing'), |
|
1467 | + 'TR74' => __('Bartın', 'invoicing'), |
|
1468 | + 'TR75' => __('Ardahan', 'invoicing'), |
|
1469 | + 'TR76' => __('Iğdır', 'invoicing'), |
|
1470 | + 'TR77' => __('Yalova', 'invoicing'), |
|
1471 | + 'TR78' => __('Karabük', 'invoicing'), |
|
1472 | + 'TR79' => __('Kilis', 'invoicing'), |
|
1473 | + 'TR80' => __('Osmaniye', 'invoicing'), |
|
1474 | + 'TR81' => __('Düzce', 'invoicing') |
|
1475 | 1475 | ); |
1476 | 1476 | |
1477 | - return apply_filters( 'wpinv_turkey_states', $states ); |
|
1477 | + return apply_filters('wpinv_turkey_states', $states); |
|
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | function wpinv_get_spain_states_list() { |
1481 | 1481 | $states = array( |
1482 | - 'C' => __( 'A Coruña', 'invoicing' ), |
|
1483 | - 'VI' => __( 'Araba', 'invoicing' ), |
|
1484 | - 'AB' => __( 'Albacete', 'invoicing' ), |
|
1485 | - 'A' => __( 'Alicante', 'invoicing' ), |
|
1486 | - 'AL' => __( 'Almería', 'invoicing' ), |
|
1487 | - 'O' => __( 'Asturias', 'invoicing' ), |
|
1488 | - 'AV' => __( 'Ávila', 'invoicing' ), |
|
1489 | - 'BA' => __( 'Badajoz', 'invoicing' ), |
|
1490 | - 'PM' => __( 'Baleares', 'invoicing' ), |
|
1491 | - 'B' => __( 'Barcelona', 'invoicing' ), |
|
1492 | - 'BU' => __( 'Burgos', 'invoicing' ), |
|
1493 | - 'CC' => __( 'Cáceres', 'invoicing' ), |
|
1494 | - 'CA' => __( 'Cádiz', 'invoicing' ), |
|
1495 | - 'S' => __( 'Cantabria', 'invoicing' ), |
|
1496 | - 'CS' => __( 'Castellón', 'invoicing' ), |
|
1497 | - 'CE' => __( 'Ceuta', 'invoicing' ), |
|
1498 | - 'CR' => __( 'Ciudad Real', 'invoicing' ), |
|
1499 | - 'CO' => __( 'Córdoba', 'invoicing' ), |
|
1500 | - 'CU' => __( 'Cuenca', 'invoicing' ), |
|
1501 | - 'GI' => __( 'Girona', 'invoicing' ), |
|
1502 | - 'GR' => __( 'Granada', 'invoicing' ), |
|
1503 | - 'GU' => __( 'Guadalajara', 'invoicing' ), |
|
1504 | - 'SS' => __( 'Gipuzkoa', 'invoicing' ), |
|
1505 | - 'H' => __( 'Huelva', 'invoicing' ), |
|
1506 | - 'HU' => __( 'Huesca', 'invoicing' ), |
|
1507 | - 'J' => __( 'Jaén', 'invoicing' ), |
|
1508 | - 'LO' => __( 'La Rioja', 'invoicing' ), |
|
1509 | - 'GC' => __( 'Las Palmas', 'invoicing' ), |
|
1510 | - 'LE' => __( 'León', 'invoicing' ), |
|
1511 | - 'L' => __( 'Lleida', 'invoicing' ), |
|
1512 | - 'LU' => __( 'Lugo', 'invoicing' ), |
|
1513 | - 'M' => __( 'Madrid', 'invoicing' ), |
|
1514 | - 'MA' => __( 'Málaga', 'invoicing' ), |
|
1515 | - 'ML' => __( 'Melilla', 'invoicing' ), |
|
1516 | - 'MU' => __( 'Murcia', 'invoicing' ), |
|
1517 | - 'NA' => __( 'Navarra', 'invoicing' ), |
|
1518 | - 'OR' => __( 'Ourense', 'invoicing' ), |
|
1519 | - 'P' => __( 'Palencia', 'invoicing' ), |
|
1520 | - 'PO' => __( 'Pontevedra', 'invoicing' ), |
|
1521 | - 'SA' => __( 'Salamanca', 'invoicing' ), |
|
1522 | - 'TF' => __( 'Santa Cruz de Tenerife', 'invoicing' ), |
|
1523 | - 'SG' => __( 'Segovia', 'invoicing' ), |
|
1524 | - 'SE' => __( 'Sevilla', 'invoicing' ), |
|
1525 | - 'SO' => __( 'Soria', 'invoicing' ), |
|
1526 | - 'T' => __( 'Tarragona', 'invoicing' ), |
|
1527 | - 'TE' => __( 'Teruel', 'invoicing' ), |
|
1528 | - 'TO' => __( 'Toledo', 'invoicing' ), |
|
1529 | - 'V' => __( 'Valencia', 'invoicing' ), |
|
1530 | - 'VA' => __( 'Valladolid', 'invoicing' ), |
|
1531 | - 'BI' => __( 'Bizkaia', 'invoicing' ), |
|
1532 | - 'ZA' => __( 'Zamora', 'invoicing' ), |
|
1533 | - 'Z' => __( 'Zaragoza', 'invoicing' ) |
|
1482 | + 'C' => __('A Coruña', 'invoicing'), |
|
1483 | + 'VI' => __('Araba', 'invoicing'), |
|
1484 | + 'AB' => __('Albacete', 'invoicing'), |
|
1485 | + 'A' => __('Alicante', 'invoicing'), |
|
1486 | + 'AL' => __('Almería', 'invoicing'), |
|
1487 | + 'O' => __('Asturias', 'invoicing'), |
|
1488 | + 'AV' => __('Ávila', 'invoicing'), |
|
1489 | + 'BA' => __('Badajoz', 'invoicing'), |
|
1490 | + 'PM' => __('Baleares', 'invoicing'), |
|
1491 | + 'B' => __('Barcelona', 'invoicing'), |
|
1492 | + 'BU' => __('Burgos', 'invoicing'), |
|
1493 | + 'CC' => __('Cáceres', 'invoicing'), |
|
1494 | + 'CA' => __('Cádiz', 'invoicing'), |
|
1495 | + 'S' => __('Cantabria', 'invoicing'), |
|
1496 | + 'CS' => __('Castellón', 'invoicing'), |
|
1497 | + 'CE' => __('Ceuta', 'invoicing'), |
|
1498 | + 'CR' => __('Ciudad Real', 'invoicing'), |
|
1499 | + 'CO' => __('Córdoba', 'invoicing'), |
|
1500 | + 'CU' => __('Cuenca', 'invoicing'), |
|
1501 | + 'GI' => __('Girona', 'invoicing'), |
|
1502 | + 'GR' => __('Granada', 'invoicing'), |
|
1503 | + 'GU' => __('Guadalajara', 'invoicing'), |
|
1504 | + 'SS' => __('Gipuzkoa', 'invoicing'), |
|
1505 | + 'H' => __('Huelva', 'invoicing'), |
|
1506 | + 'HU' => __('Huesca', 'invoicing'), |
|
1507 | + 'J' => __('Jaén', 'invoicing'), |
|
1508 | + 'LO' => __('La Rioja', 'invoicing'), |
|
1509 | + 'GC' => __('Las Palmas', 'invoicing'), |
|
1510 | + 'LE' => __('León', 'invoicing'), |
|
1511 | + 'L' => __('Lleida', 'invoicing'), |
|
1512 | + 'LU' => __('Lugo', 'invoicing'), |
|
1513 | + 'M' => __('Madrid', 'invoicing'), |
|
1514 | + 'MA' => __('Málaga', 'invoicing'), |
|
1515 | + 'ML' => __('Melilla', 'invoicing'), |
|
1516 | + 'MU' => __('Murcia', 'invoicing'), |
|
1517 | + 'NA' => __('Navarra', 'invoicing'), |
|
1518 | + 'OR' => __('Ourense', 'invoicing'), |
|
1519 | + 'P' => __('Palencia', 'invoicing'), |
|
1520 | + 'PO' => __('Pontevedra', 'invoicing'), |
|
1521 | + 'SA' => __('Salamanca', 'invoicing'), |
|
1522 | + 'TF' => __('Santa Cruz de Tenerife', 'invoicing'), |
|
1523 | + 'SG' => __('Segovia', 'invoicing'), |
|
1524 | + 'SE' => __('Sevilla', 'invoicing'), |
|
1525 | + 'SO' => __('Soria', 'invoicing'), |
|
1526 | + 'T' => __('Tarragona', 'invoicing'), |
|
1527 | + 'TE' => __('Teruel', 'invoicing'), |
|
1528 | + 'TO' => __('Toledo', 'invoicing'), |
|
1529 | + 'V' => __('Valencia', 'invoicing'), |
|
1530 | + 'VA' => __('Valladolid', 'invoicing'), |
|
1531 | + 'BI' => __('Bizkaia', 'invoicing'), |
|
1532 | + 'ZA' => __('Zamora', 'invoicing'), |
|
1533 | + 'Z' => __('Zaragoza', 'invoicing') |
|
1534 | 1534 | ); |
1535 | 1535 | |
1536 | - return apply_filters( 'wpinv_spain_states', $states ); |
|
1536 | + return apply_filters('wpinv_spain_states', $states); |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | function wpinv_get_states_field() { |
1540 | - if( empty( $_POST['country'] ) ) { |
|
1540 | + if (empty($_POST['country'])) { |
|
1541 | 1541 | $_POST['country'] = wpinv_get_default_country(); |
1542 | 1542 | } |
1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
1543 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
1544 | 1544 | |
1545 | - if( !empty( $states ) ) { |
|
1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
1545 | + if (!empty($states)) { |
|
1546 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
1547 | 1547 | |
1548 | 1548 | $args = array( |
1549 | 1549 | 'name' => $sanitized_field_name, |
1550 | 1550 | 'id' => $sanitized_field_name, |
1551 | 1551 | 'class' => $sanitized_field_name . ' wpinv-select', |
1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1552 | + 'options' => array_merge(array('' => ''), $states), |
|
1553 | 1553 | 'show_option_all' => false, |
1554 | 1554 | 'show_option_none' => false |
1555 | 1555 | ); |
1556 | 1556 | |
1557 | - $response = wpinv_html_select( $args ); |
|
1557 | + $response = wpinv_html_select($args); |
|
1558 | 1558 | |
1559 | 1559 | } else { |
1560 | 1560 | $response = 'nostates'; |
@@ -1563,8 +1563,8 @@ discard block |
||
1563 | 1563 | return $response; |
1564 | 1564 | } |
1565 | 1565 | |
1566 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
1567 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
1566 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
1567 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
1568 | 1568 | |
1569 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
1569 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
1570 | 1570 | } |
1571 | 1571 | \ No newline at end of file |
@@ -7,440 +7,440 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_get_invoice_cart_id() { |
15 | 15 | $wpinv_checkout = wpinv_get_checkout_session(); |
16 | 16 | |
17 | - if ( !empty( $wpinv_checkout['invoice_id'] ) ) { |
|
17 | + if (!empty($wpinv_checkout['invoice_id'])) { |
|
18 | 18 | return $wpinv_checkout['invoice_id']; |
19 | 19 | } |
20 | 20 | |
21 | 21 | return NULL; |
22 | 22 | } |
23 | 23 | |
24 | -function wpinv_get_invoice( $invoice_id = 0, $cart = false ) { |
|
25 | - if ( $cart && empty( $invoice_id ) ) { |
|
24 | +function wpinv_get_invoice($invoice_id = 0, $cart = false) { |
|
25 | + if ($cart && empty($invoice_id)) { |
|
26 | 26 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
27 | 27 | } |
28 | 28 | |
29 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
29 | + $invoice = new WPInv_Invoice($invoice_id); |
|
30 | 30 | return $invoice; |
31 | 31 | } |
32 | 32 | |
33 | -function wpinv_get_invoice_cart( $invoice_id = 0 ) { |
|
34 | - return wpinv_get_invoice( $invoice_id, true ); |
|
33 | +function wpinv_get_invoice_cart($invoice_id = 0) { |
|
34 | + return wpinv_get_invoice($invoice_id, true); |
|
35 | 35 | } |
36 | 36 | |
37 | -function wpinv_get_invoice_description( $invoice_id = 0 ) { |
|
38 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
37 | +function wpinv_get_invoice_description($invoice_id = 0) { |
|
38 | + $invoice = new WPInv_Invoice($invoice_id); |
|
39 | 39 | return $invoice->get_description(); |
40 | 40 | } |
41 | 41 | |
42 | -function wpinv_get_invoice_currency_code( $invoice_id = 0 ) { |
|
43 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
42 | +function wpinv_get_invoice_currency_code($invoice_id = 0) { |
|
43 | + $invoice = new WPInv_Invoice($invoice_id); |
|
44 | 44 | return $invoice->get_currency(); |
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_get_payment_user_email( $invoice_id ) { |
|
48 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
47 | +function wpinv_get_payment_user_email($invoice_id) { |
|
48 | + $invoice = new WPInv_Invoice($invoice_id); |
|
49 | 49 | return $invoice->get_email(); |
50 | 50 | } |
51 | 51 | |
52 | -function wpinv_get_user_id( $invoice_id ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
52 | +function wpinv_get_user_id($invoice_id) { |
|
53 | + $invoice = new WPInv_Invoice($invoice_id); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | -function wpinv_get_invoice_status( $invoice_id, $return_label = false ) { |
|
58 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
57 | +function wpinv_get_invoice_status($invoice_id, $return_label = false) { |
|
58 | + $invoice = new WPInv_Invoice($invoice_id); |
|
59 | 59 | |
60 | - return $invoice->get_status( $return_label ); |
|
60 | + return $invoice->get_status($return_label); |
|
61 | 61 | } |
62 | 62 | |
63 | -function wpinv_get_payment_gateway( $invoice_id, $return_label = false ) { |
|
64 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
63 | +function wpinv_get_payment_gateway($invoice_id, $return_label = false) { |
|
64 | + $invoice = new WPInv_Invoice($invoice_id); |
|
65 | 65 | |
66 | - return $invoice->get_gateway( $return_label ); |
|
66 | + return $invoice->get_gateway($return_label); |
|
67 | 67 | } |
68 | 68 | |
69 | -function wpinv_get_payment_gateway_name( $invoice_id ) { |
|
70 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
69 | +function wpinv_get_payment_gateway_name($invoice_id) { |
|
70 | + $invoice = new WPInv_Invoice($invoice_id); |
|
71 | 71 | |
72 | 72 | return $invoice->get_gateway_title(); |
73 | 73 | } |
74 | 74 | |
75 | -function wpinv_get_payment_transaction_id( $invoice_id ) { |
|
76 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
75 | +function wpinv_get_payment_transaction_id($invoice_id) { |
|
76 | + $invoice = new WPInv_Invoice($invoice_id); |
|
77 | 77 | |
78 | 78 | return $invoice->get_transaction_id(); |
79 | 79 | } |
80 | 80 | |
81 | -function wpinv_get_id_by_transaction_id( $key ) { |
|
81 | +function wpinv_get_id_by_transaction_id($key) { |
|
82 | 82 | global $wpdb; |
83 | 83 | |
84 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
84 | + $invoice_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
85 | 85 | |
86 | - if ( $invoice_id != NULL ) |
|
86 | + if ($invoice_id != NULL) |
|
87 | 87 | return $invoice_id; |
88 | 88 | |
89 | 89 | return 0; |
90 | 90 | } |
91 | 91 | |
92 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
93 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
92 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
93 | + $invoice = new WPInv_Invoice($invoice_id); |
|
94 | 94 | |
95 | - return $invoice->get_meta( $meta_key, $single ); |
|
95 | + return $invoice->get_meta($meta_key, $single); |
|
96 | 96 | } |
97 | 97 | |
98 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
99 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
98 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
99 | + $invoice = new WPInv_Invoice($invoice_id); |
|
100 | 100 | |
101 | - return $invoice->update_meta( $meta_key, $meta_value, $prev_value ); |
|
101 | + return $invoice->update_meta($meta_key, $meta_value, $prev_value); |
|
102 | 102 | } |
103 | 103 | |
104 | -function wpinv_get_items( $invoice_id = 0 ) { |
|
105 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
104 | +function wpinv_get_items($invoice_id = 0) { |
|
105 | + $invoice = wpinv_get_invoice($invoice_id); |
|
106 | 106 | |
107 | 107 | $items = $invoice->get_items(); |
108 | 108 | $invoice_currency = $invoice->get_currency(); |
109 | 109 | |
110 | - if ( !empty( $items ) && is_array( $items ) ) { |
|
111 | - foreach ( $items as $key => $item ) { |
|
110 | + if (!empty($items) && is_array($items)) { |
|
111 | + foreach ($items as $key => $item) { |
|
112 | 112 | $items[$key]['currency'] = $invoice_currency; |
113 | 113 | |
114 | - if ( !isset( $cart_item['subtotal'] ) ) { |
|
114 | + if (!isset($cart_item['subtotal'])) { |
|
115 | 115 | $items[$key]['subtotal'] = $items[$key]['amount'] * 1; |
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - return apply_filters( 'wpinv_get_items', $items, $invoice_id ); |
|
120 | + return apply_filters('wpinv_get_items', $items, $invoice_id); |
|
121 | 121 | } |
122 | 122 | |
123 | -function wpinv_get_fees( $invoice_id = 0 ) { |
|
124 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
123 | +function wpinv_get_fees($invoice_id = 0) { |
|
124 | + $invoice = wpinv_get_invoice($invoice_id); |
|
125 | 125 | $fees = $invoice->get_fees(); |
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_fees', $fees, $invoice_id ); |
|
127 | + return apply_filters('wpinv_get_fees', $fees, $invoice_id); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_get_invoice_ip( $invoice_id ) { |
|
131 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
130 | +function wpinv_get_invoice_ip($invoice_id) { |
|
131 | + $invoice = new WPInv_Invoice($invoice_id); |
|
132 | 132 | return $invoice->get_ip(); |
133 | 133 | } |
134 | 134 | |
135 | -function wpinv_get_invoice_user_info( $invoice_id ) { |
|
136 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
135 | +function wpinv_get_invoice_user_info($invoice_id) { |
|
136 | + $invoice = new WPInv_Invoice($invoice_id); |
|
137 | 137 | return $invoice->get_user_info(); |
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_subtotal( $invoice_id = 0, $currency = false ) { |
|
141 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
140 | +function wpinv_subtotal($invoice_id = 0, $currency = false) { |
|
141 | + $invoice = new WPInv_Invoice($invoice_id); |
|
142 | 142 | |
143 | - return $invoice->get_subtotal( $currency ); |
|
143 | + return $invoice->get_subtotal($currency); |
|
144 | 144 | } |
145 | 145 | |
146 | -function wpinv_tax( $invoice_id = 0, $currency = false ) { |
|
147 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
146 | +function wpinv_tax($invoice_id = 0, $currency = false) { |
|
147 | + $invoice = new WPInv_Invoice($invoice_id); |
|
148 | 148 | |
149 | - return $invoice->get_tax( $currency ); |
|
149 | + return $invoice->get_tax($currency); |
|
150 | 150 | } |
151 | 151 | |
152 | -function wpinv_discount( $invoice_id = 0, $currency = false, $dash = false ) { |
|
153 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
152 | +function wpinv_discount($invoice_id = 0, $currency = false, $dash = false) { |
|
153 | + $invoice = wpinv_get_invoice($invoice_id); |
|
154 | 154 | |
155 | - return $invoice->get_discount( $currency, $dash ); |
|
155 | + return $invoice->get_discount($currency, $dash); |
|
156 | 156 | } |
157 | 157 | |
158 | -function wpinv_discount_code( $invoice_id = 0 ) { |
|
159 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
158 | +function wpinv_discount_code($invoice_id = 0) { |
|
159 | + $invoice = new WPInv_Invoice($invoice_id); |
|
160 | 160 | |
161 | 161 | return $invoice->get_discount_code(); |
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_payment_total( $invoice_id = 0, $currency = false ) { |
|
165 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
164 | +function wpinv_payment_total($invoice_id = 0, $currency = false) { |
|
165 | + $invoice = new WPInv_Invoice($invoice_id); |
|
166 | 166 | |
167 | - return $invoice->get_total( $currency ); |
|
167 | + return $invoice->get_total($currency); |
|
168 | 168 | } |
169 | 169 | |
170 | -function wpinv_get_date_created( $invoice_id = 0 ) { |
|
171 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
170 | +function wpinv_get_date_created($invoice_id = 0) { |
|
171 | + $invoice = new WPInv_Invoice($invoice_id); |
|
172 | 172 | |
173 | 173 | $date_created = $invoice->get_created_date(); |
174 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ), strtotime( $date_created ) ) : ''; |
|
174 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format'), strtotime($date_created)) : ''; |
|
175 | 175 | |
176 | 176 | return $date_created; |
177 | 177 | } |
178 | 178 | |
179 | -function wpinv_get_invoice_date( $invoice_id = 0, $format = '' ) { |
|
180 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
179 | +function wpinv_get_invoice_date($invoice_id = 0, $format = '') { |
|
180 | + $invoice = new WPInv_Invoice($invoice_id); |
|
181 | 181 | |
182 | - $format = !empty( $format ) ? $format : get_option( 'date_format' ); |
|
182 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
183 | 183 | $date_completed = $invoice->get_completed_date(); |
184 | - $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_completed ) ) : ''; |
|
185 | - if ( $invoice_date == '' ) { |
|
184 | + $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_completed)) : ''; |
|
185 | + if ($invoice_date == '') { |
|
186 | 186 | $date_created = $invoice->get_created_date(); |
187 | - $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
187 | + $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_created)) : ''; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | return $invoice_date; |
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_get_invoice_vat_number( $invoice_id = 0 ) { |
|
194 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
193 | +function wpinv_get_invoice_vat_number($invoice_id = 0) { |
|
194 | + $invoice = new WPInv_Invoice($invoice_id); |
|
195 | 195 | |
196 | 196 | return $invoice->vat_number; |
197 | 197 | } |
198 | 198 | |
199 | -function wpinv_insert_payment_note( $invoice_id = 0, $note = '', $user_type = false, $added_by_user = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
199 | +function wpinv_insert_payment_note($invoice_id = 0, $note = '', $user_type = false, $added_by_user = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice_id); |
|
201 | 201 | |
202 | - return $invoice->add_note( $note, $user_type, $added_by_user ); |
|
202 | + return $invoice->add_note($note, $user_type, $added_by_user); |
|
203 | 203 | } |
204 | 204 | |
205 | -function wpinv_get_invoice_notes( $invoice_id = 0, $type = '' ) { |
|
205 | +function wpinv_get_invoice_notes($invoice_id = 0, $type = '') { |
|
206 | 206 | global $invoicing; |
207 | 207 | |
208 | - if ( empty( $invoice_id ) ) { |
|
208 | + if (empty($invoice_id)) { |
|
209 | 209 | return NULL; |
210 | 210 | } |
211 | 211 | |
212 | - $notes = $invoicing->notes->get_invoice_notes( $invoice_id, $type ); |
|
212 | + $notes = $invoicing->notes->get_invoice_notes($invoice_id, $type); |
|
213 | 213 | |
214 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice_id, $type ); |
|
214 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice_id, $type); |
|
215 | 215 | } |
216 | 216 | |
217 | -function wpinv_get_payment_key( $invoice_id = 0 ) { |
|
218 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
217 | +function wpinv_get_payment_key($invoice_id = 0) { |
|
218 | + $invoice = new WPInv_Invoice($invoice_id); |
|
219 | 219 | return $invoice->get_key(); |
220 | 220 | } |
221 | 221 | |
222 | -function wpinv_get_invoice_number( $invoice_id = 0 ) { |
|
223 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
222 | +function wpinv_get_invoice_number($invoice_id = 0) { |
|
223 | + $invoice = new WPInv_Invoice($invoice_id); |
|
224 | 224 | return $invoice->get_number(); |
225 | 225 | } |
226 | 226 | |
227 | -function wpinv_get_cart_discountable_subtotal( $code_id ) { |
|
227 | +function wpinv_get_cart_discountable_subtotal($code_id) { |
|
228 | 228 | $cart_items = wpinv_get_cart_content_details(); |
229 | 229 | $items = array(); |
230 | 230 | |
231 | - $excluded_items = wpinv_get_discount_excluded_items( $code_id ); |
|
231 | + $excluded_items = wpinv_get_discount_excluded_items($code_id); |
|
232 | 232 | |
233 | - if( $cart_items ) { |
|
233 | + if ($cart_items) { |
|
234 | 234 | |
235 | - foreach( $cart_items as $item ) { |
|
235 | + foreach ($cart_items as $item) { |
|
236 | 236 | |
237 | - if( ! in_array( $item['id'], $excluded_items ) ) { |
|
238 | - $items[] = $item; |
|
237 | + if (!in_array($item['id'], $excluded_items)) { |
|
238 | + $items[] = $item; |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - $subtotal = wpinv_get_cart_items_subtotal( $items ); |
|
243 | + $subtotal = wpinv_get_cart_items_subtotal($items); |
|
244 | 244 | |
245 | - return apply_filters( 'wpinv_get_cart_discountable_subtotal', $subtotal ); |
|
245 | + return apply_filters('wpinv_get_cart_discountable_subtotal', $subtotal); |
|
246 | 246 | } |
247 | 247 | |
248 | -function wpinv_get_cart_items_subtotal( $items ) { |
|
248 | +function wpinv_get_cart_items_subtotal($items) { |
|
249 | 249 | $subtotal = 0.00; |
250 | 250 | |
251 | - if ( is_array( $items ) && ! empty( $items ) ) { |
|
252 | - $prices = wp_list_pluck( $items, 'subtotal' ); |
|
251 | + if (is_array($items) && !empty($items)) { |
|
252 | + $prices = wp_list_pluck($items, 'subtotal'); |
|
253 | 253 | |
254 | - if( is_array( $prices ) ) { |
|
255 | - $subtotal = array_sum( $prices ); |
|
254 | + if (is_array($prices)) { |
|
255 | + $subtotal = array_sum($prices); |
|
256 | 256 | } else { |
257 | 257 | $subtotal = 0.00; |
258 | 258 | } |
259 | 259 | |
260 | - if( $subtotal < 0 ) { |
|
260 | + if ($subtotal < 0) { |
|
261 | 261 | $subtotal = 0.00; |
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
265 | - return apply_filters( 'wpinv_get_cart_items_subtotal', $subtotal ); |
|
265 | + return apply_filters('wpinv_get_cart_items_subtotal', $subtotal); |
|
266 | 266 | } |
267 | 267 | |
268 | -function wpinv_get_cart_subtotal( $items = array() ) { |
|
269 | - $items = !empty( $items ) ? $items : wpinv_get_cart_content_details(); |
|
270 | - $subtotal = wpinv_get_cart_items_subtotal( $items ); |
|
268 | +function wpinv_get_cart_subtotal($items = array()) { |
|
269 | + $items = !empty($items) ? $items : wpinv_get_cart_content_details(); |
|
270 | + $subtotal = wpinv_get_cart_items_subtotal($items); |
|
271 | 271 | |
272 | - return apply_filters( 'wpinv_get_cart_subtotal', $subtotal ); |
|
272 | + return apply_filters('wpinv_get_cart_subtotal', $subtotal); |
|
273 | 273 | } |
274 | 274 | |
275 | -function wpinv_cart_subtotal( $items = array() ) { |
|
276 | - $price = wpinv_price( wpinv_format_amount( wpinv_get_cart_subtotal( $items ) ) ); |
|
275 | +function wpinv_cart_subtotal($items = array()) { |
|
276 | + $price = wpinv_price(wpinv_format_amount(wpinv_get_cart_subtotal($items))); |
|
277 | 277 | |
278 | 278 | // Todo - Show tax labels here (if needed) |
279 | 279 | |
280 | 280 | return $price; |
281 | 281 | } |
282 | 282 | |
283 | -function wpinv_get_cart_total( $items = array(), $discounts = false, $invoice = array() ) { |
|
284 | - $subtotal = (float)wpinv_get_cart_subtotal( $items ); |
|
285 | - $discounts = (float)wpinv_get_cart_discounted_amount( $items ); |
|
286 | - $cart_tax = (float)wpinv_get_cart_tax( $items ); |
|
283 | +function wpinv_get_cart_total($items = array(), $discounts = false, $invoice = array()) { |
|
284 | + $subtotal = (float)wpinv_get_cart_subtotal($items); |
|
285 | + $discounts = (float)wpinv_get_cart_discounted_amount($items); |
|
286 | + $cart_tax = (float)wpinv_get_cart_tax($items); |
|
287 | 287 | $fees = (float)wpinv_get_cart_fee_total(); |
288 | - if ( !empty( $invoice ) && $invoice->is_free_trial() ) { |
|
288 | + if (!empty($invoice) && $invoice->is_free_trial()) { |
|
289 | 289 | $total = 0; |
290 | 290 | } else { |
291 | - $total = $subtotal - $discounts + $cart_tax + $fees; |
|
291 | + $total = $subtotal - $discounts + $cart_tax + $fees; |
|
292 | 292 | } |
293 | 293 | |
294 | - if ( $total < 0 ) { |
|
294 | + if ($total < 0) { |
|
295 | 295 | $total = 0.00; |
296 | 296 | } |
297 | 297 | |
298 | - $total = (float)apply_filters( 'wpinv_get_cart_total', $total, $items ); |
|
298 | + $total = (float)apply_filters('wpinv_get_cart_total', $total, $items); |
|
299 | 299 | |
300 | - return wpinv_sanitize_amount( $total ); |
|
300 | + return wpinv_sanitize_amount($total); |
|
301 | 301 | } |
302 | 302 | |
303 | -function wpinv_cart_total( $cart_items = array(), $echo = true, $invoice = array() ) { |
|
303 | +function wpinv_cart_total($cart_items = array(), $echo = true, $invoice = array()) { |
|
304 | 304 | global $cart_total; |
305 | - $total = wpinv_price( wpinv_format_amount( wpinv_get_cart_total( $cart_items, NULL, $invoice ) ) ); |
|
306 | - $total = apply_filters( 'wpinv_cart_total', $total, $cart_items, $invoice ); |
|
305 | + $total = wpinv_price(wpinv_format_amount(wpinv_get_cart_total($cart_items, NULL, $invoice))); |
|
306 | + $total = apply_filters('wpinv_cart_total', $total, $cart_items, $invoice); |
|
307 | 307 | |
308 | 308 | // Todo - Show tax labels here (if needed) |
309 | 309 | |
310 | 310 | $cart_total = $total; |
311 | 311 | |
312 | - if ( !$echo ) { |
|
312 | + if (!$echo) { |
|
313 | 313 | return $total; |
314 | 314 | } |
315 | 315 | |
316 | 316 | echo $total; |
317 | 317 | } |
318 | 318 | |
319 | -function wpinv_get_cart_tax( $items = array() ) { |
|
319 | +function wpinv_get_cart_tax($items = array()) { |
|
320 | 320 | $cart_tax = 0; |
321 | - $items = !empty( $items ) ? $items : wpinv_get_cart_content_details(); |
|
321 | + $items = !empty($items) ? $items : wpinv_get_cart_content_details(); |
|
322 | 322 | |
323 | - if ( $items ) { |
|
324 | - $taxes = wp_list_pluck( $items, 'tax' ); |
|
323 | + if ($items) { |
|
324 | + $taxes = wp_list_pluck($items, 'tax'); |
|
325 | 325 | |
326 | - if( is_array( $taxes ) ) { |
|
327 | - $cart_tax = array_sum( $taxes ); |
|
326 | + if (is_array($taxes)) { |
|
327 | + $cart_tax = array_sum($taxes); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | 331 | $cart_tax += wpinv_get_cart_fee_tax(); |
332 | 332 | |
333 | - return apply_filters( 'wpinv_get_cart_tax', wpinv_sanitize_amount( $cart_tax ) ); |
|
333 | + return apply_filters('wpinv_get_cart_tax', wpinv_sanitize_amount($cart_tax)); |
|
334 | 334 | } |
335 | 335 | |
336 | -function wpinv_cart_tax( $items = array(), $echo = false ) { |
|
337 | - $cart_tax = wpinv_get_cart_tax( $items ); |
|
338 | - $cart_tax = wpinv_price( wpinv_format_amount( $cart_tax ) ); |
|
336 | +function wpinv_cart_tax($items = array(), $echo = false) { |
|
337 | + $cart_tax = wpinv_get_cart_tax($items); |
|
338 | + $cart_tax = wpinv_price(wpinv_format_amount($cart_tax)); |
|
339 | 339 | |
340 | - $tax = apply_filters( 'wpinv_cart_tax', $cart_tax, $items ); |
|
340 | + $tax = apply_filters('wpinv_cart_tax', $cart_tax, $items); |
|
341 | 341 | |
342 | - if ( !$echo ) { |
|
342 | + if (!$echo) { |
|
343 | 343 | return $tax; |
344 | 344 | } |
345 | 345 | |
346 | 346 | echo $tax; |
347 | 347 | } |
348 | 348 | |
349 | -function wpinv_get_cart_discount_code( $items = array() ) { |
|
349 | +function wpinv_get_cart_discount_code($items = array()) { |
|
350 | 350 | $invoice = wpinv_get_invoice_cart(); |
351 | - $cart_discount_code = !empty( $invoice ) ? $invoice->get_discount_code() : ''; |
|
351 | + $cart_discount_code = !empty($invoice) ? $invoice->get_discount_code() : ''; |
|
352 | 352 | |
353 | - return apply_filters( 'wpinv_get_cart_discount_code', $cart_discount_code ); |
|
353 | + return apply_filters('wpinv_get_cart_discount_code', $cart_discount_code); |
|
354 | 354 | } |
355 | 355 | |
356 | -function wpinv_cart_discount_code( $items = array(), $echo = false ) { |
|
357 | - $cart_discount_code = wpinv_get_cart_discount_code( $items ); |
|
356 | +function wpinv_cart_discount_code($items = array(), $echo = false) { |
|
357 | + $cart_discount_code = wpinv_get_cart_discount_code($items); |
|
358 | 358 | |
359 | - if ( $cart_discount_code != '' ) { |
|
359 | + if ($cart_discount_code != '') { |
|
360 | 360 | $cart_discount_code = ' (' . $cart_discount_code . ')'; |
361 | 361 | } |
362 | 362 | |
363 | - $discount_code = apply_filters( 'wpinv_cart_discount_code', $cart_discount_code, $items ); |
|
363 | + $discount_code = apply_filters('wpinv_cart_discount_code', $cart_discount_code, $items); |
|
364 | 364 | |
365 | - if ( !$echo ) { |
|
365 | + if (!$echo) { |
|
366 | 366 | return $discount_code; |
367 | 367 | } |
368 | 368 | |
369 | 369 | echo $discount_code; |
370 | 370 | } |
371 | 371 | |
372 | -function wpinv_get_cart_discount( $items = array() ) { |
|
372 | +function wpinv_get_cart_discount($items = array()) { |
|
373 | 373 | $invoice = wpinv_get_invoice_cart(); |
374 | - $cart_discount = !empty( $invoice ) ? $invoice->get_discount() : 0; |
|
374 | + $cart_discount = !empty($invoice) ? $invoice->get_discount() : 0; |
|
375 | 375 | |
376 | - return apply_filters( 'wpinv_get_cart_discount', wpinv_sanitize_amount( $cart_discount ), $items ); |
|
376 | + return apply_filters('wpinv_get_cart_discount', wpinv_sanitize_amount($cart_discount), $items); |
|
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_cart_discount( $items = array(), $echo = false ) { |
|
380 | - $cart_discount = wpinv_get_cart_discount( $items ); |
|
381 | - $cart_discount = wpinv_price( wpinv_format_amount( $cart_discount ) ); |
|
379 | +function wpinv_cart_discount($items = array(), $echo = false) { |
|
380 | + $cart_discount = wpinv_get_cart_discount($items); |
|
381 | + $cart_discount = wpinv_price(wpinv_format_amount($cart_discount)); |
|
382 | 382 | |
383 | - $discount = apply_filters( 'wpinv_cart_discount', $cart_discount, $items ); |
|
383 | + $discount = apply_filters('wpinv_cart_discount', $cart_discount, $items); |
|
384 | 384 | |
385 | - if ( !$echo ) { |
|
385 | + if (!$echo) { |
|
386 | 386 | return $discount; |
387 | 387 | } |
388 | 388 | |
389 | 389 | echo $discount; |
390 | 390 | } |
391 | 391 | |
392 | -function wpinv_get_cart_fees( $type = 'all', $item_id = 0 ) { |
|
393 | - $item = new WPInv_Item( $item_id ); |
|
392 | +function wpinv_get_cart_fees($type = 'all', $item_id = 0) { |
|
393 | + $item = new WPInv_Item($item_id); |
|
394 | 394 | |
395 | - return $item->get_fees( $type, $item_id ); |
|
395 | + return $item->get_fees($type, $item_id); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_get_cart_fee_total() { |
399 | - $total = 0; |
|
399 | + $total = 0; |
|
400 | 400 | $fees = wpinv_get_cart_fees(); |
401 | 401 | |
402 | - if ( $fees ) { |
|
403 | - foreach ( $fees as $fee_id => $fee ) { |
|
402 | + if ($fees) { |
|
403 | + foreach ($fees as $fee_id => $fee) { |
|
404 | 404 | $total += $fee['amount']; |
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | - return apply_filters( 'wpinv_get_cart_fee_total', $total ); |
|
408 | + return apply_filters('wpinv_get_cart_fee_total', $total); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | function wpinv_get_cart_fee_tax() { |
412 | 412 | $tax = 0; |
413 | 413 | $fees = wpinv_get_cart_fees(); |
414 | 414 | |
415 | - if ( $fees ) { |
|
416 | - foreach ( $fees as $fee_id => $fee ) { |
|
417 | - if( ! empty( $fee['no_tax'] ) ) { |
|
415 | + if ($fees) { |
|
416 | + foreach ($fees as $fee_id => $fee) { |
|
417 | + if (!empty($fee['no_tax'])) { |
|
418 | 418 | continue; |
419 | 419 | } |
420 | 420 | |
421 | - $tax += wpinv_calculate_tax( $fee['amount'] ); |
|
421 | + $tax += wpinv_calculate_tax($fee['amount']); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - return apply_filters( 'wpinv_get_cart_fee_tax', $tax ); |
|
425 | + return apply_filters('wpinv_get_cart_fee_tax', $tax); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | function wpinv_cart_has_recurring_item() { |
429 | 429 | $cart_items = wpinv_get_cart_contents(); |
430 | 430 | |
431 | - if ( empty( $cart_items ) ) { |
|
431 | + if (empty($cart_items)) { |
|
432 | 432 | return false; |
433 | 433 | } |
434 | 434 | |
435 | 435 | $has_subscription = false; |
436 | - foreach( $cart_items as $cart_item ) { |
|
437 | - if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
436 | + foreach ($cart_items as $cart_item) { |
|
437 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
438 | 438 | $has_subscription = true; |
439 | 439 | break; |
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | - return apply_filters( 'wpinv_cart_has_recurring_item', $has_subscription, $cart_items ); |
|
443 | + return apply_filters('wpinv_cart_has_recurring_item', $has_subscription, $cart_items); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | function wpinv_cart_has_free_trial() { |
@@ -448,85 +448,85 @@ discard block |
||
448 | 448 | |
449 | 449 | $free_trial = false; |
450 | 450 | |
451 | - if ( !empty( $invoice ) && $invoice->is_free_trial() ) { |
|
451 | + if (!empty($invoice) && $invoice->is_free_trial()) { |
|
452 | 452 | $free_trial = true; |
453 | 453 | } |
454 | 454 | |
455 | - return apply_filters( 'wpinv_cart_has_free_trial', $free_trial, $invoice ); |
|
455 | + return apply_filters('wpinv_cart_has_free_trial', $free_trial, $invoice); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | function wpinv_get_cart_contents() { |
459 | 459 | $cart_details = wpinv_get_cart_details(); |
460 | 460 | |
461 | - return apply_filters( 'wpinv_get_cart_contents', $cart_details ); |
|
461 | + return apply_filters('wpinv_get_cart_contents', $cart_details); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | function wpinv_get_cart_content_details() { |
465 | 465 | global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpinv_is_last_cart_item, $wpinv_flat_discount_total; |
466 | 466 | $cart_items = wpinv_get_cart_contents(); |
467 | 467 | |
468 | - if ( empty( $cart_items ) ) { |
|
468 | + if (empty($cart_items)) { |
|
469 | 469 | return false; |
470 | 470 | } |
471 | 471 | $invoice = wpinv_get_invoice_cart(); |
472 | 472 | |
473 | 473 | $details = array(); |
474 | - $length = count( $cart_items ) - 1; |
|
474 | + $length = count($cart_items) - 1; |
|
475 | 475 | |
476 | - if ( empty( $_POST['country'] ) ) { |
|
476 | + if (empty($_POST['country'])) { |
|
477 | 477 | $_POST['country'] = $invoice->country; |
478 | 478 | } |
479 | - if ( !isset( $_POST['state'] ) ) { |
|
479 | + if (!isset($_POST['state'])) { |
|
480 | 480 | $_POST['state'] = $invoice->state; |
481 | 481 | } |
482 | 482 | |
483 | - foreach( $cart_items as $key => $item ) { |
|
484 | - $item_id = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : ''; |
|
485 | - if ( empty( $item_id ) ) { |
|
483 | + foreach ($cart_items as $key => $item) { |
|
484 | + $item_id = isset($item['id']) ? sanitize_text_field($item['id']) : ''; |
|
485 | + if (empty($item_id)) { |
|
486 | 486 | continue; |
487 | 487 | } |
488 | 488 | |
489 | 489 | $wpi_current_id = $invoice->ID; |
490 | 490 | $wpi_item_id = $item_id; |
491 | 491 | |
492 | - $item_price = wpinv_get_item_price( $item_id ); |
|
493 | - $discount = wpinv_get_cart_item_discount_amount( $item ); |
|
494 | - $discount = apply_filters( 'wpinv_get_cart_content_details_item_discount_amount', $discount, $item ); |
|
495 | - $quantity = wpinv_get_cart_item_quantity( $item ); |
|
496 | - $fees = wpinv_get_cart_fees( 'fee', $item_id ); |
|
492 | + $item_price = wpinv_get_item_price($item_id); |
|
493 | + $discount = wpinv_get_cart_item_discount_amount($item); |
|
494 | + $discount = apply_filters('wpinv_get_cart_content_details_item_discount_amount', $discount, $item); |
|
495 | + $quantity = wpinv_get_cart_item_quantity($item); |
|
496 | + $fees = wpinv_get_cart_fees('fee', $item_id); |
|
497 | 497 | |
498 | 498 | $subtotal = $item_price * $quantity; |
499 | - $tax_rate = wpinv_get_tax_rate( $_POST['country'], $_POST['state'], $wpi_item_id ); |
|
500 | - $tax_class = $wpinv_euvat->get_item_class( $item_id ); |
|
501 | - $tax = wpinv_get_cart_item_tax( $item_id, $subtotal - $discount ); |
|
499 | + $tax_rate = wpinv_get_tax_rate($_POST['country'], $_POST['state'], $wpi_item_id); |
|
500 | + $tax_class = $wpinv_euvat->get_item_class($item_id); |
|
501 | + $tax = wpinv_get_cart_item_tax($item_id, $subtotal - $discount); |
|
502 | 502 | |
503 | - if ( wpinv_prices_include_tax() ) { |
|
504 | - $subtotal -= wpinv_format_amount( $tax, NULL, true ); |
|
503 | + if (wpinv_prices_include_tax()) { |
|
504 | + $subtotal -= wpinv_format_amount($tax, NULL, true); |
|
505 | 505 | } |
506 | 506 | |
507 | - $total = $subtotal - $discount + $tax; |
|
507 | + $total = $subtotal - $discount + $tax; |
|
508 | 508 | |
509 | 509 | // Do not allow totals to go negatve |
510 | - if( $total < 0 ) { |
|
510 | + if ($total < 0) { |
|
511 | 511 | $total = 0; |
512 | 512 | } |
513 | 513 | |
514 | - $details[ $key ] = array( |
|
514 | + $details[$key] = array( |
|
515 | 515 | 'id' => $item_id, |
516 | - 'name' => !empty($item['name']) ? $item['name'] : get_the_title( $item_id ), |
|
517 | - 'item_price' => wpinv_format_amount( $item_price, NULL, true ), |
|
516 | + 'name' => !empty($item['name']) ? $item['name'] : get_the_title($item_id), |
|
517 | + 'item_price' => wpinv_format_amount($item_price, NULL, true), |
|
518 | 518 | 'quantity' => $quantity, |
519 | - 'discount' => wpinv_format_amount( $discount, NULL, true ), |
|
520 | - 'subtotal' => wpinv_format_amount( $subtotal, NULL, true ), |
|
521 | - 'tax' => wpinv_format_amount( $tax, NULL, true ), |
|
522 | - 'price' => wpinv_format_amount( $total, NULL, true ), |
|
519 | + 'discount' => wpinv_format_amount($discount, NULL, true), |
|
520 | + 'subtotal' => wpinv_format_amount($subtotal, NULL, true), |
|
521 | + 'tax' => wpinv_format_amount($tax, NULL, true), |
|
522 | + 'price' => wpinv_format_amount($total, NULL, true), |
|
523 | 523 | 'vat_rates_class' => $tax_class, |
524 | - 'vat_rate' => wpinv_format_amount( $tax_rate, NULL, true ), |
|
525 | - 'meta' => isset( $item['meta'] ) ? $item['meta'] : array(), |
|
524 | + 'vat_rate' => wpinv_format_amount($tax_rate, NULL, true), |
|
525 | + 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
|
526 | 526 | 'fees' => $fees, |
527 | 527 | ); |
528 | 528 | |
529 | - if ( $wpinv_is_last_cart_item ) { |
|
529 | + if ($wpinv_is_last_cart_item) { |
|
530 | 530 | $wpinv_is_last_cart_item = false; |
531 | 531 | $wpinv_flat_discount_total = 0.00; |
532 | 532 | } |
@@ -535,56 +535,56 @@ discard block |
||
535 | 535 | return $details; |
536 | 536 | } |
537 | 537 | |
538 | -function wpinv_get_cart_details( $invoice_id = 0 ) { |
|
538 | +function wpinv_get_cart_details($invoice_id = 0) { |
|
539 | 539 | global $ajax_cart_details; |
540 | 540 | |
541 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
542 | - $cart_details = !empty( $ajax_cart_details ) ? $ajax_cart_details : $invoice->cart_details; |
|
541 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
542 | + $cart_details = !empty($ajax_cart_details) ? $ajax_cart_details : $invoice->cart_details; |
|
543 | 543 | |
544 | 544 | $invoice_currency = $invoice->currency; |
545 | 545 | |
546 | - if ( ! empty( $cart_details ) && is_array( $cart_details ) ) { |
|
547 | - foreach ( $cart_details as $key => $cart_item ) { |
|
548 | - $cart_details[ $key ]['currency'] = $invoice_currency; |
|
546 | + if (!empty($cart_details) && is_array($cart_details)) { |
|
547 | + foreach ($cart_details as $key => $cart_item) { |
|
548 | + $cart_details[$key]['currency'] = $invoice_currency; |
|
549 | 549 | |
550 | - if ( ! isset( $cart_item['subtotal'] ) ) { |
|
551 | - $cart_details[ $key ]['subtotal'] = $cart_item['price']; |
|
550 | + if (!isset($cart_item['subtotal'])) { |
|
551 | + $cart_details[$key]['subtotal'] = $cart_item['price']; |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | } |
555 | 555 | |
556 | - return apply_filters( 'wpinv_get_cart_details', $cart_details, $invoice_id ); |
|
556 | + return apply_filters('wpinv_get_cart_details', $cart_details, $invoice_id); |
|
557 | 557 | } |
558 | 558 | |
559 | -function wpinv_record_status_change( $invoice_id, $new_status, $old_status ) { |
|
560 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
559 | +function wpinv_record_status_change($invoice_id, $new_status, $old_status) { |
|
560 | + $invoice = wpinv_get_invoice($invoice_id); |
|
561 | 561 | |
562 | - $old_status = wpinv_status_nicename( $old_status ); |
|
563 | - $new_status = wpinv_status_nicename( $new_status ); |
|
562 | + $old_status = wpinv_status_nicename($old_status); |
|
563 | + $new_status = wpinv_status_nicename($new_status); |
|
564 | 564 | |
565 | - $status_change = sprintf( __( 'Invoice status changed from %s to %s', 'invoicing' ), $old_status, $new_status ); |
|
565 | + $status_change = sprintf(__('Invoice status changed from %s to %s', 'invoicing'), $old_status, $new_status); |
|
566 | 566 | |
567 | 567 | // Add note |
568 | - return $invoice->add_note( $status_change, 0 ); |
|
568 | + return $invoice->add_note($status_change, 0); |
|
569 | 569 | } |
570 | -add_action( 'wpinv_update_status', 'wpinv_record_status_change', 100, 3 ); |
|
570 | +add_action('wpinv_update_status', 'wpinv_record_status_change', 100, 3); |
|
571 | 571 | |
572 | -function wpinv_complete_payment( $invoice_id, $new_status, $old_status ) { |
|
572 | +function wpinv_complete_payment($invoice_id, $new_status, $old_status) { |
|
573 | 573 | global $wpi_has_free_trial; |
574 | 574 | |
575 | 575 | $wpi_has_free_trial = false; |
576 | 576 | |
577 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
577 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
578 | 578 | return; // Make sure that payments are only paid once |
579 | 579 | } |
580 | 580 | |
581 | 581 | // Make sure the payment completion is only processed when new status is paid |
582 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
582 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
583 | 583 | return; |
584 | 584 | } |
585 | 585 | |
586 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
587 | - if ( empty( $invoice ) ) { |
|
586 | + $invoice = new WPInv_Invoice($invoice_id); |
|
587 | + if (empty($invoice)) { |
|
588 | 588 | return; |
589 | 589 | } |
590 | 590 | |
@@ -592,58 +592,58 @@ discard block |
||
592 | 592 | $completed_date = $invoice->completed_date; |
593 | 593 | $cart_details = $invoice->cart_details; |
594 | 594 | |
595 | - do_action( 'wpinv_pre_complete_payment', $invoice_id ); |
|
595 | + do_action('wpinv_pre_complete_payment', $invoice_id); |
|
596 | 596 | |
597 | - if ( is_array( $cart_details ) ) { |
|
597 | + if (is_array($cart_details)) { |
|
598 | 598 | // Increase purchase count and earnings |
599 | - foreach ( $cart_details as $cart_index => $item ) { |
|
599 | + foreach ($cart_details as $cart_index => $item) { |
|
600 | 600 | // Ensure these actions only run once, ever |
601 | - if ( empty( $completed_date ) ) { |
|
602 | - do_action( 'wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index ); |
|
601 | + if (empty($completed_date)) { |
|
602 | + do_action('wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index); |
|
603 | 603 | } |
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
607 | 607 | // Check for discount codes and increment their use counts |
608 | - if ( $discounts = $invoice->get_discounts( true ) ) { |
|
609 | - if( ! empty( $discounts ) ) { |
|
610 | - foreach( $discounts as $code ) { |
|
611 | - wpinv_increase_discount_usage( $code ); |
|
608 | + if ($discounts = $invoice->get_discounts(true)) { |
|
609 | + if (!empty($discounts)) { |
|
610 | + foreach ($discounts as $code) { |
|
611 | + wpinv_increase_discount_usage($code); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Ensure this action only runs once ever |
617 | - if( empty( $completed_date ) ) { |
|
617 | + if (empty($completed_date)) { |
|
618 | 618 | // Save the completed date |
619 | - $invoice->set( 'completed_date', current_time( 'mysql', 0 ) ); |
|
619 | + $invoice->set('completed_date', current_time('mysql', 0)); |
|
620 | 620 | $invoice->save(); |
621 | 621 | |
622 | - do_action( 'wpinv_complete_payment', $invoice_id ); |
|
622 | + do_action('wpinv_complete_payment', $invoice_id); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | // Empty the shopping cart |
626 | 626 | wpinv_empty_cart(); |
627 | 627 | } |
628 | -add_action( 'wpinv_update_status', 'wpinv_complete_payment', 100, 3 ); |
|
628 | +add_action('wpinv_update_status', 'wpinv_complete_payment', 100, 3); |
|
629 | 629 | |
630 | -function wpinv_update_payment_status( $invoice_id, $new_status = 'publish' ) { |
|
631 | - $invoice = !empty( $invoice_id ) && is_object( $invoice_id ) ? $invoice_id : wpinv_get_invoice( (int)$invoice_id ); |
|
630 | +function wpinv_update_payment_status($invoice_id, $new_status = 'publish') { |
|
631 | + $invoice = !empty($invoice_id) && is_object($invoice_id) ? $invoice_id : wpinv_get_invoice((int)$invoice_id); |
|
632 | 632 | |
633 | - if ( empty( $invoice ) ) { |
|
633 | + if (empty($invoice)) { |
|
634 | 634 | return false; |
635 | 635 | } |
636 | 636 | |
637 | - return $invoice->update_status( $new_status ); |
|
637 | + return $invoice->update_status($new_status); |
|
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_cart_has_fees( $type = 'all' ) { |
|
640 | +function wpinv_cart_has_fees($type = 'all') { |
|
641 | 641 | return false; |
642 | 642 | } |
643 | 643 | |
644 | 644 | function wpinv_validate_checkout_fields() { |
645 | 645 | // Check if there is $_POST |
646 | - if ( empty( $_POST ) ) { |
|
646 | + if (empty($_POST)) { |
|
647 | 647 | return false; |
648 | 648 | } |
649 | 649 | |
@@ -655,11 +655,11 @@ discard block |
||
655 | 655 | ); |
656 | 656 | |
657 | 657 | // Validate agree to terms |
658 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
658 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
659 | 659 | wpinv_checkout_validate_agree_to_terms(); |
660 | 660 | } |
661 | 661 | |
662 | - $valid_data['logged_in_user'] = wpinv_checkout_validate_logged_in_user(); |
|
662 | + $valid_data['logged_in_user'] = wpinv_checkout_validate_logged_in_user(); |
|
663 | 663 | |
664 | 664 | // Return collected data |
665 | 665 | return $valid_data; |
@@ -671,20 +671,20 @@ discard block |
||
671 | 671 | $has_subscription = wpinv_cart_has_recurring_item(); |
672 | 672 | |
673 | 673 | // Check if a gateway value is present |
674 | - if ( !empty( $_REQUEST['wpi-gateway'] ) ) { |
|
675 | - $gateway = sanitize_text_field( $_REQUEST['wpi-gateway'] ); |
|
674 | + if (!empty($_REQUEST['wpi-gateway'])) { |
|
675 | + $gateway = sanitize_text_field($_REQUEST['wpi-gateway']); |
|
676 | 676 | |
677 | - if ( '0.00' == wpinv_get_cart_total() ) { |
|
677 | + if ('0.00' == wpinv_get_cart_total()) { |
|
678 | 678 | $gateway = 'manual'; |
679 | - } elseif ( !wpinv_is_gateway_active( $gateway ) ) { |
|
680 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'invoicing' ) ); |
|
681 | - } elseif ( $has_subscription && !wpinv_gateway_support_subscription( $gateway ) ) { |
|
682 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway doesnot support subscription payment', 'invoicing' ) ); |
|
679 | + } elseif (!wpinv_is_gateway_active($gateway)) { |
|
680 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'invoicing')); |
|
681 | + } elseif ($has_subscription && !wpinv_gateway_support_subscription($gateway)) { |
|
682 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway doesnot support subscription payment', 'invoicing')); |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | |
686 | - if ( $has_subscription && count( wpinv_get_cart_contents() ) > 1 ) { |
|
687 | - wpinv_set_error( 'subscription_invalid', __( 'Only one subscription may be purchased through payment per checkout.', 'invoicing' ) ); |
|
686 | + if ($has_subscription && count(wpinv_get_cart_contents()) > 1) { |
|
687 | + wpinv_set_error('subscription_invalid', __('Only one subscription may be purchased through payment per checkout.', 'invoicing')); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | return $gateway; |
@@ -696,10 +696,10 @@ discard block |
||
696 | 696 | |
697 | 697 | $error = false; |
698 | 698 | // If we have discounts, loop through them |
699 | - if ( ! empty( $discounts ) ) { |
|
700 | - foreach ( $discounts as $discount ) { |
|
699 | + if (!empty($discounts)) { |
|
700 | + foreach ($discounts as $discount) { |
|
701 | 701 | // Check if valid |
702 | - if ( !wpinv_is_discount_valid( $discount, get_current_user_id() ) ) { |
|
702 | + if (!wpinv_is_discount_valid($discount, get_current_user_id())) { |
|
703 | 703 | // Discount is not valid |
704 | 704 | $error = true; |
705 | 705 | } |
@@ -709,20 +709,20 @@ discard block |
||
709 | 709 | return NULL; |
710 | 710 | } |
711 | 711 | |
712 | - if ( $error && !wpinv_get_errors() ) { |
|
713 | - wpinv_set_error( 'invalid_discount', __( 'Discount code you entered is invalid', 'invoicing' ) ); |
|
712 | + if ($error && !wpinv_get_errors()) { |
|
713 | + wpinv_set_error('invalid_discount', __('Discount code you entered is invalid', 'invoicing')); |
|
714 | 714 | } |
715 | 715 | |
716 | - return implode( ',', $discounts ); |
|
716 | + return implode(',', $discounts); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | function wpinv_checkout_validate_cc() { |
720 | 720 | $card_data = wpinv_checkout_get_cc_info(); |
721 | 721 | |
722 | 722 | // Validate the card zip |
723 | - if ( !empty( $card_data['wpinv_zip'] ) ) { |
|
724 | - if ( !wpinv_checkout_validate_cc_zip( $card_data['wpinv_zip'], $card_data['wpinv_country'] ) ) { |
|
725 | - wpinv_set_error( 'invalid_cc_zip', __( 'The zip / postcode you entered for your billing address is invalid', 'invoicing' ) ); |
|
723 | + if (!empty($card_data['wpinv_zip'])) { |
|
724 | + if (!wpinv_checkout_validate_cc_zip($card_data['wpinv_zip'], $card_data['wpinv_country'])) { |
|
725 | + wpinv_set_error('invalid_cc_zip', __('The zip / postcode you entered for your billing address is invalid', 'invoicing')); |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | |
@@ -732,28 +732,28 @@ discard block |
||
732 | 732 | |
733 | 733 | function wpinv_checkout_get_cc_info() { |
734 | 734 | $cc_info = array(); |
735 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
736 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
737 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
738 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
739 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
740 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
741 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
742 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
743 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
744 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
735 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
736 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
737 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
738 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
739 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
740 | + $cc_info['card_address'] = isset($_POST['wpinv_address']) ? sanitize_text_field($_POST['wpinv_address']) : ''; |
|
741 | + $cc_info['card_city'] = isset($_POST['wpinv_city']) ? sanitize_text_field($_POST['wpinv_city']) : ''; |
|
742 | + $cc_info['card_state'] = isset($_POST['wpinv_state']) ? sanitize_text_field($_POST['wpinv_state']) : ''; |
|
743 | + $cc_info['card_country'] = isset($_POST['wpinv_country']) ? sanitize_text_field($_POST['wpinv_country']) : ''; |
|
744 | + $cc_info['card_zip'] = isset($_POST['wpinv_zip']) ? sanitize_text_field($_POST['wpinv_zip']) : ''; |
|
745 | 745 | |
746 | 746 | // Return cc info |
747 | 747 | return $cc_info; |
748 | 748 | } |
749 | 749 | |
750 | -function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
750 | +function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') { |
|
751 | 751 | $ret = false; |
752 | 752 | |
753 | - if ( empty( $zip ) || empty( $country_code ) ) |
|
753 | + if (empty($zip) || empty($country_code)) |
|
754 | 754 | return $ret; |
755 | 755 | |
756 | - $country_code = strtoupper( $country_code ); |
|
756 | + $country_code = strtoupper($country_code); |
|
757 | 757 | |
758 | 758 | $zip_regex = array( |
759 | 759 | "AD" => "AD\d{3}", |
@@ -913,17 +913,17 @@ discard block |
||
913 | 913 | "ZM" => "\d{5}" |
914 | 914 | ); |
915 | 915 | |
916 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) |
|
916 | + if (!isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip)) |
|
917 | 917 | $ret = true; |
918 | 918 | |
919 | - return apply_filters( 'wpinv_is_zip_valid', $ret, $zip, $country_code ); |
|
919 | + return apply_filters('wpinv_is_zip_valid', $ret, $zip, $country_code); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | function wpinv_checkout_validate_agree_to_terms() { |
923 | 923 | // Validate agree to terms |
924 | - if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) { |
|
924 | + if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) { |
|
925 | 925 | // User did not agree |
926 | - wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) ); |
|
926 | + wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing'))); |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
@@ -936,36 +936,36 @@ discard block |
||
936 | 936 | ); |
937 | 937 | |
938 | 938 | // Verify there is a user_ID |
939 | - if ( $user_ID > 0 ) { |
|
939 | + if ($user_ID > 0) { |
|
940 | 940 | // Get the logged in user data |
941 | - $user_data = get_userdata( $user_ID ); |
|
942 | - $required_fields = wpinv_checkout_required_fields(); |
|
941 | + $user_data = get_userdata($user_ID); |
|
942 | + $required_fields = wpinv_checkout_required_fields(); |
|
943 | 943 | |
944 | 944 | // Loop through required fields and show error messages |
945 | - if ( !empty( $required_fields ) ) { |
|
946 | - foreach ( $required_fields as $field_name => $value ) { |
|
947 | - if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
|
948 | - wpinv_set_error( $value['error_id'], $value['error_message'] ); |
|
945 | + if (!empty($required_fields)) { |
|
946 | + foreach ($required_fields as $field_name => $value) { |
|
947 | + if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) { |
|
948 | + wpinv_set_error($value['error_id'], $value['error_message']); |
|
949 | 949 | } |
950 | 950 | } |
951 | 951 | } |
952 | 952 | |
953 | 953 | // Verify data |
954 | - if ( $user_data ) { |
|
954 | + if ($user_data) { |
|
955 | 955 | // Collected logged in user data |
956 | 956 | $valid_user_data = array( |
957 | 957 | 'user_id' => $user_ID, |
958 | - 'email' => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email, |
|
959 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name, |
|
960 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name'] ) ? sanitize_text_field( $_POST['wpinv_last_name'] ) : $user_data->last_name, |
|
958 | + 'email' => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email, |
|
959 | + 'first_name' => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name, |
|
960 | + 'last_name' => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name, |
|
961 | 961 | ); |
962 | 962 | |
963 | - if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) { |
|
964 | - wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) ); |
|
963 | + if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) { |
|
964 | + wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing')); |
|
965 | 965 | } |
966 | 966 | } else { |
967 | 967 | // Set invalid user error |
968 | - wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) ); |
|
968 | + wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing')); |
|
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
@@ -973,21 +973,21 @@ discard block |
||
973 | 973 | return $valid_user_data; |
974 | 974 | } |
975 | 975 | |
976 | -function wpinv_checkout_form_get_user( $valid_data = array() ) { |
|
976 | +function wpinv_checkout_form_get_user($valid_data = array()) { |
|
977 | 977 | // Initialize user |
978 | 978 | $user = false; |
979 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
979 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
980 | 980 | |
981 | 981 | /*if ( $is_ajax ) { |
982 | 982 | // Do not create or login the user during the ajax submission (check for errors only) |
983 | 983 | return true; |
984 | - } else */if ( is_user_logged_in() ) { |
|
984 | + } else */if (is_user_logged_in()) { |
|
985 | 985 | // Set the valid user as the logged in collected data |
986 | 986 | $user = $valid_data['logged_in_user']; |
987 | 987 | } |
988 | 988 | |
989 | 989 | // Verify we have an user |
990 | - if ( false === $user || empty( $user ) ) { |
|
990 | + if (false === $user || empty($user)) { |
|
991 | 991 | // Return false |
992 | 992 | return false; |
993 | 993 | } |
@@ -1006,11 +1006,11 @@ discard block |
||
1006 | 1006 | 'zip', |
1007 | 1007 | ); |
1008 | 1008 | |
1009 | - foreach ( $address_fields as $field ) { |
|
1010 | - $user[$field] = !empty( $_POST['wpinv_' . $field] ) ? sanitize_text_field( $_POST['wpinv_' . $field] ) : false; |
|
1009 | + foreach ($address_fields as $field) { |
|
1010 | + $user[$field] = !empty($_POST['wpinv_' . $field]) ? sanitize_text_field($_POST['wpinv_' . $field]) : false; |
|
1011 | 1011 | |
1012 | - if ( !empty( $user['user_id'] ) ) { |
|
1013 | - update_user_meta( $user['user_id'], '_wpinv_' . $field, $user[$field] ); |
|
1012 | + if (!empty($user['user_id'])) { |
|
1013 | + update_user_meta($user['user_id'], '_wpinv_' . $field, $user[$field]); |
|
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | |
@@ -1018,28 +1018,28 @@ discard block |
||
1018 | 1018 | return $user; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | -function wpinv_set_checkout_session( $invoice_data = array() ) { |
|
1021 | +function wpinv_set_checkout_session($invoice_data = array()) { |
|
1022 | 1022 | global $wpi_session; |
1023 | 1023 | |
1024 | - return $wpi_session->set( 'wpinv_checkout', $invoice_data ); |
|
1024 | + return $wpi_session->set('wpinv_checkout', $invoice_data); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | function wpinv_get_checkout_session() { |
1028 | 1028 | global $wpi_session; |
1029 | 1029 | |
1030 | - return $wpi_session->get( 'wpinv_checkout' ); |
|
1030 | + return $wpi_session->get('wpinv_checkout'); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | function wpinv_empty_cart() { |
1034 | 1034 | global $wpi_session; |
1035 | 1035 | |
1036 | 1036 | // Remove cart contents |
1037 | - $wpi_session->set( 'wpinv_checkout', NULL ); |
|
1037 | + $wpi_session->set('wpinv_checkout', NULL); |
|
1038 | 1038 | |
1039 | 1039 | // Remove all cart fees |
1040 | - $wpi_session->set( 'wpi_cart_fees', NULL ); |
|
1040 | + $wpi_session->set('wpi_cart_fees', NULL); |
|
1041 | 1041 | |
1042 | - do_action( 'wpinv_empty_cart' ); |
|
1042 | + do_action('wpinv_empty_cart'); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | function wpinv_process_checkout() { |
@@ -1051,42 +1051,42 @@ discard block |
||
1051 | 1051 | |
1052 | 1052 | $wpi_checkout_id = $invoice->ID; |
1053 | 1053 | |
1054 | - do_action( 'wpinv_pre_process_checkout' ); |
|
1054 | + do_action('wpinv_pre_process_checkout'); |
|
1055 | 1055 | |
1056 | - if ( !wpinv_get_cart_contents() ) { // Make sure the cart isn't empty |
|
1056 | + if (!wpinv_get_cart_contents()) { // Make sure the cart isn't empty |
|
1057 | 1057 | $valid_data = false; |
1058 | - wpinv_set_error( 'empty_cart', __( 'Your cart is empty', 'invoicing' ) ); |
|
1058 | + wpinv_set_error('empty_cart', __('Your cart is empty', 'invoicing')); |
|
1059 | 1059 | } else { |
1060 | 1060 | // Validate the form $_POST data |
1061 | 1061 | $valid_data = wpinv_validate_checkout_fields(); |
1062 | 1062 | |
1063 | 1063 | // Allow themes and plugins to hook to errors |
1064 | - do_action( 'wpinv_checkout_error_checks', $valid_data, $_POST ); |
|
1064 | + do_action('wpinv_checkout_error_checks', $valid_data, $_POST); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
1067 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
1068 | 1068 | |
1069 | 1069 | // Validate the user |
1070 | - $user = wpinv_checkout_form_get_user( $valid_data ); |
|
1070 | + $user = wpinv_checkout_form_get_user($valid_data); |
|
1071 | 1071 | |
1072 | 1072 | // Let extensions validate fields after user is logged in if user has used login/registration form |
1073 | - do_action( 'wpinv_checkout_user_error_checks', $user, $valid_data, $_POST ); |
|
1073 | + do_action('wpinv_checkout_user_error_checks', $user, $valid_data, $_POST); |
|
1074 | 1074 | |
1075 | - if ( false === $valid_data || wpinv_get_errors() || ! $user ) { |
|
1076 | - if ( $is_ajax ) { |
|
1077 | - do_action( 'wpinv_ajax_checkout_errors' ); |
|
1075 | + if (false === $valid_data || wpinv_get_errors() || !$user) { |
|
1076 | + if ($is_ajax) { |
|
1077 | + do_action('wpinv_ajax_checkout_errors'); |
|
1078 | 1078 | die(); |
1079 | 1079 | } else { |
1080 | 1080 | return false; |
1081 | 1081 | } |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - if ( $is_ajax ) { |
|
1084 | + if ($is_ajax) { |
|
1085 | 1085 | // Save address fields. |
1086 | - $address_fields = array( 'first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company' ); |
|
1087 | - foreach ( $address_fields as $field ) { |
|
1088 | - if ( isset( $user[$field] ) ) { |
|
1089 | - $invoice->set( $field, $user[$field] ); |
|
1086 | + $address_fields = array('first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company'); |
|
1087 | + foreach ($address_fields as $field) { |
|
1088 | + if (isset($user[$field])) { |
|
1089 | + $invoice->set($field, $user[$field]); |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | $invoice->save(); |
@@ -1094,15 +1094,15 @@ discard block |
||
1094 | 1094 | |
1095 | 1095 | $response['success'] = true; |
1096 | 1096 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
1097 | - $response['data']['subtotalf'] = $invoice->get_subtotal( true ); |
|
1097 | + $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
|
1098 | 1098 | $response['data']['discount'] = $invoice->get_discount(); |
1099 | - $response['data']['discountf'] = $invoice->get_discount( true ); |
|
1099 | + $response['data']['discountf'] = $invoice->get_discount(true); |
|
1100 | 1100 | $response['data']['tax'] = $invoice->get_tax(); |
1101 | - $response['data']['taxf'] = $invoice->get_tax( true ); |
|
1101 | + $response['data']['taxf'] = $invoice->get_tax(true); |
|
1102 | 1102 | $response['data']['total'] = $invoice->get_total(); |
1103 | - $response['data']['totalf'] = $invoice->get_total( true ); |
|
1103 | + $response['data']['totalf'] = $invoice->get_total(true); |
|
1104 | 1104 | |
1105 | - wp_send_json( $response ); |
|
1105 | + wp_send_json($response); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | $user_info = array( |
@@ -1124,42 +1124,42 @@ discard block |
||
1124 | 1124 | |
1125 | 1125 | // Setup invoice information |
1126 | 1126 | $invoice_data = array( |
1127 | - 'invoice_id' => !empty( $invoice ) ? $invoice->ID : 0, |
|
1127 | + 'invoice_id' => !empty($invoice) ? $invoice->ID : 0, |
|
1128 | 1128 | 'items' => $cart_items, |
1129 | 1129 | 'cart_discounts' => $discounts, |
1130 | - 'fees' => wpinv_get_cart_fees(), // Any arbitrary fees that have been added to the cart |
|
1131 | - 'subtotal' => wpinv_get_cart_subtotal( $cart_items ), // Amount before taxes and discounts |
|
1132 | - 'discount' => wpinv_get_cart_items_discount_amount( $cart_items, $discounts ), // Discounted amount |
|
1133 | - 'tax' => wpinv_get_cart_tax( $cart_items ), // Taxed amount |
|
1134 | - 'price' => wpinv_get_cart_total( $cart_items, $discounts ), // Amount after taxes |
|
1130 | + 'fees' => wpinv_get_cart_fees(), // Any arbitrary fees that have been added to the cart |
|
1131 | + 'subtotal' => wpinv_get_cart_subtotal($cart_items), // Amount before taxes and discounts |
|
1132 | + 'discount' => wpinv_get_cart_items_discount_amount($cart_items, $discounts), // Discounted amount |
|
1133 | + 'tax' => wpinv_get_cart_tax($cart_items), // Taxed amount |
|
1134 | + 'price' => wpinv_get_cart_total($cart_items, $discounts), // Amount after taxes |
|
1135 | 1135 | 'invoice_key' => $invoice->get_key() ? $invoice->get_key() : $invoice->generate_key(), |
1136 | 1136 | 'user_email' => $user['email'], |
1137 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
1138 | - 'user_info' => stripslashes_deep( $user_info ), |
|
1137 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
1138 | + 'user_info' => stripslashes_deep($user_info), |
|
1139 | 1139 | 'post_data' => $_POST, |
1140 | 1140 | 'cart_details' => $cart_items, |
1141 | 1141 | 'gateway' => $valid_data['gateway'], |
1142 | 1142 | 'card_info' => $valid_data['cc_info'] |
1143 | 1143 | ); |
1144 | 1144 | |
1145 | - $vat_info = $wpinv_euvat->current_vat_data(); |
|
1146 | - if ( is_array( $vat_info ) ) { |
|
1145 | + $vat_info = $wpinv_euvat->current_vat_data(); |
|
1146 | + if (is_array($vat_info)) { |
|
1147 | 1147 | $invoice_data['user_info']['vat_number'] = $vat_info['number']; |
1148 | 1148 | $invoice_data['user_info']['vat_rate'] = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state']); |
1149 | - $invoice_data['user_info']['adddress_confirmed'] = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
1149 | + $invoice_data['user_info']['adddress_confirmed'] = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
1150 | 1150 | |
1151 | 1151 | // Add the VAT rate to each item in the cart |
1152 | - foreach( $invoice_data['cart_details'] as $key => $item_data) { |
|
1152 | + foreach ($invoice_data['cart_details'] as $key => $item_data) { |
|
1153 | 1153 | $rate = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state'], $item_data['id']); |
1154 | - $invoice_data['cart_details'][$key]['vat_rate'] = round( $rate, 3 ); |
|
1154 | + $invoice_data['cart_details'][$key]['vat_rate'] = round($rate, 3); |
|
1155 | 1155 | } |
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | // Save vat fields. |
1159 | - $address_fields = array( 'vat_number', 'vat_rate', 'adddress_confirmed' ); |
|
1160 | - foreach ( $address_fields as $field ) { |
|
1161 | - if ( isset( $invoice_data['user_info'][$field] ) ) { |
|
1162 | - $invoice->set( $field, $invoice_data['user_info'][$field] ); |
|
1159 | + $address_fields = array('vat_number', 'vat_rate', 'adddress_confirmed'); |
|
1160 | + foreach ($address_fields as $field) { |
|
1161 | + if (isset($invoice_data['user_info'][$field])) { |
|
1162 | + $invoice->set($field, $invoice_data['user_info'][$field]); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | $invoice->save(); |
@@ -1169,49 +1169,49 @@ discard block |
||
1169 | 1169 | $valid_data['user'] = $user; |
1170 | 1170 | |
1171 | 1171 | // Allow themes and plugins to hook before the gateway |
1172 | - do_action( 'wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
1172 | + do_action('wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
1173 | 1173 | |
1174 | 1174 | // If the total amount in the cart is 0, send to the manual gateway. This emulates a free invoice |
1175 | - if ( !$invoice_data['price'] ) { |
|
1175 | + if (!$invoice_data['price']) { |
|
1176 | 1176 | // Revert to manual |
1177 | 1177 | $invoice_data['gateway'] = 'manual'; |
1178 | 1178 | $_POST['wpi-gateway'] = 'manual'; |
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | // Allow the invoice data to be modified before it is sent to the gateway |
1182 | - $invoice_data = apply_filters( 'wpinv_data_before_gateway', $invoice_data, $valid_data ); |
|
1182 | + $invoice_data = apply_filters('wpinv_data_before_gateway', $invoice_data, $valid_data); |
|
1183 | 1183 | |
1184 | 1184 | // Setup the data we're storing in the purchase session |
1185 | 1185 | $session_data = $invoice_data; |
1186 | 1186 | // Make sure credit card numbers are never stored in sessions |
1187 | - if ( !empty( $session_data['card_info']['card_number'] ) ) { |
|
1188 | - unset( $session_data['card_info']['card_number'] ); |
|
1187 | + if (!empty($session_data['card_info']['card_number'])) { |
|
1188 | + unset($session_data['card_info']['card_number']); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | // Used for showing item links to non logged-in users after purchase, and for other plugins needing purchase data. |
1192 | - wpinv_set_checkout_session( $invoice_data ); |
|
1192 | + wpinv_set_checkout_session($invoice_data); |
|
1193 | 1193 | |
1194 | 1194 | // Set gateway |
1195 | - $invoice->update_meta( '_wpinv_gateway', $invoice_data['gateway'] ); |
|
1196 | - $invoice->update_meta( '_wpinv_mode', ( wpinv_is_test_mode( $invoice_data['gateway'] ) ? 'test' : 'live' ) ); |
|
1197 | - $invoice->update_meta( '_wpinv_checkout', true ); |
|
1195 | + $invoice->update_meta('_wpinv_gateway', $invoice_data['gateway']); |
|
1196 | + $invoice->update_meta('_wpinv_mode', (wpinv_is_test_mode($invoice_data['gateway']) ? 'test' : 'live')); |
|
1197 | + $invoice->update_meta('_wpinv_checkout', true); |
|
1198 | 1198 | |
1199 | - do_action( 'wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data ); |
|
1199 | + do_action('wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data); |
|
1200 | 1200 | |
1201 | 1201 | // Send info to the gateway for payment processing |
1202 | - wpinv_send_to_gateway( $invoice_data['gateway'], $invoice_data ); |
|
1202 | + wpinv_send_to_gateway($invoice_data['gateway'], $invoice_data); |
|
1203 | 1203 | die(); |
1204 | 1204 | } |
1205 | -add_action( 'wpinv_payment', 'wpinv_process_checkout' ); |
|
1205 | +add_action('wpinv_payment', 'wpinv_process_checkout'); |
|
1206 | 1206 | |
1207 | -function wpinv_get_invoices( $args ) { |
|
1208 | - $args = wp_parse_args( $args, array( |
|
1209 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
1207 | +function wpinv_get_invoices($args) { |
|
1208 | + $args = wp_parse_args($args, array( |
|
1209 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
1210 | 1210 | 'type' => 'wpi_invoice', |
1211 | 1211 | 'parent' => null, |
1212 | 1212 | 'user' => null, |
1213 | 1213 | 'email' => '', |
1214 | - 'limit' => get_option( 'posts_per_page' ), |
|
1214 | + 'limit' => get_option('posts_per_page'), |
|
1215 | 1215 | 'offset' => null, |
1216 | 1216 | 'page' => 1, |
1217 | 1217 | 'exclude' => array(), |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | 'order' => 'DESC', |
1220 | 1220 | 'return' => 'objects', |
1221 | 1221 | 'paginate' => false, |
1222 | - ) ); |
|
1222 | + )); |
|
1223 | 1223 | |
1224 | 1224 | // Handle some BW compatibility arg names where wp_query args differ in naming. |
1225 | 1225 | $map_legacy = array( |
@@ -1232,18 +1232,18 @@ discard block |
||
1232 | 1232 | 'paged' => 'page', |
1233 | 1233 | ); |
1234 | 1234 | |
1235 | - foreach ( $map_legacy as $from => $to ) { |
|
1236 | - if ( isset( $args[ $from ] ) ) { |
|
1237 | - $args[ $to ] = $args[ $from ]; |
|
1235 | + foreach ($map_legacy as $from => $to) { |
|
1236 | + if (isset($args[$from])) { |
|
1237 | + $args[$to] = $args[$from]; |
|
1238 | 1238 | } |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - if ( get_query_var( 'paged' ) ) |
|
1241 | + if (get_query_var('paged')) |
|
1242 | 1242 | $args['page'] = get_query_var('paged'); |
1243 | - else if ( get_query_var( 'page' ) ) |
|
1244 | - $args['page'] = get_query_var( 'page' ); |
|
1245 | - else if ( !empty( $args[ 'page' ] ) ) |
|
1246 | - $args['page'] = $args[ 'page' ]; |
|
1243 | + else if (get_query_var('page')) |
|
1244 | + $args['page'] = get_query_var('page'); |
|
1245 | + else if (!empty($args['page'])) |
|
1246 | + $args['page'] = $args['page']; |
|
1247 | 1247 | else |
1248 | 1248 | $args['page'] = 1; |
1249 | 1249 | |
@@ -1256,47 +1256,47 @@ discard block |
||
1256 | 1256 | 'post_status' => $args['status'], |
1257 | 1257 | 'posts_per_page' => $args['limit'], |
1258 | 1258 | 'meta_query' => array(), |
1259 | - 'date_query' => !empty( $args['date_query'] ) ? $args['date_query'] : array(), |
|
1259 | + 'date_query' => !empty($args['date_query']) ? $args['date_query'] : array(), |
|
1260 | 1260 | 'fields' => 'ids', |
1261 | 1261 | 'orderby' => $args['orderby'], |
1262 | 1262 | 'order' => $args['order'], |
1263 | 1263 | ); |
1264 | 1264 | |
1265 | - if ( !empty( $args['user'] ) ) { |
|
1266 | - $wp_query_args['author'] = absint( $args['user'] ); |
|
1265 | + if (!empty($args['user'])) { |
|
1266 | + $wp_query_args['author'] = absint($args['user']); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | - if ( ! is_null( $args['parent'] ) ) { |
|
1270 | - $wp_query_args['post_parent'] = absint( $args['parent'] ); |
|
1269 | + if (!is_null($args['parent'])) { |
|
1270 | + $wp_query_args['post_parent'] = absint($args['parent']); |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if ( ! is_null( $args['offset'] ) ) { |
|
1274 | - $wp_query_args['offset'] = absint( $args['offset'] ); |
|
1273 | + if (!is_null($args['offset'])) { |
|
1274 | + $wp_query_args['offset'] = absint($args['offset']); |
|
1275 | 1275 | } else { |
1276 | - $wp_query_args['paged'] = absint( $args['page'] ); |
|
1276 | + $wp_query_args['paged'] = absint($args['page']); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | - if ( ! empty( $args['exclude'] ) ) { |
|
1280 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
1279 | + if (!empty($args['exclude'])) { |
|
1280 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | - if ( ! $args['paginate' ] ) { |
|
1283 | + if (!$args['paginate']) { |
|
1284 | 1284 | $wp_query_args['no_found_rows'] = true; |
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | // Get results. |
1288 | - $invoices = new WP_Query( $wp_query_args ); |
|
1288 | + $invoices = new WP_Query($wp_query_args); |
|
1289 | 1289 | |
1290 | - if ( 'objects' === $args['return'] ) { |
|
1291 | - $return = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
1292 | - } elseif ( 'self' === $args['return'] ) { |
|
1290 | + if ('objects' === $args['return']) { |
|
1291 | + $return = array_map('wpinv_get_invoice', $invoices->posts); |
|
1292 | + } elseif ('self' === $args['return']) { |
|
1293 | 1293 | return $invoices; |
1294 | 1294 | } else { |
1295 | 1295 | $return = $invoices->posts; |
1296 | 1296 | } |
1297 | 1297 | |
1298 | - if ( $args['paginate' ] ) { |
|
1299 | - return (object) array( |
|
1298 | + if ($args['paginate']) { |
|
1299 | + return (object)array( |
|
1300 | 1300 | 'invoices' => $return, |
1301 | 1301 | 'total' => $invoices->found_posts, |
1302 | 1302 | 'max_num_pages' => $invoices->max_num_pages, |
@@ -1308,21 +1308,21 @@ discard block |
||
1308 | 1308 | |
1309 | 1309 | function wpinv_get_user_invoices_columns() { |
1310 | 1310 | $columns = array( |
1311 | - 'invoice-number' => array( 'title' => __( 'ID', 'invoicing' ), 'class' => 'text-left' ), |
|
1312 | - 'invoice-date' => array( 'title' => __( 'Date', 'invoicing' ), 'class' => 'text-left' ), |
|
1313 | - 'invoice-status' => array( 'title' => __( 'Status', 'invoicing' ), 'class' => 'text-center' ), |
|
1314 | - 'invoice-total' => array( 'title' => __( 'Total', 'invoicing' ), 'class' => 'text-right' ), |
|
1315 | - 'invoice-actions' => array( 'title' => ' ', 'class' => 'text-center' ), |
|
1311 | + 'invoice-number' => array('title' => __('ID', 'invoicing'), 'class' => 'text-left'), |
|
1312 | + 'invoice-date' => array('title' => __('Date', 'invoicing'), 'class' => 'text-left'), |
|
1313 | + 'invoice-status' => array('title' => __('Status', 'invoicing'), 'class' => 'text-center'), |
|
1314 | + 'invoice-total' => array('title' => __('Total', 'invoicing'), 'class' => 'text-right'), |
|
1315 | + 'invoice-actions' => array('title' => ' ', 'class' => 'text-center'), |
|
1316 | 1316 | ); |
1317 | 1317 | |
1318 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
1318 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | -function wpinv_payment_receipt( $atts, $content = null ) { |
|
1321 | +function wpinv_payment_receipt($atts, $content = null) { |
|
1322 | 1322 | global $wpinv_receipt_args; |
1323 | 1323 | |
1324 | - $wpinv_receipt_args = shortcode_atts( array( |
|
1325 | - 'error' => __( 'Sorry, trouble retrieving payment receipt.', 'invoicing' ), |
|
1324 | + $wpinv_receipt_args = shortcode_atts(array( |
|
1325 | + 'error' => __('Sorry, trouble retrieving payment receipt.', 'invoicing'), |
|
1326 | 1326 | 'price' => true, |
1327 | 1327 | 'discount' => true, |
1328 | 1328 | 'items' => true, |
@@ -1331,185 +1331,185 @@ discard block |
||
1331 | 1331 | 'invoice_key' => false, |
1332 | 1332 | 'payment_method' => true, |
1333 | 1333 | 'invoice_id' => true |
1334 | - ), $atts, 'wpinv_receipt' ); |
|
1334 | + ), $atts, 'wpinv_receipt'); |
|
1335 | 1335 | |
1336 | 1336 | $session = wpinv_get_checkout_session(); |
1337 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
1338 | - $invoice_key = urldecode( $_GET['invoice_key'] ); |
|
1339 | - } else if ( $session && isset( $session['invoice_key'] ) ) { |
|
1337 | + if (isset($_GET['invoice_key'])) { |
|
1338 | + $invoice_key = urldecode($_GET['invoice_key']); |
|
1339 | + } else if ($session && isset($session['invoice_key'])) { |
|
1340 | 1340 | $invoice_key = $session['invoice_key']; |
1341 | - } elseif ( isset( $wpinv_receipt_args['invoice_key'] ) && $wpinv_receipt_args['invoice_key'] ) { |
|
1341 | + } elseif (isset($wpinv_receipt_args['invoice_key']) && $wpinv_receipt_args['invoice_key']) { |
|
1342 | 1342 | $invoice_key = $wpinv_receipt_args['invoice_key']; |
1343 | - } else if ( isset( $_GET['invoice-id'] ) ) { |
|
1344 | - $invoice_key = wpinv_get_payment_key( (int)$_GET['invoice-id'] ); |
|
1343 | + } else if (isset($_GET['invoice-id'])) { |
|
1344 | + $invoice_key = wpinv_get_payment_key((int)$_GET['invoice-id']); |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | // No key found |
1348 | - if ( ! isset( $invoice_key ) ) { |
|
1348 | + if (!isset($invoice_key)) { |
|
1349 | 1349 | return '<p class="alert alert-error">' . $wpinv_receipt_args['error'] . '</p>'; |
1350 | 1350 | } |
1351 | 1351 | |
1352 | - $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1353 | - $user_can_view = wpinv_can_view_receipt( $invoice_key ); |
|
1354 | - if ( $user_can_view && isset( $_GET['invoice-id'] ) ) { |
|
1352 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
1353 | + $user_can_view = wpinv_can_view_receipt($invoice_key); |
|
1354 | + if ($user_can_view && isset($_GET['invoice-id'])) { |
|
1355 | 1355 | $invoice_id = (int)$_GET['invoice-id']; |
1356 | - $user_can_view = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false; |
|
1356 | + $user_can_view = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? true : false; |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt |
1360 | - if ( ! $user_can_view && ! empty( $invoice_key ) && ! is_user_logged_in() ) { |
|
1360 | + if (!$user_can_view && !empty($invoice_key) && !is_user_logged_in()) { |
|
1361 | 1361 | // login redirect |
1362 | - return '<p class="alert alert-error">' . __( 'You are not allowed to access this section', 'invoicing' ) . '</p>'; |
|
1362 | + return '<p class="alert alert-error">' . __('You are not allowed to access this section', 'invoicing') . '</p>'; |
|
1363 | 1363 | } |
1364 | 1364 | |
1365 | - if ( ! apply_filters( 'wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args ) ) { |
|
1365 | + if (!apply_filters('wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args)) { |
|
1366 | 1366 | return '<p class="alert alert-error">' . $wpinv_receipt_args['error'] . '</p>'; |
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | ob_start(); |
1370 | 1370 | |
1371 | - wpinv_get_template_part( 'wpinv-invoice-receipt' ); |
|
1371 | + wpinv_get_template_part('wpinv-invoice-receipt'); |
|
1372 | 1372 | |
1373 | 1373 | $display = ob_get_clean(); |
1374 | 1374 | |
1375 | 1375 | return $display; |
1376 | 1376 | } |
1377 | 1377 | |
1378 | -function wpinv_get_invoice_id_by_key( $key ) { |
|
1378 | +function wpinv_get_invoice_id_by_key($key) { |
|
1379 | 1379 | global $wpdb; |
1380 | 1380 | |
1381 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1381 | + $invoice_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key)); |
|
1382 | 1382 | |
1383 | - if ( $invoice_id != NULL ) |
|
1383 | + if ($invoice_id != NULL) |
|
1384 | 1384 | return $invoice_id; |
1385 | 1385 | |
1386 | 1386 | return 0; |
1387 | 1387 | } |
1388 | 1388 | |
1389 | -function wpinv_can_view_receipt( $invoice_key = '' ) { |
|
1389 | +function wpinv_can_view_receipt($invoice_key = '') { |
|
1390 | 1390 | $return = false; |
1391 | 1391 | |
1392 | - if ( empty( $invoice_key ) ) { |
|
1392 | + if (empty($invoice_key)) { |
|
1393 | 1393 | return $return; |
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | global $wpinv_receipt_args; |
1397 | 1397 | |
1398 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1399 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
1400 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1398 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key($invoice_key); |
|
1399 | + if (isset($_GET['invoice-id'])) { |
|
1400 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? (int)$_GET['invoice-id'] : 0; |
|
1401 | 1401 | } |
1402 | 1402 | |
1403 | - $user_id = (int) wpinv_get_user_id( $wpinv_receipt_args['id'] ); |
|
1404 | - $invoice_meta = wpinv_get_invoice_meta( $wpinv_receipt_args['id'] ); |
|
1403 | + $user_id = (int)wpinv_get_user_id($wpinv_receipt_args['id']); |
|
1404 | + $invoice_meta = wpinv_get_invoice_meta($wpinv_receipt_args['id']); |
|
1405 | 1405 | |
1406 | - if ( is_user_logged_in() ) { |
|
1407 | - if ( $user_id === (int) get_current_user_id() ) { |
|
1406 | + if (is_user_logged_in()) { |
|
1407 | + if ($user_id === (int)get_current_user_id()) { |
|
1408 | 1408 | $return = true; |
1409 | 1409 | } |
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | $session = wpinv_get_checkout_session(); |
1413 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
1414 | - if ( $session['invoice_key'] === $invoice_meta['key'] ) { |
|
1413 | + if (!empty($session) && !is_user_logged_in()) { |
|
1414 | + if ($session['invoice_key'] === $invoice_meta['key']) { |
|
1415 | 1415 | $return = true; |
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | |
1419 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1419 | + return (bool)apply_filters('wpinv_can_view_receipt', $return, $invoice_key); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | function wpinv_pay_for_invoice() { |
1423 | 1423 | global $wpinv_euvat; |
1424 | 1424 | |
1425 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
1425 | + if (isset($_GET['invoice_key'])) { |
|
1426 | 1426 | $checkout_uri = wpinv_get_checkout_uri(); |
1427 | - $invoice_key = sanitize_text_field( $_GET['invoice_key'] ); |
|
1427 | + $invoice_key = sanitize_text_field($_GET['invoice_key']); |
|
1428 | 1428 | |
1429 | - if ( empty( $invoice_key ) ) { |
|
1430 | - wpinv_set_error( 'invalid_invoice', __( 'Invoice not found', 'invoicing' ) ); |
|
1431 | - wp_redirect( $checkout_uri ); |
|
1429 | + if (empty($invoice_key)) { |
|
1430 | + wpinv_set_error('invalid_invoice', __('Invoice not found', 'invoicing')); |
|
1431 | + wp_redirect($checkout_uri); |
|
1432 | 1432 | wpinv_die(); |
1433 | 1433 | } |
1434 | 1434 | |
1435 | - do_action( 'wpinv_check_pay_for_invoice', $invoice_key ); |
|
1435 | + do_action('wpinv_check_pay_for_invoice', $invoice_key); |
|
1436 | 1436 | |
1437 | - $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1438 | - $user_can_view = wpinv_can_view_receipt( $invoice_key ); |
|
1439 | - if ( $user_can_view && isset( $_GET['invoice-id'] ) ) { |
|
1437 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
1438 | + $user_can_view = wpinv_can_view_receipt($invoice_key); |
|
1439 | + if ($user_can_view && isset($_GET['invoice-id'])) { |
|
1440 | 1440 | $invoice_id = (int)$_GET['invoice-id']; |
1441 | - $user_can_view = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false; |
|
1441 | + $user_can_view = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? true : false; |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | - if ( $invoice_id && $user_can_view && ( $invoice = wpinv_get_invoice( $invoice_id ) ) ) { |
|
1445 | - if ( $invoice->needs_payment() ) { |
|
1444 | + if ($invoice_id && $user_can_view && ($invoice = wpinv_get_invoice($invoice_id))) { |
|
1445 | + if ($invoice->needs_payment()) { |
|
1446 | 1446 | $data = array(); |
1447 | 1447 | $data['invoice_id'] = $invoice_id; |
1448 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
1448 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
1449 | 1449 | |
1450 | - wpinv_set_checkout_session( $data ); |
|
1450 | + wpinv_set_checkout_session($data); |
|
1451 | 1451 | |
1452 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
1452 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
1453 | 1453 | $_POST['country'] = $wpinv_euvat->get_country_by_ip(); |
1454 | 1454 | $_POST['state'] = $_POST['country'] == $invoice->country ? $invoice->state : ''; |
1455 | 1455 | |
1456 | - wpinv_recalculate_tax( true ); |
|
1456 | + wpinv_recalculate_tax(true); |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | } else { |
1460 | 1460 | $checkout_uri = $invoice->get_view_url(); |
1461 | 1461 | } |
1462 | 1462 | } else { |
1463 | - wpinv_set_error( 'invalid_invoice', __( 'You are not allowed to view this invoice', 'invoicing' ) ); |
|
1463 | + wpinv_set_error('invalid_invoice', __('You are not allowed to view this invoice', 'invoicing')); |
|
1464 | 1464 | |
1465 | - $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
1465 | + $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
1466 | 1466 | } |
1467 | 1467 | |
1468 | - wp_redirect( $checkout_uri ); |
|
1468 | + wp_redirect($checkout_uri); |
|
1469 | 1469 | wpinv_die(); |
1470 | 1470 | } |
1471 | 1471 | } |
1472 | -add_action( 'wpinv_pay_for_invoice', 'wpinv_pay_for_invoice' ); |
|
1472 | +add_action('wpinv_pay_for_invoice', 'wpinv_pay_for_invoice'); |
|
1473 | 1473 | |
1474 | -function wpinv_handle_pay_via_invoice_link( $invoice_key ) { |
|
1475 | - if ( !empty( $invoice_key ) && !empty( $_REQUEST['_wpipay'] ) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ) ) { |
|
1476 | - if ( $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
1474 | +function wpinv_handle_pay_via_invoice_link($invoice_key) { |
|
1475 | + if (!empty($invoice_key) && !empty($_REQUEST['_wpipay']) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key($invoice_key)) { |
|
1476 | + if ($invoice = wpinv_get_invoice($invoice_id)) { |
|
1477 | 1477 | $user_id = $invoice->get_user_id(); |
1478 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
1478 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
1479 | 1479 | |
1480 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice_key ) ) { // valid invoice link |
|
1481 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
1480 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice_key)) { // valid invoice link |
|
1481 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
1482 | 1482 | |
1483 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
1483 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
1484 | 1484 | wpinv_die(); |
1485 | 1485 | } |
1486 | 1486 | } |
1487 | 1487 | } |
1488 | 1488 | } |
1489 | -add_action( 'wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link' ); |
|
1489 | +add_action('wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link'); |
|
1490 | 1490 | |
1491 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
1492 | - $invoice_id = is_object( $invoice_id ) && !empty( $invoice_id->ID ) ? $invoice_id : $invoice_id; |
|
1491 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
1492 | + $invoice_id = is_object($invoice_id) && !empty($invoice_id->ID) ? $invoice_id : $invoice_id; |
|
1493 | 1493 | |
1494 | - if ( empty( $invoice_id ) && $invoice_id > 0 ) { |
|
1494 | + if (empty($invoice_id) && $invoice_id > 0) { |
|
1495 | 1495 | return false; |
1496 | 1496 | } |
1497 | 1497 | |
1498 | - if ( empty( $transaction_id ) ) { |
|
1498 | + if (empty($transaction_id)) { |
|
1499 | 1499 | $transaction_id = $invoice_id; |
1500 | 1500 | } |
1501 | 1501 | |
1502 | - $transaction_id = apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice_id ); |
|
1502 | + $transaction_id = apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice_id); |
|
1503 | 1503 | |
1504 | - return wpinv_update_invoice_meta( $invoice_id, '_wpinv_transaction_id', $transaction_id ); |
|
1504 | + return wpinv_update_invoice_meta($invoice_id, '_wpinv_transaction_id', $transaction_id); |
|
1505 | 1505 | } |
1506 | 1506 | |
1507 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
1508 | - if ( empty( $status_display ) ) { |
|
1509 | - $status_display = wpinv_status_nicename( $status ); |
|
1507 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
1508 | + if (empty($status_display)) { |
|
1509 | + $status_display = wpinv_status_nicename($status); |
|
1510 | 1510 | } |
1511 | 1511 | |
1512 | - switch ( $status ) { |
|
1512 | + switch ($status) { |
|
1513 | 1513 | case 'publish' : |
1514 | 1514 | case 'complete' : |
1515 | 1515 | case 'renewal' : |
@@ -1535,28 +1535,28 @@ discard block |
||
1535 | 1535 | |
1536 | 1536 | $label = '<span class="label label-inv-' . $status . ' ' . $class . '">' . $status_display . '</span>'; |
1537 | 1537 | |
1538 | - return apply_filters( 'wpinv_invoice_status_label', $label, $status, $status_display ); |
|
1538 | + return apply_filters('wpinv_invoice_status_label', $label, $status, $status_display); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | -function wpinv_format_invoice_number( $number ) { |
|
1542 | - $padd = wpinv_get_option( 'invoice_number_padd' ); |
|
1541 | +function wpinv_format_invoice_number($number) { |
|
1542 | + $padd = wpinv_get_option('invoice_number_padd'); |
|
1543 | 1543 | |
1544 | 1544 | // TODO maintain old invoice numbers if invoice number settings not saved. Should be removed before stable release. |
1545 | - if ( $padd === '' || $padd === false || $padd === NULL ) { |
|
1546 | - return wp_sprintf( __( 'WPINV-%d', 'invoicing' ), $number ); |
|
1545 | + if ($padd === '' || $padd === false || $padd === NULL) { |
|
1546 | + return wp_sprintf(__('WPINV-%d', 'invoicing'), $number); |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | - $prefix = wpinv_get_option( 'invoice_number_prefix' ); |
|
1550 | - $postfix = wpinv_get_option( 'invoice_number_postfix' ); |
|
1549 | + $prefix = wpinv_get_option('invoice_number_prefix'); |
|
1550 | + $postfix = wpinv_get_option('invoice_number_postfix'); |
|
1551 | 1551 | |
1552 | - $padd = absint( $padd ); |
|
1553 | - $formatted_number = absint( $number ); |
|
1552 | + $padd = absint($padd); |
|
1553 | + $formatted_number = absint($number); |
|
1554 | 1554 | |
1555 | - if ( $padd > 0 ) { |
|
1556 | - $formatted_number = zeroise( $formatted_number, $padd ); |
|
1555 | + if ($padd > 0) { |
|
1556 | + $formatted_number = zeroise($formatted_number, $padd); |
|
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | $formatted_number = $prefix . $formatted_number . $postfix; |
1560 | 1560 | |
1561 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
1561 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
1562 | 1562 | } |
1563 | 1563 | \ No newline at end of file |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // MUST have WordPress. |
14 | -if ( !defined( 'WPINC' ) ) { |
|
15 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
14 | +if (!defined('WPINC')) { |
|
15 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
16 | 16 | } |
17 | 17 | |
18 | -if ( !defined( 'WPINV_VERSION' ) ) { |
|
19 | - define( 'WPINV_VERSION', '0.0.4' ); |
|
18 | +if (!defined('WPINV_VERSION')) { |
|
19 | + define('WPINV_VERSION', '0.0.4'); |
|
20 | 20 | } |
21 | 21 | |
22 | -if ( !defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
23 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
22 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
23 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
24 | 24 | } |
25 | 25 | |
26 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php'; |
|
26 | +require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php'; |
|
27 | 27 | |
28 | 28 | function wpinv_run() { |
29 | 29 | global $invoicing; |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * Show update plugin admin notification. |
42 | 42 | */ |
43 | -if(is_admin()){ |
|
43 | +if (is_admin()) { |
|
44 | 44 | if (!function_exists('ayecode_show_update_plugin_requirement')) {//only load the update file if needed |
45 | 45 | function ayecode_show_update_plugin_requirement() { |
46 | - if ( !defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
46 | + if (!defined('WP_EASY_UPDATES_ACTIVE')) { |
|
47 | 47 | ?> |
48 | 48 | <div class="notice notice-warning is-dismissible"> |
49 | 49 | <p> |
50 | 50 | <strong> |
51 | 51 | <?php |
52 | - echo sprintf( __( 'The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory' ), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>' ); |
|
52 | + echo sprintf(__('The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory'), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>'); |
|
53 | 53 | ?> |
54 | 54 | </strong> |
55 | 55 | </p> |
@@ -58,6 +58,6 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - add_action( 'admin_notices', 'ayecode_show_update_plugin_requirement' ); |
|
61 | + add_action('admin_notices', 'ayecode_show_update_plugin_requirement'); |
|
62 | 62 | } |
63 | 63 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -21,68 +21,68 @@ discard block |
||
21 | 21 | public function init() { |
22 | 22 | global $wp_filesystem; |
23 | 23 | |
24 | - if ( empty( $wp_filesystem ) ) { |
|
25 | - require_once( ABSPATH . '/wp-admin/includes/file.php' ); |
|
24 | + if (empty($wp_filesystem)) { |
|
25 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); |
|
26 | 26 | WP_Filesystem(); |
27 | 27 | global $wp_filesystem; |
28 | 28 | } |
29 | 29 | $this->wp_filesystem = $wp_filesystem; |
30 | 30 | |
31 | 31 | $this->export_dir = $this->export_location(); |
32 | - $this->export_url = $this->export_location( true ); |
|
32 | + $this->export_url = $this->export_location(true); |
|
33 | 33 | $this->export = 'invoicing'; |
34 | 34 | $this->filetype = 'csv'; |
35 | 35 | $this->per_page = 20; |
36 | 36 | |
37 | - do_action( 'wpinv_class_reports_init', $this ); |
|
37 | + do_action('wpinv_class_reports_init', $this); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function includes() { |
41 | - do_action( 'wpinv_class_reports_includes', $this ); |
|
41 | + do_action('wpinv_class_reports_includes', $this); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function actions() { |
45 | - if ( is_admin() ) { |
|
46 | - add_action( 'admin_menu', array( $this, 'add_submenu' ), 10 ); |
|
47 | - add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) ); |
|
48 | - add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) ); |
|
45 | + if (is_admin()) { |
|
46 | + add_action('admin_menu', array($this, 'add_submenu'), 10); |
|
47 | + add_action('wpinv_reports_tab_export', array($this, 'export')); |
|
48 | + add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export')); |
|
49 | 49 | |
50 | 50 | // Export Invoices. |
51 | - add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) ); |
|
52 | - add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) ); |
|
53 | - add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) ); |
|
54 | - add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) ); |
|
51 | + add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export')); |
|
52 | + add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns')); |
|
53 | + add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data')); |
|
54 | + add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status')); |
|
55 | 55 | } |
56 | - do_action( 'wpinv_class_reports_actions', $this ); |
|
56 | + do_action('wpinv_class_reports_actions', $this); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public function add_submenu() { |
60 | 60 | global $wpi_reports_page; |
61 | - $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), 'manage_options', 'wpinv-reports', array( $this, 'reports_page' ) ); |
|
61 | + $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), 'manage_options', 'wpinv-reports', array($this, 'reports_page')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public function reports_page() { |
65 | - if ( !wp_script_is( 'postbox', 'enqueued' ) ) { |
|
66 | - wp_enqueue_script( 'postbox' ); |
|
65 | + if (!wp_script_is('postbox', 'enqueued')) { |
|
66 | + wp_enqueue_script('postbox'); |
|
67 | 67 | } |
68 | - if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { |
|
69 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
68 | + if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) { |
|
69 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
70 | 70 | } |
71 | 71 | |
72 | - $current_page = admin_url( 'admin.php?page=wpinv-reports' ); |
|
73 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'export'; |
|
72 | + $current_page = admin_url('admin.php?page=wpinv-reports'); |
|
73 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'export'; |
|
74 | 74 | ?> |
75 | 75 | <div class="wrap wpi-reports-wrap"> |
76 | - <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1> |
|
76 | + <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1> |
|
77 | 77 | <h2 class="nav-tab-wrapper wp-clearfix"> |
78 | - <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a> |
|
79 | - <?php do_action( 'wpinv_reports_page_tabs' ); ;?> |
|
78 | + <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a> |
|
79 | + <?php do_action('wpinv_reports_page_tabs'); ;?> |
|
80 | 80 | </h2> |
81 | 81 | <div class="wpi-reports-content wpi-reports-<?php echo $active_tab; ?>"> |
82 | 82 | <?php |
83 | - do_action( 'wpinv_reports_page_top' ); |
|
84 | - do_action( 'wpinv_reports_tab_' . $active_tab ); |
|
85 | - do_action( 'wpinv_reports_page_bottom' ); |
|
83 | + do_action('wpinv_reports_page_top'); |
|
84 | + do_action('wpinv_reports_tab_' . $active_tab); |
|
85 | + do_action('wpinv_reports_page_bottom'); |
|
86 | 86 | ?> |
87 | 87 | </div> |
88 | 88 | <?php |
@@ -90,97 +90,97 @@ discard block |
||
90 | 90 | |
91 | 91 | public function export() { |
92 | 92 | $statuses = wpinv_get_invoice_statuses(); |
93 | - $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses ); |
|
93 | + $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses); |
|
94 | 94 | ?> |
95 | 95 | <div class="metabox-holder"> |
96 | 96 | <div id="post-body"> |
97 | 97 | <div id="post-body-content"> |
98 | - <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?> |
|
98 | + <?php do_action('wpinv_reports_tab_export_content_top'); ?> |
|
99 | 99 | |
100 | 100 | <div class="postbox wpi-export-invoices"> |
101 | - <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2> |
|
101 | + <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2> |
|
102 | 102 | <div class="inside"> |
103 | - <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p> |
|
103 | + <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p> |
|
104 | 104 | <form id="wpi-export-invoices" class="wpi-export-form" method="post"> |
105 | - <?php echo wpinv_html_date_field( array( |
|
105 | + <?php echo wpinv_html_date_field(array( |
|
106 | 106 | 'id' => 'wpi_export_from_date', |
107 | 107 | 'name' => 'from_date', |
108 | 108 | 'data' => array( |
109 | 109 | 'dateFormat' => 'yy-mm-dd' |
110 | 110 | ), |
111 | - 'placeholder' => __( 'From date', 'invoicing' ) ) |
|
111 | + 'placeholder' => __('From date', 'invoicing') ) |
|
112 | 112 | ); ?> |
113 | - <?php echo wpinv_html_date_field( array( |
|
113 | + <?php echo wpinv_html_date_field(array( |
|
114 | 114 | 'id' => 'wpi_export_to_date', |
115 | 115 | 'name' => 'to_date', |
116 | 116 | 'data' => array( |
117 | 117 | 'dateFormat' => 'yy-mm-dd' |
118 | 118 | ), |
119 | - 'placeholder' => __( 'To date', 'invoicing' ) ) |
|
119 | + 'placeholder' => __('To date', 'invoicing') ) |
|
120 | 120 | ); ?> |
121 | 121 | <span id="wpinv-status-wrap"> |
122 | - <?php echo wpinv_html_select( array( |
|
122 | + <?php echo wpinv_html_select(array( |
|
123 | 123 | 'options' => $statuses, |
124 | 124 | 'name' => 'status', |
125 | 125 | 'id' => 'wpi_export_status', |
126 | 126 | 'show_option_all' => false, |
127 | 127 | 'show_option_none' => false, |
128 | 128 | 'class' => '', |
129 | - ) ); ?> |
|
130 | - <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?> |
|
129 | + )); ?> |
|
130 | + <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?> |
|
131 | 131 | </span> |
132 | 132 | <span id="wpinv-submit-wrap"> |
133 | 133 | <input type="hidden" value="invoices" name="export" /> |
134 | - <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" /> |
|
134 | + <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" /> |
|
135 | 135 | </span> |
136 | 136 | </form> |
137 | 137 | </div> |
138 | 138 | </div> |
139 | 139 | |
140 | - <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?> |
|
140 | + <?php do_action('wpinv_reports_tab_export_content_bottom'); ?> |
|
141 | 141 | </div> |
142 | 142 | </div> |
143 | 143 | </div> |
144 | 144 | <?php |
145 | 145 | } |
146 | 146 | |
147 | - public function export_location( $relative = false ) { |
|
147 | + public function export_location($relative = false) { |
|
148 | 148 | $upload_dir = wp_upload_dir(); |
149 | - $export_location = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache'; |
|
150 | - $export_location = apply_filters( 'wpinv_export_location', $export_location, $relative ); |
|
149 | + $export_location = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache'; |
|
150 | + $export_location = apply_filters('wpinv_export_location', $export_location, $relative); |
|
151 | 151 | |
152 | - return trailingslashit( $export_location ); |
|
152 | + return trailingslashit($export_location); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | public function check_export_location() { |
156 | 156 | try { |
157 | - if ( empty( $this->wp_filesystem ) ) { |
|
158 | - return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' ); |
|
157 | + if (empty($this->wp_filesystem)) { |
|
158 | + return __('Filesystem ERROR: Could not access filesystem.', 'invoicing'); |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( is_wp_error( $this->wp_filesystem ) ) { |
|
162 | - return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' ); |
|
161 | + if (is_wp_error($this->wp_filesystem)) { |
|
162 | + return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing'); |
|
163 | 163 | } |
164 | 164 | |
165 | - $is_dir = $this->wp_filesystem->is_dir( $this->export_dir ); |
|
166 | - $is_writeable = $is_dir && is_writeable( $this->export_dir ); |
|
165 | + $is_dir = $this->wp_filesystem->is_dir($this->export_dir); |
|
166 | + $is_writeable = $is_dir && is_writeable($this->export_dir); |
|
167 | 167 | |
168 | - if ( $is_dir && $is_writeable ) { |
|
168 | + if ($is_dir && $is_writeable) { |
|
169 | 169 | return true; |
170 | - } else if ( $is_dir && !$is_writeable ) { |
|
171 | - if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
172 | - return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
170 | + } else if ($is_dir && !$is_writeable) { |
|
171 | + if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) { |
|
172 | + return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | return true; |
176 | 176 | } else { |
177 | - if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
178 | - return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir ); |
|
177 | + if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) { |
|
178 | + return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return true; |
182 | 182 | } |
183 | - } catch ( Exception $e ) { |
|
183 | + } catch (Exception $e) { |
|
184 | 184 | return $e->getMessage(); |
185 | 185 | } |
186 | 186 | } |
@@ -188,130 +188,130 @@ discard block |
||
188 | 188 | public function ajax_export() { |
189 | 189 | $response = array(); |
190 | 190 | $response['success'] = false; |
191 | - $response['msg'] = __( 'Invalid export request found.', 'invoicing' ); |
|
191 | + $response['msg'] = __('Invalid export request found.', 'invoicing'); |
|
192 | 192 | |
193 | - if ( empty( $_POST['data'] ) || !current_user_can( 'manage_options' ) ) { |
|
194 | - wp_send_json( $response ); |
|
193 | + if (empty($_POST['data']) || !current_user_can('manage_options')) { |
|
194 | + wp_send_json($response); |
|
195 | 195 | } |
196 | 196 | |
197 | - parse_str( $_POST['data'], $data ); |
|
197 | + parse_str($_POST['data'], $data); |
|
198 | 198 | |
199 | - $data['step'] = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; |
|
199 | + $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1; |
|
200 | 200 | |
201 | 201 | $_REQUEST = (array)$data; |
202 | - if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) { |
|
203 | - $response['msg'] = __( 'Security check failed.', 'invoicing' ); |
|
204 | - wp_send_json( $response ); |
|
202 | + if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) { |
|
203 | + $response['msg'] = __('Security check failed.', 'invoicing'); |
|
204 | + wp_send_json($response); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( ( $error = $this->check_export_location( true ) ) !== true ) { |
|
208 | - $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' ); |
|
209 | - wp_send_json( $response ); |
|
207 | + if (($error = $this->check_export_location(true)) !== true) { |
|
208 | + $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing'); |
|
209 | + wp_send_json($response); |
|
210 | 210 | } |
211 | 211 | |
212 | - $this->set_export_params( $_REQUEST ); |
|
212 | + $this->set_export_params($_REQUEST); |
|
213 | 213 | |
214 | 214 | $return = $this->process_export_step(); |
215 | 215 | $done = $this->get_export_status(); |
216 | 216 | |
217 | - if ( $return ) { |
|
217 | + if ($return) { |
|
218 | 218 | $this->step += 1; |
219 | 219 | |
220 | 220 | $response['success'] = true; |
221 | 221 | $response['msg'] = ''; |
222 | 222 | |
223 | - if ( $done >= 100 ) { |
|
223 | + if ($done >= 100) { |
|
224 | 224 | $this->step = 'done'; |
225 | - $new_filename = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype; |
|
225 | + $new_filename = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype; |
|
226 | 226 | $new_file = $this->export_dir . $new_filename; |
227 | 227 | |
228 | - if ( file_exists( $this->file ) ) { |
|
229 | - $this->wp_filesystem->move( $this->file, $new_file, true ); |
|
228 | + if (file_exists($this->file)) { |
|
229 | + $this->wp_filesystem->move($this->file, $new_file, true); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( file_exists( $new_file ) ) { |
|
233 | - $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) ); |
|
232 | + if (file_exists($new_file)) { |
|
233 | + $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2)); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | 237 | $response['data']['step'] = $this->step; |
238 | 238 | $response['data']['done'] = $done; |
239 | 239 | } else { |
240 | - $response['msg'] = __( 'No data found for export.', 'invoicing' ); |
|
240 | + $response['msg'] = __('No data found for export.', 'invoicing'); |
|
241 | 241 | } |
242 | 242 | |
243 | - wp_send_json( $response ); |
|
243 | + wp_send_json($response); |
|
244 | 244 | } |
245 | 245 | |
246 | - public function set_export_params( $request ) { |
|
246 | + public function set_export_params($request) { |
|
247 | 247 | $this->empty = false; |
248 | - $this->step = !empty( $request['step'] ) ? absint( $request['step'] ) : 1; |
|
249 | - $this->export = !empty( $request['export'] ) ? $request['export'] : $this->export; |
|
248 | + $this->step = !empty($request['step']) ? absint($request['step']) : 1; |
|
249 | + $this->export = !empty($request['export']) ? $request['export'] : $this->export; |
|
250 | 250 | $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype; |
251 | 251 | $this->file = $this->export_dir . $this->filename; |
252 | 252 | |
253 | - do_action( 'wpinv_export_set_params_' . $this->export, $request ); |
|
253 | + do_action('wpinv_export_set_params_' . $this->export, $request); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | public function get_columns() { |
257 | 257 | $columns = array( |
258 | - 'id' => __( 'ID', 'invoicing' ), |
|
259 | - 'date' => __( 'Date', 'invoicing' ) |
|
258 | + 'id' => __('ID', 'invoicing'), |
|
259 | + 'date' => __('Date', 'invoicing') |
|
260 | 260 | ); |
261 | 261 | |
262 | - return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns ); |
|
262 | + return apply_filters('wpinv_export_get_columns_' . $this->export, $columns); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | protected function get_export_file() { |
266 | 266 | $file = ''; |
267 | 267 | |
268 | - if ( $this->wp_filesystem->exists( $this->file ) ) { |
|
269 | - $file = $this->wp_filesystem->get_contents( $this->file ); |
|
268 | + if ($this->wp_filesystem->exists($this->file)) { |
|
269 | + $file = $this->wp_filesystem->get_contents($this->file); |
|
270 | 270 | } else { |
271 | - $this->wp_filesystem->put_contents( $this->file, '' ); |
|
271 | + $this->wp_filesystem->put_contents($this->file, ''); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | return $file; |
275 | 275 | } |
276 | 276 | |
277 | - protected function attach_export_data( $data = '' ) { |
|
278 | - $filedata = $this->get_export_file(); |
|
279 | - $filedata .= $data; |
|
277 | + protected function attach_export_data($data = '') { |
|
278 | + $filedata = $this->get_export_file(); |
|
279 | + $filedata .= $data; |
|
280 | 280 | |
281 | - $this->wp_filesystem->put_contents( $this->file, $filedata ); |
|
281 | + $this->wp_filesystem->put_contents($this->file, $filedata); |
|
282 | 282 | |
283 | - $rows = file( $this->file, FILE_SKIP_EMPTY_LINES ); |
|
283 | + $rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
284 | 284 | $columns = $this->get_columns(); |
285 | - $columns = empty( $columns ) ? 0 : 1; |
|
285 | + $columns = empty($columns) ? 0 : 1; |
|
286 | 286 | |
287 | - $this->empty = count( $rows ) == $columns ? true : false; |
|
287 | + $this->empty = count($rows) == $columns ? true : false; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | public function print_columns() { |
291 | 291 | $column_data = ''; |
292 | 292 | $columns = $this->get_columns(); |
293 | 293 | $i = 1; |
294 | - foreach( $columns as $key => $column ) { |
|
295 | - $column_data .= '"' . addslashes( $column ) . '"'; |
|
296 | - $column_data .= $i == count( $columns ) ? '' : ','; |
|
294 | + foreach ($columns as $key => $column) { |
|
295 | + $column_data .= '"' . addslashes($column) . '"'; |
|
296 | + $column_data .= $i == count($columns) ? '' : ','; |
|
297 | 297 | $i++; |
298 | 298 | } |
299 | 299 | $column_data .= "\r\n"; |
300 | 300 | |
301 | - $this->attach_export_data( $column_data ); |
|
301 | + $this->attach_export_data($column_data); |
|
302 | 302 | |
303 | 303 | return $column_data; |
304 | 304 | } |
305 | 305 | |
306 | 306 | public function process_export_step() { |
307 | - if ( $this->step < 2 ) { |
|
308 | - @unlink( $this->file ); |
|
307 | + if ($this->step < 2) { |
|
308 | + @unlink($this->file); |
|
309 | 309 | $this->print_columns(); |
310 | 310 | } |
311 | 311 | |
312 | 312 | $return = $this->print_rows(); |
313 | 313 | |
314 | - if ( $return ) { |
|
314 | + if ($return) { |
|
315 | 315 | return true; |
316 | 316 | } else { |
317 | 317 | return false; |
@@ -320,23 +320,23 @@ discard block |
||
320 | 320 | |
321 | 321 | public function get_export_status() { |
322 | 322 | $status = 100; |
323 | - return apply_filters( 'wpinv_get_export_status_' . $this->export, $status ); |
|
323 | + return apply_filters('wpinv_get_export_status_' . $this->export, $status); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | public function get_export_data() { |
327 | 327 | $data = array( |
328 | 328 | 0 => array( |
329 | 329 | 'id' => '', |
330 | - 'data' => date( 'F j, Y' ) |
|
330 | + 'data' => date('F j, Y') |
|
331 | 331 | ), |
332 | 332 | 1 => array( |
333 | 333 | 'id' => '', |
334 | - 'data' => date( 'F j, Y' ) |
|
334 | + 'data' => date('F j, Y') |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | - $data = apply_filters( 'wpinv_export_get_data', $data ); |
|
339 | - $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data ); |
|
338 | + $data = apply_filters('wpinv_export_get_data', $data); |
|
339 | + $data = apply_filters('wpinv_export_get_data_' . $this->export, $data); |
|
340 | 340 | |
341 | 341 | return $data; |
342 | 342 | } |
@@ -346,20 +346,20 @@ discard block |
||
346 | 346 | $data = $this->get_export_data(); |
347 | 347 | $columns = $this->get_columns(); |
348 | 348 | |
349 | - if ( $data ) { |
|
350 | - foreach ( $data as $row ) { |
|
349 | + if ($data) { |
|
350 | + foreach ($data as $row) { |
|
351 | 351 | $i = 1; |
352 | - foreach ( $row as $key => $column ) { |
|
353 | - if ( array_key_exists( $key, $columns ) ) { |
|
354 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
355 | - $row_data .= $i == count( $columns ) ? '' : ','; |
|
352 | + foreach ($row as $key => $column) { |
|
353 | + if (array_key_exists($key, $columns)) { |
|
354 | + $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"'; |
|
355 | + $row_data .= $i == count($columns) ? '' : ','; |
|
356 | 356 | $i++; |
357 | 357 | } |
358 | 358 | } |
359 | 359 | $row_data .= "\r\n"; |
360 | 360 | } |
361 | 361 | |
362 | - $this->attach_export_data( $row_data ); |
|
362 | + $this->attach_export_data($row_data); |
|
363 | 363 | |
364 | 364 | return $row_data; |
365 | 365 | } |
@@ -368,46 +368,46 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | // Export Invoices. |
371 | - public function set_invoices_export( $request ) { |
|
372 | - $this->from_date = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : ''; |
|
373 | - $this->to_date = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : ''; |
|
374 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publich'; |
|
371 | + public function set_invoices_export($request) { |
|
372 | + $this->from_date = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : ''; |
|
373 | + $this->to_date = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : ''; |
|
374 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'publich'; |
|
375 | 375 | } |
376 | 376 | |
377 | - public function get_invoices_columns( $columns = array() ) { |
|
377 | + public function get_invoices_columns($columns = array()) { |
|
378 | 378 | $columns = array( |
379 | - 'id' => __( 'ID', 'invoicing' ), |
|
380 | - 'number' => __( 'Number', 'invoicing' ), |
|
381 | - 'date' => __( 'Date', 'invoicing' ), |
|
382 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
383 | - 'status_nicename' => __( 'Status Nicename', 'invoicing' ), |
|
384 | - 'status' => __( 'Status', 'invoicing' ), |
|
385 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
386 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
387 | - 'user_id' => __( 'User ID', 'invoicing' ), |
|
388 | - 'email' => __( 'Email', 'invoicing' ), |
|
389 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
390 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
391 | - 'address' => __( 'Address', 'invoicing' ), |
|
392 | - 'city' => __( 'City', 'invoicing' ), |
|
393 | - 'state' => __( 'State', 'invoicing' ), |
|
394 | - 'country' => __( 'Country', 'invoicing' ), |
|
395 | - 'zip' => __( 'Zipcode', 'invoicing' ), |
|
396 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
397 | - 'company' => __( 'Company', 'invoicing' ), |
|
398 | - 'vat_number' => __( 'Vat Number', 'invoicing' ), |
|
399 | - 'ip' => __( 'IP', 'invoicing' ), |
|
400 | - 'gateway' => __( 'Gateway', 'invoicing' ), |
|
401 | - 'gateway_nicename' => __( 'Gateway Nicename', 'invoicing' ), |
|
402 | - 'transaction_id'=> __( 'Transaction ID', 'invoicing' ), |
|
403 | - 'currency' => __( 'Currency', 'invoicing' ), |
|
404 | - 'due_date' => __( 'Due Date', 'invoicing' ), |
|
379 | + 'id' => __('ID', 'invoicing'), |
|
380 | + 'number' => __('Number', 'invoicing'), |
|
381 | + 'date' => __('Date', 'invoicing'), |
|
382 | + 'amount' => __('Amount', 'invoicing'), |
|
383 | + 'status_nicename' => __('Status Nicename', 'invoicing'), |
|
384 | + 'status' => __('Status', 'invoicing'), |
|
385 | + 'tax' => __('Tax', 'invoicing'), |
|
386 | + 'discount' => __('Discount', 'invoicing'), |
|
387 | + 'user_id' => __('User ID', 'invoicing'), |
|
388 | + 'email' => __('Email', 'invoicing'), |
|
389 | + 'first_name' => __('First Name', 'invoicing'), |
|
390 | + 'last_name' => __('Last Name', 'invoicing'), |
|
391 | + 'address' => __('Address', 'invoicing'), |
|
392 | + 'city' => __('City', 'invoicing'), |
|
393 | + 'state' => __('State', 'invoicing'), |
|
394 | + 'country' => __('Country', 'invoicing'), |
|
395 | + 'zip' => __('Zipcode', 'invoicing'), |
|
396 | + 'phone' => __('Phone', 'invoicing'), |
|
397 | + 'company' => __('Company', 'invoicing'), |
|
398 | + 'vat_number' => __('Vat Number', 'invoicing'), |
|
399 | + 'ip' => __('IP', 'invoicing'), |
|
400 | + 'gateway' => __('Gateway', 'invoicing'), |
|
401 | + 'gateway_nicename' => __('Gateway Nicename', 'invoicing'), |
|
402 | + 'transaction_id'=> __('Transaction ID', 'invoicing'), |
|
403 | + 'currency' => __('Currency', 'invoicing'), |
|
404 | + 'due_date' => __('Due Date', 'invoicing'), |
|
405 | 405 | ); |
406 | 406 | |
407 | 407 | return $columns; |
408 | 408 | } |
409 | 409 | |
410 | - public function get_invoices_data( $response = array() ) { |
|
410 | + public function get_invoices_data($response = array()) { |
|
411 | 411 | $args = array( |
412 | 412 | 'limit' => $this->per_page, |
413 | 413 | 'page' => $this->step, |
@@ -415,35 +415,35 @@ discard block |
||
415 | 415 | 'orderby' => 'date', |
416 | 416 | ); |
417 | 417 | |
418 | - if ( $this->status != 'any' ) { |
|
418 | + if ($this->status != 'any') { |
|
419 | 419 | $args['status'] = $this->status; |
420 | 420 | } |
421 | 421 | |
422 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
422 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
423 | 423 | $args['date_query'] = array( |
424 | 424 | array( |
425 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
426 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
425 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
426 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
427 | 427 | 'inclusive' => true |
428 | 428 | ) |
429 | 429 | ); |
430 | 430 | } |
431 | 431 | |
432 | - $invoices = wpinv_get_invoices( $args ); |
|
432 | + $invoices = wpinv_get_invoices($args); |
|
433 | 433 | |
434 | 434 | $data = array(); |
435 | 435 | |
436 | - if ( !empty( $invoices ) ) { |
|
437 | - foreach ( $invoices as $invoice ) { |
|
436 | + if (!empty($invoices)) { |
|
437 | + foreach ($invoices as $invoice) { |
|
438 | 438 | $row = array( |
439 | 439 | 'id' => $invoice->ID, |
440 | 440 | 'number' => $invoice->get_number(), |
441 | - 'date' => $invoice->get_invoice_date( false ), |
|
442 | - 'amount' => wpinv_format_amount( $invoice->get_total(), NULL, true ), |
|
443 | - 'status_nicename' => $invoice->get_status( true ), |
|
441 | + 'date' => $invoice->get_invoice_date(false), |
|
442 | + 'amount' => wpinv_format_amount($invoice->get_total(), NULL, true), |
|
443 | + 'status_nicename' => $invoice->get_status(true), |
|
444 | 444 | 'status' => $invoice->get_status(), |
445 | - 'tax' => $invoice->get_tax() > 0 ? wpinv_format_amount( $invoice->get_tax(), NULL, true ) : '', |
|
446 | - 'discount' => $invoice->get_discount() > 0 ? wpinv_format_amount( $invoice->get_discount(), NULL, true ) : '', |
|
445 | + 'tax' => $invoice->get_tax() > 0 ? wpinv_format_amount($invoice->get_tax(), NULL, true) : '', |
|
446 | + 'discount' => $invoice->get_discount() > 0 ? wpinv_format_amount($invoice->get_discount(), NULL, true) : '', |
|
447 | 447 | 'user_id' => $invoice->get_user_id(), |
448 | 448 | 'email' => $invoice->get_email(), |
449 | 449 | 'first_name' => $invoice->get_first_name(), |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | 'due_date' => $invoice->needs_payment() ? $invoice->get_due_date() : '', |
465 | 465 | ); |
466 | 466 | |
467 | - $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice ); |
|
467 | + $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | return $data; |
@@ -480,29 +480,29 @@ discard block |
||
480 | 480 | 'return' => 'ids', |
481 | 481 | ); |
482 | 482 | |
483 | - if ( $this->status != 'any' ) { |
|
483 | + if ($this->status != 'any') { |
|
484 | 484 | $args['status'] = $this->status; |
485 | 485 | } |
486 | 486 | |
487 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
487 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
488 | 488 | $args['date_query'] = array( |
489 | 489 | array( |
490 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
491 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
490 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
491 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
492 | 492 | 'inclusive' => true |
493 | 493 | ) |
494 | 494 | ); |
495 | 495 | } |
496 | 496 | |
497 | - $invoices = wpinv_get_invoices( $args ); |
|
498 | - $total = !empty( $invoices ) ? count( $invoices ) : 0; |
|
497 | + $invoices = wpinv_get_invoices($args); |
|
498 | + $total = !empty($invoices) ? count($invoices) : 0; |
|
499 | 499 | $status = 100; |
500 | 500 | |
501 | - if ( $total > 0 ) { |
|
502 | - $status = ( ( $this->per_page * $this->step ) / $total ) * 100; |
|
501 | + if ($total > 0) { |
|
502 | + $status = (($this->per_page * $this->step) / $total) * 100; |
|
503 | 503 | } |
504 | 504 | |
505 | - if ( $status > 100 ) { |
|
505 | + if ($status > 100) { |
|
506 | 506 | $status = 100; |
507 | 507 | } |
508 | 508 |
@@ -7,105 +7,105 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_template_path() { |
22 | - return apply_filters( 'wpinv_template_path', 'invoicing/' ); |
|
22 | + return apply_filters('wpinv_template_path', 'invoicing/'); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_post_class( $classes, $class, $post_id ) { |
|
25 | +function wpinv_post_class($classes, $class, $post_id) { |
|
26 | 26 | global $pagenow, $typenow; |
27 | 27 | |
28 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' ) { |
|
28 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && get_post_meta($post_id, '_wpinv_type', true) == 'package') { |
|
29 | 29 | $classes[] = 'wpi-gd-package'; |
30 | 30 | } |
31 | 31 | return $classes; |
32 | 32 | } |
33 | -add_filter( 'post_class', 'wpinv_post_class', 10, 3 ); |
|
33 | +add_filter('post_class', 'wpinv_post_class', 10, 3); |
|
34 | 34 | |
35 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
36 | - if ( empty( $invoice ) ) { |
|
35 | +function wpinv_display_invoice_top_bar($invoice) { |
|
36 | + if (empty($invoice)) { |
|
37 | 37 | return; |
38 | 38 | } |
39 | 39 | ?> |
40 | 40 | <div class="row wpinv-top-bar no-print"> |
41 | 41 | <div class="container"> |
42 | 42 | <div class="col-xs-6"> |
43 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
43 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
44 | 44 | </div> |
45 | 45 | <div class="col-xs-6 text-right"> |
46 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
46 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | 50 | <?php |
51 | 51 | } |
52 | 52 | |
53 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
54 | - if ( empty( $invoice ) ) { |
|
53 | +function wpinv_invoice_display_left_actions($invoice) { |
|
54 | + if (empty($invoice)) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $user_id = (int)$invoice->get_user_id(); |
59 | 59 | $current_user_id = (int)get_current_user_id(); |
60 | 60 | |
61 | - if ( $user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment() ) { |
|
61 | + if ($user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment()) { |
|
62 | 62 | ?> |
63 | - <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a> |
|
63 | + <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a> |
|
64 | 64 | <?php |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
69 | - if ( empty( $invoice ) ) { |
|
68 | +function wpinv_invoice_display_right_actions($invoice) { |
|
69 | + if (empty($invoice)) { |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | 73 | $user_id = (int)$invoice->get_user_id(); |
74 | 74 | $current_user_id = (int)get_current_user_id(); |
75 | 75 | |
76 | - if ( $user_id > 0 && $user_id == $current_user_id ) { |
|
76 | + if ($user_id > 0 && $user_id == $current_user_id) { |
|
77 | 77 | ?> |
78 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
79 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
78 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
79 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
80 | 80 | <?php } ?> |
81 | 81 | <?php |
82 | 82 | } |
83 | 83 | |
84 | -function wpinv_before_invoice_content( $content ) { |
|
84 | +function wpinv_before_invoice_content($content) { |
|
85 | 85 | global $post; |
86 | 86 | |
87 | - if ( $post && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
87 | + if ($post && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
88 | 88 | ob_start(); |
89 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
89 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
90 | 90 | $content = ob_get_clean() . $content; |
91 | 91 | } |
92 | 92 | |
93 | 93 | return $content; |
94 | 94 | } |
95 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
95 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
96 | 96 | |
97 | -function wpinv_after_invoice_content( $content ) { |
|
97 | +function wpinv_after_invoice_content($content) { |
|
98 | 98 | global $post; |
99 | 99 | |
100 | - if ( $post && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
100 | + if ($post && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
101 | 101 | ob_start(); |
102 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
102 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
103 | 103 | $content .= ob_get_clean(); |
104 | 104 | } |
105 | 105 | |
106 | 106 | return $content; |
107 | 107 | } |
108 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
108 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
109 | 109 | |
110 | 110 | function wpinv_get_templates_dir() { |
111 | 111 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -115,105 +115,105 @@ discard block |
||
115 | 115 | return WPINV_PLUGIN_URL . 'templates'; |
116 | 116 | } |
117 | 117 | |
118 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
119 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
120 | - extract( $args ); |
|
118 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
119 | + if (!empty($args) && is_array($args)) { |
|
120 | + extract($args); |
|
121 | 121 | } |
122 | 122 | |
123 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
124 | - if ( ! file_exists( $located ) ) { |
|
125 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
123 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
124 | + if (!file_exists($located)) { |
|
125 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Allow 3rd party plugin filter template file from their plugin. |
130 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
130 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
131 | 131 | |
132 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
132 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
133 | 133 | |
134 | - include( $located ); |
|
134 | + include($located); |
|
135 | 135 | |
136 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
136 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
139 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
140 | 140 | ob_start(); |
141 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
141 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
142 | 142 | return ob_get_clean(); |
143 | 143 | } |
144 | 144 | |
145 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
146 | - if ( ! $template_path ) { |
|
145 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
146 | + if (!$template_path) { |
|
147 | 147 | $template_path = wpinv_template_path(); |
148 | 148 | } |
149 | 149 | |
150 | - if ( ! $default_path ) { |
|
150 | + if (!$default_path) { |
|
151 | 151 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
152 | 152 | } |
153 | 153 | |
154 | 154 | // Look within passed path within the theme - this is priority. |
155 | 155 | $template = locate_template( |
156 | 156 | array( |
157 | - trailingslashit( $template_path ) . $template_name, |
|
157 | + trailingslashit($template_path) . $template_name, |
|
158 | 158 | $template_name |
159 | 159 | ) |
160 | 160 | ); |
161 | 161 | |
162 | 162 | // Get default templates/ |
163 | - if ( !$template && $default_path ) { |
|
164 | - $template = trailingslashit( $default_path ) . $template_name; |
|
163 | + if (!$template && $default_path) { |
|
164 | + $template = trailingslashit($default_path) . $template_name; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // Return what we found. |
168 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
168 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
169 | 169 | } |
170 | 170 | |
171 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
172 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
171 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
172 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
173 | 173 | |
174 | 174 | // Setup possible parts |
175 | 175 | $templates = array(); |
176 | - if ( isset( $name ) ) |
|
176 | + if (isset($name)) |
|
177 | 177 | $templates[] = $slug . '-' . $name . '.php'; |
178 | 178 | $templates[] = $slug . '.php'; |
179 | 179 | |
180 | 180 | // Allow template parts to be filtered |
181 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
181 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
182 | 182 | |
183 | 183 | // Return the part that is found |
184 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
184 | + return wpinv_locate_tmpl($templates, $load, false); |
|
185 | 185 | } |
186 | 186 | |
187 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
187 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
188 | 188 | // No file found yet |
189 | 189 | $located = false; |
190 | 190 | |
191 | 191 | // Try to find a template file |
192 | - foreach ( (array)$template_names as $template_name ) { |
|
192 | + foreach ((array)$template_names as $template_name) { |
|
193 | 193 | |
194 | 194 | // Continue if template is empty |
195 | - if ( empty( $template_name ) ) |
|
195 | + if (empty($template_name)) |
|
196 | 196 | continue; |
197 | 197 | |
198 | 198 | // Trim off any slashes from the template name |
199 | - $template_name = ltrim( $template_name, '/' ); |
|
199 | + $template_name = ltrim($template_name, '/'); |
|
200 | 200 | |
201 | 201 | // try locating this template file by looping through the template paths |
202 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
202 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
203 | 203 | |
204 | - if( file_exists( $template_path . $template_name ) ) { |
|
204 | + if (file_exists($template_path . $template_name)) { |
|
205 | 205 | $located = $template_path . $template_name; |
206 | 206 | break; |
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - if( !empty( $located ) ) { |
|
210 | + if (!empty($located)) { |
|
211 | 211 | break; |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
216 | - load_template( $located, $require_once ); |
|
215 | + if ((true == $load) && !empty($located)) |
|
216 | + load_template($located, $require_once); |
|
217 | 217 | |
218 | 218 | return $located; |
219 | 219 | } |
@@ -222,143 +222,143 @@ discard block |
||
222 | 222 | $template_dir = wpinv_get_theme_template_dir_name(); |
223 | 223 | |
224 | 224 | $file_paths = array( |
225 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
226 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
225 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
226 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
227 | 227 | 100 => wpinv_get_templates_dir() |
228 | 228 | ); |
229 | 229 | |
230 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
230 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
231 | 231 | |
232 | 232 | // sort the file paths based on priority |
233 | - ksort( $file_paths, SORT_NUMERIC ); |
|
233 | + ksort($file_paths, SORT_NUMERIC); |
|
234 | 234 | |
235 | - return array_map( 'trailingslashit', $file_paths ); |
|
235 | + return array_map('trailingslashit', $file_paths); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | function wpinv_get_theme_template_dir_name() { |
239 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
239 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'wpinv_templates')); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | function wpinv_checkout_meta_tags() { |
243 | 243 | |
244 | 244 | $pages = array(); |
245 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
246 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
247 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
245 | + $pages[] = wpinv_get_option('success_page'); |
|
246 | + $pages[] = wpinv_get_option('failure_page'); |
|
247 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
248 | 248 | |
249 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
249 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | 253 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
254 | 254 | } |
255 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
255 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
256 | 256 | |
257 | -function wpinv_add_body_classes( $class ) { |
|
257 | +function wpinv_add_body_classes($class) { |
|
258 | 258 | $classes = (array)$class; |
259 | 259 | |
260 | - if( wpinv_is_checkout() ) { |
|
260 | + if (wpinv_is_checkout()) { |
|
261 | 261 | $classes[] = 'wpinv-checkout'; |
262 | 262 | $classes[] = 'wpinv-page'; |
263 | 263 | } |
264 | 264 | |
265 | - if( wpinv_is_success_page() ) { |
|
265 | + if (wpinv_is_success_page()) { |
|
266 | 266 | $classes[] = 'wpinv-success'; |
267 | 267 | $classes[] = 'wpinv-page'; |
268 | 268 | } |
269 | 269 | |
270 | - if( wpinv_is_failed_transaction_page() ) { |
|
270 | + if (wpinv_is_failed_transaction_page()) { |
|
271 | 271 | $classes[] = 'wpinv-failed-transaction'; |
272 | 272 | $classes[] = 'wpinv-page'; |
273 | 273 | } |
274 | 274 | |
275 | - if( wpinv_is_invoice_history_page() ) { |
|
275 | + if (wpinv_is_invoice_history_page()) { |
|
276 | 276 | $classes[] = 'wpinv-history'; |
277 | 277 | $classes[] = 'wpinv-page'; |
278 | 278 | } |
279 | 279 | |
280 | - if( wpinv_is_test_mode() ) { |
|
280 | + if (wpinv_is_test_mode()) { |
|
281 | 281 | $classes[] = 'wpinv-test-mode'; |
282 | 282 | $classes[] = 'wpinv-page'; |
283 | 283 | } |
284 | 284 | |
285 | - return array_unique( $classes ); |
|
285 | + return array_unique($classes); |
|
286 | 286 | } |
287 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
287 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
288 | 288 | |
289 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
290 | - $args = array( 'nopaging' => true ); |
|
289 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
290 | + $args = array('nopaging' => true); |
|
291 | 291 | |
292 | - if ( ! empty( $status ) ) |
|
292 | + if (!empty($status)) |
|
293 | 293 | $args['post_status'] = $status; |
294 | 294 | |
295 | - $discounts = wpinv_get_discounts( $args ); |
|
295 | + $discounts = wpinv_get_discounts($args); |
|
296 | 296 | $options = array(); |
297 | 297 | |
298 | - if ( $discounts ) { |
|
299 | - foreach ( $discounts as $discount ) { |
|
300 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
298 | + if ($discounts) { |
|
299 | + foreach ($discounts as $discount) { |
|
300 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
301 | 301 | } |
302 | 302 | } else { |
303 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
303 | + $options[0] = __('No discounts found', 'invoicing'); |
|
304 | 304 | } |
305 | 305 | |
306 | - $output = wpinv_html_select( array( |
|
306 | + $output = wpinv_html_select(array( |
|
307 | 307 | 'name' => $name, |
308 | 308 | 'selected' => $selected, |
309 | 309 | 'options' => $options, |
310 | 310 | 'show_option_all' => false, |
311 | 311 | 'show_option_none' => false, |
312 | - ) ); |
|
312 | + )); |
|
313 | 313 | |
314 | 314 | return $output; |
315 | 315 | } |
316 | 316 | |
317 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
318 | - $current = date( 'Y' ); |
|
319 | - $start_year = $current - absint( $years_before ); |
|
320 | - $end_year = $current + absint( $years_after ); |
|
321 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
317 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
318 | + $current = date('Y'); |
|
319 | + $start_year = $current - absint($years_before); |
|
320 | + $end_year = $current + absint($years_after); |
|
321 | + $selected = empty($selected) ? date('Y') : $selected; |
|
322 | 322 | $options = array(); |
323 | 323 | |
324 | - while ( $start_year <= $end_year ) { |
|
325 | - $options[ absint( $start_year ) ] = $start_year; |
|
324 | + while ($start_year <= $end_year) { |
|
325 | + $options[absint($start_year)] = $start_year; |
|
326 | 326 | $start_year++; |
327 | 327 | } |
328 | 328 | |
329 | - $output = wpinv_html_select( array( |
|
329 | + $output = wpinv_html_select(array( |
|
330 | 330 | 'name' => $name, |
331 | 331 | 'selected' => $selected, |
332 | 332 | 'options' => $options, |
333 | 333 | 'show_option_all' => false, |
334 | 334 | 'show_option_none' => false |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | |
337 | 337 | return $output; |
338 | 338 | } |
339 | 339 | |
340 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
340 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
341 | 341 | $month = 1; |
342 | 342 | $options = array(); |
343 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
343 | + $selected = empty($selected) ? date('n') : $selected; |
|
344 | 344 | |
345 | - while ( $month <= 12 ) { |
|
346 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
345 | + while ($month <= 12) { |
|
346 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
347 | 347 | $month++; |
348 | 348 | } |
349 | 349 | |
350 | - $output = wpinv_html_select( array( |
|
350 | + $output = wpinv_html_select(array( |
|
351 | 351 | 'name' => $name, |
352 | 352 | 'selected' => $selected, |
353 | 353 | 'options' => $options, |
354 | 354 | 'show_option_all' => false, |
355 | 355 | 'show_option_none' => false |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | |
358 | 358 | return $output; |
359 | 359 | } |
360 | 360 | |
361 | -function wpinv_html_select( $args = array() ) { |
|
361 | +function wpinv_html_select($args = array()) { |
|
362 | 362 | $defaults = array( |
363 | 363 | 'options' => array(), |
364 | 364 | 'name' => null, |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | 'chosen' => false, |
369 | 369 | 'placeholder' => null, |
370 | 370 | 'multiple' => false, |
371 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
372 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
371 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
372 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
373 | 373 | 'data' => array(), |
374 | 374 | 'onchange' => null, |
375 | 375 | 'required' => false, |
@@ -377,78 +377,78 @@ discard block |
||
377 | 377 | 'readonly' => false, |
378 | 378 | ); |
379 | 379 | |
380 | - $args = wp_parse_args( $args, $defaults ); |
|
380 | + $args = wp_parse_args($args, $defaults); |
|
381 | 381 | |
382 | 382 | $data_elements = ''; |
383 | - foreach ( $args['data'] as $key => $value ) { |
|
384 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
383 | + foreach ($args['data'] as $key => $value) { |
|
384 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
385 | 385 | } |
386 | 386 | |
387 | - if( $args['multiple'] ) { |
|
387 | + if ($args['multiple']) { |
|
388 | 388 | $multiple = ' MULTIPLE'; |
389 | 389 | } else { |
390 | 390 | $multiple = ''; |
391 | 391 | } |
392 | 392 | |
393 | - if( $args['chosen'] ) { |
|
393 | + if ($args['chosen']) { |
|
394 | 394 | $args['class'] .= ' wpinv-select-chosen'; |
395 | 395 | } |
396 | 396 | |
397 | - if( $args['placeholder'] ) { |
|
397 | + if ($args['placeholder']) { |
|
398 | 398 | $placeholder = $args['placeholder']; |
399 | 399 | } else { |
400 | 400 | $placeholder = ''; |
401 | 401 | } |
402 | 402 | |
403 | 403 | $options = ''; |
404 | - if( !empty( $args['onchange'] ) ) { |
|
405 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
404 | + if (!empty($args['onchange'])) { |
|
405 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
406 | 406 | } |
407 | 407 | |
408 | - if( !empty( $args['required'] ) ) { |
|
408 | + if (!empty($args['required'])) { |
|
409 | 409 | $options .= ' required="required"'; |
410 | 410 | } |
411 | 411 | |
412 | - if( !empty( $args['disabled'] ) ) { |
|
412 | + if (!empty($args['disabled'])) { |
|
413 | 413 | $options .= ' disabled'; |
414 | 414 | } |
415 | 415 | |
416 | - if( !empty( $args['readonly'] ) ) { |
|
416 | + if (!empty($args['readonly'])) { |
|
417 | 417 | $options .= ' readonly'; |
418 | 418 | } |
419 | 419 | |
420 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
421 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
420 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
421 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
422 | 422 | |
423 | - if ( $args['show_option_all'] ) { |
|
424 | - if( $args['multiple'] ) { |
|
425 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
423 | + if ($args['show_option_all']) { |
|
424 | + if ($args['multiple']) { |
|
425 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
426 | 426 | } else { |
427 | - $selected = selected( $args['selected'], 0, false ); |
|
427 | + $selected = selected($args['selected'], 0, false); |
|
428 | 428 | } |
429 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
429 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
430 | 430 | } |
431 | 431 | |
432 | - if ( !empty( $args['options'] ) ) { |
|
432 | + if (!empty($args['options'])) { |
|
433 | 433 | |
434 | - if ( $args['show_option_none'] ) { |
|
435 | - if( $args['multiple'] ) { |
|
436 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
434 | + if ($args['show_option_none']) { |
|
435 | + if ($args['multiple']) { |
|
436 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
437 | 437 | } else { |
438 | - $selected = selected( $args['selected'] === "", true, false ); |
|
438 | + $selected = selected($args['selected'] === "", true, false); |
|
439 | 439 | } |
440 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
440 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
441 | 441 | } |
442 | 442 | |
443 | - foreach( $args['options'] as $key => $option ) { |
|
443 | + foreach ($args['options'] as $key => $option) { |
|
444 | 444 | |
445 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
446 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
445 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
446 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
447 | 447 | } else { |
448 | - $selected = selected( $args['selected'], $key, false ); |
|
448 | + $selected = selected($args['selected'], $key, false); |
|
449 | 449 | } |
450 | 450 | |
451 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
451 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | return $output; |
458 | 458 | } |
459 | 459 | |
460 | -function wpinv_item_dropdown( $args = array() ) { |
|
460 | +function wpinv_item_dropdown($args = array()) { |
|
461 | 461 | $defaults = array( |
462 | 462 | 'name' => 'wpi_item', |
463 | 463 | 'id' => 'wpi_item', |
@@ -466,15 +466,15 @@ discard block |
||
466 | 466 | 'selected' => 0, |
467 | 467 | 'chosen' => false, |
468 | 468 | 'number' => 100, |
469 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
470 | - 'data' => array( 'search-type' => 'item' ), |
|
469 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
470 | + 'data' => array('search-type' => 'item'), |
|
471 | 471 | 'show_option_all' => false, |
472 | 472 | 'show_option_none' => false, |
473 | 473 | 'with_packages' => true, |
474 | 474 | 'show_recurring' => false, |
475 | 475 | ); |
476 | 476 | |
477 | - $args = wp_parse_args( $args, $defaults ); |
|
477 | + $args = wp_parse_args($args, $defaults); |
|
478 | 478 | |
479 | 479 | $item_args = array( |
480 | 480 | 'post_type' => 'wpi_item', |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | 'posts_per_page' => $args['number'] |
484 | 484 | ); |
485 | 485 | |
486 | - if ( !$args['with_packages'] ) { |
|
486 | + if (!$args['with_packages']) { |
|
487 | 487 | $item_args['meta_query'] = array( |
488 | 488 | array( |
489 | 489 | 'key' => '_wpinv_type', |
@@ -493,42 +493,42 @@ discard block |
||
493 | 493 | ); |
494 | 494 | } |
495 | 495 | |
496 | - $items = get_posts( $item_args ); |
|
496 | + $items = get_posts($item_args); |
|
497 | 497 | $options = array(); |
498 | - if ( $items ) { |
|
499 | - foreach ( $items as $item ) { |
|
500 | - $title = esc_html( $item->post_title ); |
|
498 | + if ($items) { |
|
499 | + foreach ($items as $item) { |
|
500 | + $title = esc_html($item->post_title); |
|
501 | 501 | |
502 | - if ( !empty( $args['show_recurring'] ) ) { |
|
503 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
502 | + if (!empty($args['show_recurring'])) { |
|
503 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
504 | 504 | } |
505 | 505 | |
506 | - $options[ absint( $item->ID ) ] = $title; |
|
506 | + $options[absint($item->ID)] = $title; |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | |
510 | 510 | // This ensures that any selected items are included in the drop down |
511 | - if( is_array( $args['selected'] ) ) { |
|
512 | - foreach( $args['selected'] as $item ) { |
|
513 | - if( ! in_array( $item, $options ) ) { |
|
514 | - $title = get_the_title( $item ); |
|
515 | - if ( !empty( $args['show_recurring'] ) ) { |
|
516 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
511 | + if (is_array($args['selected'])) { |
|
512 | + foreach ($args['selected'] as $item) { |
|
513 | + if (!in_array($item, $options)) { |
|
514 | + $title = get_the_title($item); |
|
515 | + if (!empty($args['show_recurring'])) { |
|
516 | + $title .= wpinv_get_item_suffix($item, false); |
|
517 | 517 | } |
518 | 518 | $options[$item] = $title; |
519 | 519 | } |
520 | 520 | } |
521 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
522 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
523 | - $title = get_the_title( $args['selected'] ); |
|
524 | - if ( !empty( $args['show_recurring'] ) ) { |
|
525 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
521 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
522 | + if (!in_array($args['selected'], $options)) { |
|
523 | + $title = get_the_title($args['selected']); |
|
524 | + if (!empty($args['show_recurring'])) { |
|
525 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
526 | 526 | } |
527 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
527 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - $output = wpinv_html_select( array( |
|
531 | + $output = wpinv_html_select(array( |
|
532 | 532 | 'name' => $args['name'], |
533 | 533 | 'selected' => $args['selected'], |
534 | 534 | 'id' => $args['id'], |
@@ -540,12 +540,12 @@ discard block |
||
540 | 540 | 'show_option_all' => $args['show_option_all'], |
541 | 541 | 'show_option_none' => $args['show_option_none'], |
542 | 542 | 'data' => $args['data'], |
543 | - ) ); |
|
543 | + )); |
|
544 | 544 | |
545 | 545 | return $output; |
546 | 546 | } |
547 | 547 | |
548 | -function wpinv_html_checkbox( $args = array() ) { |
|
548 | +function wpinv_html_checkbox($args = array()) { |
|
549 | 549 | $defaults = array( |
550 | 550 | 'name' => null, |
551 | 551 | 'current' => null, |
@@ -556,38 +556,38 @@ discard block |
||
556 | 556 | ) |
557 | 557 | ); |
558 | 558 | |
559 | - $args = wp_parse_args( $args, $defaults ); |
|
559 | + $args = wp_parse_args($args, $defaults); |
|
560 | 560 | |
561 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
561 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
562 | 562 | $options = ''; |
563 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
563 | + if (!empty($args['options']['disabled'])) { |
|
564 | 564 | $options .= ' disabled="disabled"'; |
565 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
565 | + } elseif (!empty($args['options']['readonly'])) { |
|
566 | 566 | $options .= ' readonly'; |
567 | 567 | } |
568 | 568 | |
569 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
569 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
570 | 570 | |
571 | 571 | return $output; |
572 | 572 | } |
573 | 573 | |
574 | -function wpinv_html_text( $args = array() ) { |
|
574 | +function wpinv_html_text($args = array()) { |
|
575 | 575 | // Backwards compatibility |
576 | - if ( func_num_args() > 1 ) { |
|
576 | + if (func_num_args() > 1) { |
|
577 | 577 | $args = func_get_args(); |
578 | 578 | |
579 | 579 | $name = $args[0]; |
580 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
581 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
582 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
580 | + $value = isset($args[1]) ? $args[1] : ''; |
|
581 | + $label = isset($args[2]) ? $args[2] : ''; |
|
582 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | $defaults = array( |
586 | 586 | 'id' => '', |
587 | - 'name' => isset( $name ) ? $name : 'text', |
|
588 | - 'value' => isset( $value ) ? $value : null, |
|
589 | - 'label' => isset( $label ) ? $label : null, |
|
590 | - 'desc' => isset( $desc ) ? $desc : null, |
|
587 | + 'name' => isset($name) ? $name : 'text', |
|
588 | + 'value' => isset($value) ? $value : null, |
|
589 | + 'label' => isset($label) ? $label : null, |
|
590 | + 'desc' => isset($desc) ? $desc : null, |
|
591 | 591 | 'placeholder' => '', |
592 | 592 | 'class' => 'regular-text', |
593 | 593 | 'disabled' => false, |
@@ -597,51 +597,51 @@ discard block |
||
597 | 597 | 'data' => false |
598 | 598 | ); |
599 | 599 | |
600 | - $args = wp_parse_args( $args, $defaults ); |
|
600 | + $args = wp_parse_args($args, $defaults); |
|
601 | 601 | |
602 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
602 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
603 | 603 | $options = ''; |
604 | - if( $args['required'] ) { |
|
604 | + if ($args['required']) { |
|
605 | 605 | $options .= ' required="required"'; |
606 | 606 | } |
607 | - if( $args['readonly'] ) { |
|
607 | + if ($args['readonly']) { |
|
608 | 608 | $options .= ' readonly'; |
609 | 609 | } |
610 | - if( $args['readonly'] ) { |
|
610 | + if ($args['readonly']) { |
|
611 | 611 | $options .= ' readonly'; |
612 | 612 | } |
613 | 613 | |
614 | 614 | $data = ''; |
615 | - if ( !empty( $args['data'] ) ) { |
|
616 | - foreach ( $args['data'] as $key => $value ) { |
|
617 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
615 | + if (!empty($args['data'])) { |
|
616 | + foreach ($args['data'] as $key => $value) { |
|
617 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
618 | 618 | } |
619 | 619 | } |
620 | 620 | |
621 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
622 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
623 | - if ( ! empty( $args['desc'] ) ) { |
|
624 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
621 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
622 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
623 | + if (!empty($args['desc'])) { |
|
624 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
625 | 625 | } |
626 | 626 | |
627 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
627 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
628 | 628 | |
629 | 629 | $output .= '</span>'; |
630 | 630 | |
631 | 631 | return $output; |
632 | 632 | } |
633 | 633 | |
634 | -function wpinv_html_date_field( $args = array() ) { |
|
635 | - if( empty( $args['class'] ) ) { |
|
634 | +function wpinv_html_date_field($args = array()) { |
|
635 | + if (empty($args['class'])) { |
|
636 | 636 | $args['class'] = 'wpiDatepicker'; |
637 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
637 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
638 | 638 | $args['class'] .= ' wpiDatepicker'; |
639 | 639 | } |
640 | 640 | |
641 | - return wpinv_html_text( $args ); |
|
641 | + return wpinv_html_text($args); |
|
642 | 642 | } |
643 | 643 | |
644 | -function wpinv_html_textarea( $args = array() ) { |
|
644 | +function wpinv_html_textarea($args = array()) { |
|
645 | 645 | $defaults = array( |
646 | 646 | 'name' => 'textarea', |
647 | 647 | 'value' => null, |
@@ -651,31 +651,31 @@ discard block |
||
651 | 651 | 'disabled' => false |
652 | 652 | ); |
653 | 653 | |
654 | - $args = wp_parse_args( $args, $defaults ); |
|
654 | + $args = wp_parse_args($args, $defaults); |
|
655 | 655 | |
656 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
656 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
657 | 657 | $disabled = ''; |
658 | - if( $args['disabled'] ) { |
|
658 | + if ($args['disabled']) { |
|
659 | 659 | $disabled = ' disabled="disabled"'; |
660 | 660 | } |
661 | 661 | |
662 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
663 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
664 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
662 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
663 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
664 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
665 | 665 | |
666 | - if ( ! empty( $args['desc'] ) ) { |
|
667 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
666 | + if (!empty($args['desc'])) { |
|
667 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
668 | 668 | } |
669 | 669 | $output .= '</span>'; |
670 | 670 | |
671 | 671 | return $output; |
672 | 672 | } |
673 | 673 | |
674 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
674 | +function wpinv_html_ajax_user_search($args = array()) { |
|
675 | 675 | $defaults = array( |
676 | 676 | 'name' => 'user_id', |
677 | 677 | 'value' => null, |
678 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
678 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
679 | 679 | 'label' => null, |
680 | 680 | 'desc' => null, |
681 | 681 | 'class' => '', |
@@ -684,13 +684,13 @@ discard block |
||
684 | 684 | 'data' => false |
685 | 685 | ); |
686 | 686 | |
687 | - $args = wp_parse_args( $args, $defaults ); |
|
687 | + $args = wp_parse_args($args, $defaults); |
|
688 | 688 | |
689 | 689 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
690 | 690 | |
691 | 691 | $output = '<span class="wpinv_user_search_wrap">'; |
692 | - $output .= wpinv_html_text( $args ); |
|
693 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
692 | + $output .= wpinv_html_text($args); |
|
693 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
694 | 694 | $output .= '</span>'; |
695 | 695 | |
696 | 696 | return $output; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | function wpinv_ip_geolocation() { |
700 | 700 | global $wpinv_euvat; |
701 | 701 | |
702 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
702 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
703 | 703 | $content = ''; |
704 | 704 | $iso = ''; |
705 | 705 | $country = ''; |
@@ -710,69 +710,69 @@ discard block |
||
710 | 710 | $credit = ''; |
711 | 711 | $address = ''; |
712 | 712 | |
713 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
713 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
714 | 714 | try { |
715 | 715 | $iso = $geoip2_city->country->isoCode; |
716 | 716 | $country = $geoip2_city->country->name; |
717 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
717 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
718 | 718 | $city = $geoip2_city->city->name; |
719 | 719 | $longitude = $geoip2_city->location->longitude; |
720 | 720 | $latitude = $geoip2_city->location->latitude; |
721 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
722 | - } catch( Exception $e ) { } |
|
721 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
722 | + } catch (Exception $e) { } |
|
723 | 723 | } |
724 | 724 | |
725 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
725 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
726 | 726 | try { |
727 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
727 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
728 | 728 | |
729 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
729 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
730 | 730 | $iso = $load_xml->geoplugin_countryCode; |
731 | 731 | $country = $load_xml->geoplugin_countryName; |
732 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
733 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
732 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
733 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
734 | 734 | $longitude = $load_xml->geoplugin_longitude; |
735 | 735 | $latitude = $load_xml->geoplugin_latitude; |
736 | 736 | $credit = $load_xml->geoplugin_credit; |
737 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
737 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
738 | 738 | } |
739 | - } catch( Exception $e ) { } |
|
739 | + } catch (Exception $e) { } |
|
740 | 740 | } |
741 | 741 | |
742 | - if ( $iso && $longitude && $latitude ) { |
|
743 | - if ( $city ) { |
|
742 | + if ($iso && $longitude && $latitude) { |
|
743 | + if ($city) { |
|
744 | 744 | $address .= $city . ', '; |
745 | 745 | } |
746 | 746 | |
747 | - if ( $region ) { |
|
747 | + if ($region) { |
|
748 | 748 | $address .= $region . ', '; |
749 | 749 | } |
750 | 750 | |
751 | 751 | $address .= $country . ' (' . $iso . ')'; |
752 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
753 | - $content .= '<p>'. $credit . '</p>'; |
|
752 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
753 | + $content .= '<p>' . $credit . '</p>'; |
|
754 | 754 | } else { |
755 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
755 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
756 | 756 | } |
757 | 757 | ?> |
758 | 758 | <!DOCTYPE html> |
759 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
759 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
760 | 760 | <body> |
761 | - <?php if ( $latitude && $latitude ) { ?> |
|
761 | + <?php if ($latitude && $latitude) { ?> |
|
762 | 762 | <div id="map"></div> |
763 | 763 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
764 | 764 | <script type="text/javascript"> |
765 | 765 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
766 | 766 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
767 | 767 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
768 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
768 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
769 | 769 | |
770 | 770 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
771 | 771 | |
772 | 772 | var marker = new L.Marker(latlng); |
773 | 773 | map.addLayer(marker); |
774 | 774 | |
775 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
775 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
776 | 776 | </script> |
777 | 777 | <?php } ?> |
778 | 778 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -780,31 +780,31 @@ discard block |
||
780 | 780 | <?php |
781 | 781 | exit; |
782 | 782 | } |
783 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
784 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
783 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
784 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
785 | 785 | |
786 | 786 | // Set up the template for the invoice. |
787 | -function wpinv_template( $template ) { |
|
787 | +function wpinv_template($template) { |
|
788 | 788 | global $post, $wp_query; |
789 | 789 | |
790 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && get_post_type( $post->ID ) == 'wpi_invoice' ) { |
|
791 | - if ( wpinv_user_can_print_invoice( $post->ID ) ) { |
|
792 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
790 | + if ((is_single() || is_404()) && !empty($post->ID) && get_post_type($post->ID) == 'wpi_invoice') { |
|
791 | + if (wpinv_user_can_print_invoice($post->ID)) { |
|
792 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
793 | 793 | } else { |
794 | - if ( !is_user_logged_in() && !empty( $_REQUEST['_wpipay'] ) && $invoice = wpinv_get_invoice( $post->ID ) ) { |
|
794 | + if (!is_user_logged_in() && !empty($_REQUEST['_wpipay']) && $invoice = wpinv_get_invoice($post->ID)) { |
|
795 | 795 | $user_id = $invoice->get_user_id(); |
796 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
796 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
797 | 797 | |
798 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key() ) ) { // valid invoice link |
|
799 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
798 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key())) { // valid invoice link |
|
799 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
800 | 800 | |
801 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
801 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
802 | 802 | wpinv_die(); |
803 | 803 | } |
804 | 804 | } |
805 | - $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
805 | + $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
806 | 806 | |
807 | - wp_redirect( $redirect_to ); |
|
807 | + wp_redirect($redirect_to); |
|
808 | 808 | wpinv_die(); |
809 | 809 | } |
810 | 810 | } |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | function wpinv_get_business_address() { |
816 | 816 | $business_address = wpinv_store_address(); |
817 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
817 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
818 | 818 | |
819 | 819 | /* |
820 | 820 | $default_country = wpinv_get_default_country(); |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | |
839 | 839 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
840 | 840 | |
841 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
841 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | function wpinv_display_from_address() { |
@@ -848,181 +848,181 @@ discard block |
||
848 | 848 | if (empty($from_name)) { |
849 | 849 | $from_name = wpinv_get_business_name(); |
850 | 850 | } |
851 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
851 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
852 | 852 | <div class="wrapper col-xs-10"> |
853 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
854 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
855 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
853 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
854 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
855 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
856 | 856 | <?php } ?> |
857 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
858 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s' ), $email_from );?></div> |
|
857 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
858 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s'), $email_from); ?></div> |
|
859 | 859 | <?php } ?> |
860 | 860 | </div> |
861 | 861 | <?php |
862 | 862 | } |
863 | 863 | |
864 | -function wpinv_watermark( $id = 0 ) { |
|
865 | - $output = wpinv_get_watermark( $id ); |
|
864 | +function wpinv_watermark($id = 0) { |
|
865 | + $output = wpinv_get_watermark($id); |
|
866 | 866 | |
867 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
867 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
868 | 868 | } |
869 | 869 | |
870 | -function wpinv_get_watermark( $id ) { |
|
871 | - if ( !$id > 0 ) { |
|
870 | +function wpinv_get_watermark($id) { |
|
871 | + if (!$id > 0) { |
|
872 | 872 | return NULL; |
873 | 873 | } |
874 | - $invoice = wpinv_get_invoice( $id ); |
|
874 | + $invoice = wpinv_get_invoice($id); |
|
875 | 875 | |
876 | - if ( !empty( $invoice ) ) { |
|
877 | - if ( $invoice->is_paid() ) { |
|
878 | - return __( 'Paid', 'invoicing' ); |
|
876 | + if (!empty($invoice)) { |
|
877 | + if ($invoice->is_paid()) { |
|
878 | + return __('Paid', 'invoicing'); |
|
879 | 879 | } |
880 | - if ( $invoice->has_status( array( 'cancelled' ) ) ) { |
|
881 | - return __( 'Cancelled', 'invoicing' ); |
|
880 | + if ($invoice->has_status(array('cancelled'))) { |
|
881 | + return __('Cancelled', 'invoicing'); |
|
882 | 882 | } |
883 | 883 | } |
884 | 884 | |
885 | 885 | return NULL; |
886 | 886 | } |
887 | 887 | |
888 | -function wpinv_display_invoice_details( $invoice ) { |
|
888 | +function wpinv_display_invoice_details($invoice) { |
|
889 | 889 | global $wpinv_euvat; |
890 | 890 | |
891 | 891 | $invoice_id = $invoice->ID; |
892 | 892 | $vat_name = $wpinv_euvat->get_vat_name(); |
893 | 893 | |
894 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
894 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
895 | 895 | ?> |
896 | 896 | <table class="table table-bordered table-sm"> |
897 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
897 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
898 | 898 | <tr class="wpi-row-number"> |
899 | - <th><?php _e( 'Invoice Number', 'invoicing' ); ?></th> |
|
900 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
899 | + <th><?php _e('Invoice Number', 'invoicing'); ?></th> |
|
900 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
901 | 901 | </tr> |
902 | 902 | <?php } ?> |
903 | 903 | <tr class="wpi-row-status"> |
904 | - <th><?php _e( 'Invoice Status', 'invoicing' ); ?></th> |
|
905 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
904 | + <th><?php _e('Invoice Status', 'invoicing'); ?></th> |
|
905 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
906 | 906 | </tr> |
907 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
907 | + <?php if ($invoice->is_renewal()) { ?> |
|
908 | 908 | <tr class="wpi-row-parent"> |
909 | - <th><?php _e( 'Parent Invoice', 'invoicing' ); ?></th> |
|
910 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
909 | + <th><?php _e('Parent Invoice', 'invoicing'); ?></th> |
|
910 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
911 | 911 | </tr> |
912 | 912 | <?php } ?> |
913 | 913 | <tr class="wpi-row-gateway"> |
914 | - <th><?php _e( 'Payment Method', 'invoicing' ); ?></th> |
|
915 | - <td><?php echo wpinv_get_payment_gateway_name( $invoice_id ); ?></td> |
|
914 | + <th><?php _e('Payment Method', 'invoicing'); ?></th> |
|
915 | + <td><?php echo wpinv_get_payment_gateway_name($invoice_id); ?></td> |
|
916 | 916 | </tr> |
917 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
917 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
918 | 918 | <tr class="wpi-row-date"> |
919 | - <th><?php _e( 'Invoice Date', 'invoicing' ); ?></th> |
|
919 | + <th><?php _e('Invoice Date', 'invoicing'); ?></th> |
|
920 | 920 | <td><?php echo $invoice_date; ?></td> |
921 | 921 | </tr> |
922 | 922 | <?php } ?> |
923 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
923 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
924 | 924 | <tr class="wpi-row-date"> |
925 | - <th><?php _e( 'Due Date', 'invoicing' ); ?></th> |
|
925 | + <th><?php _e('Due Date', 'invoicing'); ?></th> |
|
926 | 926 | <td><?php echo $due_date; ?></td> |
927 | 927 | </tr> |
928 | 928 | <?php } ?> |
929 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
929 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
930 | 930 | <tr class="wpi-row-ovatno"> |
931 | - <th><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
931 | + <th><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></th> |
|
932 | 932 | <td><?php echo $owner_vat_number; ?></td> |
933 | 933 | </tr> |
934 | 934 | <?php } ?> |
935 | - <?php if ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) { ?> |
|
935 | + <?php if ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id)) { ?> |
|
936 | 936 | <tr class="wpi-row-uvatno"> |
937 | - <th><?php echo wp_sprintf( __( 'Your %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
937 | + <th><?php echo wp_sprintf(__('Your %s Number', 'invoicing'), $vat_name); ?></th> |
|
938 | 938 | <td><?php echo $user_vat_number; ?></td> |
939 | 939 | </tr> |
940 | 940 | <?php } ?> |
941 | 941 | <tr class="table-active tr-total wpi-row-total"> |
942 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
943 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
942 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
943 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
944 | 944 | </tr> |
945 | 945 | </table> |
946 | 946 | <?php |
947 | 947 | } |
948 | 948 | |
949 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
950 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
949 | +function wpinv_display_to_address($invoice_id = 0) { |
|
950 | + $invoice = wpinv_get_invoice($invoice_id); |
|
951 | 951 | |
952 | - if ( empty( $invoice ) ) { |
|
952 | + if (empty($invoice)) { |
|
953 | 953 | return NULL; |
954 | 954 | } |
955 | 955 | |
956 | 956 | $billing_details = $invoice->get_user_info(); |
957 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
957 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
958 | 958 | $output .= '<div class="wrapper col-xs-10">'; |
959 | 959 | |
960 | 960 | ob_start(); |
961 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
961 | + do_action('wpinv_display_to_address_top', $invoice); |
|
962 | 962 | $output .= ob_get_clean(); |
963 | 963 | |
964 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
965 | - if ( $company = $billing_details['company'] ) { |
|
966 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
964 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
965 | + if ($company = $billing_details['company']) { |
|
966 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
967 | 967 | } |
968 | 968 | $address_row = ''; |
969 | - if ( $address = $billing_details['address'] ) { |
|
970 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
969 | + if ($address = $billing_details['address']) { |
|
970 | + $address_row .= wpautop(wp_kses_post($address)); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | $address_fields = array(); |
974 | - if ( !empty( $billing_details['city'] ) ) { |
|
974 | + if (!empty($billing_details['city'])) { |
|
975 | 975 | $address_fields[] = $billing_details['city']; |
976 | 976 | } |
977 | 977 | |
978 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
979 | - if ( !empty( $billing_details['state'] ) ) { |
|
980 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
978 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
979 | + if (!empty($billing_details['state'])) { |
|
980 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
981 | 981 | } |
982 | 982 | |
983 | - if ( !empty( $billing_country ) ) { |
|
984 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
983 | + if (!empty($billing_country)) { |
|
984 | + $address_fields[] = wpinv_country_name($billing_country); |
|
985 | 985 | } |
986 | 986 | |
987 | - if ( !empty( $address_fields ) ) { |
|
988 | - $address_fields = implode( ", ", $address_fields ); |
|
987 | + if (!empty($address_fields)) { |
|
988 | + $address_fields = implode(", ", $address_fields); |
|
989 | 989 | |
990 | - if ( !empty( $billing_details['zip'] ) ) { |
|
990 | + if (!empty($billing_details['zip'])) { |
|
991 | 991 | $address_fields .= ' ' . $billing_details['zip']; |
992 | 992 | } |
993 | 993 | |
994 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
994 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
995 | 995 | } |
996 | 996 | |
997 | - if ( $address_row ) { |
|
997 | + if ($address_row) { |
|
998 | 998 | $output .= '<div class="address">' . $address_row . '</div>'; |
999 | 999 | } |
1000 | 1000 | |
1001 | - if ( $phone = $invoice->get_phone() ) { |
|
1002 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s' ), esc_html( $phone ) ) . '</div>'; |
|
1001 | + if ($phone = $invoice->get_phone()) { |
|
1002 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s'), esc_html($phone)) . '</div>'; |
|
1003 | 1003 | } |
1004 | - if ( $email = $invoice->get_email() ) { |
|
1005 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' ), esc_html( $email ) ) . '</div>'; |
|
1004 | + if ($email = $invoice->get_email()) { |
|
1005 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s'), esc_html($email)) . '</div>'; |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | ob_start(); |
1009 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
1009 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
1010 | 1010 | $output .= ob_get_clean(); |
1011 | 1011 | |
1012 | 1012 | $output .= '</div>'; |
1013 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
1013 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
1014 | 1014 | |
1015 | 1015 | echo $output; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1018 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1019 | 1019 | global $wpinv_euvat, $ajax_cart_details; |
1020 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1020 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1021 | 1021 | $quantities_enabled = wpinv_item_quantities_enabled(); |
1022 | 1022 | $use_taxes = wpinv_use_taxes(); |
1023 | 1023 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
1024 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
1025 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
1024 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
1025 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
1026 | 1026 | |
1027 | 1027 | $cart_details = $invoice->get_cart_details(); |
1028 | 1028 | $ajax_cart_details = $cart_details; |
@@ -1031,68 +1031,68 @@ discard block |
||
1031 | 1031 | <table class="table table-sm table-bordered table-responsive"> |
1032 | 1032 | <thead> |
1033 | 1033 | <tr> |
1034 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1035 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1034 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1035 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1036 | 1036 | <?php if ($quantities_enabled) { ?> |
1037 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1037 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1038 | 1038 | <?php } ?> |
1039 | 1039 | <?php if ($use_taxes && !$zero_tax) { ?> |
1040 | 1040 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1041 | 1041 | <?php } ?> |
1042 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1042 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1043 | 1043 | </tr> |
1044 | 1044 | </thead> |
1045 | 1045 | <tbody> |
1046 | 1046 | <?php |
1047 | - if ( !empty( $cart_details ) ) { |
|
1048 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1047 | + if (!empty($cart_details)) { |
|
1048 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1049 | 1049 | |
1050 | 1050 | $count = 0; |
1051 | 1051 | $cols = 3; |
1052 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1053 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1054 | - $item_price = isset($cart_item["item_price"]) ? wpinv_format_amount( $cart_item["item_price"] ) : 0; |
|
1055 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_format_amount( $cart_item["subtotal"] ) : 0; |
|
1056 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1052 | + foreach ($cart_details as $key => $cart_item) { |
|
1053 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1054 | + $item_price = isset($cart_item["item_price"]) ? wpinv_format_amount($cart_item["item_price"]) : 0; |
|
1055 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_format_amount($cart_item["subtotal"]) : 0; |
|
1056 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1057 | 1057 | |
1058 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1058 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1059 | 1059 | $summary = ''; |
1060 | 1060 | $cols = 3; |
1061 | - if ( !empty($item) ) { |
|
1061 | + if (!empty($item)) { |
|
1062 | 1062 | $item_name = $item->get_name(); |
1063 | 1063 | $summary = $item->get_summary(); |
1064 | 1064 | } |
1065 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1065 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1066 | 1066 | |
1067 | 1067 | if (!empty($item) && $item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1068 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1069 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $item->get_cpt_singular_name(), $post_link ); |
|
1068 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1069 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $item->get_cpt_singular_name(), $post_link); |
|
1070 | 1070 | } |
1071 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1071 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1072 | 1072 | |
1073 | 1073 | $item_tax = ''; |
1074 | 1074 | $tax_rate = ''; |
1075 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1076 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1077 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1078 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount( $tax_rate, 2 ) : ''; |
|
1075 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1076 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1077 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1078 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount($tax_rate, 2) : ''; |
|
1079 | 1079 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | $line_item_tax = $item_tax . $tax_rate; |
1083 | 1083 | |
1084 | - if ( $line_item_tax === '' ) { |
|
1084 | + if ($line_item_tax === '') { |
|
1085 | 1085 | $line_item_tax = 0; // Zero tax |
1086 | 1086 | } |
1087 | 1087 | |
1088 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1089 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1090 | - if ( $summary !== '' ) { |
|
1091 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1088 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1089 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1090 | + if ($summary !== '') { |
|
1091 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1092 | 1092 | } |
1093 | 1093 | $line_item .= '</td>'; |
1094 | 1094 | |
1095 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( $item_price, $invoice->get_currency() ) ) . '</td>'; |
|
1095 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price($item_price, $invoice->get_currency())) . '</td>'; |
|
1096 | 1096 | if ($quantities_enabled) { |
1097 | 1097 | $cols++; |
1098 | 1098 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1101,55 +1101,55 @@ discard block |
||
1101 | 1101 | $cols++; |
1102 | 1102 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1103 | 1103 | } |
1104 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( $line_total, $invoice->get_currency() ) ) . '</td>'; |
|
1104 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price($line_total, $invoice->get_currency())) . '</td>'; |
|
1105 | 1105 | $line_item .= '</tr>'; |
1106 | 1106 | |
1107 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1107 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1108 | 1108 | |
1109 | 1109 | $count++; |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1112 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1113 | 1113 | ?> |
1114 | 1114 | <tr class="row-sub-total row_odd"> |
1115 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1116 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1115 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1116 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1117 | 1117 | </tr> |
1118 | 1118 | <?php |
1119 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1119 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1120 | 1120 | |
1121 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1122 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1121 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1122 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1123 | 1123 | ?> |
1124 | 1124 | <tr class="row-discount"> |
1125 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1126 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1125 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1126 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1127 | 1127 | </tr> |
1128 | 1128 | <?php |
1129 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1129 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | - if ( $use_taxes ) { |
|
1133 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1132 | + if ($use_taxes) { |
|
1133 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1134 | 1134 | ?> |
1135 | 1135 | <tr class="row-tax"> |
1136 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1137 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1136 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1137 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1138 | 1138 | </tr> |
1139 | 1139 | <?php |
1140 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1140 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1143 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1144 | 1144 | ?> |
1145 | 1145 | <tr class="table-active row-total"> |
1146 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1147 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1146 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1147 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1148 | 1148 | </tr> |
1149 | 1149 | <?php |
1150 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1150 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1151 | 1151 | |
1152 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1152 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1153 | 1153 | } |
1154 | 1154 | ?> |
1155 | 1155 | </tbody> |
@@ -1158,35 +1158,35 @@ discard block |
||
1158 | 1158 | echo ob_get_clean(); |
1159 | 1159 | } |
1160 | 1160 | |
1161 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1161 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1162 | 1162 | $use_taxes = wpinv_use_taxes(); |
1163 | 1163 | |
1164 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1164 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1165 | 1165 | ?> |
1166 | 1166 | <table class="table table-sm table-bordered table-responsive"> |
1167 | 1167 | <tbody> |
1168 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1168 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1169 | 1169 | <tr class="row-sub-total"> |
1170 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1171 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1170 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1171 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1172 | 1172 | </tr> |
1173 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1174 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1173 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1174 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1175 | 1175 | <tr class="row-discount"> |
1176 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1177 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1176 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1177 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1178 | 1178 | </tr> |
1179 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1179 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1180 | 1180 | <?php } ?> |
1181 | - <?php if ( $use_taxes ) { ?> |
|
1181 | + <?php if ($use_taxes) { ?> |
|
1182 | 1182 | <tr class="row-tax"> |
1183 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1184 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1183 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1184 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1185 | 1185 | </tr> |
1186 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1186 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1187 | 1187 | <?php } ?> |
1188 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1189 | - <?php foreach ( $fees as $fee ) { ?> |
|
1188 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1189 | + <?php foreach ($fees as $fee) { ?> |
|
1190 | 1190 | <tr class="row-fee"> |
1191 | 1191 | <td class="rate"><?php echo $fee['label']; ?></td> |
1192 | 1192 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1194,72 +1194,72 @@ discard block |
||
1194 | 1194 | <?php } ?> |
1195 | 1195 | <?php } ?> |
1196 | 1196 | <tr class="table-active row-total"> |
1197 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1198 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1197 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1198 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1199 | 1199 | </tr> |
1200 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1200 | + <?php do_action('wpinv_after_totals'); ?> |
|
1201 | 1201 | </tbody> |
1202 | 1202 | |
1203 | 1203 | </table> |
1204 | 1204 | |
1205 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1205 | + <?php do_action('wpinv_after_totals_table'); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1209 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1208 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1209 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1210 | 1210 | |
1211 | 1211 | ob_start(); |
1212 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1213 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() ) { |
|
1212 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1213 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid()) { |
|
1214 | 1214 | ?> |
1215 | 1215 | <div class="wpi-payment-info"> |
1216 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1217 | - <?php if ( $gateway_title ) { ?> |
|
1218 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1216 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1217 | + <?php if ($gateway_title) { ?> |
|
1218 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1219 | 1219 | <?php } ?> |
1220 | 1220 | </div> |
1221 | 1221 | <?php |
1222 | 1222 | } |
1223 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1223 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1224 | 1224 | $outout = ob_get_clean(); |
1225 | 1225 | |
1226 | - if ( $echo ) { |
|
1226 | + if ($echo) { |
|
1227 | 1227 | echo $outout; |
1228 | 1228 | } else { |
1229 | 1229 | return $outout; |
1230 | 1230 | } |
1231 | 1231 | } |
1232 | 1232 | |
1233 | -function wpinv_display_style( $invoice ) { |
|
1234 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1233 | +function wpinv_display_style($invoice) { |
|
1234 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1235 | 1235 | |
1236 | - wp_print_styles( 'open-sans' ); |
|
1237 | - wp_print_styles( 'wpinv-single-style' ); |
|
1236 | + wp_print_styles('open-sans'); |
|
1237 | + wp_print_styles('wpinv-single-style'); |
|
1238 | 1238 | } |
1239 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1239 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1240 | 1240 | |
1241 | 1241 | function wpinv_checkout_billing_details() { |
1242 | 1242 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1243 | 1243 | if (empty($invoice_id)) { |
1244 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1244 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1245 | 1245 | return null; |
1246 | 1246 | } |
1247 | 1247 | |
1248 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1248 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1249 | 1249 | if (empty($invoice)) { |
1250 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1250 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1251 | 1251 | return null; |
1252 | 1252 | } |
1253 | 1253 | $user_id = $invoice->get_user_id(); |
1254 | 1254 | $user_info = $invoice->get_user_info(); |
1255 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1255 | + $address_info = wpinv_get_user_address($user_id); |
|
1256 | 1256 | |
1257 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1257 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1258 | 1258 | $user_info['first_name'] = $user_info['first_name']; |
1259 | 1259 | $user_info['last_name'] = $user_info['last_name']; |
1260 | 1260 | } |
1261 | 1261 | |
1262 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1262 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1263 | 1263 | $user_info['country'] = $address_info['country']; |
1264 | 1264 | $user_info['state'] = $address_info['state']; |
1265 | 1265 | $user_info['city'] = $address_info['city']; |
@@ -1275,103 +1275,103 @@ discard block |
||
1275 | 1275 | 'address' |
1276 | 1276 | ); |
1277 | 1277 | |
1278 | - foreach ( $address_fields as $field ) { |
|
1279 | - if ( empty( $user_info[$field] ) ) { |
|
1278 | + foreach ($address_fields as $field) { |
|
1279 | + if (empty($user_info[$field])) { |
|
1280 | 1280 | $user_info[$field] = $address_info[$field]; |
1281 | 1281 | } |
1282 | 1282 | } |
1283 | 1283 | |
1284 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1284 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | function wpinv_admin_get_line_items($invoice = array()) { |
1288 | 1288 | $item_quantities = wpinv_item_quantities_enabled(); |
1289 | 1289 | $use_taxes = wpinv_use_taxes(); |
1290 | 1290 | |
1291 | - if ( empty( $invoice ) ) { |
|
1291 | + if (empty($invoice)) { |
|
1292 | 1292 | return NULL; |
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | $cart_items = $invoice->get_cart_details(); |
1296 | - if ( empty( $cart_items ) ) { |
|
1296 | + if (empty($cart_items)) { |
|
1297 | 1297 | return NULL; |
1298 | 1298 | } |
1299 | 1299 | ob_start(); |
1300 | 1300 | |
1301 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1301 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1302 | 1302 | |
1303 | 1303 | $count = 0; |
1304 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1304 | + foreach ($cart_items as $key => $cart_item) { |
|
1305 | 1305 | $item_id = $cart_item['id']; |
1306 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1306 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1307 | 1307 | |
1308 | 1308 | if (empty($wpi_item)) { |
1309 | 1309 | continue; |
1310 | 1310 | } |
1311 | 1311 | |
1312 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ) ); |
|
1313 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1314 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ) ); |
|
1312 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price'])); |
|
1313 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1314 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal'])); |
|
1315 | 1315 | $can_remove = true; |
1316 | 1316 | |
1317 | 1317 | $summary = ''; |
1318 | 1318 | if ($wpi_item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1319 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1320 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_cpt_singular_name(), $post_link ); |
|
1319 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1320 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_cpt_singular_name(), $post_link); |
|
1321 | 1321 | } |
1322 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice ); |
|
1322 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice); |
|
1323 | 1323 | |
1324 | 1324 | $item_tax = ''; |
1325 | 1325 | $tax_rate = ''; |
1326 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1327 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1328 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1329 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount( $tax_rate, 2 ) : ''; |
|
1326 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1327 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1328 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1329 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount($tax_rate, 2) : ''; |
|
1330 | 1330 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1331 | 1331 | } |
1332 | 1332 | $line_item_tax = $item_tax . $tax_rate; |
1333 | 1333 | |
1334 | - if ( $line_item_tax === '' ) { |
|
1334 | + if ($line_item_tax === '') { |
|
1335 | 1335 | $line_item_tax = 0; // Zero tax |
1336 | 1336 | } |
1337 | 1337 | |
1338 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1338 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1339 | 1339 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1340 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
1341 | - if ( $summary !== '' ) { |
|
1342 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1340 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
1341 | + if ($summary !== '') { |
|
1342 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1343 | 1343 | } |
1344 | 1344 | $line_item .= '</td>'; |
1345 | 1345 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1346 | 1346 | |
1347 | - if ( $item_quantities ) { |
|
1348 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1347 | + if ($item_quantities) { |
|
1348 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1349 | 1349 | $can_remove = false; |
1350 | 1350 | } |
1351 | 1351 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1352 | 1352 | } else { |
1353 | - if ( count( $cart_items ) == 1 ) { |
|
1353 | + if (count($cart_items) == 1) { |
|
1354 | 1354 | $can_remove = false; |
1355 | 1355 | } |
1356 | 1356 | } |
1357 | 1357 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1358 | 1358 | |
1359 | - if ( $use_taxes ) { |
|
1359 | + if ($use_taxes) { |
|
1360 | 1360 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1361 | 1361 | } |
1362 | 1362 | $line_item .= '<td class="action">'; |
1363 | - if ( !$invoice->is_paid() && $can_remove ) { |
|
1363 | + if (!$invoice->is_paid() && $can_remove) { |
|
1364 | 1364 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1365 | 1365 | } |
1366 | 1366 | $line_item .= '</td>'; |
1367 | 1367 | $line_item .= '</tr>'; |
1368 | 1368 | |
1369 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1369 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1370 | 1370 | |
1371 | 1371 | $count++; |
1372 | 1372 | } |
1373 | 1373 | |
1374 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1374 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1375 | 1375 | |
1376 | 1376 | return ob_get_clean(); |
1377 | 1377 | } |
@@ -1382,35 +1382,35 @@ discard block |
||
1382 | 1382 | // Set current invoice id. |
1383 | 1383 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1384 | 1384 | |
1385 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1385 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1386 | 1386 | |
1387 | 1387 | ob_start(); |
1388 | 1388 | echo '<div id="wpinv_checkout_wrap">'; |
1389 | 1389 | |
1390 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1390 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1391 | 1391 | ?> |
1392 | 1392 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1393 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1393 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1394 | 1394 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1395 | 1395 | <?php |
1396 | - do_action( 'wpinv_checkout_form_top' ); |
|
1397 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1398 | - do_action( 'wpinv_checkout_cart' ); |
|
1399 | - do_action( 'wpinv_payment_mode_select' ); |
|
1400 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1396 | + do_action('wpinv_checkout_form_top'); |
|
1397 | + do_action('wpinv_checkout_billing_info'); |
|
1398 | + do_action('wpinv_checkout_cart'); |
|
1399 | + do_action('wpinv_payment_mode_select'); |
|
1400 | + do_action('wpinv_checkout_form_bottom') |
|
1401 | 1401 | ?> |
1402 | 1402 | </form> |
1403 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1403 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1404 | 1404 | </div><!--end #wpinv_checkout_form_wrap--> |
1405 | 1405 | <?php |
1406 | 1406 | } else { |
1407 | - do_action( 'wpinv_cart_empty' ); |
|
1407 | + do_action('wpinv_cart_empty'); |
|
1408 | 1408 | } |
1409 | 1409 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1410 | 1410 | return ob_get_clean(); |
1411 | 1411 | } |
1412 | 1412 | |
1413 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1413 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1414 | 1414 | global $ajax_cart_details; |
1415 | 1415 | $ajax_cart_details = $cart_details; |
1416 | 1416 | /* |
@@ -1425,25 +1425,25 @@ discard block |
||
1425 | 1425 | } |
1426 | 1426 | */ |
1427 | 1427 | ob_start(); |
1428 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1428 | + do_action('wpinv_before_checkout_cart'); |
|
1429 | 1429 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1430 | 1430 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1431 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1431 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1432 | 1432 | echo '</div>'; |
1433 | 1433 | echo '</div>'; |
1434 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1434 | + do_action('wpinv_after_checkout_cart'); |
|
1435 | 1435 | $content = ob_get_clean(); |
1436 | 1436 | |
1437 | - if ( $echo ) { |
|
1437 | + if ($echo) { |
|
1438 | 1438 | echo $content; |
1439 | 1439 | } else { |
1440 | 1440 | return $content; |
1441 | 1441 | } |
1442 | 1442 | } |
1443 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1443 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1444 | 1444 | |
1445 | 1445 | function wpinv_empty_cart_message() { |
1446 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1446 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | /** |
@@ -1455,91 +1455,91 @@ discard block |
||
1455 | 1455 | function wpinv_empty_checkout_cart() { |
1456 | 1456 | echo wpinv_empty_cart_message(); |
1457 | 1457 | } |
1458 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1458 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1459 | 1459 | |
1460 | 1460 | function wpinv_save_cart_button() { |
1461 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1461 | + if (wpinv_is_cart_saving_disabled()) |
|
1462 | 1462 | return; |
1463 | 1463 | ?> |
1464 | - <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
|
1464 | + <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a> |
|
1465 | 1465 | <?php |
1466 | 1466 | } |
1467 | 1467 | |
1468 | 1468 | function wpinv_update_cart_button() { |
1469 | - if ( !wpinv_item_quantities_enabled() ) |
|
1469 | + if (!wpinv_item_quantities_enabled()) |
|
1470 | 1470 | return; |
1471 | 1471 | ?> |
1472 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1472 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1473 | 1473 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1474 | 1474 | <?php |
1475 | 1475 | } |
1476 | 1476 | |
1477 | 1477 | function wpinv_checkout_cart_columns() { |
1478 | 1478 | $default = 3; |
1479 | - if ( wpinv_item_quantities_enabled() ) { |
|
1479 | + if (wpinv_item_quantities_enabled()) { |
|
1480 | 1480 | $default++; |
1481 | 1481 | } |
1482 | 1482 | |
1483 | - if ( wpinv_use_taxes() ) { |
|
1483 | + if (wpinv_use_taxes()) { |
|
1484 | 1484 | $default++; |
1485 | 1485 | } |
1486 | 1486 | |
1487 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1487 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | function wpinv_display_cart_messages() { |
1491 | 1491 | global $wpi_session; |
1492 | 1492 | |
1493 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1493 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1494 | 1494 | |
1495 | - if ( $messages ) { |
|
1496 | - foreach ( $messages as $message_id => $message ) { |
|
1495 | + if ($messages) { |
|
1496 | + foreach ($messages as $message_id => $message) { |
|
1497 | 1497 | // Try and detect what type of message this is |
1498 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1498 | + if (strpos(strtolower($message), 'error')) { |
|
1499 | 1499 | $type = 'error'; |
1500 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1500 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1501 | 1501 | $type = 'success'; |
1502 | 1502 | } else { |
1503 | 1503 | $type = 'info'; |
1504 | 1504 | } |
1505 | 1505 | |
1506 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1506 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1507 | 1507 | |
1508 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1508 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1509 | 1509 | // Loop message codes and display messages |
1510 | 1510 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1511 | 1511 | echo '</div>'; |
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | // Remove all of the cart saving messages |
1515 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1515 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1516 | 1516 | } |
1517 | 1517 | } |
1518 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1518 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1519 | 1519 | |
1520 | 1520 | function wpinv_discount_field() { |
1521 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1521 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1522 | 1522 | return; // Only show before a payment method has been selected if ajax is disabled |
1523 | 1523 | } |
1524 | 1524 | |
1525 | - if ( !wpinv_is_checkout() ) { |
|
1525 | + if (!wpinv_is_checkout()) { |
|
1526 | 1526 | return; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1529 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1530 | 1530 | ?> |
1531 | 1531 | <div id="wpinv-discount-field" class="panel panel-default"> |
1532 | 1532 | <div class="panel-body"> |
1533 | 1533 | <p> |
1534 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1535 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1534 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1535 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1536 | 1536 | </p> |
1537 | 1537 | <div class="form-group row"> |
1538 | 1538 | <div class="col-sm-4"> |
1539 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1539 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1540 | 1540 | </div> |
1541 | 1541 | <div class="col-sm-3"> |
1542 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1542 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1543 | 1543 | </div> |
1544 | 1544 | <div class="col-sm-12 wpinv-discount-msg"> |
1545 | 1545 | <div class="alert alert-success"><i class="fa fa-check-circle"></i><span class="wpi-msg"></span></div> |
@@ -1551,10 +1551,10 @@ discard block |
||
1551 | 1551 | <?php |
1552 | 1552 | } |
1553 | 1553 | } |
1554 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1554 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1555 | 1555 | |
1556 | 1556 | function wpinv_agree_to_terms_js() { |
1557 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1557 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1558 | 1558 | ?> |
1559 | 1559 | <script type="text/javascript"> |
1560 | 1560 | jQuery(document).ready(function($){ |
@@ -1569,124 +1569,124 @@ discard block |
||
1569 | 1569 | <?php |
1570 | 1570 | } |
1571 | 1571 | } |
1572 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1572 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1573 | 1573 | |
1574 | 1574 | function wpinv_payment_mode_select() { |
1575 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1576 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1575 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1576 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1577 | 1577 | $page_URL = wpinv_get_current_page_url(); |
1578 | 1578 | |
1579 | 1579 | do_action('wpinv_payment_mode_top'); |
1580 | 1580 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1581 | 1581 | ?> |
1582 | 1582 | <div id="wpinv_payment_mode_select"> |
1583 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1583 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1584 | 1584 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1585 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1585 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1586 | 1586 | <div class="panel-body list-group wpi-payment_methods"> |
1587 | 1587 | <?php |
1588 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1589 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1588 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1589 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1590 | 1590 | |
1591 | - if(!empty($gateways)){ |
|
1592 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1593 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1594 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1595 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1591 | + if (!empty($gateways)) { |
|
1592 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1593 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1594 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1595 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1596 | 1596 | ?> |
1597 | 1597 | <div class="list-group-item"> |
1598 | 1598 | <div class="radio"> |
1599 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1599 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1600 | 1600 | </div> |
1601 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1602 | - <?php if ( !empty( $description ) ) { ?> |
|
1603 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
1601 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1602 | + <?php if (!empty($description)) { ?> |
|
1603 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
1604 | 1604 | <?php } ?> |
1605 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1605 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1606 | 1606 | </div> |
1607 | 1607 | </div> |
1608 | 1608 | <?php |
1609 | 1609 | } |
1610 | - }else{ |
|
1611 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1610 | + } else { |
|
1611 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1612 | 1612 | } |
1613 | 1613 | |
1614 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1614 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1615 | 1615 | ?> |
1616 | 1616 | </div> |
1617 | 1617 | </div> |
1618 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1618 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1619 | 1619 | </div> |
1620 | 1620 | <?php |
1621 | 1621 | do_action('wpinv_payment_mode_bottom'); |
1622 | 1622 | } |
1623 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1623 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1624 | 1624 | |
1625 | 1625 | function wpinv_checkout_billing_info() { |
1626 | - if ( wpinv_is_checkout() ) { |
|
1626 | + if (wpinv_is_checkout()) { |
|
1627 | 1627 | $logged_in = is_user_logged_in(); |
1628 | 1628 | $billing_details = wpinv_checkout_billing_details(); |
1629 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1629 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1630 | 1630 | ?> |
1631 | 1631 | <div id="wpinv-fields" class="clearfix"> |
1632 | 1632 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1633 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1633 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1634 | 1634 | <div id="wpinv-fields-box" class="panel-body"> |
1635 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1635 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1636 | 1636 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1637 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1637 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1638 | 1638 | <?php |
1639 | - echo wpinv_html_text( array( |
|
1639 | + echo wpinv_html_text(array( |
|
1640 | 1640 | 'id' => 'wpinv_first_name', |
1641 | 1641 | 'name' => 'wpinv_first_name', |
1642 | 1642 | 'value' => $billing_details['first_name'], |
1643 | 1643 | 'class' => 'wpi-input form-control required', |
1644 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1644 | + 'placeholder' => __('First name', 'invoicing'), |
|
1645 | 1645 | 'required' => true, |
1646 | - ) ); |
|
1646 | + )); |
|
1647 | 1647 | ?> |
1648 | 1648 | </p> |
1649 | 1649 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1650 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?></label> |
|
1650 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?></label> |
|
1651 | 1651 | <?php |
1652 | - echo wpinv_html_text( array( |
|
1652 | + echo wpinv_html_text(array( |
|
1653 | 1653 | 'id' => 'wpinv_last_name', |
1654 | 1654 | 'name' => 'wpinv_last_name', |
1655 | 1655 | 'value' => $billing_details['last_name'], |
1656 | 1656 | 'class' => 'wpi-input form-control', |
1657 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1658 | - ) ); |
|
1657 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1658 | + )); |
|
1659 | 1659 | ?> |
1660 | 1660 | </p> |
1661 | 1661 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1662 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1662 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1663 | 1663 | <?php |
1664 | - echo wpinv_html_text( array( |
|
1664 | + echo wpinv_html_text(array( |
|
1665 | 1665 | 'id' => 'wpinv_address', |
1666 | 1666 | 'name' => 'wpinv_address', |
1667 | 1667 | 'value' => $billing_details['address'], |
1668 | 1668 | 'class' => 'wpi-input form-control required', |
1669 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1669 | + 'placeholder' => __('Address', 'invoicing'), |
|
1670 | 1670 | 'required' => true, |
1671 | - ) ); |
|
1671 | + )); |
|
1672 | 1672 | ?> |
1673 | 1673 | </p> |
1674 | 1674 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1675 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1675 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1676 | 1676 | <?php |
1677 | - echo wpinv_html_text( array( |
|
1677 | + echo wpinv_html_text(array( |
|
1678 | 1678 | 'id' => 'wpinv_city', |
1679 | 1679 | 'name' => 'wpinv_city', |
1680 | 1680 | 'value' => $billing_details['city'], |
1681 | 1681 | 'class' => 'wpi-input form-control required', |
1682 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1682 | + 'placeholder' => __('City', 'invoicing'), |
|
1683 | 1683 | 'required' => true, |
1684 | - ) ); |
|
1684 | + )); |
|
1685 | 1685 | ?> |
1686 | 1686 | </p> |
1687 | 1687 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1688 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1689 | - <?php echo wpinv_html_select( array( |
|
1688 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1689 | + <?php echo wpinv_html_select(array( |
|
1690 | 1690 | 'options' => wpinv_get_country_list(), |
1691 | 1691 | 'name' => 'wpinv_country', |
1692 | 1692 | 'id' => 'wpinv_country', |
@@ -1694,16 +1694,16 @@ discard block |
||
1694 | 1694 | 'show_option_all' => false, |
1695 | 1695 | 'show_option_none' => false, |
1696 | 1696 | 'class' => 'wpi-input form-control required', |
1697 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1697 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1698 | 1698 | 'required' => true, |
1699 | - ) ); ?> |
|
1699 | + )); ?> |
|
1700 | 1700 | </p> |
1701 | 1701 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1702 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1702 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1703 | 1703 | <?php |
1704 | - $states = wpinv_get_country_states( $selected_country ); |
|
1705 | - if( !empty( $states ) ) { |
|
1706 | - echo wpinv_html_select( array( |
|
1704 | + $states = wpinv_get_country_states($selected_country); |
|
1705 | + if (!empty($states)) { |
|
1706 | + echo wpinv_html_select(array( |
|
1707 | 1707 | 'options' => $states, |
1708 | 1708 | 'name' => 'wpinv_state', |
1709 | 1709 | 'id' => 'wpinv_state', |
@@ -1711,60 +1711,60 @@ discard block |
||
1711 | 1711 | 'show_option_all' => false, |
1712 | 1712 | 'show_option_none' => false, |
1713 | 1713 | 'class' => 'wpi-input form-control required', |
1714 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1714 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1715 | 1715 | 'required' => true, |
1716 | - ) ); |
|
1716 | + )); |
|
1717 | 1717 | } else { |
1718 | - echo wpinv_html_text( array( |
|
1718 | + echo wpinv_html_text(array( |
|
1719 | 1719 | 'name' => 'wpinv_state', |
1720 | 1720 | 'value' => $billing_details['state'], |
1721 | 1721 | 'id' => 'wpinv_state', |
1722 | 1722 | 'class' => 'wpi-input form-control required', |
1723 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1723 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1724 | 1724 | 'required' => true, |
1725 | - ) ); |
|
1725 | + )); |
|
1726 | 1726 | } |
1727 | 1727 | ?> |
1728 | 1728 | </p> |
1729 | 1729 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1730 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?></label> |
|
1730 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?></label> |
|
1731 | 1731 | <?php |
1732 | - echo wpinv_html_text( array( |
|
1732 | + echo wpinv_html_text(array( |
|
1733 | 1733 | 'name' => 'wpinv_zip', |
1734 | 1734 | 'value' => $billing_details['zip'], |
1735 | 1735 | 'id' => 'wpinv_zip', |
1736 | 1736 | 'class' => 'wpi-input form-control', |
1737 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1738 | - ) ); |
|
1737 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1738 | + )); |
|
1739 | 1739 | ?> |
1740 | 1740 | </p> |
1741 | 1741 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1742 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1742 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1743 | 1743 | <?php |
1744 | - echo wpinv_html_text( array( |
|
1744 | + echo wpinv_html_text(array( |
|
1745 | 1745 | 'id' => 'wpinv_phone', |
1746 | 1746 | 'name' => 'wpinv_phone', |
1747 | 1747 | 'value' => $billing_details['phone'], |
1748 | 1748 | 'class' => 'wpi-input form-control', |
1749 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1750 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1751 | - ) ); |
|
1749 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1750 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1751 | + )); |
|
1752 | 1752 | ?> |
1753 | 1753 | </p> |
1754 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1754 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1755 | 1755 | <div class="clearfix"></div> |
1756 | 1756 | </div> |
1757 | 1757 | </div> |
1758 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1758 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1759 | 1759 | </div> |
1760 | 1760 | <?php |
1761 | 1761 | } |
1762 | 1762 | } |
1763 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1763 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1764 | 1764 | |
1765 | 1765 | function wpinv_checkout_hidden_fields() { |
1766 | 1766 | ?> |
1767 | - <?php if ( is_user_logged_in() ) { ?> |
|
1767 | + <?php if (is_user_logged_in()) { ?> |
|
1768 | 1768 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1769 | 1769 | <?php } ?> |
1770 | 1770 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1774,9 +1774,9 @@ discard block |
||
1774 | 1774 | function wpinv_checkout_button_purchase() { |
1775 | 1775 | ob_start(); |
1776 | 1776 | ?> |
1777 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
1777 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
1778 | 1778 | <?php |
1779 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1779 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | 1782 | function wpinv_checkout_total() { |
@@ -1785,96 +1785,96 @@ discard block |
||
1785 | 1785 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1786 | 1786 | <div class="panel-body"> |
1787 | 1787 | <?php |
1788 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1788 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1789 | 1789 | ?> |
1790 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1790 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1791 | 1791 | <?php |
1792 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1792 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1793 | 1793 | ?> |
1794 | 1794 | </div> |
1795 | 1795 | </div> |
1796 | 1796 | <?php |
1797 | 1797 | } |
1798 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1798 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1799 | 1799 | |
1800 | 1800 | function wpinv_checkout_submit() { |
1801 | 1801 | ?> |
1802 | 1802 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1803 | 1803 | <div class="panel-body text-center"> |
1804 | 1804 | <?php |
1805 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1805 | + do_action('wpinv_purchase_form_before_submit'); |
|
1806 | 1806 | wpinv_checkout_hidden_fields(); |
1807 | 1807 | echo wpinv_checkout_button_purchase(); |
1808 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1808 | + do_action('wpinv_purchase_form_after_submit'); |
|
1809 | 1809 | ?> |
1810 | 1810 | </div> |
1811 | 1811 | </div> |
1812 | 1812 | <?php |
1813 | 1813 | } |
1814 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1814 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1815 | 1815 | |
1816 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1817 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1816 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1817 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1818 | 1818 | |
1819 | - if ( empty( $invoice ) ) { |
|
1819 | + if (empty($invoice)) { |
|
1820 | 1820 | return NULL; |
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | $billing_details = $invoice->get_user_info(); |
1824 | 1824 | $address_row = ''; |
1825 | - if ( $address = $billing_details['address'] ) { |
|
1826 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1825 | + if ($address = $billing_details['address']) { |
|
1826 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1827 | 1827 | } |
1828 | 1828 | |
1829 | 1829 | $address_fields = array(); |
1830 | - if ( !empty( $billing_details['city'] ) ) { |
|
1830 | + if (!empty($billing_details['city'])) { |
|
1831 | 1831 | $address_fields[] = $billing_details['city']; |
1832 | 1832 | } |
1833 | 1833 | |
1834 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1835 | - if ( !empty( $billing_details['state'] ) ) { |
|
1836 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1834 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1835 | + if (!empty($billing_details['state'])) { |
|
1836 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1837 | 1837 | } |
1838 | 1838 | |
1839 | - if ( !empty( $billing_country ) ) { |
|
1840 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1839 | + if (!empty($billing_country)) { |
|
1840 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1841 | 1841 | } |
1842 | 1842 | |
1843 | - if ( !empty( $address_fields ) ) { |
|
1844 | - $address_fields = implode( ", ", $address_fields ); |
|
1843 | + if (!empty($address_fields)) { |
|
1844 | + $address_fields = implode(", ", $address_fields); |
|
1845 | 1845 | |
1846 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1846 | + if (!empty($billing_details['zip'])) { |
|
1847 | 1847 | $address_fields .= ' ' . $billing_details['zip']; |
1848 | 1848 | } |
1849 | 1849 | |
1850 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1850 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1851 | 1851 | } |
1852 | 1852 | ob_start(); |
1853 | 1853 | ?> |
1854 | 1854 | <table class="table table-bordered table-sm wpi-billing-details"> |
1855 | 1855 | <tbody> |
1856 | 1856 | <tr class="wpi-receipt-name"> |
1857 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1858 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1857 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1858 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1859 | 1859 | </tr> |
1860 | 1860 | <tr class="wpi-receipt-email"> |
1861 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1862 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1861 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1862 | + <td><?php echo $billing_details['email']; ?></td> |
|
1863 | 1863 | </tr> |
1864 | - <?php if ( $billing_details['company'] ) { ?> |
|
1864 | + <?php if ($billing_details['company']) { ?> |
|
1865 | 1865 | <tr class="wpi-receipt-company"> |
1866 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1867 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1866 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1867 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1868 | 1868 | </tr> |
1869 | 1869 | <?php } ?> |
1870 | 1870 | <tr class="wpi-receipt-address"> |
1871 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1872 | - <td><?php echo $address_row ;?></td> |
|
1871 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1872 | + <td><?php echo $address_row; ?></td> |
|
1873 | 1873 | </tr> |
1874 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1874 | + <?php if ($billing_details['phone']) { ?> |
|
1875 | 1875 | <tr class="wpi-receipt-phone"> |
1876 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1877 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1876 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1877 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1878 | 1878 | </tr> |
1879 | 1879 | <?php } ?> |
1880 | 1880 | </tbody> |
@@ -1882,98 +1882,98 @@ discard block |
||
1882 | 1882 | <?php |
1883 | 1883 | $output = ob_get_clean(); |
1884 | 1884 | |
1885 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1885 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1886 | 1886 | |
1887 | 1887 | echo $output; |
1888 | 1888 | } |
1889 | 1889 | |
1890 | -function wpinv_filter_success_page_content( $content ) { |
|
1891 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1892 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1893 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1890 | +function wpinv_filter_success_page_content($content) { |
|
1891 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1892 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1893 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1894 | 1894 | } |
1895 | 1895 | } |
1896 | 1896 | |
1897 | 1897 | return $content; |
1898 | 1898 | } |
1899 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1899 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1900 | 1900 | |
1901 | -function wpinv_receipt_actions( $invoice ) { |
|
1902 | - if ( !empty( $invoice ) ) { |
|
1901 | +function wpinv_receipt_actions($invoice) { |
|
1902 | + if (!empty($invoice)) { |
|
1903 | 1903 | $actions = array( |
1904 | 1904 | 'print' => array( |
1905 | 1905 | 'url' => $invoice->get_view_url(), |
1906 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1906 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1907 | 1907 | 'class' => 'btn-primary', |
1908 | 1908 | ), |
1909 | 1909 | 'history' => array( |
1910 | 1910 | 'url' => wpinv_get_history_page_uri(), |
1911 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1911 | + 'name' => __('Invoice History', 'invoicing'), |
|
1912 | 1912 | 'class' => 'btn-warning', |
1913 | 1913 | ) |
1914 | 1914 | ); |
1915 | 1915 | |
1916 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1916 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1917 | 1917 | |
1918 | - if ( !empty( $actions ) ) { |
|
1918 | + if (!empty($actions)) { |
|
1919 | 1919 | ?> |
1920 | 1920 | <div class="wpinv-receipt-actions text-right"> |
1921 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1922 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1921 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1922 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1923 | 1923 | <?php } ?> |
1924 | 1924 | </div> |
1925 | 1925 | <?php |
1926 | 1926 | } |
1927 | 1927 | } |
1928 | 1928 | } |
1929 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1929 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1930 | 1930 | |
1931 | -function wpinv_invoice_link( $invoice_id ) { |
|
1932 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1931 | +function wpinv_invoice_link($invoice_id) { |
|
1932 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1933 | 1933 | |
1934 | - if ( empty( $invoice ) ) { |
|
1934 | + if (empty($invoice)) { |
|
1935 | 1935 | return NULL; |
1936 | 1936 | } |
1937 | 1937 | |
1938 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1938 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1939 | 1939 | |
1940 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1940 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1941 | 1941 | } |
1942 | 1942 | |
1943 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1944 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
1943 | +function wpinv_invoice_subscription_details($invoice) { |
|
1944 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1945 | 1945 | $total_payments = (int)$invoice->get_total_payments(); |
1946 | 1946 | $payments = $invoice->get_child_payments(); |
1947 | 1947 | |
1948 | 1948 | $subscription = $invoice->get_subscription_data(); |
1949 | 1949 | |
1950 | - if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) { |
|
1950 | + if (!(!empty($subscription) && !empty($subscription['item_id']))) { |
|
1951 | 1951 | return; |
1952 | 1952 | } |
1953 | 1953 | |
1954 | - $billing_cycle = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() ); |
|
1955 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
1954 | + $billing_cycle = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency()); |
|
1955 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
1956 | 1956 | |
1957 | 1957 | $subscription_status = $invoice->get_subscription_status(); |
1958 | 1958 | |
1959 | 1959 | $status_desc = ''; |
1960 | - if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { |
|
1961 | - $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date ); |
|
1962 | - } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) { |
|
1963 | - $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date ); |
|
1960 | + if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { |
|
1961 | + $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date); |
|
1962 | + } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) { |
|
1963 | + $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date); |
|
1964 | 1964 | } |
1965 | 1965 | $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : ''; |
1966 | 1966 | ?> |
1967 | 1967 | <div class="wpinv-subscriptions-details"> |
1968 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1968 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1969 | 1969 | <table class="table"> |
1970 | 1970 | <thead> |
1971 | 1971 | <tr> |
1972 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1973 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1974 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1975 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1976 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1972 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1973 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1974 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1975 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1976 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1977 | 1977 | </tr> |
1978 | 1978 | </thead> |
1979 | 1979 | <tbody> |
@@ -1982,32 +1982,32 @@ discard block |
||
1982 | 1982 | <td><?php echo $invoice->get_subscription_start(); ?></td> |
1983 | 1983 | <td><?php echo $invoice->get_subscription_end(); ?></td> |
1984 | 1984 | <td class="text-center"><?php echo $times_billed; ?></td> |
1985 | - <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?> |
|
1985 | + <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?> |
|
1986 | 1986 | <?php echo $status_desc; ?> |
1987 | 1987 | </td> |
1988 | 1988 | </tr> |
1989 | 1989 | </tbody> |
1990 | 1990 | </table> |
1991 | 1991 | </div> |
1992 | - <?php if ( !empty( $payments ) ) { ?> |
|
1992 | + <?php if (!empty($payments)) { ?> |
|
1993 | 1993 | <div class="wpinv-renewal-payments"> |
1994 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
1994 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
1995 | 1995 | <table class="table"> |
1996 | 1996 | <thead> |
1997 | 1997 | <tr> |
1998 | 1998 | <th>#</th> |
1999 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
2000 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
2001 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
1999 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
2000 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
2001 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
2002 | 2002 | </tr> |
2003 | 2003 | </thead> |
2004 | 2004 | <tbody> |
2005 | - <?php foreach ( $payments as $key => $invoice_id ) { ?> |
|
2005 | + <?php foreach ($payments as $key => $invoice_id) { ?> |
|
2006 | 2006 | <tr> |
2007 | - <th scope="row"><?php echo ( $key + 1 );?></th> |
|
2008 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2009 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2010 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2007 | + <th scope="row"><?php echo ($key + 1); ?></th> |
|
2008 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2009 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2010 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2011 | 2011 | </tr> |
2012 | 2012 | <?php } ?> |
2013 | 2013 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -2019,52 +2019,52 @@ discard block |
||
2019 | 2019 | } |
2020 | 2020 | } |
2021 | 2021 | |
2022 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2023 | - if ( empty( $invoice ) ) { |
|
2022 | +function wpinv_cart_total_label($label, $invoice) { |
|
2023 | + if (empty($invoice)) { |
|
2024 | 2024 | return $label; |
2025 | 2025 | } |
2026 | 2026 | |
2027 | 2027 | $prefix_label = ''; |
2028 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2029 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2030 | - } else if ( $invoice->is_renewal() ) { |
|
2031 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2028 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2029 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2030 | + } else if ($invoice->is_renewal()) { |
|
2031 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2032 | 2032 | } |
2033 | 2033 | |
2034 | - if ( $prefix_label != '' ) { |
|
2035 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2034 | + if ($prefix_label != '') { |
|
2035 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2036 | 2036 | } |
2037 | 2037 | |
2038 | 2038 | return $label; |
2039 | 2039 | } |
2040 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2041 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2042 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2040 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2041 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2042 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2043 | 2043 | |
2044 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2044 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2045 | 2045 | |
2046 | -function wpinv_invoice_print_description( $invoice ) { |
|
2047 | - if ( empty( $invoice ) ) { |
|
2046 | +function wpinv_invoice_print_description($invoice) { |
|
2047 | + if (empty($invoice)) { |
|
2048 | 2048 | return NULL; |
2049 | 2049 | } |
2050 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2050 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2051 | 2051 | ?> |
2052 | 2052 | <div class="row wpinv-lower"> |
2053 | 2053 | <div class="col-sm-12 wpinv-description"> |
2054 | - <?php echo wpautop( $description ); ?> |
|
2054 | + <?php echo wpautop($description); ?> |
|
2055 | 2055 | </div> |
2056 | 2056 | </div> |
2057 | 2057 | <?php |
2058 | 2058 | } |
2059 | 2059 | } |
2060 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2060 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2061 | 2061 | |
2062 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2063 | - if ( empty( $invoice ) ) { |
|
2062 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2063 | + if (empty($invoice)) { |
|
2064 | 2064 | return NULL; |
2065 | 2065 | } |
2066 | 2066 | |
2067 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2067 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2068 | 2068 | ?> |
2069 | 2069 | <div class="row wpinv-payments"> |
2070 | 2070 | <div class="col-sm-12"> |
@@ -2076,40 +2076,40 @@ discard block |
||
2076 | 2076 | } |
2077 | 2077 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2078 | 2078 | |
2079 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2080 | - if ( empty( $note ) ) { |
|
2079 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2080 | + if (empty($note)) { |
|
2081 | 2081 | return NULL; |
2082 | 2082 | } |
2083 | 2083 | |
2084 | - if ( is_int( $note ) ) { |
|
2085 | - $note = get_comment( $note ); |
|
2084 | + if (is_int($note)) { |
|
2085 | + $note = get_comment($note); |
|
2086 | 2086 | } |
2087 | 2087 | |
2088 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2088 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2089 | 2089 | return NULL; |
2090 | 2090 | } |
2091 | 2091 | |
2092 | - $note_classes = array( 'note' ); |
|
2093 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2094 | - $note_classes[] = $note->comment_author === __( 'GeoDirectory', 'invoicing' ) ? 'system-note' : ''; |
|
2095 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2096 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2092 | + $note_classes = array('note'); |
|
2093 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2094 | + $note_classes[] = $note->comment_author === __('GeoDirectory', 'invoicing') ? 'system-note' : ''; |
|
2095 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2096 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2097 | 2097 | |
2098 | 2098 | ob_start(); |
2099 | 2099 | ?> |
2100 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2100 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2101 | 2101 | <div class="note_content"> |
2102 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2102 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2103 | 2103 | </div> |
2104 | 2104 | <p class="meta"> |
2105 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2105 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2106 | 2106 | </p> |
2107 | 2107 | </li> |
2108 | 2108 | <?php |
2109 | 2109 | $note_content = ob_get_clean(); |
2110 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2110 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2111 | 2111 | |
2112 | - if ( $echo ) { |
|
2112 | + if ($echo) { |
|
2113 | 2113 | echo $note_content; |
2114 | 2114 | } else { |
2115 | 2115 | return $note_content; |
@@ -1,66 +1,66 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_action( 'admin_menu', 'wpinv_add_options_link', 10 ); |
|
7 | +add_action('admin_menu', 'wpinv_add_options_link', 10); |
|
8 | 8 | function wpinv_add_options_link() { |
9 | 9 | global $menu; |
10 | 10 | |
11 | - if ( current_user_can( 'manage_options' ) ) { |
|
12 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
11 | + if (current_user_can('manage_options')) { |
|
12 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
13 | 13 | } |
14 | 14 | |
15 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
15 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
16 | 16 | |
17 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
17 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
18 | 18 | |
19 | - $wpi_settings_page = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), 'manage_options', 'wpinv-settings', 'wpinv_options_page' ); |
|
19 | + $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), 'manage_options', 'wpinv-settings', 'wpinv_options_page'); |
|
20 | 20 | } |
21 | 21 | |
22 | -add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 ); |
|
22 | +add_action('admin_menu', 'wpinv_remove_admin_submenus', 999); |
|
23 | 23 | function wpinv_remove_admin_submenus() { |
24 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
24 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
25 | 25 | } |
26 | 26 | |
27 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
28 | -function wpinv_discount_columns( $existing_columns ) { |
|
27 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
28 | +function wpinv_discount_columns($existing_columns) { |
|
29 | 29 | $columns = array(); |
30 | 30 | $columns['cb'] = $existing_columns['cb']; |
31 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
32 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
33 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
34 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
35 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
36 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
31 | + $columns['name'] = __('Name', 'invoicing'); |
|
32 | + $columns['code'] = __('Code', 'invoicing'); |
|
33 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
34 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
35 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
36 | + $columns['status'] = __('Status', 'invoicing'); |
|
37 | 37 | |
38 | 38 | return $columns; |
39 | 39 | } |
40 | 40 | |
41 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
42 | -function wpinv_discount_custom_column( $column ) { |
|
41 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
42 | +function wpinv_discount_custom_column($column) { |
|
43 | 43 | global $post; |
44 | 44 | |
45 | 45 | $discount = $post; |
46 | 46 | |
47 | - switch ( $column ) { |
|
47 | + switch ($column) { |
|
48 | 48 | case 'name' : |
49 | - echo get_the_title( $discount->ID ); |
|
49 | + echo get_the_title($discount->ID); |
|
50 | 50 | break; |
51 | 51 | case 'code' : |
52 | - echo wpinv_get_discount_code( $discount->ID ); |
|
52 | + echo wpinv_get_discount_code($discount->ID); |
|
53 | 53 | break; |
54 | 54 | case 'amount' : |
55 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
55 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
56 | 56 | break; |
57 | 57 | case 'usage_limit' : |
58 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
58 | + echo wpinv_get_discount_uses($discount->ID); |
|
59 | 59 | break; |
60 | 60 | case 'usage' : |
61 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
62 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
63 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
61 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
62 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
63 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
64 | 64 | } else { |
65 | 65 | $usage .= ' ∞'; |
66 | 66 | } |
@@ -68,162 +68,162 @@ discard block |
||
68 | 68 | echo $usage; |
69 | 69 | break; |
70 | 70 | case 'expiry_date' : |
71 | - if ( wpinv_get_discount_expiration( $discount->ID ) ) { |
|
72 | - $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) ); |
|
71 | + if (wpinv_get_discount_expiration($discount->ID)) { |
|
72 | + $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID))); |
|
73 | 73 | } else { |
74 | - $expiration = __( 'Never', 'invoicing' ); |
|
74 | + $expiration = __('Never', 'invoicing'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | echo $expiration; |
78 | 78 | break; |
79 | 79 | case 'description' : |
80 | - echo wp_kses_post( $post->post_excerpt ); |
|
80 | + echo wp_kses_post($post->post_excerpt); |
|
81 | 81 | break; |
82 | 82 | case 'status' : |
83 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
83 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
84 | 84 | |
85 | - echo wpinv_discount_status( $status ); |
|
85 | + echo wpinv_discount_status($status); |
|
86 | 86 | break; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
91 | -function wpinv_post_row_actions( $actions, $post ) { |
|
92 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
90 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
91 | +function wpinv_post_row_actions($actions, $post) { |
|
92 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
93 | 93 | |
94 | - if ( $post_type == 'wpi_invoice' ) { |
|
94 | + if ($post_type == 'wpi_invoice') { |
|
95 | 95 | $actions = array(); |
96 | 96 | } |
97 | 97 | |
98 | - if ( $post_type == 'wpi_discount' ) { |
|
99 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
98 | + if ($post_type == 'wpi_discount') { |
|
99 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return $actions; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
106 | - $row_actions = array(); |
|
107 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
108 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
105 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
106 | + $row_actions = array(); |
|
107 | + $edit_link = get_edit_post_link($discount->ID); |
|
108 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
109 | 109 | |
110 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
111 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
112 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
113 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
110 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
111 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
112 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
113 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
114 | 114 | } |
115 | 115 | |
116 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
117 | - if ( isset( $row_actions['delete'] ) ) { |
|
118 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
116 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
117 | + if (isset($row_actions['delete'])) { |
|
118 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
119 | 119 | } |
120 | 120 | } else { |
121 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
121 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
125 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
126 | 126 | |
127 | 127 | return $row_actions; |
128 | 128 | } |
129 | 129 | |
130 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
131 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
132 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
130 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
131 | +function wpinv_table_primary_column($default, $screen_id) { |
|
132 | + if ('edit-wpi_invoice' === $screen_id) { |
|
133 | 133 | return 'name'; |
134 | 134 | } |
135 | 135 | |
136 | 136 | return $default; |
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
140 | - if ( !$display ) { |
|
139 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
140 | + if (!$display) { |
|
141 | 141 | return array(); |
142 | 142 | } |
143 | 143 | |
144 | 144 | $actions = array( |
145 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
146 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
147 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
145 | + 'activate' => __('Activate', 'invoicing'), |
|
146 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
147 | + 'delete' => __('Delete', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | $two = ''; |
150 | 150 | $which = 'top'; |
151 | 151 | echo '</div><div class="alignleft actions bulkactions">'; |
152 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
153 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
154 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
152 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
153 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
154 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
155 | 155 | |
156 | - foreach ( $actions as $name => $title ) { |
|
156 | + foreach ($actions as $name => $title) { |
|
157 | 157 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
158 | 158 | |
159 | 159 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
160 | 160 | } |
161 | 161 | echo "</select>"; |
162 | 162 | |
163 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
163 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
164 | 164 | |
165 | 165 | echo '</div><div class="alignleft actions">'; |
166 | 166 | } |
167 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
167 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
168 | 168 | |
169 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
170 | - if ( $post_type == 'wpi_discount' ) { |
|
169 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
170 | + if ($post_type == 'wpi_discount') { |
|
171 | 171 | $disable = true; |
172 | 172 | } |
173 | 173 | |
174 | 174 | return $disable; |
175 | 175 | } |
176 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
176 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
177 | 177 | |
178 | 178 | function wpinv_restrict_manage_posts() { |
179 | 179 | global $typenow; |
180 | 180 | |
181 | - if( 'wpi_discount' == $typenow ) { |
|
181 | + if ('wpi_discount' == $typenow) { |
|
182 | 182 | wpinv_discount_filters(); |
183 | 183 | } |
184 | 184 | } |
185 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
185 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
186 | 186 | |
187 | 187 | function wpinv_discount_filters() { |
188 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
188 | + echo wpinv_discount_bulk_actions(array(), true); |
|
189 | 189 | |
190 | 190 | ?> |
191 | 191 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
192 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
192 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
193 | 193 | <?php |
194 | 194 | $types = wpinv_get_discount_types(); |
195 | 195 | |
196 | - foreach ( $types as $name => $type ) { |
|
197 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
196 | + foreach ($types as $name => $type) { |
|
197 | + echo '<option value="' . esc_attr($name) . '"'; |
|
198 | 198 | |
199 | - if ( isset( $_GET['discount_type'] ) ) |
|
200 | - selected( $name, $_GET['discount_type'] ); |
|
199 | + if (isset($_GET['discount_type'])) |
|
200 | + selected($name, $_GET['discount_type']); |
|
201 | 201 | |
202 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
202 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
203 | 203 | } |
204 | 204 | ?> |
205 | 205 | </select> |
206 | 206 | <?php |
207 | 207 | } |
208 | 208 | |
209 | -function wpinv_request( $vars ) { |
|
209 | +function wpinv_request($vars) { |
|
210 | 210 | global $typenow, $wp_query, $wp_post_statuses; |
211 | 211 | |
212 | - if ( 'wpi_invoice' === $typenow ) { |
|
213 | - if ( !isset( $vars['post_status'] ) ) { |
|
212 | + if ('wpi_invoice' === $typenow) { |
|
213 | + if (!isset($vars['post_status'])) { |
|
214 | 214 | $post_statuses = wpinv_get_invoice_statuses(); |
215 | 215 | |
216 | - foreach ( $post_statuses as $status => $value ) { |
|
217 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
218 | - unset( $post_statuses[ $status ] ); |
|
216 | + foreach ($post_statuses as $status => $value) { |
|
217 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
218 | + unset($post_statuses[$status]); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
222 | + $vars['post_status'] = array_keys($post_statuses); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( isset( $vars['orderby'] ) ) { |
|
226 | - if ( 'amount' == $vars['orderby'] ) { |
|
225 | + if (isset($vars['orderby'])) { |
|
226 | + if ('amount' == $vars['orderby']) { |
|
227 | 227 | $vars = array_merge( |
228 | 228 | $vars, |
229 | 229 | array( |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | 'orderby' => 'meta_value_num' |
232 | 232 | ) |
233 | 233 | ); |
234 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
234 | + } else if ('customer' == $vars['orderby']) { |
|
235 | 235 | $vars = array_merge( |
236 | 236 | $vars, |
237 | 237 | array( |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | ); |
242 | 242 | } |
243 | 243 | } |
244 | - } else if ( 'wpi_item' == $typenow ) { |
|
244 | + } else if ('wpi_item' == $typenow) { |
|
245 | 245 | // Check if 'orderby' is set to "price" |
246 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
246 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
247 | 247 | $vars = array_merge( |
248 | 248 | $vars, |
249 | 249 | array( |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // Check if "orderby" is set to "vat_rule" |
257 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
257 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
258 | 258 | $vars = array_merge( |
259 | 259 | $vars, |
260 | 260 | array( |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | // Check if "orderby" is set to "vat_class" |
268 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
268 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
269 | 269 | $vars = array_merge( |
270 | 270 | $vars, |
271 | 271 | array( |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | // Check if "orderby" is set to "type" |
279 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
279 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
280 | 280 | $vars = array_merge( |
281 | 281 | $vars, |
282 | 282 | array( |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | // Check if "orderby" is set to "recurring" |
290 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
290 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
291 | 291 | $vars = array_merge( |
292 | 292 | $vars, |
293 | 293 | array( |
@@ -297,120 +297,120 @@ discard block |
||
297 | 297 | ); |
298 | 298 | } |
299 | 299 | |
300 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
300 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
301 | 301 | // Filter vat rule type |
302 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
302 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
303 | 303 | $meta_query[] = array( |
304 | 304 | 'key' => '_wpinv_vat_rule', |
305 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
305 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
306 | 306 | 'compare' => '=' |
307 | 307 | ); |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Filter vat class |
311 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
311 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
312 | 312 | $meta_query[] = array( |
313 | 313 | 'key' => '_wpinv_vat_class', |
314 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
314 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
315 | 315 | 'compare' => '=' |
316 | 316 | ); |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Filter item type |
320 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
320 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
321 | 321 | $meta_query[] = array( |
322 | 322 | 'key' => '_wpinv_type', |
323 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
323 | + 'value' => sanitize_text_field($_GET['type']), |
|
324 | 324 | 'compare' => '=' |
325 | 325 | ); |
326 | 326 | } |
327 | 327 | |
328 | - if ( !empty( $meta_query ) ) { |
|
328 | + if (!empty($meta_query)) { |
|
329 | 329 | $vars['meta_query'] = $meta_query; |
330 | 330 | } |
331 | - } else if ( 'wpi_discount' == $typenow ) { |
|
332 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
331 | + } else if ('wpi_discount' == $typenow) { |
|
332 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
333 | 333 | // Filter vat rule type |
334 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
334 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
335 | 335 | $meta_query[] = array( |
336 | 336 | 'key' => '_wpi_discount_type', |
337 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
337 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
338 | 338 | 'compare' => '=' |
339 | 339 | ); |
340 | 340 | } |
341 | 341 | |
342 | - if ( !empty( $meta_query ) ) { |
|
342 | + if (!empty($meta_query)) { |
|
343 | 343 | $vars['meta_query'] = $meta_query; |
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | return $vars; |
348 | 348 | } |
349 | -add_filter( 'request', 'wpinv_request' ); |
|
349 | +add_filter('request', 'wpinv_request'); |
|
350 | 350 | |
351 | 351 | function wpinv_options_page() { |
352 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
352 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
353 | 353 | |
354 | - if ( $page !== 'wpinv-settings' ) { |
|
354 | + if ($page !== 'wpinv-settings') { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | 358 | $settings_tabs = wpinv_get_settings_tabs(); |
359 | 359 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
360 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
361 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
360 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
361 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
362 | 362 | $key = 'main'; |
363 | 363 | |
364 | - if ( is_array( $sections ) ) { |
|
365 | - $key = key( $sections ); |
|
364 | + if (is_array($sections)) { |
|
365 | + $key = key($sections); |
|
366 | 366 | } |
367 | 367 | |
368 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
369 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
368 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
369 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
370 | 370 | ob_start(); |
371 | 371 | ?> |
372 | 372 | <div class="wrap"> |
373 | 373 | <h1 class="nav-tab-wrapper"> |
374 | 374 | <?php |
375 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
376 | - $tab_url = add_query_arg( array( |
|
375 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
376 | + $tab_url = add_query_arg(array( |
|
377 | 377 | 'settings-updated' => false, |
378 | 378 | 'tab' => $tab_id, |
379 | - ) ); |
|
379 | + )); |
|
380 | 380 | |
381 | 381 | // Remove the section from the tabs so we always end up at the main section |
382 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
383 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
382 | + $tab_url = remove_query_arg('section', $tab_url); |
|
383 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
384 | 384 | |
385 | 385 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
386 | 386 | |
387 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
388 | - echo esc_html( $tab_name ); |
|
387 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
388 | + echo esc_html($tab_name); |
|
389 | 389 | echo '</a>'; |
390 | 390 | } |
391 | 391 | ?> |
392 | 392 | </h1> |
393 | 393 | <?php |
394 | - $number_of_sections = count( $sections ); |
|
394 | + $number_of_sections = count($sections); |
|
395 | 395 | $number = 0; |
396 | - if ( $number_of_sections > 1 ) { |
|
396 | + if ($number_of_sections > 1) { |
|
397 | 397 | echo '<div><ul class="subsubsub">'; |
398 | - foreach( $sections as $section_id => $section_name ) { |
|
398 | + foreach ($sections as $section_id => $section_name) { |
|
399 | 399 | echo '<li>'; |
400 | 400 | $number++; |
401 | - $tab_url = add_query_arg( array( |
|
401 | + $tab_url = add_query_arg(array( |
|
402 | 402 | 'settings-updated' => false, |
403 | 403 | 'tab' => $active_tab, |
404 | 404 | 'section' => $section_id |
405 | - ) ); |
|
406 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
405 | + )); |
|
406 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
407 | 407 | $class = ''; |
408 | - if ( $section == $section_id ) { |
|
408 | + if ($section == $section_id) { |
|
409 | 409 | $class = 'current'; |
410 | 410 | } |
411 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
411 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
412 | 412 | |
413 | - if ( $number != $number_of_sections ) { |
|
413 | + if ($number != $number_of_sections) { |
|
414 | 414 | echo ' | '; |
415 | 415 | } |
416 | 416 | echo '</li>'; |
@@ -422,19 +422,19 @@ discard block |
||
422 | 422 | <form method="post" action="options.php"> |
423 | 423 | <table class="form-table"> |
424 | 424 | <?php |
425 | - settings_fields( 'wpinv_settings' ); |
|
425 | + settings_fields('wpinv_settings'); |
|
426 | 426 | |
427 | - if ( 'main' === $section ) { |
|
428 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
427 | + if ('main' === $section) { |
|
428 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
429 | 429 | } |
430 | 430 | |
431 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section ); |
|
432 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section ); |
|
433 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section ); |
|
431 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section); |
|
432 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section); |
|
433 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section); |
|
434 | 434 | |
435 | 435 | // For backwards compatibility |
436 | - if ( 'main' === $section ) { |
|
437 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
436 | + if ('main' === $section) { |
|
437 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
438 | 438 | } |
439 | 439 | ?> |
440 | 440 | </table> |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | echo $content; |
448 | 448 | } |
449 | 449 | |
450 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
450 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
451 | 451 | global $pagenow, $typenow; |
452 | 452 | |
453 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
454 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
453 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && $type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
454 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
455 | 455 | } |
456 | 456 | return $classes; |
457 | 457 | } |
458 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
459 | 458 | \ No newline at end of file |
459 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
460 | 460 | \ No newline at end of file |