@@ -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,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | add_action( 'wpinv_manual_cc_form', '__return_false' ); |
6 | 8 |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | add_action( 'wpinv_bank_transfer_cc_form', '__return_false' ); |
6 | 8 |
@@ -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, 'wpi-pending' ); |
|
29 | + if (!empty($invoice)) { |
|
30 | + wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key()); |
|
31 | + wpinv_update_payment_status($invoice, 'wpi-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 == 'wpi-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 == 'wpi-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 == 'wpi-pending' ) { |
|
67 | +function wpinv_invoice_print_bank_info($invoice) { |
|
68 | + if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'wpi-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,6 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | add_action( 'wpinv_paypal_cc_form', '__return_false' ); |
6 | 8 | add_filter( 'wpinv_paypal_support_subscription', '__return_true' ); |
@@ -307,8 +309,9 @@ discard block |
||
307 | 309 | } |
308 | 310 | |
309 | 311 | // Check if $post_data_array has been populated |
310 | - if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
311 | - return; |
|
312 | + if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) { |
|
313 | + return; |
|
314 | + } |
|
312 | 315 | |
313 | 316 | $defaults = array( |
314 | 317 | 'txn_type' => '', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'notify_url' => $listener_url, |
66 | 66 | 'cbt' => get_bloginfo( 'name' ), |
67 | 67 | 'bn' => 'WPInvoicing_SP', |
68 | - 'lc' => 'US' // this will force paypal site to english |
|
68 | + 'lc' => 'US' // this will force paypal site to english |
|
69 | 69 | ); |
70 | 70 | |
71 | 71 | $paypal_args['address1'] = $invoice->get_address(); |
@@ -217,261 +217,261 @@ discard block |
||
217 | 217 | add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 ); |
218 | 218 | |
219 | 219 | function wpinv_process_paypal_ipn() { |
220 | - // Check the request method is POST |
|
221 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
222 | - return; |
|
223 | - } |
|
224 | - |
|
225 | - // Set initial post data to empty string |
|
226 | - $post_data = ''; |
|
227 | - |
|
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' ); |
|
231 | - } else { |
|
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' ); |
|
234 | - } |
|
235 | - // Start the encoded data collection with notification command |
|
236 | - $encoded_data = 'cmd=_notify-validate'; |
|
237 | - |
|
238 | - // Get current arg separator |
|
239 | - $arg_separator = wpinv_get_php_arg_separator_output(); |
|
240 | - |
|
241 | - // Verify there is a post_data |
|
242 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
243 | - // Append the data |
|
244 | - $encoded_data .= $arg_separator.$post_data; |
|
245 | - } else { |
|
246 | - // Check if POST is empty |
|
247 | - if ( empty( $_POST ) ) { |
|
248 | - // Nothing to do |
|
249 | - return; |
|
250 | - } else { |
|
251 | - // Loop through each POST |
|
252 | - foreach ( $_POST as $key => $value ) { |
|
253 | - // Encode the value and append the data |
|
254 | - $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
255 | - } |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - // Convert collected post data to an array |
|
260 | - parse_str( $encoded_data, $encoded_data_array ); |
|
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 ); |
|
266 | - |
|
267 | - unset( $encoded_data_array[ $key ] ); |
|
268 | - $encoded_data_array[ $new_key ] = $value; |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - // Get the PayPal redirect uri |
|
273 | - $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
274 | - |
|
275 | - if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
276 | - // Validate the IPN |
|
277 | - |
|
278 | - $remote_post_vars = array( |
|
279 | - 'method' => 'POST', |
|
280 | - 'timeout' => 45, |
|
281 | - 'redirection' => 5, |
|
282 | - 'httpversion' => '1.1', |
|
283 | - 'blocking' => true, |
|
284 | - 'headers' => array( |
|
285 | - 'host' => 'www.paypal.com', |
|
286 | - 'connection' => 'close', |
|
287 | - 'content-type' => 'application/x-www-form-urlencoded', |
|
288 | - 'post' => '/cgi-bin/webscr HTTP/1.1', |
|
289 | - |
|
290 | - ), |
|
291 | - 'sslverify' => false, |
|
292 | - 'body' => $encoded_data_array |
|
293 | - ); |
|
294 | - |
|
295 | - // Get response |
|
296 | - $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
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 ) ) ); |
|
300 | - return; // Something went wrong |
|
301 | - } |
|
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 ) ) ); |
|
305 | - return; // Response not okay |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - // Check if $post_data_array has been populated |
|
310 | - if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
311 | - return; |
|
312 | - |
|
313 | - $defaults = array( |
|
314 | - 'txn_type' => '', |
|
315 | - 'payment_status' => '' |
|
316 | - ); |
|
317 | - |
|
318 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
319 | - |
|
320 | - $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
220 | + // Check the request method is POST |
|
221 | + if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
222 | + return; |
|
223 | + } |
|
224 | + |
|
225 | + // Set initial post data to empty string |
|
226 | + $post_data = ''; |
|
227 | + |
|
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' ); |
|
231 | + } else { |
|
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' ); |
|
234 | + } |
|
235 | + // Start the encoded data collection with notification command |
|
236 | + $encoded_data = 'cmd=_notify-validate'; |
|
237 | + |
|
238 | + // Get current arg separator |
|
239 | + $arg_separator = wpinv_get_php_arg_separator_output(); |
|
240 | + |
|
241 | + // Verify there is a post_data |
|
242 | + if ( $post_data || strlen( $post_data ) > 0 ) { |
|
243 | + // Append the data |
|
244 | + $encoded_data .= $arg_separator.$post_data; |
|
245 | + } else { |
|
246 | + // Check if POST is empty |
|
247 | + if ( empty( $_POST ) ) { |
|
248 | + // Nothing to do |
|
249 | + return; |
|
250 | + } else { |
|
251 | + // Loop through each POST |
|
252 | + foreach ( $_POST as $key => $value ) { |
|
253 | + // Encode the value and append the data |
|
254 | + $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
255 | + } |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + // Convert collected post data to an array |
|
260 | + parse_str( $encoded_data, $encoded_data_array ); |
|
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 ); |
|
266 | + |
|
267 | + unset( $encoded_data_array[ $key ] ); |
|
268 | + $encoded_data_array[ $new_key ] = $value; |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + // Get the PayPal redirect uri |
|
273 | + $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
274 | + |
|
275 | + if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
276 | + // Validate the IPN |
|
277 | + |
|
278 | + $remote_post_vars = array( |
|
279 | + 'method' => 'POST', |
|
280 | + 'timeout' => 45, |
|
281 | + 'redirection' => 5, |
|
282 | + 'httpversion' => '1.1', |
|
283 | + 'blocking' => true, |
|
284 | + 'headers' => array( |
|
285 | + 'host' => 'www.paypal.com', |
|
286 | + 'connection' => 'close', |
|
287 | + 'content-type' => 'application/x-www-form-urlencoded', |
|
288 | + 'post' => '/cgi-bin/webscr HTTP/1.1', |
|
289 | + |
|
290 | + ), |
|
291 | + 'sslverify' => false, |
|
292 | + 'body' => $encoded_data_array |
|
293 | + ); |
|
294 | + |
|
295 | + // Get response |
|
296 | + $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
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 ) ) ); |
|
300 | + return; // Something went wrong |
|
301 | + } |
|
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 ) ) ); |
|
305 | + return; // Response not okay |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + // Check if $post_data_array has been populated |
|
310 | + if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
311 | + return; |
|
312 | + |
|
313 | + $defaults = array( |
|
314 | + 'txn_type' => '', |
|
315 | + 'payment_status' => '' |
|
316 | + ); |
|
317 | + |
|
318 | + $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
319 | + |
|
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__ ); |
|
323 | - |
|
324 | - if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
325 | - // Allow PayPal IPN types to be processed separately |
|
326 | - do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
327 | - } else { |
|
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 ); |
|
330 | - } |
|
331 | - exit; |
|
322 | + wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ ); |
|
323 | + |
|
324 | + if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
325 | + // Allow PayPal IPN types to be processed separately |
|
326 | + do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
327 | + } else { |
|
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 ); |
|
330 | + } |
|
331 | + exit; |
|
332 | 332 | } |
333 | 333 | add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' ); |
334 | 334 | |
335 | 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 | - return; |
|
338 | - } |
|
339 | - |
|
340 | - if( empty( $invoice_id ) ) { |
|
341 | - return; |
|
342 | - } |
|
343 | - |
|
344 | - // Collect payment details |
|
345 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
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 ); |
|
351 | - |
|
352 | - if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
353 | - return; // this isn't a PayPal standard IPN |
|
354 | - } |
|
355 | - |
|
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, 'wpi-failed' ); |
|
360 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
361 | - return; |
|
362 | - } |
|
363 | - |
|
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, 'wpi-failed' ); |
|
368 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
369 | - return; |
|
370 | - } |
|
371 | - |
|
372 | - if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
373 | - // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
|
374 | - // No email associated with purchase, so store from PayPal |
|
375 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
376 | - |
|
377 | - // Setup and store the customer's details |
|
378 | - $user_info = array( |
|
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'] ), |
|
383 | - 'discount' => '', |
|
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; |
|
390 | - |
|
391 | - $payment_meta['user_info'] = $user_info; |
|
392 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
393 | - } |
|
394 | - |
|
395 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
396 | - // Process a refund |
|
397 | - wpinv_process_paypal_refund( $data, $invoice_id ); |
|
398 | - } else { |
|
399 | - if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
400 | - return; // Only paid payments once |
|
401 | - } |
|
402 | - |
|
403 | - // Retrieve the total purchase amount (before PayPal) |
|
404 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
405 | - |
|
406 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
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, 'wpi-failed' ); |
|
410 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
411 | - return; |
|
412 | - } |
|
413 | - if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
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, 'wpi-failed' ); |
|
417 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
418 | - return; |
|
419 | - } |
|
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 ( 'wpi-pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
426 | - // Look for possible pending reasons, such as an echeck |
|
427 | - $note = ''; |
|
428 | - |
|
429 | - switch( strtolower( $data['pending_reason'] ) ) { |
|
430 | - case 'echeck' : |
|
431 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
432 | - break; |
|
336 | + if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
337 | + return; |
|
338 | + } |
|
339 | + |
|
340 | + if( empty( $invoice_id ) ) { |
|
341 | + return; |
|
342 | + } |
|
343 | + |
|
344 | + // Collect payment details |
|
345 | + $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
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 ); |
|
351 | + |
|
352 | + if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
353 | + return; // this isn't a PayPal standard IPN |
|
354 | + } |
|
355 | + |
|
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, 'wpi-failed' ); |
|
360 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
361 | + return; |
|
362 | + } |
|
363 | + |
|
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, 'wpi-failed' ); |
|
368 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
369 | + return; |
|
370 | + } |
|
371 | + |
|
372 | + if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
373 | + // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
|
374 | + // No email associated with purchase, so store from PayPal |
|
375 | + wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
376 | + |
|
377 | + // Setup and store the customer's details |
|
378 | + $user_info = array( |
|
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'] ), |
|
383 | + 'discount' => '', |
|
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; |
|
390 | + |
|
391 | + $payment_meta['user_info'] = $user_info; |
|
392 | + wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
393 | + } |
|
394 | + |
|
395 | + if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
396 | + // Process a refund |
|
397 | + wpinv_process_paypal_refund( $data, $invoice_id ); |
|
398 | + } else { |
|
399 | + if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
400 | + return; // Only paid payments once |
|
401 | + } |
|
402 | + |
|
403 | + // Retrieve the total purchase amount (before PayPal) |
|
404 | + $payment_amount = wpinv_payment_total( $invoice_id ); |
|
405 | + |
|
406 | + if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
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, 'wpi-failed' ); |
|
410 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
411 | + return; |
|
412 | + } |
|
413 | + if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
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, 'wpi-failed' ); |
|
417 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
418 | + return; |
|
419 | + } |
|
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 ( 'wpi-pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
426 | + // Look for possible pending reasons, such as an echeck |
|
427 | + $note = ''; |
|
428 | + |
|
429 | + switch( strtolower( $data['pending_reason'] ) ) { |
|
430 | + case 'echeck' : |
|
431 | + $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
432 | + break; |
|
433 | 433 | |
434 | 434 | case 'address' : |
435 | - $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
436 | - break; |
|
435 | + $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
436 | + break; |
|
437 | 437 | |
438 | 438 | case 'intl' : |
439 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
440 | - break; |
|
439 | + $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
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' ); |
|
444 | - break; |
|
443 | + $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' ); |
|
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' ); |
|
449 | - break; |
|
448 | + $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' ); |
|
449 | + break; |
|
450 | 450 | |
451 | 451 | case 'unilateral' : |
452 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
453 | - break; |
|
452 | + $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
453 | + break; |
|
454 | 454 | |
455 | 455 | case 'upgrade' : |
456 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
457 | - break; |
|
456 | + $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
457 | + break; |
|
458 | 458 | |
459 | 459 | case 'verify' : |
460 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
461 | - break; |
|
462 | - |
|
463 | - case 'other' : |
|
464 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
465 | - break; |
|
466 | - } |
|
467 | - |
|
468 | - if ( ! empty( $note ) ) { |
|
469 | - wpinv_insert_payment_note( $invoice_id, $note ); |
|
470 | - } |
|
471 | - } else { |
|
472 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
473 | - } |
|
474 | - } |
|
460 | + $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
461 | + break; |
|
462 | + |
|
463 | + case 'other' : |
|
464 | + $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
465 | + break; |
|
466 | + } |
|
467 | + |
|
468 | + if ( ! empty( $note ) ) { |
|
469 | + wpinv_insert_payment_note( $invoice_id, $note ); |
|
470 | + } |
|
471 | + } else { |
|
472 | + wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
473 | + } |
|
474 | + } |
|
475 | 475 | } |
476 | 476 | add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 ); |
477 | 477 | |
@@ -686,27 +686,27 @@ discard block |
||
686 | 686 | } |
687 | 687 | |
688 | 688 | function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) { |
689 | - // Collect payment details |
|
689 | + // Collect payment details |
|
690 | 690 | |
691 | - if( empty( $invoice_id ) ) { |
|
692 | - return; |
|
693 | - } |
|
691 | + if( empty( $invoice_id ) ) { |
|
692 | + return; |
|
693 | + } |
|
694 | 694 | |
695 | - if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) { |
|
696 | - return; // Only refund payments once |
|
697 | - } |
|
695 | + if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) { |
|
696 | + return; // Only refund payments once |
|
697 | + } |
|
698 | 698 | |
699 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
700 | - $refund_amount = $data['mc_gross'] * -1; |
|
699 | + $payment_amount = wpinv_payment_total( $invoice_id ); |
|
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'] ) ); |
|
704 | - return; // This is a partial refund |
|
705 | - } |
|
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 | + return; // This is a partial refund |
|
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, 'wpi-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, 'wpi-refunded' ); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | function wpinv_get_paypal_redirect( $ssl_check = false ) { |
@@ -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 |
@@ -25,30 +25,30 @@ discard block |
||
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 = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 ); |
|
89 | + $item_amount = wpinv_sanitize_amount($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 ] = wpinv_sanitize_amount( $item['discount'], 2 ); |
|
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] = wpinv_sanitize_amount($item['discount'], 2); |
|
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(), 2 ); |
|
106 | + if (wpinv_use_taxes()) { |
|
107 | + $paypal_args['tax_cart'] = wpinv_sanitize_amount((float)$invoice->get_tax(), 2); |
|
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_sanitize_amount( $invoice->get_total(), 2 ); |
|
141 | - $recurring_amount = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 ); |
|
140 | + $initial_amount = wpinv_sanitize_amount($invoice->get_total(), 2); |
|
141 | + $recurring_amount = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2); |
|
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, 'wpi-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, 'wpi-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, 'wpi-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, 'wpi-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, 'wpi-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, 'wpi-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, 'wpi-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, 'wpi-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 ( 'wpi-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 ('wpi-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 ) == 'wpi-refunded' ) { |
|
695 | + if (get_post_status($invoice_id) == 'wpi-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, 'wpi-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, 'wpi-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 ) && 'wpi-pending' == $wpi_invoice->status ) { |
|
748 | + if (!empty($wpi_invoice) && 'wpi-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 |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_is_base_country( $country ) { |
@@ -40,9 +40,9 @@ discard block |
||
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 | 48 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -115,260 +115,260 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | function wpinv_get_country_list( $first_empty = false ) { |
118 | - $countries = array( |
|
119 | - 'US' => __('United States', 'invoicing'), |
|
120 | - 'CA' => __('Canada', 'invoicing'), |
|
121 | - 'GB' => __('United Kingdom', 'invoicing'), |
|
122 | - 'AF' => __('Afghanistan', 'invoicing'), |
|
123 | - 'AX' => __('Aland Islands', 'invoicing'), |
|
124 | - 'AL' => __('Albania', 'invoicing'), |
|
125 | - 'DZ' => __('Algeria', 'invoicing'), |
|
126 | - 'AS' => __('American Samoa', 'invoicing'), |
|
127 | - 'AD' => __('Andorra', 'invoicing'), |
|
128 | - 'AO' => __('Angola', 'invoicing'), |
|
129 | - 'AI' => __('Anguilla', 'invoicing'), |
|
130 | - 'AQ' => __('Antarctica', 'invoicing'), |
|
131 | - 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
132 | - 'AR' => __('Argentina', 'invoicing'), |
|
133 | - 'AM' => __('Armenia', 'invoicing'), |
|
134 | - 'AW' => __('Aruba', 'invoicing'), |
|
135 | - 'AU' => __('Australia', 'invoicing'), |
|
136 | - 'AT' => __('Austria', 'invoicing'), |
|
137 | - 'AZ' => __('Azerbaijan', 'invoicing'), |
|
138 | - 'BS' => __('Bahamas', 'invoicing'), |
|
139 | - 'BH' => __('Bahrain', 'invoicing'), |
|
140 | - 'BD' => __('Bangladesh', 'invoicing'), |
|
141 | - 'BB' => __('Barbados', 'invoicing'), |
|
142 | - 'BY' => __('Belarus', 'invoicing'), |
|
143 | - 'BE' => __('Belgium', 'invoicing'), |
|
144 | - 'BZ' => __('Belize', 'invoicing'), |
|
145 | - 'BJ' => __('Benin', 'invoicing'), |
|
146 | - 'BM' => __('Bermuda', 'invoicing'), |
|
147 | - 'BT' => __('Bhutan', 'invoicing'), |
|
148 | - 'BO' => __('Bolivia', 'invoicing'), |
|
149 | - 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
150 | - 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
151 | - 'BW' => __('Botswana', 'invoicing'), |
|
152 | - 'BV' => __('Bouvet Island', 'invoicing'), |
|
153 | - 'BR' => __('Brazil', 'invoicing'), |
|
154 | - 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
155 | - 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
156 | - 'BG' => __('Bulgaria', 'invoicing'), |
|
157 | - 'BF' => __('Burkina Faso', 'invoicing'), |
|
158 | - 'BI' => __('Burundi', 'invoicing'), |
|
159 | - 'KH' => __('Cambodia', 'invoicing'), |
|
160 | - 'CM' => __('Cameroon', 'invoicing'), |
|
161 | - 'CV' => __('Cape Verde', 'invoicing'), |
|
162 | - 'KY' => __('Cayman Islands', 'invoicing'), |
|
163 | - 'CF' => __('Central African Republic', 'invoicing'), |
|
164 | - 'TD' => __('Chad', 'invoicing'), |
|
165 | - 'CL' => __('Chile', 'invoicing'), |
|
166 | - 'CN' => __('China', 'invoicing'), |
|
167 | - 'CX' => __('Christmas Island', 'invoicing'), |
|
168 | - 'CC' => __('Cocos Islands', 'invoicing'), |
|
169 | - 'CO' => __('Colombia', 'invoicing'), |
|
170 | - 'KM' => __('Comoros', 'invoicing'), |
|
171 | - 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
172 | - 'CG' => __('Congo, Republic of', 'invoicing'), |
|
173 | - 'CK' => __('Cook Islands', 'invoicing'), |
|
174 | - 'CR' => __('Costa Rica', 'invoicing'), |
|
175 | - 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
176 | - 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
177 | - 'CU' => __('Cuba', 'invoicing'), |
|
178 | - 'CW' => __('CuraÇao', 'invoicing'), |
|
179 | - 'CY' => __('Cyprus', 'invoicing'), |
|
180 | - 'CZ' => __('Czech Republic', 'invoicing'), |
|
181 | - 'DK' => __('Denmark', 'invoicing'), |
|
182 | - 'DJ' => __('Djibouti', 'invoicing'), |
|
183 | - 'DM' => __('Dominica', 'invoicing'), |
|
184 | - 'DO' => __('Dominican Republic', 'invoicing'), |
|
185 | - 'TP' => __('East Timor', 'invoicing'), |
|
186 | - 'EC' => __('Ecuador', 'invoicing'), |
|
187 | - 'EG' => __('Egypt', 'invoicing'), |
|
188 | - 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
189 | - 'SV' => __('El Salvador', 'invoicing'), |
|
190 | - 'ER' => __('Eritrea', 'invoicing'), |
|
191 | - 'EE' => __('Estonia', 'invoicing'), |
|
192 | - 'ET' => __('Ethiopia', 'invoicing'), |
|
193 | - 'FK' => __('Falkland Islands', 'invoicing'), |
|
194 | - 'FO' => __('Faroe Islands', 'invoicing'), |
|
195 | - 'FJ' => __('Fiji', 'invoicing'), |
|
196 | - 'FI' => __('Finland', 'invoicing'), |
|
197 | - 'FR' => __('France', 'invoicing'), |
|
198 | - 'GF' => __('French Guiana', 'invoicing'), |
|
199 | - 'PF' => __('French Polynesia', 'invoicing'), |
|
200 | - 'TF' => __('French Southern Territories', 'invoicing'), |
|
201 | - 'GA' => __('Gabon', 'invoicing'), |
|
202 | - 'GM' => __('Gambia', 'invoicing'), |
|
203 | - 'GE' => __('Georgia', 'invoicing'), |
|
204 | - 'DE' => __('Germany', 'invoicing'), |
|
205 | - 'GR' => __('Greece', 'invoicing'), |
|
206 | - 'GH' => __('Ghana', 'invoicing'), |
|
207 | - 'GI' => __('Gibraltar', 'invoicing'), |
|
208 | - 'GL' => __('Greenland', 'invoicing'), |
|
209 | - 'GD' => __('Grenada', 'invoicing'), |
|
210 | - 'GP' => __('Guadeloupe', 'invoicing'), |
|
211 | - 'GU' => __('Guam', 'invoicing'), |
|
212 | - 'GT' => __('Guatemala', 'invoicing'), |
|
213 | - 'GG' => __('Guernsey', 'invoicing'), |
|
214 | - 'GN' => __('Guinea', 'invoicing'), |
|
215 | - 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
216 | - 'GY' => __('Guyana', 'invoicing'), |
|
217 | - 'HT' => __('Haiti', 'invoicing'), |
|
218 | - 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
219 | - 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
220 | - 'HN' => __('Honduras', 'invoicing'), |
|
221 | - 'HK' => __('Hong Kong', 'invoicing'), |
|
222 | - 'HU' => __('Hungary', 'invoicing'), |
|
223 | - 'IS' => __('Iceland', 'invoicing'), |
|
224 | - 'IN' => __('India', 'invoicing'), |
|
225 | - 'ID' => __('Indonesia', 'invoicing'), |
|
226 | - 'IR' => __('Iran', 'invoicing'), |
|
227 | - 'IQ' => __('Iraq', 'invoicing'), |
|
228 | - 'IE' => __('Ireland', 'invoicing'), |
|
229 | - 'IM' => __('Isle of Man', 'invoicing'), |
|
230 | - 'IL' => __('Israel', 'invoicing'), |
|
231 | - 'IT' => __('Italy', 'invoicing'), |
|
232 | - 'JM' => __('Jamaica', 'invoicing'), |
|
233 | - 'JP' => __('Japan', 'invoicing'), |
|
234 | - 'JE' => __('Jersey', 'invoicing'), |
|
235 | - 'JO' => __('Jordan', 'invoicing'), |
|
236 | - 'KZ' => __('Kazakhstan', 'invoicing'), |
|
237 | - 'KE' => __('Kenya', 'invoicing'), |
|
238 | - 'KI' => __('Kiribati', 'invoicing'), |
|
239 | - 'KW' => __('Kuwait', 'invoicing'), |
|
240 | - 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
241 | - 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
242 | - 'LV' => __('Latvia', 'invoicing'), |
|
243 | - 'LB' => __('Lebanon', 'invoicing'), |
|
244 | - 'LS' => __('Lesotho', 'invoicing'), |
|
245 | - 'LR' => __('Liberia', 'invoicing'), |
|
246 | - 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
247 | - 'LI' => __('Liechtenstein', 'invoicing'), |
|
248 | - 'LT' => __('Lithuania', 'invoicing'), |
|
249 | - 'LU' => __('Luxembourg', 'invoicing'), |
|
250 | - 'MO' => __('Macau', 'invoicing'), |
|
251 | - 'MK' => __('Macedonia', 'invoicing'), |
|
252 | - 'MG' => __('Madagascar', 'invoicing'), |
|
253 | - 'MW' => __('Malawi', 'invoicing'), |
|
254 | - 'MY' => __('Malaysia', 'invoicing'), |
|
255 | - 'MV' => __('Maldives', 'invoicing'), |
|
256 | - 'ML' => __('Mali', 'invoicing'), |
|
257 | - 'MT' => __('Malta', 'invoicing'), |
|
258 | - 'MH' => __('Marshall Islands', 'invoicing'), |
|
259 | - 'MQ' => __('Martinique', 'invoicing'), |
|
260 | - 'MR' => __('Mauritania', 'invoicing'), |
|
261 | - 'MU' => __('Mauritius', 'invoicing'), |
|
262 | - 'YT' => __('Mayotte', 'invoicing'), |
|
263 | - 'MX' => __('Mexico', 'invoicing'), |
|
264 | - 'FM' => __('Micronesia', 'invoicing'), |
|
265 | - 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
266 | - 'MC' => __('Monaco', 'invoicing'), |
|
267 | - 'MN' => __('Mongolia', 'invoicing'), |
|
268 | - 'ME' => __('Montenegro', 'invoicing'), |
|
269 | - 'MS' => __('Montserrat', 'invoicing'), |
|
270 | - 'MA' => __('Morocco', 'invoicing'), |
|
271 | - 'MZ' => __('Mozambique', 'invoicing'), |
|
272 | - 'MM' => __('Myanmar', 'invoicing'), |
|
273 | - 'NA' => __('Namibia', 'invoicing'), |
|
274 | - 'NR' => __('Nauru', 'invoicing'), |
|
275 | - 'NP' => __('Nepal', 'invoicing'), |
|
276 | - 'NL' => __('Netherlands', 'invoicing'), |
|
277 | - 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
278 | - 'NC' => __('New Caledonia', 'invoicing'), |
|
279 | - 'NZ' => __('New Zealand', 'invoicing'), |
|
280 | - 'NI' => __('Nicaragua', 'invoicing'), |
|
281 | - 'NE' => __('Niger', 'invoicing'), |
|
282 | - 'NG' => __('Nigeria', 'invoicing'), |
|
283 | - 'NU' => __('Niue', 'invoicing'), |
|
284 | - 'NF' => __('Norfolk Island', 'invoicing'), |
|
285 | - 'KP' => __('North Korea', 'invoicing'), |
|
286 | - 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
287 | - 'NO' => __('Norway', 'invoicing'), |
|
288 | - 'OM' => __('Oman', 'invoicing'), |
|
289 | - 'PK' => __('Pakistan', 'invoicing'), |
|
290 | - 'PW' => __('Palau', 'invoicing'), |
|
291 | - 'PS' => __('Palestinian Territories', 'invoicing'), |
|
292 | - 'PA' => __('Panama', 'invoicing'), |
|
293 | - 'PG' => __('Papua New Guinea', 'invoicing'), |
|
294 | - 'PY' => __('Paraguay', 'invoicing'), |
|
295 | - 'PE' => __('Peru', 'invoicing'), |
|
296 | - 'PH' => __('Phillipines', 'invoicing'), |
|
297 | - 'PN' => __('Pitcairn Island', 'invoicing'), |
|
298 | - 'PL' => __('Poland', 'invoicing'), |
|
299 | - 'PT' => __('Portugal', 'invoicing'), |
|
300 | - 'PR' => __('Puerto Rico', 'invoicing'), |
|
301 | - 'QA' => __('Qatar', 'invoicing'), |
|
302 | - 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
303 | - 'RE' => __('Reunion Island', 'invoicing'), |
|
304 | - 'RO' => __('Romania', 'invoicing'), |
|
305 | - 'RU' => __('Russian Federation', 'invoicing'), |
|
306 | - 'RW' => __('Rwanda', 'invoicing'), |
|
307 | - 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
308 | - 'SH' => __('Saint Helena', 'invoicing'), |
|
309 | - 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
310 | - 'LC' => __('Saint Lucia', 'invoicing'), |
|
311 | - 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
312 | - 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
313 | - 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
314 | - 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
315 | - 'SM' => __('San Marino', 'invoicing'), |
|
316 | - 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
317 | - 'SA' => __('Saudi Arabia', 'invoicing'), |
|
318 | - 'SN' => __('Senegal', 'invoicing'), |
|
319 | - 'RS' => __('Serbia', 'invoicing'), |
|
320 | - 'SC' => __('Seychelles', 'invoicing'), |
|
321 | - 'SL' => __('Sierra Leone', 'invoicing'), |
|
322 | - 'SG' => __('Singapore', 'invoicing'), |
|
323 | - 'SK' => __('Slovak Republic', 'invoicing'), |
|
324 | - 'SI' => __('Slovenia', 'invoicing'), |
|
325 | - 'SB' => __('Solomon Islands', 'invoicing'), |
|
326 | - 'SO' => __('Somalia', 'invoicing'), |
|
327 | - 'ZA' => __('South Africa', 'invoicing'), |
|
328 | - 'GS' => __('South Georgia', 'invoicing'), |
|
329 | - 'KR' => __('South Korea', 'invoicing'), |
|
330 | - 'SS' => __('South Sudan', 'invoicing'), |
|
331 | - 'ES' => __('Spain', 'invoicing'), |
|
332 | - 'LK' => __('Sri Lanka', 'invoicing'), |
|
333 | - 'SD' => __('Sudan', 'invoicing'), |
|
334 | - 'SR' => __('Suriname', 'invoicing'), |
|
335 | - 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
336 | - 'SZ' => __('Swaziland', 'invoicing'), |
|
337 | - 'SE' => __('Sweden', 'invoicing'), |
|
338 | - 'CH' => __('Switzerland', 'invoicing'), |
|
339 | - 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
340 | - 'TW' => __('Taiwan', 'invoicing'), |
|
341 | - 'TJ' => __('Tajikistan', 'invoicing'), |
|
342 | - 'TZ' => __('Tanzania', 'invoicing'), |
|
343 | - 'TH' => __('Thailand', 'invoicing'), |
|
344 | - 'TL' => __('Timor-Leste', 'invoicing'), |
|
345 | - 'TG' => __('Togo', 'invoicing'), |
|
346 | - 'TK' => __('Tokelau', 'invoicing'), |
|
347 | - 'TO' => __('Tonga', 'invoicing'), |
|
348 | - 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
349 | - 'TN' => __('Tunisia', 'invoicing'), |
|
350 | - 'TR' => __('Turkey', 'invoicing'), |
|
351 | - 'TM' => __('Turkmenistan', 'invoicing'), |
|
352 | - 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
353 | - 'TV' => __('Tuvalu', 'invoicing'), |
|
354 | - 'UG' => __('Uganda', 'invoicing'), |
|
355 | - 'UA' => __('Ukraine', 'invoicing'), |
|
356 | - 'AE' => __('United Arab Emirates', 'invoicing'), |
|
357 | - 'UY' => __('Uruguay', 'invoicing'), |
|
358 | - 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
359 | - 'UZ' => __('Uzbekistan', 'invoicing'), |
|
360 | - 'VU' => __('Vanuatu', 'invoicing'), |
|
361 | - 'VE' => __('Venezuela', 'invoicing'), |
|
362 | - 'VN' => __('Vietnam', 'invoicing'), |
|
363 | - 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
364 | - 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
365 | - 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
366 | - 'EH' => __('Western Sahara', 'invoicing'), |
|
367 | - 'WS' => __('Western Samoa', 'invoicing'), |
|
368 | - 'YE' => __('Yemen', 'invoicing'), |
|
369 | - 'ZM' => __('Zambia', 'invoicing'), |
|
370 | - 'ZW' => __('Zimbabwe', 'invoicing'), |
|
371 | - ); |
|
118 | + $countries = array( |
|
119 | + 'US' => __('United States', 'invoicing'), |
|
120 | + 'CA' => __('Canada', 'invoicing'), |
|
121 | + 'GB' => __('United Kingdom', 'invoicing'), |
|
122 | + 'AF' => __('Afghanistan', 'invoicing'), |
|
123 | + 'AX' => __('Aland Islands', 'invoicing'), |
|
124 | + 'AL' => __('Albania', 'invoicing'), |
|
125 | + 'DZ' => __('Algeria', 'invoicing'), |
|
126 | + 'AS' => __('American Samoa', 'invoicing'), |
|
127 | + 'AD' => __('Andorra', 'invoicing'), |
|
128 | + 'AO' => __('Angola', 'invoicing'), |
|
129 | + 'AI' => __('Anguilla', 'invoicing'), |
|
130 | + 'AQ' => __('Antarctica', 'invoicing'), |
|
131 | + 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
132 | + 'AR' => __('Argentina', 'invoicing'), |
|
133 | + 'AM' => __('Armenia', 'invoicing'), |
|
134 | + 'AW' => __('Aruba', 'invoicing'), |
|
135 | + 'AU' => __('Australia', 'invoicing'), |
|
136 | + 'AT' => __('Austria', 'invoicing'), |
|
137 | + 'AZ' => __('Azerbaijan', 'invoicing'), |
|
138 | + 'BS' => __('Bahamas', 'invoicing'), |
|
139 | + 'BH' => __('Bahrain', 'invoicing'), |
|
140 | + 'BD' => __('Bangladesh', 'invoicing'), |
|
141 | + 'BB' => __('Barbados', 'invoicing'), |
|
142 | + 'BY' => __('Belarus', 'invoicing'), |
|
143 | + 'BE' => __('Belgium', 'invoicing'), |
|
144 | + 'BZ' => __('Belize', 'invoicing'), |
|
145 | + 'BJ' => __('Benin', 'invoicing'), |
|
146 | + 'BM' => __('Bermuda', 'invoicing'), |
|
147 | + 'BT' => __('Bhutan', 'invoicing'), |
|
148 | + 'BO' => __('Bolivia', 'invoicing'), |
|
149 | + 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
150 | + 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
151 | + 'BW' => __('Botswana', 'invoicing'), |
|
152 | + 'BV' => __('Bouvet Island', 'invoicing'), |
|
153 | + 'BR' => __('Brazil', 'invoicing'), |
|
154 | + 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
155 | + 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
156 | + 'BG' => __('Bulgaria', 'invoicing'), |
|
157 | + 'BF' => __('Burkina Faso', 'invoicing'), |
|
158 | + 'BI' => __('Burundi', 'invoicing'), |
|
159 | + 'KH' => __('Cambodia', 'invoicing'), |
|
160 | + 'CM' => __('Cameroon', 'invoicing'), |
|
161 | + 'CV' => __('Cape Verde', 'invoicing'), |
|
162 | + 'KY' => __('Cayman Islands', 'invoicing'), |
|
163 | + 'CF' => __('Central African Republic', 'invoicing'), |
|
164 | + 'TD' => __('Chad', 'invoicing'), |
|
165 | + 'CL' => __('Chile', 'invoicing'), |
|
166 | + 'CN' => __('China', 'invoicing'), |
|
167 | + 'CX' => __('Christmas Island', 'invoicing'), |
|
168 | + 'CC' => __('Cocos Islands', 'invoicing'), |
|
169 | + 'CO' => __('Colombia', 'invoicing'), |
|
170 | + 'KM' => __('Comoros', 'invoicing'), |
|
171 | + 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
172 | + 'CG' => __('Congo, Republic of', 'invoicing'), |
|
173 | + 'CK' => __('Cook Islands', 'invoicing'), |
|
174 | + 'CR' => __('Costa Rica', 'invoicing'), |
|
175 | + 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
176 | + 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
177 | + 'CU' => __('Cuba', 'invoicing'), |
|
178 | + 'CW' => __('CuraÇao', 'invoicing'), |
|
179 | + 'CY' => __('Cyprus', 'invoicing'), |
|
180 | + 'CZ' => __('Czech Republic', 'invoicing'), |
|
181 | + 'DK' => __('Denmark', 'invoicing'), |
|
182 | + 'DJ' => __('Djibouti', 'invoicing'), |
|
183 | + 'DM' => __('Dominica', 'invoicing'), |
|
184 | + 'DO' => __('Dominican Republic', 'invoicing'), |
|
185 | + 'TP' => __('East Timor', 'invoicing'), |
|
186 | + 'EC' => __('Ecuador', 'invoicing'), |
|
187 | + 'EG' => __('Egypt', 'invoicing'), |
|
188 | + 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
189 | + 'SV' => __('El Salvador', 'invoicing'), |
|
190 | + 'ER' => __('Eritrea', 'invoicing'), |
|
191 | + 'EE' => __('Estonia', 'invoicing'), |
|
192 | + 'ET' => __('Ethiopia', 'invoicing'), |
|
193 | + 'FK' => __('Falkland Islands', 'invoicing'), |
|
194 | + 'FO' => __('Faroe Islands', 'invoicing'), |
|
195 | + 'FJ' => __('Fiji', 'invoicing'), |
|
196 | + 'FI' => __('Finland', 'invoicing'), |
|
197 | + 'FR' => __('France', 'invoicing'), |
|
198 | + 'GF' => __('French Guiana', 'invoicing'), |
|
199 | + 'PF' => __('French Polynesia', 'invoicing'), |
|
200 | + 'TF' => __('French Southern Territories', 'invoicing'), |
|
201 | + 'GA' => __('Gabon', 'invoicing'), |
|
202 | + 'GM' => __('Gambia', 'invoicing'), |
|
203 | + 'GE' => __('Georgia', 'invoicing'), |
|
204 | + 'DE' => __('Germany', 'invoicing'), |
|
205 | + 'GR' => __('Greece', 'invoicing'), |
|
206 | + 'GH' => __('Ghana', 'invoicing'), |
|
207 | + 'GI' => __('Gibraltar', 'invoicing'), |
|
208 | + 'GL' => __('Greenland', 'invoicing'), |
|
209 | + 'GD' => __('Grenada', 'invoicing'), |
|
210 | + 'GP' => __('Guadeloupe', 'invoicing'), |
|
211 | + 'GU' => __('Guam', 'invoicing'), |
|
212 | + 'GT' => __('Guatemala', 'invoicing'), |
|
213 | + 'GG' => __('Guernsey', 'invoicing'), |
|
214 | + 'GN' => __('Guinea', 'invoicing'), |
|
215 | + 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
216 | + 'GY' => __('Guyana', 'invoicing'), |
|
217 | + 'HT' => __('Haiti', 'invoicing'), |
|
218 | + 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
219 | + 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
220 | + 'HN' => __('Honduras', 'invoicing'), |
|
221 | + 'HK' => __('Hong Kong', 'invoicing'), |
|
222 | + 'HU' => __('Hungary', 'invoicing'), |
|
223 | + 'IS' => __('Iceland', 'invoicing'), |
|
224 | + 'IN' => __('India', 'invoicing'), |
|
225 | + 'ID' => __('Indonesia', 'invoicing'), |
|
226 | + 'IR' => __('Iran', 'invoicing'), |
|
227 | + 'IQ' => __('Iraq', 'invoicing'), |
|
228 | + 'IE' => __('Ireland', 'invoicing'), |
|
229 | + 'IM' => __('Isle of Man', 'invoicing'), |
|
230 | + 'IL' => __('Israel', 'invoicing'), |
|
231 | + 'IT' => __('Italy', 'invoicing'), |
|
232 | + 'JM' => __('Jamaica', 'invoicing'), |
|
233 | + 'JP' => __('Japan', 'invoicing'), |
|
234 | + 'JE' => __('Jersey', 'invoicing'), |
|
235 | + 'JO' => __('Jordan', 'invoicing'), |
|
236 | + 'KZ' => __('Kazakhstan', 'invoicing'), |
|
237 | + 'KE' => __('Kenya', 'invoicing'), |
|
238 | + 'KI' => __('Kiribati', 'invoicing'), |
|
239 | + 'KW' => __('Kuwait', 'invoicing'), |
|
240 | + 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
241 | + 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
242 | + 'LV' => __('Latvia', 'invoicing'), |
|
243 | + 'LB' => __('Lebanon', 'invoicing'), |
|
244 | + 'LS' => __('Lesotho', 'invoicing'), |
|
245 | + 'LR' => __('Liberia', 'invoicing'), |
|
246 | + 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
247 | + 'LI' => __('Liechtenstein', 'invoicing'), |
|
248 | + 'LT' => __('Lithuania', 'invoicing'), |
|
249 | + 'LU' => __('Luxembourg', 'invoicing'), |
|
250 | + 'MO' => __('Macau', 'invoicing'), |
|
251 | + 'MK' => __('Macedonia', 'invoicing'), |
|
252 | + 'MG' => __('Madagascar', 'invoicing'), |
|
253 | + 'MW' => __('Malawi', 'invoicing'), |
|
254 | + 'MY' => __('Malaysia', 'invoicing'), |
|
255 | + 'MV' => __('Maldives', 'invoicing'), |
|
256 | + 'ML' => __('Mali', 'invoicing'), |
|
257 | + 'MT' => __('Malta', 'invoicing'), |
|
258 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
259 | + 'MQ' => __('Martinique', 'invoicing'), |
|
260 | + 'MR' => __('Mauritania', 'invoicing'), |
|
261 | + 'MU' => __('Mauritius', 'invoicing'), |
|
262 | + 'YT' => __('Mayotte', 'invoicing'), |
|
263 | + 'MX' => __('Mexico', 'invoicing'), |
|
264 | + 'FM' => __('Micronesia', 'invoicing'), |
|
265 | + 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
266 | + 'MC' => __('Monaco', 'invoicing'), |
|
267 | + 'MN' => __('Mongolia', 'invoicing'), |
|
268 | + 'ME' => __('Montenegro', 'invoicing'), |
|
269 | + 'MS' => __('Montserrat', 'invoicing'), |
|
270 | + 'MA' => __('Morocco', 'invoicing'), |
|
271 | + 'MZ' => __('Mozambique', 'invoicing'), |
|
272 | + 'MM' => __('Myanmar', 'invoicing'), |
|
273 | + 'NA' => __('Namibia', 'invoicing'), |
|
274 | + 'NR' => __('Nauru', 'invoicing'), |
|
275 | + 'NP' => __('Nepal', 'invoicing'), |
|
276 | + 'NL' => __('Netherlands', 'invoicing'), |
|
277 | + 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
278 | + 'NC' => __('New Caledonia', 'invoicing'), |
|
279 | + 'NZ' => __('New Zealand', 'invoicing'), |
|
280 | + 'NI' => __('Nicaragua', 'invoicing'), |
|
281 | + 'NE' => __('Niger', 'invoicing'), |
|
282 | + 'NG' => __('Nigeria', 'invoicing'), |
|
283 | + 'NU' => __('Niue', 'invoicing'), |
|
284 | + 'NF' => __('Norfolk Island', 'invoicing'), |
|
285 | + 'KP' => __('North Korea', 'invoicing'), |
|
286 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
287 | + 'NO' => __('Norway', 'invoicing'), |
|
288 | + 'OM' => __('Oman', 'invoicing'), |
|
289 | + 'PK' => __('Pakistan', 'invoicing'), |
|
290 | + 'PW' => __('Palau', 'invoicing'), |
|
291 | + 'PS' => __('Palestinian Territories', 'invoicing'), |
|
292 | + 'PA' => __('Panama', 'invoicing'), |
|
293 | + 'PG' => __('Papua New Guinea', 'invoicing'), |
|
294 | + 'PY' => __('Paraguay', 'invoicing'), |
|
295 | + 'PE' => __('Peru', 'invoicing'), |
|
296 | + 'PH' => __('Phillipines', 'invoicing'), |
|
297 | + 'PN' => __('Pitcairn Island', 'invoicing'), |
|
298 | + 'PL' => __('Poland', 'invoicing'), |
|
299 | + 'PT' => __('Portugal', 'invoicing'), |
|
300 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
301 | + 'QA' => __('Qatar', 'invoicing'), |
|
302 | + 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
303 | + 'RE' => __('Reunion Island', 'invoicing'), |
|
304 | + 'RO' => __('Romania', 'invoicing'), |
|
305 | + 'RU' => __('Russian Federation', 'invoicing'), |
|
306 | + 'RW' => __('Rwanda', 'invoicing'), |
|
307 | + 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
308 | + 'SH' => __('Saint Helena', 'invoicing'), |
|
309 | + 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
310 | + 'LC' => __('Saint Lucia', 'invoicing'), |
|
311 | + 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
312 | + 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
313 | + 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
314 | + 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
315 | + 'SM' => __('San Marino', 'invoicing'), |
|
316 | + 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
317 | + 'SA' => __('Saudi Arabia', 'invoicing'), |
|
318 | + 'SN' => __('Senegal', 'invoicing'), |
|
319 | + 'RS' => __('Serbia', 'invoicing'), |
|
320 | + 'SC' => __('Seychelles', 'invoicing'), |
|
321 | + 'SL' => __('Sierra Leone', 'invoicing'), |
|
322 | + 'SG' => __('Singapore', 'invoicing'), |
|
323 | + 'SK' => __('Slovak Republic', 'invoicing'), |
|
324 | + 'SI' => __('Slovenia', 'invoicing'), |
|
325 | + 'SB' => __('Solomon Islands', 'invoicing'), |
|
326 | + 'SO' => __('Somalia', 'invoicing'), |
|
327 | + 'ZA' => __('South Africa', 'invoicing'), |
|
328 | + 'GS' => __('South Georgia', 'invoicing'), |
|
329 | + 'KR' => __('South Korea', 'invoicing'), |
|
330 | + 'SS' => __('South Sudan', 'invoicing'), |
|
331 | + 'ES' => __('Spain', 'invoicing'), |
|
332 | + 'LK' => __('Sri Lanka', 'invoicing'), |
|
333 | + 'SD' => __('Sudan', 'invoicing'), |
|
334 | + 'SR' => __('Suriname', 'invoicing'), |
|
335 | + 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
336 | + 'SZ' => __('Swaziland', 'invoicing'), |
|
337 | + 'SE' => __('Sweden', 'invoicing'), |
|
338 | + 'CH' => __('Switzerland', 'invoicing'), |
|
339 | + 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
340 | + 'TW' => __('Taiwan', 'invoicing'), |
|
341 | + 'TJ' => __('Tajikistan', 'invoicing'), |
|
342 | + 'TZ' => __('Tanzania', 'invoicing'), |
|
343 | + 'TH' => __('Thailand', 'invoicing'), |
|
344 | + 'TL' => __('Timor-Leste', 'invoicing'), |
|
345 | + 'TG' => __('Togo', 'invoicing'), |
|
346 | + 'TK' => __('Tokelau', 'invoicing'), |
|
347 | + 'TO' => __('Tonga', 'invoicing'), |
|
348 | + 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
349 | + 'TN' => __('Tunisia', 'invoicing'), |
|
350 | + 'TR' => __('Turkey', 'invoicing'), |
|
351 | + 'TM' => __('Turkmenistan', 'invoicing'), |
|
352 | + 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
353 | + 'TV' => __('Tuvalu', 'invoicing'), |
|
354 | + 'UG' => __('Uganda', 'invoicing'), |
|
355 | + 'UA' => __('Ukraine', 'invoicing'), |
|
356 | + 'AE' => __('United Arab Emirates', 'invoicing'), |
|
357 | + 'UY' => __('Uruguay', 'invoicing'), |
|
358 | + 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
359 | + 'UZ' => __('Uzbekistan', 'invoicing'), |
|
360 | + 'VU' => __('Vanuatu', 'invoicing'), |
|
361 | + 'VE' => __('Venezuela', 'invoicing'), |
|
362 | + 'VN' => __('Vietnam', 'invoicing'), |
|
363 | + 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
364 | + 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
365 | + 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
366 | + 'EH' => __('Western Sahara', 'invoicing'), |
|
367 | + 'WS' => __('Western Samoa', 'invoicing'), |
|
368 | + 'YE' => __('Yemen', 'invoicing'), |
|
369 | + 'ZM' => __('Zambia', 'invoicing'), |
|
370 | + 'ZW' => __('Zimbabwe', 'invoicing'), |
|
371 | + ); |
|
372 | 372 | |
373 | 373 | if ( $first_empty ) { |
374 | 374 | $countries = array_merge( array( '' => '' ), $countries ); |
@@ -1537,30 +1537,30 @@ discard block |
||
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | function wpinv_get_states_field() { |
1540 | - if( empty( $_POST['country'] ) ) { |
|
1541 | - $_POST['country'] = wpinv_get_default_country(); |
|
1542 | - } |
|
1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
1540 | + if( empty( $_POST['country'] ) ) { |
|
1541 | + $_POST['country'] = wpinv_get_default_country(); |
|
1542 | + } |
|
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 | - 'name' => $sanitized_field_name, |
|
1550 | - 'id' => $sanitized_field_name, |
|
1551 | - 'class' => $sanitized_field_name . ' wpinv-select', |
|
1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1553 | - 'show_option_all' => false, |
|
1554 | - 'show_option_none' => false |
|
1555 | - ); |
|
1556 | - |
|
1557 | - $response = wpinv_html_select( $args ); |
|
1558 | - |
|
1559 | - } else { |
|
1560 | - $response = 'nostates'; |
|
1561 | - } |
|
1549 | + 'name' => $sanitized_field_name, |
|
1550 | + 'id' => $sanitized_field_name, |
|
1551 | + 'class' => $sanitized_field_name . ' wpinv-select', |
|
1552 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
1553 | + 'show_option_all' => false, |
|
1554 | + 'show_option_none' => false |
|
1555 | + ); |
|
1556 | + |
|
1557 | + $response = wpinv_html_select( $args ); |
|
1558 | + |
|
1559 | + } else { |
|
1560 | + $response = 'nostates'; |
|
1561 | + } |
|
1562 | 1562 | |
1563 | - return $response; |
|
1563 | + return $response; |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -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 |
@@ -95,20 +95,24 @@ |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | if ( !empty( $user_info ) ) { |
98 | - if( empty( $address['first_name'] ) ) |
|
99 | - $address['first_name'] = $user_info->first_name; |
|
98 | + if( empty( $address['first_name'] ) ) { |
|
99 | + $address['first_name'] = $user_info->first_name; |
|
100 | + } |
|
100 | 101 | |
101 | - if( empty( $address['last_name'] ) ) |
|
102 | - $address['last_name'] = $user_info->last_name; |
|
102 | + if( empty( $address['last_name'] ) ) { |
|
103 | + $address['last_name'] = $user_info->last_name; |
|
104 | + } |
|
103 | 105 | } |
104 | 106 | |
105 | 107 | $address['name'] = trim( trim( $address['first_name'] . ' ' . $address['last_name'] ), "," ); |
106 | 108 | |
107 | - if( empty( $address['state'] ) && $with_default ) |
|
108 | - $address['state'] = wpinv_get_default_state(); |
|
109 | + if( empty( $address['state'] ) && $with_default ) { |
|
110 | + $address['state'] = wpinv_get_default_state(); |
|
111 | + } |
|
109 | 112 | |
110 | - if( empty( $address['country'] ) && $with_default ) |
|
111 | - $address['country'] = wpinv_get_default_country(); |
|
113 | + if( empty( $address['country'] ) && $with_default ) { |
|
114 | + $address['country'] = wpinv_get_default_country(); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | |
114 | 118 | return $address; |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
7 | 8 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | |
8 | -do_action( 'wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
8 | +do_action('wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
9 | 9 | |
10 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
10 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
11 | 11 | |
12 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
12 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
13 | 13 | |
14 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
14 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
15 | 15 | |
16 | -do_action( 'wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
16 | +do_action('wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
17 | 17 | |
18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
19 | 18 | \ No newline at end of file |
19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
7 | 8 | ?> |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | ?> |
8 | 8 | |
9 | -<p><?php printf( __( 'You have received payment from %s. The invoice is as follows:', 'invoicing' ), $invoice->get_user_full_name() ); ?></p> |
|
9 | +<p><?php printf(__('You have received payment from %s. The invoice is as follows:', 'invoicing'), $invoice->get_user_full_name()); ?></p> |
|
10 | 10 | |
11 | 11 | <?php |
12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
13 | 13 | |
14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
15 | 15 | |
16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
17 | 17 | |
18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
19 | 18 | \ No newline at end of file |
19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
20 | 20 | \ No newline at end of file |
@@ -1,41 +1,41 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | global $post; |
6 | 6 | $invoice_id = $post->ID; |
7 | -$invoice = wpinv_get_invoice( $invoice_id ); |
|
8 | -if ( empty( $invoice ) ) { |
|
7 | +$invoice = wpinv_get_invoice($invoice_id); |
|
8 | +if (empty($invoice)) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | -$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' ); |
|
12 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); ?><!DOCTYPE html> |
|
11 | +$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing'); |
|
12 | +do_action('wpinv_invoice_print_before_display', $invoice); ?><!DOCTYPE html> |
|
13 | 13 | <html <?php language_attributes(); ?>> |
14 | 14 | <head> |
15 | 15 | <meta charset="UTF-8"> |
16 | 16 | <title><?php wp_title() ?></title> |
17 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
17 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
18 | 18 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
19 | 19 | <meta name="robots" content="noindex,nofollow"> |
20 | 20 | |
21 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
21 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
22 | 22 | </head> |
23 | 23 | <body class="body wpinv wpinv-print"> |
24 | - <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?> |
|
24 | + <?php do_action('wpinv_invoice_print_body_start', $invoice); ?> |
|
25 | 25 | <div class="container wpinv-wrap"> |
26 | - <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?> |
|
27 | - <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div> |
|
26 | + <?php if ($watermark = wpinv_watermark($invoice_id)) { ?> |
|
27 | + <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div> |
|
28 | 28 | <?php } ?> |
29 | 29 | <!-- ///// Start PDF header --> |
30 | 30 | <htmlpageheader name="wpinv-pdf-header"> |
31 | - <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?> |
|
31 | + <?php do_action('wpinv_invoice_print_before_header', $invoice); ?> |
|
32 | 32 | <div class="row wpinv-header"> |
33 | 33 | <div class="col-xs-6 wpinv-business"> |
34 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
35 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
36 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
34 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
35 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
36 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
37 | 37 | <?php } else { ?> |
38 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
38 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
39 | 39 | <?php } ?> |
40 | 40 | </a> |
41 | 41 | </div> |
@@ -44,56 +44,56 @@ discard block |
||
44 | 44 | <h2><?php echo $type; ?></h2> |
45 | 45 | </div> |
46 | 46 | </div> |
47 | - <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?> |
|
47 | + <?php do_action('wpinv_invoice_print_after_header', $invoice); ?> |
|
48 | 48 | </htmlpageheader> |
49 | 49 | <!-- End PDF header ///// --> |
50 | 50 | |
51 | - <?php do_action( 'wpinv_invoice_print_before_top_content', $invoice ); ?> |
|
51 | + <?php do_action('wpinv_invoice_print_before_top_content', $invoice); ?> |
|
52 | 52 | <div class="row wpinv-top-content"> |
53 | 53 | <div class="col-xs-12 col-sm-6 wpinv-addresses"> |
54 | 54 | <div class="col-xs-12 wpinv-address wpinv-from-address"> |
55 | 55 | <?php wpinv_display_from_address(); ?> |
56 | 56 | </div> |
57 | 57 | <div class="col-xs-12 wpinv-address wpinv-to-address"> |
58 | - <?php wpinv_display_to_address( $invoice_id ); ?> |
|
58 | + <?php wpinv_display_to_address($invoice_id); ?> |
|
59 | 59 | </div> |
60 | 60 | </div> |
61 | 61 | <div class="col-xs-12 col-sm-6 wpinv-details"> |
62 | 62 | <div class="col-xs-12 wpinv-line-details"> |
63 | - <?php do_action( 'wpinv_invoice_print_before_details', $invoice ); ?> |
|
64 | - <?php wpinv_display_invoice_details( $invoice ); ?> |
|
65 | - <?php do_action( 'wpinv_invoice_print_after_details', $invoice ); ?> |
|
63 | + <?php do_action('wpinv_invoice_print_before_details', $invoice); ?> |
|
64 | + <?php wpinv_display_invoice_details($invoice); ?> |
|
65 | + <?php do_action('wpinv_invoice_print_after_details', $invoice); ?> |
|
66 | 66 | </div> |
67 | 67 | </div> |
68 | 68 | </div> |
69 | - <?php do_action( 'wpinv_invoice_print_after_top_content', $invoice ); ?> |
|
69 | + <?php do_action('wpinv_invoice_print_after_top_content', $invoice); ?> |
|
70 | 70 | |
71 | - <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?> |
|
71 | + <?php do_action('wpinv_invoice_print_middle', $invoice); ?> |
|
72 | 72 | |
73 | - <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?> |
|
73 | + <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?> |
|
74 | 74 | <div class="row wpinv-items"> |
75 | 75 | <div class="col-sm-12 wpinv-line-items"> |
76 | - <?php wpinv_display_line_items( $invoice_id ); ?> |
|
76 | + <?php wpinv_display_line_items($invoice_id); ?> |
|
77 | 77 | </div> |
78 | 78 | </div> |
79 | - <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?> |
|
79 | + <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?> |
|
80 | 80 | |
81 | 81 | <!-- ///// Start PDF footer --> |
82 | 82 | <htmlpagefooter name="wpinv-pdf-footer"> |
83 | - <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?> |
|
83 | + <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?> |
|
84 | 84 | <div class="row wpinv-footer"> |
85 | 85 | <div class="col-sm-12"> |
86 | - <?php if ( $term_text = wpinv_get_terms_text() ) { ?> |
|
87 | - <div class="terms-text"><?php echo wpautop( $term_text ); ?></div> |
|
86 | + <?php if ($term_text = wpinv_get_terms_text()) { ?> |
|
87 | + <div class="terms-text"><?php echo wpautop($term_text); ?></div> |
|
88 | 88 | <?php } ?> |
89 | 89 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
90 | - <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div> |
|
90 | + <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div> |
|
91 | 91 | </div> |
92 | 92 | </div> |
93 | - <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?> |
|
93 | + <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?> |
|
94 | 94 | </htmlpagefooter> |
95 | 95 | <!-- End PDF footer ///// --> |
96 | 96 | </div><!-- END wpinv-wrap --> |
97 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
97 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
98 | 98 | </body> |
99 | 99 | </html> |
100 | 100 | \ No newline at end of file |
@@ -976,67 +976,67 @@ |
||
976 | 976 | function wpinv_tool_merge_fix_taxes() { |
977 | 977 | global $wpdb; |
978 | 978 | |
979 | - $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
|
980 | - $items = $wpdb->get_results( $sql ); |
|
979 | + $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
|
980 | + $items = $wpdb->get_results( $sql ); |
|
981 | 981 | |
982 | - if ( !empty( $items ) ) { |
|
983 | - foreach ( $items as $item ) { |
|
984 | - if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
985 | - update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
986 | - } |
|
987 | - } |
|
988 | - } |
|
982 | + if ( !empty( $items ) ) { |
|
983 | + foreach ( $items as $item ) { |
|
984 | + if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
985 | + update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
986 | + } |
|
987 | + } |
|
988 | + } |
|
989 | 989 | |
990 | 990 | $sql = "SELECT `p`.`ID`, gdi.id AS gdp_id FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NOT NULL AND p.post_status NOT IN( 'publish', 'wpi-processing', 'wpi-renewal' ) ORDER BY `gdi`.`id` ASC"; |
991 | 991 | $items = $wpdb->get_results( $sql ); |
992 | 992 | |
993 | - if ( !empty( $items ) ) { |
|
994 | - $success = false; |
|
993 | + if ( !empty( $items ) ) { |
|
994 | + $success = false; |
|
995 | 995 | $message = __( 'Taxes fixed for non-paid merged GD invoices.', 'invoicing' ); |
996 | 996 | |
997 | - global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
|
997 | + global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
|
998 | 998 | |
999 | - foreach ( $items as $item ) { |
|
1000 | - $wpi_tax_rates = NULL; |
|
1001 | - $data = wpinv_get_invoice($item->ID); |
|
999 | + foreach ( $items as $item ) { |
|
1000 | + $wpi_tax_rates = NULL; |
|
1001 | + $data = wpinv_get_invoice($item->ID); |
|
1002 | 1002 | |
1003 | - if ( empty( $data ) ) { |
|
1004 | - continue; |
|
1005 | - } |
|
1003 | + if ( empty( $data ) ) { |
|
1004 | + continue; |
|
1005 | + } |
|
1006 | 1006 | |
1007 | - $checkout_session = wpinv_get_checkout_session(); |
|
1007 | + $checkout_session = wpinv_get_checkout_session(); |
|
1008 | 1008 | |
1009 | - $data_session = array(); |
|
1010 | - $data_session['invoice_id'] = $data->ID; |
|
1011 | - $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
1009 | + $data_session = array(); |
|
1010 | + $data_session['invoice_id'] = $data->ID; |
|
1011 | + $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
1012 | 1012 | |
1013 | - wpinv_set_checkout_session( $data_session ); |
|
1013 | + wpinv_set_checkout_session( $data_session ); |
|
1014 | 1014 | |
1015 | - $wpi_userID = (int)$data->get_user_id(); |
|
1016 | - $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
|
1015 | + $wpi_userID = (int)$data->get_user_id(); |
|
1016 | + $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
|
1017 | 1017 | |
1018 | - $data->country = sanitize_text_field( $_POST['country'] ); |
|
1019 | - $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
1018 | + $data->country = sanitize_text_field( $_POST['country'] ); |
|
1019 | + $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
1020 | 1020 | |
1021 | - $wpinv_ip_address_country = $data->country; |
|
1021 | + $wpinv_ip_address_country = $data->country; |
|
1022 | 1022 | |
1023 | - $data->recalculate_totals(true); |
|
1023 | + $data->recalculate_totals(true); |
|
1024 | 1024 | |
1025 | - wpinv_set_checkout_session( $checkout_session ); |
|
1025 | + wpinv_set_checkout_session( $checkout_session ); |
|
1026 | 1026 | |
1027 | - $update_data = array(); |
|
1028 | - $update_data['tax_amount'] = $data->get_tax(); |
|
1029 | - $update_data['paied_amount'] = $data->get_total(); |
|
1030 | - $update_data['invoice_id'] = $data->ID; |
|
1027 | + $update_data = array(); |
|
1028 | + $update_data['tax_amount'] = $data->get_tax(); |
|
1029 | + $update_data['paied_amount'] = $data->get_total(); |
|
1030 | + $update_data['invoice_id'] = $data->ID; |
|
1031 | 1031 | |
1032 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
1033 | - } |
|
1034 | - } else { |
|
1032 | + $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
1033 | + } |
|
1034 | + } else { |
|
1035 | 1035 | $success = false; |
1036 | 1036 | $message = __( 'No invoices found to fix taxes!', 'invoicing' ); |
1037 | 1037 | } |
1038 | 1038 | |
1039 | - $response = array(); |
|
1039 | + $response = array(); |
|
1040 | 1040 | $response['success'] = $success; |
1041 | 1041 | $response['data']['message'] = $message; |
1042 | 1042 | wp_send_json( $response ); |
@@ -740,6 +740,9 @@ |
||
740 | 740 | add_action( 'geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link' ); |
741 | 741 | remove_action( 'geodir_dashboard_links', 'geodir_payment_invoices_list_page_link' ); |
742 | 742 | |
743 | +/** |
|
744 | + * @param string $new_status |
|
745 | + */ |
|
743 | 746 | function wpinv_wpi_to_gdp_update_status( $invoice_id, $new_status, $old_status ) { |
744 | 747 | if (!defined('GEODIRPAYMENT_VERSION')) { |
745 | 748 | return false; |
@@ -1,23 +1,23 @@ 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 | 7 | function wpinv_gd_active() { |
8 | - return (bool)defined( 'GEODIRECTORY_VERSION' ); |
|
8 | + return (bool)defined('GEODIRECTORY_VERSION'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | function wpinv_pm_active() { |
12 | - return (bool)wpinv_gd_active() && (bool)defined( 'GEODIRPAYMENT_VERSION' ); |
|
12 | + return (bool)wpinv_gd_active() && (bool)defined('GEODIRPAYMENT_VERSION'); |
|
13 | 13 | } |
14 | 14 | |
15 | -function wpinv_is_gd_post_type( $post_type ) { |
|
15 | +function wpinv_is_gd_post_type($post_type) { |
|
16 | 16 | global $gd_posttypes; |
17 | 17 | |
18 | - $gd_posttypes = !empty( $gd_posttypes ) && is_array( $gd_posttypes ) ? $gd_posttypes : geodir_get_posttypes(); |
|
18 | + $gd_posttypes = !empty($gd_posttypes) && is_array($gd_posttypes) ? $gd_posttypes : geodir_get_posttypes(); |
|
19 | 19 | |
20 | - if ( !empty( $post_type ) && !empty( $gd_posttypes ) && in_array( $post_type, $gd_posttypes ) ) { |
|
20 | + if (!empty($post_type) && !empty($gd_posttypes) && in_array($post_type, $gd_posttypes)) { |
|
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
32 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
33 | 33 | // Add fields for force upgrade |
34 | - if ( defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column') ) { |
|
35 | - geodir_add_column_if_not_exist( INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0' ); |
|
34 | + if (defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column')) { |
|
35 | + geodir_add_column_if_not_exist(INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0'); |
|
36 | 36 | |
37 | 37 | update_option('wpinv_gdp_column', '1'); |
38 | 38 | } |
@@ -40,39 +40,39 @@ discard block |
||
40 | 40 | wpinv_merge_gd_packages_to_items(); |
41 | 41 | } |
42 | 42 | } |
43 | -add_action( 'admin_init', 'wpinv_geodir_integration' ); |
|
43 | +add_action('admin_init', 'wpinv_geodir_integration'); |
|
44 | 44 | |
45 | -function wpinv_get_gdp_package_type( $item_types ) { |
|
46 | - if ( wpinv_pm_active() ) { |
|
47 | - $item_types['package'] = __( 'Package', 'invoicing' ); |
|
45 | +function wpinv_get_gdp_package_type($item_types) { |
|
46 | + if (wpinv_pm_active()) { |
|
47 | + $item_types['package'] = __('Package', 'invoicing'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return $item_types; |
51 | 51 | } |
52 | -add_filter( 'wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1 ); |
|
52 | +add_filter('wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1); |
|
53 | 53 | |
54 | 54 | function wpinv_update_package_item($package_id) { |
55 | 55 | return wpinv_merge_gd_package_to_item($package_id, true); |
56 | 56 | } |
57 | 57 | add_action('geodir_after_save_package', 'wpinv_update_package_item', 10, 1); |
58 | 58 | |
59 | -function wpinv_merge_gd_packages_to_items( $force = false ) { |
|
60 | - if ( $merged = get_option( 'wpinv_merge_gd_packages' ) && !$force ) { |
|
59 | +function wpinv_merge_gd_packages_to_items($force = false) { |
|
60 | + if ($merged = get_option('wpinv_merge_gd_packages') && !$force) { |
|
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | |
64 | - if(!function_exists('geodir_package_list_info')){ |
|
64 | + if (!function_exists('geodir_package_list_info')) { |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
68 | 68 | $packages = geodir_package_list_info(); |
69 | 69 | |
70 | - foreach ( $packages as $key => $package ) { |
|
71 | - wpinv_merge_gd_package_to_item( $package->pid, $force, $package ); |
|
70 | + foreach ($packages as $key => $package) { |
|
71 | + wpinv_merge_gd_package_to_item($package->pid, $force, $package); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( !$merged ) { |
|
75 | - update_option( 'wpinv_merge_gd_packages', 1 ); |
|
74 | + if (!$merged) { |
|
75 | + update_option('wpinv_merge_gd_packages', 1); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return true; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | $package = empty($package) ? geodir_get_package_info_by_id($package_id, '') : $package; |
103 | 103 | |
104 | - if ( empty($package) || !wpinv_is_gd_post_type( $package->post_type ) ) { |
|
104 | + if (empty($package) || !wpinv_is_gd_post_type($package->post_type)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | $meta['custom_id'] = $package_id; |
111 | 111 | $meta['custom_singular_name'] = get_post_type_singular_label($package->post_type); |
112 | 112 | $meta['custom_name'] = get_post_type_plural_label($package->post_type); |
113 | - $meta['price'] = wpinv_round_amount( $package->amount ); |
|
113 | + $meta['price'] = wpinv_round_amount($package->amount); |
|
114 | 114 | $meta['vat_rule'] = 'digital'; |
115 | 115 | $meta['vat_class'] = '_standard'; |
116 | 116 | |
117 | - if ( !empty( $package->sub_active ) ) { |
|
118 | - $sub_num_trial_days = absint( $package->sub_num_trial_days ); |
|
117 | + if (!empty($package->sub_active)) { |
|
118 | + $sub_num_trial_days = absint($package->sub_num_trial_days); |
|
119 | 119 | |
120 | 120 | $meta['is_recurring'] = 1; |
121 | 121 | $meta['recurring_period'] = $package->sub_units; |
122 | - $meta['recurring_interval'] = absint( $package->sub_units_num ); |
|
123 | - $meta['recurring_limit'] = absint( $package->sub_units_num_times ); |
|
122 | + $meta['recurring_interval'] = absint($package->sub_units_num); |
|
123 | + $meta['recurring_limit'] = absint($package->sub_units_num_times); |
|
124 | 124 | $meta['free_trial'] = $sub_num_trial_days > 0 ? 1 : 0; |
125 | 125 | $meta['trial_period'] = $package->sub_num_trial_units; |
126 | 126 | $meta['trial_interval'] = $sub_num_trial_days; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $meta['trial_interval'] = ''; |
135 | 135 | } |
136 | 136 | |
137 | - $data = array( |
|
137 | + $data = array( |
|
138 | 138 | 'post_title' => $package->title, |
139 | 139 | 'post_excerpt' => $package->title_desc, |
140 | 140 | 'post_status' => $package->status == 1 ? 'publish' : 'pending', |
@@ -151,48 +151,48 @@ discard block |
||
151 | 151 | return $item; |
152 | 152 | } |
153 | 153 | |
154 | -function wpinv_gdp_to_wpi_gateway( $payment_method ) { |
|
155 | - switch( $payment_method ) { |
|
154 | +function wpinv_gdp_to_wpi_gateway($payment_method) { |
|
155 | + switch ($payment_method) { |
|
156 | 156 | case 'prebanktransfer': |
157 | 157 | $gateway = 'bank_transfer'; |
158 | 158 | break; |
159 | 159 | default: |
160 | - $gateway = empty( $payment_method ) ? 'manual' : $payment_method; |
|
160 | + $gateway = empty($payment_method) ? 'manual' : $payment_method; |
|
161 | 161 | break; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'wpinv_gdp_to_wpi_gateway', $gateway, $payment_method ); |
|
164 | + return apply_filters('wpinv_gdp_to_wpi_gateway', $gateway, $payment_method); |
|
165 | 165 | } |
166 | 166 | |
167 | -function wpinv_gdp_to_wpi_gateway_title( $payment_method ) { |
|
168 | - $gateway = wpinv_gdp_to_wpi_gateway( $payment_method ); |
|
167 | +function wpinv_gdp_to_wpi_gateway_title($payment_method) { |
|
168 | + $gateway = wpinv_gdp_to_wpi_gateway($payment_method); |
|
169 | 169 | |
170 | - $gateway_title = wpinv_get_gateway_checkout_label( $gateway ); |
|
170 | + $gateway_title = wpinv_get_gateway_checkout_label($gateway); |
|
171 | 171 | |
172 | - if ( $gateway == $gateway_title ) { |
|
173 | - $gateway_title = geodir_payment_method_title( $gateway ); |
|
172 | + if ($gateway == $gateway_title) { |
|
173 | + $gateway_title = geodir_payment_method_title($gateway); |
|
174 | 174 | } |
175 | 175 | |
176 | - return apply_filters( 'wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method ); |
|
176 | + return apply_filters('wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | function wpinv_print_checkout_errors() { |
180 | 180 | global $wpi_session; |
181 | 181 | wpinv_print_errors(); |
182 | 182 | } |
183 | -add_action( 'geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10 ); |
|
183 | +add_action('geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10); |
|
184 | 184 | |
185 | -function wpinv_cpt_save( $invoice_id, $update = false, $pre_status = NULL ) { |
|
185 | +function wpinv_cpt_save($invoice_id, $update = false, $pre_status = NULL) { |
|
186 | 186 | global $wpi_nosave, $wpi_zero_tax, $wpi_gdp_inv_merge; |
187 | 187 | |
188 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
188 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
189 | 189 | |
190 | - $wpi_invoice_id = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : 0; |
|
190 | + $wpi_invoice_id = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : 0; |
|
191 | 191 | |
192 | 192 | if (!empty($invoice_info)) { |
193 | - $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice( $wpi_invoice_id ) : NULL; |
|
193 | + $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice($wpi_invoice_id) : NULL; |
|
194 | 194 | |
195 | - if ( !empty( $wpi_invoice ) ) { // update invoice |
|
195 | + if (!empty($wpi_invoice)) { // update invoice |
|
196 | 196 | $save = false; |
197 | 197 | if ($invoice_info->coupon_code !== $wpi_invoice->discount_code || (float)$invoice_info->discount < (float)$wpi_invoice->discount || (float)$invoice_info->discount > (float)$wpi_invoice->discount) { |
198 | 198 | $save = true; |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | |
203 | 203 | if ($invoice_info->paymentmethod !== $wpi_invoice->gateway) { |
204 | 204 | $save = true; |
205 | - $gateway = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : ''; |
|
206 | - $gateway = wpinv_gdp_to_wpi_gateway( $gateway ); |
|
207 | - $gateway_title = wpinv_gdp_to_wpi_gateway_title( $gateway ); |
|
208 | - $wpi_invoice->set('gateway', $gateway ); |
|
209 | - $wpi_invoice->set('gateway_title', $gateway_title ); |
|
205 | + $gateway = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : ''; |
|
206 | + $gateway = wpinv_gdp_to_wpi_gateway($gateway); |
|
207 | + $gateway_title = wpinv_gdp_to_wpi_gateway_title($gateway); |
|
208 | + $wpi_invoice->set('gateway', $gateway); |
|
209 | + $wpi_invoice->set('gateway_title', $gateway_title); |
|
210 | 210 | } |
211 | 211 | |
212 | - if ( ( $status = wpinv_gdp_to_wpi_status( $invoice_info->status ) ) !== $wpi_invoice->status ) { |
|
212 | + if (($status = wpinv_gdp_to_wpi_status($invoice_info->status)) !== $wpi_invoice->status) { |
|
213 | 213 | $save = true; |
214 | - $wpi_invoice->set( 'status', $status ); |
|
214 | + $wpi_invoice->set('status', $status); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($save) { |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | |
223 | 223 | return $wpi_invoice; |
224 | 224 | } else { // create invoice |
225 | - $user_info = get_userdata( $invoice_info->user_id ); |
|
225 | + $user_info = get_userdata($invoice_info->user_id); |
|
226 | 226 | |
227 | - if ( !empty( $pre_status ) ) { |
|
227 | + if (!empty($pre_status)) { |
|
228 | 228 | $invoice_info->status = $pre_status; |
229 | 229 | } |
230 | - $status = wpinv_gdp_to_wpi_status( $invoice_info->status ); |
|
230 | + $status = wpinv_gdp_to_wpi_status($invoice_info->status); |
|
231 | 231 | |
232 | 232 | $wpi_zero_tax = false; |
233 | 233 | |
234 | - if ( $wpi_gdp_inv_merge && in_array( $status, array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
234 | + if ($wpi_gdp_inv_merge && in_array($status, array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
235 | 235 | $wpi_zero_tax = true; |
236 | 236 | } |
237 | 237 | |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | $invoice_data['user_id'] = $invoice_info->user_id; |
242 | 242 | $invoice_data['created_via'] = 'API'; |
243 | 243 | |
244 | - if ( !empty( $invoice_info->date ) ) { |
|
245 | - $invoice_data['created_date'] = $invoice_info->date; |
|
244 | + if (!empty($invoice_info->date)) { |
|
245 | + $invoice_data['created_date'] = $invoice_info->date; |
|
246 | 246 | } |
247 | 247 | |
248 | - $paymentmethod = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : ''; |
|
249 | - $paymentmethod = wpinv_gdp_to_wpi_gateway( $paymentmethod ); |
|
250 | - $payment_method_title = wpinv_gdp_to_wpi_gateway_title( $paymentmethod ); |
|
248 | + $paymentmethod = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : ''; |
|
249 | + $paymentmethod = wpinv_gdp_to_wpi_gateway($paymentmethod); |
|
250 | + $payment_method_title = wpinv_gdp_to_wpi_gateway_title($paymentmethod); |
|
251 | 251 | |
252 | 252 | $invoice_data['payment_details'] = array( |
253 | 253 | 'gateway' => $paymentmethod, |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | 'currency' => geodir_get_currency_type(), |
256 | 256 | ); |
257 | 257 | |
258 | - $user_address = wpinv_get_user_address( $invoice_info->user_id, false ); |
|
258 | + $user_address = wpinv_get_user_address($invoice_info->user_id, false); |
|
259 | 259 | |
260 | 260 | $invoice_data['user_info'] = array( |
261 | 261 | 'user_id' => $invoice_info->user_id, |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | |
279 | 279 | $post_item = wpinv_get_gd_package_item($invoice_info->package_id); |
280 | 280 | |
281 | - if ( $invoice_info->invoice_type == 'add_franchise' ) { |
|
281 | + if ($invoice_info->invoice_type == 'add_franchise') { |
|
282 | 282 | $custom_price = $invoice_info->amount; |
283 | 283 | } else { |
284 | 284 | $custom_price = ''; |
285 | 285 | } |
286 | 286 | |
287 | - if ( !empty( $post_item ) ) { |
|
288 | - $cart_details = array(); |
|
287 | + if (!empty($post_item)) { |
|
288 | + $cart_details = array(); |
|
289 | 289 | $cart_details[] = array( |
290 | 290 | 'id' => $post_item->ID, |
291 | 291 | 'name' => $post_item->get_name(), |
@@ -299,19 +299,19 @@ discard block |
||
299 | 299 | ), |
300 | 300 | ); |
301 | 301 | |
302 | - $invoice_data['cart_details'] = $cart_details; |
|
302 | + $invoice_data['cart_details'] = $cart_details; |
|
303 | 303 | } |
304 | 304 | |
305 | - $data = array( 'invoice' => $invoice_data ); |
|
305 | + $data = array('invoice' => $invoice_data); |
|
306 | 306 | |
307 | 307 | $wpinv_api = new WPInv_API(); |
308 | - $data = $wpinv_api->insert_invoice( $data ); |
|
308 | + $data = $wpinv_api->insert_invoice($data); |
|
309 | 309 | |
310 | - if ( is_wp_error( $data ) ) { |
|
311 | - wpinv_error_log( 'WPInv_Invoice: ' . $data->get_error_message() ); |
|
310 | + if (is_wp_error($data)) { |
|
311 | + wpinv_error_log('WPInv_Invoice: ' . $data->get_error_message()); |
|
312 | 312 | } else { |
313 | - if ( !empty( $data ) ) { |
|
314 | - update_post_meta( $data->ID, '_wpinv_gdp_id', $invoice_id ); |
|
313 | + if (!empty($data)) { |
|
314 | + update_post_meta($data->ID, '_wpinv_gdp_id', $invoice_id); |
|
315 | 315 | |
316 | 316 | $update_data = array(); |
317 | 317 | $update_data['tax_amount'] = $data->get_tax(); |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | $update_data['invoice_id'] = $data->ID; |
320 | 320 | |
321 | 321 | global $wpdb; |
322 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $invoice_id ) ); |
|
322 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $invoice_id)); |
|
323 | 323 | |
324 | 324 | return $data; |
325 | 325 | } else { |
326 | - if ( $update ) { |
|
327 | - wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to update invoice.', 'invoicing' ) ); |
|
326 | + if ($update) { |
|
327 | + wpinv_error_log('WPInv_Invoice: ' . __('Fail to update invoice.', 'invoicing')); |
|
328 | 328 | } else { |
329 | - wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to create invoice.', 'invoicing' ) ); |
|
329 | + wpinv_error_log('WPInv_Invoice: ' . __('Fail to create invoice.', 'invoicing')); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | } |
@@ -337,59 +337,59 @@ discard block |
||
337 | 337 | } |
338 | 338 | add_action('geodir_payment_invoice_created', 'wpinv_cpt_save', 11, 3); |
339 | 339 | |
340 | -function wpinv_cpt_update( $invoice_id ) { |
|
341 | - return wpinv_cpt_save( $invoice_id, true ); |
|
340 | +function wpinv_cpt_update($invoice_id) { |
|
341 | + return wpinv_cpt_save($invoice_id, true); |
|
342 | 342 | } |
343 | 343 | add_action('geodir_payment_invoice_updated', 'wpinv_cpt_update', 11, 1); |
344 | 344 | |
345 | -function wpinv_payment_status_changed( $invoice_id, $new_status, $old_status = 'wpi-pending', $subscription = false ) { |
|
346 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
347 | - if ( empty( $invoice_info ) ) { |
|
345 | +function wpinv_payment_status_changed($invoice_id, $new_status, $old_status = 'wpi-pending', $subscription = false) { |
|
346 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
347 | + if (empty($invoice_info)) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | 350 | |
351 | - $invoice = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL; |
|
352 | - if ( !empty( $invoice ) ) { |
|
351 | + $invoice = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL; |
|
352 | + if (!empty($invoice)) { |
|
353 | 353 | $new_status = wpinv_gdp_to_wpi_status($new_status); |
354 | - $invoice = wpinv_update_payment_status( $invoice->ID, $new_status ); |
|
354 | + $invoice = wpinv_update_payment_status($invoice->ID, $new_status); |
|
355 | 355 | } else { |
356 | - $invoice = wpinv_cpt_save( $invoice_id ); |
|
356 | + $invoice = wpinv_cpt_save($invoice_id); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | return $invoice; |
360 | 360 | } |
361 | -add_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 ); |
|
361 | +add_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4); |
|
362 | 362 | |
363 | -function wpinv_transaction_details_note( $invoice_id, $html ) { |
|
364 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
365 | - if ( empty( $invoice_info ) ) { |
|
363 | +function wpinv_transaction_details_note($invoice_id, $html) { |
|
364 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
365 | + if (empty($invoice_info)) { |
|
366 | 366 | return false; |
367 | 367 | } |
368 | 368 | |
369 | - $wpi_invoice_id = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : NULL; |
|
369 | + $wpi_invoice_id = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : NULL; |
|
370 | 370 | |
371 | - if ( !$wpi_invoice_id ) { |
|
372 | - $invoice = wpinv_cpt_save( $invoice_id, false, $old_status ); |
|
371 | + if (!$wpi_invoice_id) { |
|
372 | + $invoice = wpinv_cpt_save($invoice_id, false, $old_status); |
|
373 | 373 | |
374 | - if ( !empty( $invoice ) ) { |
|
374 | + if (!empty($invoice)) { |
|
375 | 375 | $wpi_invoice_id = $invoice->ID; |
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
379 | - $invoice = wpinv_get_invoice( $wpi_invoice_id ); |
|
379 | + $invoice = wpinv_get_invoice($wpi_invoice_id); |
|
380 | 380 | |
381 | - if ( empty( $invoice ) ) { |
|
381 | + if (empty($invoice)) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
385 | - return $invoice->add_note( $html, true ); |
|
385 | + return $invoice->add_note($html, true); |
|
386 | 386 | } |
387 | -add_action( 'geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2 ); |
|
387 | +add_action('geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2); |
|
388 | 388 | |
389 | -function wpinv_gdp_to_wpi_status( $status ) { |
|
389 | +function wpinv_gdp_to_wpi_status($status) { |
|
390 | 390 | $inv_status = $status ? $status : 'wpi-pending'; |
391 | 391 | |
392 | - switch ( $status ) { |
|
392 | + switch ($status) { |
|
393 | 393 | case 'pending': |
394 | 394 | $inv_status = 'wpi-pending'; |
395 | 395 | break; |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | return $inv_status; |
413 | 413 | } |
414 | 414 | |
415 | -function wpinv_wpi_to_gdp_status( $status ) { |
|
415 | +function wpinv_wpi_to_gdp_status($status) { |
|
416 | 416 | $inv_status = $status ? $status : 'pending'; |
417 | 417 | |
418 | - switch ( $status ) { |
|
418 | + switch ($status) { |
|
419 | 419 | case 'wpi-pending': |
420 | 420 | $inv_status = 'pending'; |
421 | 421 | break; |
@@ -441,72 +441,72 @@ discard block |
||
441 | 441 | return $inv_status; |
442 | 442 | } |
443 | 443 | |
444 | -function wpinv_wpi_to_gdp_id( $invoice_id ) { |
|
444 | +function wpinv_wpi_to_gdp_id($invoice_id) { |
|
445 | 445 | global $wpdb; |
446 | 446 | |
447 | - return $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array( (int)$invoice_id ) ) ); |
|
447 | + return $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array((int)$invoice_id))); |
|
448 | 448 | } |
449 | 449 | |
450 | -function wpinv_gdp_to_wpi_id( $invoice_id ) { |
|
451 | - $invoice = geodir_get_invoice( $invoice_id ); |
|
452 | - return ( empty( $invoice->invoice_id ) ? $invoice->invoice_id : false); |
|
450 | +function wpinv_gdp_to_wpi_id($invoice_id) { |
|
451 | + $invoice = geodir_get_invoice($invoice_id); |
|
452 | + return (empty($invoice->invoice_id) ? $invoice->invoice_id : false); |
|
453 | 453 | } |
454 | 454 | |
455 | -function wpinv_to_gdp_recalculate_total( $invoice, $wpi_nosave ) { |
|
455 | +function wpinv_to_gdp_recalculate_total($invoice, $wpi_nosave) { |
|
456 | 456 | global $wpdb; |
457 | 457 | |
458 | - if ( !empty( $wpi_nosave ) ) { |
|
458 | + if (!empty($wpi_nosave)) { |
|
459 | 459 | return; |
460 | 460 | } |
461 | 461 | |
462 | - $gdp_invoice_id = wpinv_wpi_to_gdp_id( $invoice->ID ); |
|
462 | + $gdp_invoice_id = wpinv_wpi_to_gdp_id($invoice->ID); |
|
463 | 463 | |
464 | - if ( $gdp_invoice_id > 0 ) { |
|
464 | + if ($gdp_invoice_id > 0) { |
|
465 | 465 | $update_data = array(); |
466 | 466 | $update_data['tax_amount'] = $invoice->tax; |
467 | 467 | $update_data['paied_amount'] = $invoice->total; |
468 | 468 | $update_data['discount'] = $invoice->discount; |
469 | 469 | $update_data['coupon_code'] = $invoice->discount_code; |
470 | 470 | |
471 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $gdp_invoice_id ) ); |
|
471 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $gdp_invoice_id)); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | return; |
475 | 475 | } |
476 | 476 | //add_action( 'wpinv_invoice_recalculate_total', 'wpinv_to_gdp_recalculate_total', 10, 2 ); |
477 | 477 | |
478 | -function wpinv_gdp_to_wpi_invoice( $invoice_id ) { |
|
479 | - $invoice = geodir_get_invoice( $invoice_id ); |
|
480 | - if ( empty( $invoice->invoice_id ) ) { |
|
478 | +function wpinv_gdp_to_wpi_invoice($invoice_id) { |
|
479 | + $invoice = geodir_get_invoice($invoice_id); |
|
480 | + if (empty($invoice->invoice_id)) { |
|
481 | 481 | return false; |
482 | 482 | } |
483 | 483 | |
484 | - return wpinv_get_invoice( $invoice->invoice_id ); |
|
484 | + return wpinv_get_invoice($invoice->invoice_id); |
|
485 | 485 | } |
486 | 486 | |
487 | -function wpinv_payment_set_coupon_code( $status, $invoice_id, $coupon_code ) { |
|
488 | - $invoice = wpinv_gdp_to_wpi_invoice( $invoice_id ); |
|
489 | - if ( empty( $invoice ) ) { |
|
487 | +function wpinv_payment_set_coupon_code($status, $invoice_id, $coupon_code) { |
|
488 | + $invoice = wpinv_gdp_to_wpi_invoice($invoice_id); |
|
489 | + if (empty($invoice)) { |
|
490 | 490 | return $status; |
491 | 491 | } |
492 | 492 | |
493 | - if ( $status === 1 || $status === 0 ) { |
|
494 | - if ( $status === 1 ) { |
|
495 | - $discount = geodir_get_discount_amount( $coupon_code, $invoice->get_subtotal() ); |
|
493 | + if ($status === 1 || $status === 0) { |
|
494 | + if ($status === 1) { |
|
495 | + $discount = geodir_get_discount_amount($coupon_code, $invoice->get_subtotal()); |
|
496 | 496 | } else { |
497 | 497 | $discount = ''; |
498 | 498 | $coupon_code = ''; |
499 | 499 | } |
500 | 500 | |
501 | - $invoice->set( 'discount', $discount ); |
|
502 | - $invoice->set( 'discount_code', $coupon_code ); |
|
501 | + $invoice->set('discount', $discount); |
|
502 | + $invoice->set('discount_code', $coupon_code); |
|
503 | 503 | $invoice->save(); |
504 | 504 | $invoice->recalculate_total(); |
505 | 505 | } |
506 | 506 | |
507 | 507 | return $status; |
508 | 508 | } |
509 | -add_filter( 'geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3 ); |
|
509 | +add_filter('geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3); |
|
510 | 510 | |
511 | 511 | function wpinv_merge_gd_invoices() { |
512 | 512 | if (!defined('GEODIRPAYMENT_VERSION')) { |
@@ -514,157 +514,157 @@ discard block |
||
514 | 514 | } |
515 | 515 | ?> |
516 | 516 | <tr> |
517 | - <td><?php _e( 'Merge Price Packages', 'invoicing' ); ?></td> |
|
518 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing' ); ?></p></td> |
|
519 | - <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
517 | + <td><?php _e('Merge Price Packages', 'invoicing'); ?></td> |
|
518 | + <td><p><?php _e('Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing'); ?></p></td> |
|
519 | + <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
520 | 520 | </tr> |
521 | 521 | <tr> |
522 | - <td><?php _e( 'Merge Invoices', 'invoicing' ); ?></td> |
|
523 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing' ); ?></p></td> |
|
524 | - <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
522 | + <td><?php _e('Merge Invoices', 'invoicing'); ?></td> |
|
523 | + <td><p><?php _e('Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing'); ?></p></td> |
|
524 | + <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
525 | 525 | </tr> |
526 | 526 | <tr> |
527 | - <td><?php _e( 'Fix Taxes for Merged Invoices', 'invoicing' ); ?></td> |
|
528 | - <td><p><?php _e( 'Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing' ); ?></p></td> |
|
529 | - <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
527 | + <td><?php _e('Fix Taxes for Merged Invoices', 'invoicing'); ?></td> |
|
528 | + <td><p><?php _e('Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing'); ?></p></td> |
|
529 | + <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
530 | 530 | </tr> |
531 | 531 | <tr> |
532 | - <td><?php _e( 'Merge Coupons', 'invoicing' ); ?></td> |
|
533 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing' ); ?></p></td> |
|
534 | - <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
532 | + <td><?php _e('Merge Coupons', 'invoicing'); ?></td> |
|
533 | + <td><p><?php _e('Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing'); ?></p></td> |
|
534 | + <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
535 | 535 | </tr> |
536 | 536 | <?php |
537 | 537 | } |
538 | -add_action( 'wpinv_tools_row', 'wpinv_merge_gd_invoices', 10 ); |
|
538 | +add_action('wpinv_tools_row', 'wpinv_merge_gd_invoices', 10); |
|
539 | 539 | |
540 | 540 | function wpinv_tool_merge_packages() { |
541 | 541 | $packages = geodir_package_list_info(); |
542 | 542 | |
543 | 543 | $count = 0; |
544 | 544 | |
545 | - if ( !empty( $packages ) ) { |
|
545 | + if (!empty($packages)) { |
|
546 | 546 | $success = true; |
547 | 547 | |
548 | - foreach ( $packages as $key => $package ) { |
|
548 | + foreach ($packages as $key => $package) { |
|
549 | 549 | $item = wpinv_get_item_by('custom_id', $package->pid, 'package'); |
550 | - if ( !empty( $item ) ) { |
|
550 | + if (!empty($item)) { |
|
551 | 551 | continue; |
552 | 552 | } |
553 | 553 | |
554 | - $merged = wpinv_merge_gd_package_to_item( $package->pid, false, $package ); |
|
554 | + $merged = wpinv_merge_gd_package_to_item($package->pid, false, $package); |
|
555 | 555 | |
556 | - if ( !empty( $merged ) ) { |
|
557 | - wpinv_error_log( 'Package merge S : ' . $package->pid ); |
|
556 | + if (!empty($merged)) { |
|
557 | + wpinv_error_log('Package merge S : ' . $package->pid); |
|
558 | 558 | $count++; |
559 | 559 | } else { |
560 | - wpinv_error_log( 'Package merge F : ' . $package->pid ); |
|
560 | + wpinv_error_log('Package merge F : ' . $package->pid); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | |
564 | - if ( $count > 0 ) { |
|
565 | - $message = sprintf( _n( 'Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing' ), $count ); |
|
564 | + if ($count > 0) { |
|
565 | + $message = sprintf(_n('Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing'), $count); |
|
566 | 566 | } else { |
567 | - $message = __( 'No price packages merged.', 'invoicing' ); |
|
567 | + $message = __('No price packages merged.', 'invoicing'); |
|
568 | 568 | } |
569 | 569 | } else { |
570 | 570 | $success = false; |
571 | - $message = __( 'No price packages found to merge!', 'invoicing' ); |
|
571 | + $message = __('No price packages found to merge!', 'invoicing'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | $response = array(); |
575 | 575 | $response['success'] = $success; |
576 | 576 | $response['data']['message'] = $message; |
577 | - wp_send_json( $response ); |
|
577 | + wp_send_json($response); |
|
578 | 578 | } |
579 | -add_action( 'wpinv_tool_merge_packages', 'wpinv_tool_merge_packages' ); |
|
579 | +add_action('wpinv_tool_merge_packages', 'wpinv_tool_merge_packages'); |
|
580 | 580 | |
581 | 581 | function wpinv_tool_merge_invoices() { |
582 | 582 | global $wpdb, $wpi_gdp_inv_merge, $wpi_tax_rates; |
583 | 583 | |
584 | 584 | $sql = "SELECT `gdi`.`id`, `gdi`.`date`, `gdi`.`date_updated` FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NULL ORDER BY `gdi`.`id` ASC"; |
585 | 585 | |
586 | - $items = $wpdb->get_results( $sql ); |
|
586 | + $items = $wpdb->get_results($sql); |
|
587 | 587 | |
588 | 588 | $count = 0; |
589 | 589 | |
590 | - if ( !empty( $items ) ) { |
|
590 | + if (!empty($items)) { |
|
591 | 591 | $success = true; |
592 | 592 | $wpi_gdp_inv_merge = true; |
593 | 593 | |
594 | - foreach ( $items as $item ) { |
|
594 | + foreach ($items as $item) { |
|
595 | 595 | $wpi_tax_rates = NULL; |
596 | 596 | |
597 | - $wpdb->query( "UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'" ); |
|
597 | + $wpdb->query("UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'"); |
|
598 | 598 | |
599 | - $merged = wpinv_cpt_save( $item->id ); |
|
599 | + $merged = wpinv_cpt_save($item->id); |
|
600 | 600 | |
601 | - if ( !empty( $merged ) && !empty( $merged->ID ) ) { |
|
601 | + if (!empty($merged) && !empty($merged->ID)) { |
|
602 | 602 | $count++; |
603 | 603 | |
604 | - $post_date = !empty( $item->date ) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time( 'mysql' ); |
|
605 | - $post_date_gmt = get_gmt_from_date( $post_date ); |
|
606 | - $post_modified = !empty( $item->date_updated ) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date; |
|
607 | - $post_modified_gmt = get_gmt_from_date( $post_modified ); |
|
604 | + $post_date = !empty($item->date) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time('mysql'); |
|
605 | + $post_date_gmt = get_gmt_from_date($post_date); |
|
606 | + $post_modified = !empty($item->date_updated) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date; |
|
607 | + $post_modified_gmt = get_gmt_from_date($post_modified); |
|
608 | 608 | |
609 | - $wpdb->update( $wpdb->posts, array( 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt ), array( 'ID' => $merged->ID ) ); |
|
609 | + $wpdb->update($wpdb->posts, array('post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt), array('ID' => $merged->ID)); |
|
610 | 610 | |
611 | - if ( $merged->is_paid() ) { |
|
612 | - update_post_meta( $merged->ID, '_wpinv_completed_date', $post_modified ); |
|
611 | + if ($merged->is_paid()) { |
|
612 | + update_post_meta($merged->ID, '_wpinv_completed_date', $post_modified); |
|
613 | 613 | } |
614 | 614 | |
615 | - clean_post_cache( $merged->ID ); |
|
615 | + clean_post_cache($merged->ID); |
|
616 | 616 | |
617 | - wpinv_error_log( 'Invoice merge S : ' . $item->id . ' => ' . $merged->ID ); |
|
617 | + wpinv_error_log('Invoice merge S : ' . $item->id . ' => ' . $merged->ID); |
|
618 | 618 | } else { |
619 | - wpinv_error_log( 'Invoice merge F : ' . $item->id ); |
|
619 | + wpinv_error_log('Invoice merge F : ' . $item->id); |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 | |
623 | 623 | $wpi_gdp_inv_merge = false; |
624 | 624 | |
625 | - if ( $count > 0 ) { |
|
626 | - $message = sprintf( _n( 'Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing' ), $count ); |
|
625 | + if ($count > 0) { |
|
626 | + $message = sprintf(_n('Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing'), $count); |
|
627 | 627 | } else { |
628 | - $message = __( 'No invoices merged.', 'invoicing' ); |
|
628 | + $message = __('No invoices merged.', 'invoicing'); |
|
629 | 629 | } |
630 | 630 | } else { |
631 | 631 | $success = false; |
632 | - $message = __( 'No invoices found to merge!', 'invoicing' ); |
|
632 | + $message = __('No invoices found to merge!', 'invoicing'); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | $response = array(); |
636 | 636 | $response['success'] = $success; |
637 | 637 | $response['data']['message'] = $message; |
638 | - wp_send_json( $response ); |
|
638 | + wp_send_json($response); |
|
639 | 639 | } |
640 | -add_action( 'wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices' ); |
|
640 | +add_action('wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices'); |
|
641 | 641 | |
642 | 642 | function wpinv_tool_merge_coupons() { |
643 | 643 | global $wpdb; |
644 | 644 | |
645 | 645 | $sql = "SELECT * FROM `" . COUPON_TABLE . "` WHERE `coupon_code` IS NOT NULL AND `coupon_code` != '' ORDER BY `cid` ASC"; |
646 | - $items = $wpdb->get_results( $sql ); |
|
646 | + $items = $wpdb->get_results($sql); |
|
647 | 647 | $count = 0; |
648 | 648 | |
649 | - if ( !empty( $items ) ) { |
|
649 | + if (!empty($items)) { |
|
650 | 650 | $success = true; |
651 | 651 | |
652 | - foreach ( $items as $item ) { |
|
653 | - if ( wpinv_get_discount_by_code( $item->coupon_code ) ) { |
|
652 | + foreach ($items as $item) { |
|
653 | + if (wpinv_get_discount_by_code($item->coupon_code)) { |
|
654 | 654 | continue; |
655 | 655 | } |
656 | 656 | |
657 | 657 | $args = array( |
658 | 658 | 'post_type' => 'wpi_discount', |
659 | 659 | 'post_title' => $item->coupon_code, |
660 | - 'post_status' => !empty( $item->status ) ? 'publish' : 'pending' |
|
660 | + 'post_status' => !empty($item->status) ? 'publish' : 'pending' |
|
661 | 661 | ); |
662 | 662 | |
663 | - $merged = wp_insert_post( $args ); |
|
663 | + $merged = wp_insert_post($args); |
|
664 | 664 | |
665 | 665 | $item_id = $item->cid; |
666 | 666 | |
667 | - if ( $merged ) { |
|
667 | + if ($merged) { |
|
668 | 668 | $meta = array( |
669 | 669 | 'code' => $item->coupon_code, |
670 | 670 | 'type' => $item->discount_type != 'per' ? 'flat' : 'percent', |
@@ -672,65 +672,65 @@ discard block |
||
672 | 672 | 'max_uses' => (int)$item->usage_limit, |
673 | 673 | 'uses' => (int)$item->usage_count, |
674 | 674 | ); |
675 | - wpinv_store_discount( $merged, $meta, get_post( $merged ) ); |
|
675 | + wpinv_store_discount($merged, $meta, get_post($merged)); |
|
676 | 676 | |
677 | 677 | $count++; |
678 | 678 | |
679 | - wpinv_error_log( 'Coupon merge S : ' . $item_id . ' => ' . $merged ); |
|
679 | + wpinv_error_log('Coupon merge S : ' . $item_id . ' => ' . $merged); |
|
680 | 680 | } else { |
681 | - wpinv_error_log( 'Coupon merge F : ' . $item_id ); |
|
681 | + wpinv_error_log('Coupon merge F : ' . $item_id); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 | |
685 | - if ( $count > 0 ) { |
|
686 | - $message = sprintf( _n( 'Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing' ), $count ); |
|
685 | + if ($count > 0) { |
|
686 | + $message = sprintf(_n('Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing'), $count); |
|
687 | 687 | } else { |
688 | - $message = __( 'No coupons merged.', 'invoicing' ); |
|
688 | + $message = __('No coupons merged.', 'invoicing'); |
|
689 | 689 | } |
690 | 690 | } else { |
691 | 691 | $success = false; |
692 | - $message = __( 'No coupons found to merge!', 'invoicing' ); |
|
692 | + $message = __('No coupons found to merge!', 'invoicing'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | $response = array(); |
696 | 696 | $response['success'] = $success; |
697 | 697 | $response['data']['message'] = $message; |
698 | - wp_send_json( $response ); |
|
698 | + wp_send_json($response); |
|
699 | 699 | } |
700 | -add_action( 'wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons' ); |
|
700 | +add_action('wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons'); |
|
701 | 701 | |
702 | -function wpinv_gdp_to_wpi_currency( $value, $option = '' ) { |
|
702 | +function wpinv_gdp_to_wpi_currency($value, $option = '') { |
|
703 | 703 | return wpinv_get_currency(); |
704 | 704 | } |
705 | -add_filter( 'pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2 ); |
|
705 | +add_filter('pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2); |
|
706 | 706 | |
707 | -function wpinv_gdp_to_wpi_currency_sign( $value, $option = '' ) { |
|
707 | +function wpinv_gdp_to_wpi_currency_sign($value, $option = '') { |
|
708 | 708 | return wpinv_currency_symbol(); |
709 | 709 | } |
710 | -add_filter( 'pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2 ); |
|
710 | +add_filter('pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2); |
|
711 | 711 | |
712 | -function wpinv_gdp_to_wpi_display_price( $price, $amount, $display = true , $decimal_sep, $thousand_sep ) { |
|
713 | - if ( !$display ) { |
|
714 | - $price = wpinv_round_amount( $amount ); |
|
712 | +function wpinv_gdp_to_wpi_display_price($price, $amount, $display = true, $decimal_sep, $thousand_sep) { |
|
713 | + if (!$display) { |
|
714 | + $price = wpinv_round_amount($amount); |
|
715 | 715 | } else { |
716 | - $price = wpinv_price( wpinv_format_amount( $amount ) ); |
|
716 | + $price = wpinv_price(wpinv_format_amount($amount)); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | return $price; |
720 | 720 | } |
721 | -add_filter( 'geodir_payment_price' , 'wpinv_gdp_to_wpi_display_price', 10000, 5 ); |
|
721 | +add_filter('geodir_payment_price', 'wpinv_gdp_to_wpi_display_price', 10000, 5); |
|
722 | 722 | |
723 | -function wpinv_gdp_to_inv_checkout_redirect( $redirect_url ) { |
|
723 | +function wpinv_gdp_to_inv_checkout_redirect($redirect_url) { |
|
724 | 724 | $invoice_id = geodir_payment_cart_id(); |
725 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
726 | - $wpi_invoice = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL; |
|
725 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
726 | + $wpi_invoice = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL; |
|
727 | 727 | |
728 | - if ( !( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) ) { |
|
729 | - $wpi_invoice_id = wpinv_cpt_save( $invoice_id ); |
|
730 | - $wpi_invoice = wpinv_get_invoice( $wpi_invoice_id ); |
|
728 | + if (!(!empty($wpi_invoice) && !empty($wpi_invoice->ID))) { |
|
729 | + $wpi_invoice_id = wpinv_cpt_save($invoice_id); |
|
730 | + $wpi_invoice = wpinv_get_invoice($wpi_invoice_id); |
|
731 | 731 | } |
732 | 732 | |
733 | - if ( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) { |
|
733 | + if (!empty($wpi_invoice) && !empty($wpi_invoice->ID)) { |
|
734 | 734 | |
735 | 735 | // Clear cart |
736 | 736 | geodir_payment_clear_cart(); |
@@ -740,121 +740,121 @@ discard block |
||
740 | 740 | |
741 | 741 | return $redirect_url; |
742 | 742 | } |
743 | -add_filter( 'geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1 ); |
|
743 | +add_filter('geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1); |
|
744 | 744 | |
745 | -function wpinv_gdp_dashboard_invoice_history_link( $dashboard_links ) { |
|
746 | - if ( get_current_user_id() ) { |
|
747 | - $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url( wpinv_get_history_page_uri() ) . '">' . __( 'My Invoice History', 'invoicing' ) . '</a></li>'; |
|
745 | +function wpinv_gdp_dashboard_invoice_history_link($dashboard_links) { |
|
746 | + if (get_current_user_id()) { |
|
747 | + $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url(wpinv_get_history_page_uri()) . '">' . __('My Invoice History', 'invoicing') . '</a></li>'; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | return $dashboard_links; |
751 | 751 | } |
752 | -add_action( 'geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link' ); |
|
753 | -remove_action( 'geodir_dashboard_links', 'geodir_payment_invoices_list_page_link' ); |
|
752 | +add_action('geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link'); |
|
753 | +remove_action('geodir_dashboard_links', 'geodir_payment_invoices_list_page_link'); |
|
754 | 754 | |
755 | -function wpinv_wpi_to_gdp_update_status( $invoice_id, $new_status, $old_status ) { |
|
755 | +function wpinv_wpi_to_gdp_update_status($invoice_id, $new_status, $old_status) { |
|
756 | 756 | if (!defined('GEODIRPAYMENT_VERSION')) { |
757 | 757 | return false; |
758 | 758 | } |
759 | 759 | |
760 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
761 | - if ( empty( $invoice ) ) { |
|
760 | + $invoice = wpinv_get_invoice($invoice_id); |
|
761 | + if (empty($invoice)) { |
|
762 | 762 | return false; |
763 | 763 | } |
764 | 764 | |
765 | - remove_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 ); |
|
765 | + remove_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4); |
|
766 | 766 | |
767 | - $invoice_id = wpinv_wpi_to_gdp_id( $invoice_id ); |
|
768 | - $new_status = wpinv_wpi_to_gdp_status( $new_status ); |
|
767 | + $invoice_id = wpinv_wpi_to_gdp_id($invoice_id); |
|
768 | + $new_status = wpinv_wpi_to_gdp_status($new_status); |
|
769 | 769 | |
770 | - geodir_update_invoice_status( $invoice_id, $new_status, $invoice->is_recurring() ); |
|
770 | + geodir_update_invoice_status($invoice_id, $new_status, $invoice->is_recurring()); |
|
771 | 771 | } |
772 | -add_action( 'wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3 ); |
|
772 | +add_action('wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3); |
|
773 | 773 | |
774 | -function wpinv_gdp_to_wpi_delete_package( $gd_package_id ) { |
|
775 | - $item = wpinv_get_item_by( 'custom_id', $gd_package_id, 'package' ); |
|
774 | +function wpinv_gdp_to_wpi_delete_package($gd_package_id) { |
|
775 | + $item = wpinv_get_item_by('custom_id', $gd_package_id, 'package'); |
|
776 | 776 | |
777 | - if ( !empty( $item ) ) { |
|
778 | - wpinv_remove_item( $item, true ); |
|
777 | + if (!empty($item)) { |
|
778 | + wpinv_remove_item($item, true); |
|
779 | 779 | } |
780 | 780 | } |
781 | -add_action( 'geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1 ) ; |
|
781 | +add_action('geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1); |
|
782 | 782 | |
783 | -function wpinv_can_delete_package_item( $return, $post_id ) { |
|
784 | - if ( $return && function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && $package_id = get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
785 | - $gd_package = geodir_get_package_info_by_id( $package_id, '' ); |
|
783 | +function wpinv_can_delete_package_item($return, $post_id) { |
|
784 | + if ($return && function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && $package_id = get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
785 | + $gd_package = geodir_get_package_info_by_id($package_id, ''); |
|
786 | 786 | |
787 | - if ( !empty( $gd_package ) ) { |
|
787 | + if (!empty($gd_package)) { |
|
788 | 788 | $return = false; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | 792 | return $return; |
793 | 793 | } |
794 | -add_filter( 'wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2 ); |
|
794 | +add_filter('wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2); |
|
795 | 795 | |
796 | -function wpinv_package_item_classes( $classes, $class, $post_id ) { |
|
796 | +function wpinv_package_item_classes($classes, $class, $post_id) { |
|
797 | 797 | global $typenow; |
798 | 798 | |
799 | - if ( $typenow == 'wpi_item' && in_array( 'wpi-gd-package', $classes ) ) { |
|
800 | - if ( wpinv_item_in_use( $post_id ) ) { |
|
799 | + if ($typenow == 'wpi_item' && in_array('wpi-gd-package', $classes)) { |
|
800 | + if (wpinv_item_in_use($post_id)) { |
|
801 | 801 | $classes[] = 'wpi-inuse-pkg'; |
802 | - } else if ( !( function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && geodir_get_package_info_by_id( (int)get_post_meta( $post_id, '_wpinv_custom_id', true ), '' ) ) ) { |
|
802 | + } else if (!(function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && geodir_get_package_info_by_id((int)get_post_meta($post_id, '_wpinv_custom_id', true), ''))) { |
|
803 | 803 | $classes[] = 'wpi-delete-pkg'; |
804 | 804 | } |
805 | 805 | } |
806 | 806 | |
807 | 807 | return $classes; |
808 | 808 | } |
809 | -add_filter( 'post_class', 'wpinv_package_item_classes', 10, 3 ); |
|
809 | +add_filter('post_class', 'wpinv_package_item_classes', 10, 3); |
|
810 | 810 | |
811 | -function wpinv_gdp_package_type_info( $post ) { |
|
812 | - if ( wpinv_pm_active() ) { |
|
813 | - ?><p class="wpi-m0"><?php _e( 'Package: GeoDirectory price packages items.', 'invoicing' );?></p> |
|
811 | +function wpinv_gdp_package_type_info($post) { |
|
812 | + if (wpinv_pm_active()) { |
|
813 | + ?><p class="wpi-m0"><?php _e('Package: GeoDirectory price packages items.', 'invoicing'); ?></p> |
|
814 | 814 | <?php |
815 | 815 | } |
816 | 816 | } |
817 | -add_action( 'wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1 ) ; |
|
817 | +add_action('wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1); |
|
818 | 818 | |
819 | -function wpinv_gdp_to_gdi_set_zero_tax( $is_taxable, $item_id, $country , $state ) { |
|
819 | +function wpinv_gdp_to_gdi_set_zero_tax($is_taxable, $item_id, $country, $state) { |
|
820 | 820 | global $wpi_zero_tax; |
821 | 821 | |
822 | - if ( $wpi_zero_tax ) { |
|
822 | + if ($wpi_zero_tax) { |
|
823 | 823 | $is_taxable = false; |
824 | 824 | } |
825 | 825 | |
826 | 826 | return $is_taxable; |
827 | 827 | } |
828 | -add_action( 'wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4 ) ; |
|
828 | +add_action('wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4); |
|
829 | 829 | |
830 | 830 | function wpinv_tool_merge_fix_taxes() { |
831 | 831 | global $wpdb; |
832 | 832 | |
833 | 833 | $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
834 | - $items = $wpdb->get_results( $sql ); |
|
834 | + $items = $wpdb->get_results($sql); |
|
835 | 835 | |
836 | - if ( !empty( $items ) ) { |
|
837 | - foreach ( $items as $item ) { |
|
838 | - if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
839 | - update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
836 | + if (!empty($items)) { |
|
837 | + foreach ($items as $item) { |
|
838 | + if (get_post_meta($item->ID, '_wpinv_vat_class', true) == '_exempt') { |
|
839 | + update_post_meta($item->ID, '_wpinv_vat_class', '_standard'); |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | } |
843 | 843 | |
844 | 844 | $sql = "SELECT `p`.`ID`, gdi.id AS gdp_id FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NOT NULL AND p.post_status NOT IN( 'publish', 'wpi-processing', 'wpi-renewal' ) ORDER BY `gdi`.`id` ASC"; |
845 | - $items = $wpdb->get_results( $sql ); |
|
845 | + $items = $wpdb->get_results($sql); |
|
846 | 846 | |
847 | - if ( !empty( $items ) ) { |
|
847 | + if (!empty($items)) { |
|
848 | 848 | $success = false; |
849 | - $message = __( 'Taxes fixed for non-paid merged GD invoices.', 'invoicing' ); |
|
849 | + $message = __('Taxes fixed for non-paid merged GD invoices.', 'invoicing'); |
|
850 | 850 | |
851 | 851 | global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
852 | 852 | |
853 | - foreach ( $items as $item ) { |
|
853 | + foreach ($items as $item) { |
|
854 | 854 | $wpi_tax_rates = NULL; |
855 | 855 | $data = wpinv_get_invoice($item->ID); |
856 | 856 | |
857 | - if ( empty( $data ) ) { |
|
857 | + if (empty($data)) { |
|
858 | 858 | continue; |
859 | 859 | } |
860 | 860 | |
@@ -862,51 +862,51 @@ discard block |
||
862 | 862 | |
863 | 863 | $data_session = array(); |
864 | 864 | $data_session['invoice_id'] = $data->ID; |
865 | - $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
865 | + $data_session['cart_discounts'] = $data->get_discounts(true); |
|
866 | 866 | |
867 | - wpinv_set_checkout_session( $data_session ); |
|
867 | + wpinv_set_checkout_session($data_session); |
|
868 | 868 | |
869 | 869 | $wpi_userID = (int)$data->get_user_id(); |
870 | 870 | $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
871 | 871 | |
872 | - $data->country = sanitize_text_field( $_POST['country'] ); |
|
873 | - $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
872 | + $data->country = sanitize_text_field($_POST['country']); |
|
873 | + $data->set('country', sanitize_text_field($_POST['country'])); |
|
874 | 874 | |
875 | 875 | $wpinv_ip_address_country = $data->country; |
876 | 876 | |
877 | 877 | $data->recalculate_totals(true); |
878 | 878 | |
879 | - wpinv_set_checkout_session( $checkout_session ); |
|
879 | + wpinv_set_checkout_session($checkout_session); |
|
880 | 880 | |
881 | 881 | $update_data = array(); |
882 | 882 | $update_data['tax_amount'] = $data->get_tax(); |
883 | 883 | $update_data['paied_amount'] = $data->get_total(); |
884 | 884 | $update_data['invoice_id'] = $data->ID; |
885 | 885 | |
886 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
886 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $item->gdp_id)); |
|
887 | 887 | } |
888 | 888 | } else { |
889 | 889 | $success = false; |
890 | - $message = __( 'No invoices found to fix taxes!', 'invoicing' ); |
|
890 | + $message = __('No invoices found to fix taxes!', 'invoicing'); |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | $response = array(); |
894 | 894 | $response['success'] = $success; |
895 | 895 | $response['data']['message'] = $message; |
896 | - wp_send_json( $response ); |
|
896 | + wp_send_json($response); |
|
897 | 897 | } |
898 | -add_action( 'wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes' ); |
|
899 | -remove_action( 'geodir_before_detail_fields' , 'geodir_build_coupon', 2 ); |
|
898 | +add_action('wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes'); |
|
899 | +remove_action('geodir_before_detail_fields', 'geodir_build_coupon', 2); |
|
900 | 900 | |
901 | -function wpinv_wpi_to_gdp_handle_subscription_cancel( $invoice_id, $invoice ) { |
|
902 | - if ( wpinv_pm_active() && !empty( $invoice ) && $invoice->is_recurring() ) { |
|
903 | - if ( $invoice->is_renewal() ) { |
|
901 | +function wpinv_wpi_to_gdp_handle_subscription_cancel($invoice_id, $invoice) { |
|
902 | + if (wpinv_pm_active() && !empty($invoice) && $invoice->is_recurring()) { |
|
903 | + if ($invoice->is_renewal()) { |
|
904 | 904 | $invoice = $invoice->get_parent_payment(); |
905 | 905 | } |
906 | 906 | |
907 | - if ( !empty( $invoice ) ) { |
|
908 | - wpinv_wpi_to_gdp_update_status( $invoice->ID, 'wpi-cancelled', $invoice->get_status() ); |
|
907 | + if (!empty($invoice)) { |
|
908 | + wpinv_wpi_to_gdp_update_status($invoice->ID, 'wpi-cancelled', $invoice->get_status()); |
|
909 | 909 | } |
910 | 910 | } |
911 | 911 | } |
912 | -add_action( 'wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2 ); |
|
913 | 912 | \ No newline at end of file |
913 | +add_action('wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2); |
|
914 | 914 | \ No newline at end of file |
@@ -121,29 +121,29 @@ discard block |
||
121 | 121 | |
122 | 122 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
123 | 123 | if ( ! empty( $args ) && is_array( $args ) ) { |
124 | - extract( $args ); |
|
125 | - } |
|
124 | + extract( $args ); |
|
125 | + } |
|
126 | 126 | |
127 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
128 | - // Allow 3rd party plugin filter template file from their plugin. |
|
129 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
127 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
128 | + // Allow 3rd party plugin filter template file from their plugin. |
|
129 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
130 | 130 | |
131 | - if ( ! file_exists( $located ) ) { |
|
131 | + if ( ! file_exists( $located ) ) { |
|
132 | 132 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
133 | - return; |
|
134 | - } |
|
133 | + return; |
|
134 | + } |
|
135 | 135 | |
136 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
136 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
137 | 137 | |
138 | - include( $located ); |
|
138 | + include( $located ); |
|
139 | 139 | |
140 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
140 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
144 | - ob_start(); |
|
145 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
146 | - return ob_get_clean(); |
|
144 | + ob_start(); |
|
145 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
146 | + return ob_get_clean(); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -173,120 +173,120 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
176 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
176 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | 177 | |
178 | - // Setup possible parts |
|
179 | - $templates = array(); |
|
180 | - if ( isset( $name ) ) |
|
181 | - $templates[] = $slug . '-' . $name . '.php'; |
|
182 | - $templates[] = $slug . '.php'; |
|
178 | + // Setup possible parts |
|
179 | + $templates = array(); |
|
180 | + if ( isset( $name ) ) |
|
181 | + $templates[] = $slug . '-' . $name . '.php'; |
|
182 | + $templates[] = $slug . '.php'; |
|
183 | 183 | |
184 | - // Allow template parts to be filtered |
|
185 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
184 | + // Allow template parts to be filtered |
|
185 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
186 | 186 | |
187 | - // Return the part that is found |
|
188 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
187 | + // Return the part that is found |
|
188 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
192 | - // No file found yet |
|
193 | - $located = false; |
|
192 | + // No file found yet |
|
193 | + $located = false; |
|
194 | 194 | |
195 | - // Try to find a template file |
|
196 | - foreach ( (array)$template_names as $template_name ) { |
|
195 | + // Try to find a template file |
|
196 | + foreach ( (array)$template_names as $template_name ) { |
|
197 | 197 | |
198 | - // Continue if template is empty |
|
199 | - if ( empty( $template_name ) ) |
|
200 | - continue; |
|
198 | + // Continue if template is empty |
|
199 | + if ( empty( $template_name ) ) |
|
200 | + continue; |
|
201 | 201 | |
202 | - // Trim off any slashes from the template name |
|
203 | - $template_name = ltrim( $template_name, '/' ); |
|
202 | + // Trim off any slashes from the template name |
|
203 | + $template_name = ltrim( $template_name, '/' ); |
|
204 | 204 | |
205 | - // try locating this template file by looping through the template paths |
|
206 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
205 | + // try locating this template file by looping through the template paths |
|
206 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
207 | 207 | |
208 | - if( file_exists( $template_path . $template_name ) ) { |
|
209 | - $located = $template_path . $template_name; |
|
210 | - break; |
|
211 | - } |
|
212 | - } |
|
208 | + if( file_exists( $template_path . $template_name ) ) { |
|
209 | + $located = $template_path . $template_name; |
|
210 | + break; |
|
211 | + } |
|
212 | + } |
|
213 | 213 | |
214 | - if( !empty( $located ) ) { |
|
215 | - break; |
|
216 | - } |
|
217 | - } |
|
214 | + if( !empty( $located ) ) { |
|
215 | + break; |
|
216 | + } |
|
217 | + } |
|
218 | 218 | |
219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
220 | - load_template( $located, $require_once ); |
|
219 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
220 | + load_template( $located, $require_once ); |
|
221 | 221 | |
222 | - return $located; |
|
222 | + return $located; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | function wpinv_get_theme_template_paths() { |
226 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
226 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
227 | 227 | |
228 | - $file_paths = array( |
|
229 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
230 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | - 100 => wpinv_get_templates_dir() |
|
232 | - ); |
|
228 | + $file_paths = array( |
|
229 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
230 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 100 => wpinv_get_templates_dir() |
|
232 | + ); |
|
233 | 233 | |
234 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
234 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
235 | 235 | |
236 | - // sort the file paths based on priority |
|
237 | - ksort( $file_paths, SORT_NUMERIC ); |
|
236 | + // sort the file paths based on priority |
|
237 | + ksort( $file_paths, SORT_NUMERIC ); |
|
238 | 238 | |
239 | - return array_map( 'trailingslashit', $file_paths ); |
|
239 | + return array_map( 'trailingslashit', $file_paths ); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | function wpinv_get_theme_template_dir_name() { |
243 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
243 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | function wpinv_checkout_meta_tags() { |
247 | 247 | |
248 | - $pages = array(); |
|
249 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
248 | + $pages = array(); |
|
249 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
250 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
251 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
252 | 252 | |
253 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
254 | - return; |
|
255 | - } |
|
253 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
254 | + return; |
|
255 | + } |
|
256 | 256 | |
257 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
257 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
258 | 258 | } |
259 | 259 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
260 | 260 | |
261 | 261 | function wpinv_add_body_classes( $class ) { |
262 | - $classes = (array)$class; |
|
262 | + $classes = (array)$class; |
|
263 | 263 | |
264 | - if( wpinv_is_checkout() ) { |
|
265 | - $classes[] = 'wpinv-checkout'; |
|
266 | - $classes[] = 'wpinv-page'; |
|
267 | - } |
|
264 | + if( wpinv_is_checkout() ) { |
|
265 | + $classes[] = 'wpinv-checkout'; |
|
266 | + $classes[] = 'wpinv-page'; |
|
267 | + } |
|
268 | 268 | |
269 | - if( wpinv_is_success_page() ) { |
|
270 | - $classes[] = 'wpinv-success'; |
|
271 | - $classes[] = 'wpinv-page'; |
|
272 | - } |
|
269 | + if( wpinv_is_success_page() ) { |
|
270 | + $classes[] = 'wpinv-success'; |
|
271 | + $classes[] = 'wpinv-page'; |
|
272 | + } |
|
273 | 273 | |
274 | - if( wpinv_is_failed_transaction_page() ) { |
|
275 | - $classes[] = 'wpinv-failed-transaction'; |
|
276 | - $classes[] = 'wpinv-page'; |
|
277 | - } |
|
274 | + if( wpinv_is_failed_transaction_page() ) { |
|
275 | + $classes[] = 'wpinv-failed-transaction'; |
|
276 | + $classes[] = 'wpinv-page'; |
|
277 | + } |
|
278 | 278 | |
279 | - if( wpinv_is_invoice_history_page() ) { |
|
280 | - $classes[] = 'wpinv-history'; |
|
281 | - $classes[] = 'wpinv-page'; |
|
282 | - } |
|
279 | + if( wpinv_is_invoice_history_page() ) { |
|
280 | + $classes[] = 'wpinv-history'; |
|
281 | + $classes[] = 'wpinv-page'; |
|
282 | + } |
|
283 | 283 | |
284 | - if( wpinv_is_test_mode() ) { |
|
285 | - $classes[] = 'wpinv-test-mode'; |
|
286 | - $classes[] = 'wpinv-page'; |
|
287 | - } |
|
284 | + if( wpinv_is_test_mode() ) { |
|
285 | + $classes[] = 'wpinv-test-mode'; |
|
286 | + $classes[] = 'wpinv-page'; |
|
287 | + } |
|
288 | 288 | |
289 | - return array_unique( $classes ); |
|
289 | + return array_unique( $classes ); |
|
290 | 290 | } |
291 | 291 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
292 | 292 | |
@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1452 | 1452 | |
1453 | 1453 | function wpinv_empty_cart_message() { |
1454 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1454 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | /** |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | * @return void |
1462 | 1462 | */ |
1463 | 1463 | function wpinv_empty_checkout_cart() { |
1464 | - echo wpinv_empty_cart_message(); |
|
1464 | + echo wpinv_empty_cart_message(); |
|
1465 | 1465 | } |
1466 | 1466 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1467 | 1467 | |
@@ -1598,11 +1598,11 @@ discard block |
||
1598 | 1598 | do_action( 'wpinv_payment_mode_before_gateways' ); |
1599 | 1599 | |
1600 | 1600 | if(!empty($gateways)){ |
1601 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1602 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1603 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1604 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1605 | - ?> |
|
1601 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
1602 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1603 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1604 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
1605 | + ?> |
|
1606 | 1606 | <div class="list-group-item"> |
1607 | 1607 | <div class="radio"> |
1608 | 1608 | <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> |
@@ -1615,9 +1615,9 @@ discard block |
||
1615 | 1615 | </div> |
1616 | 1616 | </div> |
1617 | 1617 | <?php |
1618 | - } |
|
1618 | + } |
|
1619 | 1619 | }else{ |
1620 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1620 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | do_action( 'wpinv_payment_mode_after_gateways' ); |
@@ -140,6 +140,9 @@ discard block |
||
140 | 140 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
141 | 141 | } |
142 | 142 | |
143 | +/** |
|
144 | + * @param string $template_name |
|
145 | + */ |
|
143 | 146 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
144 | 147 | ob_start(); |
145 | 148 | wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
@@ -172,6 +175,9 @@ discard block |
||
172 | 175 | return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
173 | 176 | } |
174 | 177 | |
178 | +/** |
|
179 | + * @param string $slug |
|
180 | + */ |
|
175 | 181 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
176 | 182 | do_action( 'get_template_part_' . $slug, $slug, $name ); |
177 | 183 | |
@@ -871,6 +877,9 @@ discard block |
||
871 | 877 | return apply_filters( 'wpinv_get_watermark', $output, $id ); |
872 | 878 | } |
873 | 879 | |
880 | +/** |
|
881 | + * @param integer $id |
|
882 | + */ |
|
874 | 883 | function wpinv_get_watermark( $id ) { |
875 | 884 | if ( !$id > 0 ) { |
876 | 885 | return NULL; |
@@ -169,8 +169,9 @@ discard block |
||
169 | 169 | |
170 | 170 | // Setup possible parts |
171 | 171 | $templates = array(); |
172 | - if ( isset( $name ) ) |
|
173 | - $templates[] = $slug . '-' . $name . '.php'; |
|
172 | + if ( isset( $name ) ) { |
|
173 | + $templates[] = $slug . '-' . $name . '.php'; |
|
174 | + } |
|
174 | 175 | $templates[] = $slug . '.php'; |
175 | 176 | |
176 | 177 | // Allow template parts to be filtered |
@@ -188,8 +189,9 @@ discard block |
||
188 | 189 | foreach ( (array)$template_names as $template_name ) { |
189 | 190 | |
190 | 191 | // Continue if template is empty |
191 | - if ( empty( $template_name ) ) |
|
192 | - continue; |
|
192 | + if ( empty( $template_name ) ) { |
|
193 | + continue; |
|
194 | + } |
|
193 | 195 | |
194 | 196 | // Trim off any slashes from the template name |
195 | 197 | $template_name = ltrim( $template_name, '/' ); |
@@ -208,8 +210,9 @@ discard block |
||
208 | 210 | } |
209 | 211 | } |
210 | 212 | |
211 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
212 | - load_template( $located, $require_once ); |
|
213 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
214 | + load_template( $located, $require_once ); |
|
215 | + } |
|
213 | 216 | |
214 | 217 | return $located; |
215 | 218 | } |
@@ -285,8 +288,9 @@ discard block |
||
285 | 288 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
286 | 289 | $args = array( 'nopaging' => true ); |
287 | 290 | |
288 | - if ( ! empty( $status ) ) |
|
289 | - $args['post_status'] = $status; |
|
291 | + if ( ! empty( $status ) ) { |
|
292 | + $args['post_status'] = $status; |
|
293 | + } |
|
290 | 294 | |
291 | 295 | $discounts = wpinv_get_discounts( $args ); |
292 | 296 | $options = array(); |
@@ -893,8 +897,11 @@ discard block |
||
893 | 897 | |
894 | 898 | $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
895 | 899 | |
896 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
897 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
900 | + if($invoice->post_type == 'wpi_invoice') { |
|
901 | + $type = 'Invoice'; |
|
902 | + } elseif($invoice->post_type == 'wpi_quote') { |
|
903 | + $type = 'Quote'; |
|
904 | + } |
|
898 | 905 | ?> |
899 | 906 | <table class="table table-bordered table-sm"> |
900 | 907 | <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
@@ -1461,17 +1468,19 @@ discard block |
||
1461 | 1468 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1462 | 1469 | |
1463 | 1470 | function wpinv_save_cart_button() { |
1464 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1465 | - return; |
|
1466 | -?> |
|
1471 | + if ( wpinv_is_cart_saving_disabled() ) { |
|
1472 | + return; |
|
1473 | + } |
|
1474 | + ?> |
|
1467 | 1475 | <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> |
1468 | 1476 | <?php |
1469 | 1477 | } |
1470 | 1478 | |
1471 | 1479 | function wpinv_update_cart_button() { |
1472 | - if ( !wpinv_item_quantities_enabled() ) |
|
1473 | - return; |
|
1474 | -?> |
|
1480 | + if ( !wpinv_item_quantities_enabled() ) { |
|
1481 | + return; |
|
1482 | + } |
|
1483 | + ?> |
|
1475 | 1484 | <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
1476 | 1485 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1477 | 1486 | <?php |
@@ -1612,7 +1621,7 @@ discard block |
||
1612 | 1621 | </div> |
1613 | 1622 | <?php |
1614 | 1623 | } |
1615 | - }else{ |
|
1624 | + } else{ |
|
1616 | 1625 | echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
1617 | 1626 | } |
1618 | 1627 |
@@ -7,101 +7,101 @@ 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; // Exit if invoice is not set. |
56 | 56 | } |
57 | 57 | |
58 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
59 | - if ( $invoice->needs_payment() ) { |
|
60 | - ?> <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><?php |
|
58 | + if ($invoice->post_type == 'wpi_invoice') { |
|
59 | + if ($invoice->needs_payment()) { |
|
60 | + ?> <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><?php |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | do_action('wpinv_invoice_display_left_actions', $invoice); |
64 | 64 | } |
65 | 65 | |
66 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
67 | - if ( empty( $invoice ) ) { |
|
66 | +function wpinv_invoice_display_right_actions($invoice) { |
|
67 | + if (empty($invoice)) { |
|
68 | 68 | return; // Exit if invoice is not set. |
69 | 69 | } |
70 | 70 | |
71 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
72 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
73 | - <?php if ( is_user_logged_in() ) { ?> |
|
74 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
71 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
72 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
73 | + <?php if (is_user_logged_in()) { ?> |
|
74 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
75 | 75 | <?php } |
76 | 76 | } |
77 | 77 | do_action('wpinv_invoice_display_right_actions', $invoice); |
78 | 78 | } |
79 | 79 | |
80 | -function wpinv_before_invoice_content( $content ) { |
|
80 | +function wpinv_before_invoice_content($content) { |
|
81 | 81 | global $post; |
82 | 82 | |
83 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
83 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
84 | 84 | ob_start(); |
85 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
85 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
86 | 86 | $content = ob_get_clean() . $content; |
87 | 87 | } |
88 | 88 | |
89 | 89 | return $content; |
90 | 90 | } |
91 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
91 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
92 | 92 | |
93 | -function wpinv_after_invoice_content( $content ) { |
|
93 | +function wpinv_after_invoice_content($content) { |
|
94 | 94 | global $post; |
95 | 95 | |
96 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
96 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
97 | 97 | ob_start(); |
98 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
98 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
99 | 99 | $content .= ob_get_clean(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | return $content; |
103 | 103 | } |
104 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
104 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
105 | 105 | |
106 | 106 | function wpinv_get_templates_dir() { |
107 | 107 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -111,105 +111,105 @@ discard block |
||
111 | 111 | return WPINV_PLUGIN_URL . 'templates'; |
112 | 112 | } |
113 | 113 | |
114 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
115 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
116 | - extract( $args ); |
|
114 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
115 | + if (!empty($args) && is_array($args)) { |
|
116 | + extract($args); |
|
117 | 117 | } |
118 | 118 | |
119 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
119 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
120 | 120 | // Allow 3rd party plugin filter template file from their plugin. |
121 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
121 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
122 | 122 | |
123 | - if ( ! file_exists( $located ) ) { |
|
124 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
123 | + if (!file_exists($located)) { |
|
124 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
128 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
129 | 129 | |
130 | - include( $located ); |
|
130 | + include($located); |
|
131 | 131 | |
132 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
132 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
133 | 133 | } |
134 | 134 | |
135 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
135 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
136 | 136 | ob_start(); |
137 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
137 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
138 | 138 | return ob_get_clean(); |
139 | 139 | } |
140 | 140 | |
141 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
142 | - if ( ! $template_path ) { |
|
141 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
142 | + if (!$template_path) { |
|
143 | 143 | $template_path = wpinv_template_path(); |
144 | 144 | } |
145 | 145 | |
146 | - if ( ! $default_path ) { |
|
146 | + if (!$default_path) { |
|
147 | 147 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Look within passed path within the theme - this is priority. |
151 | 151 | $template = locate_template( |
152 | 152 | array( |
153 | - trailingslashit( $template_path ) . $template_name, |
|
153 | + trailingslashit($template_path) . $template_name, |
|
154 | 154 | $template_name |
155 | 155 | ) |
156 | 156 | ); |
157 | 157 | |
158 | 158 | // Get default templates/ |
159 | - if ( !$template && $default_path ) { |
|
160 | - $template = trailingslashit( $default_path ) . $template_name; |
|
159 | + if (!$template && $default_path) { |
|
160 | + $template = trailingslashit($default_path) . $template_name; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // Return what we found. |
164 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
164 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
165 | 165 | } |
166 | 166 | |
167 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
168 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
167 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
168 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
169 | 169 | |
170 | 170 | // Setup possible parts |
171 | 171 | $templates = array(); |
172 | - if ( isset( $name ) ) |
|
172 | + if (isset($name)) |
|
173 | 173 | $templates[] = $slug . '-' . $name . '.php'; |
174 | 174 | $templates[] = $slug . '.php'; |
175 | 175 | |
176 | 176 | // Allow template parts to be filtered |
177 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
177 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
178 | 178 | |
179 | 179 | // Return the part that is found |
180 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
180 | + return wpinv_locate_tmpl($templates, $load, false); |
|
181 | 181 | } |
182 | 182 | |
183 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
183 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
184 | 184 | // No file found yet |
185 | 185 | $located = false; |
186 | 186 | |
187 | 187 | // Try to find a template file |
188 | - foreach ( (array)$template_names as $template_name ) { |
|
188 | + foreach ((array)$template_names as $template_name) { |
|
189 | 189 | |
190 | 190 | // Continue if template is empty |
191 | - if ( empty( $template_name ) ) |
|
191 | + if (empty($template_name)) |
|
192 | 192 | continue; |
193 | 193 | |
194 | 194 | // Trim off any slashes from the template name |
195 | - $template_name = ltrim( $template_name, '/' ); |
|
195 | + $template_name = ltrim($template_name, '/'); |
|
196 | 196 | |
197 | 197 | // try locating this template file by looping through the template paths |
198 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
198 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
199 | 199 | |
200 | - if( file_exists( $template_path . $template_name ) ) { |
|
200 | + if (file_exists($template_path . $template_name)) { |
|
201 | 201 | $located = $template_path . $template_name; |
202 | 202 | break; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - if( !empty( $located ) ) { |
|
206 | + if (!empty($located)) { |
|
207 | 207 | break; |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
212 | - load_template( $located, $require_once ); |
|
211 | + if ((true == $load) && !empty($located)) |
|
212 | + load_template($located, $require_once); |
|
213 | 213 | |
214 | 214 | return $located; |
215 | 215 | } |
@@ -218,143 +218,143 @@ discard block |
||
218 | 218 | $template_dir = wpinv_get_theme_template_dir_name(); |
219 | 219 | |
220 | 220 | $file_paths = array( |
221 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
222 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
221 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
222 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
223 | 223 | 100 => wpinv_get_templates_dir() |
224 | 224 | ); |
225 | 225 | |
226 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
226 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
227 | 227 | |
228 | 228 | // sort the file paths based on priority |
229 | - ksort( $file_paths, SORT_NUMERIC ); |
|
229 | + ksort($file_paths, SORT_NUMERIC); |
|
230 | 230 | |
231 | - return array_map( 'trailingslashit', $file_paths ); |
|
231 | + return array_map('trailingslashit', $file_paths); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | function wpinv_get_theme_template_dir_name() { |
235 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
235 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'wpinv_templates')); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | function wpinv_checkout_meta_tags() { |
239 | 239 | |
240 | 240 | $pages = array(); |
241 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
242 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
243 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
241 | + $pages[] = wpinv_get_option('success_page'); |
|
242 | + $pages[] = wpinv_get_option('failure_page'); |
|
243 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
244 | 244 | |
245 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
245 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
246 | 246 | return; |
247 | 247 | } |
248 | 248 | |
249 | 249 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
250 | 250 | } |
251 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
251 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
252 | 252 | |
253 | -function wpinv_add_body_classes( $class ) { |
|
253 | +function wpinv_add_body_classes($class) { |
|
254 | 254 | $classes = (array)$class; |
255 | 255 | |
256 | - if( wpinv_is_checkout() ) { |
|
256 | + if (wpinv_is_checkout()) { |
|
257 | 257 | $classes[] = 'wpinv-checkout'; |
258 | 258 | $classes[] = 'wpinv-page'; |
259 | 259 | } |
260 | 260 | |
261 | - if( wpinv_is_success_page() ) { |
|
261 | + if (wpinv_is_success_page()) { |
|
262 | 262 | $classes[] = 'wpinv-success'; |
263 | 263 | $classes[] = 'wpinv-page'; |
264 | 264 | } |
265 | 265 | |
266 | - if( wpinv_is_failed_transaction_page() ) { |
|
266 | + if (wpinv_is_failed_transaction_page()) { |
|
267 | 267 | $classes[] = 'wpinv-failed-transaction'; |
268 | 268 | $classes[] = 'wpinv-page'; |
269 | 269 | } |
270 | 270 | |
271 | - if( wpinv_is_invoice_history_page() ) { |
|
271 | + if (wpinv_is_invoice_history_page()) { |
|
272 | 272 | $classes[] = 'wpinv-history'; |
273 | 273 | $classes[] = 'wpinv-page'; |
274 | 274 | } |
275 | 275 | |
276 | - if( wpinv_is_test_mode() ) { |
|
276 | + if (wpinv_is_test_mode()) { |
|
277 | 277 | $classes[] = 'wpinv-test-mode'; |
278 | 278 | $classes[] = 'wpinv-page'; |
279 | 279 | } |
280 | 280 | |
281 | - return array_unique( $classes ); |
|
281 | + return array_unique($classes); |
|
282 | 282 | } |
283 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
283 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
284 | 284 | |
285 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
286 | - $args = array( 'nopaging' => true ); |
|
285 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
286 | + $args = array('nopaging' => true); |
|
287 | 287 | |
288 | - if ( ! empty( $status ) ) |
|
288 | + if (!empty($status)) |
|
289 | 289 | $args['post_status'] = $status; |
290 | 290 | |
291 | - $discounts = wpinv_get_discounts( $args ); |
|
291 | + $discounts = wpinv_get_discounts($args); |
|
292 | 292 | $options = array(); |
293 | 293 | |
294 | - if ( $discounts ) { |
|
295 | - foreach ( $discounts as $discount ) { |
|
296 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
294 | + if ($discounts) { |
|
295 | + foreach ($discounts as $discount) { |
|
296 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
297 | 297 | } |
298 | 298 | } else { |
299 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
299 | + $options[0] = __('No discounts found', 'invoicing'); |
|
300 | 300 | } |
301 | 301 | |
302 | - $output = wpinv_html_select( array( |
|
302 | + $output = wpinv_html_select(array( |
|
303 | 303 | 'name' => $name, |
304 | 304 | 'selected' => $selected, |
305 | 305 | 'options' => $options, |
306 | 306 | 'show_option_all' => false, |
307 | 307 | 'show_option_none' => false, |
308 | - ) ); |
|
308 | + )); |
|
309 | 309 | |
310 | 310 | return $output; |
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
314 | - $current = date( 'Y' ); |
|
315 | - $start_year = $current - absint( $years_before ); |
|
316 | - $end_year = $current + absint( $years_after ); |
|
317 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
313 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
314 | + $current = date('Y'); |
|
315 | + $start_year = $current - absint($years_before); |
|
316 | + $end_year = $current + absint($years_after); |
|
317 | + $selected = empty($selected) ? date('Y') : $selected; |
|
318 | 318 | $options = array(); |
319 | 319 | |
320 | - while ( $start_year <= $end_year ) { |
|
321 | - $options[ absint( $start_year ) ] = $start_year; |
|
320 | + while ($start_year <= $end_year) { |
|
321 | + $options[absint($start_year)] = $start_year; |
|
322 | 322 | $start_year++; |
323 | 323 | } |
324 | 324 | |
325 | - $output = wpinv_html_select( array( |
|
325 | + $output = wpinv_html_select(array( |
|
326 | 326 | 'name' => $name, |
327 | 327 | 'selected' => $selected, |
328 | 328 | 'options' => $options, |
329 | 329 | 'show_option_all' => false, |
330 | 330 | 'show_option_none' => false |
331 | - ) ); |
|
331 | + )); |
|
332 | 332 | |
333 | 333 | return $output; |
334 | 334 | } |
335 | 335 | |
336 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
336 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
337 | 337 | $month = 1; |
338 | 338 | $options = array(); |
339 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
339 | + $selected = empty($selected) ? date('n') : $selected; |
|
340 | 340 | |
341 | - while ( $month <= 12 ) { |
|
342 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
341 | + while ($month <= 12) { |
|
342 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
343 | 343 | $month++; |
344 | 344 | } |
345 | 345 | |
346 | - $output = wpinv_html_select( array( |
|
346 | + $output = wpinv_html_select(array( |
|
347 | 347 | 'name' => $name, |
348 | 348 | 'selected' => $selected, |
349 | 349 | 'options' => $options, |
350 | 350 | 'show_option_all' => false, |
351 | 351 | 'show_option_none' => false |
352 | - ) ); |
|
352 | + )); |
|
353 | 353 | |
354 | 354 | return $output; |
355 | 355 | } |
356 | 356 | |
357 | -function wpinv_html_select( $args = array() ) { |
|
357 | +function wpinv_html_select($args = array()) { |
|
358 | 358 | $defaults = array( |
359 | 359 | 'options' => array(), |
360 | 360 | 'name' => null, |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | 'chosen' => false, |
365 | 365 | 'placeholder' => null, |
366 | 366 | 'multiple' => false, |
367 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
368 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
367 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
368 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
369 | 369 | 'data' => array(), |
370 | 370 | 'onchange' => null, |
371 | 371 | 'required' => false, |
@@ -373,78 +373,78 @@ discard block |
||
373 | 373 | 'readonly' => false, |
374 | 374 | ); |
375 | 375 | |
376 | - $args = wp_parse_args( $args, $defaults ); |
|
376 | + $args = wp_parse_args($args, $defaults); |
|
377 | 377 | |
378 | 378 | $data_elements = ''; |
379 | - foreach ( $args['data'] as $key => $value ) { |
|
380 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
379 | + foreach ($args['data'] as $key => $value) { |
|
380 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
381 | 381 | } |
382 | 382 | |
383 | - if( $args['multiple'] ) { |
|
383 | + if ($args['multiple']) { |
|
384 | 384 | $multiple = ' MULTIPLE'; |
385 | 385 | } else { |
386 | 386 | $multiple = ''; |
387 | 387 | } |
388 | 388 | |
389 | - if( $args['chosen'] ) { |
|
389 | + if ($args['chosen']) { |
|
390 | 390 | $args['class'] .= ' wpinv-select-chosen'; |
391 | 391 | } |
392 | 392 | |
393 | - if( $args['placeholder'] ) { |
|
393 | + if ($args['placeholder']) { |
|
394 | 394 | $placeholder = $args['placeholder']; |
395 | 395 | } else { |
396 | 396 | $placeholder = ''; |
397 | 397 | } |
398 | 398 | |
399 | 399 | $options = ''; |
400 | - if( !empty( $args['onchange'] ) ) { |
|
401 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
400 | + if (!empty($args['onchange'])) { |
|
401 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
402 | 402 | } |
403 | 403 | |
404 | - if( !empty( $args['required'] ) ) { |
|
404 | + if (!empty($args['required'])) { |
|
405 | 405 | $options .= ' required="required"'; |
406 | 406 | } |
407 | 407 | |
408 | - if( !empty( $args['disabled'] ) ) { |
|
408 | + if (!empty($args['disabled'])) { |
|
409 | 409 | $options .= ' disabled'; |
410 | 410 | } |
411 | 411 | |
412 | - if( !empty( $args['readonly'] ) ) { |
|
412 | + if (!empty($args['readonly'])) { |
|
413 | 413 | $options .= ' readonly'; |
414 | 414 | } |
415 | 415 | |
416 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
417 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
416 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
417 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
418 | 418 | |
419 | - if ( $args['show_option_all'] ) { |
|
420 | - if( $args['multiple'] ) { |
|
421 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
419 | + if ($args['show_option_all']) { |
|
420 | + if ($args['multiple']) { |
|
421 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
422 | 422 | } else { |
423 | - $selected = selected( $args['selected'], 0, false ); |
|
423 | + $selected = selected($args['selected'], 0, false); |
|
424 | 424 | } |
425 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
425 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
426 | 426 | } |
427 | 427 | |
428 | - if ( !empty( $args['options'] ) ) { |
|
428 | + if (!empty($args['options'])) { |
|
429 | 429 | |
430 | - if ( $args['show_option_none'] ) { |
|
431 | - if( $args['multiple'] ) { |
|
432 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
430 | + if ($args['show_option_none']) { |
|
431 | + if ($args['multiple']) { |
|
432 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
433 | 433 | } else { |
434 | - $selected = selected( $args['selected'] === "", true, false ); |
|
434 | + $selected = selected($args['selected'] === "", true, false); |
|
435 | 435 | } |
436 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
436 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
437 | 437 | } |
438 | 438 | |
439 | - foreach( $args['options'] as $key => $option ) { |
|
439 | + foreach ($args['options'] as $key => $option) { |
|
440 | 440 | |
441 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
442 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
441 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
442 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
443 | 443 | } else { |
444 | - $selected = selected( $args['selected'], $key, false ); |
|
444 | + $selected = selected($args['selected'], $key, false); |
|
445 | 445 | } |
446 | 446 | |
447 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
447 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | return $output; |
454 | 454 | } |
455 | 455 | |
456 | -function wpinv_item_dropdown( $args = array() ) { |
|
456 | +function wpinv_item_dropdown($args = array()) { |
|
457 | 457 | $defaults = array( |
458 | 458 | 'name' => 'wpi_item', |
459 | 459 | 'id' => 'wpi_item', |
@@ -462,15 +462,15 @@ discard block |
||
462 | 462 | 'selected' => 0, |
463 | 463 | 'chosen' => false, |
464 | 464 | 'number' => 100, |
465 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
466 | - 'data' => array( 'search-type' => 'item' ), |
|
465 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
466 | + 'data' => array('search-type' => 'item'), |
|
467 | 467 | 'show_option_all' => false, |
468 | 468 | 'show_option_none' => false, |
469 | 469 | 'with_packages' => true, |
470 | 470 | 'show_recurring' => false, |
471 | 471 | ); |
472 | 472 | |
473 | - $args = wp_parse_args( $args, $defaults ); |
|
473 | + $args = wp_parse_args($args, $defaults); |
|
474 | 474 | |
475 | 475 | $item_args = array( |
476 | 476 | 'post_type' => 'wpi_item', |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | 'posts_per_page' => $args['number'] |
480 | 480 | ); |
481 | 481 | |
482 | - if ( !$args['with_packages'] ) { |
|
482 | + if (!$args['with_packages']) { |
|
483 | 483 | $item_args['meta_query'] = array( |
484 | 484 | array( |
485 | 485 | 'key' => '_wpinv_type', |
@@ -489,42 +489,42 @@ discard block |
||
489 | 489 | ); |
490 | 490 | } |
491 | 491 | |
492 | - $items = get_posts( $item_args ); |
|
492 | + $items = get_posts($item_args); |
|
493 | 493 | $options = array(); |
494 | - if ( $items ) { |
|
495 | - foreach ( $items as $item ) { |
|
496 | - $title = esc_html( $item->post_title ); |
|
494 | + if ($items) { |
|
495 | + foreach ($items as $item) { |
|
496 | + $title = esc_html($item->post_title); |
|
497 | 497 | |
498 | - if ( !empty( $args['show_recurring'] ) ) { |
|
499 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
498 | + if (!empty($args['show_recurring'])) { |
|
499 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
500 | 500 | } |
501 | 501 | |
502 | - $options[ absint( $item->ID ) ] = $title; |
|
502 | + $options[absint($item->ID)] = $title; |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | 506 | // This ensures that any selected items are included in the drop down |
507 | - if( is_array( $args['selected'] ) ) { |
|
508 | - foreach( $args['selected'] as $item ) { |
|
509 | - if( ! in_array( $item, $options ) ) { |
|
510 | - $title = get_the_title( $item ); |
|
511 | - if ( !empty( $args['show_recurring'] ) ) { |
|
512 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
507 | + if (is_array($args['selected'])) { |
|
508 | + foreach ($args['selected'] as $item) { |
|
509 | + if (!in_array($item, $options)) { |
|
510 | + $title = get_the_title($item); |
|
511 | + if (!empty($args['show_recurring'])) { |
|
512 | + $title .= wpinv_get_item_suffix($item, false); |
|
513 | 513 | } |
514 | 514 | $options[$item] = $title; |
515 | 515 | } |
516 | 516 | } |
517 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
518 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
519 | - $title = get_the_title( $args['selected'] ); |
|
520 | - if ( !empty( $args['show_recurring'] ) ) { |
|
521 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
517 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
518 | + if (!in_array($args['selected'], $options)) { |
|
519 | + $title = get_the_title($args['selected']); |
|
520 | + if (!empty($args['show_recurring'])) { |
|
521 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
522 | 522 | } |
523 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
523 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
527 | - $output = wpinv_html_select( array( |
|
527 | + $output = wpinv_html_select(array( |
|
528 | 528 | 'name' => $args['name'], |
529 | 529 | 'selected' => $args['selected'], |
530 | 530 | 'id' => $args['id'], |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | 'show_option_all' => $args['show_option_all'], |
537 | 537 | 'show_option_none' => $args['show_option_none'], |
538 | 538 | 'data' => $args['data'], |
539 | - ) ); |
|
539 | + )); |
|
540 | 540 | |
541 | 541 | return $output; |
542 | 542 | } |
543 | 543 | |
544 | -function wpinv_html_checkbox( $args = array() ) { |
|
544 | +function wpinv_html_checkbox($args = array()) { |
|
545 | 545 | $defaults = array( |
546 | 546 | 'name' => null, |
547 | 547 | 'current' => null, |
@@ -552,38 +552,38 @@ discard block |
||
552 | 552 | ) |
553 | 553 | ); |
554 | 554 | |
555 | - $args = wp_parse_args( $args, $defaults ); |
|
555 | + $args = wp_parse_args($args, $defaults); |
|
556 | 556 | |
557 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
557 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
558 | 558 | $options = ''; |
559 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
559 | + if (!empty($args['options']['disabled'])) { |
|
560 | 560 | $options .= ' disabled="disabled"'; |
561 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
561 | + } elseif (!empty($args['options']['readonly'])) { |
|
562 | 562 | $options .= ' readonly'; |
563 | 563 | } |
564 | 564 | |
565 | - $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 ) . ' />'; |
|
565 | + $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) . ' />'; |
|
566 | 566 | |
567 | 567 | return $output; |
568 | 568 | } |
569 | 569 | |
570 | -function wpinv_html_text( $args = array() ) { |
|
570 | +function wpinv_html_text($args = array()) { |
|
571 | 571 | // Backwards compatibility |
572 | - if ( func_num_args() > 1 ) { |
|
572 | + if (func_num_args() > 1) { |
|
573 | 573 | $args = func_get_args(); |
574 | 574 | |
575 | 575 | $name = $args[0]; |
576 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
577 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
578 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
576 | + $value = isset($args[1]) ? $args[1] : ''; |
|
577 | + $label = isset($args[2]) ? $args[2] : ''; |
|
578 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | $defaults = array( |
582 | 582 | 'id' => '', |
583 | - 'name' => isset( $name ) ? $name : 'text', |
|
584 | - 'value' => isset( $value ) ? $value : null, |
|
585 | - 'label' => isset( $label ) ? $label : null, |
|
586 | - 'desc' => isset( $desc ) ? $desc : null, |
|
583 | + 'name' => isset($name) ? $name : 'text', |
|
584 | + 'value' => isset($value) ? $value : null, |
|
585 | + 'label' => isset($label) ? $label : null, |
|
586 | + 'desc' => isset($desc) ? $desc : null, |
|
587 | 587 | 'placeholder' => '', |
588 | 588 | 'class' => 'regular-text', |
589 | 589 | 'disabled' => false, |
@@ -593,51 +593,51 @@ discard block |
||
593 | 593 | 'data' => false |
594 | 594 | ); |
595 | 595 | |
596 | - $args = wp_parse_args( $args, $defaults ); |
|
596 | + $args = wp_parse_args($args, $defaults); |
|
597 | 597 | |
598 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
598 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
599 | 599 | $options = ''; |
600 | - if( $args['required'] ) { |
|
600 | + if ($args['required']) { |
|
601 | 601 | $options .= ' required="required"'; |
602 | 602 | } |
603 | - if( $args['readonly'] ) { |
|
603 | + if ($args['readonly']) { |
|
604 | 604 | $options .= ' readonly'; |
605 | 605 | } |
606 | - if( $args['readonly'] ) { |
|
606 | + if ($args['readonly']) { |
|
607 | 607 | $options .= ' readonly'; |
608 | 608 | } |
609 | 609 | |
610 | 610 | $data = ''; |
611 | - if ( !empty( $args['data'] ) ) { |
|
612 | - foreach ( $args['data'] as $key => $value ) { |
|
613 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
611 | + if (!empty($args['data'])) { |
|
612 | + foreach ($args['data'] as $key => $value) { |
|
613 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
618 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
619 | - if ( ! empty( $args['desc'] ) ) { |
|
620 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
617 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
618 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
619 | + if (!empty($args['desc'])) { |
|
620 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
621 | 621 | } |
622 | 622 | |
623 | - $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 ) . '/>'; |
|
623 | + $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) . '/>'; |
|
624 | 624 | |
625 | 625 | $output .= '</span>'; |
626 | 626 | |
627 | 627 | return $output; |
628 | 628 | } |
629 | 629 | |
630 | -function wpinv_html_date_field( $args = array() ) { |
|
631 | - if( empty( $args['class'] ) ) { |
|
630 | +function wpinv_html_date_field($args = array()) { |
|
631 | + if (empty($args['class'])) { |
|
632 | 632 | $args['class'] = 'wpiDatepicker'; |
633 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
633 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
634 | 634 | $args['class'] .= ' wpiDatepicker'; |
635 | 635 | } |
636 | 636 | |
637 | - return wpinv_html_text( $args ); |
|
637 | + return wpinv_html_text($args); |
|
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_html_textarea( $args = array() ) { |
|
640 | +function wpinv_html_textarea($args = array()) { |
|
641 | 641 | $defaults = array( |
642 | 642 | 'name' => 'textarea', |
643 | 643 | 'value' => null, |
@@ -647,31 +647,31 @@ discard block |
||
647 | 647 | 'disabled' => false |
648 | 648 | ); |
649 | 649 | |
650 | - $args = wp_parse_args( $args, $defaults ); |
|
650 | + $args = wp_parse_args($args, $defaults); |
|
651 | 651 | |
652 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
652 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
653 | 653 | $disabled = ''; |
654 | - if( $args['disabled'] ) { |
|
654 | + if ($args['disabled']) { |
|
655 | 655 | $disabled = ' disabled="disabled"'; |
656 | 656 | } |
657 | 657 | |
658 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
659 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
660 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
658 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
659 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
660 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
661 | 661 | |
662 | - if ( ! empty( $args['desc'] ) ) { |
|
663 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
662 | + if (!empty($args['desc'])) { |
|
663 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
664 | 664 | } |
665 | 665 | $output .= '</span>'; |
666 | 666 | |
667 | 667 | return $output; |
668 | 668 | } |
669 | 669 | |
670 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
670 | +function wpinv_html_ajax_user_search($args = array()) { |
|
671 | 671 | $defaults = array( |
672 | 672 | 'name' => 'user_id', |
673 | 673 | 'value' => null, |
674 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
674 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
675 | 675 | 'label' => null, |
676 | 676 | 'desc' => null, |
677 | 677 | 'class' => '', |
@@ -680,13 +680,13 @@ discard block |
||
680 | 680 | 'data' => false |
681 | 681 | ); |
682 | 682 | |
683 | - $args = wp_parse_args( $args, $defaults ); |
|
683 | + $args = wp_parse_args($args, $defaults); |
|
684 | 684 | |
685 | 685 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
686 | 686 | |
687 | 687 | $output = '<span class="wpinv_user_search_wrap">'; |
688 | - $output .= wpinv_html_text( $args ); |
|
689 | - $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>'; |
|
688 | + $output .= wpinv_html_text($args); |
|
689 | + $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>'; |
|
690 | 690 | $output .= '</span>'; |
691 | 691 | |
692 | 692 | return $output; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | function wpinv_ip_geolocation() { |
696 | 696 | global $wpinv_euvat; |
697 | 697 | |
698 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
698 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
699 | 699 | $content = ''; |
700 | 700 | $iso = ''; |
701 | 701 | $country = ''; |
@@ -706,69 +706,69 @@ discard block |
||
706 | 706 | $credit = ''; |
707 | 707 | $address = ''; |
708 | 708 | |
709 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
709 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
710 | 710 | try { |
711 | 711 | $iso = $geoip2_city->country->isoCode; |
712 | 712 | $country = $geoip2_city->country->name; |
713 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
713 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
714 | 714 | $city = $geoip2_city->city->name; |
715 | 715 | $longitude = $geoip2_city->location->longitude; |
716 | 716 | $latitude = $geoip2_city->location->latitude; |
717 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
718 | - } catch( Exception $e ) { } |
|
717 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
718 | + } catch (Exception $e) { } |
|
719 | 719 | } |
720 | 720 | |
721 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
721 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
722 | 722 | try { |
723 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
723 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
724 | 724 | |
725 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
725 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
726 | 726 | $iso = $load_xml->geoplugin_countryCode; |
727 | 727 | $country = $load_xml->geoplugin_countryName; |
728 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
729 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
728 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
729 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
730 | 730 | $longitude = $load_xml->geoplugin_longitude; |
731 | 731 | $latitude = $load_xml->geoplugin_latitude; |
732 | 732 | $credit = $load_xml->geoplugin_credit; |
733 | - $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; |
|
733 | + $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; |
|
734 | 734 | } |
735 | - } catch( Exception $e ) { } |
|
735 | + } catch (Exception $e) { } |
|
736 | 736 | } |
737 | 737 | |
738 | - if ( $iso && $longitude && $latitude ) { |
|
739 | - if ( $city ) { |
|
738 | + if ($iso && $longitude && $latitude) { |
|
739 | + if ($city) { |
|
740 | 740 | $address .= $city . ', '; |
741 | 741 | } |
742 | 742 | |
743 | - if ( $region ) { |
|
743 | + if ($region) { |
|
744 | 744 | $address .= $region . ', '; |
745 | 745 | } |
746 | 746 | |
747 | 747 | $address .= $country . ' (' . $iso . ')'; |
748 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
749 | - $content .= '<p>'. $credit . '</p>'; |
|
748 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
749 | + $content .= '<p>' . $credit . '</p>'; |
|
750 | 750 | } else { |
751 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
751 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
752 | 752 | } |
753 | 753 | ?> |
754 | 754 | <!DOCTYPE html> |
755 | -<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> |
|
755 | +<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> |
|
756 | 756 | <body> |
757 | - <?php if ( $latitude && $latitude ) { ?> |
|
757 | + <?php if ($latitude && $latitude) { ?> |
|
758 | 758 | <div id="map"></div> |
759 | 759 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
760 | 760 | <script type="text/javascript"> |
761 | 761 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
762 | 762 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
763 | 763 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
764 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
764 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
765 | 765 | |
766 | 766 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
767 | 767 | |
768 | 768 | var marker = new L.Marker(latlng); |
769 | 769 | map.addLayer(marker); |
770 | 770 | |
771 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
771 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
772 | 772 | </script> |
773 | 773 | <?php } ?> |
774 | 774 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -776,18 +776,18 @@ discard block |
||
776 | 776 | <?php |
777 | 777 | exit; |
778 | 778 | } |
779 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
780 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
779 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
780 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
781 | 781 | |
782 | 782 | // Set up the template for the invoice. |
783 | -function wpinv_template( $template ) { |
|
783 | +function wpinv_template($template) { |
|
784 | 784 | global $post, $wp_query; |
785 | 785 | |
786 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
787 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
788 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
786 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
787 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
788 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
789 | 789 | } else { |
790 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
790 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 | |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | |
797 | 797 | function wpinv_get_business_address() { |
798 | 798 | $business_address = wpinv_store_address(); |
799 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
799 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
800 | 800 | |
801 | 801 | /* |
802 | 802 | $default_country = wpinv_get_default_country(); |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | |
821 | 821 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
822 | 822 | |
823 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
823 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | function wpinv_display_from_address() { |
@@ -830,188 +830,188 @@ discard block |
||
830 | 830 | if (empty($from_name)) { |
831 | 831 | $from_name = wpinv_get_business_name(); |
832 | 832 | } |
833 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
833 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
834 | 834 | <div class="wrapper col-xs-10"> |
835 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
836 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
837 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
835 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
836 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
837 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
838 | 838 | <?php } ?> |
839 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
840 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
839 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
840 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
841 | 841 | <?php } ?> |
842 | 842 | </div> |
843 | 843 | <?php |
844 | 844 | } |
845 | 845 | |
846 | -function wpinv_watermark( $id = 0 ) { |
|
847 | - $output = wpinv_get_watermark( $id ); |
|
846 | +function wpinv_watermark($id = 0) { |
|
847 | + $output = wpinv_get_watermark($id); |
|
848 | 848 | |
849 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
849 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
850 | 850 | } |
851 | 851 | |
852 | -function wpinv_get_watermark( $id ) { |
|
853 | - if ( !$id > 0 ) { |
|
852 | +function wpinv_get_watermark($id) { |
|
853 | + if (!$id > 0) { |
|
854 | 854 | return NULL; |
855 | 855 | } |
856 | - $invoice = wpinv_get_invoice( $id ); |
|
856 | + $invoice = wpinv_get_invoice($id); |
|
857 | 857 | |
858 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
859 | - if ( $invoice->is_paid() ) { |
|
860 | - return __( 'Paid', 'invoicing' ); |
|
858 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
859 | + if ($invoice->is_paid()) { |
|
860 | + return __('Paid', 'invoicing'); |
|
861 | 861 | } |
862 | - if ( $invoice->is_refunded() ) { |
|
863 | - return __( 'Refunded', 'invoicing' ); |
|
862 | + if ($invoice->is_refunded()) { |
|
863 | + return __('Refunded', 'invoicing'); |
|
864 | 864 | } |
865 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
866 | - return __( 'Cancelled', 'invoicing' ); |
|
865 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
866 | + return __('Cancelled', 'invoicing'); |
|
867 | 867 | } |
868 | 868 | } |
869 | 869 | |
870 | 870 | return NULL; |
871 | 871 | } |
872 | 872 | |
873 | -function wpinv_display_invoice_details( $invoice ) { |
|
873 | +function wpinv_display_invoice_details($invoice) { |
|
874 | 874 | global $wpinv_euvat; |
875 | 875 | |
876 | 876 | $invoice_id = $invoice->ID; |
877 | 877 | $vat_name = $wpinv_euvat->get_vat_name(); |
878 | 878 | $use_taxes = wpinv_use_taxes(); |
879 | 879 | |
880 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
880 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
881 | 881 | |
882 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
883 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
882 | + if ($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
883 | + elseif ($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
884 | 884 | ?> |
885 | 885 | <table class="table table-bordered table-sm"> |
886 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
886 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
887 | 887 | <tr class="wpi-row-number"> |
888 | - <th><?php echo sprintf(__( '%s Number', 'invoicing' ), $type); ?></th> |
|
889 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
888 | + <th><?php echo sprintf(__('%s Number', 'invoicing'), $type); ?></th> |
|
889 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
890 | 890 | </tr> |
891 | 891 | <?php } ?> |
892 | 892 | <tr class="wpi-row-status"> |
893 | - <th><?php echo wp_sprintf(__( '%s Status', 'invoicing' ), $type); ?></th> |
|
894 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
893 | + <th><?php echo wp_sprintf(__('%s Status', 'invoicing'), $type); ?></th> |
|
894 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
895 | 895 | </tr> |
896 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
896 | + <?php if ($invoice->is_renewal()) { ?> |
|
897 | 897 | <tr class="wpi-row-parent"> |
898 | - <th><?php echo wp_sprintf(__( 'Parent %s', 'invoicing' ), $type); ?></th> |
|
899 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
898 | + <th><?php echo wp_sprintf(__('Parent %s', 'invoicing'), $type); ?></th> |
|
899 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
900 | 900 | </tr> |
901 | 901 | <?php } ?> |
902 | 902 | <tr class="wpi-row-gateway"> |
903 | - <th><?php _e( 'Payment Method', 'invoicing' ); ?></th> |
|
904 | - <td><?php echo wpinv_get_payment_gateway_name( $invoice_id ); ?></td> |
|
903 | + <th><?php _e('Payment Method', 'invoicing'); ?></th> |
|
904 | + <td><?php echo wpinv_get_payment_gateway_name($invoice_id); ?></td> |
|
905 | 905 | </tr> |
906 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
906 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
907 | 907 | <tr class="wpi-row-date"> |
908 | - <th><?php echo wp_sprintf(__( '%s Date', 'invoicing' ), $type); ?></th> |
|
908 | + <th><?php echo wp_sprintf(__('%s Date', 'invoicing'), $type); ?></th> |
|
909 | 909 | <td><?php echo $invoice_date; ?></td> |
910 | 910 | </tr> |
911 | 911 | <?php } ?> |
912 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
912 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
913 | 913 | <tr class="wpi-row-date"> |
914 | - <th><?php _e( 'Due Date', 'invoicing' ); ?></th> |
|
914 | + <th><?php _e('Due Date', 'invoicing'); ?></th> |
|
915 | 915 | <td><?php echo $due_date; ?></td> |
916 | 916 | </tr> |
917 | 917 | <?php } ?> |
918 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
918 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
919 | 919 | <tr class="wpi-row-ovatno"> |
920 | - <th><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
920 | + <th><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></th> |
|
921 | 921 | <td><?php echo $owner_vat_number; ?></td> |
922 | 922 | </tr> |
923 | 923 | <?php } ?> |
924 | - <?php if ( $use_taxes && $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) { ?> |
|
924 | + <?php if ($use_taxes && $user_vat_number = wpinv_get_invoice_vat_number($invoice_id)) { ?> |
|
925 | 925 | <tr class="wpi-row-uvatno"> |
926 | - <th><?php echo wp_sprintf( __( 'Your %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
926 | + <th><?php echo wp_sprintf(__('Your %s Number', 'invoicing'), $vat_name); ?></th> |
|
927 | 927 | <td><?php echo $user_vat_number; ?></td> |
928 | 928 | </tr> |
929 | 929 | <?php } ?> |
930 | 930 | <tr class="table-active tr-total wpi-row-total"> |
931 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
932 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
931 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
932 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
933 | 933 | </tr> |
934 | 934 | </table> |
935 | 935 | <?php |
936 | 936 | } |
937 | 937 | |
938 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
939 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
938 | +function wpinv_display_to_address($invoice_id = 0) { |
|
939 | + $invoice = wpinv_get_invoice($invoice_id); |
|
940 | 940 | |
941 | - if ( empty( $invoice ) ) { |
|
941 | + if (empty($invoice)) { |
|
942 | 942 | return NULL; |
943 | 943 | } |
944 | 944 | |
945 | 945 | $billing_details = $invoice->get_user_info(); |
946 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
946 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
947 | 947 | $output .= '<div class="wrapper col-xs-10">'; |
948 | 948 | |
949 | 949 | ob_start(); |
950 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
950 | + do_action('wpinv_display_to_address_top', $invoice); |
|
951 | 951 | $output .= ob_get_clean(); |
952 | 952 | |
953 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
954 | - if ( $company = $billing_details['company'] ) { |
|
955 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
953 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
954 | + if ($company = $billing_details['company']) { |
|
955 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
956 | 956 | } |
957 | 957 | $address_row = ''; |
958 | - if ( $address = $billing_details['address'] ) { |
|
959 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
958 | + if ($address = $billing_details['address']) { |
|
959 | + $address_row .= wpautop(wp_kses_post($address)); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | $address_fields = array(); |
963 | - if ( !empty( $billing_details['city'] ) ) { |
|
963 | + if (!empty($billing_details['city'])) { |
|
964 | 964 | $address_fields[] = $billing_details['city']; |
965 | 965 | } |
966 | 966 | |
967 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
968 | - if ( !empty( $billing_details['state'] ) ) { |
|
969 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
967 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
968 | + if (!empty($billing_details['state'])) { |
|
969 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
970 | 970 | } |
971 | 971 | |
972 | - if ( !empty( $billing_country ) ) { |
|
973 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
972 | + if (!empty($billing_country)) { |
|
973 | + $address_fields[] = wpinv_country_name($billing_country); |
|
974 | 974 | } |
975 | 975 | |
976 | - if ( !empty( $address_fields ) ) { |
|
977 | - $address_fields = implode( ", ", $address_fields ); |
|
976 | + if (!empty($address_fields)) { |
|
977 | + $address_fields = implode(", ", $address_fields); |
|
978 | 978 | |
979 | - if ( !empty( $billing_details['zip'] ) ) { |
|
979 | + if (!empty($billing_details['zip'])) { |
|
980 | 980 | $address_fields .= ' ' . $billing_details['zip']; |
981 | 981 | } |
982 | 982 | |
983 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
983 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
984 | 984 | } |
985 | 985 | |
986 | - if ( $address_row ) { |
|
986 | + if ($address_row) { |
|
987 | 987 | $output .= '<div class="address">' . $address_row . '</div>'; |
988 | 988 | } |
989 | 989 | |
990 | - if ( $phone = $invoice->get_phone() ) { |
|
991 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
990 | + if ($phone = $invoice->get_phone()) { |
|
991 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
992 | 992 | } |
993 | - if ( $email = $invoice->get_email() ) { |
|
994 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
993 | + if ($email = $invoice->get_email()) { |
|
994 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | ob_start(); |
998 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
998 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
999 | 999 | $output .= ob_get_clean(); |
1000 | 1000 | |
1001 | 1001 | $output .= '</div>'; |
1002 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
1002 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
1003 | 1003 | |
1004 | 1004 | echo $output; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1007 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1008 | 1008 | global $wpinv_euvat, $ajax_cart_details; |
1009 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1009 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1010 | 1010 | $quantities_enabled = wpinv_item_quantities_enabled(); |
1011 | 1011 | $use_taxes = wpinv_use_taxes(); |
1012 | 1012 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
1013 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
1014 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
1013 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
1014 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
1015 | 1015 | |
1016 | 1016 | $cart_details = $invoice->get_cart_details(); |
1017 | 1017 | $ajax_cart_details = $cart_details; |
@@ -1020,68 +1020,68 @@ discard block |
||
1020 | 1020 | <table class="table table-sm table-bordered table-responsive"> |
1021 | 1021 | <thead> |
1022 | 1022 | <tr> |
1023 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1024 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1023 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1024 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1025 | 1025 | <?php if ($quantities_enabled) { ?> |
1026 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1026 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1027 | 1027 | <?php } ?> |
1028 | 1028 | <?php if ($use_taxes && !$zero_tax) { ?> |
1029 | 1029 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1030 | 1030 | <?php } ?> |
1031 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1031 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1032 | 1032 | </tr> |
1033 | 1033 | </thead> |
1034 | 1034 | <tbody> |
1035 | 1035 | <?php |
1036 | - if ( !empty( $cart_details ) ) { |
|
1037 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1036 | + if (!empty($cart_details)) { |
|
1037 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1038 | 1038 | |
1039 | 1039 | $count = 0; |
1040 | 1040 | $cols = 3; |
1041 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1042 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1043 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
1044 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
1045 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1041 | + foreach ($cart_details as $key => $cart_item) { |
|
1042 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1043 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
1044 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
1045 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1046 | 1046 | |
1047 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1047 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1048 | 1048 | $summary = ''; |
1049 | 1049 | $cols = 3; |
1050 | - if ( !empty($item) ) { |
|
1050 | + if (!empty($item)) { |
|
1051 | 1051 | $item_name = $item->get_name(); |
1052 | 1052 | $summary = $item->get_summary(); |
1053 | 1053 | } |
1054 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1054 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1055 | 1055 | |
1056 | 1056 | if (!empty($item) && $item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1057 | - $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>'; |
|
1058 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $item->get_custom_singular_name(), $post_link ); |
|
1057 | + $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>'; |
|
1058 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $item->get_custom_singular_name(), $post_link); |
|
1059 | 1059 | } |
1060 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1060 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1061 | 1061 | |
1062 | 1062 | $item_tax = ''; |
1063 | 1063 | $tax_rate = ''; |
1064 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1065 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1066 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1067 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1064 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1065 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1066 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1067 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1068 | 1068 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | $line_item_tax = $item_tax . $tax_rate; |
1072 | 1072 | |
1073 | - if ( $line_item_tax === '' ) { |
|
1073 | + if ($line_item_tax === '') { |
|
1074 | 1074 | $line_item_tax = 0; // Zero tax |
1075 | 1075 | } |
1076 | 1076 | |
1077 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1078 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1079 | - if ( $summary !== '' ) { |
|
1080 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1077 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1078 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1079 | + if ($summary !== '') { |
|
1080 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1081 | 1081 | } |
1082 | 1082 | $line_item .= '</td>'; |
1083 | 1083 | |
1084 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1084 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1085 | 1085 | if ($quantities_enabled) { |
1086 | 1086 | $cols++; |
1087 | 1087 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1090,55 +1090,55 @@ discard block |
||
1090 | 1090 | $cols++; |
1091 | 1091 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1092 | 1092 | } |
1093 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1093 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1094 | 1094 | $line_item .= '</tr>'; |
1095 | 1095 | |
1096 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1096 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1097 | 1097 | |
1098 | 1098 | $count++; |
1099 | 1099 | } |
1100 | 1100 | |
1101 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1101 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1102 | 1102 | ?> |
1103 | 1103 | <tr class="row-sub-total row_odd"> |
1104 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1105 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1104 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1105 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1106 | 1106 | </tr> |
1107 | 1107 | <?php |
1108 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1108 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1109 | 1109 | |
1110 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1111 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1110 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1111 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1112 | 1112 | ?> |
1113 | 1113 | <tr class="row-discount"> |
1114 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1115 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1114 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1115 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1116 | 1116 | </tr> |
1117 | 1117 | <?php |
1118 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1118 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | - if ( $use_taxes ) { |
|
1122 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1121 | + if ($use_taxes) { |
|
1122 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1123 | 1123 | ?> |
1124 | 1124 | <tr class="row-tax"> |
1125 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1126 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1125 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1126 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1127 | 1127 | </tr> |
1128 | 1128 | <?php |
1129 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1129 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1132 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1133 | 1133 | ?> |
1134 | 1134 | <tr class="table-active row-total"> |
1135 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1136 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1135 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1136 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1137 | 1137 | </tr> |
1138 | 1138 | <?php |
1139 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1139 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1140 | 1140 | |
1141 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1141 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1142 | 1142 | } |
1143 | 1143 | ?> |
1144 | 1144 | </tbody> |
@@ -1147,35 +1147,35 @@ discard block |
||
1147 | 1147 | echo ob_get_clean(); |
1148 | 1148 | } |
1149 | 1149 | |
1150 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1150 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1151 | 1151 | $use_taxes = wpinv_use_taxes(); |
1152 | 1152 | |
1153 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1153 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1154 | 1154 | ?> |
1155 | 1155 | <table class="table table-sm table-bordered table-responsive"> |
1156 | 1156 | <tbody> |
1157 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1157 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1158 | 1158 | <tr class="row-sub-total"> |
1159 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1160 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1159 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1160 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1161 | 1161 | </tr> |
1162 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1163 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1162 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1163 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1164 | 1164 | <tr class="row-discount"> |
1165 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1166 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1165 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1166 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1167 | 1167 | </tr> |
1168 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1168 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1169 | 1169 | <?php } ?> |
1170 | - <?php if ( $use_taxes ) { ?> |
|
1170 | + <?php if ($use_taxes) { ?> |
|
1171 | 1171 | <tr class="row-tax"> |
1172 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1173 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1172 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1173 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1174 | 1174 | </tr> |
1175 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1175 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1176 | 1176 | <?php } ?> |
1177 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1178 | - <?php foreach ( $fees as $fee ) { ?> |
|
1177 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1178 | + <?php foreach ($fees as $fee) { ?> |
|
1179 | 1179 | <tr class="row-fee"> |
1180 | 1180 | <td class="rate"><?php echo $fee['label']; ?></td> |
1181 | 1181 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1183,73 +1183,73 @@ discard block |
||
1183 | 1183 | <?php } ?> |
1184 | 1184 | <?php } ?> |
1185 | 1185 | <tr class="table-active row-total"> |
1186 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1187 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1186 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1187 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1188 | 1188 | </tr> |
1189 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1189 | + <?php do_action('wpinv_after_totals'); ?> |
|
1190 | 1190 | </tbody> |
1191 | 1191 | |
1192 | 1192 | </table> |
1193 | 1193 | |
1194 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1194 | + <?php do_action('wpinv_after_totals_table'); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1198 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1197 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1198 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1199 | 1199 | |
1200 | 1200 | ob_start(); |
1201 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1202 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1201 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1202 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1203 | 1203 | ?> |
1204 | 1204 | <div class="wpi-payment-info"> |
1205 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1206 | - <?php if ( $gateway_title ) { ?> |
|
1207 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1205 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1206 | + <?php if ($gateway_title) { ?> |
|
1207 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1208 | 1208 | <?php } ?> |
1209 | 1209 | </div> |
1210 | 1210 | <?php |
1211 | 1211 | } |
1212 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1212 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1213 | 1213 | $outout = ob_get_clean(); |
1214 | 1214 | |
1215 | - if ( $echo ) { |
|
1215 | + if ($echo) { |
|
1216 | 1216 | echo $outout; |
1217 | 1217 | } else { |
1218 | 1218 | return $outout; |
1219 | 1219 | } |
1220 | 1220 | } |
1221 | 1221 | |
1222 | -function wpinv_display_style( $invoice ) { |
|
1223 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1222 | +function wpinv_display_style($invoice) { |
|
1223 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1224 | 1224 | |
1225 | - wp_print_styles( 'open-sans' ); |
|
1226 | - wp_print_styles( 'wpinv-single-style' ); |
|
1225 | + wp_print_styles('open-sans'); |
|
1226 | + wp_print_styles('wpinv-single-style'); |
|
1227 | 1227 | } |
1228 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1229 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1228 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1229 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1230 | 1230 | |
1231 | 1231 | function wpinv_checkout_billing_details() { |
1232 | 1232 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1233 | 1233 | if (empty($invoice_id)) { |
1234 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1234 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1235 | 1235 | return null; |
1236 | 1236 | } |
1237 | 1237 | |
1238 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1238 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1239 | 1239 | if (empty($invoice)) { |
1240 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1240 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1241 | 1241 | return null; |
1242 | 1242 | } |
1243 | 1243 | $user_id = $invoice->get_user_id(); |
1244 | 1244 | $user_info = $invoice->get_user_info(); |
1245 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1245 | + $address_info = wpinv_get_user_address($user_id); |
|
1246 | 1246 | |
1247 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1247 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1248 | 1248 | $user_info['first_name'] = $user_info['first_name']; |
1249 | 1249 | $user_info['last_name'] = $user_info['last_name']; |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1252 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1253 | 1253 | $user_info['country'] = $address_info['country']; |
1254 | 1254 | $user_info['state'] = $address_info['state']; |
1255 | 1255 | $user_info['city'] = $address_info['city']; |
@@ -1265,103 +1265,103 @@ discard block |
||
1265 | 1265 | 'address' |
1266 | 1266 | ); |
1267 | 1267 | |
1268 | - foreach ( $address_fields as $field ) { |
|
1269 | - if ( empty( $user_info[$field] ) ) { |
|
1268 | + foreach ($address_fields as $field) { |
|
1269 | + if (empty($user_info[$field])) { |
|
1270 | 1270 | $user_info[$field] = $address_info[$field]; |
1271 | 1271 | } |
1272 | 1272 | } |
1273 | 1273 | |
1274 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1274 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | function wpinv_admin_get_line_items($invoice = array()) { |
1278 | 1278 | $item_quantities = wpinv_item_quantities_enabled(); |
1279 | 1279 | $use_taxes = wpinv_use_taxes(); |
1280 | 1280 | |
1281 | - if ( empty( $invoice ) ) { |
|
1281 | + if (empty($invoice)) { |
|
1282 | 1282 | return NULL; |
1283 | 1283 | } |
1284 | 1284 | |
1285 | 1285 | $cart_items = $invoice->get_cart_details(); |
1286 | - if ( empty( $cart_items ) ) { |
|
1286 | + if (empty($cart_items)) { |
|
1287 | 1287 | return NULL; |
1288 | 1288 | } |
1289 | 1289 | ob_start(); |
1290 | 1290 | |
1291 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1291 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1292 | 1292 | |
1293 | 1293 | $count = 0; |
1294 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1294 | + foreach ($cart_items as $key => $cart_item) { |
|
1295 | 1295 | $item_id = $cart_item['id']; |
1296 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1296 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1297 | 1297 | |
1298 | 1298 | if (empty($wpi_item)) { |
1299 | 1299 | continue; |
1300 | 1300 | } |
1301 | 1301 | |
1302 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ) ); |
|
1303 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1304 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ) ); |
|
1302 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price'])); |
|
1303 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1304 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal'])); |
|
1305 | 1305 | $can_remove = true; |
1306 | 1306 | |
1307 | 1307 | $summary = ''; |
1308 | 1308 | if ($wpi_item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1309 | - $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>'; |
|
1310 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_custom_singular_name(), $post_link ); |
|
1309 | + $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>'; |
|
1310 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_custom_singular_name(), $post_link); |
|
1311 | 1311 | } |
1312 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice ); |
|
1312 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice); |
|
1313 | 1313 | |
1314 | 1314 | $item_tax = ''; |
1315 | 1315 | $tax_rate = ''; |
1316 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1317 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1318 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1319 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1316 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1317 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1318 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1319 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1320 | 1320 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1321 | 1321 | } |
1322 | 1322 | $line_item_tax = $item_tax . $tax_rate; |
1323 | 1323 | |
1324 | - if ( $line_item_tax === '' ) { |
|
1324 | + if ($line_item_tax === '') { |
|
1325 | 1325 | $line_item_tax = 0; // Zero tax |
1326 | 1326 | } |
1327 | 1327 | |
1328 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1328 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1329 | 1329 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1330 | - $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 ); |
|
1331 | - if ( $summary !== '' ) { |
|
1332 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1330 | + $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); |
|
1331 | + if ($summary !== '') { |
|
1332 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1333 | 1333 | } |
1334 | 1334 | $line_item .= '</td>'; |
1335 | 1335 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1336 | 1336 | |
1337 | - if ( $item_quantities ) { |
|
1338 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1337 | + if ($item_quantities) { |
|
1338 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1339 | 1339 | $can_remove = false; |
1340 | 1340 | } |
1341 | 1341 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1342 | 1342 | } else { |
1343 | - if ( count( $cart_items ) == 1 ) { |
|
1343 | + if (count($cart_items) == 1) { |
|
1344 | 1344 | $can_remove = false; |
1345 | 1345 | } |
1346 | 1346 | } |
1347 | 1347 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1348 | 1348 | |
1349 | - if ( $use_taxes ) { |
|
1349 | + if ($use_taxes) { |
|
1350 | 1350 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1351 | 1351 | } |
1352 | 1352 | $line_item .= '<td class="action">'; |
1353 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
1353 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
1354 | 1354 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1355 | 1355 | } |
1356 | 1356 | $line_item .= '</td>'; |
1357 | 1357 | $line_item .= '</tr>'; |
1358 | 1358 | |
1359 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1359 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1360 | 1360 | |
1361 | 1361 | $count++; |
1362 | 1362 | } |
1363 | 1363 | |
1364 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1364 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1365 | 1365 | |
1366 | 1366 | return ob_get_clean(); |
1367 | 1367 | } |
@@ -1372,35 +1372,35 @@ discard block |
||
1372 | 1372 | // Set current invoice id. |
1373 | 1373 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1374 | 1374 | |
1375 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1375 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1376 | 1376 | |
1377 | 1377 | ob_start(); |
1378 | 1378 | echo '<div id="wpinv_checkout_wrap">'; |
1379 | 1379 | |
1380 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1380 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1381 | 1381 | ?> |
1382 | 1382 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1383 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1383 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1384 | 1384 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1385 | 1385 | <?php |
1386 | - do_action( 'wpinv_checkout_form_top' ); |
|
1387 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1388 | - do_action( 'wpinv_checkout_cart' ); |
|
1389 | - do_action( 'wpinv_payment_mode_select' ); |
|
1390 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1386 | + do_action('wpinv_checkout_form_top'); |
|
1387 | + do_action('wpinv_checkout_billing_info'); |
|
1388 | + do_action('wpinv_checkout_cart'); |
|
1389 | + do_action('wpinv_payment_mode_select'); |
|
1390 | + do_action('wpinv_checkout_form_bottom') |
|
1391 | 1391 | ?> |
1392 | 1392 | </form> |
1393 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1393 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1394 | 1394 | </div><!--end #wpinv_checkout_form_wrap--> |
1395 | 1395 | <?php |
1396 | 1396 | } else { |
1397 | - do_action( 'wpinv_cart_empty' ); |
|
1397 | + do_action('wpinv_cart_empty'); |
|
1398 | 1398 | } |
1399 | 1399 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1400 | 1400 | return ob_get_clean(); |
1401 | 1401 | } |
1402 | 1402 | |
1403 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1403 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1404 | 1404 | global $ajax_cart_details; |
1405 | 1405 | $ajax_cart_details = $cart_details; |
1406 | 1406 | /* |
@@ -1415,25 +1415,25 @@ discard block |
||
1415 | 1415 | } |
1416 | 1416 | */ |
1417 | 1417 | ob_start(); |
1418 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1418 | + do_action('wpinv_before_checkout_cart'); |
|
1419 | 1419 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1420 | 1420 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1421 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1421 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1422 | 1422 | echo '</div>'; |
1423 | 1423 | echo '</div>'; |
1424 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1424 | + do_action('wpinv_after_checkout_cart'); |
|
1425 | 1425 | $content = ob_get_clean(); |
1426 | 1426 | |
1427 | - if ( $echo ) { |
|
1427 | + if ($echo) { |
|
1428 | 1428 | echo $content; |
1429 | 1429 | } else { |
1430 | 1430 | return $content; |
1431 | 1431 | } |
1432 | 1432 | } |
1433 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1433 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1434 | 1434 | |
1435 | 1435 | function wpinv_empty_cart_message() { |
1436 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1436 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | /** |
@@ -1445,91 +1445,91 @@ discard block |
||
1445 | 1445 | function wpinv_empty_checkout_cart() { |
1446 | 1446 | echo wpinv_empty_cart_message(); |
1447 | 1447 | } |
1448 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1448 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1449 | 1449 | |
1450 | 1450 | function wpinv_save_cart_button() { |
1451 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1451 | + if (wpinv_is_cart_saving_disabled()) |
|
1452 | 1452 | return; |
1453 | 1453 | ?> |
1454 | - <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> |
|
1454 | + <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> |
|
1455 | 1455 | <?php |
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | function wpinv_update_cart_button() { |
1459 | - if ( !wpinv_item_quantities_enabled() ) |
|
1459 | + if (!wpinv_item_quantities_enabled()) |
|
1460 | 1460 | return; |
1461 | 1461 | ?> |
1462 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1462 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1463 | 1463 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1464 | 1464 | <?php |
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | function wpinv_checkout_cart_columns() { |
1468 | 1468 | $default = 3; |
1469 | - if ( wpinv_item_quantities_enabled() ) { |
|
1469 | + if (wpinv_item_quantities_enabled()) { |
|
1470 | 1470 | $default++; |
1471 | 1471 | } |
1472 | 1472 | |
1473 | - if ( wpinv_use_taxes() ) { |
|
1473 | + if (wpinv_use_taxes()) { |
|
1474 | 1474 | $default++; |
1475 | 1475 | } |
1476 | 1476 | |
1477 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1477 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | function wpinv_display_cart_messages() { |
1481 | 1481 | global $wpi_session; |
1482 | 1482 | |
1483 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1483 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1484 | 1484 | |
1485 | - if ( $messages ) { |
|
1486 | - foreach ( $messages as $message_id => $message ) { |
|
1485 | + if ($messages) { |
|
1486 | + foreach ($messages as $message_id => $message) { |
|
1487 | 1487 | // Try and detect what type of message this is |
1488 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1488 | + if (strpos(strtolower($message), 'error')) { |
|
1489 | 1489 | $type = 'error'; |
1490 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1490 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1491 | 1491 | $type = 'success'; |
1492 | 1492 | } else { |
1493 | 1493 | $type = 'info'; |
1494 | 1494 | } |
1495 | 1495 | |
1496 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1496 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1497 | 1497 | |
1498 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1498 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1499 | 1499 | // Loop message codes and display messages |
1500 | 1500 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1501 | 1501 | echo '</div>'; |
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | // Remove all of the cart saving messages |
1505 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1505 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1506 | 1506 | } |
1507 | 1507 | } |
1508 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1508 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1509 | 1509 | |
1510 | 1510 | function wpinv_discount_field() { |
1511 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1511 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1512 | 1512 | return; // Only show before a payment method has been selected if ajax is disabled |
1513 | 1513 | } |
1514 | 1514 | |
1515 | - if ( !wpinv_is_checkout() ) { |
|
1515 | + if (!wpinv_is_checkout()) { |
|
1516 | 1516 | return; |
1517 | 1517 | } |
1518 | 1518 | |
1519 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1519 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1520 | 1520 | ?> |
1521 | 1521 | <div id="wpinv-discount-field" class="panel panel-default"> |
1522 | 1522 | <div class="panel-body"> |
1523 | 1523 | <p> |
1524 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1525 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1524 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1525 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1526 | 1526 | </p> |
1527 | 1527 | <div class="form-group row"> |
1528 | 1528 | <div class="col-sm-4"> |
1529 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1529 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1530 | 1530 | </div> |
1531 | 1531 | <div class="col-sm-3"> |
1532 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1532 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1533 | 1533 | </div> |
1534 | 1534 | <div style="clear:both"></div> |
1535 | 1535 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1542,10 +1542,10 @@ discard block |
||
1542 | 1542 | <?php |
1543 | 1543 | } |
1544 | 1544 | } |
1545 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1545 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1546 | 1546 | |
1547 | 1547 | function wpinv_agree_to_terms_js() { |
1548 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1548 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1549 | 1549 | ?> |
1550 | 1550 | <script type="text/javascript"> |
1551 | 1551 | jQuery(document).ready(function($){ |
@@ -1560,126 +1560,126 @@ discard block |
||
1560 | 1560 | <?php |
1561 | 1561 | } |
1562 | 1562 | } |
1563 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1563 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1564 | 1564 | |
1565 | 1565 | function wpinv_payment_mode_select() { |
1566 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1567 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1566 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1567 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1568 | 1568 | $page_URL = wpinv_get_current_page_url(); |
1569 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1569 | + $invoice = wpinv_get_invoice(0, true); |
|
1570 | 1570 | |
1571 | 1571 | do_action('wpinv_payment_mode_top'); |
1572 | 1572 | $invoice_id = (int)$invoice->ID; |
1573 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1573 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1574 | 1574 | ?> |
1575 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;"' : '' ); ?>> |
|
1576 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1575 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;"' : ''); ?>> |
|
1576 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1577 | 1577 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1578 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1578 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1579 | 1579 | <div class="panel-body list-group wpi-payment_methods"> |
1580 | 1580 | <?php |
1581 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1581 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1582 | 1582 | |
1583 | - if(!empty($gateways)){ |
|
1584 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1585 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1586 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1587 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1583 | + if (!empty($gateways)) { |
|
1584 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1585 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1586 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1587 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1588 | 1588 | ?> |
1589 | 1589 | <div class="list-group-item"> |
1590 | 1590 | <div class="radio"> |
1591 | - <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> |
|
1591 | + <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> |
|
1592 | 1592 | </div> |
1593 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1594 | - <?php if ( !empty( $description ) ) { ?> |
|
1595 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
1593 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1594 | + <?php if (!empty($description)) { ?> |
|
1595 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
1596 | 1596 | <?php } ?> |
1597 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1597 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1598 | 1598 | </div> |
1599 | 1599 | </div> |
1600 | 1600 | <?php |
1601 | 1601 | } |
1602 | - }else{ |
|
1603 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1602 | + } else { |
|
1603 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1604 | 1604 | } |
1605 | 1605 | |
1606 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1606 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1607 | 1607 | ?> |
1608 | 1608 | </div> |
1609 | 1609 | </div> |
1610 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1610 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1611 | 1611 | </div> |
1612 | 1612 | <?php |
1613 | 1613 | do_action('wpinv_payment_mode_bottom'); |
1614 | 1614 | } |
1615 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1615 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1616 | 1616 | |
1617 | 1617 | function wpinv_checkout_billing_info() { |
1618 | - if ( wpinv_is_checkout() ) { |
|
1618 | + if (wpinv_is_checkout()) { |
|
1619 | 1619 | $logged_in = is_user_logged_in(); |
1620 | 1620 | $billing_details = wpinv_checkout_billing_details(); |
1621 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1621 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1622 | 1622 | ?> |
1623 | 1623 | <div id="wpinv-fields" class="clearfix"> |
1624 | 1624 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1625 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1625 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1626 | 1626 | <div id="wpinv-fields-box" class="panel-body"> |
1627 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1627 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1628 | 1628 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1629 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1629 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1630 | 1630 | <?php |
1631 | - echo wpinv_html_text( array( |
|
1631 | + echo wpinv_html_text(array( |
|
1632 | 1632 | 'id' => 'wpinv_first_name', |
1633 | 1633 | 'name' => 'wpinv_first_name', |
1634 | 1634 | 'value' => $billing_details['first_name'], |
1635 | 1635 | 'class' => 'wpi-input form-control', |
1636 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1637 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1638 | - ) ); |
|
1636 | + 'placeholder' => __('First name', 'invoicing'), |
|
1637 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1638 | + )); |
|
1639 | 1639 | ?> |
1640 | 1640 | </p> |
1641 | 1641 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1642 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1642 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1643 | 1643 | <?php |
1644 | - echo wpinv_html_text( array( |
|
1644 | + echo wpinv_html_text(array( |
|
1645 | 1645 | 'id' => 'wpinv_last_name', |
1646 | 1646 | 'name' => 'wpinv_last_name', |
1647 | 1647 | 'value' => $billing_details['last_name'], |
1648 | 1648 | 'class' => 'wpi-input form-control', |
1649 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1650 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1651 | - ) ); |
|
1649 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1650 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1651 | + )); |
|
1652 | 1652 | ?> |
1653 | 1653 | </p> |
1654 | 1654 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1655 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1655 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1656 | 1656 | <?php |
1657 | - echo wpinv_html_text( array( |
|
1657 | + echo wpinv_html_text(array( |
|
1658 | 1658 | 'id' => 'wpinv_address', |
1659 | 1659 | 'name' => 'wpinv_address', |
1660 | 1660 | 'value' => $billing_details['address'], |
1661 | 1661 | 'class' => 'wpi-input form-control', |
1662 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1663 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1664 | - ) ); |
|
1662 | + 'placeholder' => __('Address', 'invoicing'), |
|
1663 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1664 | + )); |
|
1665 | 1665 | ?> |
1666 | 1666 | </p> |
1667 | 1667 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1668 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1668 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1669 | 1669 | <?php |
1670 | - echo wpinv_html_text( array( |
|
1670 | + echo wpinv_html_text(array( |
|
1671 | 1671 | 'id' => 'wpinv_city', |
1672 | 1672 | 'name' => 'wpinv_city', |
1673 | 1673 | 'value' => $billing_details['city'], |
1674 | 1674 | 'class' => 'wpi-input form-control', |
1675 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1676 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1677 | - ) ); |
|
1675 | + 'placeholder' => __('City', 'invoicing'), |
|
1676 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1677 | + )); |
|
1678 | 1678 | ?> |
1679 | 1679 | </p> |
1680 | 1680 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1681 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1682 | - <?php echo wpinv_html_select( array( |
|
1681 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1682 | + <?php echo wpinv_html_select(array( |
|
1683 | 1683 | 'options' => wpinv_get_country_list(), |
1684 | 1684 | 'name' => 'wpinv_country', |
1685 | 1685 | 'id' => 'wpinv_country', |
@@ -1687,16 +1687,16 @@ discard block |
||
1687 | 1687 | 'show_option_all' => false, |
1688 | 1688 | 'show_option_none' => false, |
1689 | 1689 | 'class' => 'wpi-input form-control', |
1690 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1691 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1692 | - ) ); ?> |
|
1690 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1691 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1692 | + )); ?> |
|
1693 | 1693 | </p> |
1694 | 1694 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1695 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1695 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1696 | 1696 | <?php |
1697 | - $states = wpinv_get_country_states( $selected_country ); |
|
1698 | - if( !empty( $states ) ) { |
|
1699 | - echo wpinv_html_select( array( |
|
1697 | + $states = wpinv_get_country_states($selected_country); |
|
1698 | + if (!empty($states)) { |
|
1699 | + echo wpinv_html_select(array( |
|
1700 | 1700 | 'options' => $states, |
1701 | 1701 | 'name' => 'wpinv_state', |
1702 | 1702 | 'id' => 'wpinv_state', |
@@ -1704,61 +1704,61 @@ discard block |
||
1704 | 1704 | 'show_option_all' => false, |
1705 | 1705 | 'show_option_none' => false, |
1706 | 1706 | 'class' => 'wpi-input form-control', |
1707 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1708 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1709 | - ) ); |
|
1707 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1708 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1709 | + )); |
|
1710 | 1710 | } else { |
1711 | - echo wpinv_html_text( array( |
|
1711 | + echo wpinv_html_text(array( |
|
1712 | 1712 | 'name' => 'wpinv_state', |
1713 | 1713 | 'value' => $billing_details['state'], |
1714 | 1714 | 'id' => 'wpinv_state', |
1715 | 1715 | 'class' => 'wpi-input form-control', |
1716 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1717 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1718 | - ) ); |
|
1716 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1717 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1718 | + )); |
|
1719 | 1719 | } |
1720 | 1720 | ?> |
1721 | 1721 | </p> |
1722 | 1722 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1723 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1723 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1724 | 1724 | <?php |
1725 | - echo wpinv_html_text( array( |
|
1725 | + echo wpinv_html_text(array( |
|
1726 | 1726 | 'name' => 'wpinv_zip', |
1727 | 1727 | 'value' => $billing_details['zip'], |
1728 | 1728 | 'id' => 'wpinv_zip', |
1729 | 1729 | 'class' => 'wpi-input form-control', |
1730 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1731 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1732 | - ) ); |
|
1730 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1731 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1732 | + )); |
|
1733 | 1733 | ?> |
1734 | 1734 | </p> |
1735 | 1735 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1736 | - <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> |
|
1736 | + <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> |
|
1737 | 1737 | <?php |
1738 | - echo wpinv_html_text( array( |
|
1738 | + echo wpinv_html_text(array( |
|
1739 | 1739 | 'id' => 'wpinv_phone', |
1740 | 1740 | 'name' => 'wpinv_phone', |
1741 | 1741 | 'value' => $billing_details['phone'], |
1742 | 1742 | 'class' => 'wpi-input form-control', |
1743 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1744 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1745 | - ) ); |
|
1743 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1744 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1745 | + )); |
|
1746 | 1746 | ?> |
1747 | 1747 | </p> |
1748 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1748 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1749 | 1749 | <div class="clearfix"></div> |
1750 | 1750 | </div> |
1751 | 1751 | </div> |
1752 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1752 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1753 | 1753 | </div> |
1754 | 1754 | <?php |
1755 | 1755 | } |
1756 | 1756 | } |
1757 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1757 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1758 | 1758 | |
1759 | 1759 | function wpinv_checkout_hidden_fields() { |
1760 | 1760 | ?> |
1761 | - <?php if ( is_user_logged_in() ) { ?> |
|
1761 | + <?php if (is_user_logged_in()) { ?> |
|
1762 | 1762 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1763 | 1763 | <?php } ?> |
1764 | 1764 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1768,9 +1768,9 @@ discard block |
||
1768 | 1768 | function wpinv_checkout_button_purchase() { |
1769 | 1769 | ob_start(); |
1770 | 1770 | ?> |
1771 | - <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' ) ?>"/> |
|
1771 | + <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') ?>"/> |
|
1772 | 1772 | <?php |
1773 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1773 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | function wpinv_checkout_total() { |
@@ -1779,96 +1779,96 @@ discard block |
||
1779 | 1779 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1780 | 1780 | <div class="panel-body"> |
1781 | 1781 | <?php |
1782 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1782 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1783 | 1783 | ?> |
1784 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1784 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1785 | 1785 | <?php |
1786 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1786 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1787 | 1787 | ?> |
1788 | 1788 | </div> |
1789 | 1789 | </div> |
1790 | 1790 | <?php |
1791 | 1791 | } |
1792 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1792 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1793 | 1793 | |
1794 | 1794 | function wpinv_checkout_submit() { |
1795 | 1795 | ?> |
1796 | 1796 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1797 | 1797 | <div class="panel-body text-center"> |
1798 | 1798 | <?php |
1799 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1799 | + do_action('wpinv_purchase_form_before_submit'); |
|
1800 | 1800 | wpinv_checkout_hidden_fields(); |
1801 | 1801 | echo wpinv_checkout_button_purchase(); |
1802 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1802 | + do_action('wpinv_purchase_form_after_submit'); |
|
1803 | 1803 | ?> |
1804 | 1804 | </div> |
1805 | 1805 | </div> |
1806 | 1806 | <?php |
1807 | 1807 | } |
1808 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1808 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1809 | 1809 | |
1810 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1811 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1810 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1811 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1812 | 1812 | |
1813 | - if ( empty( $invoice ) ) { |
|
1813 | + if (empty($invoice)) { |
|
1814 | 1814 | return NULL; |
1815 | 1815 | } |
1816 | 1816 | |
1817 | 1817 | $billing_details = $invoice->get_user_info(); |
1818 | 1818 | $address_row = ''; |
1819 | - if ( $address = $billing_details['address'] ) { |
|
1820 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1819 | + if ($address = $billing_details['address']) { |
|
1820 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | $address_fields = array(); |
1824 | - if ( !empty( $billing_details['city'] ) ) { |
|
1824 | + if (!empty($billing_details['city'])) { |
|
1825 | 1825 | $address_fields[] = $billing_details['city']; |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1829 | - if ( !empty( $billing_details['state'] ) ) { |
|
1830 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1828 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1829 | + if (!empty($billing_details['state'])) { |
|
1830 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1831 | 1831 | } |
1832 | 1832 | |
1833 | - if ( !empty( $billing_country ) ) { |
|
1834 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1833 | + if (!empty($billing_country)) { |
|
1834 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | - if ( !empty( $address_fields ) ) { |
|
1838 | - $address_fields = implode( ", ", $address_fields ); |
|
1837 | + if (!empty($address_fields)) { |
|
1838 | + $address_fields = implode(", ", $address_fields); |
|
1839 | 1839 | |
1840 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1840 | + if (!empty($billing_details['zip'])) { |
|
1841 | 1841 | $address_fields .= ' ' . $billing_details['zip']; |
1842 | 1842 | } |
1843 | 1843 | |
1844 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1844 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1845 | 1845 | } |
1846 | 1846 | ob_start(); |
1847 | 1847 | ?> |
1848 | 1848 | <table class="table table-bordered table-sm wpi-billing-details"> |
1849 | 1849 | <tbody> |
1850 | 1850 | <tr class="wpi-receipt-name"> |
1851 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1852 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1851 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1852 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1853 | 1853 | </tr> |
1854 | 1854 | <tr class="wpi-receipt-email"> |
1855 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1856 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1855 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1856 | + <td><?php echo $billing_details['email']; ?></td> |
|
1857 | 1857 | </tr> |
1858 | - <?php if ( $billing_details['company'] ) { ?> |
|
1858 | + <?php if ($billing_details['company']) { ?> |
|
1859 | 1859 | <tr class="wpi-receipt-company"> |
1860 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1861 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1860 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1861 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1862 | 1862 | </tr> |
1863 | 1863 | <?php } ?> |
1864 | 1864 | <tr class="wpi-receipt-address"> |
1865 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1866 | - <td><?php echo $address_row ;?></td> |
|
1865 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1866 | + <td><?php echo $address_row; ?></td> |
|
1867 | 1867 | </tr> |
1868 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1868 | + <?php if ($billing_details['phone']) { ?> |
|
1869 | 1869 | <tr class="wpi-receipt-phone"> |
1870 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1871 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1870 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1871 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1872 | 1872 | </tr> |
1873 | 1873 | <?php } ?> |
1874 | 1874 | </tbody> |
@@ -1876,103 +1876,103 @@ discard block |
||
1876 | 1876 | <?php |
1877 | 1877 | $output = ob_get_clean(); |
1878 | 1878 | |
1879 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1879 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1880 | 1880 | |
1881 | 1881 | echo $output; |
1882 | 1882 | } |
1883 | 1883 | |
1884 | -function wpinv_filter_success_page_content( $content ) { |
|
1885 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1886 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1887 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1884 | +function wpinv_filter_success_page_content($content) { |
|
1885 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1886 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1887 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1888 | 1888 | } |
1889 | 1889 | } |
1890 | 1890 | |
1891 | 1891 | return $content; |
1892 | 1892 | } |
1893 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1893 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1894 | 1894 | |
1895 | -function wpinv_receipt_actions( $invoice ) { |
|
1896 | - if ( !empty( $invoice ) ) { |
|
1895 | +function wpinv_receipt_actions($invoice) { |
|
1896 | + if (!empty($invoice)) { |
|
1897 | 1897 | $actions = array(); |
1898 | 1898 | |
1899 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
1900 | - $actions['print'] = array( |
|
1901 | - 'url' => $invoice->get_view_url( true ), |
|
1902 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1899 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
1900 | + $actions['print'] = array( |
|
1901 | + 'url' => $invoice->get_view_url(true), |
|
1902 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1903 | 1903 | 'class' => 'btn-primary', |
1904 | 1904 | ); |
1905 | 1905 | } |
1906 | 1906 | |
1907 | - if ( is_user_logged_in() ) { |
|
1907 | + if (is_user_logged_in()) { |
|
1908 | 1908 | $actions['history'] = array( |
1909 | 1909 | 'url' => wpinv_get_history_page_uri(), |
1910 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1910 | + 'name' => __('Invoice History', 'invoicing'), |
|
1911 | 1911 | 'class' => 'btn-warning', |
1912 | 1912 | ); |
1913 | 1913 | } |
1914 | 1914 | |
1915 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1915 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1916 | 1916 | |
1917 | - if ( !empty( $actions ) ) { |
|
1917 | + if (!empty($actions)) { |
|
1918 | 1918 | ?> |
1919 | 1919 | <div class="wpinv-receipt-actions text-right"> |
1920 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1921 | - <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> |
|
1920 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1921 | + <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> |
|
1922 | 1922 | <?php } ?> |
1923 | 1923 | </div> |
1924 | 1924 | <?php |
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | } |
1928 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1928 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1929 | 1929 | |
1930 | -function wpinv_invoice_link( $invoice_id ) { |
|
1931 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1930 | +function wpinv_invoice_link($invoice_id) { |
|
1931 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1932 | 1932 | |
1933 | - if ( empty( $invoice ) ) { |
|
1933 | + if (empty($invoice)) { |
|
1934 | 1934 | return NULL; |
1935 | 1935 | } |
1936 | 1936 | |
1937 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1937 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1938 | 1938 | |
1939 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1939 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1940 | 1940 | } |
1941 | 1941 | |
1942 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1943 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
1942 | +function wpinv_invoice_subscription_details($invoice) { |
|
1943 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1944 | 1944 | $total_payments = (int)$invoice->get_total_payments(); |
1945 | 1945 | $payments = $invoice->get_child_payments(); |
1946 | 1946 | |
1947 | 1947 | $subscription = $invoice->get_subscription_data(); |
1948 | 1948 | |
1949 | - if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) { |
|
1949 | + if (!(!empty($subscription) && !empty($subscription['item_id']))) { |
|
1950 | 1950 | return; |
1951 | 1951 | } |
1952 | 1952 | |
1953 | - $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() ); |
|
1954 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
1953 | + $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()); |
|
1954 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
1955 | 1955 | |
1956 | 1956 | $subscription_status = $invoice->get_subscription_status(); |
1957 | 1957 | |
1958 | 1958 | $status_desc = ''; |
1959 | - if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { |
|
1960 | - $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date ); |
|
1961 | - } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) { |
|
1962 | - $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date ); |
|
1959 | + if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { |
|
1960 | + $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date); |
|
1961 | + } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) { |
|
1962 | + $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date); |
|
1963 | 1963 | } |
1964 | 1964 | $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : ''; |
1965 | 1965 | ?> |
1966 | 1966 | <div class="wpinv-subscriptions-details"> |
1967 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1967 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1968 | 1968 | <table class="table"> |
1969 | 1969 | <thead> |
1970 | 1970 | <tr> |
1971 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1972 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1973 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1974 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1975 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1971 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1972 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1973 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1974 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1975 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1976 | 1976 | </tr> |
1977 | 1977 | </thead> |
1978 | 1978 | <tbody> |
@@ -1981,32 +1981,32 @@ discard block |
||
1981 | 1981 | <td><?php echo $invoice->get_subscription_start(); ?></td> |
1982 | 1982 | <td><?php echo $invoice->get_subscription_end(); ?></td> |
1983 | 1983 | <td class="text-center"><?php echo $times_billed; ?></td> |
1984 | - <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?> |
|
1984 | + <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?> |
|
1985 | 1985 | <?php echo $status_desc; ?> |
1986 | 1986 | </td> |
1987 | 1987 | </tr> |
1988 | 1988 | </tbody> |
1989 | 1989 | </table> |
1990 | 1990 | </div> |
1991 | - <?php if ( !empty( $payments ) ) { ?> |
|
1991 | + <?php if (!empty($payments)) { ?> |
|
1992 | 1992 | <div class="wpinv-renewal-payments"> |
1993 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
1993 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
1994 | 1994 | <table class="table"> |
1995 | 1995 | <thead> |
1996 | 1996 | <tr> |
1997 | 1997 | <th>#</th> |
1998 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
1999 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
2000 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
1998 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
1999 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
2000 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
2001 | 2001 | </tr> |
2002 | 2002 | </thead> |
2003 | 2003 | <tbody> |
2004 | - <?php foreach ( $payments as $key => $invoice_id ) { ?> |
|
2004 | + <?php foreach ($payments as $key => $invoice_id) { ?> |
|
2005 | 2005 | <tr> |
2006 | - <th scope="row"><?php echo ( $key + 1 );?></th> |
|
2007 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2008 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2009 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2006 | + <th scope="row"><?php echo ($key + 1); ?></th> |
|
2007 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2008 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2009 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2010 | 2010 | </tr> |
2011 | 2011 | <?php } ?> |
2012 | 2012 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -2018,52 +2018,52 @@ discard block |
||
2018 | 2018 | } |
2019 | 2019 | } |
2020 | 2020 | |
2021 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2022 | - if ( empty( $invoice ) ) { |
|
2021 | +function wpinv_cart_total_label($label, $invoice) { |
|
2022 | + if (empty($invoice)) { |
|
2023 | 2023 | return $label; |
2024 | 2024 | } |
2025 | 2025 | |
2026 | 2026 | $prefix_label = ''; |
2027 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2028 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2029 | - } else if ( $invoice->is_renewal() ) { |
|
2030 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2027 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2028 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2029 | + } else if ($invoice->is_renewal()) { |
|
2030 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2031 | 2031 | } |
2032 | 2032 | |
2033 | - if ( $prefix_label != '' ) { |
|
2034 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2033 | + if ($prefix_label != '') { |
|
2034 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | return $label; |
2038 | 2038 | } |
2039 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2040 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2041 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2039 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2040 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2041 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2042 | 2042 | |
2043 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2043 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2044 | 2044 | |
2045 | -function wpinv_invoice_print_description( $invoice ) { |
|
2046 | - if ( empty( $invoice ) ) { |
|
2045 | +function wpinv_invoice_print_description($invoice) { |
|
2046 | + if (empty($invoice)) { |
|
2047 | 2047 | return NULL; |
2048 | 2048 | } |
2049 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2049 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2050 | 2050 | ?> |
2051 | 2051 | <div class="row wpinv-lower"> |
2052 | 2052 | <div class="col-sm-12 wpinv-description"> |
2053 | - <?php echo wpautop( $description ); ?> |
|
2053 | + <?php echo wpautop($description); ?> |
|
2054 | 2054 | </div> |
2055 | 2055 | </div> |
2056 | 2056 | <?php |
2057 | 2057 | } |
2058 | 2058 | } |
2059 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2059 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2060 | 2060 | |
2061 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2062 | - if ( empty( $invoice ) ) { |
|
2061 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2062 | + if (empty($invoice)) { |
|
2063 | 2063 | return NULL; |
2064 | 2064 | } |
2065 | 2065 | |
2066 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2066 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2067 | 2067 | ?> |
2068 | 2068 | <div class="row wpinv-payments"> |
2069 | 2069 | <div class="col-sm-12"> |
@@ -2075,43 +2075,43 @@ discard block |
||
2075 | 2075 | } |
2076 | 2076 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2077 | 2077 | |
2078 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2079 | - if ( empty( $note ) ) { |
|
2078 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2079 | + if (empty($note)) { |
|
2080 | 2080 | return NULL; |
2081 | 2081 | } |
2082 | 2082 | |
2083 | - if ( is_int( $note ) ) { |
|
2084 | - $note = get_comment( $note ); |
|
2083 | + if (is_int($note)) { |
|
2084 | + $note = get_comment($note); |
|
2085 | 2085 | } |
2086 | 2086 | |
2087 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2087 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2088 | 2088 | return NULL; |
2089 | 2089 | } |
2090 | 2090 | |
2091 | - $note_classes = array( 'note' ); |
|
2092 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2093 | - $note_classes[] = $note->comment_author === __( 'System', 'invoicing' ) ? 'system-note' : ''; |
|
2094 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2095 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2091 | + $note_classes = array('note'); |
|
2092 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2093 | + $note_classes[] = $note->comment_author === __('System', 'invoicing') ? 'system-note' : ''; |
|
2094 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2095 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2096 | 2096 | |
2097 | 2097 | ob_start(); |
2098 | 2098 | ?> |
2099 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2099 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2100 | 2100 | <div class="note_content"> |
2101 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2101 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2102 | 2102 | </div> |
2103 | 2103 | <p class="meta"> |
2104 | - <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> |
|
2105 | - <?php if($note->comment_author !== 'System') {?> |
|
2106 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2104 | + <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> |
|
2105 | + <?php if ($note->comment_author !== 'System') {?> |
|
2106 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2107 | 2107 | <?php } ?> |
2108 | 2108 | </p> |
2109 | 2109 | </li> |
2110 | 2110 | <?php |
2111 | 2111 | $note_content = ob_get_clean(); |
2112 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2112 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2113 | 2113 | |
2114 | - if ( $echo ) { |
|
2114 | + if ($echo) { |
|
2115 | 2115 | echo $note_content; |
2116 | 2116 | } else { |
2117 | 2117 | return $note_content; |
@@ -2121,33 +2121,33 @@ discard block |
||
2121 | 2121 | function wpinv_invalid_invoice_content() { |
2122 | 2122 | global $post; |
2123 | 2123 | |
2124 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
2124 | + $invoice = wpinv_get_invoice($post->ID); |
|
2125 | 2125 | |
2126 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
2127 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
2128 | - if ( is_user_logged_in() ) { |
|
2129 | - if ( wpinv_require_login_to_checkout() ) { |
|
2130 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2131 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
2126 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
2127 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
2128 | + if (is_user_logged_in()) { |
|
2129 | + if (wpinv_require_login_to_checkout()) { |
|
2130 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2131 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
2132 | 2132 | } |
2133 | 2133 | } |
2134 | 2134 | } else { |
2135 | - if ( wpinv_require_login_to_checkout() ) { |
|
2136 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2137 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
2135 | + if (wpinv_require_login_to_checkout()) { |
|
2136 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2137 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
2138 | 2138 | } |
2139 | 2139 | } |
2140 | 2140 | } |
2141 | 2141 | } else { |
2142 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
2142 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
2143 | 2143 | } |
2144 | 2144 | ?> |
2145 | 2145 | <div class="row wpinv-row-invalid"> |
2146 | 2146 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
2147 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
2147 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
2148 | 2148 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
2149 | 2149 | </div> |
2150 | 2150 | </div> |
2151 | 2151 | <?php |
2152 | 2152 | } |
2153 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
2154 | 2153 | \ No newline at end of file |
2154 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
2155 | 2155 | \ No newline at end of file |