Passed
Push — master ( 81bc9f...06ebe7 )
by Brian
04:13
created
includes/data/admin-settings.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -8,197 +8,197 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-$pages = wpinv_get_pages( true );
13
+$pages = wpinv_get_pages(true);
14 14
     
15 15
 $currencies = wpinv_get_currencies();
16 16
     
17 17
 $currency_code_options = array();
18
-foreach ( $currencies as $code => $name ) {
19
-    $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
18
+foreach ($currencies as $code => $name) {
19
+    $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
20 20
 }
21 21
     
22 22
 $due_payment_options       = array();
23
-$due_payment_options[0]    = __( 'Now', 'invoicing' );
24
-for ( $i = 1; $i <= 30; $i++ ) {
23
+$due_payment_options[0]    = __('Now', 'invoicing');
24
+for ($i = 1; $i <= 30; $i++) {
25 25
     $due_payment_options[$i] = $i;
26 26
 }
27 27
     
28 28
 $invoice_number_padd_options = array();
29
-for ( $i = 0; $i <= 20; $i++ ) {
29
+for ($i = 0; $i <= 20; $i++) {
30 30
     $invoice_number_padd_options[$i] = $i;
31 31
 }
32 32
     
33 33
 $currency_symbol = wpinv_currency_symbol();
34 34
     
35 35
 $last_number = $reset_number = '';
36
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
37
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
36
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
37
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
38 38
 
39
-    if ( !empty( $last_invoice_number ) ) {
40
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
39
+    if (!empty($last_invoice_number)) {
40
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
41 41
     }
42 42
 
43 43
     $nonce = wp_create_nonce('reset_invoice_count');
44
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
44
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
45 45
 }
46 46
     
47 47
 $alert_wrapper_start = '<p style="color: #F00">';
48 48
 $alert_wrapper_close = '</p>';
49 49
 
50 50
 return array(
51
-    'general' => apply_filters( 'wpinv_settings_general',
51
+    'general' => apply_filters('wpinv_settings_general',
52 52
         array(
53 53
             'main' => array(
54 54
                 'location_settings' => array(
55 55
                     'id'   => 'location_settings',
56
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
56
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
57 57
                     'desc' => '',
58 58
                     'type' => 'header',
59 59
                 ),
60 60
                 'default_country' => array(
61 61
                     'id'      => 'default_country',
62
-                    'name'    => __( 'Default Country', 'invoicing' ),
63
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
62
+                    'name'    => __('Default Country', 'invoicing'),
63
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
64 64
                     'type'    => 'select',
65 65
                     'options' => wpinv_get_country_list(),
66 66
                     'std'     => 'GB',
67 67
                     'class'   => 'wpi_select2',
68
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
68
+                    'placeholder' => __('Select a country', 'invoicing'),
69 69
                 ),
70 70
                 'default_state' => array(
71 71
                     'id'      => 'default_state',
72
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
73
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
72
+                    'name'    => __('Default State / Province', 'invoicing'),
73
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
74 74
                     'type'    => 'country_states',
75 75
                     'class'   => 'wpi_select2',
76
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
76
+                    'placeholder' => __('Select a state', 'invoicing'),
77 77
                 ),
78 78
                 'store_name' => array(
79 79
                     'id'   => 'store_name',
80
-                    'name' => __( 'Store Name', 'invoicing' ),
81
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
80
+                    'name' => __('Store Name', 'invoicing'),
81
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
82 82
                     'std'     => get_option('blogname'),
83 83
                     'type' => 'text',
84 84
                 ),
85 85
                 'logo' => array(
86 86
                     'id'   => 'logo',
87
-                    'name' => __( 'Logo URL', 'invoicing' ),
88
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
87
+                    'name' => __('Logo URL', 'invoicing'),
88
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
89 89
                     'type' => 'text',
90 90
                 ),
91 91
                 'store_address' => array(
92 92
                     'id'   => 'store_address',
93
-                    'name' => __( 'Store Address', 'invoicing' ),
94
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
93
+                    'name' => __('Store Address', 'invoicing'),
94
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
95 95
                     'type' => 'textarea',
96 96
                 ),
97 97
                 'page_settings' => array(
98 98
                     'id'   => 'page_settings',
99
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
99
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
100 100
                     'desc' => '',
101 101
                     'type' => 'header',
102 102
                 ),
103 103
                 'checkout_page' => array(
104 104
                     'id'          => 'checkout_page',
105
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
106
-                    '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' ),
105
+                    'name'        => __('Checkout Page', 'invoicing'),
106
+                    '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'),
107 107
                     'type'        => 'select',
108 108
                     'options'     => $pages,
109 109
                     'class'       => 'wpi_select2',
110
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
110
+                    'placeholder' => __('Select a page', 'invoicing'),
111 111
                     'help-tip'    => true,
112 112
                 ),
113 113
                 'success_page' => array(
114 114
                     'id'          => 'success_page',
115
-                    'name'        => __( 'Success Page', 'invoicing' ),
116
-                    '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' ),
115
+                    'name'        => __('Success Page', 'invoicing'),
116
+                    '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'),
117 117
                     'type'        => 'select',
118 118
                     'options'     => $pages,
119 119
                     'class'       => 'wpi_select2',
120
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
120
+                    'placeholder' => __('Select a page', 'invoicing'),
121 121
                     'help-tip'    => true,
122 122
                 ),
123 123
                 'failure_page' => array(
124 124
                     'id'          => 'failure_page',
125
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
126
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
125
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
126
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
127 127
                     'type'        => 'select',
128 128
                     'options'     => $pages,
129 129
                     'class'       => 'wpi_select2',
130
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
130
+                    'placeholder' => __('Select a page', 'invoicing'),
131 131
                     'help-tip'    => true,
132 132
                 ),
133 133
                 'invoice_history_page' => array(
134 134
                     'id'          => 'invoice_history_page',
135
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
136
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
135
+                    'name'        => __('Invoice History Page', 'invoicing'),
136
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
137 137
                     'type'        => 'select',
138 138
                     'options'     => $pages,
139 139
                     'class'       => 'wpi_select2',
140
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
140
+                    'placeholder' => __('Select a page', 'invoicing'),
141 141
                     'help-tip'    => true,
142 142
                 ),
143 143
                 'invoice_subscription_page' => array(
144 144
                     'id'          => 'invoice_subscription_page',
145
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
146
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
145
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
146
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
147 147
                     'type'        => 'select',
148 148
                     'options'     => $pages,
149 149
                     'class'       => 'wpi_select2',
150
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
150
+                    'placeholder' => __('Select a page', 'invoicing'),
151 151
                     'help-tip'    => true,
152 152
                 ),
153 153
             ),
154 154
             'currency_section' => array(
155 155
                 'currency_settings' => array(
156 156
                     'id'   => 'currency_settings',
157
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
157
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
158 158
                     'desc' => '',
159 159
                     'type' => 'header',
160 160
                 ),
161 161
                 'currency' => array(
162 162
                     'id'      => 'currency',
163
-                    'name'    => __( 'Currency', 'invoicing' ),
164
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
163
+                    'name'    => __('Currency', 'invoicing'),
164
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
165 165
                     'type'    => 'select',
166 166
                     'class'       => 'wpi_select2',
167 167
                     'options' => $currency_code_options,
168 168
                 ),
169 169
                 'currency_position' => array(
170 170
                     'id'      => 'currency_position',
171
-                    'name'    => __( 'Currency Position', 'invoicing' ),
172
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
171
+                    'name'    => __('Currency Position', 'invoicing'),
172
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
173 173
                     'type'    => 'select',
174 174
                     'class'   => 'wpi_select2',
175 175
                     'options'  => array(
176
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
177
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
178
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
179
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
176
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
177
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
178
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
179
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
180 180
                     )
181 181
                 ),
182 182
                 'thousands_separator' => array(
183 183
                     'id'   => 'thousands_separator',
184
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
185
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
184
+                    'name' => __('Thousands Separator', 'invoicing'),
185
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
186 186
                     'type' => 'text',
187 187
                     'size' => 'small',
188 188
                     'std'  => ',',
189 189
                 ),
190 190
                 'decimal_separator' => array(
191 191
                     'id'   => 'decimal_separator',
192
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
193
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
192
+                    'name' => __('Decimal Separator', 'invoicing'),
193
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
194 194
                     'type' => 'text',
195 195
                     'size' => 'small',
196 196
                     'std'  => '.',
197 197
                 ),
198 198
                 'decimals' => array(
199 199
                     'id'   => 'decimals',
200
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
201
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
200
+                    'name' => __('Number of Decimals', 'invoicing'),
201
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
202 202
                     'type' => 'number',
203 203
                     'size' => 'small',
204 204
                     'std'  => '2',
@@ -210,29 +210,29 @@  discard block
 block discarded – undo
210 210
             'labels' => array(
211 211
                 'labels' => array(
212 212
                     'id'   => 'labels_settings',
213
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
213
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
214 214
                     'desc' => '',
215 215
                     'type' => 'header',
216 216
                 ),
217 217
                 'vat_name' => array(
218 218
                     'id' => 'vat_name',
219
-                    'name' => __( 'VAT Name', 'invoicing' ),
220
-                    'desc' => __( 'Enter the VAT name', 'invoicing' ),
219
+                    'name' => __('VAT Name', 'invoicing'),
220
+                    'desc' => __('Enter the VAT name', 'invoicing'),
221 221
                     'type' => 'text',
222 222
                     'size' => 'regular',
223
-                    'std' => __( 'VAT', 'invoicing' ),
223
+                    'std' => __('VAT', 'invoicing'),
224 224
                 ),
225 225
                 'vat_invoice_notice_label' => array(
226 226
                     'id' => 'vat_invoice_notice_label',
227
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
228
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
227
+                    'name' => __('Invoice Notice Label', 'invoicing'),
228
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
229 229
                     'type' => 'text',
230 230
                     'size' => 'regular',
231 231
                 ),
232 232
                 'vat_invoice_notice' => array(
233 233
                     'id' => 'vat_invoice_notice',
234
-                    'name' => __( 'Invoice notice', 'invoicing' ),
235
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
234
+                    'name' => __('Invoice notice', 'invoicing'),
235
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
236 236
                     'type' => 'text',
237 237
                     'size' => 'regular',
238 238
                 ),
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
             'main' => array(
245 245
                 'gateway_settings' => array(
246 246
                     'id'   => 'api_header',
247
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
247
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
248 248
                     'desc' => '',
249 249
                     'type' => 'header',
250 250
                 ),
251 251
                 'gateways' => array(
252 252
                     'id'      => 'gateways',
253
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
254
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
253
+                    'name'    => __('Payment Gateways', 'invoicing'),
254
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
255 255
                     'type'    => 'gateways',
256 256
                     'std'     => array('manual'=>1),
257 257
                     'options' => wpinv_get_payment_gateways(),
258 258
                 ),
259 259
                 'default_gateway' => array(
260 260
                     'id'      => 'default_gateway',
261
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
262
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
261
+                    'name'    => __('Default Gateway', 'invoicing'),
262
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
263 263
                     'type'    => 'gateway_select',
264 264
                     'std'     => 'manual',
265 265
                     'class'   => 'wpi_select2',
@@ -274,32 +274,32 @@  discard block
 block discarded – undo
274 274
             'main' => array(
275 275
                 'tax_settings' => array(
276 276
                     'id'   => 'tax_settings',
277
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
277
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
278 278
                     'type' => 'header',
279 279
                 ),
280 280
 
281 281
                 'enable_taxes' => array(
282 282
                     'id'       => 'enable_taxes',
283
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
284
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
283
+                    'name'     => __('Enable Taxes', 'invoicing'),
284
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
285 285
                     'type'     => 'checkbox',
286 286
                     'std'      => 0,
287 287
                 ),
288 288
 
289 289
                 'tax_subtotal_rounding' => array(
290 290
                     'id'                => 'tax_subtotal_rounding',
291
-                    'name'              => __( 'Rounding', 'invoicing' ),
292
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
291
+                    'name'              => __('Rounding', 'invoicing'),
292
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
293 293
                     'type'              => 'checkbox',
294 294
                     'std'               => 1,
295 295
                 ),
296 296
 
297 297
                 'prices_include_tax' => array(
298 298
                     'id'      => 'prices_include_tax',
299
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
299
+                    'name'    => __('Prices entered with tax', 'invoicing'),
300 300
                     'options' => array(
301
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
302
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
301
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
302
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
303 303
                     ),
304 304
                     'type'    => 'select',
305 305
                     'std'     => 'no',
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 
308 308
                 'tax_base'              => array(
309 309
                     'id'                => 'tax_base',
310
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
310
+                    'name'              => __('Calculate tax based on', 'invoicing'),
311 311
                     'options'           => array(
312
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
313
-                        'base'          => __( 'Shop base address', 'invoicing' ),
312
+                        'billing'       => __('Customer billing address', 'invoicing'),
313
+                        'base'          => __('Shop base address', 'invoicing'),
314 314
                     ),
315 315
                     'type'              => 'select',
316 316
                     'std'               => 'billing',
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
 
319 319
                 'tax_display_totals'    => array(
320 320
                     'id'                => 'tax_display_totals',
321
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
321
+                    'name'              => __('Display tax totals', 'invoicing'),
322 322
                     'options'           => array(
323
-                        'single'        => __( 'As a single total', 'invoicing' ),
324
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
323
+                        'single'        => __('As a single total', 'invoicing'),
324
+                        'individual'    => __('As individual tax rates', 'invoicing'),
325 325
                     ),
326 326
                     'type'              => 'select',
327 327
                     'std'               => 'individual',
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 
330 330
                 'tax_rate' => array(
331 331
                     'id'   => 'tax_rate',
332
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
333
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
332
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
333
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
334 334
                     'type' => 'number',
335 335
                     'size' => 'small',
336 336
                     'min'  => '0',
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
             'rates' => array(
343 343
                 'tax_rates' => array(
344 344
                     'id'   => 'tax_rates',
345
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
346
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
345
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
346
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
347 347
                     'type' => 'tax_rates',
348 348
                 ),
349 349
             ),
@@ -352,44 +352,44 @@  discard block
 block discarded – undo
352 352
 
353 353
                 'vat_company_name' => array(
354 354
                     'id' => 'vat_company_name',
355
-                    'name' => __( 'Company Name', 'invoicing' ),
356
-                    'desc' => wp_sprintf(__( 'Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
355
+                    'name' => __('Company Name', 'invoicing'),
356
+                    'desc' => wp_sprintf(__('Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
357 357
                     'type' => 'text',
358 358
                     'size' => 'regular',
359 359
                 ),
360 360
 
361 361
                 'vat_number' => array(
362 362
                     'id'   => 'vat_number',
363
-                    'name' => __( 'VAT Number', 'invoicing' ),
364
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
363
+                    'name' => __('VAT Number', 'invoicing'),
364
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
365 365
                     'type' => 'text',
366 366
                     'size' => 'regular',
367 367
                 ),
368 368
 
369 369
                 'vat_prevent_b2c_purchase' => array(
370 370
                     'id' => 'vat_prevent_b2c_purchase',
371
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
372
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
371
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
372
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
373 373
                     'type' => 'checkbox'
374 374
                 ),
375 375
 
376 376
                 'validate_vat_number' => array(
377 377
                     'id'   => 'validate_vat_number',
378
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
379
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
378
+                    'name' => __('Validate VAT Number', 'invoicing'),
379
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
380 380
                     'type' => 'checkbox'
381 381
                 ),
382 382
 
383 383
                 'vat_same_country_rule' => array(
384 384
                     'id'          => 'vat_same_country_rule',
385
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
386
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
385
+                    'name'        => __('Same Country Rule', 'invoicing'),
386
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
387 387
                     'type'        => 'select',
388 388
                     'options'     => array(
389
-                        'no'        => __( 'Do not charge Tax', 'invoicing' ),
390
-                        'always'    => __( 'Charge Tax', 'invoicing' ),
389
+                        'no'        => __('Do not charge Tax', 'invoicing'),
390
+                        'always'    => __('Charge Tax', 'invoicing'),
391 391
                     ),
392
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
392
+                    'placeholder' => __('Select an option', 'invoicing'),
393 393
                     'std'         => 'always',
394 394
                 ),
395 395
 
@@ -403,68 +403,68 @@  discard block
 block discarded – undo
403 403
             'main' => array(
404 404
                 'email_settings_header' => array(
405 405
                     'id'   => 'email_settings_header',
406
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
406
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
407 407
                     'type' => 'header',
408 408
                 ),
409 409
                 'email_from_name' => array(
410 410
                     'id'   => 'email_from_name',
411
-                    'name' => __( 'From Name', 'invoicing' ),
412
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
413
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
411
+                    'name' => __('From Name', 'invoicing'),
412
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
413
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
414 414
                     'type' => 'text',
415 415
                 ),
416 416
                 'email_from' => array(
417 417
                     'id'   => 'email_from',
418
-                    'name' => __( 'From Email', 'invoicing' ),
419
-                    '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),
420
-                    'std' => get_option( 'admin_email' ),
418
+                    'name' => __('From Email', 'invoicing'),
419
+                    '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),
420
+                    'std' => get_option('admin_email'),
421 421
                     'type' => 'text',
422 422
                 ),
423 423
                 'admin_email' => array(
424 424
                     'id'   => 'admin_email',
425
-                    'name' => __( 'Admin Email', 'invoicing' ),
426
-                    'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
427
-                    'std' => get_option( 'admin_email' ),
425
+                    'name' => __('Admin Email', 'invoicing'),
426
+                    'desc' => __('Where should we send admin notifications?', 'invoicing'),
427
+                    'std' => get_option('admin_email'),
428 428
                     'type' => 'text',
429 429
                 ),
430 430
                 'overdue_settings_header' => array(
431 431
                     'id'   => 'overdue_settings_header',
432
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
432
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
433 433
                     'type' => 'header',
434 434
                 ),
435 435
                 'overdue_active' => array(
436 436
                     'id'   => 'overdue_active',
437
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
438
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
437
+                    'name' => __('Enable Due Date', 'invoicing'),
438
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
439 439
                     'type' => 'checkbox',
440 440
                     'std'  => false,
441 441
                 ),
442 442
                 'overdue_days' => array(
443 443
                     'id'          => 'overdue_days',
444
-                    'name'        => __( 'Default Due Date', 'invoicing' ),
445
-                    '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' ),
444
+                    'name'        => __('Default Due Date', 'invoicing'),
445
+                    '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'),
446 446
                     'type'        => 'select',
447 447
                     'options'     => $due_payment_options,
448 448
                     'std'         => 0,
449
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
449
+                    'placeholder' => __('Select a page', 'invoicing'),
450 450
                 ),
451 451
                 'email_template_header' => array(
452 452
                     'id'   => 'email_template_header',
453
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
453
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
454 454
                     'type' => 'header',
455 455
                 ),
456 456
                 'email_header_image' => array(
457 457
                     'id'   => 'email_header_image',
458
-                    'name' => __( 'Header Image', 'invoicing' ),
459
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
458
+                    'name' => __('Header Image', 'invoicing'),
459
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
460 460
                     'std' => '',
461 461
                     'type' => 'text',
462 462
                 ),
463 463
                 'email_footer_text' => array(
464 464
                     'id'   => 'email_footer_text',
465
-                    'name' => __( 'Footer Text', 'invoicing' ),
466
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
467
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
465
+                    'name' => __('Footer Text', 'invoicing'),
466
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
467
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
468 468
                     'type' => 'textarea',
469 469
                     'class' => 'regular-text',
470 470
                     'rows' => 2,
@@ -472,29 +472,29 @@  discard block
 block discarded – undo
472 472
                 ),
473 473
                 'email_base_color' => array(
474 474
                     'id'   => 'email_base_color',
475
-                    'name' => __( 'Base Color', 'invoicing' ),
476
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
475
+                    'name' => __('Base Color', 'invoicing'),
476
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
477 477
                     'std' => '#557da2',
478 478
                     'type' => 'color',
479 479
                 ),
480 480
                 'email_background_color' => array(
481 481
                     'id'   => 'email_background_color',
482
-                    'name' => __( 'Background Color', 'invoicing' ),
483
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
482
+                    'name' => __('Background Color', 'invoicing'),
483
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
484 484
                     'std' => '#f5f5f5',
485 485
                     'type' => 'color',
486 486
                 ),
487 487
                 'email_body_background_color' => array(
488 488
                     'id'   => 'email_body_background_color',
489
-                    'name' => __( 'Body Background Color', 'invoicing' ),
490
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
489
+                    'name' => __('Body Background Color', 'invoicing'),
490
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
491 491
                     'std' => '#fdfdfd',
492 492
                     'type' => 'color',
493 493
                 ),
494 494
                 'email_text_color' => array(
495 495
                     'id'   => 'email_text_color',
496
-                    'name' => __( 'Body Text Color', 'invoicing' ),
497
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
496
+                    'name' => __('Body Text Color', 'invoicing'),
497
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
498 498
                     'std' => '#505050',
499 499
                     'type' => 'color',
500 500
                 ),
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     ),
510 510
 
511 511
     // Integrations.
512
-    'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ),
512
+    'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'),
513 513
 
514 514
     /** Privacy Settings */
515 515
     'privacy' => apply_filters('wpinv_settings_privacy',
@@ -517,17 +517,17 @@  discard block
 block discarded – undo
517 517
             'main' => array(
518 518
                 'invoicing_privacy_policy_settings' => array(
519 519
                     'id'   => 'invoicing_privacy_policy_settings',
520
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
520
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
521 521
                     'type' => 'header',
522 522
                 ),
523 523
                 'privacy_page' => array(
524 524
                     'id'          => 'privacy_page',
525
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
526
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
525
+                    'name'        => __('Privacy Page', 'invoicing'),
526
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
527 527
                     'type'        => 'select',
528
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
528
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
529 529
                     'class'       => 'wpi_select2',
530
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
530
+                    'placeholder' => __('Select a page', 'invoicing'),
531 531
                 ),
532 532
             ),
533 533
         )
@@ -538,19 +538,19 @@  discard block
 block discarded – undo
538 538
             'main' => array(
539 539
                 'invoice_number_format_settings' => array(
540 540
                     'id'   => 'invoice_number_format_settings',
541
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
541
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
542 542
                     'type' => 'header',
543 543
                 ),
544 544
                 'sequential_invoice_number' => array(
545 545
                     'id'   => 'sequential_invoice_number',
546
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
547
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
546
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
547
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
548 548
                     'type' => 'checkbox',
549 549
                 ),
550 550
                 'invoice_sequence_start' => array(
551 551
                     'id'   => 'invoice_sequence_start',
552
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
553
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
552
+                    'name' => __('Sequential Starting Number', 'invoicing'),
553
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
554 554
                     'type' => 'number',
555 555
                     'size' => 'small',
556 556
                     'std'  => '1',
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
                 ),
559 559
                 'invoice_number_padd' => array(
560 560
                     'id'      => 'invoice_number_padd',
561
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
562
-                    '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' ),
561
+                    'name'    => __('Minimum Digits', 'invoicing'),
562
+                    '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'),
563 563
                     'type'    => 'select',
564 564
                     'options' => $invoice_number_padd_options,
565 565
                     'std'     => 5,
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
                 ),
568 568
                 'invoice_number_prefix' => array(
569 569
                     'id' => 'invoice_number_prefix',
570
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
571
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
570
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
571
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
572 572
                     'type' => 'text',
573 573
                     'size' => 'regular',
574 574
                     'std' => 'INV-',
@@ -576,41 +576,41 @@  discard block
 block discarded – undo
576 576
                 ),
577 577
                 'invoice_number_postfix' => array(
578 578
                     'id' => 'invoice_number_postfix',
579
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
580
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
579
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
580
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
581 581
                     'type' => 'text',
582 582
                     'size' => 'regular',
583 583
                     'std' => ''
584 584
                 ),
585 585
                 'checkout_settings' => array(
586 586
                     'id'   => 'checkout_settings',
587
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
587
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
588 588
                     'type' => 'header',
589 589
                 ),
590 590
                 'login_to_checkout' => array(
591 591
                     'id'   => 'login_to_checkout',
592
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
593
-                    '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' ),
592
+                    'name' => __('Require Login To Checkout', 'invoicing'),
593
+                    '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'),
594 594
                     'type' => 'checkbox',
595 595
                 ),
596 596
 
597 597
                 'maxmind_license_key' => array(
598 598
                     'id'   => 'maxmind_license_key',
599
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
599
+                    'name' => __('MaxMind License Key', 'invoicing'),
600 600
                     'type' => 'text',
601 601
                     'size' => 'regular',
602
-                    'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>',
602
+                    'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>',
603 603
                 ),
604 604
 
605 605
                 'uninstall_settings' => array(
606 606
                     'id'   => 'uninstall_settings',
607
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
607
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
608 608
                     'type' => 'header',
609 609
                 ),
610 610
                 'remove_data_on_unistall' => array(
611 611
                     'id'   => 'remove_data_on_unistall',
612
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
613
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
612
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
613
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
614 614
                     'type' => 'checkbox',
615 615
                     'std'  => ''
616 616
                 ),
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
             'custom-css' => array(
620 620
                 'css_settings' => array(
621 621
                     'id'   => 'css_settings',
622
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
622
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
623 623
                     'type' => 'header',
624 624
                 ),
625 625
                 'template_custom_css' => array(
626 626
                     'id' => 'template_custom_css',
627
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
628
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
627
+                    'name' => __('Invoice Template CSS', 'invoicing'),
628
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
629 629
                     'type' => 'textarea',
630 630
                     'class'=> 'regular-text',
631 631
                     'rows' => 10,
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
             'main' => array(
640 640
                 'tool_settings' => array(
641 641
                     'id'   => 'tool_settings',
642
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
643
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
642
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
643
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
644 644
                     'type' => 'tools',
645 645
                 ),
646 646
             ),
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( ! is_array( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (!is_array($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,47 +190,47 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name    = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name    = isset($option['name']) ? $option['name'] : '';
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
199
+	if (isset($option['desc']) && !empty($option['help-tip'])) {
200
+		$tip   = wpinv_clean($option['desc']);
201 201
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
202
+		unset($option['desc']);
203 203
 	}
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
207 207
         'wpinv_settings[' . $option['id'] . ']',
208 208
         $name,
209
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
209
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
210 210
         $section,
211 211
         $section,
212 212
         array(
213 213
             'section'     => $section,
214
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
215
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
216 216
             'name'        => $name,
217
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
218
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
219
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
220
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
221
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
224
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
225
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
226
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
227
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
232
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
217
+            'size'        => isset($option['size']) ? $option['size'] : null,
218
+            'options'     => isset($option['options']) ? $option['options'] : '',
219
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
220
+            'std'         => isset($option['std']) ? $option['std'] : '',
221
+            'min'         => isset($option['min']) ? $option['min'] : 0,
222
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
223
+            'step'        => isset($option['step']) ? $option['step'] : 1,
224
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
225
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
226
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
227
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
228
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
229
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
230
+			'class'       => isset($option['class']) ? $option['class'] : '',
231
+			'style'       => isset($option['style']) ? $option['style'] : '',
232
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
235 235
     );
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
246 246
 }
247 247
 
248 248
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function getpaid_get_integration_settings() {
254
-    return apply_filters( 'getpaid_integration_settings', array() );
254
+    return apply_filters('getpaid_integration_settings', array());
255 255
 }
256 256
 
257 257
 /**
@@ -259,140 +259,140 @@  discard block
 block discarded – undo
259 259
  * 
260 260
  * @return array
261 261
  */
262
-function wpinv_settings_sanitize( $input = array() ) {
262
+function wpinv_settings_sanitize($input = array()) {
263 263
 
264 264
     $wpinv_options = wpinv_get_options();
265 265
 
266
-    if ( empty( wp_get_raw_referer() ) ) {
266
+    if (empty(wp_get_raw_referer())) {
267 267
         return $input;
268 268
     }
269 269
 
270
-    wp_parse_str( wp_get_raw_referer(), $referrer );
270
+    wp_parse_str(wp_get_raw_referer(), $referrer);
271 271
 
272 272
     $settings = wpinv_get_registered_settings();
273
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
274
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
273
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
274
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
275 275
 
276 276
     $input = $input ? $input : array();
277
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
278
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
277
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
278
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
279 279
 
280 280
     // Loop through each setting being saved and pass it through a sanitization filter
281
-    foreach ( $input as $key => $value ) {
281
+    foreach ($input as $key => $value) {
282 282
 
283 283
         // Get the setting type (checkbox, select, etc)
284
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
284
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
285 285
 
286
-        if ( $type ) {
286
+        if ($type) {
287 287
             // Field type specific filter
288
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
288
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
293 293
 
294 294
 		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
295
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
299
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
300
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
299
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
300
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
301 301
 
302
-    $found_settings = array_merge( $main_settings, $section_settings );
302
+    $found_settings = array_merge($main_settings, $section_settings);
303 303
 
304
-    if ( ! empty( $found_settings ) ) {
305
-        foreach ( $found_settings as $key => $value ) {
304
+    if (!empty($found_settings)) {
305
+        foreach ($found_settings as $key => $value) {
306 306
 
307 307
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
308
-            if ( is_numeric( $key ) ) {
308
+            if (is_numeric($key)) {
309 309
                 $key = $value['id'];
310 310
             }
311 311
 
312
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
313
-                unset( $wpinv_options[ $key ] );
312
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
313
+                unset($wpinv_options[$key]);
314 314
             }
315 315
         }
316 316
     }
317 317
 
318 318
     // Merge our new settings with the existing
319
-    $output = array_merge( $wpinv_options, $input );
319
+    $output = array_merge($wpinv_options, $input);
320 320
 
321
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
321
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
322 322
 
323 323
     return $output;
324 324
 }
325 325
 
326
-function wpinv_settings_sanitize_misc_accounting( $input ) {
326
+function wpinv_settings_sanitize_misc_accounting($input) {
327 327
 
328
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
328
+    if (!wpinv_current_user_can_manage_invoicing()) {
329 329
         return $input;
330 330
     }
331 331
 
332
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
332
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
333 333
         // Shows an admin notice about upgrading previous order numbers
334
-        getpaid_session()->set( 'upgrade_sequential', '1' );
334
+        getpaid_session()->set('upgrade_sequential', '1');
335 335
     }
336 336
 
337 337
     return $input;
338 338
 }
339
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
339
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
340 340
 
341
-function wpinv_settings_sanitize_tax_rates( $input ) {
342
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
341
+function wpinv_settings_sanitize_tax_rates($input) {
342
+    if (!wpinv_current_user_can_manage_invoicing()) {
343 343
         return $input;
344 344
     }
345 345
 
346
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
346
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
347 347
     $tax_rates = array();
348 348
 
349
-    foreach ( $new_rates as $rate ) {
349
+    foreach ($new_rates as $rate) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
351
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
352
+		$rate['name']    = sanitize_text_field($rate['name']);
353
+		$rate['state']   = sanitize_text_field($rate['state']);
354
+		$rate['country'] = sanitize_text_field($rate['country']);
355
+		$rate['global']  = empty($rate['state']);
356 356
 		$tax_rates[]     = $rate;
357 357
 
358 358
 	}
359 359
 
360
-    update_option( 'wpinv_tax_rates', $tax_rates );
360
+    update_option('wpinv_tax_rates', $tax_rates);
361 361
 
362 362
     return $input;
363 363
 }
364
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
364
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
365 365
 
366
-function wpinv_sanitize_text_field( $input ) {
367
-    return trim( $input );
366
+function wpinv_sanitize_text_field($input) {
367
+    return trim($input);
368 368
 }
369
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
369
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
370 370
 
371 371
 function wpinv_get_settings_tabs() {
372 372
     $tabs             = array();
373
-    $tabs['general']  = __( 'General', 'invoicing' );
374
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
373
+    $tabs['general']  = __('General', 'invoicing');
374
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
375
+    $tabs['taxes']    = __('Taxes', 'invoicing');
376
+	$tabs['emails'] = __('Emails', 'invoicing');
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
378
+	if (count(getpaid_get_integration_settings()) > 0) {
379
+		$tabs['integrations'] = __('Integrations', 'invoicing');
380 380
 	}
381 381
 
382
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
384
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
382
+    $tabs['privacy']  = __('Privacy', 'invoicing');
383
+    $tabs['misc']     = __('Misc', 'invoicing');
384
+    $tabs['tools']    = __('Tools', 'invoicing');
385 385
 
386
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
386
+    return apply_filters('wpinv_settings_tabs', $tabs);
387 387
 }
388 388
 
389
-function wpinv_get_settings_tab_sections( $tab = false ) {
389
+function wpinv_get_settings_tab_sections($tab = false) {
390 390
     $tabs     = false;
391 391
     $sections = wpinv_get_registered_settings_sections();
392 392
 
393
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
394
-        $tabs = $sections[ $tab ];
395
-    } else if ( $tab ) {
393
+    if ($tab && !empty($sections[$tab])) {
394
+        $tabs = $sections[$tab];
395
+    } else if ($tab) {
396 396
         $tabs = false;
397 397
     }
398 398
 
@@ -402,91 +402,91 @@  discard block
 block discarded – undo
402 402
 function wpinv_get_registered_settings_sections() {
403 403
     static $sections = false;
404 404
 
405
-    if ( false !== $sections ) {
405
+    if (false !== $sections) {
406 406
         return $sections;
407 407
     }
408 408
 
409 409
     $sections = array(
410
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
411
-            'main' => __( 'General Settings', 'invoicing' ),
412
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
413
-            'labels' => __( 'Label Texts', 'invoicing' ),
414
-        ) ),
415
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
416
-            'main' => __( 'Gateway Settings', 'invoicing' ),
417
-        ) ),
418
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
419
-            'main'  => __( 'Tax Settings', 'invoicing' ),
420
-			'rates' => __( 'Tax Rates', 'invoicing' ),
421
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
422
-        ) ),
423
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
424
-            'main' => __( 'Email Settings', 'invoicing' ),
425
-		) ),
426
-
427
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
428
-
429
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
430
-            'main' => __( 'Privacy policy', 'invoicing' ),
431
-        ) ),
432
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
433
-            'main' => __( 'Miscellaneous', 'invoicing' ),
434
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
-        ) ),
436
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
437
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
438
-        ) ),
410
+        'general' => apply_filters('wpinv_settings_sections_general', array(
411
+            'main' => __('General Settings', 'invoicing'),
412
+            'currency_section' => __('Currency Settings', 'invoicing'),
413
+            'labels' => __('Label Texts', 'invoicing'),
414
+        )),
415
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
416
+            'main' => __('Gateway Settings', 'invoicing'),
417
+        )),
418
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
419
+            'main'  => __('Tax Settings', 'invoicing'),
420
+			'rates' => __('Tax Rates', 'invoicing'),
421
+			'vat'   => __('EU VAT Settings', 'invoicing')
422
+        )),
423
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
424
+            'main' => __('Email Settings', 'invoicing'),
425
+		)),
426
+
427
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
428
+
429
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
430
+            'main' => __('Privacy policy', 'invoicing'),
431
+        )),
432
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
433
+            'main' => __('Miscellaneous', 'invoicing'),
434
+            'custom-css' => __('Custom CSS', 'invoicing'),
435
+        )),
436
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
437
+            'main' => __('Diagnostic Tools', 'invoicing'),
438
+        )),
439 439
     );
440 440
 
441
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
441
+    $sections = apply_filters('wpinv_settings_sections', $sections);
442 442
 
443 443
     return $sections;
444 444
 }
445 445
 
446
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
446
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
447 447
 	$pages_options = array();
448 448
 
449
-	if( $default_label !== NULL && $default_label !== false ) {
450
-		$pages_options = array( '' => $default_label ); // Blank option
449
+	if ($default_label !== NULL && $default_label !== false) {
450
+		$pages_options = array('' => $default_label); // Blank option
451 451
 	}
452 452
 
453 453
 	$pages = get_pages();
454
-	if ( $pages ) {
455
-		foreach ( $pages as $page ) {
454
+	if ($pages) {
455
+		foreach ($pages as $page) {
456 456
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
457
-            $pages_options[ $page->ID ] = $title;
457
+            $pages_options[$page->ID] = $title;
458 458
 		}
459 459
 	}
460 460
 
461 461
 	return $pages_options;
462 462
 }
463 463
 
464
-function wpinv_header_callback( $args ) {
465
-	if ( !empty( $args['desc'] ) ) {
464
+function wpinv_header_callback($args) {
465
+	if (!empty($args['desc'])) {
466 466
         echo $args['desc'];
467 467
     }
468 468
 }
469 469
 
470
-function wpinv_hidden_callback( $args ) {
470
+function wpinv_hidden_callback($args) {
471 471
 	global $wpinv_options;
472 472
 
473
-	if ( isset( $args['set_value'] ) ) {
473
+	if (isset($args['set_value'])) {
474 474
 		$value = $args['set_value'];
475
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
476
-		$value = $wpinv_options[ $args['id'] ];
475
+	} elseif (isset($wpinv_options[$args['id']])) {
476
+		$value = $wpinv_options[$args['id']];
477 477
 	} else {
478
-		$value = isset( $args['std'] ) ? $args['std'] : '';
478
+		$value = isset($args['std']) ? $args['std'] : '';
479 479
 	}
480 480
 
481
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
481
+	if (isset($args['faux']) && true === $args['faux']) {
482 482
 		$args['readonly'] = true;
483
-		$value = isset( $args['std'] ) ? $args['std'] : '';
483
+		$value = isset($args['std']) ? $args['std'] : '';
484 484
 		$name  = '';
485 485
 	} else {
486
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
486
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
487 487
 	}
488 488
 
489
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
489
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
490 490
     
491 491
 	echo $html;
492 492
 }
@@ -494,61 +494,61 @@  discard block
 block discarded – undo
494 494
 /**
495 495
  * Displays a checkbox settings callback.
496 496
  */
497
-function wpinv_checkbox_callback( $args ) {
497
+function wpinv_checkbox_callback($args) {
498 498
 
499
-	$std = isset( $args['std'] ) ? $args['std'] : '';
500
-	$std = wpinv_get_option( $args['id'], $std );
501
-	$id  = esc_attr( $args['id'] );
499
+	$std = isset($args['std']) ? $args['std'] : '';
500
+	$std = wpinv_get_option($args['id'], $std);
501
+	$id  = esc_attr($args['id']);
502 502
 
503
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
503
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
504 504
 	?>
505 505
 		<fieldset>
506 506
 			<label>
507
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
508
-				<?php echo wp_kses_post( $args['desc'] ); ?>
507
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
508
+				<?php echo wp_kses_post($args['desc']); ?>
509 509
 			</label>
510 510
 		</fieldset>
511 511
 	<?php
512 512
 }
513 513
 
514
-function wpinv_multicheck_callback( $args ) {
514
+function wpinv_multicheck_callback($args) {
515 515
 	
516 516
 	global $wpinv_options;
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+	$sanitize_id = wpinv_sanitize_key($args['id']);
519
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+	if (!empty($args['options'])) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
523
+		$std     = isset($args['std']) ? $args['std'] : array();
524
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
525 525
 
526 526
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
527
-        foreach( $args['options'] as $key => $option ):
528
-			$sanitize_key = wpinv_sanitize_key( $key );
529
-			if ( in_array( $sanitize_key, $value ) ) { 
527
+        foreach ($args['options'] as $key => $option):
528
+			$sanitize_key = wpinv_sanitize_key($key);
529
+			if (in_array($sanitize_key, $value)) { 
530 530
 				$enabled = $sanitize_key;
531 531
 			} else { 
532 532
 				$enabled = NULL; 
533 533
 			}
534
-			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;';
535
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+			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;';
535
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
536 536
 		endforeach;
537 537
 		echo '</div>';
538 538
 		echo '<p class="description">' . $args['desc'] . '</p>';
539 539
 	}
540 540
 }
541 541
 
542
-function wpinv_payment_icons_callback( $args ) {
542
+function wpinv_payment_icons_callback($args) {
543 543
 	global $wpinv_options;
544 544
     
545
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
+    $sanitize_id = wpinv_sanitize_key($args['id']);
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach( $args['options'] as $key => $option ) {
549
-            $sanitize_key = wpinv_sanitize_key( $key );
547
+	if (!empty($args['options'])) {
548
+		foreach ($args['options'] as $key => $option) {
549
+            $sanitize_key = wpinv_sanitize_key($key);
550 550
             
551
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
551
+			if (isset($wpinv_options[$args['id']][$key])) {
552 552
 				$enabled = $option;
553 553
 			} else {
554 554
 				$enabled = NULL;
@@ -556,109 +556,109 @@  discard block
 block discarded – undo
556 556
 
557 557
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558 558
 
559
-				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;';
559
+				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;';
560 560
 
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+				if (wpinv_string_is_image_url($key)) {
562
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563 563
 				} else {
564
-					$card = strtolower( str_replace( ' ', '', $option ) );
564
+					$card = strtolower(str_replace(' ', '', $option));
565 565
 
566
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
567
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
568 568
 					} else {
569
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
569
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
570 570
 						$content_dir = WP_CONTENT_DIR;
571 571
 
572
-						if ( function_exists( 'wp_normalize_path' ) ) {
572
+						if (function_exists('wp_normalize_path')) {
573 573
 							// Replaces backslashes with forward slashes for Windows systems
574
-							$image = wp_normalize_path( $image );
575
-							$content_dir = wp_normalize_path( $content_dir );
574
+							$image = wp_normalize_path($image);
575
+							$content_dir = wp_normalize_path($content_dir);
576 576
 						}
577 577
 
578
-						$image = str_replace( $content_dir, content_url(), $image );
578
+						$image = str_replace($content_dir, content_url(), $image);
579 579
 					}
580 580
 
581
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
581
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582 582
 				}
583 583
 			echo $option . '</label>';
584 584
 		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
585
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
586 586
 	}
587 587
 }
588 588
 
589 589
 /**
590 590
  * Displays a radio settings field.
591 591
  */
592
-function wpinv_radio_callback( $args ) {
592
+function wpinv_radio_callback($args) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
594
+	$std = isset($args['std']) ? $args['std'] : '';
595
+	$std = wpinv_get_option($args['id'], $std);
596 596
 	?>
597 597
 		<fieldset>
598
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599
-				<?php foreach( $args['options'] as $key => $option ) : ?>
598
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
599
+				<?php foreach ($args['options'] as $key => $option) : ?>
600 600
 					<li>
601 601
 						<label>
602
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
603
-							<?php echo wp_kses_post( $option ); ?>
602
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
603
+							<?php echo wp_kses_post($option); ?>
604 604
 						</label>
605 605
 					</li>
606 606
 				<?php endforeach; ?>
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+	getpaid_settings_description_callback($args);
611 611
 }
612 612
 
613 613
 /**
614 614
  * Displays a description if available.
615 615
  */
616
-function getpaid_settings_description_callback( $args ) {
616
+function getpaid_settings_description_callback($args) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
619
-		$description = wp_kses_post( $args['desc'] );
618
+	if (!empty($args['desc'])) {
619
+		$description = wp_kses_post($args['desc']);
620 620
 		echo "<p class='description'>$description</p>";
621 621
 	}
622 622
 
623 623
 }
624 624
 
625
-function wpinv_gateways_callback( $args ) {
625
+function wpinv_gateways_callback($args) {
626 626
 	global $wpinv_options;
627 627
     
628
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
628
+    $sanitize_id = wpinv_sanitize_key($args['id']);
629 629
 
630
-	foreach ( $args['options'] as $key => $option ) :
631
-		$sanitize_key = wpinv_sanitize_key( $key );
630
+	foreach ($args['options'] as $key => $option) :
631
+		$sanitize_key = wpinv_sanitize_key($key);
632 632
         
633
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
633
+        if (isset($wpinv_options['gateways'][$key]))
634 634
 			$enabled = '1';
635 635
 		else
636 636
 			$enabled = null;
637 637
 
638
-		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;';
639
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
638
+		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;';
639
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
640 640
 	endforeach;
641 641
 }
642 642
 
643 643
 function wpinv_gateway_select_callback($args) {
644 644
 	global $wpinv_options;
645 645
     
646
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
647
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
646
+    $sanitize_id = wpinv_sanitize_key($args['id']);
647
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
648 648
 
649
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
649
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
650 650
 
651
-	foreach ( $args['options'] as $key => $option ) :
652
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653
-            $selected = selected( $key, $args['selected'], false );
651
+	foreach ($args['options'] as $key => $option) :
652
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
653
+            $selected = selected($key, $args['selected'], false);
654 654
         } else {
655
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
655
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
656 656
         }
657
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
657
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
658 658
 	endforeach;
659 659
 
660 660
 	echo '</select>';
661
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
661
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
662 662
 }
663 663
 
664 664
 /**
@@ -667,28 +667,28 @@  discard block
 block discarded – undo
667 667
  * @param array $args
668 668
  * @return string
669 669
  */
670
-function wpinv_settings_attrs_helper( $args ) {
670
+function wpinv_settings_attrs_helper($args) {
671 671
 
672
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
673
-	$id           = esc_attr( $args['id'] );
674
-	$placeholder  = esc_attr( $args['placeholder'] );
672
+	$value        = isset($args['std']) ? $args['std'] : '';
673
+	$id           = esc_attr($args['id']);
674
+	$placeholder  = esc_attr($args['placeholder']);
675 675
 
676
-	if ( ! empty( $args['faux'] ) ) {
676
+	if (!empty($args['faux'])) {
677 677
 		$args['readonly'] = true;
678 678
 		$name             = '';
679 679
 	} else {
680
-		$value  = wpinv_get_option( $args['id'], $value );
680
+		$value  = wpinv_get_option($args['id'], $value);
681 681
 		$name   = "wpinv_settings[$id]";
682 682
 	}
683 683
 
684
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
-	$class    = esc_attr( $args['class'] );
686
-	$style    = esc_attr( $args['style'] );
687
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
684
+	$value    = is_scalar($value) ? esc_attr($value) : '';
685
+	$class    = esc_attr($args['class']);
686
+	$style    = esc_attr($args['style']);
687
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
688 688
 
689 689
 	$onchange = '';
690
-    if ( ! empty( $args['onchange'] ) ) {
691
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
690
+    if (!empty($args['onchange'])) {
691
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
692 692
 	}
693 693
 
694 694
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 /**
698 698
  * Displays a text input settings callback.
699 699
  */
700
-function wpinv_text_callback( $args ) {
700
+function wpinv_text_callback($args) {
701 701
 
702
-	$desc = wp_kses_post( $args['desc'] );
703
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
-	$attr = wpinv_settings_attrs_helper( $args );
702
+	$desc = wp_kses_post($args['desc']);
703
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
704
+	$attr = wpinv_settings_attrs_helper($args);
705 705
 
706 706
 	?>
707 707
 		<label style="width: 100%;">
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 /**
716 716
  * Displays a number input settings callback.
717 717
  */
718
-function wpinv_number_callback( $args ) {
718
+function wpinv_number_callback($args) {
719 719
 
720
-	$desc = wp_kses_post( $args['desc'] );
721
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
-	$attr = wpinv_settings_attrs_helper( $args );
723
-	$max  = intval( $args['max'] );
724
-	$min  = intval( $args['min'] );
725
-	$step = floatval( $args['step'] );
720
+	$desc = wp_kses_post($args['desc']);
721
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
722
+	$attr = wpinv_settings_attrs_helper($args);
723
+	$max  = intval($args['max']);
724
+	$min  = intval($args['min']);
725
+	$step = floatval($args['step']);
726 726
 
727 727
 	?>
728 728
 		<label style="width: 100%;">
@@ -733,47 +733,47 @@  discard block
 block discarded – undo
733 733
 
734 734
 }
735 735
 
736
-function wpinv_textarea_callback( $args ) {
736
+function wpinv_textarea_callback($args) {
737 737
 	global $wpinv_options;
738 738
     
739
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
739
+    $sanitize_id = wpinv_sanitize_key($args['id']);
740 740
 
741
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
-		$value = $wpinv_options[ $args['id'] ];
741
+	if (isset($wpinv_options[$args['id']])) {
742
+		$value = $wpinv_options[$args['id']];
743 743
 	} else {
744
-		$value = isset( $args['std'] ) ? $args['std'] : '';
744
+		$value = isset($args['std']) ? $args['std'] : '';
745 745
 	}
746 746
     
747
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
748
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
747
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
748
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
749 749
 
750
-	$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>';
751
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750
+	$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>';
751
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
752 752
 
753 753
 	echo $html;
754 754
 }
755 755
 
756
-function wpinv_password_callback( $args ) {
756
+function wpinv_password_callback($args) {
757 757
 	global $wpinv_options;
758 758
     
759
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
759
+    $sanitize_id = wpinv_sanitize_key($args['id']);
760 760
 
761
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
-		$value = $wpinv_options[ $args['id'] ];
761
+	if (isset($wpinv_options[$args['id']])) {
762
+		$value = $wpinv_options[$args['id']];
763 763
 	} else {
764
-		$value = isset( $args['std'] ) ? $args['std'] : '';
764
+		$value = isset($args['std']) ? $args['std'] : '';
765 765
 	}
766 766
 
767
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
-	$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 ) . '"/>';
769
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
767
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
768
+	$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) . '"/>';
769
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
770 770
 
771 771
 	echo $html;
772 772
 }
773 773
 
774 774
 function wpinv_missing_callback($args) {
775 775
 	printf(
776
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
776
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
777 777
 		'<strong>' . $args['id'] . '</strong>'
778 778
 	);
779 779
 }
@@ -781,20 +781,20 @@  discard block
 block discarded – undo
781 781
 /**
782 782
  * Displays a number input settings callback.
783 783
  */
784
-function wpinv_select_callback( $args ) {
784
+function wpinv_select_callback($args) {
785 785
 
786
-	$desc   = wp_kses_post( $args['desc'] );
787
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
-	$attr   = wpinv_settings_attrs_helper( $args );
789
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
790
-	$value  = wpinv_get_option( $args['id'], $value );
786
+	$desc   = wp_kses_post($args['desc']);
787
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
788
+	$attr   = wpinv_settings_attrs_helper($args);
789
+	$value  = isset($args['std']) ? $args['std'] : '';
790
+	$value  = wpinv_get_option($args['id'], $value);
791 791
 
792 792
 	?>
793 793
 		<label style="width: 100%;">
794 794
 			<select <?php echo $attr; ?>>
795
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
796
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( is_array( $value ) ? in_array( "$option", $value, true ) : "$option" === $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
797
-				<?php endforeach;?>
795
+				<?php foreach ($args['options'] as $option => $name) : ?>
796
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected(is_array($value) ? in_array("$option", $value, true) : "$option" === $value); ?>><?php echo wpinv_clean($name); ?></option>
797
+				<?php endforeach; ?>
798 798
 			</select>
799 799
 			<?php echo $desc; ?>
800 800
 		</label>
@@ -802,95 +802,95 @@  discard block
 block discarded – undo
802 802
 
803 803
 }
804 804
 
805
-function wpinv_color_select_callback( $args ) {
805
+function wpinv_color_select_callback($args) {
806 806
 	global $wpinv_options;
807 807
     
808
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
808
+    $sanitize_id = wpinv_sanitize_key($args['id']);
809 809
 
810
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
-		$value = $wpinv_options[ $args['id'] ];
810
+	if (isset($wpinv_options[$args['id']])) {
811
+		$value = $wpinv_options[$args['id']];
812 812
 	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
813
+		$value = isset($args['std']) ? $args['std'] : '';
814 814
 	}
815 815
 
816
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
816
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
817 817
 
818
-	foreach ( $args['options'] as $option => $color ) {
819
-		$selected = selected( $option, $value, false );
820
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
818
+	foreach ($args['options'] as $option => $color) {
819
+		$selected = selected($option, $value, false);
820
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
821 821
 	}
822 822
 
823 823
 	$html .= '</select>';
824
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
824
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
825 825
 
826 826
 	echo $html;
827 827
 }
828 828
 
829
-function wpinv_rich_editor_callback( $args ) {
829
+function wpinv_rich_editor_callback($args) {
830 830
 	global $wpinv_options, $wp_version;
831 831
     
832
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
832
+    $sanitize_id = wpinv_sanitize_key($args['id']);
833 833
 
834
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
-		$value = $wpinv_options[ $args['id'] ];
834
+	if (isset($wpinv_options[$args['id']])) {
835
+		$value = $wpinv_options[$args['id']];
836 836
 
837
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
-			$value = isset( $args['std'] ) ? $args['std'] : '';
837
+		if (empty($args['allow_blank']) && empty($value)) {
838
+			$value = isset($args['std']) ? $args['std'] : '';
839 839
 		}
840 840
 	} else {
841
-		$value = isset( $args['std'] ) ? $args['std'] : '';
841
+		$value = isset($args['std']) ? $args['std'] : '';
842 842
 	}
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+	$rows = isset($args['size']) ? $args['size'] : 20;
845 845
 
846 846
 	$html = '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
847
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
848 848
 		ob_start();
849
-		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 ) );
849
+		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));
850 850
 		$html .= ob_get_clean();
851 851
 	} else {
852
-		$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>';
852
+		$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>';
853 853
 	}
854 854
 
855
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
856 856
 
857 857
 	echo $html;
858 858
 }
859 859
 
860
-function wpinv_upload_callback( $args ) {
860
+function wpinv_upload_callback($args) {
861 861
 	global $wpinv_options;
862 862
     
863
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
863
+    $sanitize_id = wpinv_sanitize_key($args['id']);
864 864
 
865
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
865
+	if (isset($wpinv_options[$args['id']])) {
866 866
 		$value = $wpinv_options[$args['id']];
867 867
 	} else {
868 868
 		$value = isset($args['std']) ? $args['std'] : '';
869 869
 	}
870 870
 
871
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
-	$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 ) ) . '"/>';
873
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
871
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
872
+	$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)) . '"/>';
873
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
874
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
875 875
 
876 876
 	echo $html;
877 877
 }
878 878
 
879
-function wpinv_color_callback( $args ) {
879
+function wpinv_color_callback($args) {
880 880
 	global $wpinv_options;
881 881
     
882
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
882
+    $sanitize_id = wpinv_sanitize_key($args['id']);
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[ $args['id'] ];
884
+	if (isset($wpinv_options[$args['id']])) {
885
+		$value = $wpinv_options[$args['id']];
886 886
 	} else {
887
-		$value = isset( $args['std'] ) ? $args['std'] : '';
887
+		$value = isset($args['std']) ? $args['std'] : '';
888 888
 	}
889 889
 
890
-	$default = isset( $args['std'] ) ? $args['std'] : '';
890
+	$default = isset($args['std']) ? $args['std'] : '';
891 891
 
892
-	$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 ) . '" />';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+	$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) . '" />';
893
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
894 894
 
895 895
 	echo $html;
896 896
 }
@@ -898,9 +898,9 @@  discard block
 block discarded – undo
898 898
 function wpinv_country_states_callback($args) {
899 899
 	global $wpinv_options;
900 900
     
901
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
901
+    $sanitize_id = wpinv_sanitize_key($args['id']);
902 902
 
903
-	if ( isset( $args['placeholder'] ) ) {
903
+	if (isset($args['placeholder'])) {
904 904
 		$placeholder = $args['placeholder'];
905 905
 	} else {
906 906
 		$placeholder = '';
@@ -908,16 +908,16 @@  discard block
 block discarded – undo
908 908
 
909 909
 	$states = wpinv_get_country_states();
910 910
 
911
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
913 913
 
914
-	foreach ( $states as $option => $name ) {
915
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
914
+	foreach ($states as $option => $name) {
915
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
916
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
917 917
 	}
918 918
 
919 919
 	$html .= '</select>';
920
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
920
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
921 921
 
922 922
 	echo $html;
923 923
 }
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 	</tr>
933 933
 	<tr class="bsui">
934 934
     	<td colspan="2" class="p-0">
935
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
935
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
936 936
 
937 937
 	<?php
938 938
 
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
 /**
942 942
  * Displays a tax rate' edit row.
943 943
  */
944
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
944
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
945 945
 	ob_start();
946 946
 
947
-	$key                      = sanitize_key( $key );
948
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
947
+	$key                      = sanitize_key($key);
948
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
949
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
950 950
 
951
-	if ( $echo ) {
951
+	if ($echo) {
952 952
 		echo ob_get_clean();
953 953
 	} else {
954 954
 		return ob_get_clean(); 
@@ -960,81 +960,81 @@  discard block
 block discarded – undo
960 960
     ob_start(); ?>
961 961
     </td><tr>
962 962
     <td colspan="2" class="wpinv_tools_tdbox">
963
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
964
-    <?php do_action( 'wpinv_tools_before' ); ?>
963
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
964
+    <?php do_action('wpinv_tools_before'); ?>
965 965
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
966 966
         <thead>
967 967
             <tr>
968
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
969
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
970
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
968
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
969
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
970
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
971 971
             </tr>
972 972
         </thead>
973
-            <?php do_action( 'wpinv_tools_row' ); ?>
973
+            <?php do_action('wpinv_tools_row'); ?>
974 974
         <tbody>
975 975
         </tbody>
976 976
     </table>
977
-    <?php do_action( 'wpinv_tools_after' ); ?>
977
+    <?php do_action('wpinv_tools_after'); ?>
978 978
     <?php
979 979
     echo ob_get_clean();
980 980
 }
981 981
 
982
-function wpinv_descriptive_text_callback( $args ) {
983
-	echo wp_kses_post( $args['desc'] );
982
+function wpinv_descriptive_text_callback($args) {
983
+	echo wp_kses_post($args['desc']);
984 984
 }
985 985
 
986
-function wpinv_raw_html_callback( $args ) {
986
+function wpinv_raw_html_callback($args) {
987 987
 	echo $args['desc'];
988 988
 }
989 989
 
990
-function wpinv_hook_callback( $args ) {
991
-	do_action( 'wpinv_' . $args['id'], $args );
990
+function wpinv_hook_callback($args) {
991
+	do_action('wpinv_' . $args['id'], $args);
992 992
 }
993 993
 
994 994
 function wpinv_set_settings_cap() {
995 995
 	return wpinv_get_capability();
996 996
 }
997
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
997
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
998 998
 
999
-function wpinv_settings_sanitize_input( $value, $key ) {
999
+function wpinv_settings_sanitize_input($value, $key) {
1000 1000
 
1001
-    if ( $key == 'tax_rate' ) {
1002
-        $value = wpinv_sanitize_amount( $value );
1001
+    if ($key == 'tax_rate') {
1002
+        $value = wpinv_sanitize_amount($value);
1003 1003
         $value = $value >= 100 ? 99 : $value;
1004 1004
     }
1005 1005
 
1006 1006
     return $value;
1007 1007
 }
1008
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1008
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1009 1009
 
1010
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1011
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1012
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1010
+function wpinv_on_update_settings($old_value, $value, $option) {
1011
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1012
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1013 1013
     
1014
-    if ( $old != $new ) {
1015
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1014
+    if ($old != $new) {
1015
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1016 1016
     }
1017 1017
 }
1018
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1019
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1020
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1021
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1022
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1023
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1024
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1025
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1026
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1027
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1028
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1029
-
1030
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1018
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1019
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1020
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1021
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1022
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1023
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1024
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1025
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1026
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1027
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1028
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1029
+
1030
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1031 1031
     ?>
1032 1032
     <div class="wpinv-email-wc-row ">
1033 1033
         <div class="wpinv-email-wc-td">
1034
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1034
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1035 1035
             <p class="wpinv-email-wc-description">
1036 1036
                 <?php
1037
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1037
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1038 1038
                     <strong>{site_title} :</strong> Site Title<br>
1039 1039
                     <strong>{name} :</strong> Customer\'s full name<br>
1040 1040
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1049 1049
                     <strong>{date} :</strong> Today\'s date.<br>
1050 1050
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1051
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1051
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1052 1052
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1053 1053
                 ?>
1054 1054
             </p>
Please login to merge, or discard this patch.
includes/invoice-functions.php 1 patch
Spacing   +344 added lines, -344 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
  * Retrieves the current invoice.
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 function getpaid_get_current_invoice_id() {
15 15
 
16 16
     // Ensure that we have an invoice key.
17
-    if ( empty( $_GET['invoice_key'] ) ) {
17
+    if (empty($_GET['invoice_key'])) {
18 18
         return 0;
19 19
     }
20 20
 
21 21
     // Retrieve an invoice using the key.
22
-    $invoice = new WPInv_Invoice( $_GET['invoice_key'] );
22
+    $invoice = new WPInv_Invoice($_GET['invoice_key']);
23 23
 
24 24
     // Compare the invoice key and the parsed key.
25
-    if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) {
25
+    if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) {
26 26
         return $invoice->get_id();
27 27
     }
28 28
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 /**
33 33
  * Checks if the current user cna view an invoice.
34 34
  */
35
-function wpinv_user_can_view_invoice( $invoice ) {
36
-    $invoice = new WPInv_Invoice( $invoice );
35
+function wpinv_user_can_view_invoice($invoice) {
36
+    $invoice = new WPInv_Invoice($invoice);
37 37
 
38 38
     // Abort if the invoice does not exist.
39
-    if ( 0 == $invoice->get_id() ) {
39
+    if (0 == $invoice->get_id()) {
40 40
         return false;
41 41
     }
42 42
 
43 43
     // Don't allow trash, draft status
44
-    if ( $invoice->is_draft() ) {
44
+    if ($invoice->is_draft()) {
45 45
         return false;
46 46
     }
47 47
 
48 48
     // If users are not required to login to check out, compare the invoice keys.
49
-    if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) {
49
+    if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) {
50 50
         return true;
51 51
     }
52 52
 
53 53
     // Always enable for admins..
54
-    if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user
54
+    if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user
55 55
         return true;
56 56
     }
57 57
 
58 58
     // Else, ensure that this is their invoice.
59
-    if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) {
59
+    if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) {
60 60
         return true;
61 61
     }
62 62
 
63
-    return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice );
63
+    return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice);
64 64
 }
65 65
 
66 66
 /**
67 67
  * Checks if the current user cna view an invoice receipt.
68 68
  */
69
-function wpinv_can_view_receipt( $invoice ) {
70
-	return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice );
69
+function wpinv_can_view_receipt($invoice) {
70
+	return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice);
71 71
 }
72 72
 
73 73
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function getpaid_get_invoice_post_types() {
79 79
     $post_types = array(
80
-        'wpi_quote'   => __( 'Quote', 'invoicing' ),
81
-        'wpi_invoice' => __( 'Invoice', 'invoicing' ),
80
+        'wpi_quote'   => __('Quote', 'invoicing'),
81
+        'wpi_invoice' => __('Invoice', 'invoicing'),
82 82
     );
83 83
 
84
-    return apply_filters( 'getpaid_invoice_post_types', $post_types );
84
+    return apply_filters('getpaid_invoice_post_types', $post_types);
85 85
 }
86 86
 
87 87
 /**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
  * 
91 91
  * @param string $post_type The post type to check for.
92 92
  */
93
-function getpaid_is_invoice_post_type( $post_type ) {
94
-    return is_scalar( $post_type ) && ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() );
93
+function getpaid_is_invoice_post_type($post_type) {
94
+    return is_scalar($post_type) && !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types());
95 95
 }
96 96
 
97 97
 /**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
102 102
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
103 103
  */
104
-function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) {
105
-    $data[ 'invoice_id' ] = 0;
106
-    return wpinv_insert_invoice( $data, $wp_error );
104
+function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) {
105
+    $data['invoice_id'] = 0;
106
+    return wpinv_insert_invoice($data, $wp_error);
107 107
 }
108 108
 
109 109
 /**
@@ -113,36 +113,36 @@  discard block
 block discarded – undo
113 113
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
114 114
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
115 115
  */
116
-function wpinv_update_invoice( $data = array(), $wp_error = false ) {
116
+function wpinv_update_invoice($data = array(), $wp_error = false) {
117 117
 
118 118
     // Backwards compatibility.
119
-    if ( ! empty( $data['ID'] ) ) {
119
+    if (!empty($data['ID'])) {
120 120
         $data['invoice_id'] = $data['ID'];
121 121
     }
122 122
 
123 123
     // Do we have an invoice id?
124
-    if ( empty( $data['invoice_id'] ) ) {
125
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0;
124
+    if (empty($data['invoice_id'])) {
125
+        return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0;
126 126
     }
127 127
 
128 128
     // Retrieve the invoice.
129
-    $invoice = wpinv_get_invoice( $data['invoice_id'] );
129
+    $invoice = wpinv_get_invoice($data['invoice_id']);
130 130
 
131 131
     // And abort if it does not exist.
132
-    if ( empty( $invoice ) ) {
133
-        return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0;
132
+    if (empty($invoice)) {
133
+        return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0;
134 134
     }
135 135
 
136 136
     // Do not update totals for paid / refunded invoices.
137
-    if ( $invoice->is_paid() || $invoice->is_refunded() ) {
137
+    if ($invoice->is_paid() || $invoice->is_refunded()) {
138 138
 
139
-        if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) {
140
-            return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0;
139
+        if (!empty($data['items']) || !empty($data['cart_details'])) {
140
+            return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0;
141 141
         }
142 142
 
143 143
     }
144 144
 
145
-    return wpinv_insert_invoice( $data, $wp_error );
145
+    return wpinv_insert_invoice($data, $wp_error);
146 146
 
147 147
 }
148 148
 
@@ -153,34 +153,34 @@  discard block
 block discarded – undo
153 153
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
154 154
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
155 155
  */
156
-function wpinv_insert_invoice( $data = array(), $wp_error = false ) {
156
+function wpinv_insert_invoice($data = array(), $wp_error = false) {
157 157
 
158 158
     // Ensure that we have invoice data.
159
-    if ( empty( $data ) ) {
159
+    if (empty($data)) {
160 160
         return false;
161 161
     }
162 162
 
163 163
     // The invoice id will be provided when updating an invoice.
164
-    $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false;
164
+    $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false;
165 165
 
166 166
     // Retrieve the invoice.
167
-    $invoice = new WPInv_Invoice( $data['invoice_id'] );
167
+    $invoice = new WPInv_Invoice($data['invoice_id']);
168 168
 
169 169
     // Do we have an error?
170
-    if ( ! empty( $invoice->last_error ) ) {
171
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0;
170
+    if (!empty($invoice->last_error)) {
171
+        return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0;
172 172
     }
173 173
 
174 174
     // Backwards compatibility (billing address).
175
-    if ( ! empty( $data['user_info'] ) ) {
175
+    if (!empty($data['user_info'])) {
176 176
 
177
-        foreach ( $data['user_info'] as $key => $value ) {
177
+        foreach ($data['user_info'] as $key => $value) {
178 178
 
179
-            if ( $key == 'discounts' ) {
179
+            if ($key == 'discounts') {
180 180
                 $value = (array) $value;
181
-                $data[ 'discount_code' ] = empty( $value ) ? null : $value[0];
181
+                $data['discount_code'] = empty($value) ? null : $value[0];
182 182
             } else {
183
-                $data[ $key ] = $value;
183
+                $data[$key] = $value;
184 184
             }
185 185
 
186 186
         }
@@ -188,30 +188,30 @@  discard block
 block discarded – undo
188 188
     }
189 189
 
190 190
     // Backwards compatibility.
191
-    if ( ! empty( $data['payment_details'] ) ) {
191
+    if (!empty($data['payment_details'])) {
192 192
 
193
-        foreach ( $data['payment_details'] as $key => $value ) {
194
-            $data[ $key ] = $value;
193
+        foreach ($data['payment_details'] as $key => $value) {
194
+            $data[$key] = $value;
195 195
         }
196 196
 
197 197
     }
198 198
 
199 199
     // Set up the owner of the invoice.
200
-    $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id();
200
+    $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id();
201 201
 
202 202
     // Make sure the user exists.
203
-    if ( ! get_userdata( $user_id ) ) {
204
-        return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0;
203
+    if (!get_userdata($user_id)) {
204
+        return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0;
205 205
     }
206 206
 
207
-    $address = wpinv_get_user_address( $user_id );
207
+    $address = wpinv_get_user_address($user_id);
208 208
 
209
-    foreach ( $address as $key => $value ) {
209
+    foreach ($address as $key => $value) {
210 210
 
211
-        if ( $value == '' ) {
212
-            $address[ $key ] = null;
211
+        if ($value == '') {
212
+            $address[$key] = null;
213 213
         } else {
214
-            $address[ $key ] = wpinv_clean( $value );
214
+            $address[$key] = wpinv_clean($value);
215 215
         }
216 216
 
217 217
     }
@@ -222,103 +222,103 @@  discard block
 block discarded – undo
222 222
         array(
223 223
 
224 224
             // Basic info.
225
-            'template'             => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null,
226
-            'email_cc'             => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null,
227
-            'date_created'         => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null,
228
-            'due_date'             => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null,
229
-            'date_completed'       => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null,
230
-            'number'               => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null,
231
-            'key'                  => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null,
232
-            'status'               => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null,
233
-            'post_type'            => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null,
234
-            'user_ip'              => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(),
235
-            'parent_id'            => isset( $data['parent'] ) ? intval( $data['parent'] ) : null,
236
-            'mode'                 => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null,
237
-            'description'          => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null,
225
+            'template'             => isset($data['template']) ? wpinv_clean($data['template']) : null,
226
+            'email_cc'             => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null,
227
+            'date_created'         => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null,
228
+            'due_date'             => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null,
229
+            'date_completed'       => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null,
230
+            'number'               => isset($data['number']) ? wpinv_clean($data['number']) : null,
231
+            'key'                  => isset($data['key']) ? wpinv_clean($data['key']) : null,
232
+            'status'               => isset($data['status']) ? wpinv_clean($data['status']) : null,
233
+            'post_type'            => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null,
234
+            'user_ip'              => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(),
235
+            'parent_id'            => isset($data['parent']) ? intval($data['parent']) : null,
236
+            'mode'                 => isset($data['mode']) ? wpinv_clean($data['mode']) : null,
237
+            'description'          => isset($data['description']) ? wp_kses_post($data['description']) : null,
238 238
 
239 239
             // Payment info.
240
-            'disable_taxes'        => ! empty( $data['disable_taxes'] ),
241
-            'currency'             => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(),
242
-            'gateway'              => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null,
243
-            'transaction_id'       => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null,
244
-            'discount_code'        => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null,
245
-            'payment_form'         => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null,
246
-            'submission_id'        => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null,
247
-            'subscription_id'      => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null,
248
-            'is_viewed'            => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null,
249
-            'fees'                 => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null,
250
-            'discounts'            => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null,
251
-            'taxes'                => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null,
240
+            'disable_taxes'        => !empty($data['disable_taxes']),
241
+            'currency'             => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(),
242
+            'gateway'              => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null,
243
+            'transaction_id'       => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null,
244
+            'discount_code'        => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null,
245
+            'payment_form'         => isset($data['payment_form']) ? intval($data['payment_form']) : null,
246
+            'submission_id'        => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null,
247
+            'subscription_id'      => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null,
248
+            'is_viewed'            => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null,
249
+            'fees'                 => isset($data['fees']) ? wpinv_clean($data['fees']) : null,
250
+            'discounts'            => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null,
251
+            'taxes'                => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null,
252 252
             
253 253
 
254 254
             // Billing details.
255 255
             'user_id'              => $data['user_id'],
256
-            'first_name'           => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'],
257
-            'last_name'            => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'],
258
-            'address'              => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] ,
259
-            'vat_number'           => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'],
260
-            'company'              => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'],
261
-            'zip'                  => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'],
262
-            'state'                => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'],
263
-            'city'                 => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'],
264
-            'country'              => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'],
265
-            'phone'                => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'],
266
-            'address_confirmed'    => ! empty( $data['address_confirmed'] ),
256
+            'first_name'           => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'],
257
+            'last_name'            => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'],
258
+            'address'              => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'],
259
+            'vat_number'           => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'],
260
+            'company'              => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'],
261
+            'zip'                  => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'],
262
+            'state'                => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'],
263
+            'city'                 => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'],
264
+            'country'              => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'],
265
+            'phone'                => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'],
266
+            'address_confirmed'    => !empty($data['address_confirmed']),
267 267
 
268 268
         )
269 269
 
270 270
     );
271 271
 
272 272
     // Backwards compatibililty.
273
-    if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) {
273
+    if (!empty($data['cart_details']) && is_array($data['cart_details'])) {
274 274
         $data['items'] = array();
275 275
 
276
-        foreach( $data['cart_details'] as $_item ) {
276
+        foreach ($data['cart_details'] as $_item) {
277 277
 
278 278
             // Ensure that we have an item id.
279
-            if ( empty(  $_item['id']  ) ) {
279
+            if (empty($_item['id'])) {
280 280
                 continue;
281 281
             }
282 282
 
283 283
             // Retrieve the item.
284
-            $item = new GetPaid_Form_Item(  $_item['id']  );
284
+            $item = new GetPaid_Form_Item($_item['id']);
285 285
 
286 286
             // Ensure that it is purchasable.
287
-            if ( ! $item->can_purchase() ) {
287
+            if (!$item->can_purchase()) {
288 288
                 continue;
289 289
             }
290 290
 
291 291
             // Set quantity.
292
-            if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) {
293
-                $item->set_quantity( $_item['quantity'] );
292
+            if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) {
293
+                $item->set_quantity($_item['quantity']);
294 294
             }
295 295
 
296 296
             // Set price.
297
-            if ( isset( $_item['item_price'] ) ) {
298
-                $item->set_price( $_item['item_price'] );
297
+            if (isset($_item['item_price'])) {
298
+                $item->set_price($_item['item_price']);
299 299
             }
300 300
 
301
-            if ( isset( $_item['custom_price'] ) ) {
302
-                $item->set_price( $_item['custom_price'] );
301
+            if (isset($_item['custom_price'])) {
302
+                $item->set_price($_item['custom_price']);
303 303
             }
304 304
 
305 305
             // Set name.
306
-            if ( ! empty( $_item['name'] ) ) {
307
-                $item->set_name( $_item['name'] );
306
+            if (!empty($_item['name'])) {
307
+                $item->set_name($_item['name']);
308 308
             }
309 309
 
310 310
             // Set description.
311
-            if ( isset( $_item['description'] ) ) {
312
-                $item->set_custom_description( $_item['description'] );
311
+            if (isset($_item['description'])) {
312
+                $item->set_custom_description($_item['description']);
313 313
             }
314 314
 
315 315
             // Set meta.
316
-            if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) {
316
+            if (isset($_item['meta']) && is_array($_item['meta'])) {
317 317
 
318
-                $item->set_item_meta( $_item['meta'] );
318
+                $item->set_item_meta($_item['meta']);
319 319
 
320
-                if ( isset( $_item['meta']['description'] ) ) {
321
-                    $item->set_custom_description( $_item['meta']['description'] );
320
+                if (isset($_item['meta']['description'])) {
321
+                    $item->set_custom_description($_item['meta']['description']);
322 322
                 }
323 323
 
324 324
             }
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
     }
330 330
 
331 331
     // Add invoice items.
332
-    if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) {
332
+    if (!empty($data['items']) && is_array($data['items'])) {
333 333
 
334
-        $invoice->set_items( array() );
334
+        $invoice->set_items(array());
335 335
 
336
-        foreach ( $data['items'] as $item ) {
336
+        foreach ($data['items'] as $item) {
337 337
 
338
-            if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) {
339
-                $invoice->add_item( $item );
338
+            if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) {
339
+                $invoice->add_item($item);
340 340
             }
341 341
 
342 342
         }
@@ -347,30 +347,30 @@  discard block
 block discarded – undo
347 347
     $invoice->recalculate_total();
348 348
     $invoice->save();
349 349
 
350
-    if ( ! $invoice->get_id() ) {
351
-        return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0;
350
+    if (!$invoice->get_id()) {
351
+        return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0;
352 352
     }
353 353
 
354 354
     // Add private note.
355
-    if ( ! empty( $data['private_note'] ) ) {
356
-        $invoice->add_note( $data['private_note'] );
355
+    if (!empty($data['private_note'])) {
356
+        $invoice->add_note($data['private_note']);
357 357
     }
358 358
 
359 359
     // User notes.
360
-    if ( !empty( $data['user_note'] ) ) {
361
-        $invoice->add_note( $data['user_note'], true );
360
+    if (!empty($data['user_note'])) {
361
+        $invoice->add_note($data['user_note'], true);
362 362
     }
363 363
 
364 364
     // Created via.
365
-    if ( isset( $data['created_via'] ) ) {
366
-        update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] );
365
+    if (isset($data['created_via'])) {
366
+        update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']);
367 367
     }
368 368
 
369 369
     // Backwards compatiblity.
370
-    if ( $invoice->is_quote() ) {
370
+    if ($invoice->is_quote()) {
371 371
 
372
-        if ( isset( $data['valid_until'] ) ) {
373
-            update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] );
372
+        if (isset($data['valid_until'])) {
373
+            update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']);
374 374
         }
375 375
         return $invoice;
376 376
 
@@ -385,18 +385,18 @@  discard block
 block discarded – undo
385 385
  * @param $bool $deprecated
386 386
  * @return WPInv_Invoice|null
387 387
  */
388
-function wpinv_get_invoice( $invoice = 0, $deprecated = false ) {
388
+function wpinv_get_invoice($invoice = 0, $deprecated = false) {
389 389
 
390 390
     // If we are retrieving the invoice from the cart...
391
-    if ( $deprecated && empty( $invoice ) ) {
391
+    if ($deprecated && empty($invoice)) {
392 392
         $invoice = (int) getpaid_get_current_invoice_id();
393 393
     }
394 394
 
395 395
     // Retrieve the invoice.
396
-    $invoice = new WPInv_Invoice( $invoice );
396
+    $invoice = new WPInv_Invoice($invoice);
397 397
 
398 398
     // Check if it exists.
399
-    if ( $invoice->get_id() != 0 ) {
399
+    if ($invoice->get_id() != 0) {
400 400
         return $invoice;
401 401
     }
402 402
 
@@ -409,15 +409,15 @@  discard block
 block discarded – undo
409 409
  * @param array $args Args to search for.
410 410
  * @return WPInv_Invoice[]|int[]|object
411 411
  */
412
-function wpinv_get_invoices( $args ) {
412
+function wpinv_get_invoices($args) {
413 413
 
414 414
     // Prepare args.
415 415
     $args = wp_parse_args(
416 416
         $args,
417 417
         array(
418
-            'status'   => array_keys( wpinv_get_invoice_statuses() ),
418
+            'status'   => array_keys(wpinv_get_invoice_statuses()),
419 419
             'type'     => 'wpi_invoice',
420
-            'limit'    => get_option( 'posts_per_page' ),
420
+            'limit'    => get_option('posts_per_page'),
421 421
             'return'   => 'objects',
422 422
         )
423 423
     );
@@ -435,24 +435,24 @@  discard block
 block discarded – undo
435 435
         'post__in'       => 'include',
436 436
     );
437 437
 
438
-    foreach ( $map_legacy as $to => $from ) {
439
-        if ( isset( $args[ $from ] ) ) {
440
-            $args[ $to ] = $args[ $from ];
441
-            unset( $args[ $from ] );
438
+    foreach ($map_legacy as $to => $from) {
439
+        if (isset($args[$from])) {
440
+            $args[$to] = $args[$from];
441
+            unset($args[$from]);
442 442
         }
443 443
     }
444 444
 
445 445
     // Backwards compatibility.
446
-    if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) {
446
+    if (!empty($args['email']) && empty($args['user'])) {
447 447
         $args['user'] = $args['email'];
448
-        unset( $args['email'] );
448
+        unset($args['email']);
449 449
     }
450 450
 
451 451
     // Handle cases where the user is set as an email.
452
-    if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) {
453
-        $user = get_user_by( 'email', $args['user'] );
452
+    if (!empty($args['author']) && is_email($args['author'])) {
453
+        $user = get_user_by('email', $args['user']);
454 454
 
455
-        if ( $user ) {
455
+        if ($user) {
456 456
             $args['author'] = $user->user_email;
457 457
         }
458 458
 
@@ -463,31 +463,31 @@  discard block
 block discarded – undo
463 463
 
464 464
     // Show all posts.
465 465
     $paginate = true;
466
-    if ( isset( $args['paginate'] ) ) {
466
+    if (isset($args['paginate'])) {
467 467
 
468 468
         $paginate = $args['paginate'];
469
-        $args['no_found_rows'] = empty( $args['paginate'] );
470
-        unset( $args['paginate'] );
469
+        $args['no_found_rows'] = empty($args['paginate']);
470
+        unset($args['paginate']);
471 471
 
472 472
     }
473 473
 
474 474
     // Whether to return objects or fields.
475 475
     $return = $args['return'];
476
-    unset( $args['return'] );
476
+    unset($args['return']);
477 477
 
478 478
     // Get invoices.
479
-    $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) );
479
+    $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args));
480 480
 
481 481
     // Prepare the results.
482
-    if ( 'objects' === $return ) {
483
-        $results = array_map( 'wpinv_get_invoice', $invoices->posts );
484
-    } elseif ( 'self' === $return ) {
482
+    if ('objects' === $return) {
483
+        $results = array_map('wpinv_get_invoice', $invoices->posts);
484
+    } elseif ('self' === $return) {
485 485
         return $invoices;
486 486
     } else {
487 487
         $results = $invoices->posts;
488 488
     }
489 489
 
490
-    if ( $paginate ) {
490
+    if ($paginate) {
491 491
         return (object) array(
492 492
             'invoices'      => $results,
493 493
             'total'         => $invoices->found_posts,
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
  * @param string $transaction_id The transaction id to check.
506 506
  * @return int Invoice id on success or 0 on failure
507 507
  */
508
-function wpinv_get_id_by_transaction_id( $transaction_id ) {
509
-    return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' );
508
+function wpinv_get_id_by_transaction_id($transaction_id) {
509
+    return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id');
510 510
 }
511 511
 
512 512
 /**
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
  * @param string $invoice_number The invoice number to check.
516 516
  * @return int Invoice id on success or 0 on failure
517 517
  */
518
-function wpinv_get_id_by_invoice_number( $invoice_number ) {
519
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' );
518
+function wpinv_get_id_by_invoice_number($invoice_number) {
519
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number');
520 520
 }
521 521
 
522 522
 /**
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
  * @param string $invoice_key The invoice key to check.
526 526
  * @return int Invoice id on success or 0 on failure
527 527
  */
528
-function wpinv_get_invoice_id_by_key( $invoice_key ) {
529
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' );
528
+function wpinv_get_invoice_id_by_key($invoice_key) {
529
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key');
530 530
 }
531 531
 
532 532
 /**
@@ -536,19 +536,19 @@  discard block
 block discarded – undo
536 536
  * @param string $type Optionally filter by type i.e customer|system
537 537
  * @return array|null
538 538
  */
539
-function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) {
539
+function wpinv_get_invoice_notes($invoice = 0, $type = '') {
540 540
 
541 541
     // Prepare the invoice.
542
-    $invoice = wpinv_get_invoice( $invoice );
543
-    if ( empty( $invoice ) ) {
542
+    $invoice = wpinv_get_invoice($invoice);
543
+    if (empty($invoice)) {
544 544
         return NULL;
545 545
     }
546 546
 
547 547
     // Fetch notes.
548
-    $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type );
548
+    $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type);
549 549
 
550 550
     // Filter the notes.
551
-    return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type );
551
+    return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type);
552 552
 }
553 553
 
554 554
 /**
@@ -556,10 +556,10 @@  discard block
 block discarded – undo
556 556
  * 
557 557
  * @param string $post_type
558 558
  */
559
-function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) {
559
+function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') {
560 560
 
561
-    $label   = getpaid_get_post_type_label( $post_type, false );
562
-    $label   = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label );
561
+    $label   = getpaid_get_post_type_label($post_type, false);
562
+    $label   = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label);
563 563
     $columns = array(
564 564
 
565 565
             'invoice-number'  => array(
@@ -568,22 +568,22 @@  discard block
 block discarded – undo
568 568
             ),
569 569
 
570 570
             'created-date'    => array(
571
-                'title' => __( 'Created Date', 'invoicing' ),
571
+                'title' => __('Created Date', 'invoicing'),
572 572
                 'class' => 'text-left'
573 573
             ),
574 574
 
575 575
             'payment-date'    => array(
576
-                'title' => __( 'Payment Date', 'invoicing' ),
576
+                'title' => __('Payment Date', 'invoicing'),
577 577
                 'class' => 'text-left'
578 578
             ),
579 579
 
580 580
             'invoice-status'  => array(
581
-                'title' => __( 'Status', 'invoicing' ),
581
+                'title' => __('Status', 'invoicing'),
582 582
                 'class' => 'text-center'
583 583
             ),
584 584
 
585 585
             'invoice-total'   => array(
586
-                'title' => __( 'Total', 'invoicing' ),
586
+                'title' => __('Total', 'invoicing'),
587 587
                 'class' => 'text-right'
588 588
             ),
589 589
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 
595 595
         );
596 596
 
597
-    return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type );
597
+    return apply_filters('wpinv_user_invoices_columns', $columns, $post_type);
598 598
 }
599 599
 
600 600
 /**
@@ -604,59 +604,59 @@  discard block
 block discarded – undo
604 604
 
605 605
     // Find the invoice.
606 606
     $invoice_id = getpaid_get_current_invoice_id();
607
-    $invoice = new WPInv_Invoice( $invoice_id );
607
+    $invoice = new WPInv_Invoice($invoice_id);
608 608
 
609 609
     // Abort if non was found.
610
-    if ( empty( $invoice_id ) || $invoice->is_draft() ) {
610
+    if (empty($invoice_id) || $invoice->is_draft()) {
611 611
 
612 612
         return aui()->alert(
613 613
             array(
614 614
                 'type'    => 'warning',
615
-                'content' => __( 'We could not find your invoice', 'invoicing' ),
615
+                'content' => __('We could not find your invoice', 'invoicing'),
616 616
             )
617 617
         );
618 618
 
619 619
     }
620 620
 
621 621
     // Can the user view this invoice?
622
-    if ( ! wpinv_can_view_receipt( $invoice_id ) ) {
622
+    if (!wpinv_can_view_receipt($invoice_id)) {
623 623
 
624 624
         return aui()->alert(
625 625
             array(
626 626
                 'type'    => 'warning',
627
-                'content' => __( 'You are not allowed to view this receipt', 'invoicing' ),
627
+                'content' => __('You are not allowed to view this receipt', 'invoicing'),
628 628
             )
629 629
         );
630 630
 
631 631
     }
632 632
 
633 633
     // Load the template.
634
-    return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) );
634
+    return wpinv_get_template_html('invoice-receipt.php', compact('invoice'));
635 635
 
636 636
 }
637 637
 
638 638
 /**
639 639
  * Displays the invoice history.
640 640
  */
641
-function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) {
641
+function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') {
642 642
 
643 643
     // Ensure that we have a user id.
644
-    if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
644
+    if (empty($user_id) || !is_numeric($user_id)) {
645 645
         $user_id = get_current_user_id();
646 646
     }
647 647
 
648
-    $label = getpaid_get_post_type_label( $post_type );
649
-    $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label );
648
+    $label = getpaid_get_post_type_label($post_type);
649
+    $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label);
650 650
 
651 651
     // View user id.
652
-    if ( empty( $user_id ) ) {
652
+    if (empty($user_id)) {
653 653
 
654 654
         return aui()->alert(
655 655
             array(
656 656
                 'type'    => 'warning',
657 657
                 'content' => sprintf(
658
-                    __( 'You must be logged in to view your %s.', 'invoicing' ),
659
-                    strtolower( $label )
658
+                    __('You must be logged in to view your %s.', 'invoicing'),
659
+                    strtolower($label)
660 660
                 )
661 661
             )
662 662
         );
@@ -667,23 +667,23 @@  discard block
 block discarded – undo
667 667
     $invoices = wpinv_get_invoices(
668 668
 
669 669
         array(
670
-            'page'      => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1,
670
+            'page'      => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1,
671 671
             'user'      => $user_id,
672 672
             'paginate'  => true,
673 673
             'type'      => $post_type,
674
-            'status'    => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ),
674
+            'status'    => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)),
675 675
         )
676 676
 
677 677
     );
678 678
 
679
-    if ( empty( $invoices->total ) ) {
679
+    if (empty($invoices->total)) {
680 680
 
681 681
         return aui()->alert(
682 682
             array(
683 683
                 'type'    => 'info',
684 684
                 'content' => sprintf(
685
-                    __( 'No %s found.', 'invoicing' ),
686
-                    strtolower( $label )
685
+                    __('No %s found.', 'invoicing'),
686
+                    strtolower($label)
687 687
                 )
688 688
             )
689 689
         );
@@ -691,38 +691,38 @@  discard block
 block discarded – undo
691 691
     }
692 692
 
693 693
     // Load the template.
694
-    return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) );
694
+    return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type'));
695 695
 
696 696
 }
697 697
 
698 698
 /**
699 699
  * Formats an invoice number given an invoice type.
700 700
  */
701
-function wpinv_format_invoice_number( $number, $type = '' ) {
701
+function wpinv_format_invoice_number($number, $type = '') {
702 702
 
703 703
     // Allow other plugins to overide this.
704
-    $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type );
705
-    if ( null !== $check ) {
704
+    $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type);
705
+    if (null !== $check) {
706 706
         return $check;
707 707
     }
708 708
 
709 709
     // Ensure that we have a numeric number.
710
-    if ( ! is_numeric( $number ) ) {
710
+    if (!is_numeric($number)) {
711 711
         return $number;
712 712
     }
713 713
 
714 714
     // Format the number.
715
-    $padd             = absint( (int) wpinv_get_option( 'invoice_number_padd' ) );
716
-    $prefix           = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) );
717
-    $prefix           = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) );
718
-    $postfix          = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) );
719
-    $postfix          = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) );
720
-    $formatted_number = zeroise( absint( $number ), $padd );
715
+    $padd             = absint((int) wpinv_get_option('invoice_number_padd'));
716
+    $prefix           = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-'));
717
+    $prefix           = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type));
718
+    $postfix          = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix'));
719
+    $postfix          = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type));
720
+    $formatted_number = zeroise(absint($number), $padd);
721 721
 
722 722
     // Add the prefix and post fix.
723 723
     $formatted_number = $prefix . $formatted_number . $postfix;
724 724
 
725
-    return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd );
725
+    return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd);
726 726
 }
727 727
 
728 728
 /**
@@ -731,58 +731,58 @@  discard block
 block discarded – undo
731 731
  * @param string $type.
732 732
  * @return int|null|bool
733 733
  */
734
-function wpinv_get_next_invoice_number( $type = '' ) {
734
+function wpinv_get_next_invoice_number($type = '') {
735 735
 
736 736
     // Allow plugins to overide this.
737
-    $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type );
738
-    if ( null !== $check ) {
737
+    $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type);
738
+    if (null !== $check) {
739 739
         return $check;
740 740
     }
741 741
 
742 742
     // Ensure sequential invoice numbers is active.
743
-    if ( ! wpinv_sequential_number_active() ) {
743
+    if (!wpinv_sequential_number_active()) {
744 744
         return false;
745 745
     }
746 746
 
747 747
     // Retrieve the current number and the start number.
748
-    $number = (int) get_option( 'wpinv_last_invoice_number', 0 );
749
-    $start  = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) );
748
+    $number = (int) get_option('wpinv_last_invoice_number', 0);
749
+    $start  = absint((int) wpinv_get_option('invoice_sequence_start', 1));
750 750
 
751 751
     // Ensure that we are starting at a positive integer.
752
-    $start  = max( $start, 1 );
752
+    $start  = max($start, 1);
753 753
 
754 754
     // If this is the first invoice, use the start number.
755
-    $number = max( $start, $number );
755
+    $number = max($start, $number);
756 756
 
757 757
     // Format the invoice number.
758
-    $formatted_number = wpinv_format_invoice_number( $number, $type );
758
+    $formatted_number = wpinv_format_invoice_number($number, $type);
759 759
 
760 760
     // Ensure that this number is unique.
761
-    $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' );
761
+    $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number');
762 762
 
763 763
     // We found a match. Nice.
764
-    if ( empty( $invoice_id ) ) {
765
-        update_option( 'wpinv_last_invoice_number', $number );
766
-        return apply_filters( 'wpinv_get_next_invoice_number', $number );
764
+    if (empty($invoice_id)) {
765
+        update_option('wpinv_last_invoice_number', $number);
766
+        return apply_filters('wpinv_get_next_invoice_number', $number);
767 767
     }
768 768
 
769
-    update_option( 'wpinv_last_invoice_number', $number + 1 );
770
-    return wpinv_get_next_invoice_number( $type );
769
+    update_option('wpinv_last_invoice_number', $number + 1);
770
+    return wpinv_get_next_invoice_number($type);
771 771
 
772 772
 }
773 773
 
774 774
 /**
775 775
  * The prefix used for invoice paths.
776 776
  */
777
-function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) {
778
-    return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type );
777
+function wpinv_post_name_prefix($post_type = 'wpi_invoice') {
778
+    return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type);
779 779
 }
780 780
 
781
-function wpinv_generate_post_name( $post_ID ) {
782
-    $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) );
783
-    $post_name = sanitize_title( $prefix . $post_ID );
781
+function wpinv_generate_post_name($post_ID) {
782
+    $prefix = wpinv_post_name_prefix(get_post_type($post_ID));
783
+    $post_name = sanitize_title($prefix . $post_ID);
784 784
 
785
-    return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix );
785
+    return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix);
786 786
 }
787 787
 
788 788
 /**
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
  * 
791 791
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
792 792
  */
793
-function wpinv_is_invoice_viewed( $invoice ) {
794
-    $invoice = new WPInv_Invoice( $invoice );
793
+function wpinv_is_invoice_viewed($invoice) {
794
+    $invoice = new WPInv_Invoice($invoice);
795 795
     return (bool) $invoice->get_is_viewed();
796 796
 }
797 797
 
@@ -800,17 +800,17 @@  discard block
 block discarded – undo
800 800
  * 
801 801
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
802 802
  */
803
-function getpaid_maybe_mark_invoice_as_viewed( $invoice ) {
804
-    $invoice = new WPInv_Invoice( $invoice );
803
+function getpaid_maybe_mark_invoice_as_viewed($invoice) {
804
+    $invoice = new WPInv_Invoice($invoice);
805 805
 
806
-    if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) {
807
-        $invoice->set_is_viewed( true );
806
+    if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) {
807
+        $invoice->set_is_viewed(true);
808 808
         $invoice->save();
809 809
     }
810 810
 
811 811
 }
812
-add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' );
813
-add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' );
812
+add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed');
813
+add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed');
814 814
 
815 815
 /**
816 816
  * Processes an invoice refund.
@@ -819,27 +819,27 @@  discard block
 block discarded – undo
819 819
  * @param array $status_transition
820 820
  * @todo: descrease customer/store earnings
821 821
  */
822
-function getpaid_maybe_process_refund( $invoice, $status_transition ) {
822
+function getpaid_maybe_process_refund($invoice, $status_transition) {
823 823
 
824
-    if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) {
824
+    if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) {
825 825
         return;
826 826
     }
827 827
 
828 828
     $discount_code = $invoice->get_discount_code();
829
-    if ( ! empty( $discount_code ) ) {
830
-        $discount = wpinv_get_discount_obj( $discount_code );
829
+    if (!empty($discount_code)) {
830
+        $discount = wpinv_get_discount_obj($discount_code);
831 831
 
832
-        if ( $discount->exists() ) {
832
+        if ($discount->exists()) {
833 833
             $discount->increase_usage( -1 );
834 834
         }
835 835
 
836 836
     }
837 837
 
838
-    do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() );
839
-    do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() );
840
-    do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() );
838
+    do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id());
839
+    do_action('wpinv_refund_invoice', $invoice, $invoice->get_id());
840
+    do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id());
841 841
 }
842
-add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 );
842
+add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2);
843 843
 
844 844
 
845 845
 /**
@@ -847,48 +847,48 @@  discard block
 block discarded – undo
847 847
  *
848 848
  * @param int $invoice_id
849 849
  */
850
-function getpaid_process_invoice_payment( $invoice_id ) {
850
+function getpaid_process_invoice_payment($invoice_id) {
851 851
 
852 852
     // Fetch the invoice.
853
-    $invoice = new WPInv_Invoice( $invoice_id );
853
+    $invoice = new WPInv_Invoice($invoice_id);
854 854
 
855 855
     // We only want to do this once.
856
-    if ( 1 ==  get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) {
856
+    if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) {
857 857
         return;
858 858
     }
859 859
 
860
-    update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 );
860
+    update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1);
861 861
 
862 862
     // Fires when processing a payment.
863
-    do_action( 'getpaid_process_payment', $invoice );
863
+    do_action('getpaid_process_payment', $invoice);
864 864
 
865 865
     // Fire an action for each invoice item.
866
-    foreach( $invoice->get_items() as $item ) {
867
-        do_action( 'getpaid_process_item_payment', $item, $invoice );
866
+    foreach ($invoice->get_items() as $item) {
867
+        do_action('getpaid_process_item_payment', $item, $invoice);
868 868
     }
869 869
 
870 870
     // Increase discount usage.
871 871
     $discount_code = $invoice->get_discount_code();
872
-    if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) {
873
-        $discount = wpinv_get_discount_obj( $discount_code );
872
+    if (!empty($discount_code) && !$invoice->is_renewal()) {
873
+        $discount = wpinv_get_discount_obj($discount_code);
874 874
 
875
-        if ( $discount->exists() ) {
875
+        if ($discount->exists()) {
876 876
             $discount->increase_usage();
877 877
         }
878 878
 
879 879
     }
880 880
 
881 881
     // Record reverse vat.
882
-    if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) {
882
+    if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) {
883 883
 
884
-        if ( wpinv_same_country_exempt_vat() && wpinv_is_base_country( $invoice->get_country() ) ) {
885
-            $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true );
884
+        if (wpinv_same_country_exempt_vat() && wpinv_is_base_country($invoice->get_country())) {
885
+            $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true);
886 886
         }
887 887
 
888 888
     }
889 889
 
890 890
 }
891
-add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' );
891
+add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment');
892 892
 
893 893
 /**
894 894
  * Returns an array of invoice item columns
@@ -896,13 +896,13 @@  discard block
 block discarded – undo
896 896
  * @param int|WPInv_Invoice $invoice
897 897
  * @return array
898 898
  */
899
-function getpaid_invoice_item_columns( $invoice ) {
899
+function getpaid_invoice_item_columns($invoice) {
900 900
 
901 901
     // Prepare the invoice.
902
-    $invoice = new WPInv_Invoice( $invoice );
902
+    $invoice = new WPInv_Invoice($invoice);
903 903
 
904 904
     // Abort if there is no invoice.
905
-    if ( 0 == $invoice->get_id() ) {
905
+    if (0 == $invoice->get_id()) {
906 906
         return array();
907 907
     }
908 908
 
@@ -910,47 +910,47 @@  discard block
 block discarded – undo
910 910
     $columns = apply_filters(
911 911
         'getpaid_invoice_item_columns',
912 912
         array(
913
-            'name'     => __( 'Item', 'invoicing' ),
914
-            'price'    => __( 'Price', 'invoicing' ),
915
-            'quantity' => __( 'Quantity', 'invoicing' ),
916
-            'subtotal' => __( 'Subtotal', 'invoicing' ),
913
+            'name'     => __('Item', 'invoicing'),
914
+            'price'    => __('Price', 'invoicing'),
915
+            'quantity' => __('Quantity', 'invoicing'),
916
+            'subtotal' => __('Subtotal', 'invoicing'),
917 917
         ),
918 918
         $invoice
919 919
     );
920 920
 
921 921
     // Quantities.
922
-    if ( isset( $columns[ 'quantity' ] ) ) {
922
+    if (isset($columns['quantity'])) {
923 923
 
924
-        if ( 'hours' == $invoice->get_template() ) {
925
-            $columns[ 'quantity' ] = __( 'Hours', 'invoicing' );
924
+        if ('hours' == $invoice->get_template()) {
925
+            $columns['quantity'] = __('Hours', 'invoicing');
926 926
         }
927 927
 
928
-        if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) {
929
-            unset( $columns[ 'quantity' ] );
928
+        if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) {
929
+            unset($columns['quantity']);
930 930
         }
931 931
 
932 932
     }
933 933
 
934 934
 
935 935
     // Price.
936
-    if ( isset( $columns[ 'price' ] ) ) {
936
+    if (isset($columns['price'])) {
937 937
 
938
-        if ( 'amount' == $invoice->get_template() ) {
939
-            $columns[ 'price' ] = __( 'Amount', 'invoicing' );
938
+        if ('amount' == $invoice->get_template()) {
939
+            $columns['price'] = __('Amount', 'invoicing');
940 940
         }
941 941
 
942
-        if ( 'hours' == $invoice->get_template() ) {
943
-            $columns[ 'price' ] = __( 'Rate', 'invoicing' );
942
+        if ('hours' == $invoice->get_template()) {
943
+            $columns['price'] = __('Rate', 'invoicing');
944 944
         }
945 945
 
946 946
     }
947 947
 
948 948
 
949 949
     // Sub total.
950
-    if ( isset( $columns[ 'subtotal' ] ) ) {
950
+    if (isset($columns['subtotal'])) {
951 951
 
952
-        if ( 'amount' == $invoice->get_template() ) {
953
-            unset( $columns[ 'subtotal' ] );
952
+        if ('amount' == $invoice->get_template()) {
953
+            unset($columns['subtotal']);
954 954
         }
955 955
 
956 956
     }
@@ -964,30 +964,30 @@  discard block
 block discarded – undo
964 964
  * @param int|WPInv_Invoice $invoice
965 965
  * @return array
966 966
  */
967
-function getpaid_invoice_totals_rows( $invoice ) {
967
+function getpaid_invoice_totals_rows($invoice) {
968 968
 
969 969
     // Prepare the invoice.
970
-    $invoice = new WPInv_Invoice( $invoice );
970
+    $invoice = new WPInv_Invoice($invoice);
971 971
 
972 972
     // Abort if there is no invoice.
973
-    if ( 0 == $invoice->get_id() ) {
973
+    if (0 == $invoice->get_id()) {
974 974
         return array();
975 975
     }
976 976
 
977 977
     $totals = apply_filters(
978 978
         'getpaid_invoice_totals_rows',
979 979
         array(
980
-            'subtotal' => __( 'Subtotal', 'invoicing' ),
981
-            'tax'      => __( 'Tax', 'invoicing' ),
982
-            'fee'      => __( 'Fee', 'invoicing' ),
983
-            'discount' => __( 'Discount', 'invoicing' ),
984
-            'total'    => __( 'Total', 'invoicing' ),
980
+            'subtotal' => __('Subtotal', 'invoicing'),
981
+            'tax'      => __('Tax', 'invoicing'),
982
+            'fee'      => __('Fee', 'invoicing'),
983
+            'discount' => __('Discount', 'invoicing'),
984
+            'total'    => __('Total', 'invoicing'),
985 985
         ),
986 986
         $invoice
987 987
     );
988 988
 
989
-    if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) {
990
-        unset( $totals['tax'] );
989
+    if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) {
990
+        unset($totals['tax']);
991 991
     }
992 992
 
993 993
     return $totals;
@@ -998,47 +998,47 @@  discard block
 block discarded – undo
998 998
  * 
999 999
  * @param WPInv_Invoice $invoice
1000 1000
  */
1001
-function getpaid_new_invoice( $invoice ) {
1001
+function getpaid_new_invoice($invoice) {
1002 1002
 
1003
-    if ( ! $invoice->get_status() ) {
1003
+    if (!$invoice->get_status()) {
1004 1004
         return;
1005 1005
     }
1006 1006
 
1007 1007
     // Add an invoice created note.
1008 1008
     $invoice->add_note(
1009 1009
         sprintf(
1010
-            __( '%s created with the status "%s".', 'invoicing' ),
1011
-            ucfirst( $invoice->get_type() ),
1012
-            wpinv_status_nicename( $invoice->get_status(), $invoice  )
1010
+            __('%s created with the status "%s".', 'invoicing'),
1011
+            ucfirst($invoice->get_type()),
1012
+            wpinv_status_nicename($invoice->get_status(), $invoice)
1013 1013
         )
1014 1014
     );
1015 1015
 
1016 1016
 }
1017
-add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' );
1017
+add_action('getpaid_new_invoice', 'getpaid_new_invoice');
1018 1018
 
1019 1019
 /**
1020 1020
  * This function updates invoice caches.
1021 1021
  * 
1022 1022
  * @param WPInv_Invoice $invoice
1023 1023
  */
1024
-function getpaid_update_invoice_caches( $invoice ) {
1024
+function getpaid_update_invoice_caches($invoice) {
1025 1025
 
1026 1026
     // Cache invoice number.
1027
-    wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" );
1027
+    wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids");
1028 1028
 
1029 1029
     // Cache invoice key.
1030
-    wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" );
1030
+    wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids");
1031 1031
 
1032 1032
     // (Maybe) cache transaction id.
1033 1033
     $transaction_id = $invoice->get_transaction_id();
1034 1034
 
1035
-    if ( ! empty( $transaction_id ) ) {
1036
-        wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" );
1035
+    if (!empty($transaction_id)) {
1036
+        wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids");
1037 1037
     }
1038 1038
 
1039 1039
 }
1040
-add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 );
1041
-add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 );
1040
+add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5);
1041
+add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5);
1042 1042
 
1043 1043
 /**
1044 1044
  * Duplicates an invoice.
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
  * @param  WPInv_Invoice $old_invoice The invoice to duplicate
1049 1049
  * @return WPInv_Invoice The new invoice.
1050 1050
  */
1051
-function getpaid_duplicate_invoice( $old_invoice ) {
1051
+function getpaid_duplicate_invoice($old_invoice) {
1052 1052
 
1053 1053
     // Create the new invoice.
1054 1054
     $invoice = new WPInv_Invoice();
@@ -1109,123 +1109,123 @@  discard block
 block discarded – undo
1109 1109
  * @param WPInv_Invoice $invoice
1110 1110
  * @return array
1111 1111
  */
1112
-function getpaid_get_invoice_meta( $invoice ) {
1112
+function getpaid_get_invoice_meta($invoice) {
1113 1113
 
1114 1114
     // Load the invoice meta.
1115 1115
     $meta = array(
1116 1116
 
1117 1117
         'number' => array(
1118 1118
             'label' => sprintf(
1119
-                __( '%s Number', 'invoicing' ),
1120
-                ucfirst( $invoice->get_type() )
1119
+                __('%s Number', 'invoicing'),
1120
+                ucfirst($invoice->get_type())
1121 1121
             ),
1122
-            'value' => sanitize_text_field( $invoice->get_number() ),
1122
+            'value' => sanitize_text_field($invoice->get_number()),
1123 1123
         ),
1124 1124
 
1125 1125
         'status' => array(
1126 1126
             'label' => sprintf(
1127
-                __( '%s Status', 'invoicing' ),
1128
-                ucfirst( $invoice->get_type() )
1127
+                __('%s Status', 'invoicing'),
1128
+                ucfirst($invoice->get_type())
1129 1129
             ),
1130 1130
             'value' => $invoice->get_status_label_html(),
1131 1131
         ),
1132 1132
 
1133 1133
         'date' => array(
1134 1134
             'label' => sprintf(
1135
-                __( '%s Date', 'invoicing' ),
1136
-                ucfirst( $invoice->get_type() )
1135
+                __('%s Date', 'invoicing'),
1136
+                ucfirst($invoice->get_type())
1137 1137
             ),
1138
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
1138
+            'value' => getpaid_format_date($invoice->get_created_date()),
1139 1139
         ),
1140 1140
 
1141 1141
         'date_paid' => array(
1142
-            'label' => __( 'Paid On', 'invoicing' ),
1143
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
1142
+            'label' => __('Paid On', 'invoicing'),
1143
+            'value' => getpaid_format_date($invoice->get_completed_date()),
1144 1144
         ),
1145 1145
 
1146 1146
         'gateway'   => array(
1147
-            'label' => __( 'Payment Method', 'invoicing' ),
1148
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
1147
+            'label' => __('Payment Method', 'invoicing'),
1148
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
1149 1149
         ),
1150 1150
 
1151 1151
         'transaction_id' => array(
1152
-            'label' => __( 'Transaction ID', 'invoicing' ),
1153
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
1152
+            'label' => __('Transaction ID', 'invoicing'),
1153
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
1154 1154
         ),
1155 1155
 
1156 1156
         'due_date'  => array(
1157
-            'label' => __( 'Due Date', 'invoicing' ),
1158
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
1157
+            'label' => __('Due Date', 'invoicing'),
1158
+            'value' => getpaid_format_date($invoice->get_due_date()),
1159 1159
         ),
1160 1160
 
1161 1161
         'vat_number' => array(
1162
-            'label' => __( 'VAT Number', 'invoicing' ),
1163
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
1162
+            'label' => __('VAT Number', 'invoicing'),
1163
+            'value' => sanitize_text_field($invoice->get_vat_number()),
1164 1164
         ),
1165 1165
 
1166 1166
     );
1167 1167
 
1168 1168
     // If it is not paid, remove the date of payment.
1169
-    if ( ! $invoice->is_paid() ) {
1170
-        unset( $meta[ 'date_paid' ] );
1171
-        unset( $meta[ 'transaction_id' ] );
1169
+    if (!$invoice->is_paid()) {
1170
+        unset($meta['date_paid']);
1171
+        unset($meta['transaction_id']);
1172 1172
     }
1173 1173
 
1174
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
1175
-        unset( $meta[ 'gateway' ] );
1174
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
1175
+        unset($meta['gateway']);
1176 1176
     }
1177 1177
 
1178 1178
     // Only display the due date if due dates are enabled.
1179
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
1180
-        unset( $meta[ 'due_date' ] );
1179
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
1180
+        unset($meta['due_date']);
1181 1181
     }
1182 1182
 
1183 1183
     // Only display the vat number if taxes are enabled.
1184
-    if ( ! wpinv_use_taxes() ) {
1185
-        unset( $meta[ 'vat_number' ] );
1184
+    if (!wpinv_use_taxes()) {
1185
+        unset($meta['vat_number']);
1186 1186
     }
1187 1187
 
1188
-    if ( $invoice->is_recurring() ) {
1188
+    if ($invoice->is_recurring()) {
1189 1189
 
1190 1190
         // Link to the parent invoice.
1191
-        if ( $invoice->is_renewal() ) {
1191
+        if ($invoice->is_renewal()) {
1192 1192
 
1193
-            $meta[ 'parent' ] = array(
1193
+            $meta['parent'] = array(
1194 1194
 
1195 1195
                 'label' => sprintf(
1196
-                    __( 'Parent %s', 'invoicing' ),
1197
-                    ucfirst( $invoice->get_type() )
1196
+                    __('Parent %s', 'invoicing'),
1197
+                    ucfirst($invoice->get_type())
1198 1198
                 ),
1199 1199
 
1200
-                'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
1200
+                'value' => wpinv_invoice_link($invoice->get_parent_id()),
1201 1201
 
1202 1202
             );
1203 1203
 
1204 1204
         }
1205 1205
 
1206
-        $subscription = wpinv_get_subscription( $invoice );
1206
+        $subscription = wpinv_get_subscription($invoice);
1207 1207
 
1208
-        if ( ! empty ( $subscription ) ) {
1208
+        if (!empty ($subscription)) {
1209 1209
 
1210 1210
             // Display the renewal date.
1211
-            if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) {
1211
+            if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) {
1212 1212
 
1213
-                $meta[ 'renewal_date' ] = array(
1213
+                $meta['renewal_date'] = array(
1214 1214
 
1215
-                    'label' => __( 'Renews On', 'invoicing' ),
1216
-                    'value' => getpaid_format_date( $subscription->get_expiration() ),
1215
+                    'label' => __('Renews On', 'invoicing'),
1216
+                    'value' => getpaid_format_date($subscription->get_expiration()),
1217 1217
         
1218 1218
                 );
1219 1219
 
1220 1220
             }
1221 1221
 
1222
-            if ( $invoice->is_parent() ) {
1222
+            if ($invoice->is_parent()) {
1223 1223
 
1224 1224
                 // Display the recurring amount.
1225
-                $meta[ 'recurring_total' ] = array(
1225
+                $meta['recurring_total'] = array(
1226 1226
 
1227
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
1228
-                    'value' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ),
1227
+                    'label' => __('Recurring Amount', 'invoicing'),
1228
+                    'value' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()),
1229 1229
         
1230 1230
                 );
1231 1231
 
@@ -1235,15 +1235,15 @@  discard block
 block discarded – undo
1235 1235
     }
1236 1236
 
1237 1237
     // Add the invoice total to the meta.
1238
-    $meta[ 'invoice_total' ] = array(
1238
+    $meta['invoice_total'] = array(
1239 1239
 
1240
-        'label' => __( 'Total Amount', 'invoicing' ),
1241
-        'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ),
1240
+        'label' => __('Total Amount', 'invoicing'),
1241
+        'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()),
1242 1242
 
1243 1243
     );
1244 1244
 
1245 1245
     // Provide a way for third party plugins to filter the meta.
1246
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
1246
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
1247 1247
 
1248 1248
     return $meta;
1249 1249
 
Please login to merge, or discard this patch.