Passed
Push — master ( 20e351...0d8bd8 )
by Brian
04:12
created
includes/data/admin-settings.php 1 patch
Spacing   +159 added lines, -159 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,21 +210,21 @@  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_invoice_notice_label' => array(
218 218
                     'id' => 'vat_invoice_notice_label',
219
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
220
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
219
+                    'name' => __('Invoice Notice Label', 'invoicing'),
220
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
221 221
                     'type' => 'text',
222 222
                     'size' => 'regular',
223 223
                 ),
224 224
                 'vat_invoice_notice' => array(
225 225
                     'id' => 'vat_invoice_notice',
226
-                    'name' => __( 'Invoice notice', 'invoicing' ),
227
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
226
+                    'name' => __('Invoice notice', 'invoicing'),
227
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
228 228
                     'type' => 'text',
229 229
                     'size' => 'regular',
230 230
                 ),
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
             'main' => array(
237 237
                 'gateway_settings' => array(
238 238
                     'id'   => 'api_header',
239
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
239
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
240 240
                     'desc' => '',
241 241
                     'type' => 'header',
242 242
                 ),
243 243
                 'gateways' => array(
244 244
                     'id'      => 'gateways',
245
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
246
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
245
+                    'name'    => __('Payment Gateways', 'invoicing'),
246
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
247 247
                     'type'    => 'gateways',
248 248
                     'std'     => array('manual'=>1),
249 249
                     'options' => wpinv_get_payment_gateways(),
250 250
                 ),
251 251
                 'default_gateway' => array(
252 252
                     'id'      => 'default_gateway',
253
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
254
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
253
+                    'name'    => __('Default Gateway', 'invoicing'),
254
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
255 255
                     'type'    => 'gateway_select',
256 256
                     'std'     => 'manual',
257 257
                     'class'   => 'wpi_select2',
@@ -266,32 +266,32 @@  discard block
 block discarded – undo
266 266
             'main' => array(
267 267
                 'tax_settings' => array(
268 268
                     'id'   => 'tax_settings',
269
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
269
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
270 270
                     'type' => 'header',
271 271
                 ),
272 272
 
273 273
                 'enable_taxes' => array(
274 274
                     'id'       => 'enable_taxes',
275
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
276
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
275
+                    'name'     => __('Enable Taxes', 'invoicing'),
276
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
277 277
                     'type'     => 'checkbox',
278 278
                     'std'      => 0,
279 279
                 ),
280 280
 
281 281
                 'tax_subtotal_rounding' => array(
282 282
                     'id'                => 'tax_subtotal_rounding',
283
-                    'name'              => __( 'Rounding', 'invoicing' ),
284
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
283
+                    'name'              => __('Rounding', 'invoicing'),
284
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
285 285
                     'type'              => 'checkbox',
286 286
                     'std'               => 1,
287 287
                 ),
288 288
 
289 289
                 'prices_include_tax' => array(
290 290
                     'id'      => 'prices_include_tax',
291
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
291
+                    'name'    => __('Prices entered with tax', 'invoicing'),
292 292
                     'options' => array(
293
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
294
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
293
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
294
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
295 295
                     ),
296 296
                     'type'    => 'select',
297 297
                     'std'     => 'no',
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 
300 300
                 'tax_base'              => array(
301 301
                     'id'                => 'tax_base',
302
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
302
+                    'name'              => __('Calculate tax based on', 'invoicing'),
303 303
                     'options'           => array(
304
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
305
-                        'base'          => __( 'Shop base address', 'invoicing' ),
304
+                        'billing'       => __('Customer billing address', 'invoicing'),
305
+                        'base'          => __('Shop base address', 'invoicing'),
306 306
                     ),
307 307
                     'type'              => 'select',
308 308
                     'std'               => 'billing',
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 
311 311
                 'tax_display_totals'    => array(
312 312
                     'id'                => 'tax_display_totals',
313
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
313
+                    'name'              => __('Display tax totals', 'invoicing'),
314 314
                     'options'           => array(
315
-                        'single'        => __( 'As a single total', 'invoicing' ),
316
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
315
+                        'single'        => __('As a single total', 'invoicing'),
316
+                        'individual'    => __('As individual tax rates', 'invoicing'),
317 317
                     ),
318 318
                     'type'              => 'select',
319 319
                     'std'               => 'individual',
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 
322 322
                 'tax_rate' => array(
323 323
                     'id'   => 'tax_rate',
324
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
325
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
324
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
325
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
326 326
                     'type' => 'number',
327 327
                     'size' => 'small',
328 328
                     'min'  => '0',
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
             'rates' => array(
335 335
                 'tax_rates' => array(
336 336
                     'id'   => 'tax_rates',
337
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
338
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
337
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
338
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
339 339
                     'type' => 'tax_rates',
340 340
                 ),
341 341
             ),
@@ -344,45 +344,45 @@  discard block
 block discarded – undo
344 344
 
345 345
                 'vat_company_name' => array(
346 346
                     'id' => 'vat_company_name',
347
-                    'name' => __( 'Company Name', 'invoicing' ),
348
-                    '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>' ),
347
+                    'name' => __('Company Name', 'invoicing'),
348
+                    '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>'),
349 349
                     'type' => 'text',
350 350
                     'size' => 'regular',
351 351
                 ),
352 352
 
353 353
                 'vat_number' => array(
354 354
                     'id'   => 'vat_number',
355
-                    'name' => __( 'VAT Number', 'invoicing' ),
356
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
355
+                    'name' => __('VAT Number', 'invoicing'),
356
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
357 357
                     'type' => 'text',
358 358
                     'size' => 'regular',
359 359
                 ),
360 360
 
361 361
                 'vat_prevent_b2c_purchase' => array(
362 362
                     'id' => 'vat_prevent_b2c_purchase',
363
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
364
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
363
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
364
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
365 365
                     'type' => 'checkbox'
366 366
                 ),
367 367
 
368 368
                 'validate_vat_number' => array(
369 369
                     'id'   => 'validate_vat_number',
370
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
371
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
370
+                    'name' => __('Validate VAT Number', 'invoicing'),
371
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
372 372
                     'type' => 'checkbox'
373 373
                 ),
374 374
 
375 375
                 'vat_same_country_rule' => array(
376 376
                     'id'          => 'vat_same_country_rule',
377
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
378
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
377
+                    'name'        => __('Same Country Rule', 'invoicing'),
378
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
379 379
                     'type'        => 'select',
380 380
                     'options'     => array(
381
-                        'no'        => __( 'Do not charge Tax', 'invoicing' ),
382
-                        'always'    => __( 'Charge Tax', 'invoicing' ),
383
-                        'vat_too'   => __( 'Charge tax even if vat number is validated', 'invoicing' )
381
+                        'no'        => __('Do not charge Tax', 'invoicing'),
382
+                        'always'    => __('Charge Tax', 'invoicing'),
383
+                        'vat_too'   => __('Charge tax even if vat number is validated', 'invoicing')
384 384
                     ),
385
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
385
+                    'placeholder' => __('Select an option', 'invoicing'),
386 386
                     'std'         => 'always',
387 387
                 ),
388 388
 
@@ -396,68 +396,68 @@  discard block
 block discarded – undo
396 396
             'main' => array(
397 397
                 'email_settings_header' => array(
398 398
                     'id'   => 'email_settings_header',
399
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
399
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
400 400
                     'type' => 'header',
401 401
                 ),
402 402
                 'email_from_name' => array(
403 403
                     'id'   => 'email_from_name',
404
-                    'name' => __( 'From Name', 'invoicing' ),
405
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
406
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
404
+                    'name' => __('From Name', 'invoicing'),
405
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
406
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
407 407
                     'type' => 'text',
408 408
                 ),
409 409
                 'email_from' => array(
410 410
                     'id'   => 'email_from',
411
-                    'name' => __( 'From Email', 'invoicing' ),
412
-                    '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),
413
-                    'std' => get_option( 'admin_email' ),
411
+                    'name' => __('From Email', 'invoicing'),
412
+                    '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),
413
+                    'std' => get_option('admin_email'),
414 414
                     'type' => 'text',
415 415
                 ),
416 416
                 'admin_email' => array(
417 417
                     'id'   => 'admin_email',
418
-                    'name' => __( 'Admin Email', 'invoicing' ),
419
-                    'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
420
-                    'std' => get_option( 'admin_email' ),
418
+                    'name' => __('Admin Email', 'invoicing'),
419
+                    'desc' => __('Where should we send admin notifications?', 'invoicing'),
420
+                    'std' => get_option('admin_email'),
421 421
                     'type' => 'text',
422 422
                 ),
423 423
                 'overdue_settings_header' => array(
424 424
                     'id'   => 'overdue_settings_header',
425
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
425
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
426 426
                     'type' => 'header',
427 427
                 ),
428 428
                 'overdue_active' => array(
429 429
                     'id'   => 'overdue_active',
430
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
431
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
430
+                    'name' => __('Enable Due Date', 'invoicing'),
431
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
432 432
                     'type' => 'checkbox',
433 433
                     'std'  => false,
434 434
                 ),
435 435
                 'overdue_days' => array(
436 436
                     'id'          => 'overdue_days',
437
-                    'name'        => __( 'Default Due Date', 'invoicing' ),
438
-                    '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' ),
437
+                    'name'        => __('Default Due Date', 'invoicing'),
438
+                    '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'),
439 439
                     'type'        => 'select',
440 440
                     'options'     => $due_payment_options,
441 441
                     'std'         => 0,
442
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
442
+                    'placeholder' => __('Select a page', 'invoicing'),
443 443
                 ),
444 444
                 'email_template_header' => array(
445 445
                     'id'   => 'email_template_header',
446
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
446
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
447 447
                     'type' => 'header',
448 448
                 ),
449 449
                 'email_header_image' => array(
450 450
                     'id'   => 'email_header_image',
451
-                    'name' => __( 'Header Image', 'invoicing' ),
452
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
451
+                    'name' => __('Header Image', 'invoicing'),
452
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
453 453
                     'std' => '',
454 454
                     'type' => 'text',
455 455
                 ),
456 456
                 'email_footer_text' => array(
457 457
                     'id'   => 'email_footer_text',
458
-                    'name' => __( 'Footer Text', 'invoicing' ),
459
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
460
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ),
458
+                    'name' => __('Footer Text', 'invoicing'),
459
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
460
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'),
461 461
                     'type' => 'textarea',
462 462
                     'class' => 'regular-text',
463 463
                     'rows' => 2,
@@ -465,29 +465,29 @@  discard block
 block discarded – undo
465 465
                 ),
466 466
                 'email_base_color' => array(
467 467
                     'id'   => 'email_base_color',
468
-                    'name' => __( 'Base Color', 'invoicing' ),
469
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
468
+                    'name' => __('Base Color', 'invoicing'),
469
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
470 470
                     'std' => '#557da2',
471 471
                     'type' => 'color',
472 472
                 ),
473 473
                 'email_background_color' => array(
474 474
                     'id'   => 'email_background_color',
475
-                    'name' => __( 'Background Color', 'invoicing' ),
476
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
475
+                    'name' => __('Background Color', 'invoicing'),
476
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
477 477
                     'std' => '#f5f5f5',
478 478
                     'type' => 'color',
479 479
                 ),
480 480
                 'email_body_background_color' => array(
481 481
                     'id'   => 'email_body_background_color',
482
-                    'name' => __( 'Body Background Color', 'invoicing' ),
483
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
482
+                    'name' => __('Body Background Color', 'invoicing'),
483
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
484 484
                     'std' => '#fdfdfd',
485 485
                     'type' => 'color',
486 486
                 ),
487 487
                 'email_text_color' => array(
488 488
                     'id'   => 'email_text_color',
489
-                    'name' => __( 'Body Text Color', 'invoicing' ),
490
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
489
+                    'name' => __('Body Text Color', 'invoicing'),
490
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
491 491
                     'std' => '#505050',
492 492
                     'type' => 'color',
493 493
                 ),
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
     ),
503 503
 
504 504
     // Integrations.
505
-    'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ),
505
+    'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'),
506 506
 
507 507
     /** Privacy Settings */
508 508
     'privacy' => apply_filters('wpinv_settings_privacy',
@@ -510,17 +510,17 @@  discard block
 block discarded – undo
510 510
             'main' => array(
511 511
                 'invoicing_privacy_policy_settings' => array(
512 512
                     'id'   => 'invoicing_privacy_policy_settings',
513
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
513
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
514 514
                     'type' => 'header',
515 515
                 ),
516 516
                 'privacy_page' => array(
517 517
                     'id'          => 'privacy_page',
518
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
519
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
518
+                    'name'        => __('Privacy Page', 'invoicing'),
519
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
520 520
                     'type'        => 'select',
521
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
521
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
522 522
                     'class'       => 'wpi_select2',
523
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
523
+                    'placeholder' => __('Select a page', 'invoicing'),
524 524
                 ),
525 525
             ),
526 526
         )
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
             'main' => array(
532 532
                 'invoice_number_format_settings' => array(
533 533
                     'id'   => 'invoice_number_format_settings',
534
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
534
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
535 535
                     'type' => 'header',
536 536
                 ),
537 537
                 'sequential_invoice_number' => array(
538 538
                     'id'   => 'sequential_invoice_number',
539
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
540
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
539
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
540
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
541 541
                     'type' => 'checkbox',
542 542
                 ),
543 543
                 'invoice_sequence_start' => array(
544 544
                     'id'   => 'invoice_sequence_start',
545
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
546
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
545
+                    'name' => __('Sequential Starting Number', 'invoicing'),
546
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
547 547
                     'type' => 'number',
548 548
                     'size' => 'small',
549 549
                     'std'  => '1',
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
                 ),
552 552
                 'invoice_number_padd' => array(
553 553
                     'id'      => 'invoice_number_padd',
554
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
555
-                    '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' ),
554
+                    'name'    => __('Minimum Digits', 'invoicing'),
555
+                    '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'),
556 556
                     'type'    => 'select',
557 557
                     'options' => $invoice_number_padd_options,
558 558
                     'std'     => 5,
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
                 ),
