@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if ( ! empty( $_GET['id'] ) ) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
15 | - return; |
|
15 | + return; |
|
16 | 16 | |
17 | - } |
|
18 | - ?> |
|
17 | + } |
|
18 | + ?> |
|
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
23 | 23 | </h1> |
24 | 24 | <?php |
25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | - $subscribers_table->prepare_items(); |
|
27 | - ?> |
|
25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | + $subscribers_table->prepare_items(); |
|
27 | + ?> |
|
28 | 28 | |
29 | 29 | <form id="subscribers-filter" method="get"> |
30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function wpinv_recurring_subscription_details() { |
49 | 49 | |
50 | - $render = true; |
|
50 | + $render = true; |
|
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | - } |
|
52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | + } |
|
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int) $_GET['id']; |
|
61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | - } |
|
63 | + if ( empty( $sub ) ) { |
|
64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - ?> |
|
67 | + ?> |
|
68 | 68 | <div class="wrap"> |
69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | - ?> |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | + ?> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | ?> |
136 | 136 | <a href="<?php echo esc_url( add_query_arg( array( |
137 | - 'post' => $sub->product_id, |
|
138 | - 'action' => 'edit' |
|
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
137 | + 'post' => $sub->product_id, |
|
138 | + 'action' => 'edit' |
|
139 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
@@ -299,56 +299,56 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
303 | - return; |
|
304 | - } |
|
302 | + if( empty( $_POST['sub_id'] ) ) { |
|
303 | + return; |
|
304 | + } |
|
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | - return; |
|
308 | - } |
|
306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | - return; |
|
312 | - } |
|
310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | + return; |
|
312 | + } |
|
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | - } |
|
314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | + } |
|
317 | 317 | |
318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | - $product_id = absint( $_POST['product_id'] ); |
|
321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | - $subscription->update( array( |
|
323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | - 'profile_id' => $profile_id, |
|
325 | - 'product_id' => $product_id, |
|
326 | - 'transaction_id' => $transaction_id, |
|
327 | - ) ); |
|
318 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | + $product_id = absint( $_POST['product_id'] ); |
|
321 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | + $subscription->update( array( |
|
323 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | + 'profile_id' => $profile_id, |
|
325 | + 'product_id' => $product_id, |
|
326 | + 'transaction_id' => $transaction_id, |
|
327 | + ) ); |
|
328 | 328 | |
329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
329 | + $status = sanitize_text_field( $_POST['status'] ); |
|
330 | 330 | |
331 | - switch( $status ) { |
|
331 | + switch( $status ) { |
|
332 | 332 | |
333 | - case 'cancelled' : |
|
333 | + case 'cancelled' : |
|
334 | 334 | |
335 | - $subscription->cancel(); |
|
336 | - break; |
|
335 | + $subscription->cancel(); |
|
336 | + break; |
|
337 | 337 | |
338 | - case 'expired' : |
|
338 | + case 'expired' : |
|
339 | 339 | |
340 | - $subscription->expire(); |
|
341 | - break; |
|
340 | + $subscription->expire(); |
|
341 | + break; |
|
342 | 342 | |
343 | - case 'completed' : |
|
343 | + case 'completed' : |
|
344 | 344 | |
345 | - $subscription->complete(); |
|
346 | - break; |
|
345 | + $subscription->complete(); |
|
346 | + break; |
|
347 | 347 | |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | - exit; |
|
350 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | + exit; |
|
352 | 352 | |
353 | 353 | } |
354 | 354 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -362,30 +362,30 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
364 | 364 | |
365 | - if( empty( $_POST['sub_id'] ) ) { |
|
366 | - return; |
|
367 | - } |
|
365 | + if( empty( $_POST['sub_id'] ) ) { |
|
366 | + return; |
|
367 | + } |
|
368 | 368 | |
369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | - return; |
|
371 | - } |
|
369 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | + return; |
|
371 | + } |
|
372 | 372 | |
373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | - return; |
|
375 | - } |
|
373 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | + return; |
|
375 | + } |
|
376 | 376 | |
377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | - } |
|
377 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | + } |
|
380 | 380 | |
381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
381 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
382 | 382 | |
383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
383 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
384 | 384 | |
385 | - $subscription->delete(); |
|
385 | + $subscription->delete(); |
|
386 | 386 | |
387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | - exit; |
|
387 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | + exit; |
|
389 | 389 | |
390 | 390 | } |
391 | 391 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | } |
670 | 670 | |
671 | 671 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
672 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
672 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
673 | 673 | return $invoice->get_key(); |
674 | 674 | } |
675 | 675 | |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | return false; |
920 | 920 | } |
921 | 921 | $invoice = wpinv_get_invoice_cart(); |
922 | - if ( empty( $invoice ) ) { |
|
922 | + if ( empty( $invoice ) ) { |
|
923 | 923 | return false; |
924 | 924 | } |
925 | 925 | |
@@ -1212,20 +1212,20 @@ discard block |
||
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | function wpinv_checkout_get_cc_info() { |
1215 | - $cc_info = array(); |
|
1216 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
1217 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
1218 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
1219 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
1220 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
1221 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
1222 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
1223 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
1224 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
1225 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
1226 | - |
|
1227 | - // Return cc info |
|
1228 | - return $cc_info; |
|
1215 | + $cc_info = array(); |
|
1216 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
1217 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
1218 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
1219 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
1220 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
1221 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
1222 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
1223 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
1224 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
1225 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
1226 | + |
|
1227 | + // Return cc info |
|
1228 | + return $cc_info; |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -1422,7 +1422,7 @@ discard block |
||
1422 | 1422 | $required_fields = wpinv_checkout_required_fields(); |
1423 | 1423 | |
1424 | 1424 | // Loop through required fields and show error messages |
1425 | - if ( !empty( $required_fields ) ) { |
|
1425 | + if ( !empty( $required_fields ) ) { |
|
1426 | 1426 | foreach ( $required_fields as $field_name => $value ) { |
1427 | 1427 | if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
1428 | 1428 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | function wpinv_get_checkout_session() { |
1531 | - global $wpi_session; |
|
1531 | + global $wpi_session; |
|
1532 | 1532 | |
1533 | 1533 | return $wpi_session->get( 'wpinv_checkout' ); |
1534 | 1534 | } |
@@ -1891,57 +1891,57 @@ discard block |
||
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | function wpinv_get_invoice_id_by_key( $key ) { |
1894 | - global $wpdb; |
|
1894 | + global $wpdb; |
|
1895 | 1895 | |
1896 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1896 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1897 | 1897 | |
1898 | - if ( $invoice_id != NULL ) |
|
1899 | - return $invoice_id; |
|
1898 | + if ( $invoice_id != NULL ) |
|
1899 | + return $invoice_id; |
|
1900 | 1900 | |
1901 | - return 0; |
|
1901 | + return 0; |
|
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
1905 | - $return = false; |
|
1906 | - |
|
1907 | - if ( empty( $invoice_key ) ) { |
|
1908 | - return $return; |
|
1909 | - } |
|
1910 | - |
|
1911 | - global $wpinv_receipt_args; |
|
1912 | - |
|
1913 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1914 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
1915 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1916 | - } |
|
1917 | - |
|
1918 | - if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
1919 | - return $return; |
|
1920 | - } |
|
1921 | - |
|
1922 | - $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
1923 | - if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
1924 | - return $return; |
|
1925 | - } |
|
1926 | - |
|
1927 | - if ( is_user_logged_in() ) { |
|
1928 | - if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
1929 | - $return = true; |
|
1930 | - } |
|
1931 | - } |
|
1932 | - |
|
1933 | - $session = wpinv_get_checkout_session(); |
|
1934 | - if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
1935 | - $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
1936 | - |
|
1937 | - if ( wpinv_require_login_to_checkout() ) { |
|
1938 | - $return = $return && $check_key === $invoice_key; |
|
1939 | - } else { |
|
1940 | - $return = $check_key === $invoice_key; |
|
1941 | - } |
|
1942 | - } |
|
1943 | - |
|
1944 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1905 | + $return = false; |
|
1906 | + |
|
1907 | + if ( empty( $invoice_key ) ) { |
|
1908 | + return $return; |
|
1909 | + } |
|
1910 | + |
|
1911 | + global $wpinv_receipt_args; |
|
1912 | + |
|
1913 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1914 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
1915 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1916 | + } |
|
1917 | + |
|
1918 | + if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
1919 | + return $return; |
|
1920 | + } |
|
1921 | + |
|
1922 | + $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
1923 | + if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
1924 | + return $return; |
|
1925 | + } |
|
1926 | + |
|
1927 | + if ( is_user_logged_in() ) { |
|
1928 | + if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
1929 | + $return = true; |
|
1930 | + } |
|
1931 | + } |
|
1932 | + |
|
1933 | + $session = wpinv_get_checkout_session(); |
|
1934 | + if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
1935 | + $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
1936 | + |
|
1937 | + if ( wpinv_require_login_to_checkout() ) { |
|
1938 | + $return = $return && $check_key === $invoice_key; |
|
1939 | + } else { |
|
1940 | + $return = $check_key === $invoice_key; |
|
1941 | + } |
|
1942 | + } |
|
1943 | + |
|
1944 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1945 | 1945 | } |
1946 | 1946 | |
1947 | 1947 | function wpinv_pay_for_invoice() { |
@@ -31,27 +31,27 @@ |
||
31 | 31 | public function get_privacy_message() { |
32 | 32 | |
33 | 33 | $content = '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' . |
34 | - '<div contenteditable="false">' . |
|
35 | - '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' . |
|
36 | - '</div>' . |
|
37 | - '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' . |
|
38 | - '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' . |
|
39 | - '<ul>' . |
|
40 | - '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' . |
|
41 | - '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' . |
|
42 | - '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' . |
|
43 | - '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
44 | - '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' . |
|
45 | - '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
46 | - '</ul>' . |
|
47 | - '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' . |
|
48 | - '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' . |
|
49 | - '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' . |
|
50 | - '<div contenteditable="false">' . |
|
51 | - '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' . |
|
52 | - '</div>' . |
|
53 | - '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' . |
|
54 | - '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>'; |
|
34 | + '<div contenteditable="false">' . |
|
35 | + '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' . |
|
36 | + '</div>' . |
|
37 | + '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' . |
|
38 | + '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' . |
|
39 | + '<ul>' . |
|
40 | + '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' . |
|
41 | + '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' . |
|
42 | + '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' . |
|
43 | + '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
44 | + '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' . |
|
45 | + '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
46 | + '</ul>' . |
|
47 | + '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' . |
|
48 | + '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' . |
|
49 | + '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' . |
|
50 | + '<div contenteditable="false">' . |
|
51 | + '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' . |
|
52 | + '</div>' . |
|
53 | + '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' . |
|
54 | + '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | class OxidInstaller extends BaseInstaller |
7 | 7 | { |
8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
8 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
9 | 9 | |
10 | 10 | protected $locations = array( |
11 | 11 | 'module' => 'modules/{$name}/', |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | 'out' => 'out/{$name}/', |
14 | 14 | ); |
15 | 15 | |
16 | - /** |
|
17 | - * getInstallPath |
|
18 | - * |
|
19 | - * @param PackageInterface $package |
|
20 | - * @param string $frameworkType |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | - { |
|
25 | - $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | - $type = $this->package->getType(); |
|
27 | - if ($type === 'oxid-module') { |
|
28 | - $this->prepareVendorDirectory($installPath); |
|
29 | - } |
|
30 | - return $installPath; |
|
31 | - } |
|
16 | + /** |
|
17 | + * getInstallPath |
|
18 | + * |
|
19 | + * @param PackageInterface $package |
|
20 | + * @param string $frameworkType |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | + { |
|
25 | + $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | + $type = $this->package->getType(); |
|
27 | + if ($type === 'oxid-module') { |
|
28 | + $this->prepareVendorDirectory($installPath); |
|
29 | + } |
|
30 | + return $installPath; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * prepareVendorDirectory |
|
35 | - * |
|
36 | - * Makes sure there is a vendormetadata.php file inside |
|
37 | - * the vendor folder if there is a vendor folder. |
|
38 | - * |
|
39 | - * @param string $installPath |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected function prepareVendorDirectory($installPath) |
|
43 | - { |
|
44 | - $matches = ''; |
|
45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | - if (!$hasVendorDirectory) { |
|
47 | - return; |
|
48 | - } |
|
33 | + /** |
|
34 | + * prepareVendorDirectory |
|
35 | + * |
|
36 | + * Makes sure there is a vendormetadata.php file inside |
|
37 | + * the vendor folder if there is a vendor folder. |
|
38 | + * |
|
39 | + * @param string $installPath |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected function prepareVendorDirectory($installPath) |
|
43 | + { |
|
44 | + $matches = ''; |
|
45 | + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | + if (!$hasVendorDirectory) { |
|
47 | + return; |
|
48 | + } |
|
49 | 49 | |
50 | - $vendorDirectory = $matches['vendor']; |
|
51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | - if (!file_exists($vendorPath)) { |
|
53 | - mkdir($vendorPath, 0755, true); |
|
54 | - } |
|
50 | + $vendorDirectory = $matches['vendor']; |
|
51 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | + if (!file_exists($vendorPath)) { |
|
53 | + mkdir($vendorPath, 0755, true); |
|
54 | + } |
|
55 | 55 | |
56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | - touch($vendorMetaDataPath); |
|
58 | - } |
|
56 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | + touch($vendorMetaDataPath); |
|
58 | + } |
|
59 | 59 | } |
@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | class ClanCatsFrameworkInstaller extends BaseInstaller |
5 | 5 | { |
6 | - protected $locations = array( |
|
7 | - 'ship' => 'CCF/orbit/{$name}/', |
|
8 | - 'theme' => 'CCF/app/themes/{$name}/', |
|
9 | - ); |
|
6 | + protected $locations = array( |
|
7 | + 'ship' => 'CCF/orbit/{$name}/', |
|
8 | + 'theme' => 'CCF/app/themes/{$name}/', |
|
9 | + ); |
|
10 | 10 | } |
11 | 11 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | 'library' => 'libraries/{$name}/', |
11 | 11 | 'profile' => 'profiles/{$name}/', |
12 | 12 | 'drush' => 'drush/{$name}/', |
13 | - 'custom-theme' => 'themes/custom/{$name}/', |
|
14 | - 'custom-module' => 'modules/custom/{$name}/', |
|
13 | + 'custom-theme' => 'themes/custom/{$name}/', |
|
14 | + 'custom-module' => 'modules/custom/{$name}/', |
|
15 | 15 | ); |
16 | 16 | } |
@@ -799,7 +799,7 @@ |
||
799 | 799 | case 'trial_interval': |
800 | 800 | $value = absint( $value ); |
801 | 801 | break; |
802 | - case 'editable': |
|
802 | + case 'editable': |
|
803 | 803 | $value = (int) $value; |
804 | 804 | break; |
805 | 805 | } |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | function wpinv_can_checkout() { |
33 | - $can_checkout = true; // Always true for now |
|
33 | + $can_checkout = true; // Always true for now |
|
34 | 34 | |
35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function wpinv_get_success_page_uri() { |
39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | - $page_id = absint( $page_id ); |
|
39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | + $page_id = absint( $page_id ); |
|
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function wpinv_get_history_page_uri() { |
46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | - $page_id = absint( $page_id ); |
|
46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | + $page_id = absint( $page_id ); |
|
48 | 48 | |
49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function wpinv_is_success_page() { |
53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
55 | 55 | |
56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_invoice_history_page() { |
60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | - $ret = $ret ? is_page( $ret ) : false; |
|
62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | + $ret = $ret ? is_page( $ret ) : false; |
|
62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | function wpinv_is_subscriptions_history_page() { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_send_to_success_page( $args = null ) { |
72 | - $redirect = wpinv_get_success_page_uri(); |
|
72 | + $redirect = wpinv_get_success_page_uri(); |
|
73 | 73 | |
74 | 74 | if ( !empty( $args ) ) { |
75 | 75 | // Check for backward compatibility |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_send_to_failed_page( $args = null ) { |
92 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
92 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
93 | 93 | |
94 | 94 | if ( !empty( $args ) ) { |
95 | 95 | // Check for backward compatibility |
@@ -109,72 +109,72 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | function wpinv_get_checkout_uri( $args = array() ) { |
112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
112 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | 114 | |
115 | - if ( !empty( $args ) ) { |
|
116 | - // Check for backward compatibility |
|
117 | - if ( is_string( $args ) ) |
|
118 | - $args = str_replace( '?', '', $args ); |
|
115 | + if ( !empty( $args ) ) { |
|
116 | + // Check for backward compatibility |
|
117 | + if ( is_string( $args ) ) |
|
118 | + $args = str_replace( '?', '', $args ); |
|
119 | 119 | |
120 | - $args = wp_parse_args( $args ); |
|
120 | + $args = wp_parse_args( $args ); |
|
121 | 121 | |
122 | - $uri = add_query_arg( $args, $uri ); |
|
123 | - } |
|
122 | + $uri = add_query_arg( $args, $uri ); |
|
123 | + } |
|
124 | 124 | |
125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
125 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | 126 | |
127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
127 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
128 | 128 | |
129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | - } |
|
129 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | + } |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
133 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | function wpinv_send_back_to_checkout( $args = array() ) { |
137 | - $redirect = wpinv_get_checkout_uri(); |
|
137 | + $redirect = wpinv_get_checkout_uri(); |
|
138 | 138 | |
139 | - if ( ! empty( $args ) ) { |
|
140 | - // Check for backward compatibility |
|
141 | - if ( is_string( $args ) ) |
|
142 | - $args = str_replace( '?', '', $args ); |
|
139 | + if ( ! empty( $args ) ) { |
|
140 | + // Check for backward compatibility |
|
141 | + if ( is_string( $args ) ) |
|
142 | + $args = str_replace( '?', '', $args ); |
|
143 | 143 | |
144 | - $args = wp_parse_args( $args ); |
|
144 | + $args = wp_parse_args( $args ); |
|
145 | 145 | |
146 | - $redirect = add_query_arg( $args, $redirect ); |
|
147 | - } |
|
146 | + $redirect = add_query_arg( $args, $redirect ); |
|
147 | + } |
|
148 | 148 | |
149 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | - exit; |
|
149 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | + exit; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | function wpinv_get_success_page_url( $query_string = null ) { |
154 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | - $success_page = get_permalink( $success_page ); |
|
154 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | + $success_page = get_permalink( $success_page ); |
|
156 | 156 | |
157 | - if ( $query_string ) |
|
158 | - $success_page .= $query_string; |
|
157 | + if ( $query_string ) |
|
158 | + $success_page .= $query_string; |
|
159 | 159 | |
160 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
160 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
164 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
164 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
166 | 166 | |
167 | - if ( $extras ) |
|
168 | - $uri .= $extras; |
|
167 | + if ( $extras ) |
|
168 | + $uri .= $extras; |
|
169 | 169 | |
170 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
170 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_is_failed_transaction_page() { |
174 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
174 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
176 | 176 | |
177 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
177 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -320,36 +320,36 @@ discard block |
||
320 | 320 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
321 | 321 | |
322 | 322 | if ( $require_billing_details ) { |
323 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
324 | - $required_fields['first_name'] = array( |
|
325 | - 'error_id' => 'invalid_first_name', |
|
326 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
327 | - ); |
|
328 | - } |
|
329 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
330 | - $required_fields['address'] = array( |
|
331 | - 'error_id' => 'invalid_address', |
|
332 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
333 | - ); |
|
334 | - } |
|
335 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
336 | - $required_fields['city'] = array( |
|
337 | - 'error_id' => 'invalid_city', |
|
338 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
339 | - ); |
|
340 | - } |
|
341 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
342 | - $required_fields['state'] = array( |
|
343 | - 'error_id' => 'invalid_state', |
|
344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
345 | - ); |
|
346 | - } |
|
347 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
348 | - $required_fields['country'] = array( |
|
349 | - 'error_id' => 'invalid_country', |
|
350 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
351 | - ); |
|
352 | - } |
|
323 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
324 | + $required_fields['first_name'] = array( |
|
325 | + 'error_id' => 'invalid_first_name', |
|
326 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
327 | + ); |
|
328 | + } |
|
329 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
330 | + $required_fields['address'] = array( |
|
331 | + 'error_id' => 'invalid_address', |
|
332 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
333 | + ); |
|
334 | + } |
|
335 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
336 | + $required_fields['city'] = array( |
|
337 | + 'error_id' => 'invalid_city', |
|
338 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
339 | + ); |
|
340 | + } |
|
341 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
342 | + $required_fields['state'] = array( |
|
343 | + 'error_id' => 'invalid_state', |
|
344 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
345 | + ); |
|
346 | + } |
|
347 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
348 | + $required_fields['country'] = array( |
|
349 | + 'error_id' => 'invalid_country', |
|
350 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
351 | + ); |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -955,326 +955,326 @@ discard block |
||
955 | 955 | } |
956 | 956 | |
957 | 957 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
958 | - $pages_options = array(); |
|
958 | + $pages_options = array(); |
|
959 | 959 | |
960 | - if( $default_label !== NULL && $default_label !== false ) { |
|
961 | - $pages_options = array( '' => $default_label ); // Blank option |
|
962 | - } |
|
960 | + if( $default_label !== NULL && $default_label !== false ) { |
|
961 | + $pages_options = array( '' => $default_label ); // Blank option |
|
962 | + } |
|
963 | 963 | |
964 | - $pages = get_pages(); |
|
965 | - if ( $pages ) { |
|
966 | - foreach ( $pages as $page ) { |
|
967 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
964 | + $pages = get_pages(); |
|
965 | + if ( $pages ) { |
|
966 | + foreach ( $pages as $page ) { |
|
967 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
968 | 968 | $pages_options[ $page->ID ] = $title; |
969 | - } |
|
970 | - } |
|
969 | + } |
|
970 | + } |
|
971 | 971 | |
972 | - return $pages_options; |
|
972 | + return $pages_options; |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | function wpinv_header_callback( $args ) { |
976 | - if ( !empty( $args['desc'] ) ) { |
|
976 | + if ( !empty( $args['desc'] ) ) { |
|
977 | 977 | echo $args['desc']; |
978 | 978 | } |
979 | 979 | } |
980 | 980 | |
981 | 981 | function wpinv_hidden_callback( $args ) { |
982 | - global $wpinv_options; |
|
983 | - |
|
984 | - if ( isset( $args['set_value'] ) ) { |
|
985 | - $value = $args['set_value']; |
|
986 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
987 | - $value = $wpinv_options[ $args['id'] ]; |
|
988 | - } else { |
|
989 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
990 | - } |
|
991 | - |
|
992 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
993 | - $args['readonly'] = true; |
|
994 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
995 | - $name = ''; |
|
996 | - } else { |
|
997 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
998 | - } |
|
999 | - |
|
1000 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
982 | + global $wpinv_options; |
|
983 | + |
|
984 | + if ( isset( $args['set_value'] ) ) { |
|
985 | + $value = $args['set_value']; |
|
986 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
987 | + $value = $wpinv_options[ $args['id'] ]; |
|
988 | + } else { |
|
989 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
990 | + } |
|
991 | + |
|
992 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
993 | + $args['readonly'] = true; |
|
994 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
995 | + $name = ''; |
|
996 | + } else { |
|
997 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
998 | + } |
|
999 | + |
|
1000 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
1001 | 1001 | |
1002 | - echo $html; |
|
1002 | + echo $html; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | function wpinv_checkbox_callback( $args ) { |
1006 | - global $wpinv_options; |
|
1006 | + global $wpinv_options; |
|
1007 | 1007 | |
1008 | 1008 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1009 | 1009 | |
1010 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1011 | - $name = ''; |
|
1012 | - } else { |
|
1013 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
1014 | - } |
|
1010 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1011 | + $name = ''; |
|
1012 | + } else { |
|
1013 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
1014 | + } |
|
1015 | 1015 | |
1016 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
1017 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
1018 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1016 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
1017 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
1018 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1019 | 1019 | |
1020 | - echo $html; |
|
1020 | + echo $html; |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | function wpinv_multicheck_callback( $args ) { |
1024 | - global $wpinv_options; |
|
1024 | + global $wpinv_options; |
|
1025 | 1025 | |
1026 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1027 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
1026 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1027 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
1028 | 1028 | |
1029 | - if ( ! empty( $args['options'] ) ) { |
|
1030 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
1029 | + if ( ! empty( $args['options'] ) ) { |
|
1030 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
1031 | 1031 | foreach( $args['options'] as $key => $option ): |
1032 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1033 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
1034 | - $enabled = $sanitize_key; |
|
1035 | - } else { |
|
1036 | - $enabled = NULL; |
|
1037 | - } |
|
1038 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
1039 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
1040 | - endforeach; |
|
1041 | - echo '</div>'; |
|
1042 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
1043 | - } |
|
1032 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1033 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
1034 | + $enabled = $sanitize_key; |
|
1035 | + } else { |
|
1036 | + $enabled = NULL; |
|
1037 | + } |
|
1038 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
1039 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
1040 | + endforeach; |
|
1041 | + echo '</div>'; |
|
1042 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
1043 | + } |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | function wpinv_payment_icons_callback( $args ) { |
1047 | - global $wpinv_options; |
|
1047 | + global $wpinv_options; |
|
1048 | 1048 | |
1049 | 1049 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1050 | 1050 | |
1051 | - if ( ! empty( $args['options'] ) ) { |
|
1052 | - foreach( $args['options'] as $key => $option ) { |
|
1051 | + if ( ! empty( $args['options'] ) ) { |
|
1052 | + foreach( $args['options'] as $key => $option ) { |
|
1053 | 1053 | $sanitize_key = wpinv_sanitize_key( $key ); |
1054 | 1054 | |
1055 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
1056 | - $enabled = $option; |
|
1057 | - } else { |
|
1058 | - $enabled = NULL; |
|
1059 | - } |
|
1060 | - |
|
1061 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
1062 | - |
|
1063 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
1064 | - |
|
1065 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
1066 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1067 | - } else { |
|
1068 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
1069 | - |
|
1070 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
1071 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
1072 | - } else { |
|
1073 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
1074 | - $content_dir = WP_CONTENT_DIR; |
|
1075 | - |
|
1076 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
1077 | - // Replaces backslashes with forward slashes for Windows systems |
|
1078 | - $image = wp_normalize_path( $image ); |
|
1079 | - $content_dir = wp_normalize_path( $content_dir ); |
|
1080 | - } |
|
1081 | - |
|
1082 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
1083 | - } |
|
1084 | - |
|
1085 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1086 | - } |
|
1087 | - echo $option . '</label>'; |
|
1088 | - } |
|
1089 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1090 | - } |
|
1055 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
1056 | + $enabled = $option; |
|
1057 | + } else { |
|
1058 | + $enabled = NULL; |
|
1059 | + } |
|
1060 | + |
|
1061 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
1062 | + |
|
1063 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
1064 | + |
|
1065 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
1066 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1067 | + } else { |
|
1068 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
1069 | + |
|
1070 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
1071 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
1072 | + } else { |
|
1073 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
1074 | + $content_dir = WP_CONTENT_DIR; |
|
1075 | + |
|
1076 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
1077 | + // Replaces backslashes with forward slashes for Windows systems |
|
1078 | + $image = wp_normalize_path( $image ); |
|
1079 | + $content_dir = wp_normalize_path( $content_dir ); |
|
1080 | + } |
|
1081 | + |
|
1082 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
1083 | + } |
|
1084 | + |
|
1085 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1086 | + } |
|
1087 | + echo $option . '</label>'; |
|
1088 | + } |
|
1089 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1090 | + } |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | function wpinv_radio_callback( $args ) { |
1094 | - global $wpinv_options; |
|
1094 | + global $wpinv_options; |
|
1095 | 1095 | |
1096 | 1096 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1097 | 1097 | |
1098 | 1098 | foreach ( $args['options'] as $key => $option ) : |
1099 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1099 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1100 | 1100 | |
1101 | 1101 | $checked = false; |
1102 | 1102 | |
1103 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1104 | - $checked = true; |
|
1105 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1106 | - $checked = true; |
|
1103 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1104 | + $checked = true; |
|
1105 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1106 | + $checked = true; |
|
1107 | 1107 | |
1108 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
1109 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1110 | - endforeach; |
|
1108 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
1109 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1110 | + endforeach; |
|
1111 | 1111 | |
1112 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1112 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | function wpinv_gateways_callback( $args ) { |
1116 | - global $wpinv_options; |
|
1116 | + global $wpinv_options; |
|
1117 | 1117 | |
1118 | 1118 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1119 | 1119 | |
1120 | - foreach ( $args['options'] as $key => $option ) : |
|
1121 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1120 | + foreach ( $args['options'] as $key => $option ) : |
|
1121 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1122 | 1122 | |
1123 | 1123 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
1124 | - $enabled = '1'; |
|
1125 | - else |
|
1126 | - $enabled = null; |
|
1124 | + $enabled = '1'; |
|
1125 | + else |
|
1126 | + $enabled = null; |
|
1127 | 1127 | |
1128 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1129 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1130 | - endforeach; |
|
1128 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1129 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1130 | + endforeach; |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | function wpinv_gateway_select_callback($args) { |
1134 | - global $wpinv_options; |
|
1134 | + global $wpinv_options; |
|
1135 | 1135 | |
1136 | 1136 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1137 | 1137 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
1138 | 1138 | |
1139 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
1139 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
1140 | 1140 | |
1141 | - foreach ( $args['options'] as $key => $option ) : |
|
1142 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1141 | + foreach ( $args['options'] as $key => $option ) : |
|
1142 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1143 | 1143 | $selected = selected( $key, $args['selected'], false ); |
1144 | 1144 | } else { |
1145 | 1145 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
1146 | 1146 | } |
1147 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1148 | - endforeach; |
|
1147 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1148 | + endforeach; |
|
1149 | 1149 | |
1150 | - echo '</select>'; |
|
1151 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1150 | + echo '</select>'; |
|
1151 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | function wpinv_text_callback( $args ) { |
1155 | - global $wpinv_options; |
|
1155 | + global $wpinv_options; |
|
1156 | 1156 | |
1157 | 1157 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1158 | 1158 | |
1159 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1160 | - $value = $wpinv_options[ $args['id'] ]; |
|
1161 | - } else { |
|
1162 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1163 | - } |
|
1164 | - |
|
1165 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1166 | - $args['readonly'] = true; |
|
1167 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1168 | - $name = ''; |
|
1169 | - } else { |
|
1170 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1171 | - } |
|
1172 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1173 | - |
|
1174 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
1175 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1176 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1177 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1178 | - |
|
1179 | - echo $html; |
|
1159 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1160 | + $value = $wpinv_options[ $args['id'] ]; |
|
1161 | + } else { |
|
1162 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1163 | + } |
|
1164 | + |
|
1165 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1166 | + $args['readonly'] = true; |
|
1167 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1168 | + $name = ''; |
|
1169 | + } else { |
|
1170 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1171 | + } |
|
1172 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1173 | + |
|
1174 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
1175 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1176 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1177 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1178 | + |
|
1179 | + echo $html; |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | function wpinv_number_callback( $args ) { |
1183 | - global $wpinv_options; |
|
1183 | + global $wpinv_options; |
|
1184 | 1184 | |
1185 | 1185 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1186 | 1186 | |
1187 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1188 | - $value = $wpinv_options[ $args['id'] ]; |
|
1189 | - } else { |
|
1190 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1191 | - } |
|
1192 | - |
|
1193 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1194 | - $args['readonly'] = true; |
|
1195 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1196 | - $name = ''; |
|
1197 | - } else { |
|
1198 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1199 | - } |
|
1200 | - |
|
1201 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1202 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1203 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1204 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1205 | - |
|
1206 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1207 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1208 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1209 | - |
|
1210 | - echo $html; |
|
1187 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1188 | + $value = $wpinv_options[ $args['id'] ]; |
|
1189 | + } else { |
|
1190 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1191 | + } |
|
1192 | + |
|
1193 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1194 | + $args['readonly'] = true; |
|
1195 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1196 | + $name = ''; |
|
1197 | + } else { |
|
1198 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1199 | + } |
|
1200 | + |
|
1201 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1202 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1203 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1204 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1205 | + |
|
1206 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1207 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1208 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1209 | + |
|
1210 | + echo $html; |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | function wpinv_textarea_callback( $args ) { |
1214 | - global $wpinv_options; |
|
1214 | + global $wpinv_options; |
|
1215 | 1215 | |
1216 | 1216 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1217 | 1217 | |
1218 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1219 | - $value = $wpinv_options[ $args['id'] ]; |
|
1220 | - } else { |
|
1221 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1222 | - } |
|
1218 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1219 | + $value = $wpinv_options[ $args['id'] ]; |
|
1220 | + } else { |
|
1221 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1222 | + } |
|
1223 | 1223 | |
1224 | 1224 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
1225 | 1225 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
1226 | 1226 | |
1227 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1228 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1227 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1228 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1229 | 1229 | |
1230 | - echo $html; |
|
1230 | + echo $html; |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | function wpinv_password_callback( $args ) { |
1234 | - global $wpinv_options; |
|
1234 | + global $wpinv_options; |
|
1235 | 1235 | |
1236 | 1236 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1237 | 1237 | |
1238 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1239 | - $value = $wpinv_options[ $args['id'] ]; |
|
1240 | - } else { |
|
1241 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1242 | - } |
|
1238 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1239 | + $value = $wpinv_options[ $args['id'] ]; |
|
1240 | + } else { |
|
1241 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1242 | + } |
|
1243 | 1243 | |
1244 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1245 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1246 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1244 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1245 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1246 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1247 | 1247 | |
1248 | - echo $html; |
|
1248 | + echo $html; |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | function wpinv_missing_callback($args) { |
1252 | - printf( |
|
1253 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1254 | - '<strong>' . $args['id'] . '</strong>' |
|
1255 | - ); |
|
1252 | + printf( |
|
1253 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1254 | + '<strong>' . $args['id'] . '</strong>' |
|
1255 | + ); |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | function wpinv_select_callback($args) { |
1259 | - global $wpinv_options; |
|
1259 | + global $wpinv_options; |
|
1260 | 1260 | |
1261 | 1261 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1262 | 1262 | |
1263 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1264 | - $value = $wpinv_options[ $args['id'] ]; |
|
1265 | - } else { |
|
1266 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1267 | - } |
|
1263 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1264 | + $value = $wpinv_options[ $args['id'] ]; |
|
1265 | + } else { |
|
1266 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1267 | + } |
|
1268 | 1268 | |
1269 | 1269 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
1270 | 1270 | $value = $args['selected']; |
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if ( isset( $args['placeholder'] ) ) { |
|
1274 | - $placeholder = $args['placeholder']; |
|
1275 | - } else { |
|
1276 | - $placeholder = ''; |
|
1277 | - } |
|
1273 | + if ( isset( $args['placeholder'] ) ) { |
|
1274 | + $placeholder = $args['placeholder']; |
|
1275 | + } else { |
|
1276 | + $placeholder = ''; |
|
1277 | + } |
|
1278 | 1278 | |
1279 | 1279 | if( !empty( $args['onchange'] ) ) { |
1280 | 1280 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1284,142 +1284,142 @@ discard block |
||
1284 | 1284 | |
1285 | 1285 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
1286 | 1286 | |
1287 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1287 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1288 | 1288 | |
1289 | - foreach ( $args['options'] as $option => $name ) { |
|
1290 | - $selected = selected( $option, $value, false ); |
|
1291 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1292 | - } |
|
1289 | + foreach ( $args['options'] as $option => $name ) { |
|
1290 | + $selected = selected( $option, $value, false ); |
|
1291 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1292 | + } |
|
1293 | 1293 | |
1294 | - $html .= '</select>'; |
|
1295 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1294 | + $html .= '</select>'; |
|
1295 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1296 | 1296 | |
1297 | - echo $html; |
|
1297 | + echo $html; |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | function wpinv_color_select_callback( $args ) { |
1301 | - global $wpinv_options; |
|
1301 | + global $wpinv_options; |
|
1302 | 1302 | |
1303 | 1303 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1304 | 1304 | |
1305 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1306 | - $value = $wpinv_options[ $args['id'] ]; |
|
1307 | - } else { |
|
1308 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1309 | - } |
|
1305 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1306 | + $value = $wpinv_options[ $args['id'] ]; |
|
1307 | + } else { |
|
1308 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1309 | + } |
|
1310 | 1310 | |
1311 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1311 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1312 | 1312 | |
1313 | - foreach ( $args['options'] as $option => $color ) { |
|
1314 | - $selected = selected( $option, $value, false ); |
|
1315 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1316 | - } |
|
1313 | + foreach ( $args['options'] as $option => $color ) { |
|
1314 | + $selected = selected( $option, $value, false ); |
|
1315 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1316 | + } |
|
1317 | 1317 | |
1318 | - $html .= '</select>'; |
|
1319 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1318 | + $html .= '</select>'; |
|
1319 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1320 | 1320 | |
1321 | - echo $html; |
|
1321 | + echo $html; |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | function wpinv_rich_editor_callback( $args ) { |
1325 | - global $wpinv_options, $wp_version; |
|
1325 | + global $wpinv_options, $wp_version; |
|
1326 | 1326 | |
1327 | 1327 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1328 | 1328 | |
1329 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1330 | - $value = $wpinv_options[ $args['id'] ]; |
|
1329 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1330 | + $value = $wpinv_options[ $args['id'] ]; |
|
1331 | 1331 | |
1332 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1333 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1334 | - } |
|
1335 | - } else { |
|
1336 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1337 | - } |
|
1332 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1333 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1334 | + } |
|
1335 | + } else { |
|
1336 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1337 | + } |
|
1338 | 1338 | |
1339 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1339 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1340 | 1340 | |
1341 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1342 | - ob_start(); |
|
1343 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
1344 | - $html = ob_get_clean(); |
|
1345 | - } else { |
|
1346 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1347 | - } |
|
1341 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1342 | + ob_start(); |
|
1343 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
1344 | + $html = ob_get_clean(); |
|
1345 | + } else { |
|
1346 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1347 | + } |
|
1348 | 1348 | |
1349 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1349 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1350 | 1350 | |
1351 | - echo $html; |
|
1351 | + echo $html; |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | function wpinv_upload_callback( $args ) { |
1355 | - global $wpinv_options; |
|
1355 | + global $wpinv_options; |
|
1356 | 1356 | |
1357 | 1357 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1358 | 1358 | |
1359 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1360 | - $value = $wpinv_options[$args['id']]; |
|
1361 | - } else { |
|
1362 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
1363 | - } |
|
1359 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1360 | + $value = $wpinv_options[$args['id']]; |
|
1361 | + } else { |
|
1362 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1363 | + } |
|
1364 | 1364 | |
1365 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1366 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1367 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1368 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1365 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1366 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1367 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1368 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1369 | 1369 | |
1370 | - echo $html; |
|
1370 | + echo $html; |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | function wpinv_color_callback( $args ) { |
1374 | - global $wpinv_options; |
|
1374 | + global $wpinv_options; |
|
1375 | 1375 | |
1376 | 1376 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1377 | 1377 | |
1378 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1379 | - $value = $wpinv_options[ $args['id'] ]; |
|
1380 | - } else { |
|
1381 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1382 | - } |
|
1378 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1379 | + $value = $wpinv_options[ $args['id'] ]; |
|
1380 | + } else { |
|
1381 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1382 | + } |
|
1383 | 1383 | |
1384 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1384 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1385 | 1385 | |
1386 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1387 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1386 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1387 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1388 | 1388 | |
1389 | - echo $html; |
|
1389 | + echo $html; |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | function wpinv_country_states_callback($args) { |
1393 | - global $wpinv_options; |
|
1393 | + global $wpinv_options; |
|
1394 | 1394 | |
1395 | 1395 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1396 | 1396 | |
1397 | - if ( isset( $args['placeholder'] ) ) { |
|
1398 | - $placeholder = $args['placeholder']; |
|
1399 | - } else { |
|
1400 | - $placeholder = ''; |
|
1401 | - } |
|
1397 | + if ( isset( $args['placeholder'] ) ) { |
|
1398 | + $placeholder = $args['placeholder']; |
|
1399 | + } else { |
|
1400 | + $placeholder = ''; |
|
1401 | + } |
|
1402 | 1402 | |
1403 | - $states = wpinv_get_country_states(); |
|
1403 | + $states = wpinv_get_country_states(); |
|
1404 | 1404 | |
1405 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
1406 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1405 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
1406 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1407 | 1407 | |
1408 | - foreach ( $states as $option => $name ) { |
|
1409 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1410 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1411 | - } |
|
1408 | + foreach ( $states as $option => $name ) { |
|
1409 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1410 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1411 | + } |
|
1412 | 1412 | |
1413 | - $html .= '</select>'; |
|
1414 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1413 | + $html .= '</select>'; |
|
1414 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1415 | 1415 | |
1416 | - echo $html; |
|
1416 | + echo $html; |
|
1417 | 1417 | } |
1418 | 1418 | |
1419 | 1419 | function wpinv_tax_rates_callback($args) { |
1420 | - global $wpinv_options; |
|
1421 | - $rates = wpinv_get_tax_rates(); |
|
1422 | - ob_start(); ?> |
|
1420 | + global $wpinv_options; |
|
1421 | + $rates = wpinv_get_tax_rates(); |
|
1422 | + ob_start(); ?> |
|
1423 | 1423 | </td><tr> |
1424 | 1424 | <td colspan="2" class="wpinv_tax_tdbox"> |
1425 | 1425 | <p><?php echo $args['desc']; ?></p> |
@@ -1443,40 +1443,40 @@ discard block |
||
1443 | 1443 | <tr> |
1444 | 1444 | <td class="wpinv_tax_country"> |
1445 | 1445 | <?php |
1446 | - echo wpinv_html_select( array( |
|
1447 | - 'options' => wpinv_get_country_list( true ), |
|
1448 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1446 | + echo wpinv_html_select( array( |
|
1447 | + 'options' => wpinv_get_country_list( true ), |
|
1448 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1449 | 1449 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1450 | - 'selected' => $rate['country'], |
|
1451 | - 'show_option_all' => false, |
|
1452 | - 'show_option_none' => false, |
|
1453 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
1454 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1455 | - ) ); |
|
1456 | - ?> |
|
1450 | + 'selected' => $rate['country'], |
|
1451 | + 'show_option_all' => false, |
|
1452 | + 'show_option_none' => false, |
|
1453 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
1454 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1455 | + ) ); |
|
1456 | + ?> |
|
1457 | 1457 | </td> |
1458 | 1458 | <td class="wpinv_tax_state"> |
1459 | 1459 | <?php |
1460 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1461 | - if( !empty( $states ) ) { |
|
1462 | - echo wpinv_html_select( array( |
|
1463 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1464 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1460 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
1461 | + if( !empty( $states ) ) { |
|
1462 | + echo wpinv_html_select( array( |
|
1463 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
1464 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1465 | 1465 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1466 | - 'selected' => $rate['state'], |
|
1467 | - 'show_option_all' => false, |
|
1468 | - 'show_option_none' => false, |
|
1466 | + 'selected' => $rate['state'], |
|
1467 | + 'show_option_all' => false, |
|
1468 | + 'show_option_none' => false, |
|
1469 | 1469 | 'class' => 'wpi_select2', |
1470 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1471 | - ) ); |
|
1472 | - } else { |
|
1473 | - echo wpinv_html_text( array( |
|
1474 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1475 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1470 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1471 | + ) ); |
|
1472 | + } else { |
|
1473 | + echo wpinv_html_text( array( |
|
1474 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1475 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1476 | 1476 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1477 | - ) ); |
|
1478 | - } |
|
1479 | - ?> |
|
1477 | + ) ); |
|
1478 | + } |
|
1479 | + ?> |
|
1480 | 1480 | </td> |
1481 | 1481 | <td class="wpinv_tax_global"> |
1482 | 1482 | <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
@@ -1491,19 +1491,19 @@ discard block |
||
1491 | 1491 | <tr> |
1492 | 1492 | <td class="wpinv_tax_country"> |
1493 | 1493 | <?php |
1494 | - echo wpinv_html_select( array( |
|
1495 | - 'options' => wpinv_get_country_list( true ), |
|
1496 | - 'name' => 'tax_rates[0][country]', |
|
1497 | - 'show_option_all' => false, |
|
1498 | - 'show_option_none' => false, |
|
1499 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
1500 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1501 | - ) ); ?> |
|
1494 | + echo wpinv_html_select( array( |
|
1495 | + 'options' => wpinv_get_country_list( true ), |
|
1496 | + 'name' => 'tax_rates[0][country]', |
|
1497 | + 'show_option_all' => false, |
|
1498 | + 'show_option_none' => false, |
|
1499 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
1500 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1501 | + ) ); ?> |
|
1502 | 1502 | </td> |
1503 | 1503 | <td class="wpinv_tax_state"> |
1504 | 1504 | <?php echo wpinv_html_text( array( |
1505 | - 'name' => 'tax_rates[0][state]' |
|
1506 | - ) ); ?> |
|
1505 | + 'name' => 'tax_rates[0][state]' |
|
1506 | + ) ); ?> |
|
1507 | 1507 | </td> |
1508 | 1508 | <td class="wpinv_tax_global"> |
1509 | 1509 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
1519 | 1519 | </table> |
1520 | 1520 | <?php |
1521 | - echo ob_get_clean(); |
|
1521 | + echo ob_get_clean(); |
|
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | function wpinv_tools_callback($args) { |
@@ -1546,15 +1546,15 @@ discard block |
||
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | function wpinv_descriptive_text_callback( $args ) { |
1549 | - echo wp_kses_post( $args['desc'] ); |
|
1549 | + echo wp_kses_post( $args['desc'] ); |
|
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | function wpinv_hook_callback( $args ) { |
1553 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1553 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1554 | 1554 | } |
1555 | 1555 | |
1556 | 1556 | function wpinv_set_settings_cap() { |
1557 | - return 'manage_options'; |
|
1557 | + return 'manage_options'; |
|
1558 | 1558 | } |
1559 | 1559 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1560 | 1560 |