@@ -11,56 +11,56 @@ discard block |
||
11 | 11 | * @var string $country The current user's country |
12 | 12 | */ |
13 | 13 | |
14 | -defined( 'ABSPATH' ) || exit; |
|
14 | +defined('ABSPATH') || exit; |
|
15 | 15 | |
16 | 16 | |
17 | -$field_type = sanitize_key( $field_type ); |
|
17 | +$field_type = sanitize_key($field_type); |
|
18 | 18 | |
19 | 19 | echo "<div class='row $field_type'>"; |
20 | 20 | |
21 | -foreach ( $fields as $address_field ) { |
|
21 | +foreach ($fields as $address_field) { |
|
22 | 22 | |
23 | 23 | // Skip if it is hidden. |
24 | - if ( empty( $address_field['visible'] ) ) { |
|
24 | + if (empty($address_field['visible'])) { |
|
25 | 25 | continue; |
26 | 26 | } |
27 | 27 | |
28 | - do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field ); |
|
28 | + do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field); |
|
29 | 29 | |
30 | 30 | // Prepare variables. |
31 | - if ( ! empty( $form->invoice ) ) { |
|
31 | + if (!empty($form->invoice)) { |
|
32 | 32 | $user_id = $form->invoice->get_user_id(); |
33 | 33 | } |
34 | 34 | |
35 | - if ( empty( $user_id ) && is_user_logged_in() ) { |
|
35 | + if (empty($user_id) && is_user_logged_in()) { |
|
36 | 36 | $user_id = $form->invoice->get_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | 39 | $field_name = $address_field['name']; |
40 | 40 | $field_name = "{$field_type}[$field_name]"; |
41 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
42 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
43 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
44 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
45 | - $value = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : ''; |
|
46 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
47 | - |
|
48 | - if ( ! empty( $address_field['required'] ) ) { |
|
41 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
42 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
43 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
44 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
45 | + $value = !empty($user_id) ? get_user_meta($user_id, '_' . $address_field['name'], true) : ''; |
|
46 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
47 | + |
|
48 | + if (!empty($address_field['required'])) { |
|
49 | 49 | $label .= "<span class='text-danger'> *</span>"; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Display the country. |
53 | - if ( 'wpinv_country' == $address_field['name'] ) { |
|
53 | + if ('wpinv_country' == $address_field['name']) { |
|
54 | 54 | |
55 | 55 | echo aui()->select( |
56 | 56 | array( |
57 | 57 | 'options' => wpinv_get_country_list(), |
58 | - 'name' => esc_attr( $field_name ), |
|
59 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
60 | - 'value' => sanitize_text_field( $country ), |
|
58 | + 'name' => esc_attr($field_name), |
|
59 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
60 | + 'value' => sanitize_text_field($country), |
|
61 | 61 | 'placeholder' => $placeholder, |
62 | - 'required' => ! empty( $address_field['required'] ), |
|
63 | - 'label' => wp_kses_post( $label ), |
|
62 | + 'required' => !empty($address_field['required']), |
|
63 | + 'label' => wp_kses_post($label), |
|
64 | 64 | 'label_type' => 'vertical', |
65 | 65 | 'help_text' => $description, |
66 | 66 | 'class' => 'getpaid-address-field wpinv_country', |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | // Display the state. |
78 | - else if ( 'wpinv_state' == $address_field['name'] ) { |
|
78 | + else if ('wpinv_state' == $address_field['name']) { |
|
79 | 79 | |
80 | - if ( empty( $value ) ) { |
|
80 | + if (empty($value)) { |
|
81 | 81 | $value = wpinv_get_default_state(); |
82 | 82 | } |
83 | 83 | |
84 | - echo getpaid_get_states_select_markup ( |
|
84 | + echo getpaid_get_states_select_markup( |
|
85 | 85 | $country, |
86 | 86 | $value, |
87 | 87 | $placeholder, |
88 | 88 | $label, |
89 | 89 | $description, |
90 | - ! empty( $address_field['required'] ), |
|
90 | + !empty($address_field['required']), |
|
91 | 91 | $wrap_class, |
92 | 92 | $field_name |
93 | 93 | ); |
94 | 94 | |
95 | 95 | } else { |
96 | 96 | |
97 | - $key = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
98 | - $key = esc_attr( str_replace( '_', '-', $key ) ); |
|
97 | + $key = str_replace('wpinv_', '', $address_field['name']); |
|
98 | + $key = esc_attr(str_replace('_', '-', $key)); |
|
99 | 99 | $autocomplete = ''; |
100 | 100 | $replacements = array( |
101 | 101 | 'zip' => 'postal-code', |
@@ -108,24 +108,24 @@ discard block |
||
108 | 108 | ); |
109 | 109 | |
110 | 110 | |
111 | - if ( isset( $replacements[ $key ] ) ) { |
|
111 | + if (isset($replacements[$key])) { |
|
112 | 112 | $autocomplete = array( |
113 | - 'autocomplete' => "$field_type {$replacements[ $key ]}", |
|
113 | + 'autocomplete' => "$field_type {$replacements[$key]}", |
|
114 | 114 | ); |
115 | 115 | } |
116 | 116 | |
117 | 117 | echo aui()->input( |
118 | 118 | array( |
119 | - 'name' => esc_attr( $field_name ), |
|
120 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
121 | - 'required' => ! empty( $address_field['required'] ), |
|
119 | + 'name' => esc_attr($field_name), |
|
120 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
121 | + 'required' => !empty($address_field['required']), |
|
122 | 122 | 'placeholder' => $placeholder, |
123 | - 'label' => wp_kses_post( $label ), |
|
123 | + 'label' => wp_kses_post($label), |
|
124 | 124 | 'label_type' => 'vertical', |
125 | 125 | 'help_text' => $description, |
126 | 126 | 'type' => 'text', |
127 | - 'value' => sanitize_text_field( $value ), |
|
128 | - 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), |
|
127 | + 'value' => sanitize_text_field($value), |
|
128 | + 'class' => 'getpaid-address-field ' . esc_attr($address_field['name']), |
|
129 | 129 | 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", |
130 | 130 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, |
131 | 131 | 'extra_attributes' => $autocomplete, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | - do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field ); |
|
137 | + do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | echo "</div>"; |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | $value = ''; |
13 | 13 | $class = ''; |
14 | 14 | |
15 | -if ( ! empty( $form->invoice ) ) { |
|
16 | - $value = sanitize_email( $form->invoice->get_email() ); |
|
17 | -} else if ( is_user_logged_in() ) { |
|
15 | +if (!empty($form->invoice)) { |
|
16 | + $value = sanitize_email($form->invoice->get_email()); |
|
17 | +} else if (is_user_logged_in()) { |
|
18 | 18 | $user = wp_get_current_user(); |
19 | - $value = sanitize_email( $user->user_email ); |
|
19 | + $value = sanitize_email($user->user_email); |
|
20 | 20 | } |
21 | 21 | |
22 | -if ( ! empty( $value ) && ! empty( $hide_billing_email ) ) { |
|
22 | +if (!empty($value) && !empty($hide_billing_email)) { |
|
23 | 23 | $class = 'd-none'; |
24 | 24 | } |
25 | 25 | |
26 | -do_action( 'getpaid_before_payment_form_billing_email', $form ); |
|
26 | +do_action('getpaid_before_payment_form_billing_email', $form); |
|
27 | 27 | |
28 | 28 | echo "<span class='$class'>"; |
29 | 29 | |
30 | 30 | echo aui()->input( |
31 | 31 | array( |
32 | 32 | 'name' => 'billing_email', |
33 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
34 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
35 | - 'required' => ! empty( $required ), |
|
36 | - 'label' => empty( $label ) ? '' : wp_kses_post( $label ) . '<span class="text-danger"> *</span>', |
|
33 | + 'id' => esc_attr($id) . uniqid('_'), |
|
34 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
35 | + 'required' => !empty($required), |
|
36 | + 'label' => empty($label) ? '' : wp_kses_post($label) . '<span class="text-danger"> *</span>', |
|
37 | 37 | 'label_type' => 'vertical', |
38 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
38 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
39 | 39 | 'type' => 'email', |
40 | 40 | 'value' => $value, |
41 | 41 | 'extra_attributes' => array( |
@@ -46,4 +46,4 @@ discard block |
||
46 | 46 | |
47 | 47 | echo '</span>'; |
48 | 48 | |
49 | -do_action( 'getpaid_after_payment_form_billing_email', $form ); |
|
49 | +do_action('getpaid_after_payment_form_billing_email', $form); |
@@ -7,58 +7,58 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -if ( empty( $fields ) ) { |
|
12 | +if (empty($fields)) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
17 | -$uniqid = uniqid( '_' ); |
|
17 | +$uniqid = uniqid('_'); |
|
18 | 18 | |
19 | 19 | // Prepare the user's country. |
20 | -if ( ! empty( $form->invoice ) ) { |
|
20 | +if (!empty($form->invoice)) { |
|
21 | 21 | $country = $form->invoice->get_country(); |
22 | 22 | } |
23 | 23 | |
24 | -if ( empty( $country ) ) { |
|
25 | - $country = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_country', true ) : ''; |
|
26 | - $country = empty( $country ) ? getpaid_get_ip_country() : $country; |
|
27 | - $country = empty( $country ) ? wpinv_get_default_country() : $country; |
|
24 | +if (empty($country)) { |
|
25 | + $country = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_country', true) : ''; |
|
26 | + $country = empty($country) ? getpaid_get_ip_country() : $country; |
|
27 | + $country = empty($country) ? wpinv_get_default_country() : $country; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
31 | -$uniqid = uniqid( '_' ); |
|
31 | +$uniqid = uniqid('_'); |
|
32 | 32 | |
33 | -$address_type = empty( $address_type ) ? 'billing' : $address_type; |
|
33 | +$address_type = empty($address_type) ? 'billing' : $address_type; |
|
34 | 34 | |
35 | 35 | ?> |
36 | 36 | |
37 | -<?php if ( 'both' === $address_type ) : ?> |
|
37 | +<?php if ('both' === $address_type) : ?> |
|
38 | 38 | |
39 | 39 | <!-- Start Billing/Shipping Address Title --> |
40 | 40 | <h4 class="mb-3 getpaid-shipping-billing-address-title"> |
41 | - <?php _e( 'Billing / Shipping Address', 'invoicing' ); ?> |
|
41 | + <?php _e('Billing / Shipping Address', 'invoicing'); ?> |
|
42 | 42 | </h4> |
43 | 43 | <!-- End Billing Address Title --> |
44 | 44 | |
45 | 45 | <!-- Start Billing Address Title --> |
46 | 46 | <h4 class="mb-3 getpaid-billing-address-title"> |
47 | - <?php _e( 'Billing Address', 'invoicing' ); ?> |
|
47 | + <?php _e('Billing Address', 'invoicing'); ?> |
|
48 | 48 | </h4> |
49 | 49 | <!-- End Billing Address Title --> |
50 | 50 | |
51 | 51 | <?php endif; ?> |
52 | 52 | |
53 | 53 | |
54 | -<?php if ( 'both' === $address_type || 'billing' === $address_type ) : ?> |
|
54 | +<?php if ('both' === $address_type || 'billing' === $address_type) : ?> |
|
55 | 55 | |
56 | 56 | <!-- Start Billing Address --> |
57 | 57 | <div class="getpaid-billing-address-wrapper"> |
58 | 58 | <?php |
59 | 59 | $field_type = 'billing'; |
60 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
61 | - do_action( 'getpaid_after_payment_form_billing_fields', $form ); |
|
60 | + include plugin_dir_path(__FILE__) . 'address-fields.php'; |
|
61 | + do_action('getpaid_after_payment_form_billing_fields', $form); |
|
62 | 62 | ?> |
63 | 63 | </div> |
64 | 64 | <!-- End Billing Address --> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | <?php endif; ?> |
67 | 67 | |
68 | 68 | |
69 | -<?php if ( 'both' === $address_type ) : ?> |
|
69 | +<?php if ('both' === $address_type) : ?> |
|
70 | 70 | |
71 | 71 | |
72 | 72 | <?php |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'name' => 'same-shipping-address', |
78 | 78 | 'id' => "shipping-toggle$uniqid", |
79 | 79 | 'required' => false, |
80 | - 'label' => wp_kses_post( $shipping_address_toggle ), |
|
80 | + 'label' => wp_kses_post($shipping_address_toggle), |
|
81 | 81 | 'value' => 1, |
82 | 82 | 'checked' => true, |
83 | 83 | ) |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | <!-- Start Shipping Address Title --> |
90 | 90 | <h4 class="mb-3 getpaid-shipping-address-title"> |
91 | - <?php _e( 'Shipping Address', 'invoicing' ); ?> |
|
91 | + <?php _e('Shipping Address', 'invoicing'); ?> |
|
92 | 92 | </h4> |
93 | 93 | <!-- End Shipping Address Title --> |
94 | 94 | |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | |
100 | -<?php if ( 'both' === $address_type || 'shipping' === $address_type ) : ?> |
|
100 | +<?php if ('both' === $address_type || 'shipping' === $address_type) : ?> |
|
101 | 101 | |
102 | 102 | <!-- Start Shipping Address --> |
103 | 103 | <div class="getpaid-shipping-address-wrapper"> |
104 | 104 | <?php |
105 | 105 | $field_type = 'shipping'; |
106 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
107 | - do_action( 'getpaid_after_payment_form_shipping_fields', $form ); |
|
106 | + include plugin_dir_path(__FILE__) . 'address-fields.php'; |
|
107 | + do_action('getpaid_after_payment_form_shipping_fields', $form); |
|
108 | 108 | ?> |
109 | 109 | </div> |
110 | 110 | <!-- End Shipping Address --> |