561 561
                 'invoice_number_prefix' => array(
562 562
                     'id' => 'invoice_number_prefix',
563
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
564
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
563
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
564
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
565 565
                     'type' => 'text',
566 566
                     'size' => 'regular',
567 567
                     'std' => 'INV-',
@@ -569,41 +569,41 @@  discard block
 block discarded – undo
569 569
                 ),
570 570
                 'invoice_number_postfix' => array(
571 571
                     'id' => 'invoice_number_postfix',
572
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
573
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
572
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
573
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
574 574
                     'type' => 'text',
575 575
                     'size' => 'regular',
576 576
                     'std' => ''
577 577
                 ),
578 578
                 'checkout_settings' => array(
579 579
                     'id'   => 'checkout_settings',
580
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
580
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
581 581
                     'type' => 'header',
582 582
                 ),
583 583
                 'login_to_checkout' => array(
584 584
                     'id'   => 'login_to_checkout',
585
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
586
-                    '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' ),
585
+                    'name' => __('Require Login To Checkout', 'invoicing'),
586
+                    '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'),
587 587
                     'type' => 'checkbox',
588 588
                 ),
589 589
 
590 590
                 'maxmind_license_key' => array(
591 591
                     'id'   => 'maxmind_license_key',
592
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
592
+                    'name' => __('MaxMind License Key', 'invoicing'),
593 593
                     'type' => 'text',
594 594
                     'size' => 'regular',
595
-                    '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>',
595
+                    '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>',
596 596
                 ),
597 597
 
598 598
                 'uninstall_settings' => array(
599 599
                     'id'   => 'uninstall_settings',
600
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
600
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
601 601
                     'type' => 'header',
602 602
                 ),
