Passed
Push — master ( 6929e7...c24352 )
by Brian
10:18 queued 05:36
created
includes/admin/register-settings.php 1 patch
Spacing   +540 added lines, -540 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let other plugin alter the value
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it's updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $email_settings, $tax_settings, $misc_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $email_settings, $tax_settings, $misc_settings, $tool_settings);
84 84
 
85
-        update_option( 'wpinv_settings', $settings );
85
+        update_option('wpinv_settings', $settings);
86 86
 
87 87
     }
88
-    return apply_filters( 'wpinv_get_settings', $settings );
88
+    return apply_filters('wpinv_get_settings', $settings);
89 89
 }
90 90
 
91 91
 function wpinv_register_settings() {
92
-    if ( false == get_option( 'wpinv_settings' ) ) {
93
-        add_option( 'wpinv_settings' );
92
+    if (false == get_option('wpinv_settings')) {
93
+        add_option('wpinv_settings');
94 94
     }
95 95
     
96 96
     $register_settings = wpinv_get_registered_settings();
97 97
     
98
-    foreach ( $register_settings as $tab => $sections ) {
99
-        foreach ( $sections as $section => $settings) {
98
+    foreach ($register_settings as $tab => $sections) {
99
+        foreach ($sections as $section => $settings) {
100 100
             // Check for backwards compatibility
101
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
102
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
101
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
102
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
103 103
                 $section = 'main';
104 104
                 $settings = $sections;
105 105
             }
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 111
                 'wpinv_settings_' . $tab . '_' . $section
112 112
             );
113 113
 
114
-            foreach ( $settings as $option ) {
114
+            foreach ($settings as $option) {
115 115
                 // For backwards compatibility
116
-                if ( empty( $option['id'] ) ) {
116
+                if (empty($option['id'])) {
117 117
                     continue;
118 118
                 }
119 119
 
120
-                $name = isset( $option['name'] ) ? $option['name'] : '';
120
+                $name = isset($option['name']) ? $option['name'] : '';
121 121
 
122 122
                 add_settings_field(
123 123
                     'wpinv_settings[' . $option['id'] . ']',
124 124
                     $name,
125
-                    function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
125
+                    function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
126 126
                     'wpinv_settings_' . $tab . '_' . $section,
127 127
                     'wpinv_settings_' . $tab . '_' . $section,
128 128
                     array(
129 129
                         'section'     => $section,
130
-                        'id'          => isset( $option['id'] )          ? $option['id']          : null,
131
-                        'desc'        => ! empty( $option['desc'] )      ? $option['desc']        : '',
132
-                        'name'        => isset( $option['name'] )        ? $option['name']        : null,
133
-                        'size'        => isset( $option['size'] )        ? $option['size']        : null,
134
-                        'options'     => isset( $option['options'] )     ? $option['options']     : '',
135
-                        'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
136
-                        'std'         => isset( $option['std'] )         ? $option['std']         : '',
137
-                        'min'         => isset( $option['min'] )         ? $option['min']         : null,
138
-                        'max'         => isset( $option['max'] )         ? $option['max']         : null,
139
-                        'step'        => isset( $option['step'] )        ? $option['step']        : null,
140
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
141
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
142
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
143
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
144
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
145
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
146
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
147
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
148
-                        'rows'        => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
130
+                        'id'          => isset($option['id']) ? $option['id'] : null,
131
+                        'desc'        => !empty($option['desc']) ? $option['desc'] : '',
132
+                        'name'        => isset($option['name']) ? $option['name'] : null,
133
+                        'size'        => isset($option['size']) ? $option['size'] : null,
134
+                        'options'     => isset($option['options']) ? $option['options'] : '',
135
+                        'selected'    => isset($option['selected']) ? $option['selected'] : null,
136
+                        'std'         => isset($option['std']) ? $option['std'] : '',
137
+                        'min'         => isset($option['min']) ? $option['min'] : null,
138
+                        'max'         => isset($option['max']) ? $option['max'] : null,
139
+                        'step'        => isset($option['step']) ? $option['step'] : null,
140
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
141
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
142
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
143
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
144
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
145
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
146
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
147
+                        'cols'        => !empty($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
148
+                        'rows'        => !empty($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
149 149
                     )
150 150
                 );
151 151
             }
@@ -153,203 +153,203 @@  discard block
 block discarded – undo
153 153
     }
154 154
 
155 155
     // Creates our settings in the options table
156
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
156
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
157 157
 }
158
-add_action( 'admin_init', 'wpinv_register_settings' );
158
+add_action('admin_init', 'wpinv_register_settings');
159 159
 
160 160
 function wpinv_get_registered_settings() {
161
-    $pages = wpinv_get_pages( true );
161
+    $pages = wpinv_get_pages(true);
162 162
     
163 163
     $currencies = wpinv_get_currencies();
164 164
     
165 165
     $currency_code_options = array();
166
-    foreach ( $currencies as $code => $name ) {
167
-        $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
166
+    foreach ($currencies as $code => $name) {
167
+        $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
168 168
     }
169 169
     
170 170
     $due_payment_options       = array();
171
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
172
-    for ( $i = 1; $i <= 30; $i++ ) {
171
+    $due_payment_options[0]    = __('Now', 'invoicing');
172
+    for ($i = 1; $i <= 30; $i++) {
173 173
         $due_payment_options[$i] = $i;
174 174
     }
175 175
     
176 176
     $invoice_number_padd_options = array();
177
-    for ( $i = 0; $i <= 20; $i++ ) {
177
+    for ($i = 0; $i <= 20; $i++) {
178 178
         $invoice_number_padd_options[$i] = $i;
179 179
     }
180 180
     
181 181
     $currency_symbol = wpinv_currency_symbol();
182 182
     
183 183
     $last_number = $reset_number = '';
184
-    if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
185
-        $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number );
184
+    if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
185
+        $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number);
186 186
 
187
-        if ( !empty( $last_invoice_number ) ) {
188
-            $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
187
+        if (!empty($last_invoice_number)) {
188
+            $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
189 189
         }
190 190
 
191 191
         $nonce = wp_create_nonce('reset_invoice_count');
192
-        $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
192
+        $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
193 193
     }
194 194
     
195 195
     $alert_wrapper_start = '<p style="color: #F00">';
196 196
     $alert_wrapper_close = '</p>';
197 197
     $wpinv_settings = array(
198
-        'general' => apply_filters( 'wpinv_settings_general',
198
+        'general' => apply_filters('wpinv_settings_general',
199 199
             array(
200 200
                 'main' => array(
201 201
                     'location_settings' => array(
202 202
                         'id'   => 'location_settings',
203
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
203
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
204 204
                         'desc' => '',
205 205
                         'type' => 'header',
206 206
                     ),
207 207
                     'default_country' => array(
208 208
                         'id'      => 'default_country',
209
-                        'name'    => __( 'Default Country', 'invoicing' ),
210
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
209
+                        'name'    => __('Default Country', 'invoicing'),
210
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
211 211
                         'type'    => 'select',
212 212
                         'options' => wpinv_get_country_list(),
213 213
                         'std'     => 'GB',
214 214
                         'class'   => 'wpi_select2',
215
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
215
+                        'placeholder' => __('Select a country', 'invoicing'),
216 216
                     ),
217 217
                     'default_state' => array(
218 218
                         'id'      => 'default_state',
219
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
220
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
219
+                        'name'    => __('Default State / Province', 'invoicing'),
220
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
221 221
                         'type'    => 'country_states',
222 222
                         'class'   => 'wpi_select2',
223
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
223
+                        'placeholder' => __('Select a state', 'invoicing'),
224 224
                     ),
225 225
                     'store_name' => array(
226 226
                         'id'   => 'store_name',
227
-                        'name' => __( 'Store Name', 'invoicing' ),
228
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
227
+                        'name' => __('Store Name', 'invoicing'),
228
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
229 229
                         'std'     => get_option('blogname'),
230 230
                         'type' => 'text',
231 231
                     ),
232 232
                     'logo' => array(
233 233
                         'id'   => 'logo',
234
-                        'name' => __( 'Logo URL', 'invoicing' ),
235
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
234
+                        'name' => __('Logo URL', 'invoicing'),
235
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
236 236
                         'type' => 'text',
237 237
                     ),
238 238
                     'store_address' => array(
239 239
                         'id'   => 'store_address',
240
-                        'name' => __( 'Store Address', 'invoicing' ),
241
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
240
+                        'name' => __('Store Address', 'invoicing'),
241
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
242 242
                         'type' => 'textarea',
243 243
                     ),
244 244
                     'page_settings' => array(
245 245
                         'id'   => 'page_settings',
246
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
246
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
247 247
                         'desc' => '',
248 248
                         'type' => 'header',
249 249
                     ),
250 250
                     'checkout_page' => array(
251 251
                         'id'          => 'checkout_page',
252
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
253
-                        'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
252
+                        'name'        => __('Checkout Page', 'invoicing'),
253
+                        'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
254 254
                         'type'        => 'select',
255 255
                         'options'     => $pages,
256 256
                         'class'       => 'wpi_select2',
257
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
257
+                        'placeholder' => __('Select a page', 'invoicing'),
258 258
                     ),
259 259
                     'tandc_page' => array(
260 260
                         'id'          => 'tandc_page',
261
-                        'name'        => __( 'Terms & Conditions', 'invoicing' ),
262
-                        'desc'        => __( 'If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing' ),
261
+                        'name'        => __('Terms & Conditions', 'invoicing'),
262
+                        'desc'        => __('If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing'),
263 263
                         'type'        => 'select',
264
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
264
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
265 265
                         'class'       => 'wpi_select2',
266
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
266
+                        'placeholder' => __('Select a page', 'invoicing'),
267 267
                     ),
268 268
                     'success_page' => array(
269 269
                         'id'          => 'success_page',
270
-                        'name'        => __( 'Success Page', 'invoicing' ),
271
-                        'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
270
+                        'name'        => __('Success Page', 'invoicing'),
271
+                        'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
272 272
                         'type'        => 'select',
273 273
                         'options'     => $pages,
274 274
                         'class'       => 'wpi_select2',
275
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
275
+                        'placeholder' => __('Select a page', 'invoicing'),
276 276
                     ),
277 277
                     'failure_page' => array(
278 278
                         'id'          => 'failure_page',
279
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
280
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
279
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
280
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
281 281
                         'type'        => 'select',
282 282
                         'options'     => $pages,
283 283
                         'class'       => 'wpi_select2',
284
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
284
+                        'placeholder' => __('Select a page', 'invoicing'),
285 285
                     ),
286 286
                     'invoice_history_page' => array(
287 287
                         'id'          => 'invoice_history_page',
288
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
289
-                        'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
288
+                        'name'        => __('Invoice History Page', 'invoicing'),
289
+                        'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
290 290
                         'type'        => 'select',
291 291
                         'options'     => $pages,
292 292
                         'class'       => 'wpi_select2',
293
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
293
+                        'placeholder' => __('Select a page', 'invoicing'),
294 294
                     ),
295 295
                     'invoice_subscription_page' => array(
296 296
                         'id'          => 'invoice_subscription_page',
297
-                        'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
298
-                        'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
297
+                        'name'        => __('Invoice Subscriptions Page', 'invoicing'),
298
+                        'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
299 299
                         'type'        => 'select',
300 300
                         'options'     => $pages,
301 301
                         'class'       => 'wpi_select2',
302
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
302
+                        'placeholder' => __('Select a page', 'invoicing'),
303 303
                     ),
304 304
                 ),
305 305
                 'currency_section' => array(
306 306
                     'currency_settings' => array(
307 307
                         'id'   => 'currency_settings',
308
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
308
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
309 309
                         'desc' => '',
310 310
                         'type' => 'header',
311 311
                     ),
312 312
                     'currency' => array(
313 313
                         'id'      => 'currency',
314
-                        'name'    => __( 'Currency', 'invoicing' ),
315
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
314
+                        'name'    => __('Currency', 'invoicing'),
315
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
316 316
                         'type'    => 'select',
317 317
                         'class'       => 'wpi_select2',
318 318
                         'options' => $currency_code_options,
319 319
                     ),
320 320
                     'currency_position' => array(
321 321
                         'id'      => 'currency_position',
322
-                        'name'    => __( 'Currency Position', 'invoicing' ),
323
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
322
+                        'name'    => __('Currency Position', 'invoicing'),
323
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
324 324
                         'type'    => 'select',
325 325
                         'class'   => 'wpi_select2',
326 326
                         'options'  => array(
327
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
328
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
329
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
330
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
327
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
328
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
329
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
330
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
331 331
                         )
332 332
                     ),
333 333
                     'thousands_separator' => array(
334 334
                         'id'   => 'thousands_separator',
335
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
336
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
335
+                        'name' => __('Thousands Separator', 'invoicing'),
336
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
337 337
                         'type' => 'text',
338 338
                         'size' => 'small',
339 339
                         'std'  => ',',
340 340
                     ),
341 341
                     'decimal_separator' => array(
342 342
                         'id'   => 'decimal_separator',
343
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
344
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
343
+                        'name' => __('Decimal Separator', 'invoicing'),
344
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
345 345
                         'type' => 'text',
346 346
                         'size' => 'small',
347 347
                         'std'  => '.',
348 348
                     ),
349 349
                     'decimals' => array(
350 350
                         'id'   => 'decimals',
351
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
352
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
351
+                        'name' => __('Number of Decimals', 'invoicing'),
352
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
353 353
                         'type' => 'number',
354 354
                         'size' => 'small',
355 355
                         'std'  => '2',
@@ -361,29 +361,29 @@  discard block
 block discarded – undo
361 361
                 'labels' => array(
362 362
                     'labels' => array(
363 363
                         'id'   => 'labels_settings',
364
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
364
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
365 365
                         'desc' => '',
366 366
                         'type' => 'header',
367 367
                     ),
368 368
                     'vat_name' => array(
369 369
                         'id' => 'vat_name',
370
-                        'name' => __( 'VAT Name', 'invoicing' ),
371
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
370
+                        'name' => __('VAT Name', 'invoicing'),
371
+                        'desc' => __('Enter the VAT name', 'invoicing'),
372 372
                         'type' => 'text',
373 373
                         'size' => 'regular',
374
-                        'std' => __( 'VAT', 'invoicing' ),
374
+                        'std' => __('VAT', 'invoicing'),
375 375
                     ),
376 376
                     'vat_invoice_notice_label' => array(
377 377
                         'id' => 'vat_invoice_notice_label',
378
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
379
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
378
+                        'name' => __('Invoice Notice Label', 'invoicing'),
379
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
380 380
                         'type' => 'text',
381 381
                         'size' => 'regular',
382 382
                     ),
383 383
                     'vat_invoice_notice' => array(
384 384
                         'id' => 'vat_invoice_notice',
385
-                        'name' => __( 'Invoice notice', 'invoicing' ),
386
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
385
+                        'name' => __('Invoice notice', 'invoicing'),
386
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
387 387
                         'type' => 'text',
388 388
                         'size' => 'regular',
389 389
                     ),
@@ -395,22 +395,22 @@  discard block
 block discarded – undo
395 395
                 'main' => array(
396 396
                     'gateway_settings' => array(
397 397
                         'id'   => 'api_header',
398
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
398
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
399 399
                         'desc' => '',
400 400
                         'type' => 'header',
401 401
                     ),
402 402
                     'gateways' => array(
403 403
                         'id'      => 'gateways',
404
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
405
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
404
+                        'name'    => __('Payment Gateways', 'invoicing'),
405
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
406 406
                         'type'    => 'gateways',
407 407
                         'std'     => array('manual'=>1),
408 408
                         'options' => wpinv_get_payment_gateways(),
409 409
                     ),
410 410
                     'default_gateway' => array(
411 411
                         'id'      => 'default_gateway',
412
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
413
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
412
+                        'name'    => __('Default Gateway', 'invoicing'),
413
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
414 414
                         'type'    => 'gateway_select',
415 415
                         'std'     => 'manual',
416 416
                         'class'   => 'wpi_select2',
@@ -425,19 +425,19 @@  discard block
 block discarded – undo
425 425
                 'main' => array(
426 426
                     'tax_settings' => array(
427 427
                         'id'   => 'tax_settings',
428
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
428
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
429 429
                         'type' => 'header',
430 430
                     ),
431 431
                     'enable_taxes' => array(
432 432
                         'id'   => 'enable_taxes',
433
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
434
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
433
+                        'name' => __('Enable Taxes', 'invoicing'),
434
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
435 435
                         'type' => 'checkbox',
436 436
                     ),
437 437
                     'tax_rate' => array(
438 438
                         'id'   => 'tax_rate',
439
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
440
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
439
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
440
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
441 441
                         'type' => 'number',
442 442
                         'size' => 'small',
443 443
                         'min'  => '0',
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
                 'rates' => array(
450 450
                     'tax_rates' => array(
451 451
                         'id'   => 'tax_rates',
452
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
453
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
452
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
453
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
454 454
                         'type' => 'tax_rates',
455 455
                     ),
456 456
                 )
@@ -462,68 +462,68 @@  discard block
 block discarded – undo
462 462
                 'main' => array(
463 463
                     'email_settings_header' => array(
464 464
                         'id'   => 'email_settings_header',
465
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
465
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
466 466
                         'type' => 'header',
467 467
                     ),
468 468
                     'email_from_name' => array(
469 469
                         'id'   => 'email_from_name',
470
-                        'name' => __( 'From Name', 'invoicing' ),
471
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
472
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
470
+                        'name' => __('From Name', 'invoicing'),
471
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
472
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
473 473
                         'type' => 'text',
474 474
                     ),
475 475
                     'email_from' => array(
476 476
                         'id'   => 'email_from',
477
-                        'name' => __( 'From Email', 'invoicing' ),
478
-                        'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
479
-                        'std' => get_option( 'admin_email' ),
477
+                        'name' => __('From Email', 'invoicing'),
478
+                        'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
479
+                        'std' => get_option('admin_email'),
480 480
                         'type' => 'text',
481 481
                     ),
482 482
                     'admin_email' => array(
483 483
                         'id'   => 'admin_email',
484
-                        'name' => __( 'Admin Email', 'invoicing' ),
485
-                        'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
486
-                        'std' => get_option( 'admin_email' ),
484
+                        'name' => __('Admin Email', 'invoicing'),
485
+                        'desc' => __('Where should we send admin notifications?', 'invoicing'),
486
+                        'std' => get_option('admin_email'),
487 487
                         'type' => 'text',
488 488
                     ),
489 489
                     'overdue_settings_header' => array(
490 490
                         'id'   => 'overdue_settings_header',
491
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
491
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
492 492
                         'type' => 'header',
493 493
                     ),
494 494
                     'overdue_active' => array(
495 495
                         'id'   => 'overdue_active',
496
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
497
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
496
+                        'name' => __('Enable Due Date', 'invoicing'),
497
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
498 498
                         'type' => 'checkbox',
499 499
                         'std'  => false,
500 500
                     ),
501 501
                     'overdue_days' => array(
502 502
                         'id'          => 'overdue_days',
503
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
504
-                        'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
503
+                        'name'        => __('Default Due Date', 'invoicing'),
504
+                        'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
505 505
                         'type'        => 'select',
506 506
                         'options'     => $due_payment_options,
507 507
                         'std'         => 0,
508
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
508
+                        'placeholder' => __('Select a page', 'invoicing'),
509 509
                     ),
510 510
                     'email_template_header' => array(
511 511
                         'id'   => 'email_template_header',
512
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
512
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
513 513
                         'type' => 'header',
514 514
                     ),
515 515
                     'email_header_image' => array(
516 516
                         'id'   => 'email_header_image',
517
-                        'name' => __( 'Header Image', 'invoicing' ),
518
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
517
+                        'name' => __('Header Image', 'invoicing'),
518
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
519 519
                         'std' => '',
520 520
                         'type' => 'text',
521 521
                     ),
522 522
                     'email_footer_text' => array(
523 523
                         'id'   => 'email_footer_text',
524
-                        'name' => __( 'Footer Text', 'invoicing' ),
525
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
526
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
524
+                        'name' => __('Footer Text', 'invoicing'),
525
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
526
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
527 527
                         'type' => 'textarea',
528 528
                         'class' => 'regular-text',
529 529
                         'rows' => 2,
@@ -531,29 +531,29 @@  discard block
 block discarded – undo
531 531
                     ),
532 532
                     'email_base_color' => array(
533 533
                         'id'   => 'email_base_color',
534
-                        'name' => __( 'Base Color', 'invoicing' ),
535
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
534
+                        'name' => __('Base Color', 'invoicing'),
535
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
536 536
                         'std' => '#557da2',
537 537
                         'type' => 'color',
538 538
                     ),
539 539
                     'email_background_color' => array(
540 540
                         'id'   => 'email_background_color',
541
-                        'name' => __( 'Background Color', 'invoicing' ),
542
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
541
+                        'name' => __('Background Color', 'invoicing'),
542
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
543 543
                         'std' => '#f5f5f5',
544 544
                         'type' => 'color',
545 545
                     ),
546 546
                     'email_body_background_color' => array(
547 547
                         'id'   => 'email_body_background_color',
548
-                        'name' => __( 'Body Background Color', 'invoicing' ),
549
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
548
+                        'name' => __('Body Background Color', 'invoicing'),
549
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
550 550
                         'std' => '#fdfdfd',
551 551
                         'type' => 'color',
552 552
                     ),
553 553
                     'email_text_color' => array(
554 554
                         'id'   => 'email_text_color',
555
-                        'name' => __( 'Body Text Color', 'invoicing' ),
556
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
555
+                        'name' => __('Body Text Color', 'invoicing'),
556
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
557 557
                         'std' => '#505050',
558 558
                         'type' => 'color',
559 559
                     ),
@@ -572,17 +572,17 @@  discard block
 block discarded – undo
572 572
                 'main' => array(
573 573
                     'invoicing_privacy_policy_settings' => array(
574 574
                         'id'   => 'invoicing_privacy_policy_settings',
575
-                        'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
575
+                        'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
576 576
                         'type' => 'header',
577 577
                     ),
578 578
                     'privacy_page' => array(
579 579
                         'id'          => 'privacy_page',
580
-                        'name'        => __( 'Privacy Page', 'invoicing' ),
581
-                        'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
580
+                        'name'        => __('Privacy Page', 'invoicing'),
581
+                        'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
582 582
                         'type'        => 'select',
583
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
583
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
584 584
                         'class'       => 'wpi_select2',
585
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
585
+                        'placeholder' => __('Select a page', 'invoicing'),
586 586
                     ),
587 587
                 ),
588 588
             )
@@ -593,19 +593,19 @@  discard block
 block discarded – undo
593 593
                 'main' => array(
594 594
                     'invoice_number_format_settings' => array(
595 595
                         'id'   => 'invoice_number_format_settings',
596
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
596
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
597 597
                         'type' => 'header',
598 598
                     ),
599 599
                     'sequential_invoice_number' => array(
600 600
                         'id'   => 'sequential_invoice_number',
601
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
602
-                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
601
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
602
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
603 603
                         'type' => 'checkbox',
604 604
                     ),
605 605
                     'invoice_sequence_start' => array(
606 606
                         'id'   => 'invoice_sequence_start',
607
-                        'name' => __( 'Sequential Starting Number', 'invoicing' ),
608
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
607
+                        'name' => __('Sequential Starting Number', 'invoicing'),
608
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
609 609
                         'type' => 'number',
610 610
                         'size' => 'small',
611 611
                         'std'  => '1',
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
                     ),
614 614
                     'invoice_number_padd' => array(
615 615
                         'id'      => 'invoice_number_padd',
616
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
617
-                        'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
616
+                        'name'    => __('Minimum Digits', 'invoicing'),
617
+                        'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
618 618
                         'type'    => 'select',
619 619
                         'options' => $invoice_number_padd_options,
620 620
                         'std'     => 5,
@@ -622,8 +622,8 @@  discard block
 block discarded – undo
622 622
                     ),
623 623
                     'invoice_number_prefix' => array(
624 624
                         'id' => 'invoice_number_prefix',
625
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
626
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
625
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
626
+                        'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
627 627
                         'type' => 'text',
628 628
                         'size' => 'regular',
629 629
                         'std' => 'INV-',
@@ -631,32 +631,32 @@  discard block
 block discarded – undo
631 631
                     ),
632 632
                     'invoice_number_postfix' => array(
633 633
                         'id' => 'invoice_number_postfix',
634
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
635
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
634
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
635
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
636 636
                         'type' => 'text',
637 637
                         'size' => 'regular',
638 638
                         'std' => ''
639 639
                     ),
640 640
                     'checkout_settings' => array(
641 641
                         'id'   => 'checkout_settings',
642
-                        'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
642
+                        'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
643 643
                         'type' => 'header',
644 644
                     ),
645 645
                     'login_to_checkout' => array(
646 646
                         'id'   => 'login_to_checkout',
647
-                        'name' => __( 'Require Login To Checkout', 'invoicing' ),
648
-                        'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
647
+                        'name' => __('Require Login To Checkout', 'invoicing'),
648
+                        'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
649 649
                         'type' => 'checkbox',
650 650
                     ),
651 651
                     'uninstall_settings' => array(
652 652
                         'id'   => 'uninstall_settings',
653
-                        'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
653
+                        'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
654 654
                         'type' => 'header',
655 655
                     ),
656 656
                     'remove_data_on_unistall' => array(
657 657
                         'id'   => 'remove_data_on_unistall',
658
-                        'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
659
-                        'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
658
+                        'name' => __('Remove Data on Uninstall?', 'invoicing'),
659
+                        'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
660 660
                         'type' => 'checkbox',
661 661
                         'std'  => ''
662 662
                     ),
@@ -664,20 +664,20 @@  discard block
 block discarded – undo
664 664
                 'fields' => array(
665 665
                     'address_autofill_settings' => array(
666 666
                         'id'   => 'address_autofill_settings',
667
-                        'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>',
667
+                        'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>',
668 668
                         'type' => 'header',
669 669
                     ),
670 670
                     'address_autofill_active' => array(
671 671
                         'id'   => 'address_autofill_active',
672
-                        'name' => __( 'Enable/Disable', 'invoicing' ),
673
-                        'desc' => __( 'Enable google address auto complete', 'invoicing' ),
672
+                        'name' => __('Enable/Disable', 'invoicing'),
673
+                        'desc' => __('Enable google address auto complete', 'invoicing'),
674 674
                         'type' => 'checkbox',
675 675
                         'std'  => 0
676 676
                     ),
677 677
                     'address_autofill_api' => array(
678 678
                         'id' => 'address_autofill_api',
679
-                        'name' => __( 'Google Place API Key', 'invoicing' ),
680
-                        'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ),
679
+                        'name' => __('Google Place API Key', 'invoicing'),
680
+                        'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'),
681 681
                         'type' => 'text',
682 682
                         'size' => 'regular',
683 683
                         'std' => ''
@@ -686,13 +686,13 @@  discard block
 block discarded – undo
686 686
                 'custom-css' => array(
687 687
                     'css_settings' => array(
688 688
                         'id'   => 'css_settings',
689
-                        'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
689
+                        'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
690 690
                         'type' => 'header',
691 691
                     ),
692 692
                     'template_custom_css' => array(
693 693
                         'id' => 'template_custom_css',
694
-                        'name' => __( 'Invoice Template CSS', 'invoicing' ),
695
-                        'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
694
+                        'name' => __('Invoice Template CSS', 'invoicing'),
695
+                        'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
696 696
                         'type' => 'textarea',
697 697
                         'class'=> 'regular-text',
698 698
                         'rows' => 10,
@@ -706,8 +706,8 @@  discard block
 block discarded – undo
706 706
                 'main' => array(
707 707
                     'tool_settings' => array(
708 708
                         'id'   => 'tool_settings',
709
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
710
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
709
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
710
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
711 711
                         'type' => 'tools',
712 712
                     ),
713 713
                 ),
@@ -715,136 +715,136 @@  discard block
 block discarded – undo
715 715
         )
716 716
     );
717 717
 
718
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
718
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
719 719
 }
720 720
 
721
-function wpinv_settings_sanitize( $input = array() ) {
721
+function wpinv_settings_sanitize($input = array()) {
722 722
     global $wpinv_options;
723 723
 
724
-    if ( empty( wp_get_raw_referer() ) ) {
724
+    if (empty(wp_get_raw_referer())) {
725 725
         return $input;
726 726
     }
727 727
 
728
-    wp_parse_str( wp_get_raw_referer(), $referrer );
728
+    wp_parse_str(wp_get_raw_referer(), $referrer);
729 729
 
730 730
     $settings = wpinv_get_registered_settings();
731
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
732
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
731
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
732
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
733 733
 
734 734
     $input = $input ? $input : array();
735
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
736
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
735
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
736
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
737 737
 
738 738
     // Loop through each setting being saved and pass it through a sanitization filter
739
-    foreach ( $input as $key => $value ) {
739
+    foreach ($input as $key => $value) {
740 740
         // Get the setting type (checkbox, select, etc)
741
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
741
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
742 742
 
743
-        if ( $type ) {
743
+        if ($type) {
744 744
             // Field type specific filter
745
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
745
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
746 746
         }
747 747
 
748 748
         // General filter
749
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
749
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
750 750
     }
751 751
 
752 752
     // Loop through the whitelist and unset any that are empty for the tab being saved
753
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
754
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
753
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
754
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
755 755
 
756
-    $found_settings = array_merge( $main_settings, $section_settings );
756
+    $found_settings = array_merge($main_settings, $section_settings);
757 757
 
758
-    if ( ! empty( $found_settings ) ) {
759
-        foreach ( $found_settings as $key => $value ) {
758
+    if (!empty($found_settings)) {
759
+        foreach ($found_settings as $key => $value) {
760 760
 
761 761
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
762
-            if ( is_numeric( $key ) ) {
762
+            if (is_numeric($key)) {
763 763
                 $key = $value['id'];
764 764
             }
765 765
 
766
-            if ( empty( $input[ $key ] ) ) {
767
-                unset( $wpinv_options[ $key ] );
766
+            if (empty($input[$key])) {
767
+                unset($wpinv_options[$key]);
768 768
             }
769 769
         }
770 770
     }
771 771
 
772 772
     // Merge our new settings with the existing
773
-    $output = array_merge( $wpinv_options, $input );
773
+    $output = array_merge($wpinv_options, $input);
774 774
 
775
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
775
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
776 776
 
777 777
     return $output;
778 778
 }
779 779
 
780
-function wpinv_settings_sanitize_misc_accounting( $input ) {
780
+function wpinv_settings_sanitize_misc_accounting($input) {
781 781
     global $wpi_session;
782 782
 
783
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
783
+    if (!wpinv_current_user_can_manage_invoicing()) {
784 784
         return $input;
785 785
     }
786 786
 
787
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
787
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
788 788
         // Shows an admin notice about upgrading previous order numbers
789
-        $wpi_session->set( 'upgrade_sequential', '1' );
789
+        $wpi_session->set('upgrade_sequential', '1');
790 790
     }
791 791
 
792 792
     return $input;
793 793
 }
794
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
794
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
795 795
 
796
-function wpinv_settings_sanitize_tax_rates( $input ) {
797
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
796
+function wpinv_settings_sanitize_tax_rates($input) {
797
+    if (!wpinv_current_user_can_manage_invoicing()) {
798 798
         return $input;
799 799
     }
800 800
 
801
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
801
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
802 802
 
803 803
     $tax_rates = array();
804 804
 
805
-    if ( !empty( $new_rates ) ) {
806
-        foreach ( $new_rates as $rate ) {
807
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
805
+    if (!empty($new_rates)) {
806
+        foreach ($new_rates as $rate) {
807
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
808 808
                 continue;
809 809
             }
810 810
             
811
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
811
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
812 812
             
813 813
             $tax_rates[] = $rate;
814 814
         }
815 815
     }
816 816
 
817
-    update_option( 'wpinv_tax_rates', $tax_rates );
817
+    update_option('wpinv_tax_rates', $tax_rates);
818 818
 
819 819
     return $input;
820 820
 }
821
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
821
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
822 822
 
823
-function wpinv_sanitize_text_field( $input ) {
824
-    return trim( $input );
823
+function wpinv_sanitize_text_field($input) {
824
+    return trim($input);
825 825
 }
826
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
826
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
827 827
 
828 828
 function wpinv_get_settings_tabs() {
829 829
     $tabs             = array();
830
-    $tabs['general']  = __( 'General', 'invoicing' );
831
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
832
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
833
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
834
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
835
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
836
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
837
-
838
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
830
+    $tabs['general']  = __('General', 'invoicing');
831
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
832
+    $tabs['taxes']    = __('Taxes', 'invoicing');
833
+    $tabs['emails']   = __('Emails', 'invoicing');
834
+    $tabs['privacy']  = __('Privacy', 'invoicing');
835
+    $tabs['misc']     = __('Misc', 'invoicing');
836
+    $tabs['tools']    = __('Tools', 'invoicing');
837
+
838
+    return apply_filters('wpinv_settings_tabs', $tabs);
839 839
 }
840 840
 
841
-function wpinv_get_settings_tab_sections( $tab = false ) {
841
+function wpinv_get_settings_tab_sections($tab = false) {
842 842
     $tabs     = false;
843 843
     $sections = wpinv_get_registered_settings_sections();
844 844
 
845
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
846
-        $tabs = $sections[ $tab ];
847
-    } else if ( $tab ) {
845
+    if ($tab && !empty($sections[$tab])) {
846
+        $tabs = $sections[$tab];
847
+    } else if ($tab) {
848 848
         $tabs = false;
849 849
     }
850 850
 
@@ -854,143 +854,143 @@  discard block
 block discarded – undo
854 854
 function wpinv_get_registered_settings_sections() {
855 855
     static $sections = false;
856 856
 
857
-    if ( false !== $sections ) {
857
+    if (false !== $sections) {
858 858
         return $sections;
859 859
     }
860 860
 
861 861
     $sections = array(
862
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
863
-            'main' => __( 'General Settings', 'invoicing' ),
864
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
865
-            'labels' => __( 'Label Texts', 'invoicing' ),
866
-        ) ),
867
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
868
-            'main' => __( 'Gateway Settings', 'invoicing' ),
869
-        ) ),
870
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
871
-            'main' => __( 'Tax Settings', 'invoicing' ),
872
-            'rates' => __( 'Tax Rates', 'invoicing' ),
873
-        ) ),
874
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
875
-            'main' => __( 'Email Settings', 'invoicing' ),
876
-        ) ),
877
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
878
-            'main' => __( 'Privacy policy', 'invoicing' ),
879
-        ) ),
880
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
881
-            'main' => __( 'Miscellaneous', 'invoicing' ),
882
-            'fields' => __( 'Fields Settings', 'invoicing' ),
883
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
884
-        ) ),
885
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
886
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
887
-        ) ),
862
+        'general' => apply_filters('wpinv_settings_sections_general', array(
863
+            'main' => __('General Settings', 'invoicing'),
864
+            'currency_section' => __('Currency Settings', 'invoicing'),
865
+            'labels' => __('Label Texts', 'invoicing'),
866
+        )),
867
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
868
+            'main' => __('Gateway Settings', 'invoicing'),
869
+        )),
870
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
871
+            'main' => __('Tax Settings', 'invoicing'),
872
+            'rates' => __('Tax Rates', 'invoicing'),
873
+        )),
874
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
875
+            'main' => __('Email Settings', 'invoicing'),
876
+        )),
877
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
878
+            'main' => __('Privacy policy', 'invoicing'),
879
+        )),
880
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
881
+            'main' => __('Miscellaneous', 'invoicing'),
882
+            'fields' => __('Fields Settings', 'invoicing'),
883
+            'custom-css' => __('Custom CSS', 'invoicing'),
884
+        )),
885
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
886
+            'main' => __('Diagnostic Tools', 'invoicing'),
887
+        )),
888 888
     );
889 889
 
890
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
890
+    $sections = apply_filters('wpinv_settings_sections', $sections);
891 891
 
892 892
     return $sections;
893 893
 }
894 894
 
895
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
895
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
896 896
 	$pages_options = array();
897 897
 
898
-	if( $default_label !== NULL && $default_label !== false ) {
899
-		$pages_options = array( '' => $default_label ); // Blank option
898
+	if ($default_label !== NULL && $default_label !== false) {
899
+		$pages_options = array('' => $default_label); // Blank option
900 900
 	}
901 901
 
902 902
 	$pages = get_pages();
903
-	if ( $pages ) {
904
-		foreach ( $pages as $page ) {
903
+	if ($pages) {
904
+		foreach ($pages as $page) {
905 905
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
906
-            $pages_options[ $page->ID ] = $title;
906
+            $pages_options[$page->ID] = $title;
907 907
 		}
908 908
 	}
909 909
 
910 910
 	return $pages_options;
911 911
 }
912 912
 
913
-function wpinv_header_callback( $args ) {
914
-	if ( !empty( $args['desc'] ) ) {
913
+function wpinv_header_callback($args) {
914
+	if (!empty($args['desc'])) {
915 915
         echo $args['desc'];
916 916
     }
917 917
 }
918 918
 
919
-function wpinv_hidden_callback( $args ) {
919
+function wpinv_hidden_callback($args) {
920 920
 	global $wpinv_options;
921 921
 
922
-	if ( isset( $args['set_value'] ) ) {
922
+	if (isset($args['set_value'])) {
923 923
 		$value = $args['set_value'];
924
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
925
-		$value = $wpinv_options[ $args['id'] ];
924
+	} elseif (isset($wpinv_options[$args['id']])) {
925
+		$value = $wpinv_options[$args['id']];
926 926
 	} else {
927
-		$value = isset( $args['std'] ) ? $args['std'] : '';
927
+		$value = isset($args['std']) ? $args['std'] : '';
928 928
 	}
929 929
 
930
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
930
+	if (isset($args['faux']) && true === $args['faux']) {
931 931
 		$args['readonly'] = true;
932
-		$value = isset( $args['std'] ) ? $args['std'] : '';
932
+		$value = isset($args['std']) ? $args['std'] : '';
933 933
 		$name  = '';
934 934
 	} else {
935
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
935
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
936 936
 	}
937 937
 
938
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
938
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
939 939
     
940 940
 	echo $html;
941 941
 }
942 942
 
943
-function wpinv_checkbox_callback( $args ) {
943
+function wpinv_checkbox_callback($args) {
944 944
 	global $wpinv_options;
945 945
     
946
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
946
+    $sanitize_id = wpinv_sanitize_key($args['id']);
947 947
 
948
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
948
+	if (isset($args['faux']) && true === $args['faux']) {
949 949
 		$name = '';
950 950
 	} else {
951 951
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
952 952
 	}
953 953
 
954
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
954
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
955 955
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
956
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
956
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
957 957
 
958 958
 	echo $html;
959 959
 }
960 960
 
961
-function wpinv_multicheck_callback( $args ) {
961
+function wpinv_multicheck_callback($args) {
962 962
 	global $wpinv_options;
963 963
 
964
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
965
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
964
+	$sanitize_id = wpinv_sanitize_key($args['id']);
965
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
966 966
 
967
-	if ( ! empty( $args['options'] ) ) {
967
+	if (!empty($args['options'])) {
968 968
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
969
-        foreach( $args['options'] as $key => $option ):
970
-			$sanitize_key = wpinv_sanitize_key( $key );
971
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
969
+        foreach ($args['options'] as $key => $option):
970
+			$sanitize_key = wpinv_sanitize_key($key);
971
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
972 972
 				$enabled = $sanitize_key;
973 973
 			} else { 
974 974
 				$enabled = NULL; 
975 975
 			}
976
-			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 ) . '/>&nbsp;';
977
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
976
+			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) . '/>&nbsp;';
977
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
978 978
 		endforeach;
979 979
 		echo '</div>';
980 980
 		echo '<p class="description">' . $args['desc'] . '</p>';
981 981
 	}
982 982
 }
983 983
 
984
-function wpinv_payment_icons_callback( $args ) {
984
+function wpinv_payment_icons_callback($args) {
985 985
 	global $wpinv_options;
986 986
     
987
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
987
+    $sanitize_id = wpinv_sanitize_key($args['id']);
988 988
 
989
-	if ( ! empty( $args['options'] ) ) {
990
-		foreach( $args['options'] as $key => $option ) {
991
-            $sanitize_key = wpinv_sanitize_key( $key );
989
+	if (!empty($args['options'])) {
990
+		foreach ($args['options'] as $key => $option) {
991
+            $sanitize_key = wpinv_sanitize_key($key);
992 992
             
993
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
993
+			if (isset($wpinv_options[$args['id']][$key])) {
994 994
 				$enabled = $option;
995 995
 			} else {
996 996
 				$enabled = NULL;
@@ -998,197 +998,197 @@  discard block
 block discarded – undo
998 998
 
999 999
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
1000 1000
 
1001
-				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 ) . '/>&nbsp;';
1001
+				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) . '/>&nbsp;';
1002 1002
 
1003
-				if ( wpinv_string_is_image_url( $key ) ) {
1004
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1003
+				if (wpinv_string_is_image_url($key)) {
1004
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1005 1005
 				} else {
1006
-					$card = strtolower( str_replace( ' ', '', $option ) );
1006
+					$card = strtolower(str_replace(' ', '', $option));
1007 1007
 
1008
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
1009
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
1008
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
1009
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
1010 1010
 					} else {
1011
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
1011
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
1012 1012
 						$content_dir = WP_CONTENT_DIR;
1013 1013
 
1014
-						if ( function_exists( 'wp_normalize_path' ) ) {
1014
+						if (function_exists('wp_normalize_path')) {
1015 1015
 							// Replaces backslashes with forward slashes for Windows systems
1016
-							$image = wp_normalize_path( $image );
1017
-							$content_dir = wp_normalize_path( $content_dir );
1016
+							$image = wp_normalize_path($image);
1017
+							$content_dir = wp_normalize_path($content_dir);
1018 1018
 						}
1019 1019
 
1020
-						$image = str_replace( $content_dir, content_url(), $image );
1020
+						$image = str_replace($content_dir, content_url(), $image);
1021 1021
 					}
1022 1022
 
1023
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1023
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1024 1024
 				}
1025 1025
 			echo $option . '</label>';
1026 1026
 		}
1027
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
1027
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
1028 1028
 	}
1029 1029
 }
1030 1030
 
1031
-function wpinv_radio_callback( $args ) {
1031
+function wpinv_radio_callback($args) {
1032 1032
 	global $wpinv_options;
1033 1033
     
1034
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1034
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1035 1035
     
1036
-    foreach ( $args['options'] as $key => $option ) :
1037
-		$sanitize_key = wpinv_sanitize_key( $key );
1036
+    foreach ($args['options'] as $key => $option) :
1037
+		$sanitize_key = wpinv_sanitize_key($key);
1038 1038
         
1039 1039
         $checked = false;
1040 1040
 
1041
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
1041
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
1042 1042
 			$checked = true;
1043
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
1043
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
1044 1044
 			$checked = true;
1045 1045
 
1046 1046
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
1047
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
1047
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
1048 1048
 	endforeach;
1049 1049
 
1050
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
1050
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
1051 1051
 }
1052 1052
 
1053
-function wpinv_gateways_callback( $args ) {
1053
+function wpinv_gateways_callback($args) {
1054 1054
 	global $wpinv_options;
1055 1055
     
1056
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1056
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1057 1057
 
1058
-	foreach ( $args['options'] as $key => $option ) :
1059
-		$sanitize_key = wpinv_sanitize_key( $key );
1058
+	foreach ($args['options'] as $key => $option) :
1059
+		$sanitize_key = wpinv_sanitize_key($key);
1060 1060
         
1061
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
1061
+        if (isset($wpinv_options['gateways'][$key]))
1062 1062
 			$enabled = '1';
1063 1063
 		else
1064 1064
 			$enabled = null;
1065 1065
 
1066
-		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) . '/>&nbsp;';
1067
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1066
+		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) . '/>&nbsp;';
1067
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1068 1068
 	endforeach;
1069 1069
 }
1070 1070
 
1071 1071
 function wpinv_gateway_select_callback($args) {
1072 1072
 	global $wpinv_options;
1073 1073
     
1074
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1075
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1074
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1075
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1076 1076
 
1077
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
1077
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
1078 1078
 
1079
-	foreach ( $args['options'] as $key => $option ) :
1080
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1081
-            $selected = selected( $key, $args['selected'], false );
1079
+	foreach ($args['options'] as $key => $option) :
1080
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1081
+            $selected = selected($key, $args['selected'], false);
1082 1082
         } else {
1083
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1083
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1084 1084
         }
1085
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1085
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1086 1086
 	endforeach;
1087 1087
 
1088 1088
 	echo '</select>';
1089
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1089
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1090 1090
 }
1091 1091
 
1092
-function wpinv_text_callback( $args ) {
1092
+function wpinv_text_callback($args) {
1093 1093
 	global $wpinv_options;
1094 1094
     
1095
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1095
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1096 1096
 
1097
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1098
-		$value = $wpinv_options[ $args['id'] ];
1097
+	if (isset($wpinv_options[$args['id']])) {
1098
+		$value = $wpinv_options[$args['id']];
1099 1099
 	} else {
1100
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1100
+		$value = isset($args['std']) ? $args['std'] : '';
1101 1101
 	}
1102 1102
 
1103
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1103
+	if (isset($args['faux']) && true === $args['faux']) {
1104 1104
 		$args['readonly'] = true;
1105
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1105
+		$value = isset($args['std']) ? $args['std'] : '';
1106 1106
 		$name  = '';
1107 1107
 	} else {
1108
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1108
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1109 1109
 	}
1110
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1110
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1111 1111
 
1112 1112
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1113
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1114
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1115
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1113
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1114
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1115
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1116 1116
 
1117 1117
 	echo $html;
1118 1118
 }
1119 1119
 
1120
-function wpinv_number_callback( $args ) {
1120
+function wpinv_number_callback($args) {
1121 1121
 	global $wpinv_options;
1122 1122
     
1123
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1123
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1124 1124
 
1125
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1126
-		$value = $wpinv_options[ $args['id'] ];
1125
+	if (isset($wpinv_options[$args['id']])) {
1126
+		$value = $wpinv_options[$args['id']];
1127 1127
 	} else {
1128
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1128
+		$value = isset($args['std']) ? $args['std'] : '';
1129 1129
 	}
1130 1130
 
1131
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1131
+	if (isset($args['faux']) && true === $args['faux']) {
1132 1132
 		$args['readonly'] = true;
1133
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1133
+		$value = isset($args['std']) ? $args['std'] : '';
1134 1134
 		$name  = '';
1135 1135
 	} else {
1136
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1136
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1137 1137
 	}
1138 1138
 
1139
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1140
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1141
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1142
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1139
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1140
+	$min  = isset($args['min']) ? $args['min'] : 0;
1141
+	$step = isset($args['step']) ? $args['step'] : 1;
1142
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1143 1143
 
1144
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1145
-	$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 ) ) . '"/>';
1146
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1144
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1145
+	$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)) . '"/>';
1146
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1147 1147
 
1148 1148
 	echo $html;
1149 1149
 }
1150 1150
 
1151
-function wpinv_textarea_callback( $args ) {
1151
+function wpinv_textarea_callback($args) {
1152 1152
 	global $wpinv_options;
1153 1153
     
1154
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1154
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1155 1155
 
1156
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1157
-		$value = $wpinv_options[ $args['id'] ];
1156
+	if (isset($wpinv_options[$args['id']])) {
1157
+		$value = $wpinv_options[$args['id']];
1158 1158
 	} else {
1159
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1159
+		$value = isset($args['std']) ? $args['std'] : '';
1160 1160
 	}
1161 1161
     
1162
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1163
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1162
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1163
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1164 1164
 
1165
-	$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>';
1166
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1165
+	$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>';
1166
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1167 1167
 
1168 1168
 	echo $html;
1169 1169
 }
1170 1170
 
1171
-function wpinv_password_callback( $args ) {
1171
+function wpinv_password_callback($args) {
1172 1172
 	global $wpinv_options;
1173 1173
     
1174
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1174
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1175 1175
 
1176
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1177
-		$value = $wpinv_options[ $args['id'] ];
1176
+	if (isset($wpinv_options[$args['id']])) {
1177
+		$value = $wpinv_options[$args['id']];
1178 1178
 	} else {
1179
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1179
+		$value = isset($args['std']) ? $args['std'] : '';
1180 1180
 	}
1181 1181
 
1182
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1183
-	$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 ) . '"/>';
1184
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1182
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1183
+	$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) . '"/>';
1184
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1185 1185
 
1186 1186
 	echo $html;
1187 1187
 }
1188 1188
 
1189 1189
 function wpinv_missing_callback($args) {
1190 1190
 	printf(
1191
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1191
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1192 1192
 		'<strong>' . $args['id'] . '</strong>'
1193 1193
 	);
1194 1194
 }
@@ -1196,133 +1196,133 @@  discard block
 block discarded – undo
1196 1196
 function wpinv_select_callback($args) {
1197 1197
 	global $wpinv_options;
1198 1198
     
1199
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1199
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1200 1200
 
1201
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1202
-		$value = $wpinv_options[ $args['id'] ];
1201
+	if (isset($wpinv_options[$args['id']])) {
1202
+		$value = $wpinv_options[$args['id']];
1203 1203
 	} else {
1204
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1204
+		$value = isset($args['std']) ? $args['std'] : '';
1205 1205
 	}
1206 1206
     
1207
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1207
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1208 1208
         $value = $args['selected'];
1209 1209
     }
1210 1210
 
1211
-	if ( isset( $args['placeholder'] ) ) {
1211
+	if (isset($args['placeholder'])) {
1212 1212
 		$placeholder = $args['placeholder'];
1213 1213
 	} else {
1214 1214
 		$placeholder = '';
1215 1215
 	}
1216 1216
     
1217
-    if( !empty( $args['onchange'] ) ) {
1218
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1217
+    if (!empty($args['onchange'])) {
1218
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1219 1219
     } else {
1220 1220
         $onchange = '';
1221 1221
     }
1222 1222
 
1223
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1223
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1224 1224
 
1225
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1225
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '"  name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1226 1226
 
1227
-	foreach ( $args['options'] as $option => $name ) {
1228
-		$selected = selected( $option, $value, false );
1229
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1227
+	foreach ($args['options'] as $option => $name) {
1228
+		$selected = selected($option, $value, false);
1229
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1230 1230
 	}
1231 1231
 
1232 1232
 	$html .= '</select>';
1233
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1233
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1234 1234
 
1235 1235
 	echo $html;
1236 1236
 }
1237 1237
 
1238
-function wpinv_color_select_callback( $args ) {
1238
+function wpinv_color_select_callback($args) {
1239 1239
 	global $wpinv_options;
1240 1240
     
1241
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1241
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1242 1242
 
1243
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1244
-		$value = $wpinv_options[ $args['id'] ];
1243
+	if (isset($wpinv_options[$args['id']])) {
1244
+		$value = $wpinv_options[$args['id']];
1245 1245
 	} else {
1246
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1246
+		$value = isset($args['std']) ? $args['std'] : '';
1247 1247
 	}
1248 1248
 
1249
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1249
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1250 1250
 
1251
-	foreach ( $args['options'] as $option => $color ) {
1252
-		$selected = selected( $option, $value, false );
1253
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1251
+	foreach ($args['options'] as $option => $color) {
1252
+		$selected = selected($option, $value, false);
1253
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1254 1254
 	}
1255 1255
 
1256 1256
 	$html .= '</select>';
1257
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1257
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1258 1258
 
1259 1259
 	echo $html;
1260 1260
 }
1261 1261
 
1262
-function wpinv_rich_editor_callback( $args ) {
1262
+function wpinv_rich_editor_callback($args) {
1263 1263
 	global $wpinv_options, $wp_version;
1264 1264
     
1265
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1265
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1266 1266
 
1267
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1268
-		$value = $wpinv_options[ $args['id'] ];
1267
+	if (isset($wpinv_options[$args['id']])) {
1268
+		$value = $wpinv_options[$args['id']];
1269 1269
 
1270
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1271
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1270
+		if (empty($args['allow_blank']) && empty($value)) {
1271
+			$value = isset($args['std']) ? $args['std'] : '';
1272 1272
 		}
1273 1273
 	} else {
1274
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1274
+		$value = isset($args['std']) ? $args['std'] : '';
1275 1275
 	}
1276 1276
 
1277
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1277
+	$rows = isset($args['size']) ? $args['size'] : 20;
1278 1278
 
1279
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1279
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1280 1280
 		ob_start();
1281
-		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 ) );
1281
+		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));
1282 1282
 		$html = ob_get_clean();
1283 1283
 	} else {
1284
-		$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>';
1284
+		$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>';
1285 1285
 	}
1286 1286
 
1287
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1287
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1288 1288
 
1289 1289
 	echo $html;
1290 1290
 }
1291 1291
 
1292
-function wpinv_upload_callback( $args ) {
1292
+function wpinv_upload_callback($args) {
1293 1293
 	global $wpinv_options;
1294 1294
     
1295
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1295
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1296 1296
 
1297
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1297
+	if (isset($wpinv_options[$args['id']])) {
1298 1298
 		$value = $wpinv_options[$args['id']];
1299 1299
 	} else {
1300 1300
 		$value = isset($args['std']) ? $args['std'] : '';
1301 1301
 	}
1302 1302
 
1303
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1304
-	$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 ) ) . '"/>';
1305
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1306
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1303
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1304
+	$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)) . '"/>';
1305
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1306
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1307 1307
 
1308 1308
 	echo $html;
1309 1309
 }
1310 1310
 
1311
-function wpinv_color_callback( $args ) {
1311
+function wpinv_color_callback($args) {
1312 1312
 	global $wpinv_options;
1313 1313
     
1314
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1314
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1315 1315
 
1316
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1317
-		$value = $wpinv_options[ $args['id'] ];
1316
+	if (isset($wpinv_options[$args['id']])) {
1317
+		$value = $wpinv_options[$args['id']];
1318 1318
 	} else {
1319
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1319
+		$value = isset($args['std']) ? $args['std'] : '';
1320 1320
 	}
1321 1321
 
1322
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1322
+	$default = isset($args['std']) ? $args['std'] : '';
1323 1323
 
1324
-	$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 ) . '" />';
1325
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1324
+	$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) . '" />';
1325
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1326 1326
 
1327 1327
 	echo $html;
1328 1328
 }
@@ -1330,9 +1330,9 @@  discard block
 block discarded – undo
1330 1330
 function wpinv_country_states_callback($args) {
1331 1331
 	global $wpinv_options;
1332 1332
     
1333
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1333
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1334 1334
 
1335
-	if ( isset( $args['placeholder'] ) ) {
1335
+	if (isset($args['placeholder'])) {
1336 1336
 		$placeholder = $args['placeholder'];
1337 1337
 	} else {
1338 1338
 		$placeholder = '';
@@ -1340,16 +1340,16 @@  discard block
 block discarded – undo
1340 1340
 
1341 1341
 	$states = wpinv_get_country_states();
1342 1342
 
1343
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
1344
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1343
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
1344
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1345 1345
 
1346
-	foreach ( $states as $option => $name ) {
1347
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1348
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1346
+	foreach ($states as $option => $name) {
1347
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1348
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1349 1349
 	}
1350 1350
 
1351 1351
 	$html .= '</select>';
1352
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1352
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1353 1353
 
1354 1354
 	echo $html;
1355 1355
 }
@@ -1364,96 +1364,96 @@  discard block
 block discarded – undo
1364 1364
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1365 1365
 		<thead>
1366 1366
 			<tr>
1367
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1368
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1369
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
1370
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1371
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1372
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1367
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1368
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1369
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
1370
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1371
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1372
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1373 1373
 			</tr>
1374 1374
 		</thead>
1375 1375
         <tbody>
1376
-		<?php if( !empty( $rates ) ) : ?>
1377
-			<?php foreach( $rates as $key => $rate ) : ?>
1376
+		<?php if (!empty($rates)) : ?>
1377
+			<?php foreach ($rates as $key => $rate) : ?>
1378 1378
             <?php 
1379
-            $sanitized_key = wpinv_sanitize_key( $key );
1379
+            $sanitized_key = wpinv_sanitize_key($key);
1380 1380
             ?>
1381 1381
 			<tr>
1382 1382
 				<td class="wpinv_tax_country">
1383 1383
 					<?php
1384
-					echo wpinv_html_select( array(
1385
-						'options'          => wpinv_get_country_list( true ),
1384
+					echo wpinv_html_select(array(
1385
+						'options'          => wpinv_get_country_list(true),
1386 1386
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1387 1387
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1388 1388
 						'selected'         => $rate['country'],
1389 1389
 						'show_option_all'  => false,
1390 1390
 						'show_option_none' => false,
1391 1391
 						'class'            => 'wpinv-tax-country wpi_select2',
1392
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1393
-					) );
1392
+						'placeholder'      => __('Choose a country', 'invoicing')
1393
+					));
1394 1394
 					?>
1395 1395
 				</td>
1396 1396
 				<td class="wpinv_tax_state">
1397 1397
 					<?php
1398
-					$states = wpinv_get_country_states( $rate['country'] );
1399
-					if( !empty( $states ) ) {
1400
-						echo wpinv_html_select( array(
1401
-							'options'          => array_merge( array( '' => '' ), $states ),
1398
+					$states = wpinv_get_country_states($rate['country']);
1399
+					if (!empty($states)) {
1400
+						echo wpinv_html_select(array(
1401
+							'options'          => array_merge(array('' => ''), $states),
1402 1402
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1403 1403
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1404 1404
 							'selected'         => $rate['state'],
1405 1405
 							'show_option_all'  => false,
1406 1406
 							'show_option_none' => false,
1407 1407
                             'class'            => 'wpi_select2',
1408
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1409
-						) );
1408
+							'placeholder'      => __('Choose a state', 'invoicing')
1409
+						));
1410 1410
 					} else {
1411
-						echo wpinv_html_text( array(
1411
+						echo wpinv_html_text(array(
1412 1412
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1413
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1413
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1414 1414
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1415
-						) );
1415
+						));
1416 1416
 					}
1417 1417
 					?>
1418 1418
 				</td>
1419 1419
 				<td class="wpinv_tax_global">
1420
-					<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'] ) ); ?>/>
1421
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1420
+					<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'])); ?>/>
1421
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1422 1422
 				</td>
1423
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
1424
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
1425
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1423
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
1424
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
1425
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1426 1426
 			</tr>
1427 1427
 			<?php endforeach; ?>
1428 1428
 		<?php else : ?>
1429 1429
 			<tr>
1430 1430
 				<td class="wpinv_tax_country">
1431 1431
 					<?php
1432
-					echo wpinv_html_select( array(
1433
-						'options'          => wpinv_get_country_list( true ),
1432
+					echo wpinv_html_select(array(
1433
+						'options'          => wpinv_get_country_list(true),
1434 1434
 						'name'             => 'tax_rates[0][country]',
1435 1435
 						'show_option_all'  => false,
1436 1436
 						'show_option_none' => false,
1437 1437
 						'class'            => 'wpinv-tax-country wpi_select2',
1438
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1439
-					) ); ?>
1438
+						'placeholder'      => __('Choose a country', 'invoicing')
1439
+					)); ?>
1440 1440
 				</td>
1441 1441
 				<td class="wpinv_tax_state">
1442
-					<?php echo wpinv_html_text( array(
1442
+					<?php echo wpinv_html_text(array(
1443 1443
 						'name' => 'tax_rates[0][state]'
1444
-					) ); ?>
1444
+					)); ?>
1445 1445
 				</td>
1446 1446
 				<td class="wpinv_tax_global">
1447 1447
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1448
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1448
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1449 1449
 				</td>
1450
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
1450
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>"/></td>
1451 1451
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1452
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1452
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1453 1453
 			</tr>
1454 1454
 		<?php endif; ?>
1455 1455
         </tbody>
1456
-        <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>
1456
+        <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>
1457 1457
 	</table>
1458 1458
 	<?php
1459 1459
 	echo ob_get_clean();
@@ -1464,76 +1464,76 @@  discard block
 block discarded – undo
1464 1464
     ob_start(); ?>
1465 1465
     </td><tr>
1466 1466
     <td colspan="2" class="wpinv_tools_tdbox">
1467
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1468
-    <?php do_action( 'wpinv_tools_before' ); ?>
1467
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1468
+    <?php do_action('wpinv_tools_before'); ?>
1469 1469
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1470 1470
         <thead>
1471 1471
             <tr>
1472
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1473
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1474
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1472
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1473
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1474
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1475 1475
             </tr>
1476 1476
         </thead>
1477
-            <?php do_action( 'wpinv_tools_row' ); ?>
1477
+            <?php do_action('wpinv_tools_row'); ?>
1478 1478
         <tbody>
1479 1479
         </tbody>
1480 1480
     </table>
1481
-    <?php do_action( 'wpinv_tools_after' ); ?>
1481
+    <?php do_action('wpinv_tools_after'); ?>
1482 1482
     <?php
1483 1483
     echo ob_get_clean();
1484 1484
 }
1485 1485
 
1486
-function wpinv_descriptive_text_callback( $args ) {
1487
-	echo wp_kses_post( $args['desc'] );
1486
+function wpinv_descriptive_text_callback($args) {
1487
+	echo wp_kses_post($args['desc']);
1488 1488
 }
1489 1489
 
1490
-function wpinv_hook_callback( $args ) {
1491
-	do_action( 'wpinv_' . $args['id'], $args );
1490
+function wpinv_hook_callback($args) {
1491
+	do_action('wpinv_' . $args['id'], $args);
1492 1492
 }
1493 1493
 
1494 1494
 function wpinv_set_settings_cap() {
1495 1495
 	return wpinv_get_capability();
1496 1496
 }
1497
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1497
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1498 1498
 
1499
-function wpinv_settings_sanitize_input( $value, $key ) {
1500
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1501
-        $value = wpinv_sanitize_amount( $value, 4 );
1499
+function wpinv_settings_sanitize_input($value, $key) {
1500
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1501
+        $value = wpinv_sanitize_amount($value, 4);
1502 1502
         $value = $value >= 100 ? 99 : $value;
1503 1503
     }
1504 1504
         
1505 1505
     return $value;
1506 1506
 }
1507
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1507
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1508 1508
 
1509
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1510
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1511
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1509
+function wpinv_on_update_settings($old_value, $value, $option) {
1510
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1511
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1512 1512
     
1513
-    if ( $old != $new ) {
1514
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1513
+    if ($old != $new) {
1514
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1515 1515
     }
1516 1516
 }
1517
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1518
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1519
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1520
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1521
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1522
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1523
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1524
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1525
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1526
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1527
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1528
-
1529
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1517
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1518
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1519
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1520
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1521
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1522
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1523
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1524
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1525
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1526
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1527
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1528
+
1529
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1530 1530
     ?>
1531 1531
     <div class="wpinv-email-wc-row ">
1532 1532
         <div class="wpinv-email-wc-td">
1533
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1533
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1534 1534
             <p class="wpinv-email-wc-description">
1535 1535
                 <?php
1536
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1536
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1537 1537
                     <strong>{site_title} :</strong> Site Title<br>
1538 1538
                     <strong>{name} :</strong> Customer\'s full name<br>
1539 1539
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1548 1548
                     <strong>{date} :</strong> Today\'s date.<br>
1549 1549
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1550
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1550
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1551 1551
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1552 1552
                 ?>
1553 1553
             </p>
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +576 added lines, -576 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,30 +125,30 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129 129
 
130 130
     // Make variables available to the template.
131
-    if ( ! empty( $args ) && is_array( $args ) ) {
132
-		extract( $args );
131
+    if (!empty($args) && is_array($args)) {
132
+		extract($args);
133 133
 	}
134 134
 
135 135
     // Locate the template.
136
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
136
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
137 137
 
138 138
     // Abort if the file does not exist.
139
-	if ( ! file_exists( $located ) ) {
140
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
139
+	if (!file_exists($located)) {
140
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
141 141
 		return;
142 142
 	}
143 143
 
144 144
     // Fires before loading a template.
145
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
145
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
146 146
 
147 147
     // Load the template.
148
-	include( $located );
148
+	include($located);
149 149
 
150 150
     // Fires after loading a template.
151
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
151
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
152 152
 }
153 153
 
154 154
 /**
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
161 161
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
162 162
  */
163
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
163
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
164 164
 	ob_start();
165
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
165
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
166 166
 	return ob_get_clean();
167 167
 }
168 168
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
  * @return string
173 173
  */
174 174
 function wpinv_template_path() {
175
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
175
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
176 176
 }
177 177
 
178 178
 /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
  * @return string
182 182
  */
183 183
 function wpinv_get_theme_template_dir_name() {
184
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
184
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
185 185
 }
186 186
 
187 187
 /**
@@ -193,72 +193,72 @@  discard block
 block discarded – undo
193 193
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
194 194
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
195 195
  */
196
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
196
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
197 197
 
198 198
     // Load the defaults for the template path and default path.
199
-    $template_path = empty( $template_path ) ? wpinv_template_path() : $template_path;
200
-    $default_path  = empty( $default_path ) ? WPINV_PLUGIN_DIR . 'templates/' : $default_path;
199
+    $template_path = empty($template_path) ? wpinv_template_path() : $template_path;
200
+    $default_path  = empty($default_path) ? WPINV_PLUGIN_DIR . 'templates/' : $default_path;
201 201
 
202 202
     // Check if the template was overidden.
203 203
     $template = locate_template(
204
-        array( trailingslashit( $template_path ) . $template_name )
204
+        array(trailingslashit($template_path) . $template_name)
205 205
     );
206 206
 
207 207
     // Maybe replace it with a default path.
208
-    if ( empty( $template ) && ! empty( $default_path ) ) {
209
-        $template = trailingslashit( $default_path ) . $template_name;
208
+    if (empty($template) && !empty($default_path)) {
209
+        $template = trailingslashit($default_path) . $template_name;
210 210
     }
211 211
 
212 212
     // Return what we found.
213
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path );
213
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path, $default_path);
214 214
 }
215 215
 
216
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
217
-	do_action( 'get_template_part_' . $slug, $slug, $name );
216
+function wpinv_get_template_part($slug, $name = null, $load = true) {
217
+	do_action('get_template_part_' . $slug, $slug, $name);
218 218
 
219 219
 	// Setup possible parts
220 220
 	$templates = array();
221
-	if ( isset( $name ) )
221
+	if (isset($name))
222 222
 		$templates[] = $slug . '-' . $name . '.php';
223 223
 	$templates[] = $slug . '.php';
224 224
 
225 225
 	// Allow template parts to be filtered
226
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
226
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
227 227
 
228 228
 	// Return the part that is found
229
-	return wpinv_locate_tmpl( $templates, $load, false );
229
+	return wpinv_locate_tmpl($templates, $load, false);
230 230
 }
231 231
 
232
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
232
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
233 233
 	// No file found yet
234 234
 	$located = false;
235 235
 
236 236
 	// Try to find a template file
237
-	foreach ( (array)$template_names as $template_name ) {
237
+	foreach ((array) $template_names as $template_name) {
238 238
 
239 239
 		// Continue if template is empty
240
-		if ( empty( $template_name ) )
240
+		if (empty($template_name))
241 241
 			continue;
242 242
 
243 243
 		// Trim off any slashes from the template name
244
-		$template_name = ltrim( $template_name, '/' );
244
+		$template_name = ltrim($template_name, '/');
245 245
 
246 246
 		// try locating this template file by looping through the template paths
247
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
247
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
248 248
 
249
-			if( file_exists( $template_path . $template_name ) ) {
249
+			if (file_exists($template_path . $template_name)) {
250 250
 				$located = $template_path . $template_name;
251 251
 				break;
252 252
 			}
253 253
 		}
254 254
 
255
-		if( !empty( $located ) ) {
255
+		if (!empty($located)) {
256 256
 			break;
257 257
 		}
258 258
 	}
259 259
 
260
-	if ( ( true == $load ) && ! empty( $located ) )
261
-		load_template( $located, $require_once );
260
+	if ((true == $load) && !empty($located))
261
+		load_template($located, $require_once);
262 262
 
263 263
 	return $located;
264 264
 }
@@ -267,155 +267,155 @@  discard block
 block discarded – undo
267 267
 	$template_dir = wpinv_get_theme_template_dir_name();
268 268
 
269 269
 	$file_paths = array(
270
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
271
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
270
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
271
+		10 => trailingslashit(get_template_directory()) . $template_dir,
272 272
 		100 => wpinv_get_templates_dir()
273 273
 	);
274 274
 
275
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
275
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
276 276
 
277 277
 	// sort the file paths based on priority
278
-	ksort( $file_paths, SORT_NUMERIC );
278
+	ksort($file_paths, SORT_NUMERIC);
279 279
 
280
-	return array_map( 'trailingslashit', $file_paths );
280
+	return array_map('trailingslashit', $file_paths);
281 281
 }
282 282
 
283 283
 function wpinv_checkout_meta_tags() {
284 284
 
285 285
 	$pages   = array();
286
-	$pages[] = wpinv_get_option( 'success_page' );
287
-	$pages[] = wpinv_get_option( 'failure_page' );
288
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
289
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
286
+	$pages[] = wpinv_get_option('success_page');
287
+	$pages[] = wpinv_get_option('failure_page');
288
+	$pages[] = wpinv_get_option('invoice_history_page');
289
+	$pages[] = wpinv_get_option('invoice_subscription_page');
290 290
 
291
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
291
+	if (!wpinv_is_checkout() && !is_page($pages)) {
292 292
 		return;
293 293
 	}
294 294
 
295 295
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
296 296
 }
297
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
297
+add_action('wp_head', 'wpinv_checkout_meta_tags');
298 298
 
299
-function wpinv_add_body_classes( $class ) {
300
-	$classes = (array)$class;
299
+function wpinv_add_body_classes($class) {
300
+	$classes = (array) $class;
301 301
 
302
-	if( wpinv_is_checkout() ) {
302
+	if (wpinv_is_checkout()) {
303 303
 		$classes[] = 'wpinv-checkout';
304 304
 		$classes[] = 'wpinv-page';
305 305
 	}
306 306
 
307
-	if( wpinv_is_success_page() ) {
307
+	if (wpinv_is_success_page()) {
308 308
 		$classes[] = 'wpinv-success';
309 309
 		$classes[] = 'wpinv-page';
310 310
 	}
311 311
 
312
-	if( wpinv_is_failed_transaction_page() ) {
312
+	if (wpinv_is_failed_transaction_page()) {
313 313
 		$classes[] = 'wpinv-failed-transaction';
314 314
 		$classes[] = 'wpinv-page';
315 315
 	}
316 316
 
317
-	if( wpinv_is_invoice_history_page() ) {
317
+	if (wpinv_is_invoice_history_page()) {
318 318
 		$classes[] = 'wpinv-history';
319 319
 		$classes[] = 'wpinv-page';
320 320
 	}
321 321
 
322
-	if( wpinv_is_subscriptions_history_page() ) {
322
+	if (wpinv_is_subscriptions_history_page()) {
323 323
 		$classes[] = 'wpinv-subscription';
324 324
 		$classes[] = 'wpinv-page';
325 325
 	}
326 326
 
327
-	if( wpinv_is_test_mode() ) {
327
+	if (wpinv_is_test_mode()) {
328 328
 		$classes[] = 'wpinv-test-mode';
329 329
 		$classes[] = 'wpinv-page';
330 330
 	}
331 331
 
332
-	return array_unique( $classes );
332
+	return array_unique($classes);
333 333
 }
334
-add_filter( 'body_class', 'wpinv_add_body_classes' );
334
+add_filter('body_class', 'wpinv_add_body_classes');
335 335
 
336
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
337
-    $args = array( 'nopaging' => true );
336
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
337
+    $args = array('nopaging' => true);
338 338
 
339
-    if ( ! empty( $status ) )
339
+    if (!empty($status))
340 340
         $args['post_status'] = $status;
341 341
 
342
-    $discounts = wpinv_get_discounts( $args );
342
+    $discounts = wpinv_get_discounts($args);
343 343
     $options   = array();
344 344
 
345
-    if ( $discounts ) {
346
-        foreach ( $discounts as $discount ) {
347
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
345
+    if ($discounts) {
346
+        foreach ($discounts as $discount) {
347
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
348 348
         }
349 349
     } else {
350
-        $options[0] = __( 'No discounts found', 'invoicing' );
350
+        $options[0] = __('No discounts found', 'invoicing');
351 351
     }
352 352
 
353
-    $output = wpinv_html_select( array(
353
+    $output = wpinv_html_select(array(
354 354
         'name'             => $name,
355 355
         'selected'         => $selected,
356 356
         'options'          => $options,
357 357
         'show_option_all'  => false,
358 358
         'show_option_none' => false,
359
-    ) );
359
+    ));
360 360
 
361 361
     return $output;
362 362
 }
363 363
 
364
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
365
-    $current     = date( 'Y' );
366
-    $start_year  = $current - absint( $years_before );
367
-    $end_year    = $current + absint( $years_after );
368
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
364
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
365
+    $current     = date('Y');
366
+    $start_year  = $current - absint($years_before);
367
+    $end_year    = $current + absint($years_after);
368
+    $selected    = empty($selected) ? date('Y') : $selected;
369 369
     $options     = array();
370 370
 
371
-    while ( $start_year <= $end_year ) {
372
-        $options[ absint( $start_year ) ] = $start_year;
371
+    while ($start_year <= $end_year) {
372
+        $options[absint($start_year)] = $start_year;
373 373
         $start_year++;
374 374
     }
375 375
 
376
-    $output = wpinv_html_select( array(
376
+    $output = wpinv_html_select(array(
377 377
         'name'             => $name,
378 378
         'selected'         => $selected,
379 379
         'options'          => $options,
380 380
         'show_option_all'  => false,
381 381
         'show_option_none' => false
382
-    ) );
382
+    ));
383 383
 
384 384
     return $output;
385 385
 }
386 386
 
387
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
387
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
388 388
 
389 389
     $options = array(
390
-        '1'  => __( 'January', 'invoicing' ),
391
-        '2'  => __( 'February', 'invoicing' ),
392
-        '3'  => __( 'March', 'invoicing' ),
393
-        '4'  => __( 'April', 'invoicing' ),
394
-        '5'  => __( 'May', 'invoicing' ),
395
-        '6'  => __( 'June', 'invoicing' ),
396
-        '7'  => __( 'July', 'invoicing' ),
397
-        '8'  => __( 'August', 'invoicing' ),
398
-        '9'  => __( 'September', 'invoicing' ),
399
-        '10' => __( 'October', 'invoicing' ),
400
-        '11' => __( 'November', 'invoicing' ),
401
-        '12' => __( 'December', 'invoicing' ),
390
+        '1'  => __('January', 'invoicing'),
391
+        '2'  => __('February', 'invoicing'),
392
+        '3'  => __('March', 'invoicing'),
393
+        '4'  => __('April', 'invoicing'),
394
+        '5'  => __('May', 'invoicing'),
395
+        '6'  => __('June', 'invoicing'),
396
+        '7'  => __('July', 'invoicing'),
397
+        '8'  => __('August', 'invoicing'),
398
+        '9'  => __('September', 'invoicing'),
399
+        '10' => __('October', 'invoicing'),
400
+        '11' => __('November', 'invoicing'),
401
+        '12' => __('December', 'invoicing'),
402 402
     );
403 403
 
404 404
     // If no month is selected, default to the current month
405
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
405
+    $selected = empty($selected) ? date('n') : $selected;
406 406
 
407
-    $output = wpinv_html_select( array(
407
+    $output = wpinv_html_select(array(
408 408
         'name'             => $name,
409 409
         'selected'         => $selected,
410 410
         'options'          => $options,
411 411
         'show_option_all'  => false,
412 412
         'show_option_none' => false
413
-    ) );
413
+    ));
414 414
 
415 415
     return $output;
416 416
 }
417 417
 
418
-function wpinv_html_select( $args = array() ) {
418
+function wpinv_html_select($args = array()) {
419 419
     $defaults = array(
420 420
         'options'          => array(),
421 421
         'name'             => null,
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
         'selected'         => 0,
425 425
         'placeholder'      => null,
426 426
         'multiple'         => false,
427
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
428
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
427
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
428
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
429 429
         'data'             => array(),
430 430
         'onchange'         => null,
431 431
         'required'         => false,
@@ -433,74 +433,74 @@  discard block
 block discarded – undo
433 433
         'readonly'         => false,
434 434
     );
435 435
 
436
-    $args = wp_parse_args( $args, $defaults );
436
+    $args = wp_parse_args($args, $defaults);
437 437
 
438 438
     $data_elements = '';
439
-    foreach ( $args['data'] as $key => $value ) {
440
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
439
+    foreach ($args['data'] as $key => $value) {
440
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
441 441
     }
442 442
 
443
-    if( $args['multiple'] ) {
443
+    if ($args['multiple']) {
444 444
         $multiple = ' MULTIPLE';
445 445
     } else {
446 446
         $multiple = '';
447 447
     }
448 448
 
449
-    if( $args['placeholder'] ) {
449
+    if ($args['placeholder']) {
450 450
         $placeholder = $args['placeholder'];
451 451
     } else {
452 452
         $placeholder = '';
453 453
     }
454 454
     
455 455
     $options = '';
456
-    if( !empty( $args['onchange'] ) ) {
457
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
456
+    if (!empty($args['onchange'])) {
457
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
458 458
     }
459 459
     
460
-    if( !empty( $args['required'] ) ) {
460
+    if (!empty($args['required'])) {
461 461
         $options .= ' required="required"';
462 462
     }
463 463
     
464
-    if( !empty( $args['disabled'] ) ) {
464
+    if (!empty($args['disabled'])) {
465 465
         $options .= ' disabled';
466 466
     }
467 467
     
468
-    if( !empty( $args['readonly'] ) ) {
468
+    if (!empty($args['readonly'])) {
469 469
         $options .= ' readonly';
470 470
     }
471 471
 
472
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
473
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
472
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
473
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
474 474
 
475
-    if ( $args['show_option_all'] ) {
476
-        if( $args['multiple'] ) {
477
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
475
+    if ($args['show_option_all']) {
476
+        if ($args['multiple']) {
477
+            $selected = selected(true, in_array(0, $args['selected']), false);
478 478
         } else {
479
-            $selected = selected( $args['selected'], 0, false );
479
+            $selected = selected($args['selected'], 0, false);
480 480
         }
481
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
481
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
482 482
     }
483 483
 
484
-    if ( !empty( $args['options'] ) ) {
484
+    if (!empty($args['options'])) {
485 485
 
486
-        if ( $args['show_option_none'] ) {
487
-            if( $args['multiple'] ) {
488
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
486
+        if ($args['show_option_none']) {
487
+            if ($args['multiple']) {
488
+                $selected = selected(true, in_array("", $args['selected']), false);
489 489
             } else {
490
-                $selected = selected( $args['selected'] === "", true, false );
490
+                $selected = selected($args['selected'] === "", true, false);
491 491
             }
492
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
492
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
493 493
         }
494 494
 
495
-        foreach( $args['options'] as $key => $option ) {
495
+        foreach ($args['options'] as $key => $option) {
496 496
 
497
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
498
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
497
+            if ($args['multiple'] && is_array($args['selected'])) {
498
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
499 499
             } else {
500
-                $selected = selected( $args['selected'], $key, false );
500
+                $selected = selected($args['selected'], $key, false);
501 501
             }
502 502
 
503
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
503
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
504 504
         }
505 505
     }
506 506
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     return $output;
510 510
 }
511 511
 
512
-function wpinv_item_dropdown( $args = array() ) {
512
+function wpinv_item_dropdown($args = array()) {
513 513
     $defaults = array(
514 514
         'name'              => 'wpi_item',
515 515
         'id'                => 'wpi_item',
@@ -517,14 +517,14 @@  discard block
 block discarded – undo
517 517
         'multiple'          => false,
518 518
         'selected'          => 0,
519 519
         'number'            => 100,
520
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
521
-        'data'              => array( 'search-type' => 'item' ),
520
+        'placeholder'       => __('Choose a item', 'invoicing'),
521
+        'data'              => array('search-type' => 'item'),
522 522
         'show_option_all'   => false,
523 523
         'show_option_none'  => false,
524 524
         'show_recurring'    => false,
525 525
     );
526 526
 
527
-    $args = wp_parse_args( $args, $defaults );
527
+    $args = wp_parse_args($args, $defaults);
528 528
 
529 529
     $item_args = array(
530 530
         'post_type'      => 'wpi_item',
@@ -533,44 +533,44 @@  discard block
 block discarded – undo
533 533
         'posts_per_page' => $args['number']
534 534
     );
535 535
 
536
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
536
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
537 537
 
538
-    $items      = get_posts( $item_args );
538
+    $items      = get_posts($item_args);
539 539
     $options    = array();
540
-    if ( $items ) {
541
-        foreach ( $items as $item ) {
542
-            $title = esc_html( $item->post_title );
540
+    if ($items) {
541
+        foreach ($items as $item) {
542
+            $title = esc_html($item->post_title);
543 543
             
544
-            if ( !empty( $args['show_recurring'] ) ) {
545
-                $title .= wpinv_get_item_suffix( $item->ID, false );
544
+            if (!empty($args['show_recurring'])) {
545
+                $title .= wpinv_get_item_suffix($item->ID, false);
546 546
             }
547 547
             
548
-            $options[ absint( $item->ID ) ] = $title;
548
+            $options[absint($item->ID)] = $title;
549 549
         }
550 550
     }
551 551
 
552 552
     // This ensures that any selected items are included in the drop down
553
-    if( is_array( $args['selected'] ) ) {
554
-        foreach( $args['selected'] as $item ) {
555
-            if( ! in_array( $item, $options ) ) {
556
-                $title = get_the_title( $item );
557
-                if ( !empty( $args['show_recurring'] ) ) {
558
-                    $title .= wpinv_get_item_suffix( $item, false );
553
+    if (is_array($args['selected'])) {
554
+        foreach ($args['selected'] as $item) {
555
+            if (!in_array($item, $options)) {
556
+                $title = get_the_title($item);
557
+                if (!empty($args['show_recurring'])) {
558
+                    $title .= wpinv_get_item_suffix($item, false);
559 559
                 }
560 560
                 $options[$item] = $title;
561 561
             }
562 562
         }
563
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
564
-        if ( ! in_array( $args['selected'], $options ) ) {
565
-            $title = get_the_title( $args['selected'] );
566
-            if ( !empty( $args['show_recurring'] ) ) {
567
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
563
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
564
+        if (!in_array($args['selected'], $options)) {
565
+            $title = get_the_title($args['selected']);
566
+            if (!empty($args['show_recurring'])) {
567
+                $title .= wpinv_get_item_suffix($args['selected'], false);
568 568
             }
569
-            $options[$args['selected']] = get_the_title( $args['selected'] );
569
+            $options[$args['selected']] = get_the_title($args['selected']);
570 570
         }
571 571
     }
572 572
 
573
-    $output = wpinv_html_select( array(
573
+    $output = wpinv_html_select(array(
574 574
         'name'             => $args['name'],
575 575
         'selected'         => $args['selected'],
576 576
         'id'               => $args['id'],
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         'show_option_all'  => $args['show_option_all'],
582 582
         'show_option_none' => $args['show_option_none'],
583 583
         'data'             => $args['data'],
584
-    ) );
584
+    ));
585 585
 
586 586
     return $output;
587 587
 }
@@ -601,16 +601,16 @@  discard block
 block discarded – undo
601 601
     );
602 602
 
603 603
     $options = array();
604
-    if ( $items ) {
605
-        foreach ( $items as $item ) {
606
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
604
+    if ($items) {
605
+        foreach ($items as $item) {
606
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
607 607
         }
608 608
     }
609 609
 
610 610
     return $options;
611 611
 }
612 612
 
613
-function wpinv_html_checkbox( $args = array() ) {
613
+function wpinv_html_checkbox($args = array()) {
614 614
     $defaults = array(
615 615
         'name'     => null,
616 616
         'current'  => null,
@@ -621,17 +621,17 @@  discard block
 block discarded – undo
621 621
         )
622 622
     );
623 623
 
624
-    $args = wp_parse_args( $args, $defaults );
624
+    $args = wp_parse_args($args, $defaults);
625 625
 
626
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
626
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
627 627
     $options = '';
628
-    if ( ! empty( $args['options']['disabled'] ) ) {
628
+    if (!empty($args['options']['disabled'])) {
629 629
         $options .= ' disabled="disabled"';
630
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
630
+    } elseif (!empty($args['options']['readonly'])) {
631 631
         $options .= ' readonly';
632 632
     }
633 633
 
634
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
634
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
635 635
 
636 636
     return $output;
637 637
 }
@@ -639,30 +639,30 @@  discard block
 block discarded – undo
639 639
 /**
640 640
  * Displays a hidden field.
641 641
  */
642
-function getpaid_hidden_field( $name, $value ) {
643
-    $name  = sanitize_text_field( $name );
644
-    $value = esc_attr( $value );
642
+function getpaid_hidden_field($name, $value) {
643
+    $name  = sanitize_text_field($name);
644
+    $value = esc_attr($value);
645 645
 
646 646
     echo "<input type='hidden' name='$name' value='$value' />";
647 647
 }
648 648
 
649
-function wpinv_html_text( $args = array() ) {
649
+function wpinv_html_text($args = array()) {
650 650
     // Backwards compatibility
651
-    if ( func_num_args() > 1 ) {
651
+    if (func_num_args() > 1) {
652 652
         $args = func_get_args();
653 653
 
654 654
         $name  = $args[0];
655
-        $value = isset( $args[1] ) ? $args[1] : '';
656
-        $label = isset( $args[2] ) ? $args[2] : '';
657
-        $desc  = isset( $args[3] ) ? $args[3] : '';
655
+        $value = isset($args[1]) ? $args[1] : '';
656
+        $label = isset($args[2]) ? $args[2] : '';
657
+        $desc  = isset($args[3]) ? $args[3] : '';
658 658
     }
659 659
 
660 660
     $defaults = array(
661 661
         'id'           => '',
662
-        'name'         => isset( $name )  ? $name  : 'text',
663
-        'value'        => isset( $value ) ? $value : null,
664
-        'label'        => isset( $label ) ? $label : null,
665
-        'desc'         => isset( $desc )  ? $desc  : null,
662
+        'name'         => isset($name) ? $name : 'text',
663
+        'value'        => isset($value) ? $value : null,
664
+        'label'        => isset($label) ? $label : null,
665
+        'desc'         => isset($desc) ? $desc : null,
666 666
         'placeholder'  => '',
667 667
         'class'        => 'regular-text',
668 668
         'disabled'     => false,
@@ -672,51 +672,51 @@  discard block
 block discarded – undo
672 672
         'data'         => false
673 673
     );
674 674
 
675
-    $args = wp_parse_args( $args, $defaults );
675
+    $args = wp_parse_args($args, $defaults);
676 676
 
677
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
677
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
678 678
     $options = '';
679
-    if( $args['required'] ) {
679
+    if ($args['required']) {
680 680
         $options .= ' required="required"';
681 681
     }
682
-    if( $args['readonly'] ) {
682
+    if ($args['readonly']) {
683 683
         $options .= ' readonly';
684 684
     }
685
-    if( $args['readonly'] ) {
685
+    if ($args['readonly']) {
686 686
         $options .= ' readonly';
687 687
     }
688 688
 
689 689
     $data = '';
690
-    if ( !empty( $args['data'] ) ) {
691
-        foreach ( $args['data'] as $key => $value ) {
692
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
690
+    if (!empty($args['data'])) {
691
+        foreach ($args['data'] as $key => $value) {
692
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
693 693
         }
694 694
     }
695 695
 
696
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
697
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
698
-    if ( ! empty( $args['desc'] ) ) {
699
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
696
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
697
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
698
+    if (!empty($args['desc'])) {
699
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
700 700
     }
701 701
 
702
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
702
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
703 703
 
704 704
     $output .= '</span>';
705 705
 
706 706
     return $output;
707 707
 }
708 708
 
709
-function wpinv_html_date_field( $args = array() ) {
710
-    if( empty( $args['class'] ) ) {
709
+function wpinv_html_date_field($args = array()) {
710
+    if (empty($args['class'])) {
711 711
         $args['class'] = 'wpiDatepicker';
712
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
712
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
713 713
         $args['class'] .= ' wpiDatepicker';
714 714
     }
715 715
 
716
-    return wpinv_html_text( $args );
716
+    return wpinv_html_text($args);
717 717
 }
718 718
 
719
-function wpinv_html_textarea( $args = array() ) {
719
+function wpinv_html_textarea($args = array()) {
720 720
     $defaults = array(
721 721
         'name'        => 'textarea',
722 722
         'value'       => null,
@@ -727,31 +727,31 @@  discard block
 block discarded – undo
727 727
         'placeholder' => '',
728 728
     );
729 729
 
730
-    $args = wp_parse_args( $args, $defaults );
730
+    $args = wp_parse_args($args, $defaults);
731 731
 
732
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
732
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
733 733
     $disabled = '';
734
-    if( $args['disabled'] ) {
734
+    if ($args['disabled']) {
735 735
         $disabled = ' disabled="disabled"';
736 736
     }
737 737
 
738
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
739
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
740
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
738
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
739
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
740
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
741 741
 
742
-    if ( ! empty( $args['desc'] ) ) {
743
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
742
+    if (!empty($args['desc'])) {
743
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
744 744
     }
745 745
     $output .= '</span>';
746 746
 
747 747
     return $output;
748 748
 }
749 749
 
750
-function wpinv_html_ajax_user_search( $args = array() ) {
750
+function wpinv_html_ajax_user_search($args = array()) {
751 751
     $defaults = array(
752 752
         'name'        => 'user_id',
753 753
         'value'       => null,
754
-        'placeholder' => __( 'Enter username', 'invoicing' ),
754
+        'placeholder' => __('Enter username', 'invoicing'),
755 755
         'label'       => null,
756 756
         'desc'        => null,
757 757
         'class'       => '',
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
         'data'        => false
761 761
     );
762 762
 
763
-    $args = wp_parse_args( $args, $defaults );
763
+    $args = wp_parse_args($args, $defaults);
764 764
 
765 765
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
766 766
 
767 767
     $output  = '<span class="wpinv_user_search_wrap">';
768
-        $output .= wpinv_html_text( $args );
769
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
768
+        $output .= wpinv_html_text($args);
769
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
770 770
     $output .= '</span>';
771 771
 
772 772
     return $output;
@@ -782,20 +782,20 @@  discard block
 block discarded – undo
782 782
  * 
783 783
  * @param string $template the template that is currently being used.
784 784
  */
785
-function wpinv_template( $template ) {
785
+function wpinv_template($template) {
786 786
     global $post;
787 787
 
788
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
788
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
789 789
 
790 790
         // If the user can view this invoice, display it.
791
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
791
+        if (wpinv_user_can_view_invoice($post->ID)) {
792 792
 
793
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
793
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
794 794
 
795 795
         // Else display an error message.
796 796
         } else {
797 797
 
798
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
798
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
799 799
 
800 800
         }
801 801
 
@@ -803,46 +803,46 @@  discard block
 block discarded – undo
803 803
 
804 804
     return $template;
805 805
 }
806
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
806
+add_filter('template_include', 'wpinv_template', 10, 1);
807 807
 
808 808
 function wpinv_get_business_address() {
809 809
     $business_address   = wpinv_store_address();
810
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
810
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
811 811
     
812 812
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
813 813
     
814
-    return apply_filters( 'wpinv_get_business_address', $business_address );
814
+    return apply_filters('wpinv_get_business_address', $business_address);
815 815
 }
816 816
 
817 817
 /**
818 818
  * Displays the company address.
819 819
  */
820 820
 function wpinv_display_from_address() {
821
-    wpinv_get_template( 'invoice/company-address.php' );
821
+    wpinv_get_template('invoice/company-address.php');
822 822
 }
823
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
823
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
824 824
 
825
-function wpinv_watermark( $id = 0 ) {
826
-    $output = wpinv_get_watermark( $id );
827
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
825
+function wpinv_watermark($id = 0) {
826
+    $output = wpinv_get_watermark($id);
827
+    return apply_filters('wpinv_get_watermark', $output, $id);
828 828
 }
829 829
 
830
-function wpinv_get_watermark( $id ) {
831
-    if ( !$id > 0 ) {
830
+function wpinv_get_watermark($id) {
831
+    if (!$id > 0) {
832 832
         return NULL;
833 833
     }
834 834
 
835
-    $invoice = wpinv_get_invoice( $id );
835
+    $invoice = wpinv_get_invoice($id);
836 836
     
837
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
838
-        if ( $invoice->is_paid() ) {
839
-            return __( 'Paid', 'invoicing' );
837
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
838
+        if ($invoice->is_paid()) {
839
+            return __('Paid', 'invoicing');
840 840
         }
841
-        if ( $invoice->is_refunded() ) {
842
-            return __( 'Refunded', 'invoicing' );
841
+        if ($invoice->is_refunded()) {
842
+            return __('Refunded', 'invoicing');
843 843
         }
844
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
845
-            return __( 'Cancelled', 'invoicing' );
844
+        if ($invoice->has_status(array('wpi-cancelled'))) {
845
+            return __('Cancelled', 'invoicing');
846 846
         }
847 847
     }
848 848
     
@@ -852,131 +852,131 @@  discard block
 block discarded – undo
852 852
 /**
853 853
  * @deprecated
854 854
  */
855
-function wpinv_display_invoice_details( $invoice ) {
856
-    return getpaid_invoice_meta( $invoice );
855
+function wpinv_display_invoice_details($invoice) {
856
+    return getpaid_invoice_meta($invoice);
857 857
 }
858 858
 
859 859
 /**
860 860
  * Displays invoice meta.
861 861
  */
862
-function getpaid_invoice_meta( $invoice ) {
862
+function getpaid_invoice_meta($invoice) {
863 863
 
864
-    $invoice = new WPInv_Invoice( $invoice );
864
+    $invoice = new WPInv_Invoice($invoice);
865 865
 
866 866
     // Ensure that we have an invoice.
867
-    if ( 0 == $invoice->get_id() ) {
867
+    if (0 == $invoice->get_id()) {
868 868
         return;
869 869
     }
870 870
 
871 871
     // Load the invoice meta.
872
-    $meta    = array(
872
+    $meta = array(
873 873
 
874 874
         'number' => array(
875 875
             'label' => sprintf(
876
-                __( '%s Number', 'invoicing' ),
877
-                ucfirst( $invoice->get_type() )
876
+                __('%s Number', 'invoicing'),
877
+                ucfirst($invoice->get_type())
878 878
             ),
879
-            'value' => sanitize_text_field( $invoice->get_number() ),
879
+            'value' => sanitize_text_field($invoice->get_number()),
880 880
         ),
881 881
 
882 882
         'status' => array(
883 883
             'label' => sprintf(
884
-                __( '%s Status', 'invoicing' ),
885
-                ucfirst( $invoice->get_type() )
884
+                __('%s Status', 'invoicing'),
885
+                ucfirst($invoice->get_type())
886 886
             ),
887
-            'value' => sanitize_text_field( $invoice->get_status_nicename() ),
887
+            'value' => sanitize_text_field($invoice->get_status_nicename()),
888 888
         ),
889 889
 
890 890
         'date' => array(
891 891
             'label' => sprintf(
892
-                __( '%s Date', 'invoicing' ),
893
-                ucfirst( $invoice->get_type() )
892
+                __('%s Date', 'invoicing'),
893
+                ucfirst($invoice->get_type())
894 894
             ),
895
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
895
+            'value' => getpaid_format_date($invoice->get_created_date()),
896 896
         ),
897 897
 
898 898
         'date_paid' => array(
899
-            'label' => __( 'Paid On', 'invoicing' ),
900
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
899
+            'label' => __('Paid On', 'invoicing'),
900
+            'value' => getpaid_format_date($invoice->get_completed_date()),
901 901
         ),
902 902
 
903 903
         'transaction_id' => array(
904
-            'label' => __( 'Transaction ID', 'invoicing' ),
905
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
904
+            'label' => __('Transaction ID', 'invoicing'),
905
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
906 906
         ),
907 907
 
908 908
         'due_date'  => array(
909
-            'label' => __( 'Due Date', 'invoicing' ),
910
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
909
+            'label' => __('Due Date', 'invoicing'),
910
+            'value' => getpaid_format_date($invoice->get_due_date()),
911 911
         ),
912 912
 
913 913
         'vat_number' => array(
914 914
             'label' => sprintf(
915
-                __( '%s Number', 'invoicing' ),
915
+                __('%s Number', 'invoicing'),
916 916
                 getpaid_tax()->get_vat_name()
917 917
             ),
918
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
918
+            'value' => sanitize_text_field($invoice->get_vat_number()),
919 919
         ),
920 920
 
921 921
     );
922 922
 
923 923
     // If it is not paid, remove the date of payment.
924
-    if ( ! $invoice->is_paid() ) {
925
-        unset( $meta[ 'date_paid' ] );
926
-        unset( $meta[ 'transaction_id' ] );
924
+    if (!$invoice->is_paid()) {
925
+        unset($meta['date_paid']);
926
+        unset($meta['transaction_id']);
927 927
     }
928 928
 
929 929
     // Only display the due date if due dates are enabled.
930
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
931
-        unset( $meta[ 'due_date' ] );
930
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
931
+        unset($meta['due_date']);
932 932
     }
933 933
 
934 934
     // Only display the vat number if taxes are enabled.
935
-    if ( ! wpinv_use_taxes() ) {
936
-        unset( $meta[ 'vat_number' ] );
935
+    if (!wpinv_use_taxes()) {
936
+        unset($meta['vat_number']);
937 937
     }
938 938
 
939
-    if ( $invoice->is_recurring() ) {
939
+    if ($invoice->is_recurring()) {
940 940
 
941 941
         // Link to the parent invoice.
942
-        if ( $invoice->is_renewal() ) {
942
+        if ($invoice->is_renewal()) {
943 943
 
944
-            $meta[ 'parent' ] = array(
944
+            $meta['parent'] = array(
945 945
 
946 946
                 'label' => sprintf(
947
-                    __( 'Parent %s', 'invoicing' ),
948
-                    ucfirst( $invoice->get_type() )
947
+                    __('Parent %s', 'invoicing'),
948
+                    ucfirst($invoice->get_type())
949 949
                 ),
950 950
 
951
-                'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
951
+                'value' => wpinv_invoice_link($invoice->get_parent_id()),
952 952
 
953 953
             );
954 954
 
955 955
         }
956 956
 
957
-        $subscription = wpinv_get_subscription( $invoice );
957
+        $subscription = wpinv_get_subscription($invoice);
958 958
 
959
-        if ( ! empty ( $subscription ) ) {
959
+        if (!empty ($subscription)) {
960 960
 
961 961
             // Display the renewal date.
962
-            if ( $subscription->is_active() && 'cancelled' != $subscription->status ) {
962
+            if ($subscription->is_active() && 'cancelled' != $subscription->status) {
963 963
 
964
-                $meta[ 'renewal_date' ] = array(
964
+                $meta['renewal_date'] = array(
965 965
 
966
-                    'label' => __( 'Renews On', 'invoicing' ),
967
-                    'value' => getpaid_format_date( $subscription->expiration ),
966
+                    'label' => __('Renews On', 'invoicing'),
967
+                    'value' => getpaid_format_date($subscription->expiration),
968 968
         
969 969
                 );
970 970
 
971 971
             }
972 972
 
973
-            if ( $invoice->is_parent() ) {
973
+            if ($invoice->is_parent()) {
974 974
 
975 975
                 // Display the recurring amount.
976
-                $meta[ 'recurring_total' ] = array(
976
+                $meta['recurring_total'] = array(
977 977
 
978
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
979
-                    'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ),
978
+                    'label' => __('Recurring Amount', 'invoicing'),
979
+                    'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()),
980 980
         
981 981
                 );
982 982
 
@@ -986,20 +986,20 @@  discard block
 block discarded – undo
986 986
     }
987 987
 
988 988
     // Add the invoice total to the meta.
989
-    $meta[ 'invoice_total' ] = array(
989
+    $meta['invoice_total'] = array(
990 990
 
991
-        'label' => __( 'Total Amount', 'invoicing' ),
992
-        'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ),
991
+        'label' => __('Total Amount', 'invoicing'),
992
+        'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()),
993 993
 
994 994
     );
995 995
 
996 996
     // Provide a way for third party plugins to filter the meta.
997
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
997
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
998 998
 
999
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
999
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
1000 1000
 
1001 1001
 }
1002
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
1002
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
1003 1003
 
1004 1004
 /**
1005 1005
  * Retrieves the address markup to use on Invoices.
@@ -1011,29 +1011,29 @@  discard block
 block discarded – undo
1011 1011
  * @param  string $separator How to separate address lines.
1012 1012
  * @return string
1013 1013
  */
1014
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
1014
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
1015 1015
 
1016 1016
     // Retrieve the address markup...
1017
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
1018
-    $format = wpinv_get_full_address_format( $country );
1017
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
1018
+    $format = wpinv_get_full_address_format($country);
1019 1019
 
1020 1020
     // ... and the replacements.
1021
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
1021
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
1022 1022
 
1023
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
1023
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
1024 1024
     
1025 1025
 	// Remove unavailable tags.
1026
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
1026
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
1027 1027
 
1028 1028
     // Clean up white space.
1029
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
1030
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
1029
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
1030
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
1031 1031
     
1032 1032
     // Break newlines apart and remove empty lines/trim commas and white space.
1033
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
1033
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
1034 1034
 
1035 1035
     // Add html breaks.
1036
-	$formatted_address = implode( $separator, $formatted_address );
1036
+	$formatted_address = implode($separator, $formatted_address);
1037 1037
 
1038 1038
 	// We're done!
1039 1039
 	return $formatted_address;
@@ -1045,88 +1045,88 @@  discard block
 block discarded – undo
1045 1045
  * 
1046 1046
  * @param WPInv_Invoice $invoice
1047 1047
  */
1048
-function wpinv_display_to_address( $invoice = 0 ) {
1049
-    if ( ! empty( $invoice ) ) {
1050
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
1048
+function wpinv_display_to_address($invoice = 0) {
1049
+    if (!empty($invoice)) {
1050
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
1051 1051
     }
1052 1052
 }
1053
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
1053
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
1054 1054
 
1055 1055
 
1056 1056
 /**
1057 1057
  * Displays invoice line items.
1058 1058
  */
1059
-function wpinv_display_line_items( $invoice_id = 0 ) {
1059
+function wpinv_display_line_items($invoice_id = 0) {
1060 1060
 
1061 1061
     // Prepare the invoice.
1062
-    $invoice = new WPInv_Invoice( $invoice_id );
1062
+    $invoice = new WPInv_Invoice($invoice_id);
1063 1063
 
1064 1064
     // Abort if there is no invoice.
1065
-    if ( 0 == $invoice->get_id() ) {
1065
+    if (0 == $invoice->get_id()) {
1066 1066
         return;
1067 1067
     }
1068 1068
 
1069 1069
     // Line item columns.
1070
-    $columns = getpaid_invoice_item_columns( $invoice );
1071
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
1070
+    $columns = getpaid_invoice_item_columns($invoice);
1071
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
1072 1072
 
1073
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
1073
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
1074 1074
 }
1075
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
1075
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
1076 1076
 
1077 1077
 /**
1078 1078
  * Displays invoice notices on invoices.
1079 1079
  */
1080 1080
 function wpinv_display_invoice_notice() {
1081 1081
 
1082
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
1083
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
1082
+    $label  = wpinv_get_option('vat_invoice_notice_label');
1083
+    $notice = wpinv_get_option('vat_invoice_notice');
1084 1084
 
1085
-    if ( empty( $label ) && empty( $notice ) ) {
1085
+    if (empty($label) && empty($notice)) {
1086 1086
         return;
1087 1087
     }
1088 1088
 
1089 1089
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
1090 1090
 
1091
-    if ( ! empty( $label ) ) {
1092
-        $label = sanitize_text_field( $label );
1091
+    if (!empty($label)) {
1092
+        $label = sanitize_text_field($label);
1093 1093
         echo "<h5>$label</h5>";
1094 1094
     }
1095 1095
 
1096
-    if ( ! empty( $notice ) ) {
1097
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
1096
+    if (!empty($notice)) {
1097
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
1098 1098
     }
1099 1099
 
1100 1100
     echo '</div>';
1101 1101
 }
1102
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
1102
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
1103 1103
 
1104 1104
 /**
1105 1105
  * @param WPInv_Invoice $invoice
1106 1106
  */
1107
-function wpinv_display_invoice_notes( $invoice ) {
1107
+function wpinv_display_invoice_notes($invoice) {
1108 1108
 
1109 1109
     // Retrieve the notes.
1110
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
1110
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
1111 1111
 
1112 1112
     // Abort if we have non.
1113
-    if ( empty( $notes ) ) {
1113
+    if (empty($notes)) {
1114 1114
         return;
1115 1115
     }
1116 1116
 
1117 1117
     // Echo the note.
1118 1118
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
1119
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
1119
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
1120 1120
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
1121 1121
 
1122
-    foreach( $notes as $note ) {
1123
-        wpinv_get_invoice_note_line_item( $note );
1122
+    foreach ($notes as $note) {
1123
+        wpinv_get_invoice_note_line_item($note);
1124 1124
     }
1125 1125
 
1126 1126
     echo '</ul>';
1127 1127
     echo '</div>';
1128 1128
 }
1129
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
1129
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
1130 1130
 
1131 1131
 /**
1132 1132
  * Loads scripts on our invoice templates.
@@ -1134,32 +1134,32 @@  discard block
 block discarded – undo
1134 1134
 function wpinv_display_style() {
1135 1135
 
1136 1136
     // Make sure that all scripts have been loaded.
1137
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
1138
-        do_action( 'wp_enqueue_scripts' );
1137
+    if (!did_action('wp_enqueue_scripts')) {
1138
+        do_action('wp_enqueue_scripts');
1139 1139
     }
1140 1140
 
1141 1141
     // Register the invoices style.
1142
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
1142
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
1143 1143
 
1144 1144
     // Load required styles
1145
-    wp_print_styles( 'open-sans' );
1146
-    wp_print_styles( 'wpinv-single-style' );
1147
-    wp_print_styles( 'ayecode-ui' );
1145
+    wp_print_styles('open-sans');
1146
+    wp_print_styles('wpinv-single-style');
1147
+    wp_print_styles('ayecode-ui');
1148 1148
 
1149 1149
     // Maybe load custom css.
1150
-    $custom_css = wpinv_get_option( 'template_custom_css' );
1150
+    $custom_css = wpinv_get_option('template_custom_css');
1151 1151
 
1152
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
1153
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1154
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1152
+    if (isset($custom_css) && !empty($custom_css)) {
1153
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1154
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1155 1155
         echo '<style type="text/css">';
1156 1156
         echo $custom_css;
1157 1157
         echo '</style>';
1158 1158
     }
1159 1159
 
1160 1160
 }
1161
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1162
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1161
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1162
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1163 1163
 
1164 1164
 
1165 1165
 /**
@@ -1171,41 +1171,41 @@  discard block
 block discarded – undo
1171 1171
     // Retrieve the current invoice.
1172 1172
     $invoice_id = getpaid_get_current_invoice_id();
1173 1173
 
1174
-    if ( empty( $invoice_id ) ) {
1174
+    if (empty($invoice_id)) {
1175 1175
 
1176 1176
         return aui()->alert(
1177 1177
             array(
1178 1178
                 'type'    => 'warning',
1179
-                'content' => __( 'Invalid invoice', 'invoicing' ),
1179
+                'content' => __('Invalid invoice', 'invoicing'),
1180 1180
             )
1181 1181
         );
1182 1182
 
1183 1183
     }
1184 1184
 
1185 1185
     // Can the user view this invoice?
1186
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
1186
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
1187 1187
 
1188 1188
         return aui()->alert(
1189 1189
             array(
1190 1190
                 'type'    => 'warning',
1191
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1191
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1192 1192
             )
1193 1193
         );
1194 1194
 
1195 1195
     }
1196 1196
 
1197 1197
     // Ensure that it is not yet paid for.
1198
-    $invoice = new WPInv_Invoice( $invoice_id );
1198
+    $invoice = new WPInv_Invoice($invoice_id);
1199 1199
 
1200 1200
     // Maybe mark it as viewed.
1201
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1201
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1202 1202
 
1203
-    if ( $invoice->is_paid() ) {
1203
+    if ($invoice->is_paid()) {
1204 1204
 
1205 1205
         return aui()->alert(
1206 1206
             array(
1207 1207
                 'type'    => 'success',
1208
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1208
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1209 1209
             )
1210 1210
         );
1211 1211
 
@@ -1215,14 +1215,14 @@  discard block
 block discarded – undo
1215 1215
     $wpi_checkout_id = $invoice_id;
1216 1216
 
1217 1217
     // We'll display this invoice via the default form.
1218
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1218
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1219 1219
 
1220
-    if ( 0 == $form->get_id() ) {
1220
+    if (0 == $form->get_id()) {
1221 1221
 
1222 1222
         return aui()->alert(
1223 1223
             array(
1224 1224
                 'type'    => 'warning',
1225
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1225
+                'content' => __('Error loading the payment form', 'invoicing'),
1226 1226
             )
1227 1227
         );
1228 1228
 
@@ -1230,37 +1230,37 @@  discard block
 block discarded – undo
1230 1230
 
1231 1231
     // Set the invoice.
1232 1232
     $form->invoice = $invoice;
1233
-    $form->set_items( $invoice->get_items() );
1233
+    $form->set_items($invoice->get_items());
1234 1234
 
1235 1235
     // Generate the html.
1236 1236
     return $form->get_html();
1237 1237
 
1238 1238
 }
1239 1239
 
1240
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1240
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1241 1241
     global $ajax_cart_details;
1242 1242
     $ajax_cart_details = $cart_details;
1243 1243
 
1244 1244
     ob_start();
1245
-    do_action( 'wpinv_before_checkout_cart' );
1245
+    do_action('wpinv_before_checkout_cart');
1246 1246
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1247 1247
         echo '<div id="wpinv_checkout_cart_wrap">';
1248
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1248
+            wpinv_get_template_part('wpinv-checkout-cart');
1249 1249
         echo '</div>';
1250 1250
     echo '</div>';
1251
-    do_action( 'wpinv_after_checkout_cart' );
1251
+    do_action('wpinv_after_checkout_cart');
1252 1252
     $content = ob_get_clean();
1253 1253
 
1254
-    if ( $echo ) {
1254
+    if ($echo) {
1255 1255
         echo $content;
1256 1256
     } else {
1257 1257
         return $content;
1258 1258
     }
1259 1259
 }
1260
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1260
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1261 1261
 
1262 1262
 function wpinv_empty_cart_message() {
1263
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1263
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1264 1264
 }
1265 1265
 
1266 1266
 /**
@@ -1277,51 +1277,51 @@  discard block
 block discarded – undo
1277 1277
         )
1278 1278
     );
1279 1279
 }
1280
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1280
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1281 1281
 
1282 1282
 function wpinv_checkout_cart_columns() {
1283 1283
     $default = 3;
1284
-    if ( wpinv_item_quantities_enabled() ) {
1284
+    if (wpinv_item_quantities_enabled()) {
1285 1285
         $default++;
1286 1286
     }
1287 1287
 
1288
-    if ( wpinv_use_taxes() ) {
1288
+    if (wpinv_use_taxes()) {
1289 1289
         $default++;
1290 1290
     }
1291 1291
 
1292
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1292
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1293 1293
 }
1294 1294
 
1295
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1296
-    $invoice = wpinv_get_invoice( $invoice_id );
1295
+function wpinv_receipt_billing_address($invoice_id = 0) {
1296
+    $invoice = wpinv_get_invoice($invoice_id);
1297 1297
 
1298
-    if ( empty( $invoice ) ) {
1298
+    if (empty($invoice)) {
1299 1299
         return NULL;
1300 1300
     }
1301 1301
 
1302 1302
     $billing_details = $invoice->get_user_info();
1303
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1303
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1304 1304
 
1305 1305
     ob_start();
1306 1306
     ?>
1307 1307
     <table class="table table-bordered table-sm wpi-billing-details">
1308 1308
         <tbody>
1309 1309
             <tr class="wpi-receipt-name">
1310
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1311
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1310
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1311
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1312 1312
             </tr>
1313 1313
             <tr class="wpi-receipt-email">
1314
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1315
-                <td><?php echo $billing_details['email'] ;?></td>
1314
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1315
+                <td><?php echo $billing_details['email']; ?></td>
1316 1316
             </tr>
1317 1317
             <tr class="wpi-receipt-address">
1318
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1319
-                <td><?php echo $address_row ;?></td>
1318
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1319
+                <td><?php echo $address_row; ?></td>
1320 1320
             </tr>
1321
-            <?php if ( $billing_details['phone'] ) { ?>
1321
+            <?php if ($billing_details['phone']) { ?>
1322 1322
             <tr class="wpi-receipt-phone">
1323
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1324
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1323
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1324
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1325 1325
             </tr>
1326 1326
             <?php } ?>
1327 1327
         </tbody>
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
     <?php
1330 1330
     $output = ob_get_clean();
1331 1331
     
1332
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1332
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1333 1333
 
1334 1334
     echo $output;
1335 1335
 }
@@ -1337,56 +1337,56 @@  discard block
 block discarded – undo
1337 1337
 /**
1338 1338
  * Filters the receipt page.
1339 1339
  */
1340
-function wpinv_filter_success_page_content( $content ) {
1340
+function wpinv_filter_success_page_content($content) {
1341 1341
 
1342 1342
     // Ensure this is our page.
1343
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1343
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1344 1344
 
1345
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1346
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1345
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1346
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1347 1347
 
1348 1348
     }
1349 1349
 
1350 1350
     return $content;
1351 1351
 }
1352
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1352
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1353 1353
 
1354
-function wpinv_invoice_link( $invoice_id ) {
1355
-    $invoice = wpinv_get_invoice( $invoice_id );
1354
+function wpinv_invoice_link($invoice_id) {
1355
+    $invoice = wpinv_get_invoice($invoice_id);
1356 1356
 
1357
-    if ( empty( $invoice ) ) {
1357
+    if (empty($invoice)) {
1358 1358
         return NULL;
1359 1359
     }
1360 1360
 
1361
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1361
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1362 1362
 
1363
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1363
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1364 1364
 }
1365 1365
 
1366
-function wpinv_invoice_subscription_details( $invoice ) {
1367
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1368
-        $subscription = wpinv_get_subscription( $invoice, true );
1366
+function wpinv_invoice_subscription_details($invoice) {
1367
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1368
+        $subscription = wpinv_get_subscription($invoice, true);
1369 1369
 
1370
-        if ( empty( $subscription ) ) {
1370
+        if (empty($subscription)) {
1371 1371
             return;
1372 1372
         }
1373 1373
 
1374 1374
         $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
1375
-        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency() ) . ' / ' . $frequency;
1376
-        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency() );
1375
+        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()) . ' / ' . $frequency;
1376
+        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency());
1377 1377
 
1378 1378
         $payments = $subscription->get_child_payments();
1379 1379
         ?>
1380 1380
         <div class="wpinv-subscriptions-details">
1381
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1381
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1382 1382
             <table class="table">
1383 1383
                 <thead>
1384 1384
                     <tr>
1385
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1386
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1387
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1388
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1389
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1385
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1386
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1387
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1388
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1389
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1390 1390
                     </tr>
1391 1391
                 </thead>
1392 1392
                 <tbody>
@@ -1400,29 +1400,29 @@  discard block
 block discarded – undo
1400 1400
                 </tbody>
1401 1401
             </table>
1402 1402
         </div>
1403
-        <?php if ( !empty( $payments ) ) { ?>
1403
+        <?php if (!empty($payments)) { ?>
1404 1404
         <div class="wpinv-renewal-payments">
1405
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1405
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1406 1406
             <table class="table">
1407 1407
                 <thead>
1408 1408
                     <tr>
1409 1409
                         <th>#</th>
1410
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1411
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1412
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1410
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1411
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1412
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1413 1413
                     </tr>
1414 1414
                 </thead>
1415 1415
                 <tbody>
1416 1416
                     <?php
1417 1417
                         $i = 1;
1418
-                        foreach ( $payments as $payment ) {
1418
+                        foreach ($payments as $payment) {
1419 1419
                             $invoice_id = $payment->ID;
1420 1420
                     ?>
1421 1421
                     <tr>
1422
-                        <th scope="row"><?php echo $i;?></th>
1423
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
1422
+                        <th scope="row"><?php echo $i; ?></th>
1423
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
1424 1424
                         <td><?php echo$invoice->get_date_created(); ?></td>
1425
-                        <td class="text-right"><?php echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); ?></td>
1425
+                        <td class="text-right"><?php echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); ?></td>
1426 1426
                     </tr>
1427 1427
                     <?php $i++; } ?>
1428 1428
                 </tbody>
@@ -1432,64 +1432,64 @@  discard block
 block discarded – undo
1432 1432
         <?php
1433 1433
     }
1434 1434
 }
1435
-add_action( 'getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20 );
1435
+add_action('getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20);
1436 1436
 
1437
-function wpinv_cart_total_label( $label, $invoice ) {
1438
-    if ( empty( $invoice ) ) {
1437
+function wpinv_cart_total_label($label, $invoice) {
1438
+    if (empty($invoice)) {
1439 1439
         return $label;
1440 1440
     }
1441 1441
 
1442 1442
     $prefix_label = '';
1443
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
1444
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
1445
-    } else if ( $invoice->is_renewal() ) {
1446
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
1443
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
1444
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
1445
+    } else if ($invoice->is_renewal()) {
1446
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
1447 1447
     }
1448 1448
 
1449
-    if ( $prefix_label != '' ) {
1450
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1449
+    if ($prefix_label != '') {
1450
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1451 1451
     }
1452 1452
 
1453 1453
     return $label;
1454 1454
 }
1455
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1456
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1457
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1455
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1456
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1457
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1458 1458
 
1459
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1460
-    if ( empty( $note ) ) {
1459
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1460
+    if (empty($note)) {
1461 1461
         return NULL;
1462 1462
     }
1463 1463
 
1464
-    if ( is_int( $note ) ) {
1465
-        $note = get_comment( $note );
1464
+    if (is_int($note)) {
1465
+        $note = get_comment($note);
1466 1466
     }
1467 1467
 
1468
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1468
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1469 1469
         return NULL;
1470 1470
     }
1471 1471
 
1472
-    $note_classes   = array( 'note' );
1473
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1472
+    $note_classes   = array('note');
1473
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1474 1474
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1475
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1476
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1475
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1476
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1477 1477
 
1478 1478
     ob_start();
1479 1479
     ?>
1480
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1480
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1481 1481
         <div class="note_content bg-light border position-relative p-4">
1482 1482
 
1483
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1483
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1484 1484
 
1485
-            <?php if ( ! is_admin() ) : ?>
1485
+            <?php if (!is_admin()) : ?>
1486 1486
                 <em class="meta position-absolute form-text">
1487 1487
                     <?php
1488 1488
                         printf(
1489
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1489
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1490 1490
                             $note->comment_author,
1491
-                            date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ),
1492
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1491
+                            date_i18n(get_option('date_format'), strtotime($note->comment_date)),
1492
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1493 1493
                         );
1494 1494
                     ?>
1495 1495
                 </em>
@@ -1497,12 +1497,12 @@  discard block
 block discarded – undo
1497 1497
 
1498 1498
         </div>
1499 1499
 
1500
-        <?php if ( is_admin() ) : ?>
1500
+        <?php if (is_admin()) : ?>
1501 1501
 
1502 1502
             <p class="meta px-4 py-2">
1503
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
1504
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1505
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1503
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
1504
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1505
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1506 1506
                 <?php } ?>
1507 1507
             </p>
1508 1508
 
@@ -1511,9 +1511,9 @@  discard block
 block discarded – undo
1511 1511
     </li>
1512 1512
     <?php
1513 1513
     $note_content = ob_get_clean();
1514
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1514
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1515 1515
 
1516
-    if ( $echo ) {
1516
+    if ($echo) {
1517 1517
         echo $note_content;
1518 1518
     } else {
1519 1519
         return $note_content;
@@ -1523,36 +1523,36 @@  discard block
 block discarded – undo
1523 1523
 function wpinv_invalid_invoice_content() {
1524 1524
     global $post;
1525 1525
 
1526
-    $invoice = wpinv_get_invoice( $post->ID );
1526
+    $invoice = wpinv_get_invoice($post->ID);
1527 1527
 
1528
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1529
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1530
-        if ( is_user_logged_in() ) {
1531
-            if ( wpinv_require_login_to_checkout() ) {
1532
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1533
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1528
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1529
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1530
+        if (is_user_logged_in()) {
1531
+            if (wpinv_require_login_to_checkout()) {
1532
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1533
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1534 1534
                 }
1535 1535
             }
1536 1536
         } else {
1537
-            if ( wpinv_require_login_to_checkout() ) {
1538
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1539
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1537
+            if (wpinv_require_login_to_checkout()) {
1538
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1539
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1540 1540
                 }
1541 1541
             }
1542 1542
         }
1543 1543
     } else {
1544
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1544
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1545 1545
     }
1546 1546
     ?>
1547 1547
     <div class="row wpinv-row-invalid">
1548 1548
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1549
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1549
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1550 1550
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1551 1551
         </div>
1552 1552
     </div>
1553 1553
     <?php
1554 1554
 }
1555
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1555
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1556 1556
 
1557 1557
 /**
1558 1558
  * Function to get privacy policy text.
@@ -1561,21 +1561,21 @@  discard block
 block discarded – undo
1561 1561
  * @return string
1562 1562
  */
1563 1563
 function wpinv_get_policy_text() {
1564
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1564
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1565 1565
 
1566
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1566
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1567 1567
 
1568
-    if(!$privacy_page_id){
1569
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1568
+    if (!$privacy_page_id) {
1569
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1570 1570
     }
1571 1571
 
1572
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1572
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1573 1573
 
1574 1574
     $find_replace = array(
1575 1575
         '[wpinv_privacy_policy]' => $privacy_link,
1576 1576
     );
1577 1577
 
1578
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1578
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1579 1579
 
1580 1580
     return wp_kses_post(wpautop($privacy_text));
1581 1581
 }
@@ -1584,25 +1584,25 @@  discard block
 block discarded – undo
1584 1584
 /**
1585 1585
  * Allows the user to set their own price for an invoice item
1586 1586
  */
1587
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
1587
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
1588 1588
     
1589 1589
     //Ensure we have an item id
1590
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
1590
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
1591 1591
         return;
1592 1592
     }
1593 1593
 
1594 1594
     //Fetch the item
1595 1595
     $item_id = $cart_item['id'];
1596
-    $item    = new WPInv_Item( $item_id );
1596
+    $item    = new WPInv_Item($item_id);
1597 1597
     
1598
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
1598
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
1599 1599
         return;
1600 1600
     }
1601 1601
 
1602 1602
     //Fetch the dynamic pricing "strings"
1603
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
1604
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
1605
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
1603
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
1604
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
1605
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
1606 1606
 
1607 1607
     //Display a "name_your_price" button
1608 1608
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
     echo '<div class="name-your-price-miniform">';
1612 1612
     
1613 1613
     //Maybe display the recommended price
1614
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
1614
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
1615 1615
         $suggested_price = $item->get_the_price();
1616 1616
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
1617 1617
     }
@@ -1619,52 +1619,52 @@  discard block
 block discarded – undo
1619 1619
     //Display the update price form
1620 1620
     $symbol         = wpinv_currency_symbol();
1621 1621
     $position       = wpinv_currency_position();
1622
-    $minimum        = esc_attr( $item->get_minimum_price() );
1623
-    $price          = esc_attr( $cart_item['item_price'] );
1624
-    $update         = esc_attr__( "Update", 'invoicing' );
1622
+    $minimum        = esc_attr($item->get_minimum_price());
1623
+    $price          = esc_attr($cart_item['item_price']);
1624
+    $update         = esc_attr__("Update", 'invoicing');
1625 1625
 
1626 1626
     //Ensure it supports dynamic prici
1627
-    if( $price < $minimum ) {
1627
+    if ($price < $minimum) {
1628 1628
         $price = $minimum;
1629 1629
     }
1630 1630
 
1631 1631
     echo '<label>';
1632 1632
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
1633 1633
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
1634
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
1634
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
1635 1635
     echo "</label>";
1636 1636
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
1637 1637
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
1638 1638
 
1639 1639
     //Maybe display the minimum price
1640
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
1641
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
1640
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
1641
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
1642 1642
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
1643 1643
     }
1644 1644
 
1645 1645
     echo "</div>";
1646 1646
 
1647 1647
 }
1648
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
1648
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
1649 1649
 
1650 1650
 function wpinv_oxygen_fix_conflict() {
1651 1651
     global $ct_ignore_post_types;
1652 1652
 
1653
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1653
+    if (!is_array($ct_ignore_post_types)) {
1654 1654
         $ct_ignore_post_types = array();
1655 1655
     }
1656 1656
 
1657
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1657
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1658 1658
 
1659
-    foreach ( $post_types as $post_type ) {
1659
+    foreach ($post_types as $post_type) {
1660 1660
         $ct_ignore_post_types[] = $post_type;
1661 1661
 
1662 1662
         // Ignore post type
1663
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1663
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1664 1664
     }
1665 1665
 
1666
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1667
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1666
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1667
+    add_filter('template_include', 'wpinv_template', 999, 1);
1668 1668
 }
1669 1669
 
1670 1670
 /**
@@ -1672,10 +1672,10 @@  discard block
 block discarded – undo
1672 1672
  * 
1673 1673
  * @param GetPaid_Payment_Form $form
1674 1674
  */
1675
-function getpaid_display_payment_form( $form ) {
1675
+function getpaid_display_payment_form($form) {
1676 1676
 
1677
-    if ( is_numeric( $form ) ) {
1678
-        $form = new GetPaid_Payment_Form( $form );
1677
+    if (is_numeric($form)) {
1678
+        $form = new GetPaid_Payment_Form($form);
1679 1679
     }
1680 1680
 
1681 1681
     $form->display();
@@ -1685,124 +1685,124 @@  discard block
 block discarded – undo
1685 1685
 /**
1686 1686
  * Helper function to display a item payment form on the frontend.
1687 1687
  */
1688
-function getpaid_display_item_payment_form( $items ) {
1688
+function getpaid_display_item_payment_form($items) {
1689 1689
     global $invoicing;
1690 1690
 
1691
-    foreach ( array_keys( $items ) as $id ) {
1692
-	    if ( 'publish' != get_post_status( $id ) ) {
1693
-		    unset( $items[ $id ] );
1691
+    foreach (array_keys($items) as $id) {
1692
+	    if ('publish' != get_post_status($id)) {
1693
+		    unset($items[$id]);
1694 1694
 	    }
1695 1695
     }
1696 1696
 
1697
-    if ( empty( $items ) ) {
1697
+    if (empty($items)) {
1698 1698
 		return aui()->alert(
1699 1699
 			array(
1700 1700
 				'type'    => 'warning',
1701
-				'content' => __( 'No published items found', 'invoicing' ),
1701
+				'content' => __('No published items found', 'invoicing'),
1702 1702
 			)
1703 1703
 		);
1704 1704
     }
1705 1705
 
1706
-    $item_key = getpaid_convert_items_to_string( $items );
1706
+    $item_key = getpaid_convert_items_to_string($items);
1707 1707
 
1708 1708
     // Get the form elements and items.
1709 1709
     $form     = wpinv_get_default_payment_form();
1710
-	$elements = $invoicing->form_elements->get_form_elements( $form );
1711
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
1710
+	$elements = $invoicing->form_elements->get_form_elements($form);
1711
+	$items    = $invoicing->form_elements->convert_normal_items($items);
1712 1712
 
1713 1713
 	ob_start();
1714 1714
 	echo "<form class='wpinv_payment_form'>";
1715
-	do_action( 'wpinv_payment_form_top' );
1715
+	do_action('wpinv_payment_form_top');
1716 1716
     echo "<input type='hidden' name='form_id' value='$form'/>";
1717 1717
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
1718
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1719
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1718
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1719
+	wp_nonce_field('vat_validation', '_wpi_nonce');
1720 1720
 
1721
-	foreach ( $elements as $element ) {
1722
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
1723
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
1721
+	foreach ($elements as $element) {
1722
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
1723
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
1724 1724
 	}
1725 1725
 
1726 1726
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
1727
-	do_action( 'wpinv_payment_form_bottom' );
1727
+	do_action('wpinv_payment_form_bottom');
1728 1728
 	echo '</form>';
1729 1729
 
1730 1730
 	$content = ob_get_clean();
1731
-	return str_replace( 'sr-only', '', $content );
1731
+	return str_replace('sr-only', '', $content);
1732 1732
 }
1733 1733
 
1734 1734
 /**
1735 1735
  * Helper function to display an invoice payment form on the frontend.
1736 1736
  */
1737
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1737
+function getpaid_display_invoice_payment_form($invoice_id) {
1738 1738
     global $invoicing;
1739 1739
 
1740
-    $invoice = wpinv_get_invoice( $invoice_id );
1740
+    $invoice = wpinv_get_invoice($invoice_id);
1741 1741
 
1742
-    if ( empty( $invoice ) ) {
1742
+    if (empty($invoice)) {
1743 1743
 		return aui()->alert(
1744 1744
 			array(
1745 1745
 				'type'    => 'warning',
1746
-				'content' => __( 'Invoice not found', 'invoicing' ),
1746
+				'content' => __('Invoice not found', 'invoicing'),
1747 1747
 			)
1748 1748
 		);
1749 1749
     }
1750 1750
 
1751
-    if ( $invoice->is_paid() ) {
1751
+    if ($invoice->is_paid()) {
1752 1752
 		return aui()->alert(
1753 1753
 			array(
1754 1754
 				'type'    => 'warning',
1755
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1755
+				'content' => __('Invoice has already been paid', 'invoicing'),
1756 1756
 			)
1757 1757
 		);
1758 1758
     }
1759 1759
 
1760 1760
     // Get the form elements and items.
1761
-    $form     = wpinv_get_default_payment_form();
1762
-	$elements = $invoicing->form_elements->get_form_elements( $form );
1763
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
1761
+    $form = wpinv_get_default_payment_form();
1762
+	$elements = $invoicing->form_elements->get_form_elements($form);
1763
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
1764 1764
 
1765 1765
 	ob_start();
1766 1766
 	echo "<form class='wpinv_payment_form'>";
1767
-	do_action( 'wpinv_payment_form_top' );
1767
+	do_action('wpinv_payment_form_top');
1768 1768
     echo "<input type='hidden' name='form_id' value='$form'/>";
1769 1769
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
1770
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1771
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1770
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1771
+	wp_nonce_field('vat_validation', '_wpi_nonce');
1772 1772
 
1773
-	foreach ( $elements as $element ) {
1774
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
1775
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
1773
+	foreach ($elements as $element) {
1774
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
1775
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
1776 1776
 	}
1777 1777
 
1778 1778
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
1779
-	do_action( 'wpinv_payment_form_bottom' );
1779
+	do_action('wpinv_payment_form_bottom');
1780 1780
 	echo '</form>';
1781 1781
 
1782 1782
 	$content = ob_get_clean();
1783
-	return str_replace( 'sr-only', '', $content );
1783
+	return str_replace('sr-only', '', $content);
1784 1784
 }
1785 1785
 
1786 1786
 /**
1787 1787
  * Helper function to convert item string to array.
1788 1788
  */
1789
-function getpaid_convert_items_to_array( $items ) {
1790
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1789
+function getpaid_convert_items_to_array($items) {
1790
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1791 1791
     $prepared = array();
1792 1792
 
1793
-    foreach ( $items as $item ) {
1794
-        $data = array_map( 'trim', explode( '|', $item ) );
1793
+    foreach ($items as $item) {
1794
+        $data = array_map('trim', explode('|', $item));
1795 1795
 
1796
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1796
+        if (empty($data[0]) || !is_numeric($data[0])) {
1797 1797
             continue;
1798 1798
         }
1799 1799
 
1800 1800
         $quantity = 1;
1801
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1801
+        if (isset($data[1]) && is_numeric($data[1])) {
1802 1802
             $quantity = $data[1];
1803 1803
         }
1804 1804
 
1805
-        $prepared[ $data[0] ] = $quantity;
1805
+        $prepared[$data[0]] = $quantity;
1806 1806
 
1807 1807
     }
1808 1808
 
@@ -1812,13 +1812,13 @@  discard block
 block discarded – undo
1812 1812
 /**
1813 1813
  * Helper function to convert item array to string.
1814 1814
  */
1815
-function getpaid_convert_items_to_string( $items ) {
1815
+function getpaid_convert_items_to_string($items) {
1816 1816
     $prepared = array();
1817 1817
 
1818
-    foreach ( $items as $item => $quantity ) {
1818
+    foreach ($items as $item => $quantity) {
1819 1819
         $prepared[] = "$item|$quantity";
1820 1820
     }
1821
-    return implode( ',', $prepared );
1821
+    return implode(',', $prepared);
1822 1822
 }
1823 1823
 
1824 1824
 /**
@@ -1826,22 +1826,22 @@  discard block
 block discarded – undo
1826 1826
  * 
1827 1827
  * Provide a label and one of $form, $items or $invoice.
1828 1828
  */
1829
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1830
-    $label = sanitize_text_field( $label );
1829
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1830
+    $label = sanitize_text_field($label);
1831 1831
     $nonce = wp_create_nonce('getpaid_ajax_form');
1832 1832
 
1833
-    if ( ! empty( $form ) ) {
1834
-        $form  = esc_attr( $form );
1833
+    if (!empty($form)) {
1834
+        $form = esc_attr($form);
1835 1835
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
1836 1836
     }
1837 1837
 	
1838
-	if ( ! empty( $items ) ) {
1839
-        $items  = esc_attr( $items );
1838
+	if (!empty($items)) {
1839
+        $items = esc_attr($items);
1840 1840
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
1841 1841
     }
1842 1842
     
1843
-    if ( ! empty( $invoice ) ) {
1844
-        $invoice  = esc_attr( $invoice );
1843
+    if (!empty($invoice)) {
1844
+        $invoice = esc_attr($invoice);
1845 1845
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
1846 1846
     }
1847 1847
 
@@ -1852,17 +1852,17 @@  discard block
 block discarded – undo
1852 1852
  *
1853 1853
  * @param WPInv_Invoice $invoice
1854 1854
  */
1855
-function getpaid_the_invoice_description( $invoice ) {
1855
+function getpaid_the_invoice_description($invoice) {
1856 1856
     $description = $invoice->get_description();
1857 1857
 
1858
-    if ( empty( $description ) ) {
1858
+    if (empty($description)) {
1859 1859
         return;
1860 1860
     }
1861 1861
 
1862
-    $description = wp_kses_post( $description );
1862
+    $description = wp_kses_post($description);
1863 1863
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1864 1864
 }
1865
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1865
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1866 1866
 
1867 1867
 /**
1868 1868
  * Render element on a form.
@@ -1870,41 +1870,41 @@  discard block
 block discarded – undo
1870 1870
  * @param array $element
1871 1871
  * @param GetPaid_Payment_Form $form
1872 1872
  */
1873
-function getpaid_payment_form_element( $element, $form ) {
1873
+function getpaid_payment_form_element($element, $form) {
1874 1874
 
1875 1875
     // Set up the args.
1876
-    $element_type    = trim( $element['type'] );
1876
+    $element_type    = trim($element['type']);
1877 1877
     $element['form'] = $form;
1878
-    extract( $element );
1878
+    extract($element);
1879 1879
 
1880 1880
     // Try to locate the appropriate template.
1881
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1881
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1882 1882
     
1883 1883
     // Abort if this is not our element.
1884
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1884
+    if (empty($located) || !file_exists($located)) {
1885 1885
         return;
1886 1886
     }
1887 1887
 
1888 1888
     // Generate the class and id of the element.
1889
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1890
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1889
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1890
+    $id            = isset($id) ? $id : uniqid('gp');
1891 1891
 
1892 1892
     // Echo the opening wrapper.
1893 1893
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1894 1894
 
1895 1895
     // Fires before displaying a given element type's content.
1896
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1896
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1897 1897
 
1898 1898
     // Include the template for the element.
1899 1899
     include $located;
1900 1900
 
1901 1901
     // Fires after displaying a given element type's content.
1902
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1902
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1903 1903
 
1904 1904
     // Echo the closing wrapper.
1905 1905
     echo '</div>';
1906 1906
 }
1907
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1907
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1908 1908
 
1909 1909
 /**
1910 1910
  * Shows a list of gateways that support recurring payments.
@@ -1912,16 +1912,16 @@  discard block
 block discarded – undo
1912 1912
 function wpinv_get_recurring_gateways_text() {
1913 1913
     $gateways = array();
1914 1914
 
1915
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1916
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1917
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1915
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1916
+        if (wpinv_gateway_support_subscription($key)) {
1917
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1918 1918
         }
1919 1919
     }
1920 1920
 
1921
-    if ( empty( $gateways ) ) {
1922
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1921
+    if (empty($gateways)) {
1922
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1923 1923
     }
1924 1924
 
1925
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1925
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1926 1926
 
1927 1927
 }
Please login to merge, or discard this patch.
includes/class-getpaid-payment-form-submission.php 2 patches
Indentation   +812 added lines, -812 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,890 +10,890 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form_Submission {
11 11
 
12 12
     /**
13
-	 * Submission ID
14
-	 *
15
-	 * @var string
16
-	 */
17
-	public $id = null;
13
+     * Submission ID
14
+     *
15
+     * @var string
16
+     */
17
+    public $id = null;
18 18
 
19
-	/**
20
-	 * Sets the associated payment form.
21
-	 *
22
-	 * @var GetPaid_Payment_Form
23
-	 */
19
+    /**
20
+     * Sets the associated payment form.
21
+     *
22
+     * @var GetPaid_Payment_Form
23
+     */
24 24
     protected $payment_form = null;
25 25
 
26 26
     /**
27
-	 * The country for the submission.
28
-	 *
29
-	 * @var string
30
-	 */
31
-	public $country = null;
32
-
33
-    /**
34
-	 * The state for the submission.
35
-	 *
36
-	 * @since 1.0.19
37
-	 * @var string
38
-	 */
39
-	public $state = null;
40
-
41
-	/**
42
-	 * The invoice associated with the submission.
43
-	 *
44
-	 * @var WPInv_Invoice
45
-	 */
46
-	protected $invoice = null;
47
-
48
-	/**
49
-	 * The discount associated with the submission.
50
-	 *
51
-	 * @var WPInv_Discount
52
-	 */
53
-	protected $discount = null;
54
-
55
-	/**
56
-	 * The raw submission data.
57
-	 *
58
-	 * @var array
59
-	 */
60
-	protected $data = null;
61
-
62
-	/**
63
-	 * Whether this submission contains a recurring item.
64
-	 *
65
-	 * @var bool
66
-	 */
67
-	public $has_recurring = false;
68
-
69
-	/**
70
-	 * The sub total amount for the submission.
71
-	 *
72
-	 * @var float
73
-	 */
74
-	public $subtotal_amount = 0;
75
-
76
-	/**
77
-	 * The total discount amount for the submission.
78
-	 *
79
-	 * @var float
80
-	 */
81
-	protected $total_discount_amount = 0;
82
-
83
-	/**
84
-	 * The total tax amount for the submission.
85
-	 *
86
-	 * @var float
87
-	 */
88
-	protected $total_tax_amount = 0;
89
-
90
-	/**
91
-	 * The total fees amount for the submission.
92
-	 *
93
-	 * @var float
94
-	 */
95
-	protected $total_fees_amount = 0;
96
-
97
-	/**
98
-	 * An array of fees for the submission.
99
-	 *
100
-	 * @var array
101
-	 */
102
-	protected $fees = array();
103
-
104
-	/**
105
-	 * An array of discounts for the submission.
106
-	 *
107
-	 * @var array
108
-	 */
109
-	protected $discounts = array();
110
-
111
-	/**
112
-	 * An array of taxes for the submission.
113
-	 *
114
-	 * @var array
115
-	 */
116
-	protected $taxes = array();
117
-
118
-	/**
119
-	 * An array of items for the submission.
120
-	 *
121
-	 * @var GetPaid_Form_Item[]
122
-	 */
123
-	protected $items = array();
124
-
125
-	/**
126
-	 * The last error.
127
-	 *
128
-	 * @var string
129
-	 */
130
-	public $last_error = null;
131
-
132
-	/**
133
-	 * Is the discount valid?
134
-	 *
135
-	 * @var bool
136
-	 */
137
-	public $is_discount_valid = true;
27
+     * The country for the submission.
28
+     *
29
+     * @var string
30
+     */
31
+    public $country = null;
32
+
33
+    /**
34
+     * The state for the submission.
35
+     *
36
+     * @since 1.0.19
37
+     * @var string
38
+     */
39
+    public $state = null;
40
+
41
+    /**
42
+     * The invoice associated with the submission.
43
+     *
44
+     * @var WPInv_Invoice
45
+     */
46
+    protected $invoice = null;
47
+
48
+    /**
49
+     * The discount associated with the submission.
50
+     *
51
+     * @var WPInv_Discount
52
+     */
53
+    protected $discount = null;
54
+
55
+    /**
56
+     * The raw submission data.
57
+     *
58
+     * @var array
59
+     */
60
+    protected $data = null;
61
+
62
+    /**
63
+     * Whether this submission contains a recurring item.
64
+     *
65
+     * @var bool
66
+     */
67
+    public $has_recurring = false;
68
+
69
+    /**
70
+     * The sub total amount for the submission.
71
+     *
72
+     * @var float
73
+     */
74
+    public $subtotal_amount = 0;
75
+
76
+    /**
77
+     * The total discount amount for the submission.
78
+     *
79
+     * @var float
80
+     */
81
+    protected $total_discount_amount = 0;
82
+
83
+    /**
84
+     * The total tax amount for the submission.
85
+     *
86
+     * @var float
87
+     */
88
+    protected $total_tax_amount = 0;
89
+
90
+    /**
91
+     * The total fees amount for the submission.
92
+     *
93
+     * @var float
94
+     */
95
+    protected $total_fees_amount = 0;
96
+
97
+    /**
98
+     * An array of fees for the submission.
99
+     *
100
+     * @var array
101
+     */
102
+    protected $fees = array();
103
+
104
+    /**
105
+     * An array of discounts for the submission.
106
+     *
107
+     * @var array
108
+     */
109
+    protected $discounts = array();
110
+
111
+    /**
112
+     * An array of taxes for the submission.
113
+     *
114
+     * @var array
115
+     */
116
+    protected $taxes = array();
117
+
118
+    /**
119
+     * An array of items for the submission.
120
+     *
121
+     * @var GetPaid_Form_Item[]
122
+     */
123
+    protected $items = array();
124
+
125
+    /**
126
+     * The last error.
127
+     *
128
+     * @var string
129
+     */
130
+    public $last_error = null;
131
+
132
+    /**
133
+     * Is the discount valid?
134
+     *
135
+     * @var bool
136
+     */
137
+    public $is_discount_valid = true;
138 138
 	
139
-	/**
140
-	 * Checks if we have a digital vat rule.
141
-	 *
142
-	 * @var bool
143
-	 */
144
-	public $has_digital = false;
139
+    /**
140
+     * Checks if we have a digital vat rule.
141
+     *
142
+     * @var bool
143
+     */
144
+    public $has_digital = false;
145 145
 	
146
-	/**
147
-	 * Checks if we require vat.
148
-	 *
149
-	 * @var bool
150
-	 */
146
+    /**
147
+     * Checks if we require vat.
148
+     *
149
+     * @var bool
150
+     */
151 151
     public $requires_vat = false;
152 152
 
153 153
     /**
154
-	 * Class constructor.
155
-	 *
156
-	 */
157
-	public function __construct() {
158
-
159
-		// Set the state and country to the default state and country.
160
-		$this->country = wpinv_default_billing_country();
161
-		$this->state = wpinv_get_default_state();
162
-
163
-		// Do we have an actual submission?
164
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
-			$this->load_data( $_POST );
166
-		}
167
-	}
154
+     * Class constructor.
155
+     *
156
+     */
157
+    public function __construct() {
158
+
159
+        // Set the state and country to the default state and country.
160
+        $this->country = wpinv_default_billing_country();
161
+        $this->state = wpinv_get_default_state();
162
+
163
+        // Do we have an actual submission?
164
+        if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
+            $this->load_data( $_POST );
166
+        }
167
+    }
168 168
 
169
-	/**
170
-	 * Loads submission data.
171
-	 *
172
-	 * @param array $data
173
-	 */
174
-	public function load_data( $data ) {
169
+    /**
170
+     * Loads submission data.
171
+     *
172
+     * @param array $data
173
+     */
174
+    public function load_data( $data ) {
175 175
 
176
-		// Prepare submitted data...
177
-		$data = wp_unslash( $data );
176
+        // Prepare submitted data...
177
+        $data = wp_unslash( $data );
178 178
 
179
-		// Filter the data.
180
-		$data = apply_filters( 'getpaid_submission_data', $data, $this );
179
+        // Filter the data.
180
+        $data = apply_filters( 'getpaid_submission_data', $data, $this );
181 181
 
182
-		$this->data = $data;
182
+        $this->data = $data;
183 183
 
184
-		$this->id = md5( wp_json_encode( $data ) );
184
+        $this->id = md5( wp_json_encode( $data ) );
185 185
 
186
-		// Every submission needs an active payment form.
187
-		if ( empty( $data['form_id'] ) ) {
188
-			$this->last_error = __( 'Missing payment form', 'invoicing' );
186
+        // Every submission needs an active payment form.
187
+        if ( empty( $data['form_id'] ) ) {
188
+            $this->last_error = __( 'Missing payment form', 'invoicing' );
189 189
             return;
190
-		}
190
+        }
191 191
 
192
-		// Fetch the payment form.
193
-		$form = new GetPaid_Payment_Form( $data['form_id'] );
192
+        // Fetch the payment form.
193
+        $form = new GetPaid_Payment_Form( $data['form_id'] );
194 194
 
195
-		if ( ! $form->is_active() ) {
196
-			$this->last_error = __( 'Payment form not active', 'invoicing' );
197
-			return;
198
-		}
195
+        if ( ! $form->is_active() ) {
196
+            $this->last_error = __( 'Payment form not active', 'invoicing' );
197
+            return;
198
+        }
199 199
 
200
-		// Fetch the payment form.
201
-		$this->payment_form = $form;
200
+        // Fetch the payment form.
201
+        $this->payment_form = $form;
202 202
 
203
-		// For existing invoices, make sure that it is valid.
203
+        // For existing invoices, make sure that it is valid.
204 204
         if ( ! empty( $data['invoice_id'] ) ) {
205 205
             $invoice = wpinv_get_invoice( $data['invoice_id'] );
206 206
 
207 207
             if ( empty( $invoice ) ) {
208
-				$this->last_error = __( 'Invalid invoice', 'invoicing' );
208
+                $this->last_error = __( 'Invalid invoice', 'invoicing' );
209 209
                 return;
210
-			}
210
+            }
211 211
 			
212
-			if ( $invoice->is_paid() ) {
213
-				$this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
212
+            if ( $invoice->is_paid() ) {
213
+                $this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
214 214
                 return;
215
-			}
215
+            }
216 216
 
217
-			$this->payment_form->set_items( $invoice->get_items() );
217
+            $this->payment_form->set_items( $invoice->get_items() );
218 218
 
219
-			$this->country = $invoice->get_country();
220
-			$this->state = $invoice->get_state();
219
+            $this->country = $invoice->get_country();
220
+            $this->state = $invoice->get_state();
221 221
 
222
-		// Default forms do not have items.
222
+        // Default forms do not have items.
223 223
         } else if ( $form->is_default() && isset( $data['form_items'] ) ) {
224
-			$this->payment_form->set_items( $data['form_items'] );
225
-		}
226
-
227
-		// User's country.
228
-		if ( ! empty( $data['wpinv_country'] ) ) {
229
-			$this->country = $data['wpinv_country'];
230
-		}
231
-
232
-		// User's state.
233
-		if ( ! empty( $data['wpinv_state'] ) ) {
234
-			$this->country = $data['wpinv_state'];
235
-		}
236
-
237
-		// Handle discounts.
238
-		$this->maybe_prepare_discount();
239
-
240
-		// Handle items.
241
-		$selected_items = array();
242
-		if ( ! empty( $data['getpaid-items'] ) ) {
243
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
244
-		}
245
-
246
-		foreach ( $this->payment_form->get_items() as $item ) {
247
-
248
-			// Continue if this is an optional item and it has not been selected.
249
-			if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
250
-				continue;
251
-			}
252
-
253
-			// (maybe) let customers change the quantities and prices.
254
-			if ( isset( $selected_items[ $item->get_id() ] ) ) {
255
-
256
-				// Maybe change the quantities.
257
-				if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
258
-					$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
259
-				}
260
-
261
-				// Maybe change the price.
262
-				if ( $item->user_can_set_their_price() ) {
263
-					$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
264
-
265
-					// But don't get lower than the minimum price.
266
-					if ( $price < $item->get_minimum_price() ) {
267
-						$price = $item->get_minimum_price();
268
-					}
269
-
270
-					$item->set_price( $price );
271
-
272
-				}
273
-
274
-			}
275
-
276
-			// Add the item to the form.
277
-			$this->add_item( $item );
278
-
279
-		}
280
-
281
-		// (Maybe) validate vat number.
282
-		$this->maybe_validate_vat();
283
-
284
-		// Fired when we are done processing a submission.
285
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
286
-
287
-		// Remove invalid discount.
288
-		$this->maybe_remove_discount();
289
-
290
-	}
291
-
292
-    /**
293
-	 * Returns the payment form.
294
-	 *
295
-	 * @since 1.0.19
296
-	 * @return GetPaid_Payment_Form
297
-	 */
298
-	public function get_payment_form() {
299
-		return $this->payment_form;
300
-	}
301
-
302
-	/**
303
-	 * Returns the associated invoice.
304
-	 *
305
-	 * @since 1.0.19
306
-	 * @return WPInv_Invoice
307
-	 */
308
-	public function get_invoice() {
309
-		return $this->invoice;
310
-	}
311
-
312
-	/**
313
-	 * Checks whether there is an invoice associated with this submission.
314
-	 *
315
-	 * @since 1.0.19
316
-	 * @return bool
317
-	 */
318
-	public function has_invoice() {
319
-		return ! empty( $this->invoice );
320
-	}
321
-
322
-	/**
323
-	 * Retrieves the vat number.
324
-	 *
325
-	 * @since 1.0.19
326
-	 * @return string
327
-	 */
328
-	public function get_vat_number() {
329
-
330
-		// Retrieve from the posted data.
331
-		if ( ! empty( $this->data['wpinv_vat_number'] ) ) {
332
-			return wpinv_clean( $this->data['wpinv_vat_number'] );
333
-		}
334
-
335
-		// Retrieve from the invoice.
336
-		return $this->has_invoice() ? $this->invoice->get_vat_number() : '';
337
-	}
338
-
339
-	/**
340
-	 * Retrieves the company.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @return string
344
-	 */
345
-	public function get_company() {
346
-
347
-		// Retrieve from the posted data.
348
-		if ( ! empty( $this->data['wpinv_company'] ) ) {
349
-			return wpinv_clean( $this->data['wpinv_company'] );
350
-		}
351
-
352
-		// Retrieve from the invoice.
353
-		return $this->has_invoice() ? $this->invoice->get_company() : '';
354
-	}
224
+            $this->payment_form->set_items( $data['form_items'] );
225
+        }
226
+
227
+        // User's country.
228
+        if ( ! empty( $data['wpinv_country'] ) ) {
229
+            $this->country = $data['wpinv_country'];
230
+        }
231
+
232
+        // User's state.
233
+        if ( ! empty( $data['wpinv_state'] ) ) {
234
+            $this->country = $data['wpinv_state'];
235
+        }
236
+
237
+        // Handle discounts.
238
+        $this->maybe_prepare_discount();
239
+
240
+        // Handle items.
241
+        $selected_items = array();
242
+        if ( ! empty( $data['getpaid-items'] ) ) {
243
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
244
+        }
245
+
246
+        foreach ( $this->payment_form->get_items() as $item ) {
247
+
248
+            // Continue if this is an optional item and it has not been selected.
249
+            if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
250
+                continue;
251
+            }
252
+
253
+            // (maybe) let customers change the quantities and prices.
254
+            if ( isset( $selected_items[ $item->get_id() ] ) ) {
255
+
256
+                // Maybe change the quantities.
257
+                if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
258
+                    $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
259
+                }
260
+
261
+                // Maybe change the price.
262
+                if ( $item->user_can_set_their_price() ) {
263
+                    $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
264
+
265
+                    // But don't get lower than the minimum price.
266
+                    if ( $price < $item->get_minimum_price() ) {
267
+                        $price = $item->get_minimum_price();
268
+                    }
269
+
270
+                    $item->set_price( $price );
271
+
272
+                }
273
+
274
+            }
275
+
276
+            // Add the item to the form.
277
+            $this->add_item( $item );
278
+
279
+        }
280
+
281
+        // (Maybe) validate vat number.
282
+        $this->maybe_validate_vat();
283
+
284
+        // Fired when we are done processing a submission.
285
+        do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
286
+
287
+        // Remove invalid discount.
288
+        $this->maybe_remove_discount();
289
+
290
+    }
291
+
292
+    /**
293
+     * Returns the payment form.
294
+     *
295
+     * @since 1.0.19
296
+     * @return GetPaid_Payment_Form
297
+     */
298
+    public function get_payment_form() {
299
+        return $this->payment_form;
300
+    }
301
+
302
+    /**
303
+     * Returns the associated invoice.
304
+     *
305
+     * @since 1.0.19
306
+     * @return WPInv_Invoice
307
+     */
308
+    public function get_invoice() {
309
+        return $this->invoice;
310
+    }
311
+
312
+    /**
313
+     * Checks whether there is an invoice associated with this submission.
314
+     *
315
+     * @since 1.0.19
316
+     * @return bool
317
+     */
318
+    public function has_invoice() {
319
+        return ! empty( $this->invoice );
320
+    }
321
+
322
+    /**
323
+     * Retrieves the vat number.
324
+     *
325
+     * @since 1.0.19
326
+     * @return string
327
+     */
328
+    public function get_vat_number() {
329
+
330
+        // Retrieve from the posted data.
331
+        if ( ! empty( $this->data['wpinv_vat_number'] ) ) {
332
+            return wpinv_clean( $this->data['wpinv_vat_number'] );
333
+        }
334
+
335
+        // Retrieve from the invoice.
336
+        return $this->has_invoice() ? $this->invoice->get_vat_number() : '';
337
+    }
338
+
339
+    /**
340
+     * Retrieves the company.
341
+     *
342
+     * @since 1.0.19
343
+     * @return string
344
+     */
345
+    public function get_company() {
346
+
347
+        // Retrieve from the posted data.
348
+        if ( ! empty( $this->data['wpinv_company'] ) ) {
349
+            return wpinv_clean( $this->data['wpinv_company'] );
350
+        }
351
+
352
+        // Retrieve from the invoice.
353
+        return $this->has_invoice() ? $this->invoice->get_company() : '';
354
+    }
355 355
 	
356
-	/**
357
-	 * Returns the appropriate currency for the submission.
358
-	 *
359
-	 * @since 1.0.19
360
-	 * @return string
361
-	 */
362
-	public function get_currency() {
363
-		if ( $this->has_invoice() ) {
364
-			return $this->invoice->get_currency();
365
-		}
366
-		return wpinv_get_currency();
367
-    }
368
-
369
-    /**
370
-	 * Returns the raw submission data.
371
-	 *
372
-	 * @since 1.0.19
373
-	 * @return array
374
-	 */
375
-	public function get_data() {
376
-		return $this->data;
377
-	}
378
-
379
-	/**
380
-	 * Checks if a required field is set.
381
-	 *
382
-	 * @since 1.0.19
383
-	 */
384
-	public function is_required_field_set( $field ) {
385
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
386
-	}
387
-
388
-	///////// Items //////////////
389
-
390
-	/**
391
-	 * Adds an item to the submission.
392
-	 *
393
-	 * @since 1.0.19
394
-	 * @param GetPaid_Form_Item $item
395
-	 */
396
-	public function add_item( $item ) {
397
-
398
-		// Make sure that it is available for purchase.
399
-		if ( ! $item->can_purchase() ) {
400
-			return;
401
-		}
402
-
403
-		// Do we have a recurring item?
404
-		if ( $item->is_recurring() ) {
405
-
406
-			if ( $this->has_recurring ) {
407
-				$this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
408
-			}
409
-
410
-			$this->has_recurring = true;
411
-
412
-		}
413
-
414
-		$this->items[ $item->get_id() ] = $item;
415
-
416
-		$this->subtotal_amount += $item->get_sub_total();
417
-
418
-		$this->process_item_discount( $item );
419
-
420
-		$this->process_item_tax( $item );
421
-	}
422
-
423
-	/**
424
-	 * Retrieves a specific item.
425
-	 *
426
-	 * @since 1.0.19
427
-	 */
428
-	public function get_item( $item_id ) {
429
-		return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
430
-	}
431
-
432
-	/**
433
-	 * Returns all items.
434
-	 *
435
-	 * @since 1.0.19
436
-	 * @return GetPaid_Form_Item[]
437
-	 */
438
-	public function get_items() {
439
-		return $this->items;
440
-	}
441
-
442
-	///////// TAXES //////////////
443
-
444
-	/**
445
-	 * Adds a tax to the submission.
446
-	 *
447
-	 * @since 1.0.19
448
-	 */
449
-	public function add_tax( $name, $amount ) {
450
-		$amount = (float) wpinv_sanitize_amount( $amount );
451
-
452
-		$this->total_tax_amount += $amount;
453
-
454
-		if ( isset( $this->taxes[ $name ] ) ) {
455
-			$this->taxes[ $name ] += $amount;
456
-		} else {
457
-			$this->taxes[ $name ] = $amount;
458
-		}
459
-
460
-	}
461
-
462
-	/**
463
-	 * Whether or not we'll use taxes for the submission.
464
-	 *
465
-	 * @since 1.0.19
466
-	 */
467
-	public function use_taxes() {
468
-
469
-		$use_taxes = wpinv_use_taxes();
470
-
471
-		if ( $this->has_invoice() && $this->invoice->disable_taxes ) {
472
-			$use_taxes = false;
473
-		}
474
-
475
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
476
-
477
-	}
478
-
479
-	/**
480
-	 * Maybe process tax.
481
-	 *
482
-	 * @since 1.0.19 
483
-	 * @param GetPaid_Form_Item $item
484
-	 */
485
-	public function process_item_tax( $item ) {
486
-
487
-		// Abort early if we're not using taxes.
488
-		if ( ! $this->use_taxes() ) {
489
-			return;
490
-		}
491
-
492
-		$rate  = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() );
493
-		$price = $item->get_sub_total();
494
-
495
-		if ( wpinv_prices_include_tax() ) {
496
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
497
-		} else {
498
-			$item_tax = $price * $rate * 0.01;
499
-		}
500
-
501
-		$this->add_tax( 'Tax', $item_tax );
502
-
503
-	}
504
-
505
-	/**
506
-	 * Returns the total tax amount.
507
-	 *
508
-	 * @since 1.0.19
509
-	 */
510
-	public function get_total_tax() {
511
-		return $this->total_tax_amount;
512
-	}
513
-
514
-	/**
515
-	 * Retrieves a specific tax.
516
-	 *
517
-	 * @since 1.0.19
518
-	 */
519
-	public function get_tax( $name ) {
520
-		return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0;
521
-	}
522
-
523
-	/**
524
-	 * Returns all taxes.
525
-	 *
526
-	 * @since 1.0.19
527
-	 */
528
-	public function get_taxes() {
529
-		return $this->taxes;
530
-	}
531
-
532
-	///////// DISCOUNTS //////////////
533
-
534
-	/**
535
-	 * Adds a discount to the submission.
536
-	 *
537
-	 * @since 1.0.19
538
-	 */
539
-	public function add_discount( $name, $amount ) {
540
-		$amount = wpinv_sanitize_amount( $amount );
541
-
542
-		$this->total_discount_amount += $amount;
543
-
544
-		if ( isset( $this->discounts[ $name ] ) ) {
545
-			$this->discounts[ $name ] += $amount;
546
-		} else {
547
-			$this->discounts[ $name ] = $amount;
548
-		}
549
-
550
-	}
551
-
552
-	/**
553
-	 * Removes a discount from the submission.
554
-	 *
555
-	 * @since 1.0.19
556
-	 */
557
-	public function remove_discount( $name ) {
558
-
559
-		if ( isset( $this->discounts[ $name ] ) ) {
560
-			$this->total_discount_amount -= $this->discounts[ $name ];
561
-			unset( $this->discounts[ $name ] );
562
-		}
563
-
564
-	}
565
-
566
-	/**
567
-	 * Checks whether there is a discount code associated with this submission.
568
-	 *
569
-	 * @since 1.0.19
570
-	 * @return bool
571
-	 */
572
-	public function has_discount_code() {
573
-		return ! empty( $this->discount );
574
-	}
575
-
576
-	/**
577
-	 * Returns the discount code.
578
-	 *
579
-	 * @since 1.0.19
580
-	 * @return bool
581
-	 */
582
-	public function get_discount_code() {
583
-		return $this->has_discount_code() ? $this->discount->code : '';
584
-	}
585
-
586
-	/**
587
-	 * Prepares an item discount.
588
-	 *
589
-	 * @since 1.0.19
590
-	 */
591
-	public function maybe_prepare_discount() {
592
-
593
-		// Do we have a discount?
594
-		if ( empty( $this->data['discount'] ) ) {
595
-			return;
596
-		}
597
-
598
-		// Fetch the discount.
599
-		$discount = wpinv_get_discount_obj( $this->data['discount'] );
600
-
601
-		// Ensure it is active.
602
-        if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) {
603
-			$this->is_discount_valid = false;
604
-			$this->last_error = __( 'Invalid or expired discount code', 'invoicing' );
605
-			return;
606
-		}
356
+    /**
357
+     * Returns the appropriate currency for the submission.
358
+     *
359
+     * @since 1.0.19
360
+     * @return string
361
+     */
362
+    public function get_currency() {
363
+        if ( $this->has_invoice() ) {
364
+            return $this->invoice->get_currency();
365
+        }
366
+        return wpinv_get_currency();
367
+    }
368
+
369
+    /**
370
+     * Returns the raw submission data.
371
+     *
372
+     * @since 1.0.19
373
+     * @return array
374
+     */
375
+    public function get_data() {
376
+        return $this->data;
377
+    }
378
+
379
+    /**
380
+     * Checks if a required field is set.
381
+     *
382
+     * @since 1.0.19
383
+     */
384
+    public function is_required_field_set( $field ) {
385
+        return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
386
+    }
387
+
388
+    ///////// Items //////////////
389
+
390
+    /**
391
+     * Adds an item to the submission.
392
+     *
393
+     * @since 1.0.19
394
+     * @param GetPaid_Form_Item $item
395
+     */
396
+    public function add_item( $item ) {
397
+
398
+        // Make sure that it is available for purchase.
399
+        if ( ! $item->can_purchase() ) {
400
+            return;
401
+        }
402
+
403
+        // Do we have a recurring item?
404
+        if ( $item->is_recurring() ) {
405
+
406
+            if ( $this->has_recurring ) {
407
+                $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
408
+            }
409
+
410
+            $this->has_recurring = true;
411
+
412
+        }
413
+
414
+        $this->items[ $item->get_id() ] = $item;
415
+
416
+        $this->subtotal_amount += $item->get_sub_total();
417
+
418
+        $this->process_item_discount( $item );
419
+
420
+        $this->process_item_tax( $item );
421
+    }
422
+
423
+    /**
424
+     * Retrieves a specific item.
425
+     *
426
+     * @since 1.0.19
427
+     */
428
+    public function get_item( $item_id ) {
429
+        return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
430
+    }
431
+
432
+    /**
433
+     * Returns all items.
434
+     *
435
+     * @since 1.0.19
436
+     * @return GetPaid_Form_Item[]
437
+     */
438
+    public function get_items() {
439
+        return $this->items;
440
+    }
441
+
442
+    ///////// TAXES //////////////
443
+
444
+    /**
445
+     * Adds a tax to the submission.
446
+     *
447
+     * @since 1.0.19
448
+     */
449
+    public function add_tax( $name, $amount ) {
450
+        $amount = (float) wpinv_sanitize_amount( $amount );
451
+
452
+        $this->total_tax_amount += $amount;
453
+
454
+        if ( isset( $this->taxes[ $name ] ) ) {
455
+            $this->taxes[ $name ] += $amount;
456
+        } else {
457
+            $this->taxes[ $name ] = $amount;
458
+        }
459
+
460
+    }
461
+
462
+    /**
463
+     * Whether or not we'll use taxes for the submission.
464
+     *
465
+     * @since 1.0.19
466
+     */
467
+    public function use_taxes() {
607 468
 
608
-		// For single use discounts...
609
-		if ( $discount->is_single_use ) {
469
+        $use_taxes = wpinv_use_taxes();
610 470
 
611
-			if ( ! $this->has_billing_email() ) {
612
-				$this->is_discount_valid = false;
613
-				$this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' );
614
-				return;
615
-			}
471
+        if ( $this->has_invoice() && $this->invoice->disable_taxes ) {
472
+            $use_taxes = false;
473
+        }
474
+
475
+        return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
476
+
477
+    }
478
+
479
+    /**
480
+     * Maybe process tax.
481
+     *
482
+     * @since 1.0.19 
483
+     * @param GetPaid_Form_Item $item
484
+     */
485
+    public function process_item_tax( $item ) {
486
+
487
+        // Abort early if we're not using taxes.
488
+        if ( ! $this->use_taxes() ) {
489
+            return;
490
+        }
491
+
492
+        $rate  = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() );
493
+        $price = $item->get_sub_total();
494
+
495
+        if ( wpinv_prices_include_tax() ) {
496
+            $item_tax = $price - ( $price - $price * $rate * 0.01 );
497
+        } else {
498
+            $item_tax = $price * $rate * 0.01;
499
+        }
500
+
501
+        $this->add_tax( 'Tax', $item_tax );
502
+
503
+    }
504
+
505
+    /**
506
+     * Returns the total tax amount.
507
+     *
508
+     * @since 1.0.19
509
+     */
510
+    public function get_total_tax() {
511
+        return $this->total_tax_amount;
512
+    }
513
+
514
+    /**
515
+     * Retrieves a specific tax.
516
+     *
517
+     * @since 1.0.19
518
+     */
519
+    public function get_tax( $name ) {
520
+        return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0;
521
+    }
522
+
523
+    /**
524
+     * Returns all taxes.
525
+     *
526
+     * @since 1.0.19
527
+     */
528
+    public function get_taxes() {
529
+        return $this->taxes;
530
+    }
531
+
532
+    ///////// DISCOUNTS //////////////
533
+
534
+    /**
535
+     * Adds a discount to the submission.
536
+     *
537
+     * @since 1.0.19
538
+     */
539
+    public function add_discount( $name, $amount ) {
540
+        $amount = wpinv_sanitize_amount( $amount );
541
+
542
+        $this->total_discount_amount += $amount;
543
+
544
+        if ( isset( $this->discounts[ $name ] ) ) {
545
+            $this->discounts[ $name ] += $amount;
546
+        } else {
547
+            $this->discounts[ $name ] = $amount;
548
+        }
549
+
550
+    }
551
+
552
+    /**
553
+     * Removes a discount from the submission.
554
+     *
555
+     * @since 1.0.19
556
+     */
557
+    public function remove_discount( $name ) {
558
+
559
+        if ( isset( $this->discounts[ $name ] ) ) {
560
+            $this->total_discount_amount -= $this->discounts[ $name ];
561
+            unset( $this->discounts[ $name ] );
562
+        }
563
+
564
+    }
616 565
 
617
-			if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) {
618
-				$this->is_discount_valid = false;
619
-				$this->last_error = __( 'You have already used this discount', 'invoicing' );
620
-				return;
621
-			}
566
+    /**
567
+     * Checks whether there is a discount code associated with this submission.
568
+     *
569
+     * @since 1.0.19
570
+     * @return bool
571
+     */
572
+    public function has_discount_code() {
573
+        return ! empty( $this->discount );
574
+    }
622 575
 
623
-		}
576
+    /**
577
+     * Returns the discount code.
578
+     *
579
+     * @since 1.0.19
580
+     * @return bool
581
+     */
582
+    public function get_discount_code() {
583
+        return $this->has_discount_code() ? $this->discount->code : '';
584
+    }
624 585
 
625
-		// Set the discount.
626
-		$this->discount = $discount;
586
+    /**
587
+     * Prepares an item discount.
588
+     *
589
+     * @since 1.0.19
590
+     */
591
+    public function maybe_prepare_discount() {
592
+
593
+        // Do we have a discount?
594
+        if ( empty( $this->data['discount'] ) ) {
595
+            return;
596
+        }
627 597
 
628
-	}
598
+        // Fetch the discount.
599
+        $discount = wpinv_get_discount_obj( $this->data['discount'] );
629 600
 
630
-	/**
631
-	 * Removes an invalid discount code.
632
-	 *
633
-	 * @since 1.0.19
634
-	 */
635
-	public function maybe_remove_discount() {
601
+        // Ensure it is active.
602
+        if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) {
603
+            $this->is_discount_valid = false;
604
+            $this->last_error = __( 'Invalid or expired discount code', 'invoicing' );
605
+            return;
606
+        }
636 607
 
637
-		// Do we have a discount?
638
-		if ( empty( $this->has_discount_code() ) ) {
639
-			return;
640
-		}
608
+        // For single use discounts...
609
+        if ( $discount->is_single_use ) {
641 610
 
642
-		// Fetch the discount amount.
643
-		$amount = $this->get_discount( 'Discount' );
611
+            if ( ! $this->has_billing_email() ) {
612
+                $this->is_discount_valid = false;
613
+                $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' );
614
+                return;
615
+            }
644 616
 
645
-		// Abort early if this is a "zero" discount.
646
-		if ( empty( $amount ) ) {
647
-			return;
648
-		}
617
+            if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) {
618
+                $this->is_discount_valid = false;
619
+                $this->last_error = __( 'You have already used this discount', 'invoicing' );
620
+                return;
621
+            }
649 622
 
650
-		$total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
623
+        }
651 624
 
652
-		if ( ! $this->discount->is_minimum_amount_met( $total ) ) {
653
-			$this->is_discount_valid = false;
625
+        // Set the discount.
626
+        $this->discount = $discount;
627
+
628
+    }
629
+
630
+    /**
631
+     * Removes an invalid discount code.
632
+     *
633
+     * @since 1.0.19
634
+     */
635
+    public function maybe_remove_discount() {
636
+
637
+        // Do we have a discount?
638
+        if ( empty( $this->has_discount_code() ) ) {
639
+            return;
640
+        }
641
+
642
+        // Fetch the discount amount.
643
+        $amount = $this->get_discount( 'Discount' );
644
+
645
+        // Abort early if this is a "zero" discount.
646
+        if ( empty( $amount ) ) {
647
+            return;
648
+        }
649
+
650
+        $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
651
+
652
+        if ( ! $this->discount->is_minimum_amount_met( $total ) ) {
653
+            $this->is_discount_valid = false;
654 654
             $min = wpinv_price( wpinv_format_amount( $$this->discount->min_total ) );
655
-			$this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min );
655
+            $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min );
656 656
         }
657 657
 
658 658
         if ( ! $this->discount->is_maximum_amount_met( $total ) ) {
659
-			$this->is_discount_valid = false;
659
+            $this->is_discount_valid = false;
660 660
             $max = wpinv_price( wpinv_format_amount( $$this->discount->max_total ) );
661
-			$this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max );
662
-		}
663
-
664
-		if ( ! $this->is_discount_valid ) {
665
-			$this->discount = null;
666
-			$this->remove_discount( 'Discount' );
667
-		}
668
-
669
-    }
670
-
671
-	/**
672
-	 * Maybe process discount.
673
-	 *
674
-	 * @since 1.0.19
675
-	 * @param GetPaid_Form_Item $item
676
-	 */
677
-	public function process_item_discount( $item ) {
678
-
679
-		// Abort early if there is no discount.
680
-		if ( ! $this->has_discount_code() ) {
681
-			return;
682
-		}
683
-
684
-		// Ensure that it is valid for this item.
685
-		if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
686
-			return;
687
-		}
688
-
689
-		// Fetch the discounted amount.
690
-		$discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() );
691
-
692
-		$this->add_discount( 'Discount', $discount );
693
-
694
-	}
695
-
696
-	/**
697
-	 * Returns the total discount amount.
698
-	 *
699
-	 * @since 1.0.19
700
-	 */
701
-	public function get_total_discount() {
702
-		return $this->total_discount_amount;
703
-	}
704
-
705
-	/**
706
-	 * Gets a specific discount.
707
-	 *
708
-	 * @since 1.0.19
709
-	 */
710
-	public function get_discount( $name ) {
711
-		return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0;
712
-	}
713
-
714
-	/**
715
-	 * Returns all discounts.
716
-	 *
717
-	 * @since 1.0.19
718
-	 */
719
-	public function get_discounts() {
720
-		return $this->discounts;
721
-	}
722
-
723
-	///////// FEES //////////////
724
-
725
-	/**
726
-	 * Adds a fee to the submission.
727
-	 *
728
-	 * @since 1.0.19
729
-	 */
730
-	public function add_fee( $name, $amount ) {
731
-		$amount = wpinv_sanitize_amount( $amount );
732
-
733
-		$this->total_fees_amount += $amount;
734
-
735
-		if ( isset( $this->fees[ $name ] ) ) {
736
-			$this->fees[ $name ] += $amount;
737
-		} else {
738
-			$this->fees[ $name ] = $amount;
739
-		}
740
-
741
-	}
742
-
743
-	/**
744
-	 * Returns the total fees amount.
745
-	 *
746
-	 * @since 1.0.19
747
-	 */
748
-	public function get_total_fees() {
749
-		return $this->total_fees_amount;
750
-	}
751
-
752
-	/**
753
-	 * Retrieves a specific fee.
754
-	 *
755
-	 * @since 1.0.19
756
-	 */
757
-	public function get_fee( $name ) {
758
-		return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0;
759
-	}
760
-
761
-	/**
762
-	 * Returns all fees.
763
-	 *
764
-	 * @since 1.0.19
765
-	 */
766
-	public function get_fees() {
767
-		return $this->fees;
768
-	}
769
-
770
-	// MISC //
771
-
772
-	/**
773
-	 * Returns the total amount to collect for this submission.
774
-	 *
775
-	 * @since 1.0.19
776
-	 */
777
-	public function get_total() {
778
-		$total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
779
-		$total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
780
-		return wpinv_sanitize_amount( $total );
781
-	}
782
-
783
-	/**
784
-	 * Whether payment details should be collected for this submission.
785
-	 *
786
-	 * @since 1.0.19
787
-	 */
788
-	public function get_payment_details() {
789
-		$collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
790
-
791
-		if ( $this->has_recurring ) {
792
-			$collect = true;
793
-		}
794
-
795
-		$collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
796
-		return $collect;
797
-	}
798
-
799
-	/**
800
-	 * Returns the billing email of the user.
801
-	 *
802
-	 * @since 1.0.19
803
-	 */
804
-	public function get_billing_email() {
805
-		$billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
806
-		return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
807
-	}
808
-
809
-	/**
810
-	 * Checks if the submitter has a billing email.
811
-	 *
812
-	 * @since 1.0.19
813
-	 */
814
-	public function has_billing_email() {
815
-		$billing_email = $this->get_billing_email();
816
-		return ! empty( $billing_email );
817
-	}
818
-
819
-	/**
820
-	 * Validate VAT data.
821
-	 *
822
-	 * @since 1.0.19
823
-	 */
824
-	public function maybe_validate_vat() {
661
+            $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max );
662
+        }
663
+
664
+        if ( ! $this->is_discount_valid ) {
665
+            $this->discount = null;
666
+            $this->remove_discount( 'Discount' );
667
+        }
668
+
669
+    }
670
+
671
+    /**
672
+     * Maybe process discount.
673
+     *
674
+     * @since 1.0.19
675
+     * @param GetPaid_Form_Item $item
676
+     */
677
+    public function process_item_discount( $item ) {
678
+
679
+        // Abort early if there is no discount.
680
+        if ( ! $this->has_discount_code() ) {
681
+            return;
682
+        }
683
+
684
+        // Ensure that it is valid for this item.
685
+        if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
686
+            return;
687
+        }
688
+
689
+        // Fetch the discounted amount.
690
+        $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() );
691
+
692
+        $this->add_discount( 'Discount', $discount );
693
+
694
+    }
695
+
696
+    /**
697
+     * Returns the total discount amount.
698
+     *
699
+     * @since 1.0.19
700
+     */
701
+    public function get_total_discount() {
702
+        return $this->total_discount_amount;
703
+    }
704
+
705
+    /**
706
+     * Gets a specific discount.
707
+     *
708
+     * @since 1.0.19
709
+     */
710
+    public function get_discount( $name ) {
711
+        return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0;
712
+    }
713
+
714
+    /**
715
+     * Returns all discounts.
716
+     *
717
+     * @since 1.0.19
718
+     */
719
+    public function get_discounts() {
720
+        return $this->discounts;
721
+    }
722
+
723
+    ///////// FEES //////////////
724
+
725
+    /**
726
+     * Adds a fee to the submission.
727
+     *
728
+     * @since 1.0.19
729
+     */
730
+    public function add_fee( $name, $amount ) {
731
+        $amount = wpinv_sanitize_amount( $amount );
732
+
733
+        $this->total_fees_amount += $amount;
734
+
735
+        if ( isset( $this->fees[ $name ] ) ) {
736
+            $this->fees[ $name ] += $amount;
737
+        } else {
738
+            $this->fees[ $name ] = $amount;
739
+        }
740
+
741
+    }
742
+
743
+    /**
744
+     * Returns the total fees amount.
745
+     *
746
+     * @since 1.0.19
747
+     */
748
+    public function get_total_fees() {
749
+        return $this->total_fees_amount;
750
+    }
751
+
752
+    /**
753
+     * Retrieves a specific fee.
754
+     *
755
+     * @since 1.0.19
756
+     */
757
+    public function get_fee( $name ) {
758
+        return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0;
759
+    }
760
+
761
+    /**
762
+     * Returns all fees.
763
+     *
764
+     * @since 1.0.19
765
+     */
766
+    public function get_fees() {
767
+        return $this->fees;
768
+    }
769
+
770
+    // MISC //
771
+
772
+    /**
773
+     * Returns the total amount to collect for this submission.
774
+     *
775
+     * @since 1.0.19
776
+     */
777
+    public function get_total() {
778
+        $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
779
+        $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
780
+        return wpinv_sanitize_amount( $total );
781
+    }
782
+
783
+    /**
784
+     * Whether payment details should be collected for this submission.
785
+     *
786
+     * @since 1.0.19
787
+     */
788
+    public function get_payment_details() {
789
+        $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
790
+
791
+        if ( $this->has_recurring ) {
792
+            $collect = true;
793
+        }
794
+
795
+        $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
796
+        return $collect;
797
+    }
798
+
799
+    /**
800
+     * Returns the billing email of the user.
801
+     *
802
+     * @since 1.0.19
803
+     */
804
+    public function get_billing_email() {
805
+        $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
806
+        return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
807
+    }
808
+
809
+    /**
810
+     * Checks if the submitter has a billing email.
811
+     *
812
+     * @since 1.0.19
813
+     */
814
+    public function has_billing_email() {
815
+        $billing_email = $this->get_billing_email();
816
+        return ! empty( $billing_email );
817
+    }
818
+
819
+    /**
820
+     * Validate VAT data.
821
+     *
822
+     * @since 1.0.19
823
+     */
824
+    public function maybe_validate_vat() {
825 825
 		
826
-		// Make sure that taxes are enabled.
827
-		if ( ! wpinv_use_taxes() ) {
828
-			return;
829
-		}
826
+        // Make sure that taxes are enabled.
827
+        if ( ! wpinv_use_taxes() ) {
828
+            return;
829
+        }
830 830
 
831
-		// Check if we have a digital VAT rule.
832
-		$has_digital = false;
831
+        // Check if we have a digital VAT rule.
832
+        $has_digital = false;
833 833
 
834
-		foreach ( $this->get_items() as $item ) {
834
+        foreach ( $this->get_items() as $item ) {
835 835
 
836
-			if ( 'digital' == $item->get_vat_rule() ) {
837
-				$has_digital = true;
838
-				break;
839
-			}
836
+            if ( 'digital' == $item->get_vat_rule() ) {
837
+                $has_digital = true;
838
+                break;
839
+            }
840 840
 
841
-		}
841
+        }
842 842
 
843
-		$this->has_digital = $has_digital;
843
+        $this->has_digital = $has_digital;
844 844
 
845
-		// Check if we require vat.
846
-		$requires_vat = (
847
-			( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) )
848
-			|| ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) )
849
-		);
845
+        // Check if we require vat.
846
+        $requires_vat = (
847
+            ( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) )
848
+            || ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) )
849
+        );
850 850
 
851
-		$this->requires_vat = $requires_vat;
851
+        $this->requires_vat = $requires_vat;
852 852
 
853
-		// Abort if we are not calculating the taxes.
854
-		if ( ! $has_digital && ! $requires_vat ) {
853
+        // Abort if we are not calculating the taxes.
854
+        if ( ! $has_digital && ! $requires_vat ) {
855 855
             return;
856
-		}
856
+        }
857 857
 
858
-		// Prepare variables.
859
-		$vat_number = $this->get_vat_number();
860
-		$company    = $this->get_company();
861
-		$ip_country = WPInv_EUVat::get_country_by_ip();
858
+        // Prepare variables.
859
+        $vat_number = $this->get_vat_number();
860
+        $company    = $this->get_company();
861
+        $ip_country = WPInv_EUVat::get_country_by_ip();
862 862
         $is_eu      = getpaid_is_eu_state( $this->country );
863 863
         $is_ip_eu   = getpaid_is_eu_state( $ip_country );
864
-		$is_non_eu  = ! $is_eu && ! $is_ip_eu;
865
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
864
+        $is_non_eu  = ! $is_eu && ! $is_ip_eu;
865
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
866 866
 
867
-		// If we're preventing business to consumer purchases...
868
-		if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) {
867
+        // If we're preventing business to consumer purchases...
868
+        if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) {
869 869
 
870 870
             if ( $is_eu ) {
871
-				$this->last_error = wp_sprintf(
872
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
873
-					getpaid_vat_name()
874
-				);
871
+                $this->last_error = wp_sprintf(
872
+                    __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
873
+                    getpaid_vat_name()
874
+                );
875 875
             } else if ( $has_digital && $is_ip_eu ) {
876 876
 
877
-				$this->last_error = wp_sprintf(
878
-					__( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ),
879
-					getpaid_vat_name()
880
-				);
877
+                $this->last_error = wp_sprintf(
878
+                    __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ),
879
+                    getpaid_vat_name()
880
+                );
881 881
 
882
-			}
882
+            }
883 883
 
884
-		}
884
+        }
885 885
 		
886
-		// Abort if we are not validating vat.
887
-		if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) {
886
+        // Abort if we are not validating vat.
887
+        if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) {
888 888
             return;
889
-		}
889
+        }
890 890
 
891
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country );
891
+        $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country );
892 892
 
893
-		if ( is_string( $is_valid ) ) {
894
-			$this->last_error = $is_valid;
895
-		}
893
+        if ( is_string( $is_valid ) ) {
894
+            $this->last_error = $is_valid;
895
+        }
896 896
 
897
-	}
897
+    }
898 898
 
899 899
 }
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 		$this->state = wpinv_get_default_state();
162 162
 
163 163
 		// Do we have an actual submission?
164
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
-			$this->load_data( $_POST );
164
+		if (isset($_POST['getpaid_payment_form_submission'])) {
165
+			$this->load_data($_POST);
166 166
 		}
167 167
 	}
168 168
 
@@ -171,29 +171,29 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @param array $data
173 173
 	 */
174
-	public function load_data( $data ) {
174
+	public function load_data($data) {
175 175
 
176 176
 		// Prepare submitted data...
177
-		$data = wp_unslash( $data );
177
+		$data = wp_unslash($data);
178 178
 
179 179
 		// Filter the data.
180
-		$data = apply_filters( 'getpaid_submission_data', $data, $this );
180
+		$data = apply_filters('getpaid_submission_data', $data, $this);
181 181
 
182 182
 		$this->data = $data;
183 183
 
184
-		$this->id = md5( wp_json_encode( $data ) );
184
+		$this->id = md5(wp_json_encode($data));
185 185
 
186 186
 		// Every submission needs an active payment form.
187
-		if ( empty( $data['form_id'] ) ) {
188
-			$this->last_error = __( 'Missing payment form', 'invoicing' );
187
+		if (empty($data['form_id'])) {
188
+			$this->last_error = __('Missing payment form', 'invoicing');
189 189
             return;
190 190
 		}
191 191
 
192 192
 		// Fetch the payment form.
193
-		$form = new GetPaid_Payment_Form( $data['form_id'] );
193
+		$form = new GetPaid_Payment_Form($data['form_id']);
194 194
 
195
-		if ( ! $form->is_active() ) {
196
-			$this->last_error = __( 'Payment form not active', 'invoicing' );
195
+		if (!$form->is_active()) {
196
+			$this->last_error = __('Payment form not active', 'invoicing');
197 197
 			return;
198 198
 		}
199 199
 
@@ -201,36 +201,36 @@  discard block
 block discarded – undo
201 201
 		$this->payment_form = $form;
202 202
 
203 203
 		// For existing invoices, make sure that it is valid.
204
-        if ( ! empty( $data['invoice_id'] ) ) {
205
-            $invoice = wpinv_get_invoice( $data['invoice_id'] );
204
+        if (!empty($data['invoice_id'])) {
205
+            $invoice = wpinv_get_invoice($data['invoice_id']);
206 206
 
207
-            if ( empty( $invoice ) ) {
208
-				$this->last_error = __( 'Invalid invoice', 'invoicing' );
207
+            if (empty($invoice)) {
208
+				$this->last_error = __('Invalid invoice', 'invoicing');
209 209
                 return;
210 210
 			}
211 211
 			
212
-			if ( $invoice->is_paid() ) {
213
-				$this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
212
+			if ($invoice->is_paid()) {
213
+				$this->last_error = __('This invoice is already paid for.', 'invoicing');
214 214
                 return;
215 215
 			}
216 216
 
217
-			$this->payment_form->set_items( $invoice->get_items() );
217
+			$this->payment_form->set_items($invoice->get_items());
218 218
 
219 219
 			$this->country = $invoice->get_country();
220 220
 			$this->state = $invoice->get_state();
221 221
 
222 222
 		// Default forms do not have items.
223
-        } else if ( $form->is_default() && isset( $data['form_items'] ) ) {
224
-			$this->payment_form->set_items( $data['form_items'] );
223
+        } else if ($form->is_default() && isset($data['form_items'])) {
224
+			$this->payment_form->set_items($data['form_items']);
225 225
 		}
226 226
 
227 227
 		// User's country.
228
-		if ( ! empty( $data['wpinv_country'] ) ) {
228
+		if (!empty($data['wpinv_country'])) {
229 229
 			$this->country = $data['wpinv_country'];
230 230
 		}
231 231
 
232 232
 		// User's state.
233
-		if ( ! empty( $data['wpinv_state'] ) ) {
233
+		if (!empty($data['wpinv_state'])) {
234 234
 			$this->country = $data['wpinv_state'];
235 235
 		}
236 236
 
@@ -239,42 +239,42 @@  discard block
 block discarded – undo
239 239
 
240 240
 		// Handle items.
241 241
 		$selected_items = array();
242
-		if ( ! empty( $data['getpaid-items'] ) ) {
243
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
242
+		if (!empty($data['getpaid-items'])) {
243
+			$selected_items = wpinv_clean($data['getpaid-items']);
244 244
 		}
245 245
 
246
-		foreach ( $this->payment_form->get_items() as $item ) {
246
+		foreach ($this->payment_form->get_items() as $item) {
247 247
 
248 248
 			// Continue if this is an optional item and it has not been selected.
249
-			if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
249
+			if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
250 250
 				continue;
251 251
 			}
252 252
 
253 253
 			// (maybe) let customers change the quantities and prices.
254
-			if ( isset( $selected_items[ $item->get_id() ] ) ) {
254
+			if (isset($selected_items[$item->get_id()])) {
255 255
 
256 256
 				// Maybe change the quantities.
257
-				if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
258
-					$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
257
+				if ($item->allows_quantities() && is_numeric($selected_items[$item->get_id()]['quantity'])) {
258
+					$item->set_quantity((int) $selected_items[$item->get_id()]['quantity']);
259 259
 				}
260 260
 
261 261
 				// Maybe change the price.
262
-				if ( $item->user_can_set_their_price() ) {
263
-					$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
262
+				if ($item->user_can_set_their_price()) {
263
+					$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
264 264
 
265 265
 					// But don't get lower than the minimum price.
266
-					if ( $price < $item->get_minimum_price() ) {
266
+					if ($price < $item->get_minimum_price()) {
267 267
 						$price = $item->get_minimum_price();
268 268
 					}
269 269
 
270
-					$item->set_price( $price );
270
+					$item->set_price($price);
271 271
 
272 272
 				}
273 273
 
274 274
 			}
275 275
 
276 276
 			// Add the item to the form.
277
-			$this->add_item( $item );
277
+			$this->add_item($item);
278 278
 
279 279
 		}
280 280
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		$this->maybe_validate_vat();
283 283
 
284 284
 		// Fired when we are done processing a submission.
285
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
285
+		do_action_ref_array('getpaid_process_submission', array(&$this));
286 286
 
287 287
 		// Remove invalid discount.
288 288
 		$this->maybe_remove_discount();
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @return bool
317 317
 	 */
318 318
 	public function has_invoice() {
319
-		return ! empty( $this->invoice );
319
+		return !empty($this->invoice);
320 320
 	}
321 321
 
322 322
 	/**
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	public function get_vat_number() {
329 329
 
330 330
 		// Retrieve from the posted data.
331
-		if ( ! empty( $this->data['wpinv_vat_number'] ) ) {
332
-			return wpinv_clean( $this->data['wpinv_vat_number'] );
331
+		if (!empty($this->data['wpinv_vat_number'])) {
332
+			return wpinv_clean($this->data['wpinv_vat_number']);
333 333
 		}
334 334
 
335 335
 		// Retrieve from the invoice.
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	public function get_company() {
346 346
 
347 347
 		// Retrieve from the posted data.
348
-		if ( ! empty( $this->data['wpinv_company'] ) ) {
349
-			return wpinv_clean( $this->data['wpinv_company'] );
348
+		if (!empty($this->data['wpinv_company'])) {
349
+			return wpinv_clean($this->data['wpinv_company']);
350 350
 		}
351 351
 
352 352
 		// Retrieve from the invoice.
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return string
361 361
 	 */
362 362
 	public function get_currency() {
363
-		if ( $this->has_invoice() ) {
363
+		if ($this->has_invoice()) {
364 364
 			return $this->invoice->get_currency();
365 365
 		}
366 366
 		return wpinv_get_currency();
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	 *
382 382
 	 * @since 1.0.19
383 383
 	 */
384
-	public function is_required_field_set( $field ) {
385
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
384
+	public function is_required_field_set($field) {
385
+		return empty($field['required']) || !empty($this->data[$field['id']]);
386 386
 	}
387 387
 
388 388
 	///////// Items //////////////
@@ -393,31 +393,31 @@  discard block
 block discarded – undo
393 393
 	 * @since 1.0.19
394 394
 	 * @param GetPaid_Form_Item $item
395 395
 	 */
396
-	public function add_item( $item ) {
396
+	public function add_item($item) {
397 397
 
398 398
 		// Make sure that it is available for purchase.
399
-		if ( ! $item->can_purchase() ) {
399
+		if (!$item->can_purchase()) {
400 400
 			return;
401 401
 		}
402 402
 
403 403
 		// Do we have a recurring item?
404
-		if ( $item->is_recurring() ) {
404
+		if ($item->is_recurring()) {
405 405
 
406
-			if ( $this->has_recurring ) {
407
-				$this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
406
+			if ($this->has_recurring) {
407
+				$this->last_error = __('You can only buy one recurring item at a time.', 'invoicing');
408 408
 			}
409 409
 
410 410
 			$this->has_recurring = true;
411 411
 
412 412
 		}
413 413
 
414
-		$this->items[ $item->get_id() ] = $item;
414
+		$this->items[$item->get_id()] = $item;
415 415
 
416 416
 		$this->subtotal_amount += $item->get_sub_total();
417 417
 
418
-		$this->process_item_discount( $item );
418
+		$this->process_item_discount($item);
419 419
 
420
-		$this->process_item_tax( $item );
420
+		$this->process_item_tax($item);
421 421
 	}
422 422
 
423 423
 	/**
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 *
426 426
 	 * @since 1.0.19
427 427
 	 */
428
-	public function get_item( $item_id ) {
429
-		return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
428
+	public function get_item($item_id) {
429
+		return isset($this->items[$item_id]) ? $this->items[$item_id] : null;
430 430
 	}
431 431
 
432 432
 	/**
@@ -446,15 +446,15 @@  discard block
 block discarded – undo
446 446
 	 *
447 447
 	 * @since 1.0.19
448 448
 	 */
449
-	public function add_tax( $name, $amount ) {
450
-		$amount = (float) wpinv_sanitize_amount( $amount );
449
+	public function add_tax($name, $amount) {
450
+		$amount = (float) wpinv_sanitize_amount($amount);
451 451
 
452 452
 		$this->total_tax_amount += $amount;
453 453
 
454
-		if ( isset( $this->taxes[ $name ] ) ) {
455
-			$this->taxes[ $name ] += $amount;
454
+		if (isset($this->taxes[$name])) {
455
+			$this->taxes[$name] += $amount;
456 456
 		} else {
457
-			$this->taxes[ $name ] = $amount;
457
+			$this->taxes[$name] = $amount;
458 458
 		}
459 459
 
460 460
 	}
@@ -468,11 +468,11 @@  discard block
 block discarded – undo
468 468
 
469 469
 		$use_taxes = wpinv_use_taxes();
470 470
 
471
-		if ( $this->has_invoice() && $this->invoice->disable_taxes ) {
471
+		if ($this->has_invoice() && $this->invoice->disable_taxes) {
472 472
 			$use_taxes = false;
473 473
 		}
474 474
 
475
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
475
+		return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this);
476 476
 
477 477
 	}
478 478
 
@@ -482,23 +482,23 @@  discard block
 block discarded – undo
482 482
 	 * @since 1.0.19 
483 483
 	 * @param GetPaid_Form_Item $item
484 484
 	 */
485
-	public function process_item_tax( $item ) {
485
+	public function process_item_tax($item) {
486 486
 
487 487
 		// Abort early if we're not using taxes.
488
-		if ( ! $this->use_taxes() ) {
488
+		if (!$this->use_taxes()) {
489 489
 			return;
490 490
 		}
491 491
 
492
-		$rate  = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() );
492
+		$rate  = wpinv_get_tax_rate($this->country, $this->state, $item->get_id());
493 493
 		$price = $item->get_sub_total();
494 494
 
495
-		if ( wpinv_prices_include_tax() ) {
496
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
495
+		if (wpinv_prices_include_tax()) {
496
+			$item_tax = $price - ($price - $price * $rate * 0.01);
497 497
 		} else {
498 498
 			$item_tax = $price * $rate * 0.01;
499 499
 		}
500 500
 
501
-		$this->add_tax( 'Tax', $item_tax );
501
+		$this->add_tax('Tax', $item_tax);
502 502
 
503 503
 	}
504 504
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	 *
517 517
 	 * @since 1.0.19
518 518
 	 */
519
-	public function get_tax( $name ) {
520
-		return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0;
519
+	public function get_tax($name) {
520
+		return isset($this->taxes[$name]) ? $this->taxes[$name] : 0;
521 521
 	}
522 522
 
523 523
 	/**
@@ -536,15 +536,15 @@  discard block
 block discarded – undo
536 536
 	 *
537 537
 	 * @since 1.0.19
538 538
 	 */
539
-	public function add_discount( $name, $amount ) {
540
-		$amount = wpinv_sanitize_amount( $amount );
539
+	public function add_discount($name, $amount) {
540
+		$amount = wpinv_sanitize_amount($amount);
541 541
 
542 542
 		$this->total_discount_amount += $amount;
543 543
 
544
-		if ( isset( $this->discounts[ $name ] ) ) {
545
-			$this->discounts[ $name ] += $amount;
544
+		if (isset($this->discounts[$name])) {
545
+			$this->discounts[$name] += $amount;
546 546
 		} else {
547
-			$this->discounts[ $name ] = $amount;
547
+			$this->discounts[$name] = $amount;
548 548
 		}
549 549
 
550 550
 	}
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
 	 *
555 555
 	 * @since 1.0.19
556 556
 	 */
557
-	public function remove_discount( $name ) {
557
+	public function remove_discount($name) {
558 558
 
559
-		if ( isset( $this->discounts[ $name ] ) ) {
560
-			$this->total_discount_amount -= $this->discounts[ $name ];
561
-			unset( $this->discounts[ $name ] );
559
+		if (isset($this->discounts[$name])) {
560
+			$this->total_discount_amount -= $this->discounts[$name];
561
+			unset($this->discounts[$name]);
562 562
 		}
563 563
 
564 564
 	}
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 * @return bool
571 571
 	 */
572 572
 	public function has_discount_code() {
573
-		return ! empty( $this->discount );
573
+		return !empty($this->discount);
574 574
 	}
575 575
 
576 576
 	/**
@@ -591,32 +591,32 @@  discard block
 block discarded – undo
591 591
 	public function maybe_prepare_discount() {
592 592
 
593 593
 		// Do we have a discount?
594
-		if ( empty( $this->data['discount'] ) ) {
594
+		if (empty($this->data['discount'])) {
595 595
 			return;
596 596
 		}
597 597
 
598 598
 		// Fetch the discount.
599
-		$discount = wpinv_get_discount_obj( $this->data['discount'] );
599
+		$discount = wpinv_get_discount_obj($this->data['discount']);
600 600
 
601 601
 		// Ensure it is active.
602
-        if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) {
602
+        if (!$discount->exists() || !$discount->is_active() || !$discount->has_started() || $discount->is_expired()) {
603 603
 			$this->is_discount_valid = false;
604
-			$this->last_error = __( 'Invalid or expired discount code', 'invoicing' );
604
+			$this->last_error = __('Invalid or expired discount code', 'invoicing');
605 605
 			return;
606 606
 		}
607 607
 
608 608
 		// For single use discounts...
609
-		if ( $discount->is_single_use ) {
609
+		if ($discount->is_single_use) {
610 610
 
611
-			if ( ! $this->has_billing_email() ) {
611
+			if (!$this->has_billing_email()) {
612 612
 				$this->is_discount_valid = false;
613
-				$this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' );
613
+				$this->last_error = __('You need to enter your billing email before applying this discount', 'invoicing');
614 614
 				return;
615 615
 			}
616 616
 
617
-			if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) {
617
+			if (!$discount->is_valid_for_user($this->get_billing_email())) {
618 618
 				$this->is_discount_valid = false;
619
-				$this->last_error = __( 'You have already used this discount', 'invoicing' );
619
+				$this->last_error = __('You have already used this discount', 'invoicing');
620 620
 				return;
621 621
 			}
622 622
 
@@ -635,35 +635,35 @@  discard block
 block discarded – undo
635 635
 	public function maybe_remove_discount() {
636 636
 
637 637
 		// Do we have a discount?
638
-		if ( empty( $this->has_discount_code() ) ) {
638
+		if (empty($this->has_discount_code())) {
639 639
 			return;
640 640
 		}
641 641
 
642 642
 		// Fetch the discount amount.
643
-		$amount = $this->get_discount( 'Discount' );
643
+		$amount = $this->get_discount('Discount');
644 644
 
645 645
 		// Abort early if this is a "zero" discount.
646
-		if ( empty( $amount ) ) {
646
+		if (empty($amount)) {
647 647
 			return;
648 648
 		}
649 649
 
650 650
 		$total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
651 651
 
652
-		if ( ! $this->discount->is_minimum_amount_met( $total ) ) {
652
+		if (!$this->discount->is_minimum_amount_met($total)) {
653 653
 			$this->is_discount_valid = false;
654
-            $min = wpinv_price( wpinv_format_amount( $$this->discount->min_total ) );
655
-			$this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min );
654
+            $min = wpinv_price(wpinv_format_amount($$this->discount->min_total));
655
+			$this->last_error = sprintf(__('The minimum total for using this discount is %s', 'invoicing'), $min);
656 656
         }
657 657
 
658
-        if ( ! $this->discount->is_maximum_amount_met( $total ) ) {
658
+        if (!$this->discount->is_maximum_amount_met($total)) {
659 659
 			$this->is_discount_valid = false;
660
-            $max = wpinv_price( wpinv_format_amount( $$this->discount->max_total ) );
661
-			$this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max );
660
+            $max = wpinv_price(wpinv_format_amount($$this->discount->max_total));
661
+			$this->last_error = sprintf(__('The maximum total for using this discount is %s', 'invoicing'), $max);
662 662
 		}
663 663
 
664
-		if ( ! $this->is_discount_valid ) {
664
+		if (!$this->is_discount_valid) {
665 665
 			$this->discount = null;
666
-			$this->remove_discount( 'Discount' );
666
+			$this->remove_discount('Discount');
667 667
 		}
668 668
 
669 669
     }
@@ -674,22 +674,22 @@  discard block
 block discarded – undo
674 674
 	 * @since 1.0.19
675 675
 	 * @param GetPaid_Form_Item $item
676 676
 	 */
677
-	public function process_item_discount( $item ) {
677
+	public function process_item_discount($item) {
678 678
 
679 679
 		// Abort early if there is no discount.
680
-		if ( ! $this->has_discount_code() ) {
680
+		if (!$this->has_discount_code()) {
681 681
 			return;
682 682
 		}
683 683
 
684 684
 		// Ensure that it is valid for this item.
685
-		if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
685
+		if (!$this->discount->is_valid_for_items(array($item->get_id()))) {
686 686
 			return;
687 687
 		}
688 688
 
689 689
 		// Fetch the discounted amount.
690
-		$discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() );
690
+		$discount = $this->discount->get_discounted_amount($item->get_price() * $item->get_quantity());
691 691
 
692
-		$this->add_discount( 'Discount', $discount );
692
+		$this->add_discount('Discount', $discount);
693 693
 
694 694
 	}
695 695
 
@@ -707,8 +707,8 @@  discard block
 block discarded – undo
707 707
 	 *
708 708
 	 * @since 1.0.19
709 709
 	 */
710
-	public function get_discount( $name ) {
711
-		return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0;
710
+	public function get_discount($name) {
711
+		return isset($this->discounts[$name]) ? $this->discounts[$name] : 0;
712 712
 	}
713 713
 
714 714
 	/**
@@ -727,15 +727,15 @@  discard block
 block discarded – undo
727 727
 	 *
728 728
 	 * @since 1.0.19
729 729
 	 */
730
-	public function add_fee( $name, $amount ) {
731
-		$amount = wpinv_sanitize_amount( $amount );
730
+	public function add_fee($name, $amount) {
731
+		$amount = wpinv_sanitize_amount($amount);
732 732
 
733 733
 		$this->total_fees_amount += $amount;
734 734
 
735
-		if ( isset( $this->fees[ $name ] ) ) {
736
-			$this->fees[ $name ] += $amount;
735
+		if (isset($this->fees[$name])) {
736
+			$this->fees[$name] += $amount;
737 737
 		} else {
738
-			$this->fees[ $name ] = $amount;
738
+			$this->fees[$name] = $amount;
739 739
 		}
740 740
 
741 741
 	}
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
 	 *
755 755
 	 * @since 1.0.19
756 756
 	 */
757
-	public function get_fee( $name ) {
758
-		return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0;
757
+	public function get_fee($name) {
758
+		return isset($this->fees[$name]) ? $this->fees[$name] : 0;
759 759
 	}
760 760
 
761 761
 	/**
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 	 */
777 777
 	public function get_total() {
778 778
 		$total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
779
-		$total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
780
-		return wpinv_sanitize_amount( $total );
779
+		$total = apply_filters('getpaid_get_submission_total_amount', $total, $this);
780
+		return wpinv_sanitize_amount($total);
781 781
 	}
782 782
 
783 783
 	/**
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
 	public function get_payment_details() {
789 789
 		$collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
790 790
 
791
-		if ( $this->has_recurring ) {
791
+		if ($this->has_recurring) {
792 792
 			$collect = true;
793 793
 		}
794 794
 
795
-		$collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
795
+		$collect = apply_filters('getpaid_submission_collect_payment_details', $collect, $this);
796 796
 		return $collect;
797 797
 	}
798 798
 
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 	 * @since 1.0.19
803 803
 	 */
804 804
 	public function get_billing_email() {
805
-		$billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
806
-		return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
805
+		$billing_email = empty($this->data['billing_email']) ? '' : $this->data['billing_email'];
806
+		return apply_filters('getpaid_get_submission_billing_email', $billing_email, $this);
807 807
 	}
808 808
 
809 809
 	/**
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	 */
814 814
 	public function has_billing_email() {
815 815
 		$billing_email = $this->get_billing_email();
816
-		return ! empty( $billing_email );
816
+		return !empty($billing_email);
817 817
 	}
818 818
 
819 819
 	/**
@@ -824,16 +824,16 @@  discard block
 block discarded – undo
824 824
 	public function maybe_validate_vat() {
825 825
 		
826 826
 		// Make sure that taxes are enabled.
827
-		if ( ! wpinv_use_taxes() ) {
827
+		if (!wpinv_use_taxes()) {
828 828
 			return;
829 829
 		}
830 830
 
831 831
 		// Check if we have a digital VAT rule.
832 832
 		$has_digital = false;
833 833
 
834
-		foreach ( $this->get_items() as $item ) {
834
+		foreach ($this->get_items() as $item) {
835 835
 
836
-			if ( 'digital' == $item->get_vat_rule() ) {
836
+			if ('digital' == $item->get_vat_rule()) {
837 837
 				$has_digital = true;
838 838
 				break;
839 839
 			}
@@ -844,14 +844,14 @@  discard block
 block discarded – undo
844 844
 
845 845
 		// Check if we require vat.
846 846
 		$requires_vat = (
847
-			( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) )
848
-			|| ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) )
847
+			(getpaid_is_eu_state($this->country) && (getpaid_is_eu_state(wpinv_get_default_country()) || $has_digital))
848
+			|| (getpaid_is_gst_country($this->country) && getpaid_is_gst_country(wpinv_get_default_country()))
849 849
 		);
850 850
 
851 851
 		$this->requires_vat = $requires_vat;
852 852
 
853 853
 		// Abort if we are not calculating the taxes.
854
-		if ( ! $has_digital && ! $requires_vat ) {
854
+		if (!$has_digital && !$requires_vat) {
855 855
             return;
856 856
 		}
857 857
 
@@ -859,23 +859,23 @@  discard block
 block discarded – undo
859 859
 		$vat_number = $this->get_vat_number();
860 860
 		$company    = $this->get_company();
861 861
 		$ip_country = WPInv_EUVat::get_country_by_ip();
862
-        $is_eu      = getpaid_is_eu_state( $this->country );
863
-        $is_ip_eu   = getpaid_is_eu_state( $ip_country );
864
-		$is_non_eu  = ! $is_eu && ! $is_ip_eu;
865
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
862
+        $is_eu      = getpaid_is_eu_state($this->country);
863
+        $is_ip_eu   = getpaid_is_eu_state($ip_country);
864
+		$is_non_eu  = !$is_eu && !$is_ip_eu;
865
+		$prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase');
866 866
 
867 867
 		// If we're preventing business to consumer purchases...
868
-		if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) {
868
+		if (!empty($prevent_b2c) && !$is_non_eu && (empty($vat_number) || !$requires_vat)) {
869 869
 
870
-            if ( $is_eu ) {
870
+            if ($is_eu) {
871 871
 				$this->last_error = wp_sprintf(
872
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
872
+					__('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'),
873 873
 					getpaid_vat_name()
874 874
 				);
875
-            } else if ( $has_digital && $is_ip_eu ) {
875
+            } else if ($has_digital && $is_ip_eu) {
876 876
 
877 877
 				$this->last_error = wp_sprintf(
878
-					__( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ),
878
+					__('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'),
879 879
 					getpaid_vat_name()
880 880
 				);
881 881
 
@@ -884,13 +884,13 @@  discard block
 block discarded – undo
884 884
 		}
885 885
 		
886 886
 		// Abort if we are not validating vat.
887
-		if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) {
887
+		if (!$is_eu || !$requires_vat || empty($vat_number)) {
888 888
             return;
889 889
 		}
890 890
 
891
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country );
891
+		$is_valid = WPInv_EUVat::validate_vat_number($vat_number, $company, $this->country);
892 892
 
893
-		if ( is_string( $is_valid ) ) {
893
+		if (is_string($is_valid)) {
894 894
 			$this->last_error = $is_valid;
895 895
 		}
896 896
 
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -103,36 +103,36 @@  discard block
 block discarded – undo
103 103
             'ip_geolocation'              => true,
104 104
         );
105 105
 
106
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
107
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
108
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
106
+        foreach ($ajax_events as $ajax_event => $nopriv) {
107
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
108
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
109 109
 
110
-            if ( $nopriv ) {
111
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
112
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
113
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
110
+            if ($nopriv) {
111
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
112
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
113
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
114 114
             }
115 115
         }
116 116
     }
117 117
     
118 118
     public static function add_note() {
119
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
119
+        check_ajax_referer('add-invoice-note', '_nonce');
120 120
 
121
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
121
+        if (!wpinv_current_user_can_manage_invoicing()) {
122 122
             die(-1);
123 123
         }
124 124
 
125
-        $post_id   = absint( $_POST['post_id'] );
126
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
127
-        $note_type = sanitize_text_field( $_POST['note_type'] );
125
+        $post_id   = absint($_POST['post_id']);
126
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
127
+        $note_type = sanitize_text_field($_POST['note_type']);
128 128
 
129 129
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
130 130
 
131
-        if ( $post_id > 0 ) {
132
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
131
+        if ($post_id > 0) {
132
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
133 133
 
134
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
135
-                wpinv_get_invoice_note_line_item( $note_id );
134
+            if ($note_id > 0 && !is_wp_error($note_id)) {
135
+                wpinv_get_invoice_note_line_item($note_id);
136 136
             }
137 137
         }
138 138
 
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
     public static function delete_note() {
143
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
143
+        check_ajax_referer('delete-invoice-note', '_nonce');
144 144
 
145
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
145
+        if (!wpinv_current_user_can_manage_invoicing()) {
146 146
             die(-1);
147 147
         }
148 148
 
149
-        $note_id = (int)$_POST['note_id'];
149
+        $note_id = (int) $_POST['note_id'];
150 150
 
151
-        if ( $note_id > 0 ) {
152
-            wp_delete_comment( $note_id, true );
151
+        if ($note_id > 0) {
152
+            wp_delete_comment($note_id, true);
153 153
         }
154 154
 
155 155
         die();
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
     }
163 163
     
164 164
     public static function checkout() {
165
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
166
-            define( 'WPINV_CHECKOUT', true );
165
+        if (!defined('WPINV_CHECKOUT')) {
166
+            define('WPINV_CHECKOUT', true);
167 167
         }
168 168
 
169 169
         wpinv_process_checkout();
@@ -176,34 +176,34 @@  discard block
 block discarded – undo
176 176
     public static function get_billing_details() {
177 177
 
178 178
         // Verify nonce.
179
-        check_ajax_referer( 'wpinv-nonce' );
179
+        check_ajax_referer('wpinv-nonce');
180 180
 
181 181
         // Can the user manage the plugin?
182
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
182
+        if (!wpinv_current_user_can_manage_invoicing()) {
183 183
             die(-1);
184 184
         }
185 185
 
186 186
         // Do we have a user id?
187 187
         $user_id = $_GET['user_id'];
188 188
 
189
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
189
+        if (empty($user_id) || !is_numeric($user_id)) {
190 190
             die(-1);
191 191
         }
192 192
 
193 193
         // Fetch the billing details.
194
-        $billing_details    = wpinv_get_user_address( $user_id );
195
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
194
+        $billing_details    = wpinv_get_user_address($user_id);
195
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
196 196
 
197 197
         // unset the user id and email.
198
-        $to_ignore = array( 'user_id', 'email' );
198
+        $to_ignore = array('user_id', 'email');
199 199
 
200
-        foreach ( $to_ignore as $key ) {
201
-            if ( isset( $billing_details[ $key ] ) ) {
202
-                unset( $billing_details[ $key ] );
200
+        foreach ($to_ignore as $key) {
201
+            if (isset($billing_details[$key])) {
202
+                unset($billing_details[$key]);
203 203
             }
204 204
         }
205 205
 
206
-        wp_send_json_success( $billing_details );
206
+        wp_send_json_success($billing_details);
207 207
 
208 208
     }
209 209
 
@@ -213,47 +213,47 @@  discard block
 block discarded – undo
213 213
     public static function check_new_user_email() {
214 214
 
215 215
         // Verify nonce.
216
-        check_ajax_referer( 'wpinv-nonce' );
216
+        check_ajax_referer('wpinv-nonce');
217 217
 
218 218
         // Can the user manage the plugin?
219
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
219
+        if (!wpinv_current_user_can_manage_invoicing()) {
220 220
             die(-1);
221 221
         }
222 222
 
223 223
         // We need an email address.
224
-        if ( empty( $_GET['email'] ) ) {
225
-            _e( "Provide the new user's email address", 'invoicing' );
224
+        if (empty($_GET['email'])) {
225
+            _e("Provide the new user's email address", 'invoicing');
226 226
             exit;
227 227
         }
228 228
 
229 229
         // Ensure the email is valid.
230
-        $email = sanitize_text_field( $_GET['email'] );
231
-        if ( ! is_email( $email ) ) {
232
-            _e( 'Invalid email address', 'invoicing' );
230
+        $email = sanitize_text_field($_GET['email']);
231
+        if (!is_email($email)) {
232
+            _e('Invalid email address', 'invoicing');
233 233
             exit;
234 234
         }
235 235
 
236 236
         // And it does not exist.
237
-        if ( email_exists( $email ) ) {
238
-            _e( 'A user with this email address already exists', 'invoicing' );
237
+        if (email_exists($email)) {
238
+            _e('A user with this email address already exists', 'invoicing');
239 239
             exit;
240 240
         }
241 241
 
242
-        wp_send_json_success( true );
242
+        wp_send_json_success(true);
243 243
     }
244 244
     
245 245
     public static function run_tool() {
246
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
247
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
246
+        check_ajax_referer('wpinv-nonce', '_nonce');
247
+        if (!wpinv_current_user_can_manage_invoicing()) {
248 248
             die(-1);
249 249
         }
250 250
         
251
-        $tool = sanitize_text_field( $_POST['tool'] );
251
+        $tool = sanitize_text_field($_POST['tool']);
252 252
         
253
-        do_action( 'wpinv_run_tool' );
253
+        do_action('wpinv_run_tool');
254 254
         
255
-        if ( !empty( $tool ) ) {
256
-            do_action( 'wpinv_tool_' . $tool );
255
+        if (!empty($tool)) {
256
+            do_action('wpinv_tool_' . $tool);
257 257
         }
258 258
     }
259 259
 
@@ -263,30 +263,30 @@  discard block
 block discarded – undo
263 263
     public static function get_payment_form() {
264 264
 
265 265
         // Check nonce.
266
-        if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) {
267
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
266
+        if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) {
267
+            _e('Error: Reload the page and try again.', 'invoicing');
268 268
             exit;
269 269
         }
270 270
 
271 271
         // Is the request set up correctly?
272
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
272
+		if (empty($_GET['form']) && empty($_GET['item'])) {
273 273
 			echo aui()->alert(
274 274
 				array(
275 275
 					'type'    => 'warning',
276
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
276
+					'content' => __('No payment form or item provided', 'invoicing'),
277 277
 				)
278 278
             );
279 279
             exit;
280 280
         }
281 281
 
282 282
         // Payment form or button?
283
-		if ( ! empty( $_GET['form'] ) ) {
284
-            echo getpaid_display_payment_form( $_GET['form'] );
285
-		} else if( $_GET['invoice'] ) {
286
-		    echo getpaid_display_invoice_payment_form( $_GET['invoice'] );
283
+		if (!empty($_GET['form'])) {
284
+            echo getpaid_display_payment_form($_GET['form']);
285
+		} else if ($_GET['invoice']) {
286
+		    echo getpaid_display_invoice_payment_form($_GET['invoice']);
287 287
         } else {
288
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
289
-		    echo getpaid_display_item_payment_form( $items );
288
+			$items = getpaid_convert_items_to_array($_GET['item']);
289
+		    echo getpaid_display_item_payment_form($items);
290 290
         }
291 291
         
292 292
         exit;
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
         global $invoicing, $wpi_checkout_id, $cart_total;
303 303
 
304 304
         // Check nonce.
305
-        check_ajax_referer( 'getpaid_form_nonce' );
305
+        check_ajax_referer('getpaid_form_nonce');
306 306
 
307 307
         // ... form fields...
308
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
309
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
308
+        if (empty($_POST['getpaid_payment_form_submission'])) {
309
+            _e('Error: Reload the page and try again.', 'invoicing');
310 310
             exit;
311 311
         }
312 312
 
@@ -314,52 +314,52 @@  discard block
 block discarded – undo
314 314
         $submission = new GetPaid_Payment_Form_Submission();
315 315
 
316 316
         // Do we have an error?
317
-        if ( ! empty( $submission->last_error ) ) {
317
+        if (!empty($submission->last_error)) {
318 318
             echo $submission->last_error;
319 319
             exit;
320 320
         }
321 321
 
322 322
         // We need a billing email.
323
-        if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) {
324
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
323
+        if (!$submission->has_billing_email() || !is_email($submission->get_billing_email())) {
324
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
325 325
         }
326 326
 
327 327
         // Prepare items.
328 328
         $items = $submission->get_items();
329 329
 
330 330
         // Ensure that we have items.
331
-        if ( empty( $items ) ) {
332
-            wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) );
331
+        if (empty($items)) {
332
+            wp_send_json_error(__('You have not selected any items.', 'invoicing'));
333 333
         }
334 334
 
335 335
         // Prepare the invoice.
336
-        if ( ! $submission->has_invoice() ) {
336
+        if (!$submission->has_invoice()) {
337 337
             $invoice = new WPInv_Invoice();
338 338
         } else {
339 339
             $invoice = $submission->get_invoice();
340 340
         }
341 341
 
342 342
         // Make sure that it is neither paid or refunded.
343
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
344
-            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
343
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
344
+            wp_send_json_error(__('This invoice has already been paid for.', 'invoicing'));
345 345
         }
346 346
 
347 347
         // Set the billing email.
348
-        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
348
+        $invoice->set_email(sanitize_email($submission->get_billing_email()));
349 349
 
350 350
         // Payment form.
351
-        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
351
+        $invoice->set_payment_form(absint($submission->get_payment_form()->get_id()));
352 352
 
353 353
         // Discount code.
354
-        if ( $submission->has_discount_code() ) {
355
-            $invoice->set_discount_code( $submission->get_discount_code() );
354
+        if ($submission->has_discount_code()) {
355
+            $invoice->set_discount_code($submission->get_discount_code());
356 356
         }
357 357
 
358 358
         // Items, Fees, taxes and discounts.
359
-        $invoice->set_items( $items );
360
-        $invoice->set_fees( $submission->get_fees() );
361
-        $invoice->set_taxes( $submission->get_taxes() );
362
-        $invoice->set_discounts( $submission->get_discounts() );
359
+        $invoice->set_items($items);
360
+        $invoice->set_fees($submission->get_fees());
361
+        $invoice->set_taxes($submission->get_taxes());
362
+        $invoice->set_discounts($submission->get_discounts());
363 363
 
364 364
         // Prepared submission details.
365 365
         $prepared = array();
@@ -368,48 +368,48 @@  discard block
 block discarded – undo
368 368
         $data = $submission->get_data();
369 369
 
370 370
         // Loop throught the submitted details.
371
-        foreach ( $submission->payment_form->get_elements() as $field ) {
371
+        foreach ($submission->payment_form->get_elements() as $field) {
372 372
 
373
-            if ( ! empty( $field['premade'] ) ) {
373
+            if (!empty($field['premade'])) {
374 374
                 continue;
375 375
             }
376 376
 
377 377
             // If it is required and not set, abort.
378
-            if ( ! $submission->is_required_field_set( $field ) ) {
379
-                wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) );
378
+            if (!$submission->is_required_field_set($field)) {
379
+                wp_send_json_error(__('Some required fields are not set.', 'invoicing'));
380 380
             }
381 381
 
382 382
             // Handle address fields.
383
-            if ( $field['type'] == 'address' ) {
383
+            if ($field['type'] == 'address') {
384 384
 
385
-                foreach ( $field['fields'] as $address_field ) {
385
+                foreach ($field['fields'] as $address_field) {
386 386
 
387 387
                     // skip if it is not visible.
388
-                    if ( empty( $address_field['visible'] ) ) {
388
+                    if (empty($address_field['visible'])) {
389 389
                         continue;
390 390
                     }
391 391
 
392 392
                     // If it is required and not set, abort
393
-                    if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) {
394
-                        wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) );
393
+                    if (!empty($address_field['required']) && empty($data[$address_field['name']])) {
394
+                        wp_send_json_error(__('Some required fields are not set.', 'invoicing'));
395 395
                     }
396 396
 
397
-                    if ( isset( $data[ $address_field['name'] ] ) ) {
398
-                        $name   = str_replace( 'wpinv_', '', $address_field['name'] );
397
+                    if (isset($data[$address_field['name']])) {
398
+                        $name   = str_replace('wpinv_', '', $address_field['name']);
399 399
                         $method = "set_$name";
400
-                        $invoice->$method( wpinv_clean( $data[ $address_field['name'] ] ) );
400
+                        $invoice->$method(wpinv_clean($data[$address_field['name']]));
401 401
                     }
402 402
 
403 403
                 }
404 404
 
405
-            } else if ( isset( $data[ $field['id'] ] ) ) {
405
+            } else if (isset($data[$field['id']])) {
406 406
                 $label = $field['id'];
407 407
 
408
-                if ( isset( $field['label'] ) ) {
408
+                if (isset($field['label'])) {
409 409
                     $label = $field['label'];
410 410
                 }
411 411
 
412
-                $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
412
+                $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]);
413 413
             }
414 414
 
415 415
         }
@@ -417,23 +417,23 @@  discard block
 block discarded – undo
417 417
         // (Maybe) create the user.
418 418
         $user = get_current_user_id();
419 419
 
420
-        if ( empty( $user ) ) {
421
-            $user = get_user_by( 'email', $submission->get_billing_email() );
420
+        if (empty($user)) {
421
+            $user = get_user_by('email', $submission->get_billing_email());
422 422
         }
423 423
 
424
-        if ( empty( $user ) ) {
425
-            $user = wpinv_create_user( $submission->get_billing_email() );
424
+        if (empty($user)) {
425
+            $user = wpinv_create_user($submission->get_billing_email());
426 426
         }
427 427
 
428
-        if ( is_wp_error( $user ) ) {
429
-            wp_send_json_error( $user->get_error_message() );
428
+        if (is_wp_error($user)) {
429
+            wp_send_json_error($user->get_error_message());
430 430
         }
431 431
 
432
-        if ( is_numeric( $user ) ) {
433
-            $user = get_user_by( 'id', $user );
432
+        if (is_numeric($user)) {
433
+            $user = get_user_by('id', $user);
434 434
         }
435 435
 
436
-        $invoice->set_user_id( $user->ID );
436
+        $invoice->set_user_id($user->ID);
437 437
 
438 438
         $invoice->recalculate_total();
439 439
 
@@ -441,33 +441,33 @@  discard block
 block discarded – undo
441 441
         $invoice->save();
442 442
 
443 443
         // Was it saved successfully:
444
-        if ($invoice->get_id() == 0 ) {
445
-            wp_send_json_error( __( 'An error occured while saving your invoice.', 'invoicing' ) );
444
+        if ($invoice->get_id() == 0) {
445
+            wp_send_json_error(__('An error occured while saving your invoice.', 'invoicing'));
446 446
         }
447 447
 
448 448
         // Save payment form data.
449
-        update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared );
449
+        update_post_meta($invoice->get_id(), 'payment_form_data', $prepared);
450 450
 
451 451
         // Backwards compatibility.
452 452
         $wpi_checkout_id = $invoice->get_id();
453 453
         $cart_total      = wpinv_price(
454
-            wpinv_format_amount( $invoice->get_total() ),
454
+            wpinv_format_amount($invoice->get_total()),
455 455
             $invoice->get_currency()
456 456
         );
457 457
 
458 458
         $data                   = array();
459 459
         $data['invoice_id']     = $invoice->get_id();
460
-        $data['cart_discounts'] = array ( $invoice->get_discount_code() );
460
+        $data['cart_discounts'] = array($invoice->get_discount_code());
461 461
 
462
-        wpinv_set_checkout_session( $data );
463
-        add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) );
464
-        add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) );
462
+        wpinv_set_checkout_session($data);
463
+        add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response'));
464
+        add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error'));
465 465
 
466
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
467
-            define( 'WPINV_CHECKOUT', true );
466
+        if (!defined('WPINV_CHECKOUT')) {
467
+            define('WPINV_CHECKOUT', true);
468 468
         }
469 469
 
470
-        wpinv_process_checkout( $invoice, $submission->get_data() );
470
+        wpinv_process_checkout($invoice, $submission->get_data());
471 471
 
472 472
         $invoicing->form_elements->checkout_error();
473 473
 
@@ -482,51 +482,51 @@  discard block
 block discarded – undo
482 482
     public static function get_payment_form_states_field() {
483 483
         global $invoicing;
484 484
 
485
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
485
+        if (empty($_GET['country']) || empty($_GET['form'])) {
486 486
             exit;
487 487
         }
488 488
 
489
-        $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] );
489
+        $elements = $invoicing->form_elements->get_form_elements($_GET['form']);
490 490
 
491
-        if ( empty( $elements ) ) {
491
+        if (empty($elements)) {
492 492
             exit;
493 493
         }
494 494
 
495 495
         $address_fields = array();
496
-        foreach ( $elements as $element ) {
497
-            if ( 'address' === $element['type'] ) {
496
+        foreach ($elements as $element) {
497
+            if ('address' === $element['type']) {
498 498
                 $address_fields = $element;
499 499
                 break;
500 500
             }
501 501
         }
502 502
 
503
-        if ( empty( $address_fields ) ) {
503
+        if (empty($address_fields)) {
504 504
             exit;
505 505
         }
506 506
 
507
-        foreach( $address_fields['fields'] as $address_field ) {
507
+        foreach ($address_fields['fields'] as $address_field) {
508 508
 
509
-            if ( 'wpinv_state' == $address_field['name'] ) {
509
+            if ('wpinv_state' == $address_field['name']) {
510 510
 
511 511
                 $label = $address_field['label'];
512 512
 
513
-                if ( ! empty( $address_field['required'] ) ) {
513
+                if (!empty($address_field['required'])) {
514 514
                     $label .= "<span class='text-danger'> *</span>";
515 515
                 }
516 516
 
517
-                $states = wpinv_get_country_states( $_GET['country'] );
517
+                $states = wpinv_get_country_states($_GET['country']);
518 518
 
519
-                if ( ! empty( $states ) ) {
519
+                if (!empty($states)) {
520 520
 
521 521
                     $html = aui()->select(
522 522
                             array(
523 523
                                 'options'          => $states,
524
-                                'name'             => esc_attr( $address_field['name'] ),
525
-                                'id'               => esc_attr( $address_field['name'] ),
526
-                                'placeholder'      => esc_attr( $address_field['placeholder'] ),
524
+                                'name'             => esc_attr($address_field['name']),
525
+                                'id'               => esc_attr($address_field['name']),
526
+                                'placeholder'      => esc_attr($address_field['placeholder']),
527 527
                                 'required'         => (bool) $address_field['required'],
528 528
                                 'no_wrap'          => true,
529
-                                'label'            => wp_kses_post( $label ),
529
+                                'label'            => wp_kses_post($label),
530 530
                                 'select2'          => false,
531 531
                             )
532 532
                         );
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
 
536 536
                     $html = aui()->input(
537 537
                             array(
538
-                                'name'       => esc_attr( $address_field['name'] ),
539
-                                'id'         => esc_attr( $address_field['name'] ),
538
+                                'name'       => esc_attr($address_field['name']),
539
+                                'id'         => esc_attr($address_field['name']),
540 540
                                 'required'   => (bool) $address_field['required'],
541
-                                'label'      => wp_kses_post( $label ),
541
+                                'label'      => wp_kses_post($label),
542 542
                                 'no_wrap'    => true,
543 543
                                 'type'       => 'text',
544 544
                             )
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 
547 547
                 }
548 548
 
549
-                wp_send_json_success( str_replace( 'sr-only', '', $html ) );
549
+                wp_send_json_success(str_replace('sr-only', '', $html));
550 550
                 exit;
551 551
 
552 552
             }
@@ -562,49 +562,49 @@  discard block
 block discarded – undo
562 562
     public static function recalculate_invoice_totals() {
563 563
 
564 564
         // Verify nonce.
565
-        check_ajax_referer( 'wpinv-nonce' );
565
+        check_ajax_referer('wpinv-nonce');
566 566
 
567
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
567
+        if (!wpinv_current_user_can_manage_invoicing()) {
568 568
             exit;
569 569
         }
570 570
 
571 571
         // We need an invoice.
572
-        if ( empty( $_POST['post_id'] ) ) {
572
+        if (empty($_POST['post_id'])) {
573 573
             exit;
574 574
         }
575 575
 
576 576
         // Fetch the invoice.
577
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
577
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
578 578
 
579 579
         // Ensure it exists.
580
-        if ( ! $invoice->get_id() ) {
580
+        if (!$invoice->get_id()) {
581 581
             exit;
582 582
         }
583 583
 
584 584
         // Maybe set the country, state, currency.
585
-        foreach ( array( 'country', 'state', 'currency' ) as $key ) {
586
-            if ( isset( $_POST[ $key ] ) ) {
585
+        foreach (array('country', 'state', 'currency') as $key) {
586
+            if (isset($_POST[$key])) {
587 587
                 $method = "set_$key";
588
-                $invoice->$method( $_POST[ $key ] );
588
+                $invoice->$method($_POST[$key]);
589 589
             }
590 590
         }
591 591
 
592 592
         // Maybe disable taxes.
593
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
593
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
594 594
 
595 595
         // Recalculate totals.
596 596
         $invoice->recalculate_total();
597 597
 
598 598
         $totals = array(
599
-            'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ) ),
600
-            'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ) ),
601
-            'tax'      => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ) ),
602
-            'total'    => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
599
+            'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal())),
600
+            'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount())),
601
+            'tax'      => wpinv_price(wpinv_format_amount($invoice->get_total_tax())),
602
+            'total'    => wpinv_price(wpinv_format_amount($invoice->get_total())),
603 603
         );
604 604
 
605
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
605
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
606 606
 
607
-        wp_send_json_success( compact( 'totals' ) );
607
+        wp_send_json_success(compact('totals'));
608 608
     }
609 609
 
610 610
     /**
@@ -613,33 +613,33 @@  discard block
 block discarded – undo
613 613
     public static function get_invoice_items() {
614 614
 
615 615
         // Verify nonce.
616
-        check_ajax_referer( 'wpinv-nonce' );
616
+        check_ajax_referer('wpinv-nonce');
617 617
 
618
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
618
+        if (!wpinv_current_user_can_manage_invoicing()) {
619 619
             exit;
620 620
         }
621 621
 
622 622
         // We need an invoice and items.
623
-        if ( empty( $_POST['post_id'] ) ) {
623
+        if (empty($_POST['post_id'])) {
624 624
             exit;
625 625
         }
626 626
 
627 627
         // Fetch the invoice.
628
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
628
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
629 629
 
630 630
         // Ensure it exists.
631
-        if ( ! $invoice->get_id() ) {
631
+        if (!$invoice->get_id()) {
632 632
             exit;
633 633
         }
634 634
 
635 635
         // Return an array of invoice items.
636 636
         $items = array();
637 637
 
638
-        foreach ( $invoice->get_items() as $item_id => $item ) {
639
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax();
638
+        foreach ($invoice->get_items() as $item_id => $item) {
639
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax();
640 640
         }
641 641
 
642
-        wp_send_json_success( compact( 'items' ) );
642
+        wp_send_json_success(compact('items'));
643 643
     }
644 644
 
645 645
     /**
@@ -648,48 +648,48 @@  discard block
 block discarded – undo
648 648
     public static function edit_invoice_item() {
649 649
 
650 650
         // Verify nonce.
651
-        check_ajax_referer( 'wpinv-nonce' );
651
+        check_ajax_referer('wpinv-nonce');
652 652
 
653
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
653
+        if (!wpinv_current_user_can_manage_invoicing()) {
654 654
             exit;
655 655
         }
656 656
 
657 657
         // We need an invoice and item details.
658
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
658
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
659 659
             exit;
660 660
         }
661 661
 
662 662
         // Fetch the invoice.
663
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
663
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
664 664
 
665 665
         // Ensure it exists and its not been paid for.
666
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
666
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
667 667
             exit;
668 668
         }
669 669
 
670 670
         // Format the data.
671
-        $data = wp_list_pluck( $_POST['data'], 'value', 'field' );
671
+        $data = wp_list_pluck($_POST['data'], 'value', 'field');
672 672
 
673 673
         // Ensure that we have an item id.
674
-        if ( empty( $data['id'] ) ) {
674
+        if (empty($data['id'])) {
675 675
             exit;
676 676
         }
677 677
 
678 678
         // Abort if the invoice does not have the specified item.
679
-        $item = $invoice->get_item( (int) $data['id'] );
679
+        $item = $invoice->get_item((int) $data['id']);
680 680
 
681
-        if ( empty( $item ) ) {
681
+        if (empty($item)) {
682 682
             exit;
683 683
         }
684 684
 
685 685
         // Update the item.
686
-        $item->set_price( $data['price'] );
687
-        $item->set_name( $data['name'] );
688
-        $item->set_description( $data['description'] );
689
-        $item->set_quantity( $data['quantity'] );
686
+        $item->set_price($data['price']);
687
+        $item->set_name($data['name']);
688
+        $item->set_description($data['description']);
689
+        $item->set_quantity($data['quantity']);
690 690
 
691 691
         // Add it to the invoice.
692
-        $invoice->add_item( $item );
692
+        $invoice->add_item($item);
693 693
 
694 694
         // Update totals.
695 695
         $invoice->recalculate_total();
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
         // Return an array of invoice items.
701 701
         $items = array();
702 702
 
703
-        foreach ( $invoice->get_items() as $item_id => $item ) {
704
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax();
703
+        foreach ($invoice->get_items() as $item_id => $item) {
704
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax();
705 705
         }
706 706
 
707
-        wp_send_json_success( compact( 'items' ) );
707
+        wp_send_json_success(compact('items'));
708 708
     }
709 709
     /**
710 710
      * Adds a items to an invoice.
@@ -712,38 +712,38 @@  discard block
 block discarded – undo
712 712
     public static function add_invoice_items() {
713 713
 
714 714
         // Verify nonce.
715
-        check_ajax_referer( 'wpinv-nonce' );
715
+        check_ajax_referer('wpinv-nonce');
716 716
 
717
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
717
+        if (!wpinv_current_user_can_manage_invoicing()) {
718 718
             exit;
719 719
         }
720 720
 
721 721
         // We need an invoice and items.
722
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
722
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
723 723
             exit;
724 724
         }
725 725
 
726 726
         // Fetch the invoice.
727
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
727
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
728 728
         $alert   = false;
729 729
 
730 730
         // Ensure it exists and its not been paid for.
731
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
731
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
732 732
             exit;
733 733
         }
734 734
 
735 735
         // Add the items.
736
-        foreach ( $_POST['items'] as $data ) {
736
+        foreach ($_POST['items'] as $data) {
737 737
 
738
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
738
+            $item = new GetPaid_Form_Item($data['id']);
739 739
 
740
-            if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) {
741
-                $item->set_quantity( $data[ 'qty' ] );
740
+            if (is_numeric($data['qty']) && (int) $data['qty'] > 0) {
741
+                $item->set_quantity($data['qty']);
742 742
             }
743 743
 
744
-            if ( $item->get_id() > 0 ) {
745
-                if ( ! $invoice->add_item( $item ) ) {
746
-                    $alert = __( 'An invoice can only contain one recurring item', 'invoicing' );
744
+            if ($item->get_id() > 0) {
745
+                if (!$invoice->add_item($item)) {
746
+                    $alert = __('An invoice can only contain one recurring item', 'invoicing');
747 747
                 }
748 748
             }
749 749
 
@@ -756,11 +756,11 @@  discard block
 block discarded – undo
756 756
         // Return an array of invoice items.
757 757
         $items = array();
758 758
 
759
-        foreach ( $invoice->get_items() as $item_id => $item ) {
760
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax();
759
+        foreach ($invoice->get_items() as $item_id => $item) {
760
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax();
761 761
         }
762 762
 
763
-        wp_send_json_success( compact( 'items', 'alert' ) );
763
+        wp_send_json_success(compact('items', 'alert'));
764 764
     }
765 765
 
766 766
     /**
@@ -769,15 +769,15 @@  discard block
 block discarded – undo
769 769
     public static function get_invoicing_items() {
770 770
 
771 771
         // Verify nonce.
772
-        check_ajax_referer( 'wpinv-nonce' );
772
+        check_ajax_referer('wpinv-nonce');
773 773
 
774
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
774
+        if (!wpinv_current_user_can_manage_invoicing()) {
775 775
             exit;
776 776
         }
777 777
 
778 778
         // We need a search term.
779
-        if ( empty( $_GET['search'] ) ) {
780
-            wp_send_json_success( array() );
779
+        if (empty($_GET['search'])) {
780
+            wp_send_json_success(array());
781 781
         }
782 782
 
783 783
         // Retrieve items.
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
             'orderby'        => 'title',
787 787
             'order'          => 'ASC',
788 788
             'posts_per_page' => -1,
789
-            'post_status'    => array( 'publish' ),
790
-            's'              => trim( $_GET['search'] ),
789
+            'post_status'    => array('publish'),
790
+            's'              => trim($_GET['search']),
791 791
             'meta_query'     => array(
792 792
                 array(
793 793
                     'key'       => '_wpinv_type',
@@ -797,18 +797,18 @@  discard block
 block discarded – undo
797 797
             )
798 798
         );
799 799
 
800
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
800
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
801 801
         $data  = array();
802 802
 
803
-        foreach ( $items as $item ) {
804
-            $item      = new GetPaid_Form_Item( $item );
803
+        foreach ($items as $item) {
804
+            $item = new GetPaid_Form_Item($item);
805 805
             $data[] = array(
806 806
                 'id'   => $item->get_id(),
807 807
                 'text' => $item->get_name()
808 808
             );
809 809
         }
810 810
 
811
-        wp_send_json_success( $data );
811
+        wp_send_json_success($data);
812 812
 
813 813
     }
814 814
 
@@ -818,24 +818,24 @@  discard block
 block discarded – undo
818 818
     public static function get_aui_states_field() {
819 819
 
820 820
         // Verify nonce.
821
-        check_ajax_referer( 'wpinv-nonce' );
821
+        check_ajax_referer('wpinv-nonce');
822 822
 
823 823
         // We need a country.
824
-        if ( empty( $_GET['country'] ) ) {
824
+        if (empty($_GET['country'])) {
825 825
             exit;
826 826
         }
827 827
 
828
-        $states = wpinv_get_country_states( trim( $_GET['country'] ) );
829
-        $state  = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state();
828
+        $states = wpinv_get_country_states(trim($_GET['country']));
829
+        $state  = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state();
830 830
 
831
-        if ( empty( $states ) ) {
831
+        if (empty($states)) {
832 832
 
833 833
             $html = aui()->input(
834 834
                 array(
835 835
                     'type'        => 'text',
836 836
                     'id'          => 'wpinv_state',
837 837
                     'name'        => 'wpinv_state',
838
-                    'label'       => __( 'State', 'invoicing' ),
838
+                    'label'       => __('State', 'invoicing'),
839 839
                     'label_type'  => 'vertical',
840 840
                     'placeholder' => 'Liège',
841 841
                     'class'       => 'form-control-sm',
@@ -849,9 +849,9 @@  discard block
 block discarded – undo
849 849
                 array(
850 850
                     'id'          => 'wpinv_state',
851 851
                     'name'        => 'wpinv_state',
852
-                    'label'       => __( 'State', 'invoicing' ),
852
+                    'label'       => __('State', 'invoicing'),
853 853
                     'label_type'  => 'vertical',
854
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
854
+                    'placeholder' => __('Select a state', 'invoicing'),
855 855
                     'class'       => 'form-control-sm',
856 856
                     'value'       => $state,
857 857
                     'options'     => $states,
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
         wp_send_json_success(
866 866
             array(
867 867
                 'html'   => $html,
868
-                'select' => ! empty ( $states )
868
+                'select' => !empty ($states)
869 869
             )
870 870
         );
871 871
 
@@ -879,46 +879,46 @@  discard block
 block discarded – undo
879 879
     public static function ip_geolocation() {
880 880
 
881 881
         // Check nonce.
882
-        check_ajax_referer( 'getpaid-ip-location' );
882
+        check_ajax_referer('getpaid-ip-location');
883 883
 
884 884
         // IP address.
885
-        if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) {
886
-            _e( 'Invalid IP Address.', 'invoicing' );
885
+        if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) {
886
+            _e('Invalid IP Address.', 'invoicing');
887 887
             exit;
888 888
         }
889 889
 
890 890
         // Retrieve location info.
891
-        $location = getpaid_geolocate_ip_address( $_GET['ip'] );
891
+        $location = getpaid_geolocate_ip_address($_GET['ip']);
892 892
 
893
-        if ( empty( $location ) ) {
894
-            _e( 'Unable to find geolocation for the IP Address.', 'invoicing' );
893
+        if (empty($location)) {
894
+            _e('Unable to find geolocation for the IP Address.', 'invoicing');
895 895
             exit;
896 896
         }
897 897
 
898 898
         // Sorry.
899
-        extract( $location );
899
+        extract($location);
900 900
 
901 901
         // Prepare the address.
902 902
         $content = '';
903 903
 
904
-        if ( ! empty( $location['city'] ) ) {
905
-            $content .=  $location['city']  . ', ';
904
+        if (!empty($location['city'])) {
905
+            $content .= $location['city'] . ', ';
906 906
         }
907 907
         
908
-        if ( ! empty( $location['region'] ) ) {
909
-            $content .=  $location['region']  . ', ';
908
+        if (!empty($location['region'])) {
909
+            $content .= $location['region'] . ', ';
910 910
         }
911 911
         
912
-        $content .=  $location['country'] . ' (' . $location['iso'] . ')';
912
+        $content .= $location['country'] . ' (' . $location['iso'] . ')';
913 913
 
914 914
         $location['address'] = $content;
915 915
 
916
-        $content  = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>';
917
-        $content .= '<p>'. $location['credit'] . '</p>';
916
+        $content  = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>';
917
+        $content .= '<p>' . $location['credit'] . '</p>';
918 918
 
919 919
         $location['content'] = $content;
920 920
 
921
-        wpinv_get_template( 'geolocation.php', $location );
921
+        wpinv_get_template('geolocation.php', $location);
922 922
 
923 923
         exit;
924 924
     }
@@ -931,11 +931,11 @@  discard block
 block discarded – undo
931 931
     public static function payment_form_refresh_prices() {
932 932
 
933 933
         // Check nonce.
934
-        check_ajax_referer( 'getpaid_form_nonce' );
934
+        check_ajax_referer('getpaid_form_nonce');
935 935
 
936 936
         // ... form fields...
937
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
938
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
937
+        if (empty($_POST['getpaid_payment_form_submission'])) {
938
+            _e('Error: Reload the page and try again.', 'invoicing');
939 939
             exit;
940 940
         }
941 941
 
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
         $submission = new GetPaid_Payment_Form_Submission();
944 944
 
945 945
         // Do we have an error?
946
-        if ( ! empty( $submission->last_error ) ) {
946
+        if (!empty($submission->last_error)) {
947 947
             echo $submission->last_error;
948 948
             exit;
949 949
         }
@@ -956,43 +956,43 @@  discard block
 block discarded – undo
956 956
             'is_free'       => $submission->get_payment_details(),
957 957
 
958 958
             'totals'        => array(
959
-                'subtotal'  => wpinv_price( wpinv_format_amount( $submission->subtotal_amount ), $submission->get_currency() ),
960
-                'discount'  => wpinv_price( wpinv_format_amount( $submission->get_total_discount() ), $submission->get_currency() ),
961
-                'fees'      => wpinv_price( wpinv_format_amount( $submission->get_total_fees() ), $submission->get_currency() ),
962
-                'tax'       => wpinv_price( wpinv_format_amount( $submission->get_total_tax() ), $submission->get_currency() ),
963
-                'total'     => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ),
959
+                'subtotal'  => wpinv_price(wpinv_format_amount($submission->subtotal_amount), $submission->get_currency()),
960
+                'discount'  => wpinv_price(wpinv_format_amount($submission->get_total_discount()), $submission->get_currency()),
961
+                'fees'      => wpinv_price(wpinv_format_amount($submission->get_total_fees()), $submission->get_currency()),
962
+                'tax'       => wpinv_price(wpinv_format_amount($submission->get_total_tax()), $submission->get_currency()),
963
+                'total'     => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()),
964 964
             ),
965 965
 
966 966
             'texts'         => array(
967
-                '.getpaid-checkout-total-payable' => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ),
967
+                '.getpaid-checkout-total-payable' => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()),
968 968
             )
969 969
 
970 970
         );
971 971
 
972 972
         // Add items.
973 973
         $items = $submission->get_items();
974
-        if ( ! empty( $items ) ) {
974
+        if (!empty($items)) {
975 975
             $result['items'] = array();
976 976
 
977
-            foreach( $items as $item_id => $item ) {
978
-                $result['items']["$item_id"] = wpinv_price( wpinv_format_amount( $item->get_price() * $item->get_quantity() ) );
977
+            foreach ($items as $item_id => $item) {
978
+                $result['items']["$item_id"] = wpinv_price(wpinv_format_amount($item->get_price() * $item->get_quantity()));
979 979
             }
980 980
         }
981 981
 
982 982
         // Add invoice.
983
-        if ( $submission->has_invoice() ) {
983
+        if ($submission->has_invoice()) {
984 984
             $result['invoice'] = $submission->get_invoice()->ID;
985 985
         }
986 986
 
987 987
         // Add discount code.
988
-        if ( $submission->has_discount_code() ) {
988
+        if ($submission->has_discount_code()) {
989 989
             $result['discount_code'] = $submission->get_discount_code();
990 990
         }
991 991
 
992 992
         // Filter the result.
993
-        $result = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $result, $submission );
993
+        $result = apply_filters('getpaid_payment_form_ajax_refresh_prices', $result, $submission);
994 994
 
995
-        wp_send_json_success( $result );
995
+        wp_send_json_success($result);
996 996
     }
997 997
 
998 998
     /**
@@ -1003,53 +1003,53 @@  discard block
 block discarded – undo
1003 1003
     public static function buy_items() {
1004 1004
         $user_id = get_current_user_id();
1005 1005
 
1006
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
1007
-            wp_send_json( array(
1008
-                'success' => wp_login_url( wp_get_referer() )
1009
-            ) );
1006
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
1007
+            wp_send_json(array(
1008
+                'success' => wp_login_url(wp_get_referer())
1009
+            ));
1010 1010
         } else {
1011 1011
             // Only check nonce if logged in as it could be cached when logged out.
1012
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
1013
-                wp_send_json( array(
1014
-                    'error' => __( 'Security checks failed.', 'invoicing' )
1015
-                ) );
1012
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
1013
+                wp_send_json(array(
1014
+                    'error' => __('Security checks failed.', 'invoicing')
1015
+                ));
1016 1016
                 wp_die();
1017 1017
             }
1018 1018
 
1019 1019
             // allow to set a custom price through post_id
1020 1020
             $items = $_POST['items'];
1021
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
1022
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
1021
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
1022
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
1023 1023
 
1024 1024
             $cart_items = array();
1025
-            if ( $items ) {
1026
-                $items = explode( ',', $items );
1025
+            if ($items) {
1026
+                $items = explode(',', $items);
1027 1027
 
1028
-                foreach( $items as $item ) {
1028
+                foreach ($items as $item) {
1029 1029
                     $item_id = $item;
1030 1030
                     $quantity = 1;
1031 1031
 
1032
-                    if ( strpos( $item, '|' ) !== false ) {
1033
-                        $item_parts = explode( '|', $item );
1032
+                    if (strpos($item, '|') !== false) {
1033
+                        $item_parts = explode('|', $item);
1034 1034
                         $item_id = $item_parts[0];
1035 1035
                         $quantity = $item_parts[1];
1036 1036
                     }
1037 1037
 
1038
-                    if ( $item_id && $quantity ) {
1038
+                    if ($item_id && $quantity) {
1039 1039
                         $cart_items_arr = array(
1040
-                            'id'            => (int)$item_id,
1041
-                            'quantity'      => (int)$quantity
1040
+                            'id'            => (int) $item_id,
1041
+                            'quantity'      => (int) $quantity
1042 1042
                         );
1043 1043
 
1044 1044
                         // If there is a related post id then add it to meta
1045
-                        if ( $related_post_id ) {
1045
+                        if ($related_post_id) {
1046 1046
                             $cart_items_arr['meta'] = array(
1047 1047
                                 'post_id'   => $related_post_id
1048 1048
                             );
1049 1049
                         }
1050 1050
 
1051 1051
                         // If there is a custom price then set it.
1052
-                        if ( $custom_item_price ) {
1052
+                        if ($custom_item_price) {
1053 1053
                             $cart_items_arr['custom_price'] = $custom_item_price;
1054 1054
                         }
1055 1055
 
@@ -1065,37 +1065,37 @@  discard block
 block discarded – undo
1065 1065
              * @param int $related_post_id The related post id if any.
1066 1066
              * @since 1.0.0
1067 1067
              */
1068
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
1068
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
1069 1069
 
1070 1070
             // Make sure its not in the cart already, if it is then redirect to checkout.
1071 1071
             $cart_invoice = wpinv_get_invoice_cart();
1072 1072
 
1073
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
1074
-                wp_send_json( array(
1073
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
1074
+                wp_send_json(array(
1075 1075
                     'success' =>  $cart_invoice->get_checkout_payment_url()
1076
-                ) );
1076
+                ));
1077 1077
                 wp_die();
1078 1078
             }
1079 1079
 
1080 1080
             // Check if user has invoice with same items waiting to be paid.
1081
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
1082
-            if ( !empty( $user_invoices ) ) {
1083
-                foreach( $user_invoices as $user_invoice ) {
1081
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
1082
+            if (!empty($user_invoices)) {
1083
+                foreach ($user_invoices as $user_invoice) {
1084 1084
                     $user_cart_details = array();
1085
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
1085
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
1086 1086
                     $cart_details = $invoice->get_cart_details();
1087 1087
 
1088
-                    if ( !empty( $cart_details ) ) {
1089
-                        foreach ( $cart_details as $invoice_item ) {
1088
+                    if (!empty($cart_details)) {
1089
+                        foreach ($cart_details as $invoice_item) {
1090 1090
                             $ii_arr = array();
1091
-                            $ii_arr['id'] = (int)$invoice_item['id'];
1092
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
1091
+                            $ii_arr['id'] = (int) $invoice_item['id'];
1092
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
1093 1093
 
1094
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
1094
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
1095 1095
                                 $ii_arr['meta'] = $invoice_item['meta'];
1096 1096
                             }
1097 1097
 
1098
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
1098
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
1099 1099
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
1100 1100
                             }
1101 1101
 
@@ -1103,17 +1103,17 @@  discard block
 block discarded – undo
1103 1103
                         }
1104 1104
                     }
1105 1105
 
1106
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
1107
-                        wp_send_json( array(
1106
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
1107
+                        wp_send_json(array(
1108 1108
                             'success' =>  $invoice->get_checkout_payment_url()
1109
-                        ) );
1109
+                        ));
1110 1110
                         wp_die();
1111 1111
                     }
1112 1112
                 }
1113 1113
             }
1114 1114
 
1115 1115
             // Create invoice and send user to checkout
1116
-            if ( !empty( $cart_items ) ) {
1116
+            if (!empty($cart_items)) {
1117 1117
                 $invoice_data = array(
1118 1118
                     'status'        =>  'wpi-pending',
1119 1119
                     'created_via'   =>  'wpi',
@@ -1121,21 +1121,21 @@  discard block
 block discarded – undo
1121 1121
                     'cart_details'  =>  $cart_items,
1122 1122
                 );
1123 1123
 
1124
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
1124
+                $invoice = wpinv_insert_invoice($invoice_data, true);
1125 1125
 
1126
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
1127
-                    wp_send_json( array(
1126
+                if (!empty($invoice) && isset($invoice->ID)) {
1127
+                    wp_send_json(array(
1128 1128
                         'success' =>  $invoice->get_checkout_payment_url()
1129
-                    ) );
1129
+                    ));
1130 1130
                 } else {
1131
-                    wp_send_json( array(
1132
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
1133
-                    ) );
1131
+                    wp_send_json(array(
1132
+                        'error' => __('Invoice failed to create', 'invoicing')
1133
+                    ));
1134 1134
                 }
1135 1135
             } else {
1136
-                wp_send_json( array(
1137
-                    'error' => __( 'Items not valid.', 'invoicing' )
1138
-                ) );
1136
+                wp_send_json(array(
1137
+                    'error' => __('Items not valid.', 'invoicing')
1138
+                ));
1139 1139
             }
1140 1140
         }
1141 1141
 
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
     exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct() {
15 15
 
16
-        foreach( $this->get_elements() as $element ) {
16
+        foreach ($this->get_elements() as $element) {
17 17
             $element = $element['type'];
18 18
 
19
-            if ( method_exists( $this, "render_{$element}_template" ) ) {
20
-                add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 );
19
+            if (method_exists($this, "render_{$element}_template")) {
20
+                add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2);
21 21
             }
22 22
 
23
-            if ( method_exists( $this, "edit_{$element}_template" ) ) {
24
-                add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 );
23
+            if (method_exists($this, "edit_{$element}_template")) {
24
+                add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2);
25 25
             }
26 26
 
27 27
 
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function get_elements() {
36 36
 
37
-        if ( ! empty( $this->elements ) ) {
37
+        if (!empty($this->elements)) {
38 38
             return $this->elements;
39 39
         }
40 40
 
41
-        $this->elements = wpinv_get_data( 'payment-form-elements' );
41
+        $this->elements = wpinv_get_data('payment-form-elements');
42 42
 
43
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
43
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
44 44
         return $this->elements;
45 45
     }
46 46
 
47 47
     /**
48 48
      * Returns the restrict markup.
49 49
      */
50
-    public function get_restrict_markup( $field, $field_type ) {
50
+    public function get_restrict_markup($field, $field_type) {
51 51
         $restrict = "$field.type=='$field_type'";
52 52
         return "v-if=\"$restrict\"";
53 53
     }
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
     /**
56 56
      * Renders the gateway select element template.
57 57
      */
58
-    public function render_gateway_select_template( $field ) {
59
-        $restrict = $this->get_restrict_markup( $field, 'gateway_select' );
60
-        $text     = __( 'The gateway select box will appear hear', 'invoicing' );
58
+    public function render_gateway_select_template($field) {
59
+        $restrict = $this->get_restrict_markup($field, 'gateway_select');
60
+        $text     = __('The gateway select box will appear hear', 'invoicing');
61 61
         echo "
62 62
             <div $restrict class='alert alert-info' role='alert'>
63 63
                 <span>$text</span>
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
     /**
69 69
      * Renders the edit gateway select element template.
70 70
      */
71
-    public function edit_gateway_select_template( $field ) {
72
-        $restrict = $this->get_restrict_markup( $field, 'gateway_select' );
73
-        $label    = __( 'The gateway select text', 'invoicing' );
71
+    public function edit_gateway_select_template($field) {
72
+        $restrict = $this->get_restrict_markup($field, 'gateway_select');
73
+        $label    = __('The gateway select text', 'invoicing');
74 74
         $id       = $field . '.id + "_edit"';
75 75
         echo "
76 76
             <div $restrict>
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
     /**
87 87
      * Renders the ip address element template.
88 88
      */
89
-    public function render_ip_address_template( $field ) {
90
-        $restrict   = $this->get_restrict_markup( $field, 'ip_address' );
91
-        $ip_address = sanitize_text_field( wpinv_get_ip() );
92
-        $url        = esc_url( getpaid_ip_location_url( $ip_address ) );
89
+    public function render_ip_address_template($field) {
90
+        $restrict   = $this->get_restrict_markup($field, 'ip_address');
91
+        $ip_address = sanitize_text_field(wpinv_get_ip());
92
+        $url        = esc_url(getpaid_ip_location_url($ip_address));
93 93
 
94 94
         echo "
95 95
             <div $restrict class='getpaid-ip-info'>
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
     /**
103 103
      * Renders the edit ip address element template.
104 104
      */
105
-    public function edit_ip_address_template( $field ) {
106
-        $restrict = $this->get_restrict_markup( $field, 'ip_address' );
107
-        $label    = __( 'The IP Address text', 'invoicing' );
105
+    public function edit_ip_address_template($field) {
106
+        $restrict = $this->get_restrict_markup($field, 'ip_address');
107
+        $label    = __('The IP Address text', 'invoicing');
108 108
         $id       = $field . '.id + "_edit"';
109 109
         echo "
110 110
             <div $restrict>
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * Renders the total payable element template.
122 122
      */
123
-    public function render_total_payable_template( $field ) {
124
-        $restrict = $this->get_restrict_markup( $field, 'total_payable' );
125
-        $text     = __( 'The total payable amount will appear here', 'invoicing' );
123
+    public function render_total_payable_template($field) {
124
+        $restrict = $this->get_restrict_markup($field, 'total_payable');
125
+        $text     = __('The total payable amount will appear here', 'invoicing');
126 126
         echo "
127 127
             <div $restrict class='alert alert-info' role='alert'>
128 128
                 <span>$text</span>
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
     /**
134 134
      * Renders the edit total payable element template.
135 135
      */
136
-    public function edit_total_payable_template( $field ) {
137
-        $restrict = $this->get_restrict_markup( $field, 'total_payable' );
138
-        $label    = __( 'The total payable text', 'invoicing' );
136
+    public function edit_total_payable_template($field) {
137
+        $restrict = $this->get_restrict_markup($field, 'total_payable');
138
+        $label    = __('The total payable text', 'invoicing');
139 139
         $id       = $field . '.id + "_edit"';
140 140
         echo "
141 141
             <div $restrict>
@@ -151,18 +151,18 @@  discard block
 block discarded – undo
151 151
     /**
152 152
      * Renders the title element template.
153 153
      */
154
-    public function render_heading_template( $field ) {
155
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
154
+    public function render_heading_template($field) {
155
+        $restrict = $this->get_restrict_markup($field, 'heading');
156 156
         echo "<component :is='$field.level' $restrict v-html='$field.text'></component>";
157 157
     }
158 158
 
159 159
     /**
160 160
      * Renders the edit title element template.
161 161
      */
162
-    public function edit_heading_template( $field ) {
163
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
164
-        $label    = __( 'Heading', 'invoicing' );
165
-        $label2   = __( 'Select Heading Level', 'invoicing' );
162
+    public function edit_heading_template($field) {
163
+        $restrict = $this->get_restrict_markup($field, 'heading');
164
+        $label    = __('Heading', 'invoicing');
165
+        $label2   = __('Select Heading Level', 'invoicing');
166 166
         $id       = $field . '.id + "_edit"';
167 167
         $id2      = $field . '.id + "_edit2"';
168 168
 
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
     /**
195 195
      * Renders a paragraph element template.
196 196
      */
197
-    public function render_paragraph_template( $field ) {
198
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
197
+    public function render_paragraph_template($field) {
198
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
199 199
         $label    = "$field.text";
200 200
         echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>";
201 201
     }
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
     /**
204 204
      * Renders the edit paragraph element template.
205 205
      */
206
-    public function edit_paragraph_template( $field ) {
207
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
208
-        $label    = __( 'Enter your text', 'invoicing' );
206
+    public function edit_paragraph_template($field) {
207
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
208
+        $label    = __('Enter your text', 'invoicing');
209 209
         $id       = $field . '.id + "_edit"';
210 210
         echo "
211 211
             <div $restrict>
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
     /**
222 222
      * Renders the text element template.
223 223
      */
224
-    public function render_text_template( $field ) {
225
-        $restrict = $this->get_restrict_markup( $field, 'text' );
224
+    public function render_text_template($field) {
225
+        $restrict = $this->get_restrict_markup($field, 'text');
226 226
         $label    = "$field.label";
227 227
         echo "
228 228
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -237,56 +237,56 @@  discard block
 block discarded – undo
237 237
     /**
238 238
      * Renders the edit price select element template.
239 239
      */
240
-    public function edit_price_select_template( $field ) {
241
-        $restrict = $this->get_restrict_markup( $field, 'price_select' );
240
+    public function edit_price_select_template($field) {
241
+        $restrict = $this->get_restrict_markup($field, 'price_select');
242 242
         
243
-        $label3   = __( 'Help text', 'invoicing' );
244
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
243
+        $label3   = __('Help text', 'invoicing');
244
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
245 245
         $id3      = $field . '.id + "_edit3"';
246
-        $label6   = __( 'Options', 'invoicing' );
246
+        $label6   = __('Options', 'invoicing');
247 247
         $id6      = $field . '.id + "_edit5"';
248 248
         ?>
249 249
             <div <?php echo $restrict; ?>>
250
-                <small class='form-text text-muted mb-2'><?php _e( 'This amount will be added to the total amount for this form', 'invoicing' ); ?></small>
250
+                <small class='form-text text-muted mb-2'><?php _e('This amount will be added to the total amount for this form', 'invoicing'); ?></small>
251 251
                 <div class='form-group'>
252 252
                     <label class="d-block">
253
-                        <span><?php _e( 'Field Label', 'invoicing' ); ?></span>
253
+                        <span><?php _e('Field Label', 'invoicing'); ?></span>
254 254
                         <input v-model='<?php echo $field; ?>.label' class='form-control' />
255 255
                     </label>
256 256
                 </div>
257 257
 
258 258
                 <div class='form-group' v-if="<?php echo $field; ?>.select_type=='select'">
259 259
                     <label class="d-block">
260
-                        <span><?php _e( 'Placeholder text', 'invoicing' ); ?></span>
260
+                        <span><?php _e('Placeholder text', 'invoicing'); ?></span>
261 261
                         <input v-model='<?php echo $field; ?>.placeholder' class='form-control' />
262 262
                     </label>
263 263
                 </div>
264 264
 
265 265
                 <div class='form-group'>
266 266
                     <label class="d-block">
267
-                        <span><?php _e( 'Select Type', 'invoicing' ); ?></span>
267
+                        <span><?php _e('Select Type', 'invoicing'); ?></span>
268 268
                         <select class='form-control custom-select' v-model='<?php echo $field; ?>.select_type'>
269
-                            <option value='select'><?php _e( 'Dropdown', 'invoicing' ) ?></option>
270
-                            <option value='checkboxes'><?php _e( 'Checkboxes', 'invoicing' ) ?></option>
271
-                            <option value='radios'><?php _e( 'Radio Buttons', 'invoicing' ) ?></option>
272
-                            <option value='buttons'><?php _e( 'Buttons', 'invoicing' ) ?></option>
273
-                            <option value='circles'><?php _e( 'Circles', 'invoicing' ) ?></option>
269
+                            <option value='select'><?php _e('Dropdown', 'invoicing') ?></option>
270
+                            <option value='checkboxes'><?php _e('Checkboxes', 'invoicing') ?></option>
271
+                            <option value='radios'><?php _e('Radio Buttons', 'invoicing') ?></option>
272
+                            <option value='buttons'><?php _e('Buttons', 'invoicing') ?></option>
273
+                            <option value='circles'><?php _e('Circles', 'invoicing') ?></option>
274 274
                         </select>
275 275
                     </label>
276 276
                 </div>
277 277
 
278 278
                 <div class='form-group'>
279 279
                     <label class="d-block">
280
-                        <span><?php _e( 'Options', 'invoicing' ); ?></span>
280
+                        <span><?php _e('Options', 'invoicing'); ?></span>
281 281
                         <textarea placeholder='Basic|10,Pro|99,Business|199' v-model='<?php echo $field; ?>.options' class='form-control' rows='3'></textarea>
282
-                        <small class='form-text text-muted mb-2'><?php _e( 'Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing' ); ?></small>
282
+                        <small class='form-text text-muted mb-2'><?php _e('Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing'); ?></small>
283 283
                     </label>
284 284
                 </div>
285 285
 
286 286
                 <div class='form-group'>
287 287
                     <label class="d-block">
288
-                        <span><?php _e( 'Help Text', 'invoicing' ); ?></span>
289
-                        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea>
288
+                        <span><?php _e('Help Text', 'invoicing'); ?></span>
289
+                        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea>
290 290
                     </label>
291 291
                 </div>
292 292
             </div>
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
     /**
298 298
      * Renders the price select element template.
299 299
      */
300
-    public function render_price_select_template( $field ) {
301
-        $restrict = $this->get_restrict_markup( $field, 'price_select' );
300
+    public function render_price_select_template($field) {
301
+        $restrict = $this->get_restrict_markup($field, 'price_select');
302 302
         ?>
303 303
             <div <?php echo $restrict; ?> class='wpinv-payment-form-field-preview'>
304 304
                 <div class='wpinv-payment-form-field-preview-overlay'></div>
@@ -306,24 +306,24 @@  discard block
 block discarded – undo
306 306
                 <label>{{<?php echo $field; ?>.label}}</label>
307 307
 
308 308
                 <!-- Buttons -->
309
-                <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="buttons"' class="getpaid-price-buttons">
310
-                    <span v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index">
311
-                        <input type="radio" :id="<?php echo esc_attr( $field ); ?>.id + index" :checked="index==0" />
312
-                        <label :for="<?php echo esc_attr( $field ); ?>.id + index" class="rounded">{{option | optionize}}</label>
309
+                <div v-if='<?php echo esc_attr($field); ?>.select_type=="buttons"' class="getpaid-price-buttons">
310
+                    <span v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index">
311
+                        <input type="radio" :id="<?php echo esc_attr($field); ?>.id + index" :checked="index==0" />
312
+                        <label :for="<?php echo esc_attr($field); ?>.id + index" class="rounded">{{option | optionize}}</label>
313 313
                     </span>
314 314
                 </div>
315 315
 
316 316
                 <!-- Circles -->
317
-                <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="circles"' class="getpaid-price-buttons getpaid-price-circles">
318
-                    <span v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index">
319
-                        <input type="radio" :id="<?php echo esc_attr( $field ); ?>.id + index" :checked="index==0" />
320
-                        <label :for="<?php echo esc_attr( $field ); ?>.id + index"><span>{{option | optionize}}</span></label>
317
+                <div v-if='<?php echo esc_attr($field); ?>.select_type=="circles"' class="getpaid-price-buttons getpaid-price-circles">
318
+                    <span v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index">
319
+                        <input type="radio" :id="<?php echo esc_attr($field); ?>.id + index" :checked="index==0" />
320
+                        <label :for="<?php echo esc_attr($field); ?>.id + index"><span>{{option | optionize}}</span></label>
321 321
                     </span>
322 322
                 </div>
323 323
 
324 324
                 <!-- Radios -->
325
-                <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="radios"'>
326
-                    <div v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index">
325
+                <div v-if='<?php echo esc_attr($field); ?>.select_type=="radios"'>
326
+                    <div v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index">
327 327
                         <label>
328 328
                             <input type="radio" :checked="index==0" />
329 329
                             <span>{{option | optionize}}</span>
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
                 </div>
333 333
 
334 334
                 <!-- Checkboxes -->
335
-                <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="checkboxes"'>
336
-                    <div v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index">
335
+                <div v-if='<?php echo esc_attr($field); ?>.select_type=="checkboxes"'>
336
+                    <div v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index">
337 337
                         <label>
338 338
                             <input type="checkbox" :checked="index==0" />
339 339
                             <span>{{option | optionize}}</span>
@@ -342,15 +342,15 @@  discard block
 block discarded – undo
342 342
                 </div>
343 343
 
344 344
                 <!-- Select -->
345
-                <select v-if='<?php echo esc_attr( $field ); ?>.select_type=="select"' class='form-control custom-select'>
346
-                    <option v-if="<?php echo esc_attr( $field ); ?>.placeholder" selected="selected">
347
-                        {{<?php echo esc_attr( $field ); ?>.placeholder}}
345
+                <select v-if='<?php echo esc_attr($field); ?>.select_type=="select"' class='form-control custom-select'>
346
+                    <option v-if="<?php echo esc_attr($field); ?>.placeholder" selected="selected">
347
+                        {{<?php echo esc_attr($field); ?>.placeholder}}
348 348
                     </option>
349
-                    <option v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index">
349
+                    <option v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index">
350 350
                         {{option | optionize}}
351 351
                     </option>
352 352
                 </select>
353
-                <small v-if='<?php echo esc_attr( $field ); ?>.description' class='form-text text-muted' v-html='<?php echo esc_attr( $field ); ?>.description'></small>
353
+                <small v-if='<?php echo esc_attr($field); ?>.description' class='form-text text-muted' v-html='<?php echo esc_attr($field); ?>.description'></small>
354 354
             </div>
355 355
 
356 356
         <?php
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
     /**
360 360
      * Renders the edit price input element template.
361 361
      */
362
-    public function edit_price_input_template( $field ) {
363
-        $restrict = $this->get_restrict_markup( $field, 'price_input' );
364
-        $label    = __( 'Field Label', 'invoicing' );
362
+    public function edit_price_input_template($field) {
363
+        $restrict = $this->get_restrict_markup($field, 'price_input');
364
+        $label    = __('Field Label', 'invoicing');
365 365
         $id       = $field . '.id + "_edit"';
366
-        $label2   = __( 'Placeholder text', 'invoicing' );
366
+        $label2   = __('Placeholder text', 'invoicing');
367 367
         $id2      = $field . '.id + "_edit2"';
368
-        $label3   = __( 'Help text', 'invoicing' );
369
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
368
+        $label3   = __('Help text', 'invoicing');
369
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
370 370
         $id3      = $field . '.id + "_edit3"';
371
-        $label5   = __( 'The amount that users add to this field will be added to the total amount', 'invoicing' );
372
-        $label6   = __( 'Default Amount', 'invoicing' );
371
+        $label5   = __('The amount that users add to this field will be added to the total amount', 'invoicing');
372
+        $label6   = __('Default Amount', 'invoicing');
373 373
         $id6      = $field . '.id + "_edit5"';
374 374
         echo "
375 375
             <div $restrict>
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
     /**
398 398
      * Renders the edit text element template.
399 399
      */
400
-    public function edit_text_template( $field ) {
401
-        $restrict = $this->get_restrict_markup( $field, 'text' );
402
-        $label    = __( 'Field Label', 'invoicing' );
400
+    public function edit_text_template($field) {
401
+        $restrict = $this->get_restrict_markup($field, 'text');
402
+        $label    = __('Field Label', 'invoicing');
403 403
         $id       = $field . '.id + "_edit"';
404
-        $label2   = __( 'Placeholder text', 'invoicing' );
404
+        $label2   = __('Placeholder text', 'invoicing');
405 405
         $id2      = $field . '.id + "_edit2"';
406
-        $label3   = __( 'Help text', 'invoicing' );
407
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
406
+        $label3   = __('Help text', 'invoicing');
407
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
408 408
         $id3      = $field . '.id + "_edit3"';
409
-        $label5   = __( 'Is this field required?', 'invoicing' );
409
+        $label5   = __('Is this field required?', 'invoicing');
410 410
         $id4      = $field . '.id + "_edit4"';
411 411
         echo "
412 412
             <div $restrict>
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
     /**
435 435
      * Renders the textarea element template.
436 436
      */
437
-    public function render_textarea_template( $field ) {
438
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
437
+    public function render_textarea_template($field) {
438
+        $restrict = $this->get_restrict_markup($field, 'textarea');
439 439
         $label    = "$field.label";
440 440
         echo "
441 441
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -450,16 +450,16 @@  discard block
 block discarded – undo
450 450
     /**
451 451
      * Renders the edit textarea element template.
452 452
      */
453
-    public function edit_textarea_template( $field ) {
454
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
455
-        $label    = __( 'Field Label', 'invoicing' );
453
+    public function edit_textarea_template($field) {
454
+        $restrict = $this->get_restrict_markup($field, 'textarea');
455
+        $label    = __('Field Label', 'invoicing');
456 456
         $id       = $field . '.id + "_edit"';
457
-        $label2   = __( 'Placeholder text', 'invoicing' );
457
+        $label2   = __('Placeholder text', 'invoicing');
458 458
         $id2      = $field . '.id + "_edit2"';
459
-        $label3   = __( 'Help text', 'invoicing' );
460
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
459
+        $label3   = __('Help text', 'invoicing');
460
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
461 461
         $id3      = $field . '.id + "_edit3"';
462
-        $label5   = __( 'Is this field required?', 'invoicing' );
462
+        $label5   = __('Is this field required?', 'invoicing');
463 463
         $id4      = $field . '.id + "_edit4"';
464 464
         echo "
465 465
             <div $restrict>
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
     /**
488 488
      * Renders the select element template.
489 489
      */
490
-    public function render_select_template( $field ) {
491
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
490
+    public function render_select_template($field) {
491
+        $restrict    = $this->get_restrict_markup($field, 'select');
492 492
         $label       = "$field.label";
493 493
         $placeholder = "$field.placeholder";
494 494
         $id          = $field . '.id';
@@ -508,18 +508,18 @@  discard block
 block discarded – undo
508 508
     /**
509 509
      * Renders the edit select element template.
510 510
      */
511
-    public function edit_select_template( $field ) {
512
-        $restrict = $this->get_restrict_markup( $field, 'select' );
513
-        $label    = __( 'Field Label', 'invoicing' );
511
+    public function edit_select_template($field) {
512
+        $restrict = $this->get_restrict_markup($field, 'select');
513
+        $label    = __('Field Label', 'invoicing');
514 514
         $id       = $field . '.id + "_edit"';
515
-        $label2   = __( 'Placeholder text', 'invoicing' );
515
+        $label2   = __('Placeholder text', 'invoicing');
516 516
         $id2      = $field . '.id + "_edit2"';
517
-        $label3   = __( 'Help text', 'invoicing' );
518
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
517
+        $label3   = __('Help text', 'invoicing');
518
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
519 519
         $id3      = $field . '.id + "_edit3"';
520
-        $label5   = __( 'Is this field required?', 'invoicing' );
520
+        $label5   = __('Is this field required?', 'invoicing');
521 521
         $id4      = $field . '.id + "_edit4"';
522
-        $label6   = __( 'Available Options', 'invoicing' );
522
+        $label6   = __('Available Options', 'invoicing');
523 523
         echo "
524 524
             <div $restrict>
525 525
                 <div class='form-group'>
@@ -557,8 +557,8 @@  discard block
 block discarded – undo
557 557
     /**
558 558
      * Renders the checkbox element template.
559 559
      */
560
-    public function render_checkbox_template( $field ) {
561
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
560
+    public function render_checkbox_template($field) {
561
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
562 562
         echo "
563 563
             <div class='form-check' $restrict>
564 564
                 <div class='wpinv-payment-form-field-preview-overlay'></div>
@@ -572,14 +572,14 @@  discard block
 block discarded – undo
572 572
     /**
573 573
      * Renders the edit checkbox element template.
574 574
      */
575
-    public function edit_checkbox_template( $field ) {
576
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
577
-        $label    = __( 'Field Label', 'invoicing' );
575
+    public function edit_checkbox_template($field) {
576
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
577
+        $label    = __('Field Label', 'invoicing');
578 578
         $id       = $field . '.id + "_edit"';
579
-        $label2   = __( 'Help text', 'invoicing' );
580
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
579
+        $label2   = __('Help text', 'invoicing');
580
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
581 581
         $id2      = $field . '.id + "_edit2"';
582
-        $label4   = __( 'Is this field required?', 'invoicing' );
582
+        $label4   = __('Is this field required?', 'invoicing');
583 583
         $id3      = $field . '.id + "_edit3"';
584 584
         echo "
585 585
             <div $restrict>
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
     /**
604 604
      * Renders the radio element template.
605 605
      */
606
-    public function render_radio_template( $field ) {
607
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
606
+    public function render_radio_template($field) {
607
+        $restrict    = $this->get_restrict_markup($field, 'radio');
608 608
         $label       = "$field.label";
609 609
         $id          = $field . '.id';
610 610
         echo "
@@ -623,16 +623,16 @@  discard block
 block discarded – undo
623 623
     /**
624 624
      * Renders the edit radio element template.
625 625
      */
626
-    public function edit_radio_template( $field ) {
627
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
628
-        $label    = __( 'Field Label', 'invoicing' );
626
+    public function edit_radio_template($field) {
627
+        $restrict = $this->get_restrict_markup($field, 'radio');
628
+        $label    = __('Field Label', 'invoicing');
629 629
         $id       = $field . '.id + "_edit"';
630
-        $label2   = __( 'Help text', 'invoicing' );
631
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
630
+        $label2   = __('Help text', 'invoicing');
631
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
632 632
         $id2      = $field . '.id + "_edit3"';
633
-        $label4   = __( 'Is this field required?', 'invoicing' );
633
+        $label4   = __('Is this field required?', 'invoicing');
634 634
         $id3      = $field . '.id + "_edit4"';
635
-        $label5   = __( 'Available Options', 'invoicing' );
635
+        $label5   = __('Available Options', 'invoicing');
636 636
         echo "
637 637
             <div $restrict>
638 638
                 <div class='form-group'>
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
     /**
667 667
      * Renders the address element template.
668 668
      */
669
-    public function render_address_template( $field ) {
670
-        $restrict    = $this->get_restrict_markup( $field, 'address' );
669
+    public function render_address_template($field) {
670
+        $restrict = $this->get_restrict_markup($field, 'address');
671 671
 
672 672
         echo "
673 673
             <div class='wpinv-address-wrapper' $restrict>
@@ -689,13 +689,13 @@  discard block
 block discarded – undo
689 689
     /**
690 690
      * Renders the edit address element template.
691 691
      */
692
-    public function edit_address_template( $field ) {
693
-        $restrict  = $this->get_restrict_markup( $field, 'address' );
694
-        $label     = __( 'Field Label', 'invoicing' );
695
-        $label2    = __( 'Placeholder', 'invoicing' );
696
-        $label3    = __( 'Description', 'invoicing' );
697
-        $label4    = __( 'Is required', 'invoicing' );
698
-        $label5    = __( 'Is visible', 'invoicing' );
692
+    public function edit_address_template($field) {
693
+        $restrict  = $this->get_restrict_markup($field, 'address');
694
+        $label     = __('Field Label', 'invoicing');
695
+        $label2    = __('Placeholder', 'invoicing');
696
+        $label3    = __('Description', 'invoicing');
697
+        $label4    = __('Is required', 'invoicing');
698
+        $label5    = __('Is visible', 'invoicing');
699 699
         $id        = $field . '.id + "_edit_label"';
700 700
         $id2       = $field . '.id + "_edit_placeholder"';
701 701
         $id3       = $field . '.id + "_edit_description"';
@@ -763,8 +763,8 @@  discard block
 block discarded – undo
763 763
     /**
764 764
      * Renders the email element template.
765 765
      */
766
-    public function render_email_template( $field ) {
767
-        $restrict = $this->get_restrict_markup( $field, 'email' );
766
+    public function render_email_template($field) {
767
+        $restrict = $this->get_restrict_markup($field, 'email');
768 768
         $label    = "$field.label";
769 769
         echo "
770 770
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
     /**
780 780
      * Renders the billing_email element template.
781 781
      */
782
-    public function render_billing_email_template( $field ) {
783
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
782
+    public function render_billing_email_template($field) {
783
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
784 784
         $label    = "$field.label";
785 785
         echo "
786 786
             <div $restrict>
@@ -794,16 +794,16 @@  discard block
 block discarded – undo
794 794
     /**
795 795
      * Renders the edit email element template.
796 796
      */
797
-    public function edit_email_template( $field ) {
798
-        $restrict = $this->get_restrict_markup( $field, 'email' );
799
-        $label    = __( 'Field Label', 'invoicing' );
797
+    public function edit_email_template($field) {
798
+        $restrict = $this->get_restrict_markup($field, 'email');
799
+        $label    = __('Field Label', 'invoicing');
800 800
         $id       = $field . '.id + "_edit"';
801
-        $label2   = __( 'Placeholder text', 'invoicing' );
801
+        $label2   = __('Placeholder text', 'invoicing');
802 802
         $id2      = $field . '.id + "_edit2"';
803
-        $label3   = __( 'Help text', 'invoicing' );
804
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
803
+        $label3   = __('Help text', 'invoicing');
804
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
805 805
         $id3      = $field . '.id + "_edit3"';
806
-        $label5   = __( 'Is this field required?', 'invoicing' );
806
+        $label5   = __('Is this field required?', 'invoicing');
807 807
         $id4      = $field . '.id + "_edit4"';
808 808
         echo "
809 809
             <div $restrict>
@@ -831,16 +831,16 @@  discard block
 block discarded – undo
831 831
     /**
832 832
      * Renders the edit billing_email element template.
833 833
      */
834
-    public function edit_billing_email_template( $field ) {
835
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
836
-        $label    = __( 'Field Label', 'invoicing' );
834
+    public function edit_billing_email_template($field) {
835
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
836
+        $label    = __('Field Label', 'invoicing');
837 837
         $id       = $field . '.id + "_edit"';
838
-        $label2   = __( 'Placeholder text', 'invoicing' );
838
+        $label2   = __('Placeholder text', 'invoicing');
839 839
         $id2      = $field . '.id + "_edit2"';
840
-        $label3   = __( 'Help text', 'invoicing' );
841
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
840
+        $label3   = __('Help text', 'invoicing');
841
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
842 842
         $id3      = $field . '.id + "_edit3"';
843
-        $label5   = __( 'Is this field required?', 'invoicing' );
843
+        $label5   = __('Is this field required?', 'invoicing');
844 844
         $id4      = $field . '.id + "_edit4"';
845 845
         echo "
846 846
             <div $restrict>
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
     /**
865 865
      * Renders the website element template.
866 866
      */
867
-    public function render_website_template( $field ) {
868
-        $restrict = $this->get_restrict_markup( $field, 'website' );
867
+    public function render_website_template($field) {
868
+        $restrict = $this->get_restrict_markup($field, 'website');
869 869
         $label    = "$field.label";
870 870
         echo "
871 871
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -880,16 +880,16 @@  discard block
 block discarded – undo
880 880
     /**
881 881
      * Renders the edit website element template.
882 882
      */
883
-    public function edit_website_template( $field ) {
884
-        $restrict = $this->get_restrict_markup( $field, 'website' );
885
-        $label    = __( 'Field Label', 'invoicing' );
883
+    public function edit_website_template($field) {
884
+        $restrict = $this->get_restrict_markup($field, 'website');
885
+        $label    = __('Field Label', 'invoicing');
886 886
         $id       = $field . '.id + "_edit"';
887
-        $label2   = __( 'Placeholder text', 'invoicing' );
887
+        $label2   = __('Placeholder text', 'invoicing');
888 888
         $id2      = $field . '.id + "_edit2"';
889
-        $label3   = __( 'Help text', 'invoicing' );
890
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
889
+        $label3   = __('Help text', 'invoicing');
890
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
891 891
         $id3      = $field . '.id + "_edit3"';
892
-        $label5   = __( 'Is this field required?', 'invoicing' );
892
+        $label5   = __('Is this field required?', 'invoicing');
893 893
         $id4      = $field . '.id + "_edit4"';
894 894
         echo "
895 895
             <div $restrict>
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
     /**
918 918
      * Renders the date element template.
919 919
      */
920
-    public function render_date_template( $field ) {
921
-        $restrict = $this->get_restrict_markup( $field, 'date' );
920
+    public function render_date_template($field) {
921
+        $restrict = $this->get_restrict_markup($field, 'date');
922 922
         $label    = "$field.label";
923 923
         echo "
924 924
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
     /**
934 934
      * Renders the edit date element template.
935 935
      */
936
-    public function edit_date_template( $field ) {
937
-        $restrict = $this->get_restrict_markup( $field, 'date' );
938
-        $label    = __( 'Field Label', 'invoicing' );
936
+    public function edit_date_template($field) {
937
+        $restrict = $this->get_restrict_markup($field, 'date');
938
+        $label    = __('Field Label', 'invoicing');
939 939
         $id       = $field . '.id + "_edit"';
940
-        $label3   = __( 'Help text', 'invoicing' );
941
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
940
+        $label3   = __('Help text', 'invoicing');
941
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
942 942
         $id3      = $field . '.id + "_edit3"';
943
-        $label5   = __( 'Is this field required?', 'invoicing' );
943
+        $label5   = __('Is this field required?', 'invoicing');
944 944
         $id4      = $field . '.id + "_edit4"';
945 945
         echo "
946 946
             <div $restrict>
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
     /**
965 965
      * Renders the time element template.
966 966
      */
967
-    public function render_time_template( $field ) {
968
-        $restrict = $this->get_restrict_markup( $field, 'time' );
967
+    public function render_time_template($field) {
968
+        $restrict = $this->get_restrict_markup($field, 'time');
969 969
         $label    = "$field.label";
970 970
         echo "
971 971
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -980,14 +980,14 @@  discard block
 block discarded – undo
980 980
     /**
981 981
      * Renders the edit time element template.
982 982
      */
983
-    public function edit_time_template( $field ) {
984
-        $restrict = $this->get_restrict_markup( $field, 'time' );
985
-        $label    = __( 'Field Label', 'invoicing' );
983
+    public function edit_time_template($field) {
984
+        $restrict = $this->get_restrict_markup($field, 'time');
985
+        $label    = __('Field Label', 'invoicing');
986 986
         $id       = $field . '.id + "_edit"';
987
-        $label3   = __( 'Help text', 'invoicing' );
988
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
987
+        $label3   = __('Help text', 'invoicing');
988
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
989 989
         $id3      = $field . '.id + "_edit3"';
990
-        $label5   = __( 'Is this field required?', 'invoicing' );
990
+        $label5   = __('Is this field required?', 'invoicing');
991 991
         $id4      = $field . '.id + "_edit4"';
992 992
         echo "
993 993
             <div $restrict>
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
     /**
1012 1012
      * Renders the number element template.
1013 1013
      */
1014
-    public function render_number_template( $field ) {
1015
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1014
+    public function render_number_template($field) {
1015
+        $restrict = $this->get_restrict_markup($field, 'number');
1016 1016
         $label    = "$field.label";
1017 1017
         echo "
1018 1018
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1027,16 +1027,16 @@  discard block
 block discarded – undo
1027 1027
     /**
1028 1028
      * Renders the edit number element template.
1029 1029
      */
1030
-    public function edit_number_template( $field ) {
1031
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1032
-        $label    = __( 'Field Label', 'invoicing' );
1030
+    public function edit_number_template($field) {
1031
+        $restrict = $this->get_restrict_markup($field, 'number');
1032
+        $label    = __('Field Label', 'invoicing');
1033 1033
         $id       = $field . '.id + "_edit"';
1034
-        $label2   = __( 'Placeholder text', 'invoicing' );
1034
+        $label2   = __('Placeholder text', 'invoicing');
1035 1035
         $id2      = $field . '.id + "_edit2"';
1036
-        $label3   = __( 'Help text', 'invoicing' );
1037
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1036
+        $label3   = __('Help text', 'invoicing');
1037
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1038 1038
         $id3      = $field . '.id + "_edit3"';
1039
-        $label5   = __( 'Is this field required?', 'invoicing' );
1039
+        $label5   = __('Is this field required?', 'invoicing');
1040 1040
         $id4      = $field . '.id + "_edit4"';
1041 1041
         echo "
1042 1042
             <div $restrict>
@@ -1064,16 +1064,16 @@  discard block
 block discarded – undo
1064 1064
     /**
1065 1065
      * Renders the separator element template.
1066 1066
      */
1067
-    public function render_separator_template( $field ) {
1068
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
1067
+    public function render_separator_template($field) {
1068
+        $restrict = $this->get_restrict_markup($field, 'separator');
1069 1069
         echo "<hr class='featurette-divider' $restrict>";
1070 1070
     }
1071 1071
 
1072 1072
     /**
1073 1073
      * Renders the pay button element template.
1074 1074
      */
1075
-    public function render_pay_button_template( $field ) {
1076
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1075
+    public function render_pay_button_template($field) {
1076
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1077 1077
         $label    = "$field.label";
1078 1078
         echo "
1079 1079
             <div $restrict>
@@ -1086,14 +1086,14 @@  discard block
 block discarded – undo
1086 1086
     /**
1087 1087
      * Renders the pay button element template.
1088 1088
      */
1089
-    public function edit_pay_button_template( $field ) {
1090
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1091
-        $label    = __( 'Button Text', 'invoicing' );
1089
+    public function edit_pay_button_template($field) {
1090
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1091
+        $label    = __('Button Text', 'invoicing');
1092 1092
         $id       = $field . '.id + "_edit"';
1093
-        $label2   = __( 'Help text', 'invoicing' );
1094
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1093
+        $label2   = __('Help text', 'invoicing');
1094
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1095 1095
         $id2      = $field . '.id + "_edit2"';
1096
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
1096
+        $label4   = esc_attr__('Button Type', 'invoicing');
1097 1097
         $id3      = $field . '.id + "_edit3"';
1098 1098
 
1099 1099
         echo "
@@ -1110,15 +1110,15 @@  discard block
 block discarded – undo
1110 1110
                     <label :for='$id3'>$label4</label>
1111 1111
 
1112 1112
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1113
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1114
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1115
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1116
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1117
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1118
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1119
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1120
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1121
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
1113
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
1114
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
1115
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
1116
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
1117
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
1118
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
1119
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
1120
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
1121
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
1122 1122
                     </select>
1123 1123
                 </div>
1124 1124
             </div>
@@ -1129,8 +1129,8 @@  discard block
 block discarded – undo
1129 1129
     /**
1130 1130
      * Renders the alert element template.
1131 1131
      */
1132
-    public function render_alert_template( $field ) {
1133
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1132
+    public function render_alert_template($field) {
1133
+        $restrict = $this->get_restrict_markup($field, 'alert');
1134 1134
         $text     = "$field.text";
1135 1135
         echo "
1136 1136
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -1145,14 +1145,14 @@  discard block
 block discarded – undo
1145 1145
     /**
1146 1146
      * Renders the alert element template.
1147 1147
      */
1148
-    public function edit_alert_template( $field ) {
1149
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1150
-        $label    = __( 'Alert Text', 'invoicing' );
1151
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
1148
+    public function edit_alert_template($field) {
1149
+        $restrict = $this->get_restrict_markup($field, 'alert');
1150
+        $label    = __('Alert Text', 'invoicing');
1151
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
1152 1152
         $id       = $field . '.id + "_edit"';
1153
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
1153
+        $label3   = __('Is Dismissible?', 'invoicing');
1154 1154
         $id2      = $field . '.id + "_edit2"';
1155
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
1155
+        $label4   = esc_attr__('Alert Type', 'invoicing');
1156 1156
         $id3      = $field . '.id + "_edit3"';
1157 1157
         echo "
1158 1158
             <div $restrict>
@@ -1168,14 +1168,14 @@  discard block
 block discarded – undo
1168 1168
                     <label :for='$id3'>$label4</label>
1169 1169
 
1170 1170
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1171
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1172
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1173
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1174
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1175
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1176
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1177
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1178
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1171
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
1172
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
1173
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
1174
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
1175
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
1176
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
1177
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
1178
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
1179 1179
                     </select>
1180 1180
                 </div>
1181 1181
             </div>
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
     /**
1187 1187
      * Renders the discount element template.
1188 1188
      */
1189
-    public function render_discount_template( $field ) {
1190
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
1189
+    public function render_discount_template($field) {
1190
+        $restrict = $this->get_restrict_markup($field, 'discount');
1191 1191
         ?>
1192 1192
 
1193 1193
             <div <?php echo $restrict; ?> class="discount_field border rounded p-3 wpinv-payment-form-field-preview">
@@ -1205,12 +1205,12 @@  discard block
 block discarded – undo
1205 1205
     /**
1206 1206
      * Renders the discount element template.
1207 1207
      */
1208
-    public function edit_discount_template( $field ) {
1209
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
1210
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
1211
-        $label2   = __( 'Help Text', 'invoicing' );
1212
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1213
-        $label4   = __( 'Button Text', 'invoicing' );
1208
+    public function edit_discount_template($field) {
1209
+        $restrict = $this->get_restrict_markup($field, 'discount');
1210
+        $label    = __('Discount Input Placeholder', 'invoicing');
1211
+        $label2   = __('Help Text', 'invoicing');
1212
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1213
+        $label4   = __('Button Text', 'invoicing');
1214 1214
         $id       = $field . '.id + "_edit"';
1215 1215
         $id2      = $field . '.id + "_edit2"';
1216 1216
         $id3      = $field . '.id + "_edit3"';
@@ -1239,17 +1239,17 @@  discard block
 block discarded – undo
1239 1239
     /**
1240 1240
      * Renders the items element template.
1241 1241
      */
1242
-    public function render_items_template( $field ) {
1243
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
1242
+    public function render_items_template($field) {
1243
+        $restrict = $this->get_restrict_markup($field, 'items');
1244 1244
         ?>
1245 1245
 
1246 1246
         <div <?php echo $restrict; ?> class='item_totals'>
1247 1247
             <div v-if='!is_default'>
1248
-                <div v-if='! canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here. Click to set items.', 'invoicing' ) ?></div>
1249
-                <div v-if='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-danger' role='alert'><?php _e( 'Your form allows customers to buy several recurring items. This is not supported and might lead to unexpected behaviour.', 'invoicing' ); ?></div>
1248
+                <div v-if='! canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-info' role='alert'><?php _e('Item totals will appear here. Click to set items.', 'invoicing') ?></div>
1249
+                <div v-if='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-danger' role='alert'><?php _e('Your form allows customers to buy several recurring items. This is not supported and might lead to unexpected behaviour.', 'invoicing'); ?></div>
1250 1250
             </div>
1251 1251
             <div v-if='is_default'>
1252
-                <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here.', 'invoicing' ) ?></div>
1252
+                <div class='alert alert-info' role='alert'><?php _e('Item totals will appear here.', 'invoicing') ?></div>
1253 1253
             </div>
1254 1254
         </div>
1255 1255
 
@@ -1259,25 +1259,25 @@  discard block
 block discarded – undo
1259 1259
     /**
1260 1260
      * Renders the items element template.
1261 1261
      */
1262
-    public function edit_items_template( $field ) {
1262
+    public function edit_items_template($field) {
1263 1263
         global $wpinv_euvat, $post;
1264 1264
 
1265
-        $restrict = $this->get_restrict_markup( $field, 'items' );
1265
+        $restrict = $this->get_restrict_markup($field, 'items');
1266 1266
         $id2      = $field . '.id + "_edit2"';
1267 1267
         $id3      = $field . '.id + "_edit3"';
1268 1268
 
1269 1269
         // Item types.
1270
-        $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
1270
+        $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
1271 1271
 
1272 1272
         ?>
1273 1273
         <div <?php echo $restrict; ?>>
1274 1274
             <div v-if="!is_default">
1275 1275
                 <label class='form-group'>
1276 1276
                     <input v-model='<?php echo $field; ?>.hide_cart' type='checkbox' />
1277
-                    <span class='form-check-label'><?php _e( 'Hide cart details', 'invoicing' ); ?></span>
1277
+                    <span class='form-check-label'><?php _e('Hide cart details', 'invoicing'); ?></span>
1278 1278
                 </label>
1279 1279
 
1280
-                <div class="mb-1"><?php _e( 'Form Items', 'invoicing' ); ?></div>
1280
+                <div class="mb-1"><?php _e('Form Items', 'invoicing'); ?></div>
1281 1281
                 <draggable v-model='form_items' group='selectable_form_items'>
1282 1282
                     <div class='wpinv-available-items-editor' v-for='(item, index) in form_items' :class="'item_' + item.id" :key="item.id">
1283 1283
 
@@ -1295,35 +1295,35 @@  discard block
 block discarded – undo
1295 1295
 
1296 1296
                                 <div class="form-group" v-if="! item.new">
1297 1297
                                     <span class='form-text'>
1298
-                                        <a target="_blank" :href="'<?php echo esc_url( admin_url( '/post.php?action=edit&post' ) ) ?>=' + item.id">
1299
-                                            <?php _e( 'Edit the item name, price and other details', 'invoicing' ); ?>
1298
+                                        <a target="_blank" :href="'<?php echo esc_url(admin_url('/post.php?action=edit&post')) ?>=' + item.id">
1299
+                                            <?php _e('Edit the item name, price and other details', 'invoicing'); ?>
1300 1300
                                         </a>
1301 1301
                                     </span>
1302 1302
                                 </div>
1303 1303
 
1304 1304
                                 <div class='form-group' v-if="item.new">
1305 1305
                                     <label class='mb-0 w-100'>
1306
-                                        <span><?php _e( 'Item Name', 'invoicing' ); ?></span>
1306
+                                        <span><?php _e('Item Name', 'invoicing'); ?></span>
1307 1307
                                         <input v-model='item.title' type='text' class='w-100'/>
1308 1308
                                     </label>
1309 1309
                                 </div>
1310 1310
 
1311 1311
                                 <div class='form-group'  v-if="item.new">
1312 1312
                                     <label class='mb-0 w-100'>
1313
-                                        <span v-if='!item.custom_price'><?php _e( 'Item Price', 'invoicing' ); ?></span>
1314
-                                        <span v-if='item.custom_price'><?php _e( 'Recommended Price', 'invoicing' ); ?></span>
1313
+                                        <span v-if='!item.custom_price'><?php _e('Item Price', 'invoicing'); ?></span>
1314
+                                        <span v-if='item.custom_price'><?php _e('Recommended Price', 'invoicing'); ?></span>
1315 1315
                                         <input v-model='item.price' type='text' class='w-100'/>
1316 1316
                                     </label>
1317 1317
                                 </div>
1318 1318
 
1319 1319
                                 <div class='form-group' v-if='item.new'>
1320 1320
                                     <label :for="'edit_item_type' + item.id" class='mb-0 w-100'>
1321
-                                        <span><?php _e( 'Item Type', 'invoicing' ); ?></span>
1321
+                                        <span><?php _e('Item Type', 'invoicing'); ?></span>
1322 1322
                                         <select class='w-100' v-model='item.type'>
1323 1323
                                             <?php
1324
-                                                foreach ( $item_types as $type => $_label ) {
1325
-                                                    $type  = esc_attr( $type );
1326
-                                                    $_label = esc_html( $_label );
1324
+                                                foreach ($item_types as $type => $_label) {
1325
+                                                    $type = esc_attr($type);
1326
+                                                    $_label = esc_html($_label);
1327 1327
                                                     echo "<option value='$type'>$_label</type>";
1328 1328
                                                 }
1329 1329
                                             ?>
@@ -1332,71 +1332,71 @@  discard block
 block discarded – undo
1332 1332
                                 </div>
1333 1333
 
1334 1334
                                 <div v-if='item.new'>
1335
-                                    <?php if ( $wpinv_euvat->allow_vat_rules() ) : ?>
1335
+                                    <?php if ($wpinv_euvat->allow_vat_rules()) : ?>
1336 1336
                                         <div class='form-group'>
1337
-                                            <label class='w-100 mb-0'><?php _e( 'VAT Rule', 'invoicing' ) ; ?>
1337
+                                            <label class='w-100 mb-0'><?php _e('VAT Rule', 'invoicing'); ?>
1338 1338
                                                 <select class='w-100' v-model='item.rule'>
1339 1339
                                                     <?php
1340
-                                                        foreach ( $wpinv_euvat->get_rules() as $type => $_label ) {
1341
-                                                            $type  = esc_attr( $type );
1342
-                                                            $_label = esc_html( $_label );
1340
+                                                        foreach ($wpinv_euvat->get_rules() as $type => $_label) {
1341
+                                                            $type = esc_attr($type);
1342
+                                                            $_label = esc_html($_label);
1343 1343
                                                             echo "<option value='$type'>$_label</type>";
1344 1344
                                                         }
1345 1345
                                                     ?>
1346 1346
                                                 </select>
1347 1347
                                             </label>
1348 1348
                                         </div>
1349
-                                    <?php endif;?>
1349
+                                    <?php endif; ?>
1350 1350
 
1351
-                                    <?php if ( $wpinv_euvat->allow_vat_classes() ) : ?>
1351
+                                    <?php if ($wpinv_euvat->allow_vat_classes()) : ?>
1352 1352
                                         <div class='form-group'>
1353
-                                            <label class='w-100 mb-0'><?php _e( 'VAT class', 'invoicing' ) ; ?>
1353
+                                            <label class='w-100 mb-0'><?php _e('VAT class', 'invoicing'); ?>
1354 1354
                                                 <select class='w-100' v-model='item.class'>
1355 1355
                                                     <?php
1356
-                                                        foreach ( $wpinv_euvat->get_all_classes() as $type => $_label ) {
1357
-                                                            $type  = esc_attr( $type );
1358
-                                                            $_label = esc_html( $_label );
1356
+                                                        foreach ($wpinv_euvat->get_all_classes() as $type => $_label) {
1357
+                                                            $type = esc_attr($type);
1358
+                                                            $_label = esc_html($_label);
1359 1359
                                                             echo "<option value='$type'>$_label</type>"; 
1360 1360
                                                         }
1361 1361
                                                     ?>
1362 1362
                                                 </select>
1363 1363
                                             </label>
1364 1364
                                         </div>
1365
-                                    <?php endif;?>
1365
+                                    <?php endif; ?>
1366 1366
                                                         
1367 1367
                                 </div>
1368 1368
 
1369 1369
                                 <label v-if='item.new' class='form-group'>
1370 1370
                                     <input v-model='item.custom_price' type='checkbox' />
1371
-                                    <span class='form-check-label'><?php _e( 'Allow users to pay what they want', 'invoicing' ); ?></span>
1371
+                                    <span class='form-check-label'><?php _e('Allow users to pay what they want', 'invoicing'); ?></span>
1372 1372
                                 </label>
1373 1373
 
1374 1374
                                 <div class='form-group' v-if='item.new && item.custom_price'>
1375 1375
                                     <label class='mb-0 w-100'>
1376
-                                        <span><?php _e( 'Minimum Price', 'invoicing' ); ?></span>
1376
+                                        <span><?php _e('Minimum Price', 'invoicing'); ?></span>
1377 1377
                                         <input placeholder='0.00' v-model='item.minimum_price' class='w-100' />
1378
-                                        <small class='form-text text-muted'><?php _e( 'Enter the minimum price that a user can pay', 'invoicing' ); ?></small>
1378
+                                        <small class='form-text text-muted'><?php _e('Enter the minimum price that a user can pay', 'invoicing'); ?></small>
1379 1379
                                     </label>
1380 1380
                                 </div>
1381 1381
 
1382 1382
                                 <label class='form-group'>
1383 1383
                                     <input v-model='item.allow_quantities' type='checkbox' />
1384
-                                    <span><?php _e( 'Allow users to buy several quantities', 'invoicing' ); ?></span>
1384
+                                    <span><?php _e('Allow users to buy several quantities', 'invoicing'); ?></span>
1385 1385
                                 </label>
1386 1386
 
1387 1387
                                 <label class='form-group'>
1388 1388
                                     <input v-model='item.required' type='checkbox' />
1389
-                                    <span><?php _e( 'This item is required', 'invoicing' ); ?></span>
1389
+                                    <span><?php _e('This item is required', 'invoicing'); ?></span>
1390 1390
                                 </label>
1391 1391
 
1392 1392
                                 <div class='form-group'>
1393 1393
                                     <label class="mb-0 w-100">
1394
-                                        <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
1394
+                                        <span><?php _e('Item Description', 'invoicing'); ?></span>
1395 1395
                                         <textarea v-model='item.description' class='w-100'></textarea>
1396 1396
                                     </label>
1397 1397
                                 </div>
1398 1398
 
1399
-                                    <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'><?php _e( 'Delete Item', 'invoicing' ); ?></button>
1399
+                                    <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'><?php _e('Delete Item', 'invoicing'); ?></button>
1400 1400
 
1401 1401
                                 </div>
1402 1402
                             </div>
@@ -1404,36 +1404,36 @@  discard block
 block discarded – undo
1404 1404
                         </div>
1405 1405
                 </draggable>
1406 1406
 
1407
-                <small v-if='! form_items.length' class='form-text text-danger'><?php _e( 'You have not set up any items. Please select an item below or create a new item.', 'invoicing' ); ?></small>
1407
+                <small v-if='! form_items.length' class='form-text text-danger'><?php _e('You have not set up any items. Please select an item below or create a new item.', 'invoicing'); ?></small>
1408 1408
 
1409 1409
                 <div class='form-group mt-2'>
1410 1410
 
1411 1411
                     <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" v-model='selected_item' @change='addSelectedItem'>
1412
-                        <option value=''><?php _e( 'Select an item to add...', 'invoicing' ) ?></option>
1412
+                        <option value=''><?php _e('Select an item to add...', 'invoicing') ?></option>
1413 1413
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
1414 1414
                     </select>
1415 1415
 
1416 1416
                 </div>
1417 1417
 
1418 1418
                 <div class='form-group'>
1419
-                    <button @click.prevent='addNewItem' class="button button-link"><?php _e( 'Or create a new item.', 'invoicing' ) ?></button>
1419
+                    <button @click.prevent='addNewItem' class="button button-link"><?php _e('Or create a new item.', 'invoicing') ?></button>
1420 1420
                 </div>
1421 1421
 
1422 1422
                 <div class='form-group mt-5'>
1423
-                    <label :for='<?php echo $id2; ?>'><?php _e( 'Let customers...', 'invoicing' ) ?></label>
1423
+                    <label :for='<?php echo $id2; ?>'><?php _e('Let customers...', 'invoicing') ?></label>
1424 1424
 
1425 1425
                     <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" :id='<?php echo $id2; ?>' v-model='<?php echo $field; ?>.items_type'>
1426
-                        <option value='total' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Buy all items on the list', 'invoicing' ); ?></option>
1427
-                        <option value='radio'><?php _e( 'Select a single item from the list', 'invoicing' ); ?></option>
1428
-                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Select one or more items on the list', 'invoicing' ) ;?></option>
1429
-                        <option value='select'><?php _e( 'Select a single item from a dropdown', 'invoicing' ); ?></option>
1426
+                        <option value='total' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e('Buy all items on the list', 'invoicing'); ?></option>
1427
+                        <option value='radio'><?php _e('Select a single item from the list', 'invoicing'); ?></option>
1428
+                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e('Select one or more items on the list', 'invoicing'); ?></option>
1429
+                        <option value='select'><?php _e('Select a single item from a dropdown', 'invoicing'); ?></option>
1430 1430
                     </select>
1431 1431
 
1432 1432
                 </div>
1433 1433
             </div>
1434 1434
             <div class='form-group'>
1435
-                <label :for='<?php echo $id3; ?>'><?php _e( 'Help Text', 'invoicing' ); ?></label>
1436
-                <textarea placeholder='<?php esc_attr_e( 'Add some help text for this element', 'invoicing' ); ?>' :id='<?php echo $id3; ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea>
1435
+                <label :for='<?php echo $id3; ?>'><?php _e('Help Text', 'invoicing'); ?></label>
1436
+                <textarea placeholder='<?php esc_attr_e('Add some help text for this element', 'invoicing'); ?>' :id='<?php echo $id3; ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea>
1437 1437
             </div>
1438 1438
 
1439 1439
         </div>
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
             'orderby'        => 'title',
1453 1453
             'order'          => 'ASC',
1454 1454
             'posts_per_page' => -1,
1455
-            'post_status'    => array( 'publish' ),
1455
+            'post_status'    => array('publish'),
1456 1456
             'meta_query'     => array(
1457 1457
                 array(
1458 1458
                     'key'       => '_wpinv_type',
@@ -1462,15 +1462,15 @@  discard block
 block discarded – undo
1462 1462
             )
1463 1463
         );
1464 1464
 
1465
-        $items = get_posts( apply_filters( 'getpaid_payment_form_item_dropdown_query_args', $item_args ) );
1465
+        $items = get_posts(apply_filters('getpaid_payment_form_item_dropdown_query_args', $item_args));
1466 1466
 
1467
-        if ( empty( $items ) ) {
1467
+        if (empty($items)) {
1468 1468
             return array();
1469 1469
         }
1470 1470
 
1471
-        $options    = array();
1472
-        foreach ( $items as $item ) {
1473
-            $item      = new GetPaid_Form_Item( $item );
1471
+        $options = array();
1472
+        foreach ($items as $item) {
1473
+            $item      = new GetPaid_Form_Item($item);
1474 1474
             $options[] = $item->prepare_data_for_use();
1475 1475
         }
1476 1476
         return $options;
@@ -1480,39 +1480,39 @@  discard block
 block discarded – undo
1480 1480
     /**
1481 1481
      * Returns an array of items for the currently being edited form.
1482 1482
      */
1483
-    public function get_form_items( $id = false ) {
1484
-        $form = new GetPaid_Payment_Form( $id );
1483
+    public function get_form_items($id = false) {
1484
+        $form = new GetPaid_Payment_Form($id);
1485 1485
 
1486 1486
         // Is this a default form?
1487
-        if ( $form->is_default() ) {
1487
+        if ($form->is_default()) {
1488 1488
             return array();
1489 1489
         }
1490 1490
 
1491
-        return $form->get_items( 'view', 'arrays' );
1491
+        return $form->get_items('view', 'arrays');
1492 1492
     }
1493 1493
 
1494 1494
     /**
1495 1495
      * Converts form items for use.
1496 1496
      */
1497
-    public function convert_checkout_items( $items, $invoice ) {
1497
+    public function convert_checkout_items($items, $invoice) {
1498 1498
 
1499 1499
         $converted = array();
1500
-        foreach ( $items as $item ) {
1500
+        foreach ($items as $item) {
1501 1501
 
1502 1502
             $item_id = $item['id'];
1503
-            $_item   = new WPInv_Item( $item_id );
1503
+            $_item   = new WPInv_Item($item_id);
1504 1504
 
1505
-            if( ! $_item ) {
1505
+            if (!$_item) {
1506 1506
                 continue;
1507 1507
             }
1508 1508
 
1509 1509
             $converted[] = array(
1510
-                'title'            => esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $_item ),
1510
+                'title'            => esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($_item),
1511 1511
                 'id'               => $item['id'],
1512 1512
                 'price'            => $item['subtotal'],
1513 1513
                 'custom_price'     => $_item->get_is_dynamic_pricing(),
1514 1514
                 'recurring'        => $_item->is_recurring(),
1515
-                'description'      => apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice ),
1515
+                'description'      => apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice),
1516 1516
                 'minimum_price'    => $_item->get_minimum_price(),
1517 1517
                 'allow_quantities' => false,
1518 1518
                 'quantity'         => $item['quantity'],
@@ -1526,27 +1526,27 @@  discard block
 block discarded – undo
1526 1526
     /**
1527 1527
      * Converts an array of id => quantity for use.
1528 1528
      */
1529
-    public function convert_normal_items( $items ) {
1529
+    public function convert_normal_items($items) {
1530 1530
 
1531 1531
         $converted = array();
1532
-        foreach ( $items as $item_id => $quantity ) {
1532
+        foreach ($items as $item_id => $quantity) {
1533 1533
 
1534
-            $item   = new WPInv_Item( $item_id );
1534
+            $item = new WPInv_Item($item_id);
1535 1535
 
1536
-            if( ! $item ) {
1536
+            if (!$item) {
1537 1537
                 continue;
1538 1538
             }
1539 1539
 
1540 1540
             $converted[] = array(
1541
-                'title'            => esc_html( $item->get_name() ) . wpinv_get_item_suffix( $item ),
1541
+                'title'            => esc_html($item->get_name()) . wpinv_get_item_suffix($item),
1542 1542
                 'id'               => $item_id,
1543 1543
                 'price'            => $item->get_price(),
1544 1544
                 'custom_price'     => $item->get_is_dynamic_pricing(),
1545 1545
                 'recurring'        => $item->is_recurring(),
1546 1546
                 'description'      => $item->get_summary(),
1547 1547
                 'minimum_price'    => $item->get_minimum_price(),
1548
-                'allow_quantities' => ! empty( $quantity ),
1549
-                'quantity'         => empty( $quantity ) ? 1 : $quantity,
1548
+                'allow_quantities' => !empty($quantity),
1549
+                'quantity'         => empty($quantity) ? 1 : $quantity,
1550 1550
                 'required'         => true,
1551 1551
             );
1552 1552
 
@@ -1559,28 +1559,28 @@  discard block
 block discarded – undo
1559 1559
     /**
1560 1560
      * Returns an array of elements for the currently being edited form.
1561 1561
      */
1562
-    public function get_form_elements( $id = false ) {
1562
+    public function get_form_elements($id = false) {
1563 1563
 
1564
-        if ( empty( $id ) ) {
1565
-            return wpinv_get_data( 'sample-payment-form' );
1564
+        if (empty($id)) {
1565
+            return wpinv_get_data('sample-payment-form');
1566 1566
         }
1567 1567
         
1568
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
1568
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
1569 1569
 
1570
-        if ( is_array( $form_elements ) ) {
1570
+        if (is_array($form_elements)) {
1571 1571
             return $form_elements;
1572 1572
         }
1573 1573
 
1574
-        return wpinv_get_data( 'sample-payment-form' );
1574
+        return wpinv_get_data('sample-payment-form');
1575 1575
     }
1576 1576
 
1577 1577
     /**
1578 1578
      * Sends a redrect response to payment details.
1579 1579
      *
1580 1580
      */
1581
-    public function send_redirect_response( $url ) {
1582
-        $url = urlencode( $url );
1583
-        wp_send_json_success( $url );
1581
+    public function send_redirect_response($url) {
1582
+        $url = urlencode($url);
1583
+        wp_send_json_success($url);
1584 1584
     }
1585 1585
 
1586 1586
     /**
@@ -1591,12 +1591,12 @@  discard block
 block discarded – undo
1591 1591
 
1592 1592
         $errors = wpinv_get_errors();
1593 1593
 
1594
-        if ( ! empty( $errors ) ) {
1594
+        if (!empty($errors)) {
1595 1595
             wpinv_print_errors();
1596 1596
             exit;
1597 1597
         }
1598 1598
 
1599
-        wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) );
1599
+        wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing'));
1600 1600
         exit;
1601 1601
 
1602 1602
     }
Please login to merge, or discard this patch.
includes/data/payment-form-elements.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@  discard block
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
     array(
17 17
         'type'     => 'heading',
18
-        'name'     => __( 'Heading', 'invoicing' ),
18
+        'name'     => __('Heading', 'invoicing'),
19 19
         'defaults' => array(
20 20
             'level' => 'h2',
21
-            'text'  => __( 'Heading', 'invoicing' ),
21
+            'text'  => __('Heading', 'invoicing'),
22 22
         )
23 23
     ),
24 24
 
25 25
     array(
26 26
         'type' => 'paragraph',
27
-        'name' => __( 'Paragraph', 'invoicing' ),
27
+        'name' => __('Paragraph', 'invoicing'),
28 28
         'defaults'  => array(
29
-            'text'  => __( 'Paragraph text', 'invoicing' ),
29
+            'text'  => __('Paragraph text', 'invoicing'),
30 30
         )
31 31
     ),
32 32
 
33 33
     array( 
34 34
         'type' => 'alert',
35
-        'name' => __( 'Alert', 'invoicing' ),
35
+        'name' => __('Alert', 'invoicing'),
36 36
         'defaults'  => array(
37 37
             'value'        => '',
38 38
             'class'        => 'alert-warning',
39
-            'text'         => __( 'Alert', 'invoicing' ),
39
+            'text'         => __('Alert', 'invoicing'),
40 40
             'dismissible'  => false,
41 41
         )
42 42
     ),
43 43
 
44 44
     array( 
45 45
         'type' => 'separator',
46
-        'name' => __( 'Separator', 'invoicing' ),
46
+        'name' => __('Separator', 'invoicing'),
47 47
         'defaults'  => array(
48 48
             'value'        => '',
49 49
         ),
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 
52 52
     array(
53 53
         'type' => 'text',
54
-        'name' => __( 'Text Input', 'invoicing' ),
54
+        'name' => __('Text Input', 'invoicing'),
55 55
         'defaults'  => array(
56
-            'placeholder'  => __( 'Enter some text', 'invoicing' ),
56
+            'placeholder'  => __('Enter some text', 'invoicing'),
57 57
             'value'        => '',
58
-            'label'        => __( 'Field Label', 'invoicing' ),
58
+            'label'        => __('Field Label', 'invoicing'),
59 59
             'description'  => '',
60 60
             'required'     => false,
61 61
         )
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 
64 64
     array(
65 65
         'type' => 'textarea',
66
-        'name' => __( 'Textarea', 'invoicing' ),
66
+        'name' => __('Textarea', 'invoicing'),
67 67
         'defaults'         => array(
68
-            'placeholder'  => __( 'Enter your text hear', 'invoicing' ),
68
+            'placeholder'  => __('Enter your text hear', 'invoicing'),
69 69
             'value'        => '',
70
-            'label'        => __( 'Textarea Label', 'invoicing' ),
70
+            'label'        => __('Textarea Label', 'invoicing'),
71 71
             'description'  => '',
72 72
             'required'     => false,
73 73
         )
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 
76 76
     array(
77 77
         'type' => 'select',
78
-        'name' => __( 'Dropdown', 'invoicing' ),
78
+        'name' => __('Dropdown', 'invoicing'),
79 79
         'defaults'         => array(
80
-            'placeholder'  => __( 'Select a value', 'invoicing' ),
80
+            'placeholder'  => __('Select a value', 'invoicing'),
81 81
             'value'        => '',
82
-            'label'        => __( 'Dropdown Label', 'invoicing' ),
82
+            'label'        => __('Dropdown Label', 'invoicing'),
83 83
             'description'  => '',
84 84
             'required'     => false,
85 85
             'options'      => array(
86
-                esc_attr__( 'Option One', 'invoicing' ),
87
-                esc_attr__( 'Option Two', 'invoicing' ),
88
-                esc_attr__( 'Option Three', 'invoicing' )
86
+                esc_attr__('Option One', 'invoicing'),
87
+                esc_attr__('Option Two', 'invoicing'),
88
+                esc_attr__('Option Three', 'invoicing')
89 89
             ),
90 90
         )
91 91
     ),
92 92
 
93 93
     array(
94 94
         'type' => 'checkbox',
95
-        'name' => __( 'Checkbox', 'invoicing' ),
95
+        'name' => __('Checkbox', 'invoicing'),
96 96
         'defaults'         => array(
97 97
             'value'        => '',
98
-            'label'        => __( 'Checkbox Label', 'invoicing' ),
98
+            'label'        => __('Checkbox Label', 'invoicing'),
99 99
             'description'  => '',
100 100
             'required'     => false,
101 101
         )
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 
104 104
     array( 
105 105
         'type' => 'radio',
106
-        'name' => __( 'Radio', 'invoicing' ),
106
+        'name' => __('Radio', 'invoicing'),
107 107
         'defaults'     => array(
108
-            'label'    => __( 'Select one choice', 'invoicing' ),
108
+            'label'    => __('Select one choice', 'invoicing'),
109 109
             'options'  => array(
110
-                esc_attr__( 'Choice One', 'invoicing' ),
111
-                esc_attr__( 'Choice Two', 'invoicing' ),
112
-                esc_attr__( 'Choice Three', 'invoicing' )
110
+                esc_attr__('Choice One', 'invoicing'),
111
+                esc_attr__('Choice Two', 'invoicing'),
112
+                esc_attr__('Choice Three', 'invoicing')
113 113
             ),
114 114
         )
115 115
     ),
116 116
 
117 117
     array( 
118 118
         'type' => 'date',
119
-        'name' => __( 'Date', 'invoicing' ),
119
+        'name' => __('Date', 'invoicing'),
120 120
         'defaults' => array(
121 121
             'value'        => '',
122
-            'label'        => __( 'Date', 'invoicing' ),
122
+            'label'        => __('Date', 'invoicing'),
123 123
             'description'  => '',
124 124
             'required'     => false,
125 125
         )
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 
128 128
     array( 
129 129
         'type' => 'time',
130
-        'name' => __( 'Time', 'invoicing' ),
130
+        'name' => __('Time', 'invoicing'),
131 131
         'defaults' => array(
132 132
             'value'        => '',
133
-            'label'        => __( 'Time', 'invoicing' ),
133
+            'label'        => __('Time', 'invoicing'),
134 134
             'description'  => '',
135 135
             'required'     => false,
136 136
         )
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 
139 139
     array( 
140 140
         'type' => 'number',
141
-        'name' => __( 'Number', 'invoicing' ),
141
+        'name' => __('Number', 'invoicing'),
142 142
         'defaults' => array(
143 143
             'placeholder'  => '',
144 144
             'value'        => '',
145
-            'label'        => __( 'Number', 'invoicing' ),
145
+            'label'        => __('Number', 'invoicing'),
146 146
             'description'  => '',
147 147
             'required'     => false,
148 148
         )
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 
151 151
     array( 
152 152
         'type' => 'website',
153
-        'name' => __( 'Website', 'invoicing' ),
153
+        'name' => __('Website', 'invoicing'),
154 154
         'defaults' => array(
155 155
             'placeholder'  => 'http://example.com',
156 156
             'value'        => '',
157
-            'label'        => __( 'Website', 'invoicing' ),
157
+            'label'        => __('Website', 'invoicing'),
158 158
             'description'  => '',
159 159
             'required'     => false,
160 160
         )
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
     array( 
164 164
         'type' => 'email',
165
-        'name' => __( 'Email', 'invoicing' ),
165
+        'name' => __('Email', 'invoicing'),
166 166
         'defaults'  => array(
167 167
             'placeholder'  => '[email protected]',
168 168
             'value'        => '',
169
-            'label'        => __( 'Email Address', 'invoicing' ),
169
+            'label'        => __('Email Address', 'invoicing'),
170 170
             'description'  => '',
171 171
             'required'     => false,
172 172
         )
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 
175 175
     array( 
176 176
         'type' => 'address',
177
-        'name' => __( 'Address', 'invoicing' ),
177
+        'name' => __('Address', 'invoicing'),
178 178
         'defaults'  => array(
179 179
 
180 180
             'fields' => array(
181 181
                 array(
182 182
                     'placeholder'  => 'Jon',
183 183
                     'value'        => '',
184
-                    'label'        => __( 'First Name', 'invoicing' ),
184
+                    'label'        => __('First Name', 'invoicing'),
185 185
                     'description'  => '',
186 186
                     'required'     => false,
187 187
                     'visible'      => true,
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 array(
192 192
                     'placeholder'  => 'Snow',
193 193
                     'value'        => '',
194
-                    'label'        => __( 'Last Name', 'invoicing' ),
194
+                    'label'        => __('Last Name', 'invoicing'),
195 195
                     'description'  => '',
196 196
                     'required'     => false,
197 197
                     'visible'      => true,
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                 array(
202 202
                     'placeholder'  => '',
203 203
                     'value'        => '',
204
-                    'label'        => __( 'Address', 'invoicing' ),
204
+                    'label'        => __('Address', 'invoicing'),
205 205
                     'description'  => '',
206 206
                     'required'     => false,
207 207
                     'visible'      => true,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 array(
212 212
                     'placeholder'  => '',
213 213
                     'value'        => '',
214
-                    'label'        => __( 'City', 'invoicing' ),
214
+                    'label'        => __('City', 'invoicing'),
215 215
                     'description'  => '',
216 216
                     'required'     => false,
217 217
                     'visible'      => true,
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
                 ),
220 220
 
221 221
                 array(
222
-                    'placeholder'  => __( 'Select your country' ),
222
+                    'placeholder'  => __('Select your country'),
223 223
                     'value'        => '',
224
-                    'label'        => __( 'Country', 'invoicing' ),
224
+                    'label'        => __('Country', 'invoicing'),
225 225
                     'description'  => '',
226 226
                     'required'     => false,
227 227
                     'visible'      => true,
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                 ),
230 230
 
231 231
                 array(
232
-                    'placeholder'  => __( 'Choose a state', 'invoicing' ),
232
+                    'placeholder'  => __('Choose a state', 'invoicing'),
233 233
                     'value'        => '',
234
-                    'label'        => __( 'State / Province', 'invoicing' ),
234
+                    'label'        => __('State / Province', 'invoicing'),
235 235
                     'description'  => '',
236 236
                     'required'     => false,
237 237
                     'visible'      => true,
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 array(
242 242
                     'placeholder'  => '',
243 243
                     'value'        => '',
244
-                    'label'        => __( 'ZIP / Postcode', 'invoicing' ),
244
+                    'label'        => __('ZIP / Postcode', 'invoicing'),
245 245
                     'description'  => '',
246 246
                     'required'     => false,
247 247
                     'visible'      => true,
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                 array(
252 252
                     'placeholder'  => '',
253 253
                     'value'        => '',
254
-                    'label'        => __( 'Phone', 'invoicing' ),
254
+                    'label'        => __('Phone', 'invoicing'),
255 255
                     'description'  => '',
256 256
                     'required'     => false,
257 257
                     'visible'      => true,
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 array(
262 262
                     'placeholder'  => '',
263 263
                     'value'        => '',
264
-                    'label'        => __( 'Company', 'invoicing' ),
264
+                    'label'        => __('Company', 'invoicing'),
265 265
                     'description'  => '',
266 266
                     'required'     => false,
267 267
                     'visible'      => false,
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                 array(
272 272
                     'placeholder'  => '',
273 273
                     'value'        => '',
274
-                    'label'        => __( 'VAT Number', 'invoicing' ),
274
+                    'label'        => __('VAT Number', 'invoicing'),
275 275
                     'description'  => '',
276 276
                     'required'     => false,
277 277
                     'visible'      => false,
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 
284 284
     array( 
285 285
         'type' => 'billing_email',
286
-        'name' => __( 'Billing Email', 'invoicing' ),
286
+        'name' => __('Billing Email', 'invoicing'),
287 287
         'defaults'  => array(
288 288
             'placeholder'  => '[email protected]',
289 289
             'value'        => '',
290
-            'label'        => __( 'Billing Email', 'invoicing' ),
290
+            'label'        => __('Billing Email', 'invoicing'),
291 291
             'description'  => '',
292 292
             'premade'      => true,
293 293
         )
@@ -295,18 +295,18 @@  discard block
 block discarded – undo
295 295
 
296 296
     array( 
297 297
         'type' => 'discount',
298
-        'name' => __( 'Discount Input', 'invoicing' ),
298
+        'name' => __('Discount Input', 'invoicing'),
299 299
         'defaults'  => array(
300 300
             'value'        => '',
301
-            'input_label'  => __( 'Coupon Code', 'invoicing' ),
302
-            'button_label' => __( 'Apply Coupon', 'invoicing' ),
303
-            'description'  => __( 'Have a discount code? Enter it above.', 'invoicing' ),
301
+            'input_label'  => __('Coupon Code', 'invoicing'),
302
+            'button_label' => __('Apply Coupon', 'invoicing'),
303
+            'description'  => __('Have a discount code? Enter it above.', 'invoicing'),
304 304
         )
305 305
     ),
306 306
 
307 307
     array( 
308 308
         'type' => 'items',
309
-        'name' => __( 'Items', 'invoicing' ),
309
+        'name' => __('Items', 'invoicing'),
310 310
         'defaults'  => array(
311 311
             'value'        => '',
312 312
             'items_type'   => 'total',
@@ -318,21 +318,21 @@  discard block
 block discarded – undo
318 318
 
319 319
     array( 
320 320
         'type' => 'price_input',
321
-        'name' => __( 'Price Input', 'invoicing' ),
321
+        'name' => __('Price Input', 'invoicing'),
322 322
         'defaults'  => array(
323 323
             'placeholder'  => wpinv_format_amount(0),
324 324
             'value'        => wpinv_format_amount(0),
325
-            'label'        => __( 'Enter Amount', 'invoicing' ),
325
+            'label'        => __('Enter Amount', 'invoicing'),
326 326
             'description'  => '',
327 327
         )
328 328
     ),
329 329
 
330 330
     array( 
331 331
         'type' => 'price_select',
332
-        'name' => __( 'Price Select', 'invoicing' ),
332
+        'name' => __('Price Select', 'invoicing'),
333 333
         'defaults'  => array(
334 334
             'description'  => '',
335
-            'label'        => __( 'Select Amount', 'invoicing' ),
335
+            'label'        => __('Select Amount', 'invoicing'),
336 336
             'options'      => 'Option 1|10, Option 2|20',
337 337
             'placeholder'  => '',
338 338
             'select_type'  => 'select',
@@ -341,38 +341,38 @@  discard block
 block discarded – undo
341 341
 
342 342
     array( 
343 343
         'type'       => 'pay_button',
344
-        'name'       => __( 'Payment Button', 'invoicing' ),
344
+        'name'       => __('Payment Button', 'invoicing'),
345 345
         'defaults'   => array(
346 346
             'value'          => '',
347 347
             'class'          => 'btn-primary',
348
-            'label'          => __( 'Pay Now »', 'invoicing' ),
349
-            'description'    => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
348
+            'label'          => __('Pay Now »', 'invoicing'),
349
+            'description'    => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
350 350
             'premade'        => true,
351 351
         )
352 352
     ),
353 353
 
354 354
     array(
355 355
         'type'       => 'gateway_select',
356
-        'name'       => __( 'Gateway Select', 'invoicing' ),
356
+        'name'       => __('Gateway Select', 'invoicing'),
357 357
         'defaults'   => array(
358
-            'text'    => __( 'Select Payment Method', 'invoicing' ),
358
+            'text'    => __('Select Payment Method', 'invoicing'),
359 359
             'premade' => true,
360 360
         )
361 361
     ),
362 362
 
363 363
     array( 
364 364
         'type'       => 'total_payable',
365
-        'name'       => __( 'Total Payable', 'invoicing' ),
365
+        'name'       => __('Total Payable', 'invoicing'),
366 366
         'defaults'   => array(
367
-            'text' => __( 'Total to pay:', 'invoicing' ),
367
+            'text' => __('Total to pay:', 'invoicing'),
368 368
         )
369 369
     ),
370 370
 
371 371
     array( 
372 372
         'type'       => 'ip_address',
373
-        'name'       => __( 'IP Address', 'invoicing' ),
373
+        'name'       => __('IP Address', 'invoicing'),
374 374
         'defaults'   => array(
375
-            'text' => __( 'Your IP address is:', 'invoicing' ),
375
+            'text' => __('Your IP address is:', 'invoicing'),
376 376
         )
377 377
     )
378 378
 );
Please login to merge, or discard this patch.
includes/libraries/wpinv-euvat/class-wpinv-euvat.php 3 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
     }
395 395
 
396 396
     /**
397
-	 * Fetches the database from the MaxMind service.
398
-	 *
399
-	 * @param string $license_key The license key to be used when downloading the database.
400
-	 */
397
+     * Fetches the database from the MaxMind service.
398
+     *
399
+     * @param string $license_key The license key to be used when downloading the database.
400
+     */
401 401
     public static function geoip2_download_database() {
402 402
 
403 403
         // Allow us to easily interact with the filesystem.
404 404
         require_once ABSPATH . 'wp-admin/includes/file.php';
405
-		WP_Filesystem();
405
+        WP_Filesystem();
406 406
         global $wp_filesystem;
407 407
 
408 408
         $license_key = wpinv_get_option( 'maxmind_license_key' );
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             }
434 434
 
435 435
             // Move the new database into position.
436
-		    $wp_filesystem->move( $database_path, $target_path, true );
436
+            $wp_filesystem->move( $database_path, $target_path, true );
437 437
             $wp_filesystem->delete( dirname( $database_path ) );
438 438
 
439 439
             wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) );
@@ -452,16 +452,16 @@  discard block
 block discarded – undo
452 452
 
453 453
         // The download URI of the database.
454 454
         $source_url = add_query_arg(
455
-			array(
455
+            array(
456 456
                 'license_key' => urlencode( sanitize_text_field( $license_key ) ),
457 457
                 'edition_id'  => $database,
458
-				'suffix'      => 'tar.gz',
459
-			),
460
-			'https://download.maxmind.com/app/geoip_download'
458
+                'suffix'      => 'tar.gz',
459
+            ),
460
+            'https://download.maxmind.com/app/geoip_download'
461 461
         );
462 462
 
463 463
         // Needed for the download_url call right below.
464
-		require_once ABSPATH . 'wp-admin/includes/file.php';
464
+        require_once ABSPATH . 'wp-admin/includes/file.php';
465 465
 
466 466
         // Download the file.
467 467
         $tmp_archive_path = download_url( esc_url_raw( $source_url ) );
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
         if ( is_wp_error( $tmp_archive_path ) ) {
471 471
 
472 472
             // Transform the error into something more informative.
473
-			$error_data = $tmp_archive_path->get_error_data();
474
-			if ( isset( $error_data['code'] ) ) {
475
-				switch ( $error_data['code'] ) {
476
-					case 401:
477
-						return new WP_Error(
478
-							'invoicing_maxmind_geolocation_database_license_key',
479
-							__( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
480
-						);
481
-				}
482
-			}
473
+            $error_data = $tmp_archive_path->get_error_data();
474
+            if ( isset( $error_data['code'] ) ) {
475
+                switch ( $error_data['code'] ) {
476
+                    case 401:
477
+                        return new WP_Error(
478
+                            'invoicing_maxmind_geolocation_database_license_key',
479
+                            __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
480
+                        );
481
+                }
482
+            }
483 483
 
484 484
             return new WP_Error( 'invoicing_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
485 485
 
@@ -487,19 +487,19 @@  discard block
 block discarded – undo
487 487
 
488 488
         // Extract the database from the archive.
489 489
         try {
490
-			$file      = new PharData( $tmp_archive_path );
490
+            $file      = new PharData( $tmp_archive_path );
491 491
             $file_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb';
492 492
 
493
-			$file->extractTo(
494
-				dirname( $tmp_archive_path ),
495
-				trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb',
496
-				true
493
+            $file->extractTo(
494
+                dirname( $tmp_archive_path ),
495
+                trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb',
496
+                true
497 497
             );
498 498
 
499
-		} catch ( Exception $exception ) {
500
-			return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
501
-		} finally {
502
-			// Remove the archive since we only care about a single file in it.
499
+        } catch ( Exception $exception ) {
500
+            return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
501
+        } finally {
502
+            // Remove the archive since we only care about a single file in it.
503 503
             unlink( $tmp_archive_path );
504 504
         }
505 505
 
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
         $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1863 1863
 
1864 1864
         if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) {
1865
-           return wp_sprintf(
1865
+            return wp_sprintf(
1866 1866
                 __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ),
1867 1867
                 getpaid_vat_name()
1868 1868
             );
Please login to merge, or discard this patch.
Spacing   +639 added lines, -639 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 class WPInv_EUVat {
10 10
 
@@ -24,128 +24,128 @@  discard block
 block discarded – undo
24 24
     public function init() {
25 25
 
26 26
         // If this is an admin page...
27
-        if ( is_admin() ) {
27
+        if (is_admin()) {
28 28
 
29 29
             // Register our scripts.
30
-            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
31
-            add_action( 'wpinv_settings_sections_taxes', array( $this, 'section_vat_settings' ) );
32
-            add_action( 'wpinv_settings_taxes', array( $this, 'vat_settings' ) );
33
-            add_filter( 'wpinv_settings_taxes-vat_sanitize', array( $this, 'sanitize_vat_settings' ) );
34
-            add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( $this, 'sanitize_vat_rates' ) );
35
-            add_action( 'wp_ajax_wpinv_add_vat_class', array( $this, 'add_class' ) );
36
-            add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( $this, 'add_class' ) );
37
-            add_action( 'wp_ajax_wpinv_delete_vat_class', array( $this, 'delete_class' ) );
38
-            add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( $this, 'delete_class' ) );
39
-            add_action( 'wp_ajax_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) );
40
-            add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) );
41
-            add_action( 'wp_ajax_wpinv_geoip2', array( $this, 'geoip2_download_database' ) );
42
-            add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( $this, 'geoip2_download_database' ) );
30
+            add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
31
+            add_action('wpinv_settings_sections_taxes', array($this, 'section_vat_settings'));
32
+            add_action('wpinv_settings_taxes', array($this, 'vat_settings'));
33
+            add_filter('wpinv_settings_taxes-vat_sanitize', array($this, 'sanitize_vat_settings'));
34
+            add_filter('wpinv_settings_taxes-vat_rates_sanitize', array($this, 'sanitize_vat_rates'));
35
+            add_action('wp_ajax_wpinv_add_vat_class', array($this, 'add_class'));
36
+            add_action('wp_ajax_nopriv_wpinv_add_vat_class', array($this, 'add_class'));
37
+            add_action('wp_ajax_wpinv_delete_vat_class', array($this, 'delete_class'));
38
+            add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array($this, 'delete_class'));
39
+            add_action('wp_ajax_wpinv_update_vat_rates', array($this, 'update_eu_rates'));
40
+            add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array($this, 'update_eu_rates'));
41
+            add_action('wp_ajax_wpinv_geoip2', array($this, 'geoip2_download_database'));
42
+            add_action('wp_ajax_nopriv_wpinv_geoip2', array($this, 'geoip2_download_database'));
43 43
         }
44 44
 
45
-        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_vat_scripts' ) );
46
-        add_filter( 'wpinv_default_billing_country', array( $this, 'get_user_country' ), 10 );
47
-        add_filter( 'wpinv_get_user_country', array( $this, 'set_user_country' ), 10 );
48
-        add_action( 'wp_ajax_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) );
49
-        add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) );
45
+        add_action('wp_enqueue_scripts', array($this, 'enqueue_vat_scripts'));
46
+        add_filter('wpinv_default_billing_country', array($this, 'get_user_country'), 10);
47
+        add_filter('wpinv_get_user_country', array($this, 'set_user_country'), 10);
48
+        add_action('wp_ajax_wpinv_vat_validate', array($this, 'ajax_vat_validate'));
49
+        add_action('wp_ajax_nopriv_wpinv_vat_validate', array($this, 'ajax_vat_validate'));
50 50
 
51
-        if ( wpinv_use_taxes() && self::allow_vat_rules() ) {
52
-            add_filter( 'wpinv_tax_rate', array( $this, 'get_rate' ), 10, 4 );
51
+        if (wpinv_use_taxes() && self::allow_vat_rules()) {
52
+            add_filter('wpinv_tax_rate', array($this, 'get_rate'), 10, 4);
53 53
         }
54 54
     }
55 55
 
56
-    public static function get_eu_states( $sort = true ) {
57
-        $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' );
58
-        if ( $sort ) {
59
-            $sort = sort( $eu_states );
56
+    public static function get_eu_states($sort = true) {
57
+        $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE');
58
+        if ($sort) {
59
+            $sort = sort($eu_states);
60 60
         }
61 61
 
62
-        return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort );
62
+        return apply_filters('wpinv_get_eu_states', $eu_states, $sort);
63 63
     }
64 64
 
65
-    public static function get_gst_countries( $sort = true ) {
66
-        $gst_countries  = array( 'AU', 'NZ', 'CA', 'CN' );
65
+    public static function get_gst_countries($sort = true) {
66
+        $gst_countries = array('AU', 'NZ', 'CA', 'CN');
67 67
 
68
-        if ( $sort ) {
69
-            $sort = sort( $gst_countries );
68
+        if ($sort) {
69
+            $sort = sort($gst_countries);
70 70
         }
71 71
 
72
-        return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort );
72
+        return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort);
73 73
     }
74 74
 
75
-    public static function is_eu_state( $country_code ) {
76
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false;
75
+    public static function is_eu_state($country_code) {
76
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false;
77 77
 
78
-        return apply_filters( 'wpinv_is_eu_state', $return, $country_code );
78
+        return apply_filters('wpinv_is_eu_state', $return, $country_code);
79 79
     }
80 80
 
81
-    public static function is_gst_country( $country_code ) {
82
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false;
81
+    public static function is_gst_country($country_code) {
82
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false;
83 83
 
84
-        return apply_filters( 'wpinv_is_gst_country', $return, $country_code );
84
+        return apply_filters('wpinv_is_gst_country', $return, $country_code);
85 85
     }
86 86
 
87 87
     public function enqueue_vat_scripts() {
88
-        if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) {
88
+        if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) {
89 89
             $this->load_vat_scripts();
90 90
         }
91 91
     }
92 92
 
93
-    public function load_vat_scripts(){
94
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
93
+    public function load_vat_scripts() {
94
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
95 95
 
96
-        wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
97
-        wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
96
+        wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
97
+        wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
98 98
 
99
-        $vat_name   = $this->get_vat_name();
99
+        $vat_name = $this->get_vat_name();
100 100
 
101 101
         $vars = array();
102 102
         $vars['UseTaxes'] = wpinv_use_taxes();
103 103
         $vars['EUStates'] = self::get_eu_states();
104
-        $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' );
105
-        $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' );
106
-        $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
107
-        $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name );
108
-        $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name );
109
-        $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name );
110
-        $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name );
111
-        $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' );
104
+        $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing');
105
+        $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing');
106
+        $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
107
+        $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name);
108
+        $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name);
109
+        $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name);
110
+        $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name);
111
+        $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing');
112 112
         $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false;
113 113
         $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true;
114
-        $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' );
115
-        $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' );
116
-        $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' );
117
-        $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' );
118
-        $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' );
119
-        $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' );
120
-        $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' );
121
-        $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' );
122
-        $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name );
123
-        $vars['VatReseting'] = __( 'Reseting...', 'invoicing' );
124
-        $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
125
-        $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
126
-        $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' );
114
+        $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing');
115
+        $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing');
116
+        $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing');
117
+        $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing');
118
+        $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing');
119
+        $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing');
120
+        $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing');
121
+        $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing');
122
+        $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name);
123
+        $vars['VatReseting'] = __('Reseting...', 'invoicing');
124
+        $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
125
+        $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
126
+        $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing');
127 127
         $vars['isFront'] = is_admin() ? false : true;
128 128
         $vars['baseCountry'] = wpinv_get_default_country();
129
-        $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false );
130
-        $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false;
129
+        $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false);
130
+        $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false;
131 131
 
132
-        wp_enqueue_script( 'wpinv-vat-validation-script' );
133
-        wp_enqueue_script( 'wpinv-vat-script' );
134
-        wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars );
132
+        wp_enqueue_script('wpinv-vat-validation-script');
133
+        wp_enqueue_script('wpinv-vat-script');
134
+        wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars);
135 135
     }
136 136
 
137 137
     public static function enqueue_admin_scripts() {
138
-        if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) {
138
+        if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) {
139 139
             self::load_vat_scripts();
140 140
         }
141 141
     }
142 142
 
143
-    public static function section_vat_settings( $sections ) {
144
-        if ( !empty( $sections ) ) {
145
-            $sections['vat'] = __( 'EU VAT Settings', 'invoicing' );
143
+    public static function section_vat_settings($sections) {
144
+        if (!empty($sections)) {
145
+            $sections['vat'] = __('EU VAT Settings', 'invoicing');
146 146
 
147
-            if ( self::allow_vat_classes() ) {
148
-                $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' );
147
+            if (self::allow_vat_classes()) {
148
+                $sections['vat_rates'] = __('EU VAT Rates', 'invoicing');
149 149
             }
150 150
         }
151 151
         return $sections;
@@ -154,52 +154,52 @@  discard block
 block discarded – undo
154 154
     public static function vat_rates_settings() {
155 155
         $vat_classes = self::get_rate_classes();
156 156
         $vat_rates = array();
157
-        $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new';
158
-        $current_url = remove_query_arg( 'wpi_sub' );
157
+        $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new';
158
+        $current_url = remove_query_arg('wpi_sub');
159 159
 
160 160
         $vat_rates['vat_rates_header'] = array(
161 161
             'id' => 'vat_rates_header',
162
-            'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>',
162
+            'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>',
163 163
             'desc' => '',
164 164
             'type' => 'header',
165 165
             'size' => 'regular'
166 166
         );
167 167
         $vat_rates['vat_rates_class'] = array(
168 168
             'id'          => 'vat_rates_class',
169
-            'name'        => __( 'Edit VAT Rates', 'invoicing' ),
170
-            'desc'        => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ),
169
+            'name'        => __('Edit VAT Rates', 'invoicing'),
170
+            'desc'        => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'),
171 171
             'type'        => 'select',
172
-            'options'     => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ),
173
-            'placeholder' => __( 'Select a VAT Rate', 'invoicing' ),
172
+            'options'     => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))),
173
+            'placeholder' => __('Select a VAT Rate', 'invoicing'),
174 174
             'selected'    => $vat_class,
175 175
             'class'       => 'wpi_select2',
176 176
             'onchange'    => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;',
177 177
         );
178 178
 
179
-        if ( $vat_class != '_standard' && $vat_class != '_new' ) {
179
+        if ($vat_class != '_standard' && $vat_class != '_new') {
180 180
             $vat_rates['vat_rate_delete'] = array(
181 181
                 'id'   => 'vat_rate_delete',
182 182
                 'type' => 'vat_rate_delete',
183 183
             );
184 184
         }
185 185
 
186
-        if ( $vat_class == '_new' ) {
186
+        if ($vat_class == '_new') {
187 187
             $vat_rates['vat_rates_settings'] = array(
188 188
                 'id' => 'vat_rates_settings',
189
-                'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>',
189
+                'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>',
190 190
                 'type' => 'header',
191 191
             );
192 192
             $vat_rates['vat_rate_name'] = array(
193 193
                 'id'   => 'vat_rate_name',
194
-                'name' => __( 'Name', 'invoicing' ),
195
-                'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ),
194
+                'name' => __('Name', 'invoicing'),
195
+                'desc' => __('A short name for the new VAT Rate class', 'invoicing'),
196 196
                 'type' => 'text',
197 197
                 'size' => 'regular',
198 198
             );
199 199
             $vat_rates['vat_rate_desc'] = array(
200 200
                 'id'   => 'vat_rate_desc',
201
-                'name' => __( 'Description', 'invoicing' ),
202
-                'desc' => __( 'Manage VAT Rate class', 'invoicing' ),
201
+                'name' => __('Description', 'invoicing'),
202
+                'desc' => __('Manage VAT Rate class', 'invoicing'),
203 203
                 'type' => 'text',
204 204
                 'size' => 'regular',
205 205
             );
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             $vat_rates['vat_rates'] = array(
212 212
                 'id'   => 'vat_rates',
213 213
                 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>',
214
-                'desc' => self::get_class_desc( $vat_class ),
214
+                'desc' => self::get_class_desc($vat_class),
215 215
                 'type' => 'vat_rates',
216 216
             );
217 217
         }
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
         return $vat_rates;
220 220
     }
221 221
 
222
-    public static function vat_settings( $settings ) {
223
-        if ( !empty( $settings ) ) {
222
+    public static function vat_settings($settings) {
223
+        if (!empty($settings)) {
224 224
             $vat_settings = array();
225 225
             $vat_settings['vat_company_title'] = array(
226 226
                 'id' => 'vat_company_title',
227
-                'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>',
227
+                'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>',
228 228
                 'desc' => '',
229 229
                 'type' => 'header',
230 230
                 'size' => 'regular'
@@ -232,22 +232,22 @@  discard block
 block discarded – undo
232 232
 
233 233
             $vat_settings['vat_company_name'] = array(
234 234
                 'id' => 'vat_company_name',
235
-                'name' => __( 'Your Company Name', 'invoicing' ),
236
-                'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
235
+                'name' => __('Your Company Name', 'invoicing'),
236
+                'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
237 237
                 'type' => 'text',
238 238
                 'size' => 'regular',
239 239
             );
240 240
 
241 241
             $vat_settings['vat_number'] = array(
242 242
                 'id'   => 'vat_number',
243
-                'name' => __( 'Your VAT Number', 'invoicing' ),
243
+                'name' => __('Your VAT Number', 'invoicing'),
244 244
                 'type' => 'vat_number',
245 245
                 'size' => 'regular',
246 246
             );
247 247
 
248 248
             $vat_settings['vat_settings_title'] = array(
249 249
                 'id' => 'vat_settings_title',
250
-                'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>',
250
+                'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>',
251 251
                 'desc' => '',
252 252
                 'type' => 'header',
253 253
                 'size' => 'regular'
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 
256 256
             $vat_settings['apply_vat_rules'] = array(
257 257
                 'id' => 'apply_vat_rules',
258
-                'name' => __( 'Enable VAT Rules', 'invoicing' ),
259
-                'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>',
258
+                'name' => __('Enable VAT Rules', 'invoicing'),
259
+                'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>',
260 260
                 'type' => 'checkbox',
261 261
                 'std' => '1'
262 262
             );
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
 
273 273
             $vat_settings['vat_prevent_b2c_purchase'] = array(
274 274
                 'id' => 'vat_prevent_b2c_purchase',
275
-                'name' => __( 'Prevent EU B2C Sales', 'invoicing' ),
276
-                'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ),
275
+                'name' => __('Prevent EU B2C Sales', 'invoicing'),
276
+                'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'),
277 277
                 'type' => 'checkbox'
278 278
             );
279 279
 
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
 
282 282
             $vat_settings['vat_same_country_rule'] = array(
283 283
                 'id'          => 'vat_same_country_rule',
284
-                'name'        => __( 'Same Country Rule', 'invoicing' ),
285
-                'desc'        => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ),
284
+                'name'        => __('Same Country Rule', 'invoicing'),
285
+                'desc'        => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'),
286 286
                 'type'        => 'select',
287 287
                 'options'     => array(
288
-                    ''          => __( 'Normal', 'invoicing' ),
289
-                    'no'        => __( 'No VAT', 'invoicing' ),
290
-                    'always'    => __( 'Always apply VAT', 'invoicing' ),
288
+                    ''          => __('Normal', 'invoicing'),
289
+                    'no'        => __('No VAT', 'invoicing'),
290
+                    'always'    => __('Always apply VAT', 'invoicing'),
291 291
                 ),
292
-                'placeholder' => __( 'Select an option', 'invoicing' ),
292
+                'placeholder' => __('Select an option', 'invoicing'),
293 293
                 'std'         => '',
294 294
                 'class'   => 'wpi_select2',
295 295
             );
296 296
 
297 297
             $vat_settings['vat_checkout_title'] = array(
298 298
                 'id' => 'vat_checkout_title',
299
-                'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>',
299
+                'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>',
300 300
                 'desc' => '',
301 301
                 'type' => 'header',
302 302
                 'size' => 'regular'
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 
305 305
             $vat_settings['vat_disable_fields'] = array(
306 306
                 'id' => 'vat_disable_fields',
307
-                'name' => __( 'Disable VAT Fields', 'invoicing' ),
308
-                'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>',
307
+                'name' => __('Disable VAT Fields', 'invoicing'),
308
+                'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>',
309 309
                 'type' => 'checkbox'
310 310
             );
311 311
 
312 312
             $vat_settings['maxmind_license_key'] = array(
313 313
                 'id'   => 'maxmind_license_key',
314
-                'name' => __( 'MaxMind License Key', 'invoicing' ),
314
+                'name' => __('MaxMind License Key', 'invoicing'),
315 315
                 'type' => 'text',
316 316
                 'size' => 'regular',
317
-                'desc' => '<a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'The key that will be used when dealing with MaxMind Geolocation services.', 'invoicing' ) . '</a>',
317
+                'desc' => '<a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('The key that will be used when dealing with MaxMind Geolocation services.', 'invoicing') . '</a>',
318 318
             );
319 319
 
320 320
             $vat_settings['vat_ip_lookup'] = array(
321 321
                 'id'   => 'vat_ip_lookup',
322
-                'name' => __( 'IP Country Look-up', 'invoicing' ),
322
+                'name' => __('IP Country Look-up', 'invoicing'),
323 323
                 'type' => 'vat_ip_lookup',
324 324
                 'size' => 'regular',
325 325
                 'std' => 'default',
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 
329 329
             $vat_settings['vat_ip_country_default'] = array(
330 330
                 'id' => 'vat_ip_country_default',
331
-                'name' => __( 'Enable IP Country as Default', 'invoicing' ),
332
-                'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ),
331
+                'name' => __('Enable IP Country as Default', 'invoicing'),
332
+                'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'),
333 333
                 'type' => 'checkbox'
334 334
             );
335 335
 
336 336
             $vat_settings['vies_validation_title'] = array(
337 337
                 'id' => 'vies_validation_title',
338
-                'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>',
338
+                'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>',
339 339
                 'desc' => '',
340 340
                 'type' => 'header',
341 341
                 'size' => 'regular'
@@ -343,37 +343,37 @@  discard block
 block discarded – undo
343 343
 
344 344
             $vat_settings['vat_vies_check'] = array(
345 345
                 'id' => 'vat_vies_check',
346
-                'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ),
347
-                'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
346
+                'name' => __('Disable VIES VAT ID Check', 'invoicing'),
347
+                'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
348 348
                 'type' => 'checkbox'
349 349
             );
350 350
 
351 351
             $vat_settings['vat_disable_company_name_check'] = array(
352 352
                 'id' => 'vat_disable_company_name_check',
353
-                'name' => __( 'Disable VIES Name Check', 'invoicing' ),
354
-                'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
353
+                'name' => __('Disable VIES Name Check', 'invoicing'),
354
+                'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
355 355
                 'type' => 'checkbox'
356 356
             );
357 357
 
358 358
             $vat_settings['vat_offline_check'] = array(
359 359
                 'id' => 'vat_offline_check',
360
-                'name' => __( 'Disable Basic Checks', 'invoicing' ),
361
-                'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ),
360
+                'name' => __('Disable Basic Checks', 'invoicing'),
361
+                'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'),
362 362
                 'type' => 'checkbox'
363 363
             );
364 364
 
365 365
 
366 366
             $settings['vat'] = $vat_settings;
367 367
 
368
-            if ( self::allow_vat_classes() ) {
368
+            if (self::allow_vat_classes()) {
369 369
                 $settings['vat_rates'] = self::vat_rates_settings();
370 370
             }
371 371
 
372 372
             $eu_fallback_rate = array(
373 373
                 'id'   => 'eu_fallback_rate',
374
-                'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>',
374
+                'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>',
375 375
                 'type' => 'eu_fallback_rate',
376
-                'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ),
376
+                'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'),
377 377
                 'std'  => '20',
378 378
                 'size' => 'small'
379 379
             );
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
      */
389 389
     public static function maxmind_folder() {
390 390
 
391
-        $upload_dir      = wp_upload_dir();
391
+        $upload_dir = wp_upload_dir();
392 392
         return $upload_dir['basedir'] . '/invoicing';
393 393
 
394 394
     }
@@ -405,39 +405,39 @@  discard block
 block discarded – undo
405 405
 		WP_Filesystem();
406 406
         global $wp_filesystem;
407 407
 
408
-        $license_key = wpinv_get_option( 'maxmind_license_key' );
408
+        $license_key = wpinv_get_option('maxmind_license_key');
409 409
 
410
-        if ( empty( $license_key ) ) {
411
-            echo __( 'Please enter your MaxMind license key then save the settings first before downloading the databases.', 'invoicing' );
410
+        if (empty($license_key)) {
411
+            echo __('Please enter your MaxMind license key then save the settings first before downloading the databases.', 'invoicing');
412 412
             exit;
413 413
         }
414 414
 
415 415
         // The database files that we will download.
416
-        $database_files     = array( 'GeoLite2-Country', 'GeoLite2-City' );
416
+        $database_files = array('GeoLite2-Country', 'GeoLite2-City');
417 417
 
418 418
         // The destination dir of all databases.
419 419
         $destination_dir = self::maxmind_folder();
420 420
 
421
-        if ( ! $wp_filesystem->is_dir( $destination_dir ) ) {
422
-            $wp_filesystem->mkdir( $destination_dir );
421
+        if (!$wp_filesystem->is_dir($destination_dir)) {
422
+            $wp_filesystem->mkdir($destination_dir);
423 423
         }
424 424
 
425
-        foreach( $database_files as $database ) {
425
+        foreach ($database_files as $database) {
426 426
 
427
-            $database_path = self::geoip2_download_file( $license_key, $database );
428
-            $target_path   = trailingslashit( $destination_dir ) .  $database . '.mmdb';
427
+            $database_path = self::geoip2_download_file($license_key, $database);
428
+            $target_path   = trailingslashit($destination_dir) . $database . '.mmdb';
429 429
 
430
-            if ( is_wp_error( $database_path ) ) {
430
+            if (is_wp_error($database_path)) {
431 431
                 echo $database_path->get_error_message();
432 432
                 exit;
433 433
             }
434 434
 
435 435
             // Move the new database into position.
436
-		    $wp_filesystem->move( $database_path, $target_path, true );
437
-            $wp_filesystem->delete( dirname( $database_path ) );
436
+		    $wp_filesystem->move($database_path, $target_path, true);
437
+            $wp_filesystem->delete(dirname($database_path));
438 438
 
439
-            wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) );
440
-            echo sprintf( __( 'GeoIP2 %s database updated successfully.', 'invoicing' ), $database ) . ' ';
439
+            wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp'));
440
+            echo sprintf(__('GeoIP2 %s database updated successfully.', 'invoicing'), $database) . ' ';
441 441
         }
442 442
 
443 443
         exit;
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
      *
449 449
      * @return string|WP_Error
450 450
      */
451
-    public static function geoip2_download_file( $license_key, $database ) {
451
+    public static function geoip2_download_file($license_key, $database) {
452 452
 
453 453
         // The download URI of the database.
454 454
         $source_url = add_query_arg(
455 455
 			array(
456
-                'license_key' => urlencode( sanitize_text_field( $license_key ) ),
456
+                'license_key' => urlencode(sanitize_text_field($license_key)),
457 457
                 'edition_id'  => $database,
458 458
 				'suffix'      => 'tar.gz',
459 459
 			),
@@ -464,54 +464,54 @@  discard block
 block discarded – undo
464 464
 		require_once ABSPATH . 'wp-admin/includes/file.php';
465 465
 
466 466
         // Download the file.
467
-        $tmp_archive_path = download_url( esc_url_raw( $source_url ) );
467
+        $tmp_archive_path = download_url(esc_url_raw($source_url));
468 468
 
469 469
         // Did we encounter an error?
470
-        if ( is_wp_error( $tmp_archive_path ) ) {
470
+        if (is_wp_error($tmp_archive_path)) {
471 471
 
472 472
             // Transform the error into something more informative.
473 473
 			$error_data = $tmp_archive_path->get_error_data();
474
-			if ( isset( $error_data['code'] ) ) {
475
-				switch ( $error_data['code'] ) {
474
+			if (isset($error_data['code'])) {
475
+				switch ($error_data['code']) {
476 476
 					case 401:
477 477
 						return new WP_Error(
478 478
 							'invoicing_maxmind_geolocation_database_license_key',
479
-							__( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
479
+							__('The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing')
480 480
 						);
481 481
 				}
482 482
 			}
483 483
 
484
-            return new WP_Error( 'invoicing_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
484
+            return new WP_Error('invoicing_maxmind_geolocation_database_download', __('Failed to download the MaxMind database.', 'invoicing'));
485 485
 
486 486
         }
487 487
 
488 488
         // Extract the database from the archive.
489 489
         try {
490
-			$file      = new PharData( $tmp_archive_path );
491
-            $file_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb';
490
+			$file = new PharData($tmp_archive_path);
491
+            $file_path = trailingslashit(dirname($tmp_archive_path)) . trailingslashit($file->current()->getFilename()) . $database . '.mmdb';
492 492
 
493 493
 			$file->extractTo(
494
-				dirname( $tmp_archive_path ),
495
-				trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb',
494
+				dirname($tmp_archive_path),
495
+				trailingslashit($file->current()->getFilename()) . $database . '.mmdb',
496 496
 				true
497 497
             );
498 498
 
499
-		} catch ( Exception $exception ) {
500
-			return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
499
+		} catch (Exception $exception) {
500
+			return new WP_Error('invoicing_maxmind_geolocation_database_archive', $exception->getMessage());
501 501
 		} finally {
502 502
 			// Remove the archive since we only care about a single file in it.
503
-            unlink( $tmp_archive_path );
503
+            unlink($tmp_archive_path);
504 504
         }
505 505
 
506 506
         return $file_path;
507 507
     }
508 508
 
509 509
     public static function load_geoip2() {
510
-        if ( defined( 'WPINV_GEOIP2_LODDED' ) ) {
510
+        if (defined('WPINV_GEOIP2_LODDED')) {
511 511
             return;
512 512
         }
513 513
 
514
-        if ( !class_exists( '\MaxMind\Db\Reader' ) ) {
514
+        if (!class_exists('\MaxMind\Db\Reader')) {
515 515
             $maxmind_db_files = array(
516 516
                 'Reader/Decoder.php',
517 517
                 'Reader/InvalidDatabaseException.php',
@@ -520,12 +520,12 @@  discard block
 block discarded – undo
520 520
                 'Reader.php',
521 521
             );
522 522
 
523
-            foreach ( $maxmind_db_files as $key => $file ) {
524
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file );
523
+            foreach ($maxmind_db_files as $key => $file) {
524
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file);
525 525
             }
526 526
         }
527 527
 
528
-        if ( !class_exists( '\GeoIp2\Database\Reader' ) ) {
528
+        if (!class_exists('\GeoIp2\Database\Reader')) {
529 529
             $geoip2_files = array(
530 530
                 'ProviderInterface.php',
531 531
                 'Compat/JsonSerializable.php',
@@ -559,23 +559,23 @@  discard block
 block discarded – undo
559 559
                 'WebService/Client.php',
560 560
             );
561 561
 
562
-            foreach ( $geoip2_files as $key => $file ) {
563
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file );
562
+            foreach ($geoip2_files as $key => $file) {
563
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file);
564 564
             }
565 565
         }
566 566
 
567
-        define( 'WPINV_GEOIP2_LODDED', true );
567
+        define('WPINV_GEOIP2_LODDED', true);
568 568
     }
569 569
 
570 570
     public static function geoip2_country_dbfile() {
571 571
         $upload_dir = wp_upload_dir();
572 572
 
573
-        if ( !isset( $upload_dir['basedir'] ) ) {
573
+        if (!isset($upload_dir['basedir'])) {
574 574
             return false;
575 575
         }
576 576
 
577 577
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb';
578
-        if ( !file_exists( $filename ) ) {
578
+        if (!file_exists($filename)) {
579 579
             return false;
580 580
         }
581 581
 
@@ -585,12 +585,12 @@  discard block
 block discarded – undo
585 585
     public static function geoip2_city_dbfile() {
586 586
         $upload_dir = wp_upload_dir();
587 587
 
588
-        if ( !isset( $upload_dir['basedir'] ) ) {
588
+        if (!isset($upload_dir['basedir'])) {
589 589
             return false;
590 590
         }
591 591
 
592 592
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb';
593
-        if ( !file_exists( $filename ) ) {
593
+        if (!file_exists($filename)) {
594 594
             return false;
595 595
         }
596 596
 
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
         try {
602 602
             self::load_geoip2();
603 603
 
604
-            if ( $filename = self::geoip2_country_dbfile() ) {
605
-                return new \GeoIp2\Database\Reader( $filename );
604
+            if ($filename = self::geoip2_country_dbfile()) {
605
+                return new \GeoIp2\Database\Reader($filename);
606 606
             }
607
-        } catch( Exception $e ) {
607
+        } catch (Exception $e) {
608 608
             return false;
609 609
         }
610 610
 
@@ -615,183 +615,183 @@  discard block
 block discarded – undo
615 615
         try {
616 616
             self::load_geoip2();
617 617
 
618
-            if ( $filename = self::geoip2_city_dbfile() ) {
619
-                return new \GeoIp2\Database\Reader( $filename );
618
+            if ($filename = self::geoip2_city_dbfile()) {
619
+                return new \GeoIp2\Database\Reader($filename);
620 620
             }
621
-        } catch( Exception $e ) {
621
+        } catch (Exception $e) {
622 622
             return false;
623 623
         }
624 624
 
625 625
         return false;
626 626
     }
627 627
 
628
-    public static function geoip2_country_record( $ip_address ) {
628
+    public static function geoip2_country_record($ip_address) {
629 629
         try {
630 630
             $reader = self::geoip2_country_reader();
631 631
 
632
-            if ( $reader ) {
633
-                $record = $reader->country( $ip_address );
632
+            if ($reader) {
633
+                $record = $reader->country($ip_address);
634 634
 
635
-                if ( !empty( $record->country->isoCode ) ) {
635
+                if (!empty($record->country->isoCode)) {
636 636
                     return $record;
637 637
                 }
638 638
             }
639
-        } catch(\InvalidArgumentException $e) {
640
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
639
+        } catch (\InvalidArgumentException $e) {
640
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
641 641
 
642 642
             return false;
643
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
644
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
643
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
644
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
645 645
 
646 646
             return false;
647
-        } catch( Exception $e ) {
647
+        } catch (Exception $e) {
648 648
             return false;
649 649
         }
650 650
 
651 651
         return false;
652 652
     }
653 653
 
654
-    public static function geoip2_city_record( $ip_address ) {
654
+    public static function geoip2_city_record($ip_address) {
655 655
         try {
656 656
             $reader = self::geoip2_city_reader();
657 657
 
658
-            if ( $reader ) {
659
-                $record = $reader->city( $ip_address );
658
+            if ($reader) {
659
+                $record = $reader->city($ip_address);
660 660
 
661
-                if ( !empty( $record->country->isoCode ) ) {
661
+                if (!empty($record->country->isoCode)) {
662 662
                     return $record;
663 663
                 }
664 664
             }
665
-        } catch(\InvalidArgumentException $e) {
666
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
665
+        } catch (\InvalidArgumentException $e) {
666
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
667 667
 
668 668
             return false;
669
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
670
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
669
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
670
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
671 671
 
672 672
             return false;
673
-        } catch( Exception $e ) {
673
+        } catch (Exception $e) {
674 674
             return false;
675 675
         }
676 676
 
677 677
         return false;
678 678
     }
679 679
 
680
-    public static function geoip2_country_code( $ip_address ) {
681
-        $record = self::geoip2_country_record( $ip_address );
682
-        return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country();
680
+    public static function geoip2_country_code($ip_address) {
681
+        $record = self::geoip2_country_record($ip_address);
682
+        return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country();
683 683
     }
684 684
 
685 685
     // Find country by IP address.
686
-    public static function get_country_by_ip( $ip = '' ) {
686
+    public static function get_country_by_ip($ip = '') {
687 687
         global $wpinv_ip_address_country;
688 688
         return '';
689
-        if ( !empty( $wpinv_ip_address_country ) ) {
689
+        if (!empty($wpinv_ip_address_country)) {
690 690
             return $wpinv_ip_address_country;
691 691
         }
692 692
 
693
-        if ( empty( $ip ) ) {
693
+        if (empty($ip)) {
694 694
             $ip = wpinv_get_ip();
695 695
         }
696 696
 
697
-        $ip_country_service = wpinv_get_option( 'vat_ip_lookup' );
698
-        $is_default         = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false;
697
+        $ip_country_service = wpinv_get_option('vat_ip_lookup');
698
+        $is_default         = empty($ip_country_service) || $ip_country_service === 'default' ? true : false;
699 699
 
700
-        if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country.
701
-            if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) {
700
+        if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country.
701
+            if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) {
702 702
                 try {
703
-                    $wpinv_ip_address_country = geoip_country_code_by_name( $ip );
704
-                } catch( Exception $e ) {
705
-                    wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' );
703
+                    $wpinv_ip_address_country = geoip_country_code_by_name($ip);
704
+                } catch (Exception $e) {
705
+                    wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )');
706 706
                 }
707
-            } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) {
708
-                $wpinv_ip_address_country = self::geoip2_country_code( $ip );
709
-            } else if ( function_exists( 'simplexml_load_file' ) && ini_get('allow_url_fopen') && ( $ip_country_service === 'geoplugin' || $is_default ) ) {
710
-                $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
707
+            } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) {
708
+                $wpinv_ip_address_country = self::geoip2_country_code($ip);
709
+            } else if (function_exists('simplexml_load_file') && ini_get('allow_url_fopen') && ($ip_country_service === 'geoplugin' || $is_default)) {
710
+                $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
711 711
 
712
-                if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) {
713
-                    $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode;
712
+                if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) {
713
+                    $wpinv_ip_address_country = (string) $load_xml->geoplugin_countryCode;
714 714
                 }
715
-            }elseif(!empty( $ip )){
715
+            }elseif (!empty($ip)) {
716 716
                 $url = 'http://ip-api.com/json/' . $ip;
717 717
                 $response = wp_remote_get($url);
718 718
 
719
-                if ( is_array( $response ) && wp_remote_retrieve_response_code( $response ) == '200' ) {
720
-                    $data = json_decode(wp_remote_retrieve_body( $response ),true);
721
-                    if(!empty($data['countryCode'])){
722
-                        $wpinv_ip_address_country = (string)$data['countryCode'];
719
+                if (is_array($response) && wp_remote_retrieve_response_code($response) == '200') {
720
+                    $data = json_decode(wp_remote_retrieve_body($response), true);
721
+                    if (!empty($data['countryCode'])) {
722
+                        $wpinv_ip_address_country = (string) $data['countryCode'];
723 723
                     }
724 724
                 }
725 725
             }
726 726
         }
727 727
 
728
-        if ( empty( $wpinv_ip_address_country ) ) {
728
+        if (empty($wpinv_ip_address_country)) {
729 729
             $wpinv_ip_address_country = wpinv_get_default_country();
730 730
         }
731 731
 
732 732
         return $wpinv_ip_address_country;
733 733
     }
734 734
 
735
-    public static function sanitize_vat_settings( $input ) {
735
+    public static function sanitize_vat_settings($input) {
736 736
         global $wpinv_options;
737 737
 
738 738
         $valid      = false;
739 739
         $message    = '';
740 740
 
741
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
742
-            if ( empty( $wpinv_options['vat_offline_check'] ) ) {
743
-                $valid = self::offline_check( $input['vat_number'] );
741
+        if (!empty($wpinv_options['vat_vies_check'])) {
742
+            if (empty($wpinv_options['vat_offline_check'])) {
743
+                $valid = self::offline_check($input['vat_number']);
744 744
             } else {
745 745
                 $valid = true;
746 746
             }
747 747
 
748
-            $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' );
748
+            $message = $valid ? '' : __('VAT number not validated', 'invoicing');
749 749
         } else {
750
-            $result = self::check_vat( $input['vat_number'] );
750
+            $result = self::check_vat($input['vat_number']);
751 751
 
752
-            if ( empty( $result['valid'] ) ) {
752
+            if (empty($result['valid'])) {
753 753
                 $valid      = false;
754 754
                 $message    = $result['message'];
755 755
             } else {
756
-                $valid      = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] );
757
-                $message    = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' );
756
+                $valid      = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']);
757
+                $message    = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing');
758 758
             }
759 759
         }
760 760
 
761
-        if ( $message && self::is_vat_validated() != $valid ) {
762
-            add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) );
761
+        if ($message && self::is_vat_validated() != $valid) {
762
+            add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error'));
763 763
         }
764 764
 
765 765
         $input['vat_valid'] = $valid;
766 766
         return $input;
767 767
     }
768 768
 
769
-    public static function sanitize_vat_rates( $input ) {
770
-        if( !wpinv_current_user_can_manage_invoicing() ) {
771
-            add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' );
769
+    public static function sanitize_vat_rates($input) {
770
+        if (!wpinv_current_user_can_manage_invoicing()) {
771
+            add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error');
772 772
             return $input;
773 773
         }
774 774
 
775 775
         $vat_classes = self::get_rate_classes();
776
-        $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : '';
776
+        $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : '';
777 777
 
778
-        if ( empty( $vat_class ) ) {
779
-            add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' );
778
+        if (empty($vat_class)) {
779
+            add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error');
780 780
 
781 781
             return $input;
782 782
         }
783 783
 
784
-        $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array();
784
+        $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array();
785 785
 
786
-        if ( $vat_class === '_standard' ) {
786
+        if ($vat_class === '_standard') {
787 787
             // Save the active rates in the invoice settings
788
-            update_option( 'wpinv_tax_rates', $new_rates );
788
+            update_option('wpinv_tax_rates', $new_rates);
789 789
         } else {
790 790
             // Get the existing set of rates
791 791
             $rates = self::get_non_standard_rates();
792 792
             $rates[$vat_class] = $new_rates;
793 793
 
794
-            update_option( 'wpinv_vat_rates', $rates );
794
+            update_option('wpinv_vat_rates', $rates);
795 795
         }
796 796
 
797 797
         return $input;
@@ -801,71 +801,71 @@  discard block
 block discarded – undo
801 801
         $response = array();
802 802
         $response['success'] = false;
803 803
 
804
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
805
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
806
-            wp_send_json( $response );
804
+        if (!wpinv_current_user_can_manage_invoicing()) {
805
+            $response['error'] = __('Invalid access!', 'invoicing');
806
+            wp_send_json($response);
807 807
         }
808 808
 
809
-        $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false;
810
-        $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false;
809
+        $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
810
+        $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false;
811 811
 
812
-        if ( empty( $vat_class_name ) ) {
813
-            $response['error'] = __( 'Select the VAT rate name', 'invoicing' );
814
-            wp_send_json( $response );
812
+        if (empty($vat_class_name)) {
813
+            $response['error'] = __('Select the VAT rate name', 'invoicing');
814
+            wp_send_json($response);
815 815
         }
816 816
 
817
-        $vat_classes = (array)self::get_rate_classes();
817
+        $vat_classes = (array) self::get_rate_classes();
818 818
 
819
-        if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) {
820
-            $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name );
821
-            wp_send_json( $response );
819
+        if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) {
820
+            $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name);
821
+            wp_send_json($response);
822 822
         }
823 823
 
824
-        $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name );
825
-        $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) );
824
+        $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name);
825
+        $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key));
826 826
 
827
-        $vat_classes = (array)self::get_rate_classes( true );
828
-        $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc );
827
+        $vat_classes = (array) self::get_rate_classes(true);
828
+        $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc);
829 829
 
830
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
830
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
831 831
 
832 832
         $response['success'] = true;
833
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key );
833
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key);
834 834
 
835
-        wp_send_json( $response );
835
+        wp_send_json($response);
836 836
     }
837 837
 
838 838
     public static function delete_class() {
839 839
         $response = array();
840 840
         $response['success'] = false;
841 841
 
842
-        if ( !wpinv_current_user_can_manage_invoicing() || !isset( $_POST['class'] ) ) {
843
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
844
-            wp_send_json( $response );
842
+        if (!wpinv_current_user_can_manage_invoicing() || !isset($_POST['class'])) {
843
+            $response['error'] = __('Invalid access!', 'invoicing');
844
+            wp_send_json($response);
845 845
         }
846 846
 
847
-        $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false;
848
-        $vat_classes = (array)self::get_rate_classes();
847
+        $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false;
848
+        $vat_classes = (array) self::get_rate_classes();
849 849
 
850
-        if ( !isset( $vat_classes[$vat_class] ) ) {
851
-            $response['error'] = __( 'Requested class does not exists', 'invoicing' );
852
-            wp_send_json( $response );
850
+        if (!isset($vat_classes[$vat_class])) {
851
+            $response['error'] = __('Requested class does not exists', 'invoicing');
852
+            wp_send_json($response);
853 853
         }
854 854
 
855
-        if ( $vat_class == '_new' || $vat_class == '_standard' ) {
856
-            $response['error'] = __( 'You can not delete standard rates class', 'invoicing' );
857
-            wp_send_json( $response );
855
+        if ($vat_class == '_new' || $vat_class == '_standard') {
856
+            $response['error'] = __('You can not delete standard rates class', 'invoicing');
857
+            wp_send_json($response);
858 858
         }
859 859
 
860
-        $vat_classes = (array)self::get_rate_classes( true );
861
-        unset( $vat_classes[$vat_class] );
860
+        $vat_classes = (array) self::get_rate_classes(true);
861
+        unset($vat_classes[$vat_class]);
862 862
 
863
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
863
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
864 864
 
865 865
         $response['success'] = true;
866
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new' );
866
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new');
867 867
 
868
-        wp_send_json( $response );
868
+        wp_send_json($response);
869 869
     }
870 870
 
871 871
     public static function update_eu_rates() {
@@ -874,73 +874,73 @@  discard block
 block discarded – undo
874 874
         $response['error']      = null;
875 875
         $response['data']       = null;
876 876
 
877
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
878
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
879
-            wp_send_json( $response );
877
+        if (!wpinv_current_user_can_manage_invoicing()) {
878
+            $response['error'] = __('Invalid access!', 'invoicing');
879
+            wp_send_json($response);
880 880
         }
881 881
 
882
-        $group      = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : '';
883
-        $euvatrates = self::request_euvatrates( $group );
882
+        $group      = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : '';
883
+        $euvatrates = self::request_euvatrates($group);
884 884
 
885
-        if ( !empty( $euvatrates ) ) {
886
-            if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) {
885
+        if (!empty($euvatrates)) {
886
+            if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) {
887 887
                 $response['success']        = true;
888 888
                 $response['data']['rates']  = $euvatrates['rates'];
889
-            } else if ( !empty( $euvatrates['error'] ) ) {
889
+            } else if (!empty($euvatrates['error'])) {
890 890
                 $response['error']          = $euvatrates['error'];
891 891
             }
892 892
         }
893 893
 
894
-        wp_send_json( $response );
894
+        wp_send_json($response);
895 895
     }
896 896
 
897 897
     public static function hide_vat_fields() {
898
-        $hide = wpinv_get_option( 'vat_disable_fields' );
898
+        $hide = wpinv_get_option('vat_disable_fields');
899 899
 
900
-        return apply_filters( 'wpinv_hide_vat_fields', $hide );
900
+        return apply_filters('wpinv_hide_vat_fields', $hide);
901 901
     }
902 902
 
903 903
     public static function same_country_rule() {
904
-        $same_country_rule = wpinv_get_option( 'vat_same_country_rule' );
904
+        $same_country_rule = wpinv_get_option('vat_same_country_rule');
905 905
 
906
-        return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule );
906
+        return apply_filters('wpinv_vat_same_country_rule', $same_country_rule);
907 907
     }
908 908
 
909 909
     /**
910 910
      * Retrieves the vat name.
911 911
      */
912 912
     public function get_vat_name() {
913
-        $vat_name = wpinv_get_option( 'vat_name' );
914
-        return empty( $vat_name ) ? __( 'VAT', 'invoicing' ) : sanitize_text_field( $vat_name );
913
+        $vat_name = wpinv_get_option('vat_name');
914
+        return empty($vat_name) ? __('VAT', 'invoicing') : sanitize_text_field($vat_name);
915 915
     }
916 916
 
917 917
     public static function get_company_name() {
918
-        $company_name = wpinv_get_option( 'vat_company_name' );
918
+        $company_name = wpinv_get_option('vat_company_name');
919 919
 
920
-        return apply_filters( 'wpinv_get_owner_company_name', $company_name );
920
+        return apply_filters('wpinv_get_owner_company_name', $company_name);
921 921
     }
922 922
 
923 923
     public static function get_vat_number() {
924
-        $vat_number = wpinv_get_option( 'vat_number' );
924
+        $vat_number = wpinv_get_option('vat_number');
925 925
 
926
-        return apply_filters( 'wpinv_get_owner_vat_number', $vat_number );
926
+        return apply_filters('wpinv_get_owner_vat_number', $vat_number);
927 927
     }
928 928
 
929 929
     public static function is_vat_validated() {
930
-        $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' );
930
+        $validated = self::get_vat_number() && wpinv_get_option('vat_valid');
931 931
 
932
-        return apply_filters( 'wpinv_is_owner_vat_validated', $validated );
932
+        return apply_filters('wpinv_is_owner_vat_validated', $validated);
933 933
     }
934 934
 
935
-    public static function sanitize_vat( $vat_number, $country_code = '' ) {
936
-        $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
935
+    public static function sanitize_vat($vat_number, $country_code = '') {
936
+        $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
937 937
 
938
-        if ( empty( $country_code ) ) {
939
-            $country_code = substr( $vat_number, 0, 2 );
938
+        if (empty($country_code)) {
939
+            $country_code = substr($vat_number, 0, 2);
940 940
         }
941 941
 
942
-        if ( strpos( $vat_number , $country_code ) === 0 ) {
943
-            $vat = str_replace( $country_code, '', $vat_number );
942
+        if (strpos($vat_number, $country_code) === 0) {
943
+            $vat = str_replace($country_code, '', $vat_number);
944 944
         } else {
945 945
             $vat = $country_code . $vat_number;
946 946
         }
@@ -953,140 +953,140 @@  discard block
 block discarded – undo
953 953
         return $return;
954 954
     }
955 955
 
956
-    public static function offline_check( $vat_number, $country_code = '', $formatted = false ) {
957
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
956
+    public static function offline_check($vat_number, $country_code = '', $formatted = false) {
957
+        $vat            = self::sanitize_vat($vat_number, $country_code);
958 958
         $vat_number     = $vat['vat_number'];
959 959
         $country_code   = $vat['iso'];
960 960
         $regex          = array();
961 961
 
962
-        switch ( $country_code ) {
962
+        switch ($country_code) {
963 963
             case 'AT':
964
-                $regex[] = '/^(AT)U(\d{8})$/';                           // Austria
964
+                $regex[] = '/^(AT)U(\d{8})$/'; // Austria
965 965
                 break;
966 966
             case 'BE':
967
-                $regex[] = '/^(BE)(0?\d{9})$/';                          // Belgium
967
+                $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium
968 968
                 break;
969 969
             case 'BG':
970
-                $regex[] = '/^(BG)(\d{9,10})$/';                         // Bulgaria
970
+                $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria
971 971
                 break;
972 972
             case 'CH':
973 973
             case 'CHE':
974
-                $regex[] = '/^(CHE)(\d{9})MWST$/';                       // Switzerland (Not EU)
974
+                $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU)
975 975
                 break;
976 976
             case 'CY':
977
-                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/';                // Cyprus
977
+                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus
978 978
                 break;
979 979
             case 'CZ':
980
-                $regex[] = '/^(CZ)(\d{8,13})$/';                         // Czech Republic
980
+                $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic
981 981
                 break;
982 982
             case 'DE':
983
-                $regex[] = '/^(DE)([1-9]\d{8})$/';                       // Germany
983
+                $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany
984 984
                 break;
985 985
             case 'DK':
986
-                $regex[] = '/^(DK)(\d{8})$/';                            // Denmark
986
+                $regex[] = '/^(DK)(\d{8})$/'; // Denmark
987 987
                 break;
988 988
             case 'EE':
989
-                $regex[] = '/^(EE)(10\d{7})$/';                          // Estonia
989
+                $regex[] = '/^(EE)(10\d{7})$/'; // Estonia
990 990
                 break;
991 991
             case 'EL':
992
-                $regex[] = '/^(EL)(\d{9})$/';                            // Greece
992
+                $regex[] = '/^(EL)(\d{9})$/'; // Greece
993 993
                 break;
994 994
             case 'ES':
995
-                $regex[] = '/^(ES)([A-Z]\d{8})$/';                       // Spain (National juridical entities)
996
-                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/';            // Spain (Other juridical entities)
997
-                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/';              // Spain (Personal entities type 1)
998
-                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/';              // Spain (Personal entities type 2)
995
+                $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities)
996
+                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities)
997
+                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1)
998
+                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2)
999 999
                 break;
1000 1000
             case 'EU':
1001
-                $regex[] = '/^(EU)(\d{9})$/';                            // EU-type
1001
+                $regex[] = '/^(EU)(\d{9})$/'; // EU-type
1002 1002
                 break;
1003 1003
             case 'FI':
1004
-                $regex[] = '/^(FI)(\d{8})$/';                            // Finland
1004
+                $regex[] = '/^(FI)(\d{8})$/'; // Finland
1005 1005
                 break;
1006 1006
             case 'FR':
1007
-                $regex[] = '/^(FR)(\d{11})$/';                           // France (1)
1008
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/';        // France (2)
1009
-                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/';       // France (3)
1010
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/';      // France (4)
1007
+                $regex[] = '/^(FR)(\d{11})$/'; // France (1)
1008
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2)
1009
+                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3)
1010
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4)
1011 1011
                 break;
1012 1012
             case 'GB':
1013
-                $regex[] = '/^(GB)?(\d{9})$/';                           // UK (Standard)
1014
-                $regex[] = '/^(GB)?(\d{12})$/';                          // UK (Branches)
1015
-                $regex[] = '/^(GB)?(GD\d{3})$/';                         // UK (Government)
1016
-                $regex[] = '/^(GB)?(HA\d{3})$/';                         // UK (Health authority)
1013
+                $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard)
1014
+                $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches)
1015
+                $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government)
1016
+                $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority)
1017 1017
                 break;
1018 1018
             case 'GR':
1019
-                $regex[] = '/^(GR)(\d{8,9})$/';                          // Greece
1019
+                $regex[] = '/^(GR)(\d{8,9})$/'; // Greece
1020 1020
                 break;
1021 1021
             case 'HR':
1022
-                $regex[] = '/^(HR)(\d{11})$/';                           // Croatia
1022
+                $regex[] = '/^(HR)(\d{11})$/'; // Croatia
1023 1023
                 break;
1024 1024
             case 'HU':
1025
-                $regex[] = '/^(HU)(\d{8})$/';                            // Hungary
1025
+                $regex[] = '/^(HU)(\d{8})$/'; // Hungary
1026 1026
                 break;
1027 1027
             case 'IE':
1028
-                $regex[] = '/^(IE)(\d{7}[A-W])$/';                       // Ireland (1)
1029
-                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/';        // Ireland (2)
1030
-                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/';                   // Ireland (3) (new format from 1 Jan 2013)
1028
+                $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1)
1029
+                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2)
1030
+                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013)
1031 1031
                 break;
1032 1032
             case 'IT':
1033
-                $regex[] = '/^(IT)(\d{11})$/';                           // Italy
1033
+                $regex[] = '/^(IT)(\d{11})$/'; // Italy
1034 1034
                 break;
1035 1035
             case 'LV':
1036
-                $regex[] = '/^(LV)(\d{11})$/';                           // Latvia
1036
+                $regex[] = '/^(LV)(\d{11})$/'; // Latvia
1037 1037
                 break;
1038 1038
             case 'LT':
1039
-                $regex[] = '/^(LT)(\d{9}|\d{12})$/';                     // Lithuania
1039
+                $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania
1040 1040
                 break;
1041 1041
             case 'LU':
1042
-                $regex[] = '/^(LU)(\d{8})$/';                            // Luxembourg
1042
+                $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg
1043 1043
                 break;
1044 1044
             case 'MT':
1045
-                $regex[] = '/^(MT)([1-9]\d{7})$/';                       // Malta
1045
+                $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta
1046 1046
                 break;
1047 1047
             case 'NL':
1048
-                $regex[] = '/^(NL)(\d{9})B\d{2}$/';                      // Netherlands
1048
+                $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands
1049 1049
                 break;
1050 1050
             case 'NO':
1051
-                $regex[] = '/^(NO)(\d{9})$/';                            // Norway (Not EU)
1051
+                $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU)
1052 1052
                 break;
1053 1053
             case 'PL':
1054
-                $regex[] = '/^(PL)(\d{10})$/';                           // Poland
1054
+                $regex[] = '/^(PL)(\d{10})$/'; // Poland
1055 1055
                 break;
1056 1056
             case 'PT':
1057
-                $regex[] = '/^(PT)(\d{9})$/';                            // Portugal
1057
+                $regex[] = '/^(PT)(\d{9})$/'; // Portugal
1058 1058
                 break;
1059 1059
             case 'RO':
1060
-                $regex[] = '/^(RO)([1-9]\d{1,9})$/';                     // Romania
1060
+                $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania
1061 1061
                 break;
1062 1062
             case 'RS':
1063
-                $regex[] = '/^(RS)(\d{9})$/';                            // Serbia (Not EU)
1063
+                $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU)
1064 1064
                 break;
1065 1065
             case 'SI':
1066
-                $regex[] = '/^(SI)([1-9]\d{7})$/';                       // Slovenia
1066
+                $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia
1067 1067
                 break;
1068 1068
             case 'SK':
1069
-                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/';        // Slovakia Republic
1069
+                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic
1070 1070
                 break;
1071 1071
             case 'SE':
1072
-                $regex[] = '/^(SE)(\d{10}01)$/';                         // Sweden
1072
+                $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden
1073 1073
                 break;
1074 1074
             default:
1075 1075
                 $regex = array();
1076 1076
             break;
1077 1077
         }
1078 1078
 
1079
-        if ( empty( $regex ) ) {
1079
+        if (empty($regex)) {
1080 1080
             return false;
1081 1081
         }
1082 1082
 
1083
-        foreach ( $regex as $pattern ) {
1083
+        foreach ($regex as $pattern) {
1084 1084
             $matches = null;
1085
-            preg_match_all( $pattern, $vat_number, $matches );
1085
+            preg_match_all($pattern, $vat_number, $matches);
1086 1086
 
1087
-            if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) {
1088
-                if ( $formatted ) {
1089
-                    return array( 'code' => $matches[1][0], 'number' => $matches[2][0] );
1087
+            if (!empty($matches[1][0]) && !empty($matches[2][0])) {
1088
+                if ($formatted) {
1089
+                    return array('code' => $matches[1][0], 'number' => $matches[2][0]);
1090 1090
                 } else {
1091 1091
                     return true;
1092 1092
                 }
@@ -1096,75 +1096,75 @@  discard block
 block discarded – undo
1096 1096
         return false;
1097 1097
     }
1098 1098
 
1099
-    public static function vies_check( $vat_number, $country_code = '', $result = false ) {
1100
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
1099
+    public static function vies_check($vat_number, $country_code = '', $result = false) {
1100
+        $vat            = self::sanitize_vat($vat_number, $country_code);
1101 1101
         $vat_number     = $vat['vat'];
1102 1102
         $iso            = $vat['iso'];
1103 1103
 
1104
-        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number );
1104
+        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number);
1105 1105
 
1106
-        if ( ini_get( 'allow_url_fopen' ) ) {
1107
-            $response = file_get_contents( $url );
1108
-        } else if ( function_exists( 'curl_init' ) ) {
1106
+        if (ini_get('allow_url_fopen')) {
1107
+            $response = file_get_contents($url);
1108
+        } else if (function_exists('curl_init')) {
1109 1109
             $ch = curl_init();
1110 1110
 
1111
-            curl_setopt( $ch, CURLOPT_URL, $url );
1112
-            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
1113
-            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1114
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
1115
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
1111
+            curl_setopt($ch, CURLOPT_URL, $url);
1112
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
1113
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1114
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
1115
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
1116 1116
 
1117
-            $response = curl_exec( $ch );
1117
+            $response = curl_exec($ch);
1118 1118
 
1119
-            if ( curl_errno( $ch ) ) {
1120
-                wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' );
1119
+            if (curl_errno($ch)) {
1120
+                wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR');
1121 1121
                 $response = '';
1122 1122
             }
1123 1123
 
1124
-            curl_close( $ch );
1124
+            curl_close($ch);
1125 1125
         } else {
1126
-            wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' );
1126
+            wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR');
1127 1127
         }
1128 1128
 
1129
-        if ( empty( $response ) ) {
1129
+        if (empty($response)) {
1130 1130
             return $result;
1131 1131
         }
1132 1132
 
1133
-        if ( preg_match( '/invalid VAT number/i', $response ) ) {
1133
+        if (preg_match('/invalid VAT number/i', $response)) {
1134 1134
             return false;
1135
-        } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) {
1136
-            $content = explode( "valid VAT number", htmlentities( $response ) );
1135
+        } else if (preg_match('/valid VAT number/i', $response, $matches)) {
1136
+            $content = explode("valid VAT number", htmlentities($response));
1137 1137
 
1138
-            if ( !empty( $content[1] ) ) {
1139
-                preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches );
1138
+            if (!empty($content[1])) {
1139
+                preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches);
1140 1140
 
1141
-                if ( !empty( $matches[2] ) && $matches[3] ) {
1141
+                if (!empty($matches[2]) && $matches[3]) {
1142 1142
                     $return = array();
1143 1143
 
1144
-                    foreach ( $matches[2] as $key => $label ) {
1145
-                        $label = trim( $label );
1144
+                    foreach ($matches[2] as $key => $label) {
1145
+                        $label = trim($label);
1146 1146
 
1147
-                        switch ( strtolower( $label ) ) {
1147
+                        switch (strtolower($label)) {
1148 1148
                             case 'member state':
1149
-                                $return['state'] = trim( strip_tags( $matches[3][$key] ) );
1149
+                                $return['state'] = trim(strip_tags($matches[3][$key]));
1150 1150
                             break;
1151 1151
                             case 'vat number':
1152
-                                $return['number'] = trim( strip_tags( $matches[3][$key] ) );
1152
+                                $return['number'] = trim(strip_tags($matches[3][$key]));
1153 1153
                             break;
1154 1154
                             case 'name':
1155
-                                $return['company'] = trim( strip_tags( $matches[3][$key] ) );
1155
+                                $return['company'] = trim(strip_tags($matches[3][$key]));
1156 1156
                             break;
1157 1157
                             case 'address':
1158
-                                $address           = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) );
1159
-                                $return['address'] = trim( strip_tags( $address, '<br>' ) );
1158
+                                $address           = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key])));
1159
+                                $return['address'] = trim(strip_tags($address, '<br>'));
1160 1160
                             break;
1161 1161
                             case 'consultation number':
1162
-                                $return['consultation'] = trim( strip_tags( $matches[3][$key] ) );
1162
+                                $return['consultation'] = trim(strip_tags($matches[3][$key]));
1163 1163
                             break;
1164 1164
                         }
1165 1165
                     }
1166 1166
 
1167
-                    if ( !empty( $return ) ) {
1167
+                    if (!empty($return)) {
1168 1168
                         return $return;
1169 1169
                     }
1170 1170
                 }
@@ -1176,62 +1176,62 @@  discard block
 block discarded – undo
1176 1176
         }
1177 1177
     }
1178 1178
 
1179
-    public static function check_vat( $vat_number, $country_code = '' ) {
1179
+    public static function check_vat($vat_number, $country_code = '') {
1180 1180
         $vat_name           = getpaid_vat_name();
1181 1181
 
1182 1182
         $return             = array();
1183 1183
         $return['valid']    = false;
1184
-        $return['message']  = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1184
+        $return['message']  = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1185 1185
 
1186
-        if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) {
1186
+        if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) {
1187 1187
             return $return;
1188 1188
         }
1189 1189
 
1190
-        $response = self::vies_check( $vat_number, $country_code );
1190
+        $response = self::vies_check($vat_number, $country_code);
1191 1191
 
1192
-        if ( $response ) {
1193
-            $return['valid']    = true;
1192
+        if ($response) {
1193
+            $return['valid'] = true;
1194 1194
 
1195
-            if ( is_array( $response ) ) {
1196
-                $return['company'] = isset( $response['company'] ) ? $response['company'] : '';
1197
-                $return['address'] = isset( $response['address'] ) ? $response['address'] : '';
1195
+            if (is_array($response)) {
1196
+                $return['company'] = isset($response['company']) ? $response['company'] : '';
1197
+                $return['address'] = isset($response['address']) ? $response['address'] : '';
1198 1198
                 $return['message'] = $return['company'] . '<br/>' . $return['address'];
1199 1199
             }
1200 1200
         } else {
1201 1201
             $return['valid']    = false;
1202
-            $return['message']  = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
1202
+            $return['message']  = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
1203 1203
         }
1204 1204
 
1205 1205
         return $return;
1206 1206
     }
1207 1207
 
1208
-    public static function request_euvatrates( $group ) {
1208
+    public static function request_euvatrates($group) {
1209 1209
         $response               = array();
1210 1210
         $response['success']    = false;
1211 1211
         $response['error']      = null;
1212 1212
         $response['eurates']    = null;
1213 1213
 
1214 1214
         $euvatrates_url = 'https://euvatrates.com/rates.json';
1215
-        $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url );
1216
-        $api_response   = wp_remote_get( $euvatrates_url );
1215
+        $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url);
1216
+        $api_response   = wp_remote_get($euvatrates_url);
1217 1217
 
1218 1218
         try {
1219
-            if ( is_wp_error( $api_response ) ) {
1220
-                $response['error']      = __( $api_response->get_error_message(), 'invoicing' );
1219
+            if (is_wp_error($api_response)) {
1220
+                $response['error'] = __($api_response->get_error_message(), 'invoicing');
1221 1221
             } else {
1222
-                $body = json_decode( $api_response['body'] );
1223
-                if ( isset( $body->rates ) ) {
1222
+                $body = json_decode($api_response['body']);
1223
+                if (isset($body->rates)) {
1224 1224
                     $rates = array();
1225 1225
 
1226
-                    foreach ( $body->rates as $country_code => $rate ) {
1226
+                    foreach ($body->rates as $country_code => $rate) {
1227 1227
                         $vat_rate = array();
1228 1228
                         $vat_rate['country']        = $rate->country;
1229
-                        $vat_rate['standard']       = (float)$rate->standard_rate;
1230
-                        $vat_rate['reduced']        = (float)$rate->reduced_rate;
1231
-                        $vat_rate['superreduced']   = (float)$rate->super_reduced_rate;
1232
-                        $vat_rate['parking']        = (float)$rate->parking_rate;
1229
+                        $vat_rate['standard']       = (float) $rate->standard_rate;
1230
+                        $vat_rate['reduced']        = (float) $rate->reduced_rate;
1231
+                        $vat_rate['superreduced']   = (float) $rate->super_reduced_rate;
1232
+                        $vat_rate['parking']        = (float) $rate->parking_rate;
1233 1233
 
1234
-                        if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) {
1234
+                        if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) {
1235 1235
                             $vat_rate_group = array();
1236 1236
                             $vat_rate_group['country'] = $rate->country;
1237 1237
                             $vat_rate_group[$group]    = $vat_rate[$group];
@@ -1243,79 +1243,79 @@  discard block
 block discarded – undo
1243 1243
                     }
1244 1244
 
1245 1245
                     $response['success']    = true;
1246
-                    $response['rates']      = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group );
1246
+                    $response['rates']      = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group);
1247 1247
                 } else {
1248
-                    $response['error']      = __( 'No EU rates found!', 'invoicing' );
1248
+                    $response['error']      = __('No EU rates found!', 'invoicing');
1249 1249
                 }
1250 1250
             }
1251
-        } catch ( Exception $e ) {
1252
-            $response['error'] = __( $e->getMessage(), 'invoicing' );
1251
+        } catch (Exception $e) {
1252
+            $response['error'] = __($e->getMessage(), 'invoicing');
1253 1253
         }
1254 1254
 
1255
-        return apply_filters( 'wpinv_response_euvatrates', $response, $group );
1255
+        return apply_filters('wpinv_response_euvatrates', $response, $group);
1256 1256
     }
1257 1257
 
1258
-    public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) {
1258
+    public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) {
1259 1259
         global $wpi_item_id, $wpi_country;
1260 1260
 
1261
-        if ( !empty( $_POST['wpinv_country'] ) ) {
1262
-            $country_code = trim( $_POST['wpinv_country'] );
1263
-        } else if ( !empty( $_POST['country'] ) ) {
1264
-            $country_code = trim( $_POST['country'] );
1265
-        } else if ( !empty( $wpi_country ) ) {
1261
+        if (!empty($_POST['wpinv_country'])) {
1262
+            $country_code = trim($_POST['wpinv_country']);
1263
+        } else if (!empty($_POST['country'])) {
1264
+            $country_code = trim($_POST['country']);
1265
+        } else if (!empty($wpi_country)) {
1266 1266
             $country_code = $wpi_country;
1267 1267
         } else {
1268
-            $country_code = self::get_user_country( '', $user_id );
1268
+            $country_code = self::get_user_country('', $user_id);
1269 1269
         }
1270 1270
 
1271
-        if ( $is_digital === null && $wpi_item_id ) {
1272
-            $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules();
1271
+        if ($is_digital === null && $wpi_item_id) {
1272
+            $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules();
1273 1273
         }
1274 1274
 
1275
-        if ( !empty( $country_code ) ) {
1276
-            $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( wpinv_get_default_country() ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( wpinv_get_default_country() ) );
1275
+        if (!empty($country_code)) {
1276
+            $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(wpinv_get_default_country()) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(wpinv_get_default_country()));
1277 1277
         }
1278 1278
 
1279
-        return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id );
1279
+        return apply_filters('wpinv_requires_vat', $requires_vat, $user_id);
1280 1280
     }
1281 1281
 
1282
-    public static function tax_label( $label = '' ) {
1282
+    public static function tax_label($label = '') {
1283 1283
         global $wpi_requires_vat;
1284 1284
 
1285
-        if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) {
1286
-            $wpi_requires_vat = self::requires_vat( 0, false );
1285
+        if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) {
1286
+            $wpi_requires_vat = self::requires_vat(0, false);
1287 1287
         }
1288 1288
 
1289
-        return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) );
1289
+        return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing'));
1290 1290
     }
1291 1291
 
1292 1292
     public static function standard_rates_label() {
1293
-        return __( 'Standard Rates', 'invoicing' );
1293
+        return __('Standard Rates', 'invoicing');
1294 1294
     }
1295 1295
 
1296
-    public static function get_rate_classes( $with_desc = false ) {
1297
-        $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true );
1298
-        $classes = maybe_unserialize( $rate_classes_option );
1296
+    public static function get_rate_classes($with_desc = false) {
1297
+        $rate_classes_option = get_option('_wpinv_vat_rate_classes', true);
1298
+        $classes = maybe_unserialize($rate_classes_option);
1299 1299
 
1300
-        if ( empty( $classes ) || !is_array( $classes ) ) {
1300
+        if (empty($classes) || !is_array($classes)) {
1301 1301
             $classes = array();
1302 1302
         }
1303 1303
 
1304 1304
         $rate_classes = array();
1305
-        if ( !array_key_exists( '_standard', $classes ) ) {
1306
-            if ( $with_desc ) {
1307
-                $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) );
1305
+        if (!array_key_exists('_standard', $classes)) {
1306
+            if ($with_desc) {
1307
+                $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing'));
1308 1308
             } else {
1309 1309
                 $rate_classes['_standard'] = self::standard_rates_label();
1310 1310
             }
1311 1311
         }
1312 1312
 
1313
-        foreach ( $classes as $key => $class ) {
1314
-            $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key;
1315
-            $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : '';
1313
+        foreach ($classes as $key => $class) {
1314
+            $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key;
1315
+            $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : '';
1316 1316
 
1317
-            if ( $with_desc ) {
1318
-                $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc );
1317
+            if ($with_desc) {
1318
+                $rate_classes[$key] = array('name' => $name, 'desc' => $desc);
1319 1319
             } else {
1320 1320
                 $rate_classes[$key] = $name;
1321 1321
             }
@@ -1326,15 +1326,15 @@  discard block
 block discarded – undo
1326 1326
 
1327 1327
     public static function get_all_classes() {
1328 1328
         $classes            = self::get_rate_classes();
1329
-        $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' );
1329
+        $classes['_exempt'] = __('Exempt (0%)', 'invoicing');
1330 1330
 
1331
-        return apply_filters( 'wpinv_vat_get_all_classes', $classes );
1331
+        return apply_filters('wpinv_vat_get_all_classes', $classes);
1332 1332
     }
1333 1333
 
1334
-    public static function get_class_desc( $rate_class ) {
1335
-        $rate_classes = self::get_rate_classes( true );
1334
+    public static function get_class_desc($rate_class) {
1335
+        $rate_classes = self::get_rate_classes(true);
1336 1336
 
1337
-        if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) {
1337
+        if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) {
1338 1338
             return $rate_classes[$rate_class]['desc'];
1339 1339
         }
1340 1340
 
@@ -1350,107 +1350,107 @@  discard block
 block discarded – undo
1350 1350
             'increased'     => 'Increased'
1351 1351
         );
1352 1352
 
1353
-        return apply_filters( 'wpinv_get_vat_groups', $vat_groups );
1353
+        return apply_filters('wpinv_get_vat_groups', $vat_groups);
1354 1354
     }
1355 1355
 
1356 1356
     public static function get_rules() {
1357 1357
         $vat_rules = array(
1358
-            'digital' => __( 'Digital Product', 'invoicing' ),
1359
-            'physical' => __( 'Physical Product', 'invoicing' ),
1360
-            '_exempt' => __( 'Tax-Free Product', 'invoicing' ),
1358
+            'digital' => __('Digital Product', 'invoicing'),
1359
+            'physical' => __('Physical Product', 'invoicing'),
1360
+            '_exempt' => __('Tax-Free Product', 'invoicing'),
1361 1361
         );
1362
-        return apply_filters( 'wpinv_get_vat_rules', $vat_rules );
1362
+        return apply_filters('wpinv_get_vat_rules', $vat_rules);
1363 1363
     }
1364 1364
 
1365
-    public static function get_vat_rates( $class ) {
1366
-        if ( $class === '_standard' ) {
1365
+    public static function get_vat_rates($class) {
1366
+        if ($class === '_standard') {
1367 1367
             return wpinv_get_tax_rates();
1368 1368
         }
1369 1369
 
1370 1370
         $rates = self::get_non_standard_rates();
1371 1371
 
1372
-        return array_key_exists( $class, $rates ) ? $rates[$class] : array();
1372
+        return array_key_exists($class, $rates) ? $rates[$class] : array();
1373 1373
     }
1374 1374
 
1375 1375
     public static function get_non_standard_rates() {
1376
-        $option = get_option( 'wpinv_vat_rates', array());
1377
-        return is_array( $option ) ? $option : array();
1376
+        $option = get_option('wpinv_vat_rates', array());
1377
+        return is_array($option) ? $option : array();
1378 1378
     }
1379 1379
 
1380 1380
     public static function allow_vat_rules() {
1381
-        return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false );
1381
+        return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false);
1382 1382
     }
1383 1383
 
1384 1384
     public static function allow_vat_classes() {
1385 1385
         return false; // TODO
1386
-        return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false );
1386
+        return (wpinv_get_option('vat_allow_classes') ? true : false);
1387 1387
     }
1388 1388
 
1389
-    public static function get_item_class( $postID ) {
1390
-        $class = get_post_meta( $postID, '_wpinv_vat_class', true );
1389
+    public static function get_item_class($postID) {
1390
+        $class = get_post_meta($postID, '_wpinv_vat_class', true);
1391 1391
 
1392
-        if ( empty( $class ) ) {
1392
+        if (empty($class)) {
1393 1393
             $class = '_standard';
1394 1394
         }
1395 1395
 
1396
-        return apply_filters( 'wpinv_get_item_vat_class', $class, $postID );
1396
+        return apply_filters('wpinv_get_item_vat_class', $class, $postID);
1397 1397
     }
1398 1398
 
1399
-    public static function item_class_label( $postID ) {
1399
+    public static function item_class_label($postID) {
1400 1400
         $vat_classes = self::get_all_classes();
1401 1401
 
1402
-        $class = self::get_item_class( $postID );
1403
-        $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' );
1402
+        $class = self::get_item_class($postID);
1403
+        $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing');
1404 1404
 
1405
-        return apply_filters( 'wpinv_item_class_label', $class, $postID );
1405
+        return apply_filters('wpinv_item_class_label', $class, $postID);
1406 1406
     }
1407 1407
 
1408
-    public static function get_item_rule( $postID ) {
1409
-        $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true );
1408
+    public static function get_item_rule($postID) {
1409
+        $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true);
1410 1410
 
1411
-        if ( empty( $rule_type ) ) {
1411
+        if (empty($rule_type)) {
1412 1412
             $rule_type = self::allow_vat_rules() ? 'digital' : 'physical';
1413 1413
         }
1414 1414
 
1415
-        return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID );
1415
+        return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID);
1416 1416
     }
1417 1417
 
1418
-    public static function item_rule_label( $postID ) {
1418
+    public static function item_rule_label($postID) {
1419 1419
         $vat_rules  = self::get_rules();
1420
-        $vat_rule   = self::get_item_rule( $postID );
1421
-        $vat_rule   = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule;
1420
+        $vat_rule   = self::get_item_rule($postID);
1421
+        $vat_rule   = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule;
1422 1422
 
1423
-        return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID );
1423
+        return apply_filters('wpinv_item_rule_label', $vat_rule, $postID);
1424 1424
     }
1425 1425
 
1426
-    public static function item_has_digital_rule( $item_id = 0 ) {
1427
-        return self::get_item_rule( $item_id ) == 'digital' ? true : false;
1426
+    public static function item_has_digital_rule($item_id = 0) {
1427
+        return self::get_item_rule($item_id) == 'digital' ? true : false;
1428 1428
     }
1429 1429
 
1430
-    public static function invoice_has_digital_rule( $invoice = 0 ) {
1431
-        if ( !self::allow_vat_rules() ) {
1430
+    public static function invoice_has_digital_rule($invoice = 0) {
1431
+        if (!self::allow_vat_rules()) {
1432 1432
             return false;
1433 1433
         }
1434 1434
 
1435
-        if ( empty( $invoice ) ) {
1435
+        if (empty($invoice)) {
1436 1436
             return true;
1437 1437
         }
1438 1438
 
1439
-        if ( is_int( $invoice ) ) {
1440
-            $invoice = new WPInv_Invoice( $invoice );
1439
+        if (is_int($invoice)) {
1440
+            $invoice = new WPInv_Invoice($invoice);
1441 1441
         }
1442 1442
 
1443
-        if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) {
1443
+        if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) {
1444 1444
             return true;
1445 1445
         }
1446 1446
 
1447
-        $cart_items  = $invoice->get_cart_details();
1447
+        $cart_items = $invoice->get_cart_details();
1448 1448
 
1449
-        if ( !empty( $cart_items ) ) {
1449
+        if (!empty($cart_items)) {
1450 1450
             $has_digital_rule = false;
1451 1451
 
1452
-            foreach ( $cart_items as $key => $item ) {
1453
-                if ( self::item_has_digital_rule( $item['id'] ) ) {
1452
+            foreach ($cart_items as $key => $item) {
1453
+                if (self::item_has_digital_rule($item['id'])) {
1454 1454
                     $has_digital_rule = true;
1455 1455
                     break;
1456 1456
                 }
@@ -1462,71 +1462,71 @@  discard block
 block discarded – undo
1462 1462
         return $has_digital_rule;
1463 1463
     }
1464 1464
 
1465
-    public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) {
1466
-        if ( !wpinv_use_taxes() ) {
1465
+    public static function item_is_taxable($item_id = 0, $country = false, $state = false) {
1466
+        if (!wpinv_use_taxes()) {
1467 1467
             return false;
1468 1468
         }
1469 1469
 
1470 1470
         $is_taxable = true;
1471 1471
 
1472
-        if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) {
1472
+        if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') {
1473 1473
             $is_taxable = false;
1474 1474
         }
1475 1475
 
1476
-        if ( !empty( $item_id ) && self::get_item_rule( $item_id ) == '_exempt' ) {
1476
+        if (!empty($item_id) && self::get_item_rule($item_id) == '_exempt') {
1477 1477
             $is_taxable = false;
1478 1478
         }
1479 1479
 
1480
-        return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state );
1480
+        return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state);
1481 1481
     }
1482 1482
 
1483
-    public static function find_rate( $country, $state, $rate, $class ) {
1483
+    public static function find_rate($country, $state, $rate, $class) {
1484 1484
         global $wpi_zero_tax;
1485 1485
 
1486
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1486
+        if ($class === '_exempt' || $wpi_zero_tax) {
1487 1487
             return 0;
1488 1488
         }
1489 1489
 
1490
-        $tax_rates   = wpinv_get_tax_rates();
1490
+        $tax_rates = wpinv_get_tax_rates();
1491 1491
 
1492
-        if ( $class !== '_standard' ) {
1493
-            $class_rates = self::get_vat_rates( $class );
1492
+        if ($class !== '_standard') {
1493
+            $class_rates = self::get_vat_rates($class);
1494 1494
 
1495
-            if ( is_array( $class_rates ) ) {
1495
+            if (is_array($class_rates)) {
1496 1496
                 $indexed_class_rates = array();
1497 1497
 
1498
-                foreach ( $class_rates as $key => $cr ) {
1498
+                foreach ($class_rates as $key => $cr) {
1499 1499
                     $indexed_class_rates[$cr['country']] = $cr;
1500 1500
                 }
1501 1501
 
1502
-                $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) {
1502
+                $tax_rates = array_map(function($tr) use($indexed_class_rates) {
1503 1503
                     $tr_country = $tr['country'];
1504
-                    if ( !isset( $indexed_class_rates[$tr_country] ) ) {
1504
+                    if (!isset($indexed_class_rates[$tr_country])) {
1505 1505
                         return $tr;
1506 1506
                     }
1507 1507
                     $icr = $indexed_class_rates[$tr_country];
1508
-                    return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr;
1508
+                    return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr;
1509 1509
 
1510
-                }, $tax_rates, $class_rates );
1510
+                }, $tax_rates, $class_rates);
1511 1511
             }
1512 1512
         }
1513 1513
 
1514
-        if ( !empty( $tax_rates ) ) {
1515
-            foreach ( $tax_rates as $key => $tax_rate ) {
1516
-                if ( $country != $tax_rate['country'] )
1514
+        if (!empty($tax_rates)) {
1515
+            foreach ($tax_rates as $key => $tax_rate) {
1516
+                if ($country != $tax_rate['country'])
1517 1517
                     continue;
1518 1518
 
1519
-                if ( !empty( $tax_rate['global'] ) ) {
1520
-                    if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) {
1521
-                        $rate = number_format( $tax_rate['rate'], 4 );
1519
+                if (!empty($tax_rate['global'])) {
1520
+                    if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) {
1521
+                        $rate = number_format($tax_rate['rate'], 4);
1522 1522
                     }
1523 1523
                 } else {
1524
-                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
1524
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
1525 1525
                         continue;
1526 1526
 
1527 1527
                     $state_rate = $tax_rate['rate'];
1528
-                    if ( 0 !== $state_rate || !empty( $state_rate ) ) {
1529
-                        $rate = number_format( $state_rate, 4 );
1528
+                    if (0 !== $state_rate || !empty($state_rate)) {
1529
+                        $rate = number_format($state_rate, 4);
1530 1530
                     }
1531 1531
                 }
1532 1532
             }
@@ -1535,84 +1535,84 @@  discard block
 block discarded – undo
1535 1535
         return $rate;
1536 1536
     }
1537 1537
 
1538
-    public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) {
1538
+    public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) {
1539 1539
         global $wpinv_options, $wpi_session, $wpi_item_id, $wpi_zero_tax;
1540 1540
 
1541 1541
         $item_id = $item_id > 0 ? $item_id : $wpi_item_id;
1542 1542
         $allow_vat_classes = self::allow_vat_classes();
1543
-        $class = $item_id ? self::get_item_class( $item_id ) : '_standard';
1543
+        $class = $item_id ? self::get_item_class($item_id) : '_standard';
1544 1544
 
1545
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1545
+        if ($class === '_exempt' || $wpi_zero_tax) {
1546 1546
             return 0;
1547
-        } else if ( !$allow_vat_classes ) {
1547
+        } else if (!$allow_vat_classes) {
1548 1548
             $class = '_standard';
1549 1549
         }
1550 1550
 
1551
-        if( !empty( $_POST['wpinv_country'] ) ) {
1551
+        if (!empty($_POST['wpinv_country'])) {
1552 1552
             $post_country = $_POST['wpinv_country'];
1553
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
1553
+        } elseif (!empty($_POST['wpinv_country'])) {
1554 1554
             $post_country = $_POST['wpinv_country'];
1555
-        } elseif( !empty( $_POST['country'] ) ) {
1555
+        } elseif (!empty($_POST['country'])) {
1556 1556
             $post_country = $_POST['country'];
1557 1557
         } else {
1558 1558
             $post_country = '';
1559 1559
         }
1560 1560
 
1561
-        $country        = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country );
1562
-        $base_country   = wpinv_is_base_country( $country );
1561
+        $country        = !empty($post_country) ? $post_country : wpinv_default_billing_country($country);
1562
+        $base_country   = wpinv_is_base_country($country);
1563 1563
 
1564
-        $requires_vat   = self::requires_vat( 0, false );
1565
-        $is_digital     = self::get_item_rule( $item_id ) == 'digital' ;
1566
-        $rate           = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate;
1564
+        $requires_vat   = self::requires_vat(0, false);
1565
+        $is_digital     = self::get_item_rule($item_id) == 'digital';
1566
+        $rate           = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate;
1567 1567
 
1568
-        if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country
1568
+        if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country
1569 1569
             $rate = 0;
1570
-        } else if ( $requires_vat ) {
1571
-            $vat_number = self::get_user_vat_number( '', 0, true );
1570
+        } else if ($requires_vat) {
1571
+            $vat_number = self::get_user_vat_number('', 0, true);
1572 1572
             $vat_info   = self::current_vat_data();
1573 1573
 
1574
-            if ( is_array( $vat_info ) ) {
1575
-                $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : "";
1574
+            if (is_array($vat_info)) {
1575
+                $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : "";
1576 1576
             }
1577 1577
 
1578
-            if ( $country == 'UK' ) {
1578
+            if ($country == 'UK') {
1579 1579
                 $country = 'GB';
1580 1580
             }
1581 1581
 
1582
-            if ( !empty( $vat_number ) ) {
1582
+            if (!empty($vat_number)) {
1583 1583
                 $rate = 0;
1584 1584
             } else {
1585
-                $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate
1585
+                $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate
1586 1586
             }
1587 1587
 
1588
-            if ( empty( $vat_number ) && !$is_digital ) {
1589
-                if ( $base_country ) {
1590
-                    $rate = self::find_rate( $country, null, $rate, $class );
1588
+            if (empty($vat_number) && !$is_digital) {
1589
+                if ($base_country) {
1590
+                    $rate = self::find_rate($country, null, $rate, $class);
1591 1591
                 } else {
1592
-                    if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1592
+                    if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1593 1593
                         $rate = $wpinv_options['eu_fallback_rate'];
1594
-                    } else if( !empty( $country ) ) {
1595
-                        $rate = self::find_rate( $country, $state, $rate, $class );
1594
+                    } else if (!empty($country)) {
1595
+                        $rate = self::find_rate($country, $state, $rate, $class);
1596 1596
                     }
1597 1597
                 }
1598
-            } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) {
1599
-                if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1598
+            } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) {
1599
+                if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1600 1600
                     $rate = $wpinv_options['eu_fallback_rate'];
1601
-                } else if( !empty( $country ) ) {
1602
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1601
+                } else if (!empty($country)) {
1602
+                    $rate = self::find_rate($country, $state, $rate, $class);
1603 1603
                 }
1604 1604
             }
1605 1605
         } else {
1606
-            if ( $is_digital ) {
1606
+            if ($is_digital) {
1607 1607
                 $ip_country_code = self::get_country_by_ip();
1608 1608
 
1609
-                if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) {
1610
-                    $rate = self::find_rate( $ip_country_code, '', 0, $class );
1609
+                if ($ip_country_code && self::is_eu_state($ip_country_code)) {
1610
+                    $rate = self::find_rate($ip_country_code, '', 0, $class);
1611 1611
                 } else {
1612
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1612
+                    $rate = self::find_rate($country, $state, $rate, $class);
1613 1613
                 }
1614 1614
             } else {
1615
-                $rate = self::find_rate( $country, $state, $rate, $class );
1615
+                $rate = self::find_rate($country, $state, $rate, $class);
1616 1616
             }
1617 1617
         }
1618 1618
 
@@ -1622,48 +1622,48 @@  discard block
 block discarded – undo
1622 1622
     public static function current_vat_data() {
1623 1623
         global $wpi_session;
1624 1624
 
1625
-        return $wpi_session->get( 'user_vat_data' );
1625
+        return $wpi_session->get('user_vat_data');
1626 1626
     }
1627 1627
 
1628
-    public static function get_user_country( $country = '', $user_id = 0 ) {
1629
-        $user_address = wpinv_get_user_address( $user_id, false );
1628
+    public static function get_user_country($country = '', $user_id = 0) {
1629
+        $user_address = wpinv_get_user_address($user_id, false);
1630 1630
 
1631
-        if ( wpinv_get_option( 'vat_ip_country_default' ) ) {
1631
+        if (wpinv_get_option('vat_ip_country_default')) {
1632 1632
             $country = '';
1633 1633
         }
1634 1634
 
1635
-        $country    = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country'];
1636
-        $result     = apply_filters( 'wpinv_get_user_country', $country, $user_id );
1635
+        $country    = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country'];
1636
+        $result     = apply_filters('wpinv_get_user_country', $country, $user_id);
1637 1637
 
1638
-        if ( empty( $result ) ) {
1638
+        if (empty($result)) {
1639 1639
             $result = self::get_country_by_ip();
1640 1640
         }
1641 1641
 
1642 1642
         return $result;
1643 1643
     }
1644 1644
 
1645
-    public static function set_user_country( $country = '', $user_id = 0 ) {
1645
+    public static function set_user_country($country = '', $user_id = 0) {
1646 1646
         global $wpi_userID;
1647 1647
 
1648
-        if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) {
1648
+        if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) {
1649 1649
             $country = wpinv_get_default_country();
1650 1650
         }
1651 1651
 
1652 1652
         return $country;
1653 1653
     }
1654 1654
 
1655
-    public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) {
1655
+    public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) {
1656 1656
         global $wpi_current_id, $wpi_userID;
1657 1657
 
1658
-        if ( !empty( $_POST['new_user'] ) ) {
1658
+        if (!empty($_POST['new_user'])) {
1659 1659
             return '';
1660 1660
         }
1661 1661
 
1662
-        if ( empty( $user_id ) ) {
1663
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1662
+        if (empty($user_id)) {
1663
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1664 1664
         }
1665 1665
 
1666
-        $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true );
1666
+        $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true);
1667 1667
 
1668 1668
         /* TODO
1669 1669
         if ( $is_valid && $vat_number ) {
@@ -1674,38 +1674,38 @@  discard block
 block discarded – undo
1674 1674
         }
1675 1675
         */
1676 1676
 
1677
-        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid );
1677
+        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid);
1678 1678
     }
1679 1679
 
1680
-    public static function get_user_company( $company = '', $user_id = 0 ) {
1680
+    public static function get_user_company($company = '', $user_id = 0) {
1681 1681
         global $wpi_current_id, $wpi_userID;
1682 1682
 
1683
-        if ( empty( $user_id ) ) {
1684
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1683
+        if (empty($user_id)) {
1684
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1685 1685
         }
1686 1686
 
1687
-        $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
1687
+        $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
1688 1688
 
1689
-        return apply_filters( 'wpinv_user_company', $company, $user_id );
1689
+        return apply_filters('wpinv_user_company', $company, $user_id);
1690 1690
     }
1691 1691
 
1692
-    public static function save_user_vat_details( $company = '', $vat_number = '' ) {
1693
-        $save = apply_filters( 'wpinv_allow_save_user_vat_details', true );
1692
+    public static function save_user_vat_details($company = '', $vat_number = '') {
1693
+        $save = apply_filters('wpinv_allow_save_user_vat_details', true);
1694 1694
 
1695
-        if ( is_user_logged_in() && $save ) {
1695
+        if (is_user_logged_in() && $save) {
1696 1696
             $user_id = get_current_user_id();
1697 1697
 
1698
-            if ( !empty( $vat_number ) ) {
1699
-                update_user_meta( $user_id, '_wpinv_vat_number', $vat_number );
1698
+            if (!empty($vat_number)) {
1699
+                update_user_meta($user_id, '_wpinv_vat_number', $vat_number);
1700 1700
             } else {
1701
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1701
+                delete_user_meta($user_id, '_wpinv_vat_number');
1702 1702
             }
1703 1703
 
1704
-            if ( !empty( $company ) ) {
1705
-                update_user_meta( $user_id, '_wpinv_company', $company );
1704
+            if (!empty($company)) {
1705
+                update_user_meta($user_id, '_wpinv_company', $company);
1706 1706
             } else {
1707
-                delete_user_meta( $user_id, '_wpinv_company');
1708
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1707
+                delete_user_meta($user_id, '_wpinv_company');
1708
+                delete_user_meta($user_id, '_wpinv_vat_number');
1709 1709
             }
1710 1710
         }
1711 1711
 
@@ -1715,113 +1715,113 @@  discard block
 block discarded – undo
1715 1715
     public static function ajax_vat_validate() {
1716 1716
         global $wpinv_options, $wpi_session;
1717 1717
 
1718
-        $is_checkout            = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false;
1718
+        $is_checkout            = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false;
1719 1719
         $response               = array();
1720 1720
         $response['success']    = false;
1721 1721
 
1722
-        if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) {
1723
-            $response['error'] = __( 'Invalid security nonce', 'invoicing' );
1724
-            wp_send_json( $response );
1722
+        if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) {
1723
+            $response['error'] = __('Invalid security nonce', 'invoicing');
1724
+            wp_send_json($response);
1725 1725
         }
1726 1726
 
1727
-        $vat_name   = self::get_vat_name();
1727
+        $vat_name = self::get_vat_name();
1728 1728
 
1729
-        if ( $is_checkout ) {
1729
+        if ($is_checkout) {
1730 1730
             $invoice = wpinv_get_invoice_cart();
1731 1731
 
1732
-            if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) {
1732
+            if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) {
1733 1733
                 $vat_info = array();
1734
-                $wpi_session->set( 'user_vat_data', $vat_info );
1734
+                $wpi_session->set('user_vat_data', $vat_info);
1735 1735
 
1736 1736
                 self::save_user_vat_details();
1737 1737
 
1738 1738
                 $response['success'] = true;
1739
-                $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name );
1740
-                wp_send_json( $response );
1739
+                $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name);
1740
+                wp_send_json($response);
1741 1741
             }
1742 1742
         }
1743 1743
 
1744
-        $company    = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : '';
1745
-        $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : '';
1744
+        $company    = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : '';
1745
+        $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : '';
1746 1746
 
1747
-        $vat_info = $wpi_session->get( 'user_vat_data' );
1748
-        if ( !is_array( $vat_info ) || empty( $vat_info ) ) {
1749
-            $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true );
1747
+        $vat_info = $wpi_session->get('user_vat_data');
1748
+        if (!is_array($vat_info) || empty($vat_info)) {
1749
+            $vat_info = array('company'=> $company, 'number' => '', 'valid' => true);
1750 1750
         }
1751 1751
 
1752
-        if ( empty( $vat_number ) ) {
1753
-            if ( $is_checkout ) {
1752
+        if (empty($vat_number)) {
1753
+            if ($is_checkout) {
1754 1754
                 $response['success'] = true;
1755
-                $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name );
1755
+                $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name);
1756 1756
 
1757
-                $vat_info = $wpi_session->get( 'user_vat_data' );
1757
+                $vat_info = $wpi_session->get('user_vat_data');
1758 1758
                 $vat_info['number'] = "";
1759 1759
                 $vat_info['valid'] = true;
1760 1760
 
1761
-                self::save_user_vat_details( $company );
1761
+                self::save_user_vat_details($company);
1762 1762
             } else {
1763
-                $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
1763
+                $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
1764 1764
 
1765 1765
                 $vat_info['valid'] = false;
1766 1766
             }
1767 1767
 
1768
-            $wpi_session->set( 'user_vat_data', $vat_info );
1769
-            wp_send_json( $response );
1768
+            $wpi_session->set('user_vat_data', $vat_info);
1769
+            wp_send_json($response);
1770 1770
         }
1771 1771
 
1772
-        if ( empty( $company ) ) {
1772
+        if (empty($company)) {
1773 1773
             $vat_info['valid'] = false;
1774
-            $wpi_session->set( 'user_vat_data', $vat_info );
1774
+            $wpi_session->set('user_vat_data', $vat_info);
1775 1775
 
1776
-            $response['error'] = __( 'Please enter your registered company name!', 'invoicing' );
1777
-            wp_send_json( $response );
1776
+            $response['error'] = __('Please enter your registered company name!', 'invoicing');
1777
+            wp_send_json($response);
1778 1778
         }
1779 1779
 
1780
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
1781
-            if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1780
+        if (!empty($wpinv_options['vat_vies_check'])) {
1781
+            if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
1782 1782
                 $vat_info['valid'] = false;
1783
-                $wpi_session->set( 'user_vat_data', $vat_info );
1783
+                $wpi_session->set('user_vat_data', $vat_info);
1784 1784
 
1785
-                $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1786
-                wp_send_json( $response );
1785
+                $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1786
+                wp_send_json($response);
1787 1787
             }
1788 1788
 
1789 1789
             $response['success'] = true;
1790
-            $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1790
+            $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1791 1791
         } else {
1792
-            $result = self::check_vat( $vat_number );
1792
+            $result = self::check_vat($vat_number);
1793 1793
 
1794
-            if ( empty( $result['valid'] ) ) {
1794
+            if (empty($result['valid'])) {
1795 1795
                 $response['error'] = $result['message'];
1796
-                wp_send_json( $response );
1796
+                wp_send_json($response);
1797 1797
             }
1798 1798
 
1799
-            $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1800
-            $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1799
+            $vies_company = !empty($result['company']) ? $result['company'] : '';
1800
+            $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1801 1801
 
1802
-            $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1802
+            $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1803 1803
 
1804
-            if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) {
1804
+            if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) {
1805 1805
                 $response['success'] = true;
1806
-                $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1806
+                $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1807 1807
             } else {
1808 1808
                 $vat_info['valid'] = false;
1809
-                $wpi_session->set( 'user_vat_data', $vat_info );
1809
+                $wpi_session->set('user_vat_data', $vat_info);
1810 1810
 
1811 1811
                 $response['success'] = false;
1812
-                $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name );
1813
-                wp_send_json( $response );
1812
+                $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name);
1813
+                wp_send_json($response);
1814 1814
             }
1815 1815
         }
1816 1816
 
1817
-        if ( $is_checkout ) {
1818
-            self::save_user_vat_details( $company, $vat_number );
1817
+        if ($is_checkout) {
1818
+            self::save_user_vat_details($company, $vat_number);
1819 1819
 
1820
-            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true );
1821
-            $wpi_session->set( 'user_vat_data', $vat_info );
1820
+            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true);
1821
+            $wpi_session->set('user_vat_data', $vat_info);
1822 1822
         }
1823 1823
 
1824
-        wp_send_json( $response );
1824
+        wp_send_json($response);
1825 1825
     }
1826 1826
 
1827 1827
     /**
@@ -1829,16 +1829,16 @@  discard block
 block discarded – undo
1829 1829
      * 
1830 1830
      * @return string
1831 1831
      */
1832
-    public static function validate_vat_number( $vat_number, $company, $country ) {
1832
+    public static function validate_vat_number($vat_number, $company, $country) {
1833 1833
         global $wpinv_options;
1834 1834
 
1835 1835
         // If we are not checking the vat number via view...
1836
-        if ( ! empty( $wpinv_options['vat_vies_check'] ) ) {
1836
+        if (!empty($wpinv_options['vat_vies_check'])) {
1837 1837
 
1838 1838
             // Try validating via regex.
1839
-            if ( empty( $wpinv_options['vat_offline_check'] ) && ! self::offline_check( $vat_number, $country ) ) {
1839
+            if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number, $country)) {
1840 1840
                 return wp_sprintf(
1841
-                    __( 'Your %s number is invalid', 'invoicing' ),
1841
+                    __('Your %s number is invalid', 'invoicing'),
1842 1842
                     getpaid_vat_name()
1843 1843
                 );
1844 1844
             }
@@ -1847,23 +1847,23 @@  discard block
 block discarded – undo
1847 1847
         }
1848 1848
 
1849 1849
         // Validate the vat number.
1850
-        $result = self::check_vat( $vat_number, $country );
1850
+        $result = self::check_vat($vat_number, $country);
1851 1851
 
1852
-        if ( empty( $result['valid'] ) ) {
1852
+        if (empty($result['valid'])) {
1853 1853
             return wp_sprintf(
1854
-                __( 'Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing' ),
1854
+                __('Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing'),
1855 1855
                 getpaid_vat_name()
1856 1856
             );
1857 1857
         }
1858 1858
 
1859 1859
         // Validate the company.
1860
-        $vies_company  = ! empty( $result['company'] ) ? $result['company'] : '';
1861
-        $vies_company  = apply_filters( 'wpinv_vies_company_name', $vies_company );
1862
-        $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1860
+        $vies_company  = !empty($result['company']) ? $result['company'] : '';
1861
+        $vies_company  = apply_filters('wpinv_vies_company_name', $vies_company);
1862
+        $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1863 1863
 
1864
-        if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) {
1864
+        if (!$valid_company && !empty($wpinv_options['vat_disable_company_name_check'])) {
1865 1865
            return wp_sprintf(
1866
-                __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ),
1866
+                __('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'),
1867 1867
                 getpaid_vat_name()
1868 1868
             );
1869 1869
         }
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
                 if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) {
713 713
                     $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode;
714 714
                 }
715
-            }elseif(!empty( $ip )){
715
+            } elseif(!empty( $ip )){
716 716
                 $url = 'http://ip-api.com/json/' . $ip;
717 717
                 $response = wp_remote_get($url);
718 718
 
@@ -1513,16 +1513,18 @@  discard block
 block discarded – undo
1513 1513
 
1514 1514
         if ( !empty( $tax_rates ) ) {
1515 1515
             foreach ( $tax_rates as $key => $tax_rate ) {
1516
-                if ( $country != $tax_rate['country'] )
1517
-                    continue;
1516
+                if ( $country != $tax_rate['country'] ) {
1517
+                                    continue;
1518
+                }
1518 1519
 
1519 1520
                 if ( !empty( $tax_rate['global'] ) ) {
1520 1521
                     if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) {
1521 1522
                         $rate = number_format( $tax_rate['rate'], 4 );
1522 1523
                     }
1523 1524
                 } else {
1524
-                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
1525
-                        continue;
1525
+                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) {
1526
+                                            continue;
1527
+                    }
1526 1528
 
1527 1529
                     $state_rate = $tax_rate['rate'];
1528 1530
                     if ( 0 !== $state_rate || !empty( $state_rate ) ) {
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -38,35 +38,35 @@  discard block
 block discarded – undo
38 38
     }
39 39
     
40 40
     public function define_constants() {
41
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
42
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
41
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
42
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
43 43
     }
44 44
 
45 45
     private function actions() {
46 46
         /* Internationalize the text strings used. */
47
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
47
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
48 48
         
49 49
         /* Perform actions on admin initialization. */
50
-        add_action( 'admin_init', array( &$this, 'admin_init') );
51
-        add_action( 'init', array( &$this, 'init' ), 3 );
52
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
50
+        add_action('admin_init', array(&$this, 'admin_init'));
51
+        add_action('init', array(&$this, 'init'), 3);
52
+        add_action('init', array(&$this, 'wpinv_actions'));
53 53
         
54
-        if ( class_exists( 'BuddyPress' ) ) {
55
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
54
+        if (class_exists('BuddyPress')) {
55
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
56 56
         }
57 57
 
58
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
59
-        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
60
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
61
-        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
58
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
59
+        add_action('wp_footer', array(&$this, 'wp_footer'));
60
+        add_action('widgets_init', array(&$this, 'register_widgets'));
61
+        add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
62 62
 
63
-        if ( is_admin() ) {
64
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
65
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
66
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
63
+        if (is_admin()) {
64
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
65
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
66
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
67 67
 
68 68
         } else {
69
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
69
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
70 70
         }
71 71
         
72 72
         /**
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
          *
77 77
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
78 78
          */
79
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
79
+        do_action_ref_array('wpinv_actions', array(&$this));
80 80
 
81
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
81
+        add_action('admin_init', array(&$this, 'activation_redirect'));
82 82
     }
83 83
 
84 84
     /**
85 85
      * Maybe show the AyeCode Connect Notice.
86 86
      */
87
-    public function init_ayecode_connect_helper(){
87
+    public function init_ayecode_connect_helper() {
88 88
         // AyeCode Connect notice
89
-        if ( is_admin() ){
89
+        if (is_admin()) {
90 90
             // set the strings so they can be translated
91 91
             $strings = array(
92
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
93
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
94
-                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
95
-                'connect_button'    => __("Connect Site","invoicing"),
96
-                'connecting_button'    => __("Connecting...","invoicing"),
97
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
98
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
92
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
93
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
94
+                'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
95
+                'connect_button'    => __("Connect Site", "invoicing"),
96
+                'connecting_button'    => __("Connecting...", "invoicing"),
97
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
98
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
99 99
             );
100
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
100
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
101 101
         }
102 102
     }
103 103
     
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
         /* Internationalize the text strings used. */
106 106
         $this->load_textdomain();
107 107
 
108
-        do_action( 'wpinv_loaded' );
108
+        do_action('wpinv_loaded');
109 109
 
110 110
         // Fix oxygen page builder conflict
111
-        if ( function_exists( 'ct_css_output' ) ) {
111
+        if (function_exists('ct_css_output')) {
112 112
             wpinv_oxygen_fix_conflict();
113 113
         }
114 114
     }
@@ -118,147 +118,147 @@  discard block
 block discarded – undo
118 118
      *
119 119
      * @since 1.0
120 120
      */
121
-    public function load_textdomain( $locale = NULL ) {
122
-        if ( empty( $locale ) ) {
123
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
121
+    public function load_textdomain($locale = NULL) {
122
+        if (empty($locale)) {
123
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
124 124
         }
125 125
 
126
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
126
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
127 127
         
128
-        unload_textdomain( 'invoicing' );
129
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
130
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
128
+        unload_textdomain('invoicing');
129
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
130
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
131 131
         
132 132
         /**
133 133
          * Define language constants.
134 134
          */
135
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
135
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
136 136
     }
137 137
 
138 138
     public function includes() {
139 139
         global $wpinv_options;
140 140
 
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
142 142
         $wpinv_options = wpinv_get_settings();
143 143
 
144 144
         // Load composer packages.
145
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
145
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
146 146
 
147 147
         // load AUI
148
-        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
148
+        require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
149 149
 
150 150
         // Load the action scheduler.
151
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
151
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
152 152
 
153 153
         // Load functions.
154
-        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
156
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
157
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
158
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
160
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
164
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
165
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
166
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
154
+        require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
156
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
157
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
158
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
160
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
164
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
165
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
166
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
168 168
 
169 169
         // Register autoloader.
170 170
 		try {
171
-			spl_autoload_register( array( $this, 'autoload' ), true );
172
-		} catch ( Exception $e ) {
173
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
174
-        }
175
-
176
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' );
177
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
178
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
179
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
180
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
181
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
182
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
183
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
184
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
185
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
186
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
187
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
188
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
189
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
190
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
191
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
192
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
193
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
194
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
195
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
196
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
197
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
198
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
199
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
200
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
201
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
202
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
203
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
204
-        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
205
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
171
+			spl_autoload_register(array($this, 'autoload'), true);
172
+		} catch (Exception $e) {
173
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
174
+        }
175
+
176
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php');
177
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
178
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
179
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
180
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
181
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
182
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
183
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
184
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
185
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
186
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
187
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
188
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
189
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
190
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
191
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
192
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
193
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
194
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
195
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
196
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
197
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
198
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
199
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
200
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
201
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
202
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
203
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
204
+        require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
205
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
206 206
 
207 207
         /**
208 208
          * Load the tax class.
209 209
          */
210
-        if ( ! class_exists( 'WPInv_EUVat' ) ) {
211
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
210
+        if (!class_exists('WPInv_EUVat')) {
211
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
212 212
         }
213 213
 
214
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
215
-        if ( !empty( $gateways ) ) {
216
-            foreach ( $gateways as $gateway ) {
217
-                if ( $gateway == 'manual' ) {
214
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
215
+        if (!empty($gateways)) {
216
+            foreach ($gateways as $gateway) {
217
+                if ($gateway == 'manual') {
218 218
                     continue;
219 219
                 }
220 220
                 
221 221
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
222 222
                 
223
-                if ( file_exists( $gateway_file ) ) {
224
-                    require_once( $gateway_file );
223
+                if (file_exists($gateway_file)) {
224
+                    require_once($gateway_file);
225 225
                 }
226 226
             }
227 227
         }
228
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
228
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
229 229
         
230
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
230
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
231 231
             GetPaid_Post_Types_Admin::init();
232 232
 
233
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
234
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
233
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
234
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
235 235
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
236
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
237
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
238
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
239
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
240
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
241
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
236
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
237
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
238
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
239
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
240
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
241
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
242 242
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
243 243
             // load the user class only on the users.php page
244 244
             global $pagenow;
245
-            if($pagenow=='users.php'){
245
+            if ($pagenow == 'users.php') {
246 246
                 new WPInv_Admin_Users();
247 247
             }
248 248
         }
249 249
 
250 250
         // Register cli commands
251
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
252
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
253
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
251
+        if (defined('WP_CLI') && WP_CLI) {
252
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
253
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
254 254
         }
255 255
         
256 256
         // include css inliner
257
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
258
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
257
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
258
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
259 259
         }
260 260
         
261
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
261
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
262 262
     }
263 263
 
264 264
     /**
@@ -269,18 +269,18 @@  discard block
 block discarded – undo
269 269
 	 * @since       1.0.19
270 270
 	 * @return      void
271 271
 	 */
272
-	public function autoload( $class_name ) {
272
+	public function autoload($class_name) {
273 273
 
274 274
 		// Normalize the class name...
275
-		$class_name  = strtolower( $class_name );
275
+		$class_name = strtolower($class_name);
276 276
 
277 277
 		// ... and make sure it is our class.
278
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
278
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
279 279
 			return;
280 280
 		}
281 281
 
282 282
 		// Next, prepare the file name from the class.
283
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
283
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
284 284
 
285 285
 		// And an array of possible locations in order of importance.
286 286
 		$locations = array(
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 		);
292 292
 
293 293
 		// Base path of the classes.
294
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
294
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
295 295
 
296
-		foreach ( $locations as $location ) {
296
+		foreach ($locations as $location) {
297 297
 
298
-			if ( file_exists( "$plugin_path/$location/$file_name" ) ) {
298
+			if (file_exists("$plugin_path/$location/$file_name")) {
299 299
 				include "$plugin_path/$location/$file_name";
300 300
 				break;
301 301
 			}
@@ -309,117 +309,117 @@  discard block
 block discarded – undo
309 309
     
310 310
     public function admin_init() {
311 311
         self::$instance->default_payment_form = wpinv_get_default_payment_form();
312
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
312
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
313 313
     }
314 314
 
315 315
     public function activation_redirect() {
316 316
         // Bail if no activation redirect
317
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
317
+        if (!get_transient('_wpinv_activation_redirect')) {
318 318
             return;
319 319
         }
320 320
 
321 321
         // Delete the redirect transient
322
-        delete_transient( '_wpinv_activation_redirect' );
322
+        delete_transient('_wpinv_activation_redirect');
323 323
 
324 324
         // Bail if activating from network, or bulk
325
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
325
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
326 326
             return;
327 327
         }
328 328
 
329
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
329
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
330 330
         exit;
331 331
     }
332 332
     
333 333
     public function enqueue_scripts() {
334
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
334
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
335 335
         
336
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
337
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
338
-        wp_enqueue_style( 'wpinv_front_style' );
336
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
337
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
338
+        wp_enqueue_style('wpinv_front_style');
339 339
                
340 340
         // Register scripts
341
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
342
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
341
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
342
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
343 343
 
344 344
         $localize                         = array();
345
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
346
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
345
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
346
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
347 347
         $localize['currency_symbol']      = wpinv_currency_symbol();
348 348
         $localize['currency_pos']         = wpinv_currency_position();
349 349
         $localize['thousand_sep']         = wpinv_thousands_separator();
350 350
         $localize['decimal_sep']          = wpinv_decimal_separator();
351 351
         $localize['decimals']             = wpinv_decimals();
352
-        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
352
+        $localize['txtComplete']          = __('Continue', 'invoicing');
353 353
         $localize['UseTaxes']             = wpinv_use_taxes();
354
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
355
-        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
356
-        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
354
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
355
+        $localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
356
+        $localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
357 357
 
358
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
358
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
359 359
         
360
-        wp_enqueue_script( 'jquery-blockui' );
360
+        wp_enqueue_script('jquery-blockui');
361 361
         $autofill_api = wpinv_get_option('address_autofill_api');
362 362
         $autofill_active = wpinv_get_option('address_autofill_active');
363
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
364
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
365
-                wp_dequeue_script( 'google-maps-api' );
363
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
364
+            if (wp_script_is('google-maps-api', 'enqueued')) {
365
+                wp_dequeue_script('google-maps-api');
366 366
             }
367
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
368
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
367
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
368
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
369 369
         }
370 370
 
371
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
372
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
371
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
372
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
373 373
 
374
-        wp_enqueue_script( 'wpinv-front-script' );
375
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
374
+        wp_enqueue_script('wpinv-front-script');
375
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
376 376
 
377
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
378
-        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
377
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
378
+        wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
379 379
     }
380 380
 
381
-    public function admin_enqueue_scripts( $hook ) {
381
+    public function admin_enqueue_scripts($hook) {
382 382
         global $post, $pagenow;
383 383
         
384 384
         $post_type  = wpinv_admin_post_type();
385
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
386
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
385
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
386
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
387 387
 
388 388
         $jquery_ui_css = false;
389
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
389
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
390 390
             $jquery_ui_css = true;
391
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
391
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
392 392
             $jquery_ui_css = true;
393 393
         }
394
-        if ( $jquery_ui_css ) {
395
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
396
-            wp_enqueue_style( 'jquery-ui-css' );
397
-            wp_deregister_style( 'yoast-seo-select2' );
398
-	        wp_deregister_style( 'yoast-seo-monorepo' );
394
+        if ($jquery_ui_css) {
395
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
396
+            wp_enqueue_style('jquery-ui-css');
397
+            wp_deregister_style('yoast-seo-select2');
398
+	        wp_deregister_style('yoast-seo-monorepo');
399 399
         }
400 400
 
401
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
402
-        wp_enqueue_style( 'wpinv_meta_box_style' );
401
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
402
+        wp_enqueue_style('wpinv_meta_box_style');
403 403
         
404
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
405
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
406
-        wp_enqueue_style( 'wpinv_admin_style' );
404
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
405
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
406
+        wp_enqueue_style('wpinv_admin_style');
407 407
 
408
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
409
-        if ( $page == 'wpinv-subscriptions' ) {
410
-            wp_enqueue_script( 'jquery-ui-datepicker' );
411
-            wp_deregister_style( 'yoast-seo-select2' );
412
-	        wp_deregister_style( 'yoast-seo-monorepo' );
408
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
409
+        if ($page == 'wpinv-subscriptions') {
410
+            wp_enqueue_script('jquery-ui-datepicker');
411
+            wp_deregister_style('yoast-seo-select2');
412
+	        wp_deregister_style('yoast-seo-monorepo');
413 413
         }
414 414
         
415
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
416
-            wp_enqueue_script( 'jquery-ui-datepicker' );
415
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
416
+            wp_enqueue_script('jquery-ui-datepicker');
417 417
         }
418 418
 
419
-        wp_enqueue_style( 'wp-color-picker' );
420
-        wp_enqueue_script( 'wp-color-picker' );
419
+        wp_enqueue_style('wp-color-picker');
420
+        wp_enqueue_script('wp-color-picker');
421 421
         
422
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
422
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
423 423
 
424 424
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
425 425
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -430,21 +430,21 @@  discard block
 block discarded – undo
430 430
             }
431 431
         }
432 432
 
433
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
434
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
433
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
434
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
435 435
 
436
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
437
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  $version );
438
-        wp_enqueue_script( 'wpinv-admin-script' );
436
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
437
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version);
438
+        wp_enqueue_script('wpinv-admin-script');
439 439
         
440 440
         $localize                               = array();
441
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
442
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
443
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
444
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
445
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
446
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
447
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
441
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
442
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
443
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
444
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
445
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
446
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
447
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
448 448
         $localize['tax']                        = wpinv_tax_amount();
449 449
         $localize['discount']                   = wpinv_discount_amount();
450 450
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -452,104 +452,104 @@  discard block
 block discarded – undo
452 452
         $localize['thousand_sep']               = wpinv_thousands_separator();
453 453
         $localize['decimal_sep']                = wpinv_decimal_separator();
454 454
         $localize['decimals']                   = wpinv_decimals();
455
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
456
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
457
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
458
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
459
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
460
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
461
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
462
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
463
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
464
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
465
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
466
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
467
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
468
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
469
-        $localize['item_description']           = __( 'Item Description', 'invoicing' );
470
-        $localize['discount_description']       = __( 'Discount Description', 'invoicing' );
471
-        $localize['invoice_description']        = __( 'Invoice Description', 'invoicing' );
472
-        $localize['searching']                  = __( 'Searching', 'invoicing' );
473
-
474
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
475
-
476
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
455
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
456
+        $localize['status_publish']             = wpinv_status_nicename('publish');
457
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
458
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
459
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
460
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
461
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
462
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
463
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
464
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
465
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
466
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
467
+        $localize['action_edit']                = __('Edit', 'invoicing');
468
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
469
+        $localize['item_description']           = __('Item Description', 'invoicing');
470
+        $localize['discount_description']       = __('Discount Description', 'invoicing');
471
+        $localize['invoice_description']        = __('Invoice Description', 'invoicing');
472
+        $localize['searching']                  = __('Searching', 'invoicing');
473
+
474
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
475
+
476
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
477 477
 
478 478
         // Load payment form scripts on our admin pages only.
479
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
479
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
480 480
 
481
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
482
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
483
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
481
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
482
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
483
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
484 484
 
485
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
486
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
485
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
486
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
487 487
         
488
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
488
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
489 489
                 'elements'      => $this->form_elements->get_elements(),
490
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
490
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
491 491
                 'all_items'     => $this->form_elements->get_published_items(),
492 492
                 'currency'      => wpinv_currency_symbol(),
493 493
                 'position'      => wpinv_currency_position(),
494 494
                 'decimals'      => (int) wpinv_decimals(),
495 495
                 'thousands_sep' => wpinv_thousands_separator(),
496 496
                 'decimals_sep'  => wpinv_decimal_separator(),
497
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
497
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
498 498
                 'is_default'    => $post->ID == $this->default_payment_form,
499
-            ) );
499
+            ));
500 500
 
501
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
501
+            wp_enqueue_script('wpinv-admin-payment-form-script');
502 502
         }
503 503
 
504
-        if ( $page == 'wpinv-subscriptions' ) {
505
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
506
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
504
+        if ($page == 'wpinv-subscriptions') {
505
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
506
+            wp_enqueue_script('wpinv-sub-admin-script');
507 507
         }
508 508
 
509
-        if ( $page == 'wpinv-reports' ) {
510
-            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
509
+        if ($page == 'wpinv-reports') {
510
+            wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
511 511
         }
512 512
 
513 513
     }
514 514
 
515
-    public function admin_body_class( $classes ) {
515
+    public function admin_body_class($classes) {
516 516
         global $pagenow, $post, $current_screen;
517 517
         
518
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
518
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
519 519
             $classes .= ' wpinv-cpt';
520 520
         }
521 521
         
522
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
522
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
523 523
 
524
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
525
-        if ( $add_class ) {
526
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
524
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
525
+        if ($add_class) {
526
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
527 527
         }
528 528
         
529 529
         $settings_class = array();
530
-        if ( $page == 'wpinv-settings' ) {
531
-            if ( !empty( $_REQUEST['tab'] ) ) {
532
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
530
+        if ($page == 'wpinv-settings') {
531
+            if (!empty($_REQUEST['tab'])) {
532
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
533 533
             }
534 534
             
535
-            if ( !empty( $_REQUEST['section'] ) ) {
536
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
535
+            if (!empty($_REQUEST['section'])) {
536
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
537 537
             }
538 538
             
539
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
539
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
540 540
         }
541 541
         
542
-        if ( !empty( $settings_class ) ) {
543
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
542
+        if (!empty($settings_class)) {
543
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
544 544
         }
545 545
         
546 546
         $post_type = wpinv_admin_post_type();
547 547
 
548
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
548
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
549 549
             return $classes .= ' wpinv';
550 550
         }
551 551
         
552
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
552
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
553 553
             $classes .= ' wpi-editable-n';
554 554
         }
555 555
 
@@ -561,21 +561,21 @@  discard block
 block discarded – undo
561 561
     }
562 562
     
563 563
     public function wpinv_actions() {
564
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
565
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
564
+        if (isset($_REQUEST['wpi_action'])) {
565
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
566 566
         }
567 567
     }
568 568
     
569
-    public function pre_get_posts( $wp_query ) {
570
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
571
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
569
+    public function pre_get_posts($wp_query) {
570
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
571
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
572 572
         }
573 573
         
574 574
         return $wp_query;
575 575
     }
576 576
     
577 577
     public function bp_invoicing_init() {
578
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
578
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
579 579
     }
580 580
 
581 581
 	/**
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 	 *
584 584
 	 */
585 585
 	public function register_widgets() {
586
-		register_widget( "WPInv_Checkout_Widget" );
587
-		register_widget( "WPInv_History_Widget" );
588
-		register_widget( "WPInv_Receipt_Widget" );
589
-		register_widget( "WPInv_Subscriptions_Widget" );
590
-		register_widget( "WPInv_Buy_Item_Widget" );
591
-        register_widget( "WPInv_Messages_Widget" );
592
-        register_widget( 'WPInv_GetPaid_Widget' );
586
+		register_widget("WPInv_Checkout_Widget");
587
+		register_widget("WPInv_History_Widget");
588
+		register_widget("WPInv_Receipt_Widget");
589
+		register_widget("WPInv_Subscriptions_Widget");
590
+		register_widget("WPInv_Buy_Item_Widget");
591
+        register_widget("WPInv_Messages_Widget");
592
+        register_widget('WPInv_GetPaid_Widget');
593 593
 	}
594 594
     
595 595
     /**
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
      * @since 1.0.19
599 599
      * @param int[] $excluded_posts_ids
600 600
      */
601
-    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
601
+    public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
602 602
 
603 603
         // Ensure that we have an array.
604
-        if ( ! is_array( $excluded_posts_ids ) ) {
604
+        if (!is_array($excluded_posts_ids)) {
605 605
             $excluded_posts_ids = array();
606 606
         }
607 607
 
@@ -609,24 +609,24 @@  discard block
 block discarded – undo
609 609
         $our_pages = array();
610 610
     
611 611
         // Checkout page.
612
-        $our_pages[] = wpinv_get_option( 'checkout_page', false );
612
+        $our_pages[] = wpinv_get_option('checkout_page', false);
613 613
 
614 614
         // Success page.
615
-        $our_pages[] = wpinv_get_option( 'success_page', false );
615
+        $our_pages[] = wpinv_get_option('success_page', false);
616 616
 
617 617
         // Failure page.
618
-        $our_pages[] = wpinv_get_option( 'failure_page', false );
618
+        $our_pages[] = wpinv_get_option('failure_page', false);
619 619
 
620 620
         // History page.
621
-        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
621
+        $our_pages[] = wpinv_get_option('invoice_history_page', false);
622 622
 
623 623
         // Subscriptions page.
624
-        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
624
+        $our_pages[] = wpinv_get_option('invoice_subscription_page', false);
625 625
 
626
-        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
626
+        $our_pages   = array_map('intval', array_filter($our_pages));
627 627
 
628 628
         $excluded_posts_ids = $excluded_posts_ids + $our_pages;
629
-        return array_unique( $excluded_posts_ids );
629
+        return array_unique($excluded_posts_ids);
630 630
 
631 631
     }
632 632
 
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -618,10 +618,10 @@
 block discarded – undo
618 618
 
619 619
     }
620 620
 
621
-   if ( empty( $iso )  ) {
622
-       return false;
623
-   }
621
+    if ( empty( $iso )  ) {
622
+        return false;
623
+    }
624 624
 
625
-   return compact( 'iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit' );
625
+    return compact( 'iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit' );
626 626
 
627 627
 }
Please login to merge, or discard this patch.
Spacing   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 /**
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
  * 
19 19
  * @return bool
20 20
  */
21
-function getpaid_is_eu_state( $country ) {
22
-    return WPInv_EUVat::is_eu_state( $country );
21
+function getpaid_is_eu_state($country) {
22
+    return WPInv_EUVat::is_eu_state($country);
23 23
 }
24 24
 
25 25
 /**
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
  * 
28 28
  * @return bool
29 29
  */
30
-function getpaid_is_gst_country( $country ) {
31
-    return WPInv_EUVat::is_gst_country( $country );
30
+function getpaid_is_gst_country($country) {
31
+    return WPInv_EUVat::is_gst_country($country);
32 32
 }
33 33
 
34 34
 /**
@@ -42,117 +42,117 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
 function wpinv_use_taxes() {
45
-    $ret = wpinv_get_option( 'enable_taxes', false );
45
+    $ret = wpinv_get_option('enable_taxes', false);
46 46
     
47
-    return (bool) apply_filters( 'wpinv_use_taxes', $ret );
47
+    return (bool) apply_filters('wpinv_use_taxes', $ret);
48 48
 }
49 49
 
50 50
 function wpinv_get_tax_rates() {
51
-    $rates = get_option( 'wpinv_tax_rates', array() );
51
+    $rates = get_option('wpinv_tax_rates', array());
52 52
     
53
-    return apply_filters( 'wpinv_get_tax_rates', $rates );
53
+    return apply_filters('wpinv_get_tax_rates', $rates);
54 54
 }
55 55
 
56
-function wpinv_get_tax_rate( $country = false, $state = false, $item_id = 0 ) {
56
+function wpinv_get_tax_rate($country = false, $state = false, $item_id = 0) {
57 57
     global $wpinv_euvat, $wpi_tax_rates, $wpi_userID;
58
-    $wpi_tax_rates = !empty( $wpi_tax_rates ) ? $wpi_tax_rates : array();
58
+    $wpi_tax_rates = !empty($wpi_tax_rates) ? $wpi_tax_rates : array();
59 59
     
60
-    if ( !empty( $wpi_tax_rates ) && !empty( $item_id ) && isset( $wpi_tax_rates[$item_id] ) ) {
60
+    if (!empty($wpi_tax_rates) && !empty($item_id) && isset($wpi_tax_rates[$item_id])) {
61 61
         return $wpi_tax_rates[$item_id];
62 62
     }
63 63
     
64
-    if ( !$wpinv_euvat->item_is_taxable( $item_id, $country, $state ) ) {
64
+    if (!$wpinv_euvat->item_is_taxable($item_id, $country, $state)) {
65 65
         $wpi_tax_rates[$item_id] = 0;
66 66
         return 0;
67 67
     }
68 68
 
69 69
     $is_global = false;
70
-    if ( $item_id == 'global' ) {
70
+    if ($item_id == 'global') {
71 71
         $is_global = true;
72 72
         $item_id = 0;
73 73
     }
74 74
     
75
-    $rate           = (float)wpinv_get_option( 'tax_rate', 0 );
76
-    $user_address   = wpinv_get_user_address( $wpi_userID );
75
+    $rate           = (float) wpinv_get_option('tax_rate', 0);
76
+    $user_address   = wpinv_get_user_address($wpi_userID);
77 77
     
78
-    if( empty( $country ) ) {
79
-        if( !empty( $_POST['wpinv_country'] ) ) {
78
+    if (empty($country)) {
79
+        if (!empty($_POST['wpinv_country'])) {
80 80
             $country = $_POST['wpinv_country'];
81
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
81
+        } elseif (!empty($_POST['wpinv_country'])) {
82 82
             $country = $_POST['wpinv_country'];
83
-        } elseif( !empty( $_POST['country'] ) ) {
83
+        } elseif (!empty($_POST['country'])) {
84 84
             $country = $_POST['country'];
85
-        } elseif( is_user_logged_in() && !empty( $user_address ) ) {
85
+        } elseif (is_user_logged_in() && !empty($user_address)) {
86 86
             $country = $user_address['country'];
87 87
         }
88
-        $country = !empty( $country ) ? $country : wpinv_get_default_country();
88
+        $country = !empty($country) ? $country : wpinv_get_default_country();
89 89
     }
90 90
 
91
-    if( empty( $state ) ) {
92
-        if( !empty( $_POST['wpinv_state'] ) ) {
91
+    if (empty($state)) {
92
+        if (!empty($_POST['wpinv_state'])) {
93 93
             $state = $_POST['wpinv_state'];
94
-        } elseif( !empty( $_POST['wpinv_state'] ) ) {
94
+        } elseif (!empty($_POST['wpinv_state'])) {
95 95
             $state = $_POST['wpinv_state'];
96
-        } elseif( !empty( $_POST['state'] ) ) {
96
+        } elseif (!empty($_POST['state'])) {
97 97
             $state = $_POST['state'];
98
-        } elseif( is_user_logged_in() && !empty( $user_address ) ) {
98
+        } elseif (is_user_logged_in() && !empty($user_address)) {
99 99
             $state = $user_address['state'];
100 100
         }
101
-        $state = !empty( $state ) ? $state : wpinv_get_default_state();
101
+        $state = !empty($state) ? $state : wpinv_get_default_state();
102 102
     }
103 103
     
104
-    if( !empty( $country ) ) {
105
-        $tax_rates   = wpinv_get_tax_rates();
104
+    if (!empty($country)) {
105
+        $tax_rates = wpinv_get_tax_rates();
106 106
 
107
-        if( !empty( $tax_rates ) ) {
107
+        if (!empty($tax_rates)) {
108 108
             // Locate the tax rate for this country / state, if it exists
109
-            foreach( $tax_rates as $key => $tax_rate ) {
110
-                if( $country != $tax_rate['country'] )
109
+            foreach ($tax_rates as $key => $tax_rate) {
110
+                if ($country != $tax_rate['country'])
111 111
                     continue;
112 112
 
113
-                if( !empty( $tax_rate['global'] ) ) {
114
-                    if( !empty( $tax_rate['rate'] ) ) {
115
-                        $rate = number_format( $tax_rate['rate'], 4 );
113
+                if (!empty($tax_rate['global'])) {
114
+                    if (!empty($tax_rate['rate'])) {
115
+                        $rate = number_format($tax_rate['rate'], 4);
116 116
                     }
117 117
                 } else {
118 118
 
119
-                    if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
119
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
120 120
                         continue;
121 121
 
122 122
                     $state_rate = $tax_rate['rate'];
123
-                    if( 0 !== $state_rate || !empty( $state_rate ) ) {
124
-                        $rate = number_format( $state_rate, 4 );
123
+                    if (0 !== $state_rate || !empty($state_rate)) {
124
+                        $rate = number_format($state_rate, 4);
125 125
                     }
126 126
                 }
127 127
             }
128 128
         }
129 129
     }
130 130
     
131
-    $rate = apply_filters( 'wpinv_tax_rate', $rate, $country, $state, $item_id );
131
+    $rate = apply_filters('wpinv_tax_rate', $rate, $country, $state, $item_id);
132 132
     
133
-    if ( !empty( $item_id ) ) {
133
+    if (!empty($item_id)) {
134 134
         $wpi_tax_rates[$item_id] = $rate;
135
-    } else if ( $is_global ) {
135
+    } else if ($is_global) {
136 136
         $wpi_tax_rates['global'] = $rate;
137 137
     }
138 138
     
139 139
     return $rate;
140 140
 }
141 141
 
142
-function wpinv_get_formatted_tax_rate( $country = false, $state = false, $item_id ) {
143
-    $rate = wpinv_get_tax_rate( $country, $state, $item_id );
144
-    $rate = round( $rate, 4 );
142
+function wpinv_get_formatted_tax_rate($country = false, $state = false, $item_id) {
143
+    $rate = wpinv_get_tax_rate($country, $state, $item_id);
144
+    $rate = round($rate, 4);
145 145
     $formatted = $rate .= '%';
146
-    return apply_filters( 'wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id );
146
+    return apply_filters('wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id);
147 147
 }
148 148
 
149
-function wpinv_calculate_tax( $amount = 0, $country = false, $state = false, $item_id = 0 ) {
150
-    $rate = wpinv_get_tax_rate( $country, $state, $item_id );
149
+function wpinv_calculate_tax($amount = 0, $country = false, $state = false, $item_id = 0) {
150
+    $rate = wpinv_get_tax_rate($country, $state, $item_id);
151 151
     $tax  = 0.00;
152 152
 
153
-    if ( wpinv_use_taxes() ) {        
154
-        if ( wpinv_prices_include_tax() ) {
155
-            $pre_tax = ( $amount / ( ( 1 + $rate ) * 0.01 ) );
153
+    if (wpinv_use_taxes()) {        
154
+        if (wpinv_prices_include_tax()) {
155
+            $pre_tax = ($amount / ((1 + $rate) * 0.01));
156 156
             $tax     = $amount - $pre_tax;
157 157
         } else {
158 158
             $tax = $amount * $rate * 0.01;
@@ -160,46 +160,46 @@  discard block
 block discarded – undo
160 160
 
161 161
     }
162 162
 
163
-    return apply_filters( 'wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id );
163
+    return apply_filters('wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id);
164 164
 }
165 165
 
166 166
 function wpinv_prices_include_tax() {
167 167
     return false; // TODO
168
-    $ret = ( wpinv_get_option( 'prices_include_tax', false ) == 'yes' && wpinv_use_taxes() );
168
+    $ret = (wpinv_get_option('prices_include_tax', false) == 'yes' && wpinv_use_taxes());
169 169
 
170
-    return apply_filters( 'wpinv_prices_include_tax', $ret );
170
+    return apply_filters('wpinv_prices_include_tax', $ret);
171 171
 }
172 172
 
173
-function wpinv_sales_tax_for_year( $year = null ) {
174
-    return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) );
173
+function wpinv_sales_tax_for_year($year = null) {
174
+    return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year)));
175 175
 }
176 176
 
177
-function wpinv_get_sales_tax_for_year( $year = null ) {
177
+function wpinv_get_sales_tax_for_year($year = null) {
178 178
     global $wpdb;
179 179
 
180 180
     // Start at zero
181 181
     $tax = 0;
182 182
 
183
-    if ( ! empty( $year ) ) {
183
+    if (!empty($year)) {
184 184
         $args = array(
185 185
             'post_type'      => 'wpi_invoice',
186
-            'post_status'    => array( 'publish' ),
186
+            'post_status'    => array('publish'),
187 187
             'posts_per_page' => -1,
188 188
             'year'           => $year,
189 189
             'fields'         => 'ids'
190 190
         );
191 191
 
192
-        $payments    = get_posts( $args );
193
-        $payment_ids = implode( ',', $payments );
192
+        $payments    = get_posts($args);
193
+        $payment_ids = implode(',', $payments);
194 194
 
195
-        if ( count( $payments ) > 0 ) {
195
+        if (count($payments) > 0) {
196 196
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
197
-            $tax = $wpdb->get_var( $sql );
197
+            $tax = $wpdb->get_var($sql);
198 198
         }
199 199
 
200 200
     }
201 201
 
202
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
202
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
203 203
 }
204 204
 
205 205
 function wpinv_is_cart_taxed() {
@@ -208,33 +208,33 @@  discard block
 block discarded – undo
208 208
 
209 209
 function wpinv_prices_show_tax_on_checkout() {
210 210
     return false; // TODO
211
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
211
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
212 212
 
213
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
213
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
214 214
 }
215 215
 
216 216
 function wpinv_display_tax_rate() {
217
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
217
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
218 218
 
219
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
219
+    return apply_filters('wpinv_display_tax_rate', $ret);
220 220
 }
221 221
 
222 222
 function wpinv_cart_needs_tax_address_fields() {
223
-    if( !wpinv_is_cart_taxed() )
223
+    if (!wpinv_is_cart_taxed())
224 224
         return false;
225 225
 
226
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
226
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
227 227
 }
228 228
 
229
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
230
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
231
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
229
+function wpinv_item_is_tax_exclusive($item_id = 0) {
230
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
231
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
232 232
 }
233 233
 
234
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
234
+function wpinv_currency_decimal_filter($decimals = 2) {
235 235
     $currency = wpinv_get_currency();
236 236
 
237
-    switch ( $currency ) {
237
+    switch ($currency) {
238 238
         case 'RIAL' :
239 239
         case 'JPY' :
240 240
         case 'TWD' :
@@ -243,48 +243,48 @@  discard block
 block discarded – undo
243 243
             break;
244 244
     }
245 245
 
246
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
246
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
247 247
 }
248 248
 
249 249
 function wpinv_tax_amount() {
250 250
     $output = 0.00;
251 251
     
252
-    return apply_filters( 'wpinv_tax_amount', $output );
252
+    return apply_filters('wpinv_tax_amount', $output);
253 253
 }
254 254
 
255 255
 function wpinv_recalculated_tax() {
256
-    define( 'WPINV_RECALCTAX', true );
256
+    define('WPINV_RECALCTAX', true);
257 257
 }
258
-add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1 );
258
+add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1);
259 259
 
260
-function wpinv_recalculate_tax( $return = false ) {
261
-    $invoice_id = (int)wpinv_get_invoice_cart_id();
262
-    if ( empty( $invoice_id ) ) {
260
+function wpinv_recalculate_tax($return = false) {
261
+    $invoice_id = (int) wpinv_get_invoice_cart_id();
262
+    if (empty($invoice_id)) {
263 263
         return false;
264 264
     }
265 265
     
266
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
266
+    $invoice = wpinv_get_invoice_cart($invoice_id);
267 267
 
268
-    if ( empty( $invoice ) ) {
268
+    if (empty($invoice)) {
269 269
         return false;
270 270
     }
271 271
 
272
-    if ( empty( $_POST['country'] ) ) {
272
+    if (empty($_POST['country'])) {
273 273
         $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
274 274
     }
275 275
         
276 276
     $invoice->country = sanitize_text_field($_POST['country']);
277
-    $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
277
+    $invoice->set('country', sanitize_text_field($_POST['country']));
278 278
     if (isset($_POST['state'])) {
279 279
         $invoice->state = sanitize_text_field($_POST['state']);
280
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
280
+        $invoice->set('state', sanitize_text_field($_POST['state']));
281 281
     }
282 282
 
283 283
     $invoice->cart_details  = wpinv_get_cart_content_details();
284 284
     
285
-    $subtotal               = wpinv_get_cart_subtotal( $invoice->cart_details );
286
-    $tax                    = wpinv_get_cart_tax( $invoice->cart_details );
287
-    $total                  = wpinv_get_cart_total( $invoice->cart_details );
285
+    $subtotal               = wpinv_get_cart_subtotal($invoice->cart_details);
286
+    $tax                    = wpinv_get_cart_tax($invoice->cart_details);
287
+    $total                  = wpinv_get_cart_total($invoice->cart_details);
288 288
 
289 289
     $invoice->tax           = $tax;
290 290
     $invoice->subtotal      = $subtotal;
@@ -292,61 +292,61 @@  discard block
 block discarded – undo
292 292
 
293 293
     $invoice->save();
294 294
     
295
-    if ( $invoice->is_free_trial() ) {
295
+    if ($invoice->is_free_trial()) {
296 296
         $total = 0;
297 297
     }
298 298
     
299 299
     $response = array(
300
-        'total'        => html_entity_decode( wpinv_price( wpinv_format_amount( $total ) ), ENT_COMPAT, 'UTF-8' ),
300
+        'total'        => html_entity_decode(wpinv_price(wpinv_format_amount($total)), ENT_COMPAT, 'UTF-8'),
301 301
         'total_raw'    => $total,
302
-        'free'         => !( (float)$total > 0 ) && $invoice->is_free() ? true : false,
303
-        'html'         => wpinv_checkout_cart( $invoice->cart_details, false ),
302
+        'free'         => !((float) $total > 0) && $invoice->is_free() ? true : false,
303
+        'html'         => wpinv_checkout_cart($invoice->cart_details, false),
304 304
     );
305 305
     
306
-    if ( $return ) {
306
+    if ($return) {
307 307
         return $response;
308 308
     }
309 309
 
310
-    wp_send_json( $response );
310
+    wp_send_json($response);
311 311
 }
312
-add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax' );
313
-add_action( 'wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax' );
312
+add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax');
313
+add_action('wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax');
314 314
 
315 315
 // VAT Settings
316
-function wpinv_vat_rate_add_callback( $args ) {
316
+function wpinv_vat_rate_add_callback($args) {
317 317
     ?>
318
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
318
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
319 319
     <?php
320 320
 }
321 321
 
322
-function wpinv_vat_rate_delete_callback( $args ) {
322
+function wpinv_vat_rate_delete_callback($args) {
323 323
     global $wpinv_euvat;
324 324
     
325 325
     $vat_classes = $wpinv_euvat->get_rate_classes();
326
-    $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '';
327
-    if ( isset( $vat_classes[$vat_class] ) ) {
326
+    $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '';
327
+    if (isset($vat_classes[$vat_class])) {
328 328
     ?>
329
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
329
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
330 330
     <?php
331 331
     }
332 332
 }
333 333
 
334
-function wpinv_vat_rates_callback( $args ) {
334
+function wpinv_vat_rates_callback($args) {
335 335
     global $wpinv_euvat;
336 336
     
337 337
     $vat_classes    = $wpinv_euvat->get_rate_classes();
338
-    $vat_class      = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard';
338
+    $vat_class      = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard';
339 339
     
340 340
     $eu_states      = $wpinv_euvat->get_eu_states();
341 341
     $countries      = wpinv_get_country_list();
342 342
     $vat_groups     = $wpinv_euvat->get_vat_groups();
343
-    $rates          = $wpinv_euvat->get_vat_rates( $vat_class );
343
+    $rates          = $wpinv_euvat->get_vat_rates($vat_class);
344 344
     ob_start();
345 345
 ?>
346 346
 </td><tr>
347 347
     <td colspan="2" class="wpinv_vat_tdbox">
348
-    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" />
349
-    <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p>
348
+    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" />
349
+    <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p>
350 350
     <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts">
351 351
         <colgroup>
352 352
             <col width="50px" />
@@ -358,43 +358,43 @@  discard block
 block discarded – undo
358 358
         </colgroup>
359 359
         <thead>
360 360
             <tr>
361
-                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th>
362
-                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
363
-                <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
364
-                <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th>
365
-                <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th>
361
+                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th>
362
+                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
363
+                <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
364
+                <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th>
365
+                <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th>
366 366
             </tr>
367 367
         </thead>
368 368
         <tbody>
369
-        <?php if( !empty( $eu_states ) ) { ?>
369
+        <?php if (!empty($eu_states)) { ?>
370 370
         <?php 
371
-        foreach ( $eu_states as $state ) { 
372
-            $country_name = isset( $countries[$state] ) ? $countries[$state] : '';
371
+        foreach ($eu_states as $state) { 
372
+            $country_name = isset($countries[$state]) ? $countries[$state] : '';
373 373
             
374 374
             // Filter the rate for each country
375
-            $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } );
375
+            $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } );
376 376
             
377 377
             // If one does not exist create a default
378
-            $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array();
378
+            $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array();
379 379
             
380
-            $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true;
381
-            $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : '';
382
-            $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : '';
383
-            $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' );
380
+            $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true;
381
+            $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : '';
382
+            $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : '';
383
+            $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced');
384 384
         ?>
385 385
         <tr>
386 386
             <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td>
387 387
             <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td>
388 388
             <td class="wpinv_vat_global">
389
-                <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" />
390
-                <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
391
-                <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" />
389
+                <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" />
390
+                <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
391
+                <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" />
392 392
             </td>
393
-            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
394
-            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td>
393
+            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
394
+            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td>
395 395
             <td class="wpinv_vat_group">
396 396
             <?php
397
-            echo wpinv_html_select( array(
397
+            echo wpinv_html_select(array(
398 398
                                         'name'             => 'vat_rates[' . $state . '][group]',
399 399
                                         'selected'         => $vat_group,
400 400
                                         'id'               => 'vat_rates[' . $state . '][group]',
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
                                         'multiple'         => false,
404 404
                                         'show_option_all'  => false,
405 405
                                         'show_option_none' => false
406
-                                    ) );
406
+                                    ));
407 407
             ?>
408 408
             </td>
409 409
         </tr>
410 410
         <?php } ?>
411 411
         <tr>
412 412
             <td colspan="6" style="background-color:#fafafa;">
413
-                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
413
+                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
414 414
             </td>
415 415
         </tr>
416 416
         <?php } ?>
@@ -422,35 +422,35 @@  discard block
 block discarded – undo
422 422
     echo $content;
423 423
 }
424 424
 
425
-function wpinv_vat_number_callback( $args ) {
425
+function wpinv_vat_number_callback($args) {
426 426
     global $wpinv_euvat;
427 427
     
428 428
     $vat_number     = $wpinv_euvat->get_vat_number();
429 429
     $vat_valid      = $wpinv_euvat->is_vat_validated();
430 430
 
431
-    $size           = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
432
-    $validated_text = $vat_valid ? __( 'VAT number validated', 'invoicing' ) : __( 'VAT number not validated', 'invoicing' );
431
+    $size           = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
432
+    $validated_text = $vat_valid ? __('VAT number validated', 'invoicing') : __('VAT number not validated', 'invoicing');
433 433
     $disabled       = $vat_valid ? 'disabled="disabled"' : " ";
434 434
     
435
-    $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr( stripslashes( $vat_number ) ) . '"/>';
436
-    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__( 'Validate VAT Number', 'invoicing' ) . '" /></span>';
437
-    $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int)$vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>';
438
-    $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __( 'Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing' ).'</p>' . '</label>';
439
-    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce( 'vat_validation' ) . '">';
435
+    $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr(stripslashes($vat_number)) . '"/>';
436
+    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__('Validate VAT Number', 'invoicing') . '" /></span>';
437
+    $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int) $vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>';
438
+    $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __('Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing') . '</p>' . '</label>';
439
+    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce('vat_validation') . '">';
440 440
 
441 441
     echo $html;
442 442
 }
443 443
 
444
-function wpinv_eu_fallback_rate_callback( $args ) {
444
+function wpinv_eu_fallback_rate_callback($args) {
445 445
     global $wpinv_options;
446 446
 
447
-    $value = isset( $wpinv_options[$args['id']] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : '' );
448
-    $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'small';
447
+    $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : '');
448
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'small';
449 449
     
450
-    $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />';
451
-    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Add EU Member States', 'invoicing' ) . '" /></span>';
452
-    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Remove EU Member States', 'invoicing' ) . '" /></span>';
453
-    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__( 'Update EU VAT Rates', 'invoicing' ) . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
450
+    $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '" />';
451
+    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Add EU Member States', 'invoicing') . '" /></span>';
452
+    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Remove EU Member States', 'invoicing') . '" /></span>';
453
+    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__('Update EU VAT Rates', 'invoicing') . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
454 454
     $html .= '<p><label for="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '">' . $args['desc'] . '</label></p>';
455 455
     echo $html;
456 456
     ?>
@@ -458,36 +458,36 @@  discard block
 block discarded – undo
458 458
     <?php
459 459
 }
460 460
 
461
-function wpinv_vat_ip_lookup_callback( $args ) {
461
+function wpinv_vat_ip_lookup_callback($args) {
462 462
     global $wpinv_options, $wpinv_euvat;
463 463
 
464
-    $value =  isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ]  : ( isset( $args['std'] ) ? $args['std'] : 'default' );
464
+    $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : 'default');
465 465
     
466 466
     $options = array();
467
-    if ( function_exists( 'geoip_country_code_by_name' ) ) {
468
-        $options['geoip'] = __( 'PHP GeoIP extension', 'invoicing' );
467
+    if (function_exists('geoip_country_code_by_name')) {
468
+        $options['geoip'] = __('PHP GeoIP extension', 'invoicing');
469 469
     }
470 470
     
471 471
     $geoip2_database = $wpinv_euvat->geoip2_country_dbfile();
472 472
     
473
-    if ( !function_exists( 'bcadd' ) ) {
474
-        $geoip2_message = __( 'GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing' );
473
+    if (!function_exists('bcadd')) {
474
+        $geoip2_message = __('GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing');
475 475
     } else {
476
-        $geoip2_message = ini_get('safe_mode') ? __( 'GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing' ) : '';
476
+        $geoip2_message = ini_get('safe_mode') ? __('GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing') : '';
477 477
     }
478 478
     
479
-    if ( $geoip2_database !== false && empty( $geoip2_message ) ) {
480
-        $options['geoip2'] = __( 'GeoIP2 Database', 'invoicing' );
479
+    if ($geoip2_database !== false && empty($geoip2_message)) {
480
+        $options['geoip2'] = __('GeoIP2 Database', 'invoicing');
481 481
     }
482 482
     
483
-    if ( function_exists( 'simplexml_load_file' ) ) {
484
-        $options['geoplugin'] = __( 'geoPlugin Web Service', 'invoicing' );
483
+    if (function_exists('simplexml_load_file')) {
484
+        $options['geoplugin'] = __('geoPlugin Web Service', 'invoicing');
485 485
     }
486 486
     
487
-    $options['site']    = __( 'Use default country', 'invoicing' );
488
-    $options['default'] = __( 'Auto', 'invoicing' );
487
+    $options['site']    = __('Use default country', 'invoicing');
488
+    $options['default'] = __('Auto', 'invoicing');
489 489
 
490
-    $html = wpinv_html_select( array(
490
+    $html = wpinv_html_select(array(
491 491
         'name'             => "wpinv_settings[{$args['id']}]",
492 492
         'selected'         => $value,
493 493
         'id'               => "wpinv_settings[{$args['id']}]",
@@ -499,23 +499,23 @@  discard block
 block discarded – undo
499 499
     ));
500 500
     
501 501
     $desc = '<label for="wpinv_settings[' . $args['id'] . ']">';
502
-    $desc .= __( 'Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing' );
502
+    $desc .= __('Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing');
503 503
     $desc .= '<p>';
504
-    if ( empty( $geoip2_message ) ) {
505
-        if ( $geoip2_database ) {
504
+    if (empty($geoip2_message)) {
505
+        if ($geoip2_database) {
506 506
             $last_updated = '';
507
-            if ( $time_updated = wpinv_get_option( 'wpinv_geoip2_date_updated' ) ) {
508
-                $date_updated = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time_updated );
509
-                $last_updated = '<br>' . sprintf( __( 'The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing' ), $date_updated );
507
+            if ($time_updated = wpinv_get_option('wpinv_geoip2_date_updated')) {
508
+                $date_updated = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $time_updated);
509
+                $last_updated = '<br>' . sprintf(__('The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing'), $date_updated);
510 510
             }
511
-            $desc .= __(  'GeoIP2 database exists:', 'invoicing' ) . $last_updated . '&nbsp;<input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __( 'Update GeoIP2 database now (~30MB)', 'invoicing' ) . '"></input>';
511
+            $desc .= __('GeoIP2 database exists:', 'invoicing') . $last_updated . '&nbsp;<input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __('Update GeoIP2 database now (~30MB)', 'invoicing') . '"></input>';
512 512
         } else {
513
-            $desc .= __( 'GeoIP2 database does not exist:', 'invoicing' ) . '&nbsp;<input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __( 'Download GeoIP2 database now', 'invoicing' ) . ' (~30MB)"></input><br>' . __(  'After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing' );
513
+            $desc .= __('GeoIP2 database does not exist:', 'invoicing') . '&nbsp;<input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __('Download GeoIP2 database now', 'invoicing') . ' (~30MB)"></input><br>' . __('After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing');
514 514
         }
515 515
     } else {
516 516
         $desc .= $geoip2_message;
517 517
     }
518
-    $desc .= '</p><p>'. __( 'geoPlugin is a great free service please consider supporting them: ', 'invoicing' ) . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>';
518
+    $desc .= '</p><p>' . __('geoPlugin is a great free service please consider supporting them: ', 'invoicing') . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>';
519 519
     $desc .= '</label>';
520 520
     
521 521
     $html .= $desc;
@@ -531,40 +531,40 @@  discard block
 block discarded – undo
531 531
  * 
532 532
  * @param string|bool|null $vat_rule
533 533
  */
534
-function getpaid_filter_vat_rule( $vat_rule ) {
534
+function getpaid_filter_vat_rule($vat_rule) {
535 535
     global $wpinv_euvat;
536 536
 
537
-    if ( empty( $vat_rule ) ) {        
537
+    if (empty($vat_rule)) {        
538 538
         return $wpinv_euvat->allow_vat_rules() ? 'digital' : 'physical';
539 539
     }
540 540
 
541 541
     return $vat_rule;
542 542
 }
543
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
543
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
544 544
 
545 545
 /**
546 546
  * Filters the VAT class to ensure that each item has a VAT class.
547 547
  * 
548 548
  * @param string|bool|null $vat_rule
549 549
  */
550
-function getpaid_filter_vat_class( $vat_class ) {
551
-    return empty( $vat_class ) ? '_standard' : $vat_class;
550
+function getpaid_filter_vat_class($vat_class) {
551
+    return empty($vat_class) ? '_standard' : $vat_class;
552 552
 }
553
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
553
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
554 554
 
555 555
 /**
556 556
  * Returns the ip address location url.
557 557
  * 
558 558
  */
559
-function getpaid_ip_location_url( $ip_address ) {
559
+function getpaid_ip_location_url($ip_address) {
560 560
 
561 561
     return add_query_arg(
562 562
         array(
563 563
             'action'   => 'wpinv_ip_geolocation',
564 564
             'ip'       => $ip_address,
565
-            '_wpnonce' => wp_create_nonce( 'getpaid-ip-location' )
565
+            '_wpnonce' => wp_create_nonce('getpaid-ip-location')
566 566
         ),
567
-        admin_url( 'admin-ajax.php' )
567
+        admin_url('admin-ajax.php')
568 568
     );
569 569
 
570 570
 }
@@ -574,54 +574,54 @@  discard block
 block discarded – undo
574 574
  * 
575 575
  * @return array|bool
576 576
  */
577
-function getpaid_geolocate_ip_address( $ip_address ) {
577
+function getpaid_geolocate_ip_address($ip_address) {
578 578
 
579 579
     // Do we have an ip address?
580
-    if ( empty( $ip_address ) ) {
580
+    if (empty($ip_address)) {
581 581
         return false;
582 582
     }
583 583
 
584 584
     /**
585 585
      * Retrieve ip address using max mind.
586 586
      */
587
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = getpaid_tax()->geoip2_city_record( $ip_address ) ) {
587
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = getpaid_tax()->geoip2_city_record($ip_address)) {
588 588
 
589 589
         try {
590 590
             $iso        = $geoip2_city->country->isoCode;
591 591
             $country    = $geoip2_city->country->name;
592
-            $region     = ! empty( $geoip2_city->subdivisions ) && ! empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
592
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
593 593
             $city       = $geoip2_city->city->name;
594 594
             $longitude  = $geoip2_city->location->longitude;
595 595
             $latitude   = $geoip2_city->location->latitude;
596
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
597
-        } catch( Exception $e ) { }
596
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
597
+        } catch (Exception $e) { }
598 598
 
599 599
     }
600 600
 
601 601
     // If that fails, GeoLocate using GeoPlugin.
602
-    if ( ( empty( $iso ) || empty( $longitude ) || empty( $latitude ) ) && function_exists( 'simplexml_load_file' ) ) {
602
+    if ((empty($iso) || empty($longitude) || empty($latitude)) && function_exists('simplexml_load_file')) {
603 603
 
604 604
         try {
605
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip_address );
605
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip_address);
606 606
             
607
-            if ( ! empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && ! empty( $load_xml->geoplugin_latitude ) && ! empty( $load_xml->geoplugin_longitude ) ) {
607
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
608 608
                 $iso        = $load_xml->geoplugin_countryCode;
609 609
                 $country    = $load_xml->geoplugin_countryName;
610
-                $region     = ! empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
611
-                $city       = ! empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
610
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
611
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
612 612
                 $longitude  = $load_xml->geoplugin_longitude;
613 613
                 $latitude   = $load_xml->geoplugin_latitude;
614 614
                 $credit     = $load_xml->geoplugin_credit;
615
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
615
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
616 616
             }
617
-        } catch( Exception $e ) { }
617
+        } catch (Exception $e) { }
618 618
 
619 619
     }
620 620
 
621
-   if ( empty( $iso )  ) {
621
+   if (empty($iso)) {
622 622
        return false;
623 623
    }
624 624
 
625
-   return compact( 'iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit' );
625
+   return compact('iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit');
626 626
 
627 627
 }
Please login to merge, or discard this patch.