603 603
                 'remove_data_on_unistall' => array(
604 604
                     'id'   => 'remove_data_on_unistall',
605
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
606
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
605
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
606
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
607 607
                     'type' => 'checkbox',
608 608
                     'std'  => ''
609 609
                 ),
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
             'custom-css' => array(
613 613
                 'css_settings' => array(
614 614
                     'id'   => 'css_settings',
615
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
615
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
616 616
                     'type' => 'header',
617 617
                 ),
618 618
                 'template_custom_css' => array(
619 619
                     'id' => 'template_custom_css',
620
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
621
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
620
+                    'name' => __('Invoice Template CSS', 'invoicing'),
621
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
622 622
                     'type' => 'textarea',
623 623
                     'class'=> 'regular-text',
624 624
                     'rows' => 10,
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
             'main' => array(
633 633
                 'tool_settings' => array(
634 634
                     'id'   => 'tool_settings',
635
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
636
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
635
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
636
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
637 637
                     'type' => 'tools',
638 638
                 ),
639 639
             ),
Please login to merge, or discard this patch.
includes/data/vat-number-regexes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @package Invoicing/data
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 return array(
12 12
 
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-geolocation.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * GetPaid_Geolocation Class.
@@ -64,31 +64,31 @@  discard block
 block discarded – undo
64 64
 
65 65
 		$transient_name = 'external_ip_address_0.0.0.0';
66 66
 
67
-		if ( '' !== self::get_ip_address() ) {
68
-			$transient_name      = 'external_ip_address_' . self::get_ip_address();
67
+		if ('' !== self::get_ip_address()) {
68
+			$transient_name = 'external_ip_address_' . self::get_ip_address();
69 69
 		}
70 70
 
71 71
 		// Try retrieving from cache.
72
-		$external_ip_address = get_transient( $transient_name );
72
+		$external_ip_address = get_transient($transient_name);
73 73
 
74
-		if ( false === $external_ip_address ) {
74
+		if (false === $external_ip_address) {
75 75
 			$external_ip_address     = '0.0.0.0';
76
-			$ip_lookup_services      = apply_filters( 'getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis );
77
-			$ip_lookup_services_keys = array_keys( $ip_lookup_services );
78
-			shuffle( $ip_lookup_services_keys );
76
+			$ip_lookup_services      = apply_filters('getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis);
77
+			$ip_lookup_services_keys = array_keys($ip_lookup_services);
78
+			shuffle($ip_lookup_services_keys);
79 79
 
80
-			foreach ( $ip_lookup_services_keys as $service_name ) {
81
-				$service_endpoint = $ip_lookup_services[ $service_name ];
82
-				$response         = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) );
80
+			foreach ($ip_lookup_services_keys as $service_name) {
81
+				$service_endpoint = $ip_lookup_services[$service_name];
82
+				$response         = wp_safe_remote_get($service_endpoint, array('timeout' => 2));
83 83
 
84
-				if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) {
85
-					$external_ip_address = apply_filters( 'getpaid_geolocation_ip_lookup_api_response', wpinv_clean( $response['body'] ), $service_name );
84
+				if (!is_wp_error($response) && rest_is_ip_address($response['body'])) {
85
+					$external_ip_address = apply_filters('getpaid_geolocation_ip_lookup_api_response', wpinv_clean($response['body']), $service_name);
86 86
 					break;
87 87
 				}
88 88
 
89 89
 			}
90 90
 
91
-			set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS );
91
+			set_transient($transient_name, $external_ip_address, WEEK_IN_SECONDS);
92 92
 		}
93 93
 
94 94
 		return $external_ip_address;
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	 * @param  bool   $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower).
103 103
 	 * @return array
104 104
 	 */
105
-	public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) {
105
+	public static function geolocate_ip($ip_address = '', $fallback = false, $api_fallback = true) {
106 106
 
107
-		if ( empty( $ip_address ) ) {
107
+		if (empty($ip_address)) {
108 108
 			$ip_address = self::get_ip_address();
109 109
 		}
110 110
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		self::$current_user_ip = $ip_address;
113 113
 
114 114
 		// Filter to allow custom geolocation of the IP address.
115
-		$country_code = apply_filters( 'getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback );
115
+		$country_code = apply_filters('getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback);
116 116
 
117
-		if ( false !== $country_code ) {
117
+		if (false !== $country_code) {
118 118
 
119 119
 			return array(
120 120
 				'country'  => $country_code,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 * @param array  $geolocation Geolocation data, including country, state, city, and postcode.
135 135
 		 * @param string $ip_address  IP Address.
136 136
 		 */
137
-		$geolocation  = apply_filters(
137
+		$geolocation = apply_filters(
138 138
 			'getpaid_get_geolocation',
139 139
 			array(
140 140
 				'country'  => $country_code,
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 		);
147 147
 
148 148
 		// If we still haven't found a country code, let's consider doing an API lookup.
149
-		if ( '' === $geolocation['country'] && $api_fallback ) {
150
-			$geolocation['country'] = self::geolocate_via_api( $ip_address );
149
+		if ('' === $geolocation['country'] && $api_fallback) {
150
+			$geolocation['country'] = self::geolocate_via_api($ip_address);
151 151
 		}
152 152
 
153 153
 		// It's possible that we're in a local environment, in which case the geolocation needs to be done from the
154 154
 		// external address.
155
-		if ( '' === $geolocation['country'] && $fallback ) {
155
+		if ('' === $geolocation['country'] && $fallback) {
156 156
 			$external_ip_address = self::get_external_ip_address();
157 157
 
158 158
 			// Only bother with this if the external IP differs.
159
-			if ( '0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address ) {
160
-				return self::geolocate_ip( $external_ip_address, false, $api_fallback );
159
+			if ('0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address) {
160
+				return self::geolocate_ip($external_ip_address, false, $api_fallback);
161 161
 			}
162 162
 
163 163
 		}
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 			'HTTP_X_COUNTRY_CODE',
188 188
 		);
189 189
 
190
-		foreach ( $headers as $header ) {
191
-			if ( empty( $_SERVER[ $header ] ) ) {
190
+		foreach ($headers as $header) {
191
+			if (empty($_SERVER[$header])) {
192 192
 				continue;
193 193
 			}
194 194
 
195
-			$country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) );
195
+			$country_code = strtoupper(sanitize_text_field(wp_unslash($_SERVER[$header])));
196 196
 			break;
197 197
 		}
198 198
 
@@ -211,36 +211,36 @@  discard block
 block discarded – undo
211 211
 	 * @param  string $ip_address IP address.
212 212
 	 * @return string
213 213
 	 */
214
-	protected static function geolocate_via_api( $ip_address ) {
214
+	protected static function geolocate_via_api($ip_address) {
215 215
 
216 216
 		// Retrieve from cache...
217
-		$country_code = get_transient( 'geoip_' . $ip_address );
217
+		$country_code = get_transient('geoip_' . $ip_address);
218 218
 
219 219
 		// If missing, retrieve from the API.
220
-		if ( false === $country_code ) {
221
-			$geoip_services = apply_filters( 'getpaid_geolocation_geoip_apis', self::$geoip_apis );
220
+		if (false === $country_code) {
221
+			$geoip_services = apply_filters('getpaid_geolocation_geoip_apis', self::$geoip_apis);
222 222
 
223
-			if ( empty( $geoip_services ) ) {
223
+			if (empty($geoip_services)) {
224 224
 				return '';
225 225
 			}
226 226
 
227
-			$geoip_services_keys = array_keys( $geoip_services );
227
+			$geoip_services_keys = array_keys($geoip_services);
228 228
 
229
-			shuffle( $geoip_services_keys );
229
+			shuffle($geoip_services_keys);
230 230
 
231
-			foreach ( $geoip_services_keys as $service_name ) {
231
+			foreach ($geoip_services_keys as $service_name) {
232 232
 
233
-				$service_endpoint = $geoip_services[ $service_name ];
234
-				$response         = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) );
235
-				$country_code     = sanitize_text_field( strtoupper( self::handle_geolocation_response( $response, $service_name ) ) );
233
+				$service_endpoint = $geoip_services[$service_name];
234
+				$response         = wp_safe_remote_get(sprintf($service_endpoint, $ip_address), array('timeout' => 2));
235
+				$country_code     = sanitize_text_field(strtoupper(self::handle_geolocation_response($response, $service_name)));
236 236
 
237
-				if ( ! empty( $country_code ) ) {
237
+				if (!empty($country_code)) {
238 238
 					break;
239 239
 				}
240 240
 
241 241
 			}
242 242
 
243
-			set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS );
243
+			set_transient('geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS);
244 244
 		}
245 245
 
246 246
 		return $country_code;
@@ -253,23 +253,23 @@  discard block
 block discarded – undo
253 253
 	 * @param  String $geolocation_service
254 254
 	 * @return string Country code
255 255
 	 */
256
-	protected static function handle_geolocation_response( $geolocation_response, $geolocation_service ) {
256
+	protected static function handle_geolocation_response($geolocation_response, $geolocation_service) {
257 257
 
258
-		if ( is_wp_error( $geolocation_response ) || empty( $geolocation_response['body'] ) ) {
258
+		if (is_wp_error($geolocation_response) || empty($geolocation_response['body'])) {
259 259
 			return '';
260 260
 		}
261 261
 
262
-		if ( $geolocation_service === 'ipinfo.io' ) {
263
-			$data = json_decode( $geolocation_response['body'] );
264
-			return empty( $data ) || empty( $data->country ) ? '' : $data->country;
262
+		if ($geolocation_service === 'ipinfo.io') {
263
+			$data = json_decode($geolocation_response['body']);
264
+			return empty($data) || empty($data->country) ? '' : $data->country;
265 265
 		}
266 266
 
267
-		if ( $geolocation_service === 'ip-api.com' ) {
268
-			$data = json_decode( $geolocation_response['body'] );
269
-			return empty( $data ) || empty( $data->countryCode ) ? '' : $data->countryCode;
267
+		if ($geolocation_service === 'ip-api.com') {
268
+			$data = json_decode($geolocation_response['body']);
269
+			return empty($data) || empty($data->countryCode) ? '' : $data->countryCode;
270 270
 		}
271 271
 
272
-		return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] );
272
+		return apply_filters('getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body']);
273 273
 
274 274
 	}
275 275
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,21 +54,21 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
71
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
65
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
66
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
67
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
68
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
69
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
70
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
71
+		do_action('getpaid_init_admin_hooks', $this);
72 72
 
73 73
     }
74 74
 
@@ -79,39 +79,39 @@  discard block
 block discarded – undo
79 79
 	public function enqeue_scripts() {
80 80
         global $current_screen, $pagenow;
81 81
 
82
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
82
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
83 83
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
84 84
 
85
-        if ( ! empty( $current_screen->post_type ) ) {
85
+        if (!empty($current_screen->post_type)) {
86 86
 			$page = $current_screen->post_type;
87 87
         }
88 88
 
89 89
         // General styles.
90
-        if ( false !== stripos( $page, 'wpi' ) ) {
90
+        if (false !== stripos($page, 'wpi')) {
91 91
 
92 92
             // Styles.
93
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
94
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
95
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
96
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
93
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
94
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
95
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
96
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
97 97
 
98 98
             // Scripts.
99
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
100
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
99
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
100
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
101 101
 
102
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
103
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
104
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
102
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
103
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
104
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
105 105
 
106 106
         }
107 107
 
108 108
         // Payment form scripts.
109
-		if ( 'wpi_payment_form' == $page && $editing ) {
109
+		if ('wpi_payment_form' == $page && $editing) {
110 110
             $this->load_payment_form_scripts();
111 111
         }
112 112
 
113
-		if ( $page == 'wpinv-subscriptions' ) {
114
-			wp_enqueue_script( 'postbox' );
113
+		if ($page == 'wpinv-subscriptions') {
114
+			wp_enqueue_script('postbox');
115 115
 		}
116 116
 
117 117
     }
@@ -124,32 +124,32 @@  discard block
 block discarded – undo
124 124
         global $post;
125 125
 
126 126
 		$date_range = array(
127
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
127
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
128 128
 		);
129 129
 
130
-		if ( $date_range['period'] == 'custom' ) {
130
+		if ($date_range['period'] == 'custom') {
131 131
 			
132
-			if ( isset( $_GET['from'] ) ) {
133
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
132
+			if (isset($_GET['from'])) {
133
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
134 134
 			}
135 135
 
136
-			if ( isset( $_GET['to'] ) ) {
137
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
136
+			if (isset($_GET['to'])) {
137
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
138 138
 			}
139 139
 
140 140
 		}
141 141
 
142 142
         $i18n = array(
143
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
144
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
145
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
146
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
147
-			'rest_root'                 => esc_url_raw( rest_url() ),
143
+            'ajax_url'                  => admin_url('admin-ajax.php'),
144
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
145
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
146
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
147
+			'rest_root'                 => esc_url_raw(rest_url()),
148 148
 			'date_range'                => $date_range,
149
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
150
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
151
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
152
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
149
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
150
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
151
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
152
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
153 153
             'tax'                       => wpinv_tax_amount(),
154 154
             'discount'                  => 0,
155 155
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -158,35 +158,35 @@  discard block
 block discarded – undo
158 158
             'thousand_sep'              => wpinv_thousands_separator(),
159 159
             'decimal_sep'               => wpinv_decimal_separator(),
160 160
             'decimals'                  => wpinv_decimals(),
161
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
162
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
163
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
164
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
165
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
166
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
167
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
168
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
169
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
170
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
171
-            'action_edit'               => __( 'Edit', 'invoicing' ),
172
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
173
-            'item_description'          => __( 'Item Description', 'invoicing' ),
174
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
175
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
176
-            'searching'                 => __( 'Searching', 'invoicing' ),
161
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
162
+            'status_publish'            => wpinv_status_nicename('publish'),
163
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
164
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
165
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
166
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
167
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
168
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
169
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
170
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
171
+            'action_edit'               => __('Edit', 'invoicing'),
172
+            'action_cancel'             => __('Cancel', 'invoicing'),
173
+            'item_description'          => __('Item Description', 'invoicing'),
174
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
175
+            'discount_description'      => __('Discount Description', 'invoicing'),
176
+            'searching'                 => __('Searching', 'invoicing'),
177 177
         );
178 178
 
179
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
179
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
180 180
 
181
-			$invoice              = new WPInv_Invoice( $post );
181
+			$invoice              = new WPInv_Invoice($post);
182 182
 			$i18n['save_invoice'] = sprintf(
183
-				__( 'Save %s', 'invoicing' ),
184
-				ucfirst( $invoice->get_invoice_quote_type() )
183
+				__('Save %s', 'invoicing'),
184
+				ucfirst($invoice->get_invoice_quote_type())
185 185
 			);
186 186
 
187 187
 			$i18n['invoice_description'] = sprintf(
188
-				__( '%s Description', 'invoicing' ),
189
-				ucfirst( $invoice->get_invoice_quote_type() )
188
+				__('%s Description', 'invoicing'),
189
+				ucfirst($invoice->get_invoice_quote_type())
190 190
 			);
191 191
 
192 192
 		}
@@ -200,24 +200,24 @@  discard block
 block discarded – undo
200 200
 	 * @param  string $footer_text
201 201
 	 * @return string
202 202
 	 */
203
-	public function admin_footer_text( $footer_text ) {
203
+	public function admin_footer_text($footer_text) {
204 204
 		global $current_screen;
205 205
 
206
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
206
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
207 207
 
208
-        if ( ! empty( $current_screen->post_type ) ) {
208
+        if (!empty($current_screen->post_type)) {
209 209
 			$page = $current_screen->post_type;
210 210
         }
211 211
 
212 212
         // General styles.
213
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
213
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
214 214
 
215 215
 			// Change the footer text
216
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
216
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
217 217
 
218
-				$rating_url  = esc_url(
218
+				$rating_url = esc_url(
219 219
 					wp_nonce_url(
220
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
220
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
221 221
 						'getpaid-nonce',
222 222
 						'getpaid-nonce'
223 223
 						)
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 				$footer_text = sprintf(
227 227
 					/* translators: %s: five stars */
228
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
228
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
229 229
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
230 230
 				);
231 231
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 				$footer_text = sprintf(
235 235
 					/* translators: %s: GetPaid */
236
-					__( 'Thank you for using %s!', 'invoicing' ),
236
+					__('Thank you for using %s!', 'invoicing'),
237 237
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
238 238
 				);
239 239
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	 * @since  2.0.0
251 251
 	 */
252 252
 	public function redirect_to_wordpress_rating_page() {
253
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
254
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
253
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
254
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
255 255
 		exit;
256 256
 	}
257 257
 
@@ -262,30 +262,30 @@  discard block
 block discarded – undo
262 262
 	protected function load_payment_form_scripts() {
263 263
         global $post;
264 264
 
265
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
266
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
267
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
265
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
266
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
267
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
268 268
 
269
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
270
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
269
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
270
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
271 271
 
272 272
 		wp_localize_script(
273 273
             'wpinv-admin-payment-form-script',
274 274
             'wpinvPaymentFormAdmin',
275 275
             array(
276
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
277
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
276
+				'elements'      => wpinv_get_data('payment-form-elements'),
277
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
278 278
 				'currency'      => wpinv_currency_symbol(),
279 279
 				'position'      => wpinv_currency_position(),
280 280
 				'decimals'      => (int) wpinv_decimals(),
281 281
 				'thousands_sep' => wpinv_thousands_separator(),
282 282
 				'decimals_sep'  => wpinv_decimal_separator(),
283
-				'form_items'    => gepaid_get_form_items( $post->ID ),
283
+				'form_items'    => gepaid_get_form_items($post->ID),
284 284
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
285 285
             )
286 286
         );
287 287
 
288
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
288
+        wp_enqueue_script('wpinv-admin-payment-form-script');
289 289
 
290 290
     }
291 291
 
@@ -296,25 +296,25 @@  discard block
 block discarded – undo
296 296
      * @return string
297 297
 	 *
298 298
 	 */
299
-    public function admin_body_class( $classes ) {
299
+    public function admin_body_class($classes) {
300 300
 		global $pagenow, $post, $current_screen;
301 301
 
302 302
 
303
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
303
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
304 304
 
305
-        if ( ! empty( $current_screen->post_type ) ) {
305
+        if (!empty($current_screen->post_type)) {
306 306
 			$page = $current_screen->post_type;
307 307
         }
308 308
 
309
-        if ( false !== stripos( $page, 'wpi' ) ) {
310
-            $classes .= ' wpi-' . sanitize_key( $page );
309
+        if (false !== stripos($page, 'wpi')) {
310
+            $classes .= ' wpi-' . sanitize_key($page);
311 311
         }
312 312
 
313
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
313
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
314 314
             $classes .= ' wpinv-cpt wpinv';
315 315
 		}
316 316
 		
317
-		if ( getpaid_is_invoice_post_type( $page ) ) {
317
+		if (getpaid_is_invoice_post_type($page)) {
318 318
             $classes .= ' getpaid-is-invoice-cpt';
319 319
         }
320 320
 
@@ -324,19 +324,19 @@  discard block
 block discarded – undo
324 324
     /**
325 325
 	 * Maybe show the AyeCode Connect Notice.
326 326
 	 */
327
-	public function init_ayecode_connect_helper(){
327
+	public function init_ayecode_connect_helper() {
328 328
 
329 329
         new AyeCode_Connect_Helper(
330 330
             array(
331
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
332
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
333
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
334
-				'connect_button'    => __("Connect Site","invoicing"),
335
-				'connecting_button'    => __("Connecting...","invoicing"),
336
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
337
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
331
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
332
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
333
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
334
+				'connect_button'    => __("Connect Site", "invoicing"),
335
+				'connecting_button'    => __("Connecting...", "invoicing"),
336
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
337
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
338 338
             ),
339
-            array( 'wpi-addons' )
339
+            array('wpi-addons')
340 340
         );
341 341
 
342 342
     }
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 	 */
349 349
 	public function activation_redirect() {
350 350
 
351
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
351
+		$redirected = get_option('wpinv_redirected_to_settings');
352 352
 
353
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
353
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
354 354
 			return;
355 355
 		}
356 356
 
357 357
 		// Bail if activating from network, or bulk
358
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
358
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
359 359
 			return;
360 360
 		}
361 361
 
362
-	    update_option( 'wpinv_redirected_to_settings', 1 );
362
+	    update_option('wpinv_redirected_to_settings', 1);
363 363
 
364
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
364
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
365 365
         exit;
366 366
 
367 367
 	}
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
      */
372 372
     public function maybe_do_admin_action() {
373 373
 
374
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
375
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
376
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
374
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
375
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
376
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
377 377
         }
378 378
 
379 379
     }
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 	 * 
384 384
 	 * @param array $args
385 385
      */
386
-    public function send_customer_invoice( $args ) {
387
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
386
+    public function send_customer_invoice($args) {
387
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
388 388
 
389
-		if ( $sent ) {
390
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
389
+		if ($sent) {
390
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
391 391
 		} else {
392
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
392
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
393 393
 		}
394 394
 
395
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
395
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
396 396
 		exit;
397 397
 	}
398 398
 
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 	 * 
402 402
 	 * @param array $args
403 403
      */
404
-    public function send_customer_payment_reminder( $args ) {
405
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
404
+    public function send_customer_payment_reminder($args) {
405
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
406 406
 
407
-		if ( $sent ) {
408
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
407
+		if ($sent) {
408
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
409 409
 		} else {
410
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
410
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
411 411
 		}
412 412
 
413
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
413
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
414 414
 		exit;
415 415
 	}
416 416
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
      */
421 421
     public function admin_reset_tax_rates() {
422 422
 
423
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
424
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
423
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
424
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
425 425
 		exit;
426 426
 
427 427
 	}
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
     public function admin_create_missing_pages() {
434 434
 		$installer = new GetPaid_Installer();
435 435
 		$installer->create_pages();
436
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
437
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
436
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
437
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
438 438
 		exit;
439 439
 	}
440 440
 
@@ -446,35 +446,35 @@  discard block
 block discarded – undo
446 446
 		global $wpdb;
447 447
 		$installer = new GetPaid_Installer();
448 448
 
449
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
449
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
450 450
 			$installer->create_subscriptions_table();
451 451
 
452
-			if ( $wpdb->last_error !== '' ) {
453
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
452
+			if ($wpdb->last_error !== '') {
453
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
454 454
 			}
455 455
 		}
456 456
 
457
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
457
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
458 458
 			$installer->create_invoices_table();
459 459
 
460
-			if ( $wpdb->last_error !== '' ) {
461
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
460
+			if ($wpdb->last_error !== '') {
461
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
462 462
 			}
463 463
 		}
464 464
 
465
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
465
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
466 466
 			$installer->create_invoice_items_table();
467 467
 
468
-			if ( $wpdb->last_error !== '' ) {
469
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
468
+			if ($wpdb->last_error !== '') {
469
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
470 470
 			}
471 471
 		}
472 472
 
473
-		if ( ! $this->has_notices() ) {
474
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
473
+		if (!$this->has_notices()) {
474
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
475 475
 		}
476 476
 
477
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
477
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
478 478
 		exit;
479 479
 	}
480 480
 
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
 		$installer->migrate_old_invoices();
490 490
 
491 491
 		// Show an admin message.
492
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
492
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
493 493
 
494 494
 		// Redirect the admin.
495
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
495
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
496 496
 		exit;
497 497
 
498 498
 	}
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
      * @return array
505 505
 	 */
506 506
 	public function get_notices() {
507
-		$notices = get_option( 'wpinv_admin_notices' );
508
-        return is_array( $notices ) ? $notices : array();
507
+		$notices = get_option('wpinv_admin_notices');
508
+        return is_array($notices) ? $notices : array();
509 509
 	}
510 510
 
511 511
 	/**
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
      * @return array
516 516
 	 */
517 517
 	public function has_notices() {
518
-		return count( $this->get_notices() ) > 0;
518
+		return count($this->get_notices()) > 0;
519 519
 	}
520 520
 
521 521
 	/**
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	 * @since       1.0.19
526 526
 	 */
527 527
 	public function clear_notices() {
528
-		delete_option( 'wpinv_admin_notices' );
528
+		delete_option('wpinv_admin_notices');
529 529
 	}
530 530
 
531 531
 	/**
@@ -534,16 +534,16 @@  discard block
 block discarded – undo
534 534
 	 * @access      public
535 535
 	 * @since       1.0.19
536 536
 	 */
537
-	public function save_notice( $type, $message ) {
537
+	public function save_notice($type, $message) {
538 538
 		$notices = $this->get_notices();
539 539
 
540
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
541
-			$notices[ $type ] = array();
540
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
541
+			$notices[$type] = array();
542 542
 		}
543 543
 
544
-		$notices[ $type ][] = $message;
544
+		$notices[$type][] = $message;
545 545
 
546
-		update_option( 'wpinv_admin_notices', $notices );
546
+		update_option('wpinv_admin_notices', $notices);
547 547
 	}
548 548
 
549 549
 	/**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 	 * @access      public
554 554
 	 * @since       1.0.19
555 555
 	 */
556
-	public function show_success( $msg ) {
557
-		$this->save_notice( 'success', $msg );
556
+	public function show_success($msg) {
557
+		$this->save_notice('success', $msg);
558 558
 	}
559 559
 
560 560
 	/**
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
 	 * @param       string $msg The message to qeue.
565 565
 	 * @since       1.0.19
566 566
 	 */
567
-	public function show_error( $msg ) {
568
-		$this->save_notice( 'error', $msg );
567
+	public function show_error($msg) {
568
+		$this->save_notice('error', $msg);
569 569
 	}
570 570
 
571 571
 	/**
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 	 * @param       string $msg The message to qeue.
576 576
 	 * @since       1.0.19
577 577
 	 */
578
-	public function show_warning( $msg ) {
579
-		$this->save_notice( 'warning', $msg );
578
+	public function show_warning($msg) {
579
+		$this->save_notice('warning', $msg);
580 580
 	}
581 581
 
582 582
 	/**
@@ -586,8 +586,8 @@  discard block
 block discarded – undo
586 586
 	 * @param       string $msg The message to qeue.
587 587
 	 * @since       1.0.19
588 588
 	 */
589
-	public function show_info( $msg ) {
590
-		$this->save_notice( 'info', $msg );
589
+	public function show_info($msg) {
590
+		$this->save_notice('info', $msg);
591 591
 	}
592 592
 
593 593
 	/**
@@ -601,32 +601,32 @@  discard block
 block discarded – undo
601 601
         $notices = $this->get_notices();
602 602
         $this->clear_notices();
603 603
 
604
-		foreach ( $notices as $type => $messages ) {
604
+		foreach ($notices as $type => $messages) {
605 605
 
606
-			if ( ! is_array( $messages ) ) {
606
+			if (!is_array($messages)) {
607 607
 				continue;
608 608
 			}
609 609
 
610
-            $type  = sanitize_key( $type );
611
-			foreach ( $messages as $message ) {
612
-                $message = wp_kses_post( $message );
610
+            $type = sanitize_key($type);
611
+			foreach ($messages as $message) {
612
+                $message = wp_kses_post($message);
613 613
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
614 614
             }
615 615
 
616 616
         }
617 617
 
618
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
618
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
619 619
 
620
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
621
-				$url     = esc_url(
620
+			if (!is_numeric(wpinv_get_option($page, false))) {
621
+				$url = esc_url(
622 622
 					wp_nonce_url(
623
-						add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
623
+						add_query_arg('getpaid-admin-action', 'create_missing_pages'),
624 624
 						'getpaid-nonce',
625 625
 						'getpaid-nonce'
626 626
 					)
627 627
 				);
628
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
629
-				$message2 = __( 'Generate Pages', 'invoicing' );
628
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
629
+				$message2 = __('Generate Pages', 'invoicing');
630 630
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
631 631
 				break;
632 632
 			}
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +381 added lines, -381 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,139 +259,139 @@  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 ];
393
+    if ($tab && !empty($sections[$tab])) {
394
+        $tabs = $sections[$tab];
395 395
     }
396 396
 
397 397
     return $tabs;
@@ -400,91 +400,91 @@  discard block
 block discarded – undo
400 400
 function wpinv_get_registered_settings_sections() {
401 401
     static $sections = false;
402 402
 
403
-    if ( false !== $sections ) {
403
+    if (false !== $sections) {
404 404
         return $sections;
405 405
     }
406 406
 
407 407
     $sections = array(
408
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
409
-            'main' => __( 'General Settings', 'invoicing' ),
410
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
411
-            'labels' => __( 'Label Texts', 'invoicing' ),
412
-        ) ),
413
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
414
-            'main' => __( 'Gateway Settings', 'invoicing' ),
415
-        ) ),
416
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
417
-            'main'  => __( 'Tax Settings', 'invoicing' ),
418
-			'rates' => __( 'Tax Rates', 'invoicing' ),
419
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
420
-        ) ),
421
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
422
-            'main' => __( 'Email Settings', 'invoicing' ),
423
-		) ),
424
-
425
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
426
-
427
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
428
-            'main' => __( 'Privacy policy', 'invoicing' ),
429
-        ) ),
430
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
431
-            'main' => __( 'Miscellaneous', 'invoicing' ),
432
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
433
-        ) ),
434
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
435
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
436
-        ) ),
408
+        'general' => apply_filters('wpinv_settings_sections_general', array(
409
+            'main' => __('General Settings', 'invoicing'),
410
+            'currency_section' => __('Currency Settings', 'invoicing'),
411
+            'labels' => __('Label Texts', 'invoicing'),
412
+        )),
413
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
414
+            'main' => __('Gateway Settings', 'invoicing'),
415
+        )),
416
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
417
+            'main'  => __('Tax Settings', 'invoicing'),
418
+			'rates' => __('Tax Rates', 'invoicing'),
419
+			'vat'   => __('EU VAT Settings', 'invoicing')
420
+        )),
421
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
422
+            'main' => __('Email Settings', 'invoicing'),
423
+		)),
424
+
425
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
426
+
427
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
428
+            'main' => __('Privacy policy', 'invoicing'),
429
+        )),
430
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
431
+            'main' => __('Miscellaneous', 'invoicing'),
432
+            'custom-css' => __('Custom CSS', 'invoicing'),
433
+        )),
434
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
435
+            'main' => __('Diagnostic Tools', 'invoicing'),
436
+        )),
437 437
     );
438 438
 
439
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
439
+    $sections = apply_filters('wpinv_settings_sections', $sections);
440 440
 
441 441
     return $sections;
442 442
 }
443 443
 
444
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
444
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
445 445
 	$pages_options = array();
446 446
 
447
-	if( $default_label !== NULL && $default_label !== false ) {
448
-		$pages_options = array( '' => $default_label ); // Blank option
447
+	if ($default_label !== NULL && $default_label !== false) {
448
+		$pages_options = array('' => $default_label); // Blank option
449 449
 	}
450 450
 
451 451
 	$pages = get_pages();
452
-	if ( $pages ) {
453
-		foreach ( $pages as $page ) {
452
+	if ($pages) {
453
+		foreach ($pages as $page) {
454 454
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
455
-            $pages_options[ $page->ID ] = $title;
455
+            $pages_options[$page->ID] = $title;
456 456
 		}
457 457
 	}
458 458
 
459 459
 	return $pages_options;
460 460
 }
461 461
 
462
-function wpinv_header_callback( $args ) {
463
-	if ( !empty( $args['desc'] ) ) {
462
+function wpinv_header_callback($args) {
463
+	if (!empty($args['desc'])) {
464 464
         echo $args['desc'];
465 465
     }
466 466
 }
467 467
 
468
-function wpinv_hidden_callback( $args ) {
468
+function wpinv_hidden_callback($args) {
469 469
 	global $wpinv_options;
470 470
 
471
-	if ( isset( $args['set_value'] ) ) {
471
+	if (isset($args['set_value'])) {
472 472
 		$value = $args['set_value'];
473
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
-		$value = $wpinv_options[ $args['id'] ];
473
+	} elseif (isset($wpinv_options[$args['id']])) {
474
+		$value = $wpinv_options[$args['id']];
475 475
 	} else {
476
-		$value = isset( $args['std'] ) ? $args['std'] : '';
476
+		$value = isset($args['std']) ? $args['std'] : '';
477 477
 	}
478 478
 
479
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
479
+	if (isset($args['faux']) && true === $args['faux']) {
480 480
 		$args['readonly'] = true;
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
481
+		$value = isset($args['std']) ? $args['std'] : '';
482 482
 		$name  = '';
483 483
 	} else {
484
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
484
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
485 485
 	}
486 486
 
487
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
487
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
488 488
     
489 489
 	echo $html;
490 490
 }
@@ -492,61 +492,61 @@  discard block
 block discarded – undo
492 492
 /**
493 493
  * Displays a checkbox settings callback.
494 494
  */
495
-function wpinv_checkbox_callback( $args ) {
495
+function wpinv_checkbox_callback($args) {
496 496
 
497
-	$std = isset( $args['std'] ) ? $args['std'] : '';
498
-	$std = wpinv_get_option( $args['id'], $std );
499
-	$id  = esc_attr( $args['id'] );
497
+	$std = isset($args['std']) ? $args['std'] : '';
498
+	$std = wpinv_get_option($args['id'], $std);
499
+	$id  = esc_attr($args['id']);
500 500
 
501
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
501
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
502 502
 	?>
503 503
 		<fieldset>
504 504
 			<label>
505
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
506
-				<?php echo wp_kses_post( $args['desc'] ); ?>
505
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
506
+				<?php echo wp_kses_post($args['desc']); ?>
507 507
 			</label>
508 508
 		</fieldset>
509 509
 	<?php
510 510
 }
511 511
 
512
-function wpinv_multicheck_callback( $args ) {
512
+function wpinv_multicheck_callback($args) {
513 513
 	
514 514
 	global $wpinv_options;
515 515
 
516
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
517
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
516
+	$sanitize_id = wpinv_sanitize_key($args['id']);
517
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
518 518
 
519
-	if ( ! empty( $args['options'] ) ) {
519
+	if (!empty($args['options'])) {
520 520
 
521
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
522
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
521
+		$std     = isset($args['std']) ? $args['std'] : array();
522
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
523 523
 
524 524
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
525
-        foreach( $args['options'] as $key => $option ):
526
-			$sanitize_key = wpinv_sanitize_key( $key );
527
-			if ( in_array( $sanitize_key, $value ) ) { 
525
+        foreach ($args['options'] as $key => $option):
526
+			$sanitize_key = wpinv_sanitize_key($key);
527
+			if (in_array($sanitize_key, $value)) { 
528 528
 				$enabled = $sanitize_key;
529 529
 			} else { 
530 530
 				$enabled = NULL; 
531 531
 			}
532
-			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;';
533
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
532
+			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;';
533
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
534 534
 		endforeach;
535 535
 		echo '</div>';
536 536
 		echo '<p class="description">' . $args['desc'] . '</p>';
537 537
 	}
538 538
 }
539 539
 
540
-function wpinv_payment_icons_callback( $args ) {
540
+function wpinv_payment_icons_callback($args) {
541 541
 	global $wpinv_options;
542 542
     
543
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
543
+    $sanitize_id = wpinv_sanitize_key($args['id']);
544 544
 
545
-	if ( ! empty( $args['options'] ) ) {
546
-		foreach( $args['options'] as $key => $option ) {
547
-            $sanitize_key = wpinv_sanitize_key( $key );
545
+	if (!empty($args['options'])) {
546
+		foreach ($args['options'] as $key => $option) {
547
+            $sanitize_key = wpinv_sanitize_key($key);
548 548
             
549
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
549
+			if (isset($wpinv_options[$args['id']][$key])) {
550 550
 				$enabled = $option;
551 551
 			} else {
552 552
 				$enabled = NULL;
@@ -554,109 +554,109 @@  discard block
 block discarded – undo
554 554
 
555 555
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
556 556
 
557
-				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;';
557
+				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;';
558 558
 
559
-				if ( wpinv_string_is_image_url( $key ) ) {
560
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
559
+				if (wpinv_string_is_image_url($key)) {
560
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561 561
 				} else {
562
-					$card = strtolower( str_replace( ' ', '', $option ) );
562
+					$card = strtolower(str_replace(' ', '', $option));
563 563
 
564
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
564
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
565
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
566 566
 					} else {
567
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
567
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
568 568
 						$content_dir = WP_CONTENT_DIR;
569 569
 
570
-						if ( function_exists( 'wp_normalize_path' ) ) {
570
+						if (function_exists('wp_normalize_path')) {
571 571
 							// Replaces backslashes with forward slashes for Windows systems
572
-							$image = wp_normalize_path( $image );
573
-							$content_dir = wp_normalize_path( $content_dir );
572
+							$image = wp_normalize_path($image);
573
+							$content_dir = wp_normalize_path($content_dir);
574 574
 						}
575 575
 
576
-						$image = str_replace( $content_dir, content_url(), $image );
576
+						$image = str_replace($content_dir, content_url(), $image);
577 577
 					}
578 578
 
579
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
579
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580 580
 				}
581 581
 			echo $option . '</label>';
582 582
 		}
583
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
583
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
584 584
 	}
585 585
 }
586 586
 
587 587
 /**
588 588
  * Displays a radio settings field.
589 589
  */
590
-function wpinv_radio_callback( $args ) {
590
+function wpinv_radio_callback($args) {
591 591
 
592
-	$std = isset( $args['std'] ) ? $args['std'] : '';
593
-	$std = wpinv_get_option( $args['id'], $std );
592
+	$std = isset($args['std']) ? $args['std'] : '';
593
+	$std = wpinv_get_option($args['id'], $std);
594 594
 	?>
595 595
 		<fieldset>
596
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
597
-				<?php foreach( $args['options'] as $key => $option ) : ?>
596
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
597
+				<?php foreach ($args['options'] as $key => $option) : ?>
598 598
 					<li>
599 599
 						<label>
600
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
601
-							<?php echo wp_kses_post( $option ); ?>
600
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
601
+							<?php echo wp_kses_post($option); ?>
602 602
 						</label>
603 603
 					</li>
604 604
 				<?php endforeach; ?>
605 605
 			</ul>
606 606
 		</fieldset>
607 607
 	<?php
608
-	getpaid_settings_description_callback( $args );
608
+	getpaid_settings_description_callback($args);
609 609
 }
610 610
 
611 611
 /**
612 612
  * Displays a description if available.
613 613
  */
614
-function getpaid_settings_description_callback( $args ) {
614
+function getpaid_settings_description_callback($args) {
615 615
 
616
-	if ( ! empty( $args['desc'] ) ) {
617
-		$description = wp_kses_post( $args['desc'] );
616
+	if (!empty($args['desc'])) {
617
+		$description = wp_kses_post($args['desc']);
618 618
 		echo "<p class='description'>$description</p>";
619 619
 	}
620 620
 
621 621
 }
622 622
 
623
-function wpinv_gateways_callback( $args ) {
623
+function wpinv_gateways_callback($args) {
624 624
 
625
-	$gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
626
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
625
+	$gateways = wpinv_get_option('gateways', array('manual' => 1));
626
+    $sanitize_id = wpinv_sanitize_key($args['id']);
627 627
 
628
-	foreach ( $args['options'] as $key => $option ) :
629
-		$sanitize_key = wpinv_sanitize_key( $key );
628
+	foreach ($args['options'] as $key => $option) :
629
+		$sanitize_key = wpinv_sanitize_key($key);
630 630
         
631
-        if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
631
+        if (is_array($gateways) && isset($gateways[$key]))
632 632
 			$enabled = '1';
633 633
 		else
634 634
 			$enabled = null;
635 635
 
636
-		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;';
637
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
636
+		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;';
637
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
638 638
 	endforeach;
639 639
 }
640 640
 
641 641
 function wpinv_gateway_select_callback($args) {
642 642
 	global $wpinv_options;
643 643
     
644
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
645
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
+    $sanitize_id = wpinv_sanitize_key($args['id']);
645
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
646 646
 
647
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
647
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
650
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651
-            $selected = selected( $key, $args['selected'], false );
649
+	foreach ($args['options'] as $key => $option) :
650
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
651
+            $selected = selected($key, $args['selected'], false);
652 652
         } else {
653
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
653
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
654 654
         }
655
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
655
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
656 656
 	endforeach;
657 657
 
658 658
 	echo '</select>';
659
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
659
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
660 660
 }
661 661
 
662 662
 /**
@@ -665,28 +665,28 @@  discard block
 block discarded – undo
665 665
  * @param array $args
666 666
  * @return string
667 667
  */
668
-function wpinv_settings_attrs_helper( $args ) {
668
+function wpinv_settings_attrs_helper($args) {
669 669
 
670
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
671
-	$id           = esc_attr( $args['id'] );
672
-	$placeholder  = esc_attr( $args['placeholder'] );
670
+	$value        = isset($args['std']) ? $args['std'] : '';
671
+	$id           = esc_attr($args['id']);
672
+	$placeholder  = esc_attr($args['placeholder']);
673 673
 
674
-	if ( ! empty( $args['faux'] ) ) {
674
+	if (!empty($args['faux'])) {
675 675
 		$args['readonly'] = true;
676 676
 		$name             = '';
677 677
 	} else {
678
-		$value  = wpinv_get_option( $args['id'], $value );
678
+		$value  = wpinv_get_option($args['id'], $value);
679 679
 		$name   = "wpinv_settings[$id]";
680 680
 	}
681 681
 
682
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
683
-	$class    = esc_attr( $args['class'] );
684
-	$style    = esc_attr( $args['style'] );
685
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
682
+	$value    = is_scalar($value) ? esc_attr($value) : '';
683
+	$class    = esc_attr($args['class']);
684
+	$style    = esc_attr($args['style']);
685
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
686 686
 
687 687
 	$onchange = '';
688
-    if ( ! empty( $args['onchange'] ) ) {
689
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
688
+    if (!empty($args['onchange'])) {
689
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
690 690
 	}
691 691
 
692 692
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 /**
696 696
  * Displays a text input settings callback.
697 697
  */
698
-function wpinv_text_callback( $args ) {
698
+function wpinv_text_callback($args) {
699 699
 
700
-	$desc = wp_kses_post( $args['desc'] );
701
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
702
-	$attr = wpinv_settings_attrs_helper( $args );
700
+	$desc = wp_kses_post($args['desc']);
701
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
702
+	$attr = wpinv_settings_attrs_helper($args);
703 703
 
704 704
 	?>
705 705
 		<label style="width: 100%;">
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
 /**
714 714
  * Displays a number input settings callback.
715 715
  */
716
-function wpinv_number_callback( $args ) {
716
+function wpinv_number_callback($args) {
717 717
 
718
-	$desc = wp_kses_post( $args['desc'] );
719
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
720
-	$attr = wpinv_settings_attrs_helper( $args );
721
-	$max  = intval( $args['max'] );
722
-	$min  = intval( $args['min'] );
723
-	$step = floatval( $args['step'] );
718
+	$desc = wp_kses_post($args['desc']);
719
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
720
+	$attr = wpinv_settings_attrs_helper($args);
721
+	$max  = intval($args['max']);
722
+	$min  = intval($args['min']);
723
+	$step = floatval($args['step']);
724 724
 
725 725
 	?>
726 726
 		<label style="width: 100%;">
@@ -731,47 +731,47 @@  discard block
 block discarded – undo
731 731
 
732 732
 }
733 733
 
734
-function wpinv_textarea_callback( $args ) {
734
+function wpinv_textarea_callback($args) {
735 735
 	global $wpinv_options;
736 736
     
737
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
737
+    $sanitize_id = wpinv_sanitize_key($args['id']);
738 738
 
739
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
-		$value = $wpinv_options[ $args['id'] ];
739
+	if (isset($wpinv_options[$args['id']])) {
740
+		$value = $wpinv_options[$args['id']];
741 741
 	} else {
742
-		$value = isset( $args['std'] ) ? $args['std'] : '';
742
+		$value = isset($args['std']) ? $args['std'] : '';
743 743
 	}
744 744
     
745
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
746
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
745
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
746
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
747 747
 
748
-	$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>';
749
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
748
+	$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>';
749
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
750 750
 
751 751
 	echo $html;
752 752
 }
753 753
 
754
-function wpinv_password_callback( $args ) {
754
+function wpinv_password_callback($args) {
755 755
 	global $wpinv_options;
756 756
     
757
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
757
+    $sanitize_id = wpinv_sanitize_key($args['id']);
758 758
 
759
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
-		$value = $wpinv_options[ $args['id'] ];
759
+	if (isset($wpinv_options[$args['id']])) {
760
+		$value = $wpinv_options[$args['id']];
761 761
 	} else {
762
-		$value = isset( $args['std'] ) ? $args['std'] : '';
762
+		$value = isset($args['std']) ? $args['std'] : '';
763 763
 	}
764 764
 
765
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
766
-	$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 ) . '"/>';
767
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
765
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
766
+	$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) . '"/>';
767
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
768 768
 
769 769
 	echo $html;
770 770
 }
771 771
 
772 772
 function wpinv_missing_callback($args) {
773 773
 	printf(
774
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
774
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
775 775
 		'<strong>' . $args['id'] . '</strong>'
776 776
 	);
777 777
 }
@@ -779,20 +779,20 @@  discard block
 block discarded – undo
779 779
 /**
780 780
  * Displays a number input settings callback.
781 781
  */
782
-function wpinv_select_callback( $args ) {
782
+function wpinv_select_callback($args) {
783 783
 
784
-	$desc   = wp_kses_post( $args['desc'] );
785
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
786
-	$attr   = wpinv_settings_attrs_helper( $args );
787
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
788
-	$value  = wpinv_get_option( $args['id'], $value );
784
+	$desc   = wp_kses_post($args['desc']);
785
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
786
+	$attr   = wpinv_settings_attrs_helper($args);
787
+	$value  = isset($args['std']) ? $args['std'] : '';
788
+	$value  = wpinv_get_option($args['id'], $value);
789 789
 
790 790
 	?>
791 791
 		<label style="width: 100%;">
792 792
 			<select <?php echo $attr; ?>>
793
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
794
-					<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>
795
-				<?php endforeach;?>
793
+				<?php foreach ($args['options'] as $option => $name) : ?>
794
+					<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>
795
+				<?php endforeach; ?>
796 796
 			</select>
797 797
 			<?php echo $desc; ?>
798 798
 		</label>
@@ -800,95 +800,95 @@  discard block
 block discarded – undo
800 800
 
801 801
 }
802 802
 
803
-function wpinv_color_select_callback( $args ) {
803
+function wpinv_color_select_callback($args) {
804 804
 	global $wpinv_options;
805 805
     
806
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
806
+    $sanitize_id = wpinv_sanitize_key($args['id']);
807 807
 
808
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
-		$value = $wpinv_options[ $args['id'] ];
808
+	if (isset($wpinv_options[$args['id']])) {
809
+		$value = $wpinv_options[$args['id']];
810 810
 	} else {
811
-		$value = isset( $args['std'] ) ? $args['std'] : '';
811
+		$value = isset($args['std']) ? $args['std'] : '';
812 812
 	}
813 813
 
814
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
814
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
815 815
 
816
-	foreach ( $args['options'] as $option => $color ) {
817
-		$selected = selected( $option, $value, false );
818
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
816
+	foreach ($args['options'] as $option => $color) {
817
+		$selected = selected($option, $value, false);
818
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
819 819
 	}
820 820
 
821 821
 	$html .= '</select>';
822
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
822
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
823 823
 
824 824
 	echo $html;
825 825
 }
826 826
 
827
-function wpinv_rich_editor_callback( $args ) {
827
+function wpinv_rich_editor_callback($args) {
828 828
 	global $wpinv_options, $wp_version;
829 829
     
830
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
830
+    $sanitize_id = wpinv_sanitize_key($args['id']);
831 831
 
832
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
833
-		$value = $wpinv_options[ $args['id'] ];
832
+	if (isset($wpinv_options[$args['id']])) {
833
+		$value = $wpinv_options[$args['id']];
834 834
 
835
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
-			$value = isset( $args['std'] ) ? $args['std'] : '';
835
+		if (empty($args['allow_blank']) && empty($value)) {
836
+			$value = isset($args['std']) ? $args['std'] : '';
837 837
 		}
838 838
 	} else {
839
-		$value = isset( $args['std'] ) ? $args['std'] : '';
839
+		$value = isset($args['std']) ? $args['std'] : '';
840 840
 	}
841 841
 
842
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
842
+	$rows = isset($args['size']) ? $args['size'] : 20;
843 843
 
844 844
 	$html = '<div class="getpaid-settings-editor-input">';
845
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
845
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
846 846
 		ob_start();
847
-		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 ) );
847
+		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));
848 848
 		$html .= ob_get_clean();
849 849
 	} else {
850
-		$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>';
850
+		$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>';
851 851
 	}
852 852
 
853
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
853
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
854 854
 
855 855
 	echo $html;
856 856
 }
857 857
 
858
-function wpinv_upload_callback( $args ) {
858
+function wpinv_upload_callback($args) {
859 859
 	global $wpinv_options;
860 860
     
861
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
861
+    $sanitize_id = wpinv_sanitize_key($args['id']);
862 862
 
863
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
+	if (isset($wpinv_options[$args['id']])) {
864 864
 		$value = $wpinv_options[$args['id']];
865 865
 	} else {
866 866
 		$value = isset($args['std']) ? $args['std'] : '';
867 867
 	}
868 868
 
869
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
870
-	$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 ) ) . '"/>';
871
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
872
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
869
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
870
+	$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)) . '"/>';
871
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
872
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
873 873
 
874 874
 	echo $html;
875 875
 }
876 876
 
877
-function wpinv_color_callback( $args ) {
877
+function wpinv_color_callback($args) {
878 878
 	global $wpinv_options;
879 879
     
880
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
880
+    $sanitize_id = wpinv_sanitize_key($args['id']);
881 881
 
882
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
-		$value = $wpinv_options[ $args['id'] ];
882
+	if (isset($wpinv_options[$args['id']])) {
883
+		$value = $wpinv_options[$args['id']];
884 884
 	} else {
885
-		$value = isset( $args['std'] ) ? $args['std'] : '';
885
+		$value = isset($args['std']) ? $args['std'] : '';
886 886
 	}
887 887
 
888
-	$default = isset( $args['std'] ) ? $args['std'] : '';
888
+	$default = isset($args['std']) ? $args['std'] : '';
889 889
 
890
-	$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 ) . '" />';
891
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
890
+	$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) . '" />';
891
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
892 892
 
893 893
 	echo $html;
894 894
 }
@@ -896,9 +896,9 @@  discard block
 block discarded – undo
896 896
 function wpinv_country_states_callback($args) {
897 897
 	global $wpinv_options;
898 898
     
899
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
899
+    $sanitize_id = wpinv_sanitize_key($args['id']);
900 900
 
901
-	if ( isset( $args['placeholder'] ) ) {
901
+	if (isset($args['placeholder'])) {
902 902
 		$placeholder = $args['placeholder'];
903 903
 	} else {
904 904
 		$placeholder = '';
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 
907 907
 	$states = wpinv_get_country_states();
908 908
 
909
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
909
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
911 911
 
912
-	foreach ( $states as $option => $name ) {
913
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
914
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
912
+	foreach ($states as $option => $name) {
913
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
914
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
915 915
 	}
916 916
 
917 917
 	$html .= '</select>';
918
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
918
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
919 919
 
920 920
 	echo $html;
921 921
 }
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	</tr>
931 931
 	<tr class="bsui">
932 932
     	<td colspan="2" class="p-0">
933
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
933
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
934 934
 
935 935
 	<?php
936 936
 
@@ -939,14 +939,14 @@  discard block
 block discarded – undo
939 939
 /**
940 940
  * Displays a tax rate' edit row.
941 941
  */
942
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
942
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
943 943
 	ob_start();
944 944
 
945
-	$key                      = sanitize_key( $key );
946
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
947
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
945
+	$key                      = sanitize_key($key);
946
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
947
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
948 948
 
949
-	if ( $echo ) {
949
+	if ($echo) {
950 950
 		echo ob_get_clean();
951 951
 	} else {
952 952
 		return ob_get_clean(); 
@@ -958,133 +958,133 @@  discard block
 block discarded – undo
958 958
     ob_start(); ?>
959 959
     </td><tr>
960 960
     <td colspan="2" class="wpinv_tools_tdbox">
961
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
962
-    <?php do_action( 'wpinv_tools_before' ); ?>
961
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
962
+    <?php do_action('wpinv_tools_before'); ?>
963 963
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
964 964
         <thead>
965 965
             <tr>
966
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
967
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
968
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
966
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
967
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
968
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
969 969
             </tr>
970 970
         </thead>
971 971
 
972 972
         <tbody>
973 973
 			<tr>
974
-                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
974
+                <td><?php _e('Check Pages', 'invoicing'); ?></td>
975 975
                 <td>
976
-                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
976
+                    <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
977 977
                 </td>
978 978
                 <td>
979 979
 					<a href="<?php
980 980
 						echo esc_url(
981 981
 							wp_nonce_url(
982
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
982
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
983 983
 								'getpaid-nonce',
984 984
 								'getpaid-nonce'
985 985
 							)
986 986
 						);
987
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
987
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
988 988
                 </td>
989 989
             </tr>
990 990
 			<tr>
991
-                <td><?php _e( 'Create Database Tables', 'invoicing' );?></td>
991
+                <td><?php _e('Create Database Tables', 'invoicing'); ?></td>
992 992
                 <td>
993
-                    <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
993
+                    <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
994 994
                 </td>
995 995
                 <td>
996 996
 					<a href="<?php
997 997
 						echo esc_url(
998 998
 							wp_nonce_url(
999
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
999
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
1000 1000
 								'getpaid-nonce',
1001 1001
 								'getpaid-nonce'
1002 1002
 							)
1003 1003
 						);
1004
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1004
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1005 1005
                 </td>
1006 1006
             </tr>
1007 1007
 			<tr>
1008
-                <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td>
1008
+                <td><?php _e('Migrate old invoices', 'invoicing'); ?></td>
1009 1009
                 <td>
1010
-                    <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
1010
+                    <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
1011 1011
                 </td>
1012 1012
                 <td>
1013 1013
 					<a href="<?php
1014 1014
 						echo esc_url(
1015 1015
 							wp_nonce_url(
1016
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1016
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
1017 1017
 								'getpaid-nonce',
1018 1018
 								'getpaid-nonce'
1019 1019
 							)
1020 1020
 						);
1021
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1021
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1022 1022
                 </td>
1023 1023
             </tr>
1024
-			<?php do_action( 'wpinv_tools_row' ); ?>
1024
+			<?php do_action('wpinv_tools_row'); ?>
1025 1025
         </tbody>
1026 1026
     </table>
1027
-    <?php do_action( 'wpinv_tools_after' ); ?>
1027
+    <?php do_action('wpinv_tools_after'); ?>
1028 1028
     <?php
1029 1029
     echo ob_get_clean();
1030 1030
 }
1031 1031
 
1032
-function wpinv_descriptive_text_callback( $args ) {
1033
-	echo wp_kses_post( $args['desc'] );
1032
+function wpinv_descriptive_text_callback($args) {
1033
+	echo wp_kses_post($args['desc']);
1034 1034
 }
1035 1035
 
1036
-function wpinv_raw_html_callback( $args ) {
1036
+function wpinv_raw_html_callback($args) {
1037 1037
 	echo $args['desc'];
1038 1038
 }
1039 1039
 
1040
-function wpinv_hook_callback( $args ) {
1041
-	do_action( 'wpinv_' . $args['id'], $args );
1040
+function wpinv_hook_callback($args) {
1041
+	do_action('wpinv_' . $args['id'], $args);
1042 1042
 }
1043 1043
 
1044 1044
 function wpinv_set_settings_cap() {
1045 1045
 	return wpinv_get_capability();
1046 1046
 }
1047
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1047
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1048 1048
 
1049
-function wpinv_settings_sanitize_input( $value, $key ) {
1049
+function wpinv_settings_sanitize_input($value, $key) {
1050 1050
 
1051
-    if ( $key == 'tax_rate' ) {
1052
-        $value = wpinv_sanitize_amount( $value );
1051
+    if ($key == 'tax_rate') {
1052
+        $value = wpinv_sanitize_amount($value);
1053 1053
         $value = $value >= 100 ? 99 : $value;
1054 1054
     }
1055 1055
 
1056 1056
     return $value;
1057 1057
 }
1058
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1058
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1059 1059
 
1060
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1061
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1062
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1060
+function wpinv_on_update_settings($old_value, $value, $option) {
1061
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1062
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1063 1063
     
1064
-    if ( $old != $new ) {
1065
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1064
+    if ($old != $new) {
1065
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1066 1066
     }
1067 1067
 }
1068
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1069
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1070
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1071
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1072
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1073
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1074
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1075
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1076
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1077
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1078
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1079
-
1080
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1068
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1069
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1070
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1071
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1072
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1073
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1074
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1075
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1076
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1077
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1078
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1079
+
1080
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1081 1081
     ?>
1082 1082
     <div class="wpinv-email-wc-row ">
1083 1083
         <div class="wpinv-email-wc-td">
1084
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1084
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1085 1085
             <p class="wpinv-email-wc-description">
1086 1086
                 <?php
1087
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1087
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1088 1088
                     <strong>{site_title} :</strong> Site Title<br>
1089 1089
                     <strong>{name} :</strong> Customer\'s full name<br>
1090 1090
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1099 1099
                     <strong>{date} :</strong> Today\'s date.<br>
1100 1100
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1101
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1101
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1102 1102
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1103 1103
                 ?>
1104 1104
             </p>
Please login to merge, or discard this patch.
includes/class-wpinv-session-handler.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Session handler class.
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function __construct() {
54 54
 
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56
-        add_action( 'init', array( $this, 'init' ), -1 );
57
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
58
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
59
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
55
+	    $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH);
56
+        add_action('init', array($this, 'init'), -1);
57
+		add_action('wp_logout', array($this, 'destroy_session'));
58
+		add_action('wp', array($this, 'set_customer_session_cookie'), 10);
59
+		add_action('shutdown', array($this, 'save_data'), 20);
60 60
 
61 61
 	}
62 62
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	public function init() {
69 69
 		$this->init_session_cookie();
70 70
 
71
-		if ( ! is_user_logged_in() ) {
72
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 );
71
+		if (!is_user_logged_in()) {
72
+			add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out'), 10, 2);
73 73
 		}
74 74
 	}
75 75
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	public function init_session_cookie() {
82 82
 		$cookie = $this->get_session_cookie();
83 83
 
84
-		if ( $cookie ) {
84
+		if ($cookie) {
85 85
 			$this->_customer_id        = $cookie[0];
86 86
 			$this->_session_expiration = $cookie[1];
87 87
 			$this->_session_expiring   = $cookie[2];
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 			$this->_data               = $this->get_session_data();
90 90
 
91 91
 			// If the user logs in, update session.
92
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
92
+			if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) {
93 93
 				$this->_customer_id = get_current_user_id();
94 94
 				$this->_dirty       = true;
95 95
 				$this->save_data();
96
-				$this->set_customer_session_cookie( true );
96
+				$this->set_customer_session_cookie(true);
97 97
 			}
98 98
 
99 99
 			// Update session if its close to expiring.
100
-			if ( time() > $this->_session_expiring ) {
100
+			if (time() > $this->_session_expiring) {
101 101
 				$this->set_session_expiration();
102
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
102
+				$this->update_session_timestamp($this->_customer_id, $this->_session_expiration);
103 103
 			}
104 104
 		} else {
105 105
 			$this->set_session_expiration();
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param bool $set Should the session cookie be set.
119 119
 	 */
120
-	public function set_customer_session_cookie( $set ) {
121
-		if ( $set ) {
120
+	public function set_customer_session_cookie($set) {
121
+		if ($set) {
122 122
 			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
123
+			$cookie_hash       = hash_hmac('md5', $to_hash, wp_hash($to_hash));
124 124
 			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125 125
 			$this->_has_cookie = true;
126 126
 
127
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
127
+			if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) {
128
+				$this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true);
129 129
 			}
130 130
 		}
131 131
 	}
132 132
 
133
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134
-        if ( ! headers_sent() ) {
135
-            setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
136
-        } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
137
-            headers_sent( $file, $line );
138
-            trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
133
+	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) {
134
+        if (!headers_sent()) {
135
+            setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure));
136
+        } elseif (defined('WP_DEBUG') && WP_DEBUG) {
137
+            headers_sent($file, $line);
138
+            trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine
139 139
         }
140 140
     }
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @return bool
147 147
 	 */
148 148
 	protected function use_secure_cookie() {
149
-        $is_https = false !== strstr( get_option( 'home' ), 'https:' );
150
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
149
+        $is_https = false !== strstr(get_option('home'), 'https:');
150
+		return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl());
151 151
 	}
152 152
 
153 153
 	/**
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 	 * @return bool
157 157
 	 */
158 158
 	public function has_session() {
159
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
159
+		return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160 160
 	}
161 161
 
162 162
 	/**
163 163
 	 * Set session expiration.
164 164
 	 */
165 165
 	public function set_session_expiration() {
166
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
166
+		$this->_session_expiring   = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours.
167
+		$this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours.
168 168
 	}
169 169
 
170 170
 	/**
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function generate_customer_id() {
176 176
 		require_once ABSPATH . 'wp-includes/class-phpass.php';
177
-		$hasher      = new PasswordHash( 8, false );
178
-		return md5( $hasher->get_random_bytes( 32 ) );
177
+		$hasher = new PasswordHash(8, false);
178
+		return md5($hasher->get_random_bytes(32));
179 179
 	}
180 180
 
181 181
 	/**
@@ -186,27 +186,27 @@  discard block
 block discarded – undo
186 186
 	 * @return bool|array
187 187
 	 */
188 188
 	public function get_session_cookie() {
189
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
189
+		$cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine.
190 190
 
191
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
191
+		if (empty($cookie_value) || !is_string($cookie_value)) {
192 192
 			return false;
193 193
 		}
194 194
 
195
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
195
+		list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value);
196 196
 
197
-		if ( empty( $customer_id ) ) {
197
+		if (empty($customer_id)) {
198 198
 			return false;
199 199
 		}
200 200
 
201 201
 		// Validate hash.
202 202
 		$to_hash = $customer_id . '|' . $session_expiration;
203
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
203
+		$hash    = hash_hmac('md5', $to_hash, wp_hash($to_hash));
204 204
 
205
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
205
+		if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) {
206 206
 			return false;
207 207
 		}
208 208
 
209
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
209
+		return array($customer_id, $session_expiration, $session_expiring, $cookie_hash);
210 210
 	}
211 211
 
212 212
 	/**
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 	 * @return array
216 216
 	 */
217 217
 	public function get_session_data() {
218
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
218
+		return $this->has_session() ? (array) $this->get_session($this->_customer_id) : array();
219 219
 	}
220 220
 
221
-	public function generate_key($customer_id){
222
-        if(!$customer_id){
221
+	public function generate_key($customer_id) {
222
+        if (!$customer_id) {
223 223
             return;
224 224
         }
225 225
 
226
-        return 'wpi_trans_'.$customer_id;
226
+        return 'wpi_trans_' . $customer_id;
227 227
     }
228 228
 
229 229
 	/**
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function save_data() {
233 233
 		// Dirty if something changed - prevents saving nothing new.
234
-		if ( $this->_dirty && $this->has_session() ) {
234
+		if ($this->_dirty && $this->has_session()) {
235 235
 
236
-            set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
236
+            set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
237 237
 
238 238
 			$this->_dirty = false;
239 239
 		}
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * Destroy all session data.
244 244
 	 */
245 245
 	public function destroy_session() {
246
-		$this->delete_session( $this->_customer_id );
246
+		$this->delete_session($this->_customer_id);
247 247
 		$this->forget_session();
248 248
 	}
249 249
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Forget all session data without destroying it.
252 252
 	 */
253 253
 	public function forget_session() {
254
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
254
+		$this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true);
255 255
 
256 256
 		wpinv_empty_cart();
257 257
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 	 * @param int $uid User ID.
267 267
 	 * @return string
268 268
 	 */
269
-	public function nonce_user_logged_out( $uid ) {
269
+	public function nonce_user_logged_out($uid) {
270 270
 
271 271
 		// Check if one of our nonces.
272
-		if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) {
272
+		if (substr($uid, 0, 5) === 'wpinv' || substr($uid, 0, 7) === 'getpaid') {
273 273
 			return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
274 274
 		}
275 275
 
@@ -283,20 +283,20 @@  discard block
 block discarded – undo
283 283
 	 * @param mixed  $default Default session value.
284 284
 	 * @return string|array
285 285
 	 */
286
-	public function get_session( $customer_id, $default = false ) {
286
+	public function get_session($customer_id, $default = false) {
287 287
 
288
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
288
+		if (defined('WP_SETUP_CONFIG')) {
289 289
 			return array();
290 290
 		}
291 291
 
292 292
         $key = $this->generate_key($customer_id);
293 293
         $value = get_transient($key);
294 294
 
295
-        if ( !$value ) {
295
+        if (!$value) {
296 296
             $value = $default;
297 297
         }
298 298
 
299
-		return maybe_unserialize( $value );
299
+		return maybe_unserialize($value);
300 300
 	}
301 301
 
302 302
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * @param int $customer_id Customer ID.
306 306
 	 */
307
-	public function delete_session( $customer_id ) {
307
+	public function delete_session($customer_id) {
308 308
 
309 309
         $key = $this->generate_key($customer_id);
310 310
 
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
 	 * @param string $customer_id Customer ID.
318 318
 	 * @param int    $timestamp Timestamp to expire the cookie.
319 319
 	 */
320
-	public function update_session_timestamp( $customer_id, $timestamp ) {
320
+	public function update_session_timestamp($customer_id, $timestamp) {
321 321
 
322
-        set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
322
+        set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp);
323 323
 
324 324
 	}
325 325
 }
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_is_checkout() {
15 15
     global $wp_query;
16 16
 
17
-    $is_object_set    = isset( $wp_query->queried_object );
18
-    $is_object_id_set = isset( $wp_query->queried_object_id );
19
-    $checkout_page    = wpinv_get_option( 'checkout_page' );
20
-    $is_checkout      = ! empty( $checkout_page ) && is_page( $checkout_page );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $checkout_page    = wpinv_get_option('checkout_page');
20
+    $is_checkout      = !empty($checkout_page) && is_page($checkout_page);
21 21
 
22
-    if ( !$is_object_set ) {
23
-        unset( $wp_query->queried_object );
22
+    if (!$is_object_set) {
23
+        unset($wp_query->queried_object);
24 24
     }
25 25
 
26
-    if ( !$is_object_id_set ) {
27
-        unset( $wp_query->queried_object_id );
26
+    if (!$is_object_id_set) {
27
+        unset($wp_query->queried_object_id);
28 28
     }
29 29
 
30
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
30
+    return apply_filters('wpinv_is_checkout', $is_checkout);
31 31
 }
32 32
 
33 33
 function wpinv_can_checkout() {
34 34
 	$can_checkout = true; // Always true for now
35 35
 
36
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36
+	return (bool) apply_filters('wpinv_can_checkout', $can_checkout);
37 37
 }
38 38
 
39 39
 function wpinv_get_success_page_uri() {
40
-	$page_id = wpinv_get_option( 'success_page', 0 );
41
-	$page_id = absint( $page_id );
40
+	$page_id = wpinv_get_option('success_page', 0);
41
+	$page_id = absint($page_id);
42 42
 
43
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
44 44
 }
45 45
 
46 46
 /**
@@ -49,139 +49,139 @@  discard block
 block discarded – undo
49 49
  * @param string $post_type The post type or invoice type.
50 50
  * @return string The history page URL.
51 51
  */
52
-function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) {
53
-    $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) );
54
-	$page_id   = wpinv_get_option( "{$post_type}_history_page", 0 );
55
-	$page_id   = absint( $page_id );
56
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type );
52
+function wpinv_get_history_page_uri($post_type = 'wpi_invoice') {
53
+    $post_type = sanitize_key(str_replace('wpi_', '', $post_type));
54
+	$page_id   = wpinv_get_option("{$post_type}_history_page", 0);
55
+	$page_id   = absint($page_id);
56
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type);
57 57
 }
58 58
 
59 59
 function wpinv_is_success_page() {
60
-	$is_success_page = wpinv_get_option( 'success_page', false );
61
-	$is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
60
+	$is_success_page = wpinv_get_option('success_page', false);
61
+	$is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false;
62 62
 
63
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
63
+	return apply_filters('wpinv_is_success_page', $is_success_page);
64 64
 }
65 65
 
66 66
 function wpinv_is_invoice_history_page() {
67
-	$ret = wpinv_get_option( 'invoice_history_page', false );
68
-	$ret = $ret ? is_page( $ret ) : false;
69
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
67
+	$ret = wpinv_get_option('invoice_history_page', false);
68
+	$ret = $ret ? is_page($ret) : false;
69
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
70 70
 }
71 71
 
72 72
 function wpinv_is_subscriptions_history_page() {
73
-    $ret = wpinv_get_option( 'invoice_subscription_page', false );
74
-    $ret = $ret ? is_page( $ret ) : false;
75
-    return apply_filters( 'wpinv_is_subscriptions_history_page', $ret );
73
+    $ret = wpinv_get_option('invoice_subscription_page', false);
74
+    $ret = $ret ? is_page($ret) : false;
75
+    return apply_filters('wpinv_is_subscriptions_history_page', $ret);
76 76
 }
77 77
 
78 78
 /**
79 79
  * Redirects a user the success page.
80 80
  */
81
-function wpinv_send_to_success_page( $args = array() ) {
81
+function wpinv_send_to_success_page($args = array()) {
82 82
 
83 83
     $redirect = add_query_arg(
84
-        wp_parse_args( $args ),
84
+        wp_parse_args($args),
85 85
         wpinv_get_success_page_uri()
86 86
     );
87 87
 
88
-    $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args );
88
+    $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args);
89 89
 
90
-    wp_redirect( $redirect );
90
+    wp_redirect($redirect);
91 91
     exit;
92 92
 }
93 93
 
94
-function wpinv_send_to_failed_page( $args = null ) {
94
+function wpinv_send_to_failed_page($args = null) {
95 95
 	$redirect = wpinv_get_failed_transaction_uri();
96 96
     
97
-    if ( !empty( $args ) ) {
97
+    if (!empty($args)) {
98 98
         // Check for backward compatibility
99
-        if ( is_string( $args ) )
100
-            $args = str_replace( '?', '', $args );
99
+        if (is_string($args))
100
+            $args = str_replace('?', '', $args);
101 101
 
102
-        $args = wp_parse_args( $args );
102
+        $args = wp_parse_args($args);
103 103
 
104
-        $redirect = add_query_arg( $args, $redirect );
104
+        $redirect = add_query_arg($args, $redirect);
105 105
     }
106 106
 
107
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
107
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
108 108
     
109
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
110
-    wp_redirect( $redirect );
109
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
110
+    wp_redirect($redirect);
111 111
     exit;
112 112
 }
113 113
 
114
-function wpinv_get_checkout_uri( $args = array() ) {
115
-	$uri = wpinv_get_option( 'checkout_page', false );
116
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
114
+function wpinv_get_checkout_uri($args = array()) {
115
+	$uri = wpinv_get_option('checkout_page', false);
116
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
117 117
 
118
-	if ( !empty( $args ) ) {
118
+	if (!empty($args)) {
119 119
 		// Check for backward compatibility
120
-		if ( is_string( $args ) )
121
-			$args = str_replace( '?', '', $args );
120
+		if (is_string($args))
121
+			$args = str_replace('?', '', $args);
122 122
 
123
-		$args = wp_parse_args( $args );
123
+		$args = wp_parse_args($args);
124 124
 
125
-		$uri = add_query_arg( $args, $uri );
125
+		$uri = add_query_arg($args, $uri);
126 126
 	}
127 127
 
128
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
128
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
129 129
 
130
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
130
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
131 131
 
132
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
133
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
132
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
133
+		$uri = preg_replace('/^http:/', 'https:', $uri);
134 134
 	}
135 135
 
136
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
136
+	return apply_filters('wpinv_get_checkout_uri', $uri);
137 137
 }
138 138
 
139
-function wpinv_get_success_page_url( $query_string = null ) {
140
-	$success_page = wpinv_get_option( 'success_page', 0 );
141
-	$success_page = get_permalink( $success_page );
139
+function wpinv_get_success_page_url($query_string = null) {
140
+	$success_page = wpinv_get_option('success_page', 0);
141
+	$success_page = get_permalink($success_page);
142 142
 
143
-	if ( $query_string )
143
+	if ($query_string)
144 144
 		$success_page .= $query_string;
145 145
 
146
-	return apply_filters( 'wpinv_success_page_url', $success_page );
146
+	return apply_filters('wpinv_success_page_url', $success_page);
147 147
 }
148 148
 
149
-function wpinv_get_failed_transaction_uri( $extras = false ) {
150
-	$uri = wpinv_get_option( 'failure_page', '' );
151
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
149
+function wpinv_get_failed_transaction_uri($extras = false) {
150
+	$uri = wpinv_get_option('failure_page', '');
151
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
152 152
 
153
-	if ( $extras )
153
+	if ($extras)
154 154
 		$uri .= $extras;
155 155
 
156
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
156
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
157 157
 }
158 158
 
159 159
 function wpinv_is_failed_transaction_page() {
160
-	$ret = wpinv_get_option( 'failure_page', false );
161
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
160
+	$ret = wpinv_get_option('failure_page', false);
161
+	$ret = isset($ret) ? is_page($ret) : false;
162 162
 
163
-	return apply_filters( 'wpinv_is_failure_page', $ret );
163
+	return apply_filters('wpinv_is_failure_page', $ret);
164 164
 }
165 165
 
166
-function wpinv_transaction_query( $type = 'start' ) {
166
+function wpinv_transaction_query($type = 'start') {
167 167
     global $wpdb;
168 168
 
169 169
     $wpdb->hide_errors();
170 170
 
171
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
172
-        define( 'WPINV_USE_TRANSACTIONS', true );
171
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
172
+        define('WPINV_USE_TRANSACTIONS', true);
173 173
     }
174 174
 
175
-    if ( WPINV_USE_TRANSACTIONS ) {
176
-        switch ( $type ) {
175
+    if (WPINV_USE_TRANSACTIONS) {
176
+        switch ($type) {
177 177
             case 'commit' :
178
-                $wpdb->query( 'COMMIT' );
178
+                $wpdb->query('COMMIT');
179 179
                 break;
180 180
             case 'rollback' :
181
-                $wpdb->query( 'ROLLBACK' );
181
+                $wpdb->query('ROLLBACK');
182 182
                 break;
183 183
             default :
184
-                $wpdb->query( 'START TRANSACTION' );
184
+                $wpdb->query('START TRANSACTION');
185 185
             break;
186 186
         }
187 187
     }
@@ -190,141 +190,141 @@  discard block
 block discarded – undo
190 190
 function wpinv_get_prefix() {
191 191
     $invoice_prefix = 'INV-';
192 192
     
193
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
193
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
194 194
 }
195 195
 
196 196
 function wpinv_get_business_logo() {
197
-    $business_logo = wpinv_get_option( 'logo' );
198
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
197
+    $business_logo = wpinv_get_option('logo');
198
+    return apply_filters('wpinv_get_business_logo', $business_logo);
199 199
 }
200 200
 
201 201
 function wpinv_get_business_name() {
202
-    $business_name = wpinv_get_option('store_name', wpinv_get_blogname() );
203
-    return apply_filters( 'wpinv_get_business_name', $business_name );
202
+    $business_name = wpinv_get_option('store_name', wpinv_get_blogname());
203
+    return apply_filters('wpinv_get_business_name', $business_name);
204 204
 }
205 205
 
206 206
 function wpinv_get_blogname() {
207
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
207
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
208 208
 }
209 209
 
210 210
 function wpinv_get_admin_email() {
211
-    $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) );
212
-    return apply_filters( 'wpinv_admin_email', $admin_email );
211
+    $admin_email = wpinv_get_option('admin_email', get_option('admin_email'));
212
+    return apply_filters('wpinv_admin_email', $admin_email);
213 213
 }
214 214
 
215 215
 function wpinv_get_business_website() {
216
-    $business_website = home_url( '/' );
217
-    return apply_filters( 'wpinv_get_business_website', $business_website );
216
+    $business_website = home_url('/');
217
+    return apply_filters('wpinv_get_business_website', $business_website);
218 218
 }
219 219
 
220
-function wpinv_get_terms_text( $invoice_id = 0 ) {
220
+function wpinv_get_terms_text($invoice_id = 0) {
221 221
     $terms_text = '';
222
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
222
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
223 223
 }
224 224
 
225 225
 function wpinv_get_business_footer() {
226
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
227
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
228
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
226
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
227
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
228
+    return apply_filters('wpinv_get_business_footer', $business_footer);
229 229
 }
230 230
 
231 231
 function wpinv_checkout_required_fields() {
232 232
     $required_fields = array();
233 233
     
234 234
     // Let payment gateways and other extensions determine if address fields should be required
235
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
235
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
236 236
     
237
-    if ( $require_billing_details ) {
238
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
237
+    if ($require_billing_details) {
238
+		if ((bool) wpinv_get_option('fname_mandatory')) {
239 239
 			$required_fields['first_name'] = array(
240 240
 				'error_id' => 'invalid_first_name',
241
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
241
+				'error_message' => __('Please enter your first name', 'invoicing')
242 242
 			);
243 243
 		}
244
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
244
+		if ((bool) wpinv_get_option('address_mandatory')) {
245 245
 			$required_fields['address'] = array(
246 246
 				'error_id' => 'invalid_address',
247
-				'error_message' => __( 'Please enter your address', 'invoicing' )
247
+				'error_message' => __('Please enter your address', 'invoicing')
248 248
 			);
249 249
 		}
250
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
250
+		if ((bool) wpinv_get_option('city_mandatory')) {
251 251
 			$required_fields['city'] = array(
252 252
 				'error_id' => 'invalid_city',
253
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
253
+				'error_message' => __('Please enter your billing city', 'invoicing')
254 254
 			);
255 255
 		}
256
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
256
+		if ((bool) wpinv_get_option('state_mandatory')) {
257 257
 			$required_fields['state'] = array(
258 258
 				'error_id' => 'invalid_state',
259
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
259
+				'error_message' => __('Please enter billing state / province', 'invoicing')
260 260
 			);
261 261
 		}
262
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
262
+		if ((bool) wpinv_get_option('country_mandatory')) {
263 263
 			$required_fields['country'] = array(
264 264
 				'error_id' => 'invalid_country',
265
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
265
+				'error_message' => __('Please select your billing country', 'invoicing')
266 266
 			);
267 267
 		}
268 268
     }
269 269
 
270
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
270
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
271 271
 }
272 272
 
273 273
 function wpinv_is_ssl_enforced() {
274
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
275
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
274
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
275
+    return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
276 276
 }
277 277
 
278 278
 function wpinv_schedule_event_twicedaily() {
279 279
     wpinv_email_payment_reminders();
280 280
 }
281
-add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' );
281
+add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily');
282 282
 
283 283
 function wpinv_require_login_to_checkout() {
284
-    $return = wpinv_get_option( 'login_to_checkout', false );
285
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
284
+    $return = wpinv_get_option('login_to_checkout', false);
285
+    return (bool) apply_filters('wpinv_require_login_to_checkout', $return);
286 286
 }
287 287
 
288
-function wpinv_sequential_number_active( $type = '' ) {
289
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
290
-    if ( null !== $check ) {
288
+function wpinv_sequential_number_active($type = '') {
289
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
290
+    if (null !== $check) {
291 291
         return $check;
292 292
     }
293 293
     
294
-    return wpinv_get_option( 'sequential_invoice_number' );
294
+    return wpinv_get_option('sequential_invoice_number');
295 295
 }
296 296
 
297
-function wpinv_switch_to_locale( $locale = NULL ) {
297
+function wpinv_switch_to_locale($locale = NULL) {
298 298
     global $invoicing, $wpi_switch_locale;
299 299
 
300
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
301
-        $locale = empty( $locale ) ? get_locale() : $locale;
300
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
301
+        $locale = empty($locale) ? get_locale() : $locale;
302 302
 
303
-        switch_to_locale( $locale );
303
+        switch_to_locale($locale);
304 304
 
305 305
         $wpi_switch_locale = $locale;
306 306
 
307
-        add_filter( 'plugin_locale', 'get_locale' );
307
+        add_filter('plugin_locale', 'get_locale');
308 308
 
309 309
         $invoicing->load_textdomain();
310 310
 
311
-        do_action( 'wpinv_switch_to_locale', $locale );
311
+        do_action('wpinv_switch_to_locale', $locale);
312 312
     }
313 313
 }
314 314
 
315 315
 function wpinv_restore_locale() {
316 316
     global $invoicing, $wpi_switch_locale;
317 317
     
318
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
318
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
319 319
         restore_previous_locale();
320 320
 
321 321
         $wpi_switch_locale = NULL;
322 322
 
323
-        remove_filter( 'plugin_locale', 'get_locale' );
323
+        remove_filter('plugin_locale', 'get_locale');
324 324
 
325 325
         $invoicing->load_textdomain();
326 326
 
327
-        do_action( 'wpinv_restore_locale' );
327
+        do_action('wpinv_restore_locale');
328 328
     }
329 329
 }
330 330
 
@@ -332,26 +332,26 @@  discard block
 block discarded – undo
332 332
  * Returns the default form's id.
333 333
  */
334 334
 function wpinv_get_default_payment_form() {
335
-    $form = get_option( 'wpinv_default_payment_form' );
335
+    $form = get_option('wpinv_default_payment_form');
336 336
 
337
-    if ( empty( $form ) || 'publish' != get_post_status( $form ) ) {
337
+    if (empty($form) || 'publish' != get_post_status($form)) {
338 338
         $form = wp_insert_post(
339 339
             array(
340 340
                 'post_type'   => 'wpi_payment_form',
341
-                'post_title'  => __( 'Checkout (default)', 'invoicing' ),
341
+                'post_title'  => __('Checkout (default)', 'invoicing'),
342 342
                 'post_status' => 'publish',
343 343
                 'meta_input'  => array(
344
-                    'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ),
344
+                    'wpinv_form_elements' => wpinv_get_data('default-payment-form'),
345 345
                     'wpinv_form_items'    => array(),
346 346
                 )
347 347
             )
348 348
         );
349 349
 
350
-        update_option( 'wpinv_default_payment_form', $form );
350
+        update_option('wpinv_default_payment_form', $form);
351 351
     }
352 352
 
353 353
     // WPML support.
354
-    $form = apply_filters( 'wpml_object_id', $form, 'wpi_payment_form', TRUE  );
354
+    $form = apply_filters('wpml_object_id', $form, 'wpi_payment_form', TRUE);
355 355
     return $form;
356 356
 }
357 357
 
@@ -360,19 +360,19 @@  discard block
 block discarded – undo
360 360
  * 
361 361
  * @param int $payment_form
362 362
  */
363
-function getpaid_get_payment_form_elements( $payment_form ) {
363
+function getpaid_get_payment_form_elements($payment_form) {
364 364
 
365
-    if ( empty( $payment_form ) ) {
366
-        return wpinv_get_data( 'sample-payment-form' );
365
+    if (empty($payment_form)) {
366
+        return wpinv_get_data('sample-payment-form');
367 367
     }
368 368
 
369
-    $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true );
369
+    $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true);
370 370
 
371
-    if ( is_array( $form_elements ) ) {
371
+    if (is_array($form_elements)) {
372 372
         return $form_elements;
373 373
     }
374 374
 
375
-    return wpinv_get_data( 'sample-payment-form' );
375
+    return wpinv_get_data('sample-payment-form');
376 376
 
377 377
 }
378 378
 
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
  * 
382 382
  * @param int $payment_form
383 383
  */
384
-function gepaid_get_form_items( $id ) {
385
-    $form = new GetPaid_Payment_Form( $id );
384
+function gepaid_get_form_items($id) {
385
+    $form = new GetPaid_Payment_Form($id);
386 386
 
387 387
     // Is this a default form?
388
-    if ( $form->is_default() ) {
388
+    if ($form->is_default()) {
389 389
         return array();
390 390
     }
391 391
 
392
-    return $form->get_items( 'view', 'arrays' );
392
+    return $form->get_items('view', 'arrays');
393 393
 }
Please login to merge, or discard this patch.
templates/subscriptions/subscription-details.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
  * @var WPInv_Subscriptions_Widget $widget
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14
-do_action( 'getpaid_single_subscription_before_notices', $subscription );
14
+do_action('getpaid_single_subscription_before_notices', $subscription);
15 15
 
16 16
 // Display errors and notices.
17 17
 wpinv_print_errors();
18 18
 
19
-do_action( 'getpaid_before_single_subscription', $subscription );
19
+do_action('getpaid_before_single_subscription', $subscription);
20 20
 
21 21
 ?>
22 22
 
@@ -28,44 +28,44 @@  discard block
 block discarded – undo
28 28
 
29 29
 </style>
30 30
 
31
-<h2 class="mb-1 h4"><?php _e( 'Subscription Details', 'invoicing' ); ?></h2>
31
+<h2 class="mb-1 h4"><?php _e('Subscription Details', 'invoicing'); ?></h2>
32 32
 <table class="table table-bordered">
33 33
 	<tbody>
34 34
 
35
-		<?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?>
35
+		<?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?>
36 36
 
37
-			<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
37
+			<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
38 38
 
39 39
 				<th class="w-25 font-weight-bold">
40
-					<?php echo sanitize_text_field( $label ); ?>
40
+					<?php echo sanitize_text_field($label); ?>
41 41
 				</th>
42 42
 
43 43
 				<td class="w-75">
44 44
 					<?php
45 45
 
46
-						switch ( $key ) {
46
+						switch ($key) {
47 47
 
48 48
 							case 'status':
49
-								echo sanitize_text_field( $subscription->get_status_label() );
49
+								echo sanitize_text_field($subscription->get_status_label());
50 50
 								break;
51 51
 
52 52
 							case 'start_date':
53
-								echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) );
53
+								echo sanitize_text_field(getpaid_format_date_value($subscription->get_date_created()));
54 54
 								break;
55 55
 
56 56
 							case 'expiry_date':
57
-								echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
57
+								echo sanitize_text_field(getpaid_format_date_value($subscription->get_next_renewal_date()));
58 58
 								break;
59 59
 
60 60
 							case 'initial_amount':
61
-								echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
61
+								echo wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
62 62
 
63
-								if ( $subscription->has_trial_period() ) {
63
+								if ($subscription->has_trial_period()) {
64 64
 
65 65
 									echo "<small class='text-muted'>&nbsp;";
66 66
 									printf(
67
-										_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
68
-										sanitize_text_field( $subscription->get_trial_period() )
67
+										_x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'),
68
+										sanitize_text_field($subscription->get_trial_period())
69 69
 									);
70 70
 									echo '</small>';
71 71
 
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 								break;
75 75
 
76 76
 							case 'recurring_amount':
77
-								$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
78
-								$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
79
-								echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
77
+								$frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
78
+								$amount    = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency());
79
+								echo strtolower("<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>");
80 80
 								break;
81 81
 
82 82
 							case 'item':
83
-								$item = get_post( $subscription->get_product_id() );
83
+								$item = get_post($subscription->get_product_id());
84 84
 
85
-								if ( ! empty( $item ) ) {
86
-									echo esc_html( get_the_title( $item ) );
85
+								if (!empty($item)) {
86
+									echo esc_html(get_the_title($item));
87 87
 								} else {
88
-									echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
88
+									echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id());
89 89
 								}
90 90
 
91 91
 								break;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 							case 'payments':
94 94
 
95 95
 								$max_activations = (int) $subscription->get_bill_times();
96
-								echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "&infin;" : $max_activations );
96
+								echo (int) $subscription->get_times_billed() . ' / ' . (empty($max_activations) ? "&infin;" : $max_activations);
97 97
 
98 98
 								break;
99 99
 
100 100
 						}
101
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
101
+						do_action("getpaid_render_single_subscription_column_$key", $subscription);
102 102
 
103 103
 					?>
104 104
 				</td>
@@ -110,24 +110,24 @@  discard block
 block discarded – undo
110 110
 	</tbody>
111 111
 </table>
112 112
 
113
-<h2 class='mt-5 mb-1 h4'><?php _e( 'Subscription Invoices', 'invoicing' ); ?></h2>
113
+<h2 class='mt-5 mb-1 h4'><?php _e('Subscription Invoices', 'invoicing'); ?></h2>
114 114
 
115
-<?php echo getpaid_admin_subscription_invoice_details_metabox( $subscription ); ?>
115
+<?php echo getpaid_admin_subscription_invoice_details_metabox($subscription); ?>
116 116
 
117 117
 <span class="form-text">
118 118
 
119 119
 	<?php
120
-		if ( $subscription->can_cancel() ) {
120
+		if ($subscription->can_cancel()) {
121 121
 			printf(
122 122
 				'<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
123
-				esc_url( $subscription->get_cancel_url() ),
124
-				esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
125
-				__( 'Cancel Subscription', 'invoicing' )
123
+				esc_url($subscription->get_cancel_url()),
124
+				esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'),
125
+				__('Cancel Subscription', 'invoicing')
126 126
 			);
127 127
 		}
128 128
 
129
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
129
+		do_action('getpaid-single-subscription-page-actions', $subscription);
130 130
 	?>
131 131
 
132
-	<a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a>
132
+	<a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php _e('Go Back', 'invoicing'); ?></a>
133 133
 </span>
134 134
\ No newline at end of file
Please login to merge, or discard this patch.
templates/subscriptions/subscriptions-table-row.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,45 +9,45 @@
 block discarded – undo
9 9
  * @var WPInv_Subscriptions_Widget $widget
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14
-foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) :
14
+foreach (array_keys($widget->get_subscriptions_table_columns()) as $column) :
15 15
 
16
-	$class = sanitize_html_class( $column );
16
+	$class = sanitize_html_class($column);
17 17
 	echo "<td class='getpaid-subscriptions-table-column-$class'>";
18 18
 
19
-		do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription );
19
+		do_action("getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription);
20 20
 
21
-		switch( $column ) :
21
+		switch ($column) :
22 22
 
23 23
 			case 'subscription':
24 24
 				$subscription_id = (int) $subscription->get_id();
25
-				$url             = esc_url( $subscription->get_view_url() );
25
+				$url             = esc_url($subscription->get_view_url());
26 26
 				$id_label        = sprintf(
27
-					esc_attr_x( '#%s', 'subscription id', 'invoicing' ),
27
+					esc_attr_x('#%s', 'subscription id', 'invoicing'),
28 28
 					$subscription->get_id()
29 29
 				);
30
-				echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription );
30
+				echo $widget->add_row_actions("<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription);
31 31
 				break;
32 32
 
33 33
 			case 'status':
34
-				echo sanitize_text_field( $subscription->get_status_label() );
34
+				echo sanitize_text_field($subscription->get_status_label());
35 35
 				break;
36 36
 
37 37
 			case 'renewal-date':
38
-				$renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() );
39
-				echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "&mdash;";
38
+				$renewal = getpaid_format_date_value($subscription->get_next_renewal_date());
39
+				echo $subscription->is_active() ? sanitize_text_field($renewal) : "&mdash;";
40 40
 				break;
41 41
 
42 42
 			case 'amount':
43
-				$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
44
-				$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
45
-				echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
43
+				$frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
44
+				$amount    = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency());
45
+				echo wp_kses_post("<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>");
46 46
 				break;
47 47
 
48 48
 		endswitch;
49 49
 
50
-		do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription );
50
+		do_action("getpaid_subscriptions_frontend_subscription_table_$column", $subscription);
51 51
 
52 52
 	echo '</td>';
53 53
 
Please login to merge, or discard this patch.