Passed
Push — master ( 9e37cd...7382ee )
by Brian
09:54
created
includes/data/admin-settings.php 1 patch
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -8,211 +8,211 @@  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 13
 $getpaid_pages = GetPaid_Installer::get_pages();
14
-$pages         = wpinv_get_pages( true );
14
+$pages         = wpinv_get_pages(true);
15 15
     
16 16
 $currencies = wpinv_get_currencies();
17 17
     
18 18
 $currency_code_options = array();
19
-foreach ( $currencies as $code => $name ) {
20
-    $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
19
+foreach ($currencies as $code => $name) {
20
+    $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
21 21
 }
22 22
 
23 23
 $invoice_number_padd_options = array();
24
-for ( $i = 0; $i <= 20; $i++ ) {
24
+for ($i = 0; $i <= 20; $i++) {
25 25
     $invoice_number_padd_options[$i] = $i;
26 26
 }
27 27
     
28 28
 $currency_symbol = wpinv_currency_symbol();
29 29
     
30 30
 $last_number = $reset_number = '';
31
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
32
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
31
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
32
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
33 33
 
34
-    if ( !empty( $last_invoice_number ) ) {
35
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
34
+    if (!empty($last_invoice_number)) {
35
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
36 36
     }
37 37
 
38 38
     $nonce = wp_create_nonce('reset_invoice_count');
39
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
39
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
40 40
 }
41 41
     
42 42
 $alert_wrapper_start = '<p style="color: #F00">';
43 43
 $alert_wrapper_close = '</p>';
44 44
 
45 45
 return array(
46
-    'general' => apply_filters( 'wpinv_settings_general',
46
+    'general' => apply_filters('wpinv_settings_general',
47 47
         array(
48 48
             'main' => array(
49 49
                 'location_settings' => array(
50 50
                     'id'   => 'location_settings',
51
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
51
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
52 52
                     'desc' => '',
53 53
                     'type' => 'header',
54 54
                 ),
55 55
                 'default_country' => array(
56 56
                     'id'      => 'default_country',
57
-                    'name'    => __( 'Default Country', 'invoicing' ),
58
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
57
+                    'name'    => __('Default Country', 'invoicing'),
58
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
59 59
                     'type'    => 'select',
60 60
                     'options' => wpinv_get_country_list(),
61 61
                     'std'     => 'GB',
62 62
                     'class'   => 'wpi_select2',
63
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
63
+                    'placeholder' => __('Select a country', 'invoicing'),
64 64
                 ),
65 65
                 'default_state' => array(
66 66
                     'id'      => 'default_state',
67
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
68
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
67
+                    'name'    => __('Default State / Province', 'invoicing'),
68
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
69 69
                     'type'    => 'country_states',
70 70
                     'class'   => 'wpi_select2',
71
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
71
+                    'placeholder' => __('Select a state', 'invoicing'),
72 72
                 ),
73 73
                 'store_name' => array(
74 74
                     'id'   => 'store_name',
75
-                    'name' => __( 'Store Name', 'invoicing' ),
76
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
75
+                    'name' => __('Store Name', 'invoicing'),
76
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
77 77
                     'std'     => get_option('blogname'),
78 78
                     'type' => 'text',
79 79
                 ),
80 80
                 'logo' => array(
81 81
                     'id'   => 'logo',
82
-                    'name' => __( 'Logo URL', 'invoicing' ),
83
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
82
+                    'name' => __('Logo URL', 'invoicing'),
83
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
84 84
                     'type' => 'text',
85 85
                 ),
86 86
                 'logo_width'      => array(
87 87
                     'id'          => 'logo_width',
88
-                    'name'        => __( 'Logo width', 'invoicing' ),
89
-                    'desc'        => __( 'Logo width to use in invoice image.', 'invoicing' ),
88
+                    'name'        => __('Logo width', 'invoicing'),
89
+                    'desc'        => __('Logo width to use in invoice image.', 'invoicing'),
90 90
                     'type'        => 'number',
91
-                    'placeholder' => __( 'Auto', 'invoicing' ),
91
+                    'placeholder' => __('Auto', 'invoicing'),
92 92
                 ),
93 93
                 'logo_height'     => array(
94 94
                     'id'          => 'logo_height',
95
-                    'name'        => __( 'Logo height', 'invoicing' ),
96
-                    'desc'        => __( 'Logo height to use in invoice image.', 'invoicing' ),
95
+                    'name'        => __('Logo height', 'invoicing'),
96
+                    'desc'        => __('Logo height to use in invoice image.', 'invoicing'),
97 97
                     'type'        => 'number',
98
-                    'placeholder' => __( 'Auto', 'invoicing' ),
98
+                    'placeholder' => __('Auto', 'invoicing'),
99 99
                 ),
100 100
                 'store_address' => array(
101 101
                     'id'   => 'store_address',
102
-                    'name' => __( 'Store Address', 'invoicing' ),
103
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
102
+                    'name' => __('Store Address', 'invoicing'),
103
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
104 104
                     'type' => 'textarea',
105 105
                 ),
106 106
                 'page_settings' => array(
107 107
                     'id'   => 'page_settings',
108
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
108
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
109 109
                     'desc' => '',
110 110
                     'type' => 'header',
111 111
                 ),
112 112
                 'checkout_page' => array(
113 113
                     'id'          => 'checkout_page',
114
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
115
-                    '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' ),
114
+                    'name'        => __('Checkout Page', 'invoicing'),
115
+                    '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'),
116 116
                     'type'        => 'select',
117 117
                     'options'     => $pages,
118 118
                     'class'       => 'wpi_select2',
119
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
120
-                    'default_content' => empty( $getpaid_pages['checkout_page'] ) ? '' : $getpaid_pages['checkout_page']['content'],
119
+                    'placeholder' => __('Select a page', 'invoicing'),
120
+                    'default_content' => empty($getpaid_pages['checkout_page']) ? '' : $getpaid_pages['checkout_page']['content'],
121 121
                     'help-tip'    => true,
122 122
                 ),
123 123
                 'success_page' => array(
124 124
                     'id'          => 'success_page',
125
-                    'name'        => __( 'Success Page', 'invoicing' ),
126
-                    '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' ),
125
+                    'name'        => __('Success Page', 'invoicing'),
126
+                    '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'),
127 127
                     'type'        => 'select',
128 128
                     'options'     => $pages,
129 129
                     'class'       => 'wpi_select2',
130
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
131
-                    'default_content' => empty( $getpaid_pages['success_page'] ) ? '' : $getpaid_pages['success_page']['content'],
130
+                    'placeholder' => __('Select a page', 'invoicing'),
131
+                    'default_content' => empty($getpaid_pages['success_page']) ? '' : $getpaid_pages['success_page']['content'],
132 132
                     'help-tip'    => true,
133 133
                 ),
134 134
                 'failure_page' => array(
135 135
                     'id'          => 'failure_page',
136
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
137
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
136
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
137
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
138 138
                     'type'        => 'select',
139 139
                     'options'     => $pages,
140 140
                     'class'       => 'wpi_select2',
141
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
142
-                    'default_content' => empty( $getpaid_pages['failure_page'] ) ? '' : $getpaid_pages['failure_page']['content'],
141
+                    'placeholder' => __('Select a page', 'invoicing'),
142
+                    'default_content' => empty($getpaid_pages['failure_page']) ? '' : $getpaid_pages['failure_page']['content'],
143 143
                     'help-tip'    => true,
144 144
                 ),
145 145
                 'invoice_history_page' => array(
146 146
                     'id'          => 'invoice_history_page',
147
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
148
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
147
+                    'name'        => __('Invoice History Page', 'invoicing'),
148
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
149 149
                     'type'        => 'select',
150 150
                     'options'     => $pages,
151 151
                     'class'       => 'wpi_select2',
152
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
153
-                    'default_content' => empty( $getpaid_pages['invoice_history_page'] ) ? '' : $getpaid_pages['invoice_history_page']['content'],
152
+                    'placeholder' => __('Select a page', 'invoicing'),
153
+                    'default_content' => empty($getpaid_pages['invoice_history_page']) ? '' : $getpaid_pages['invoice_history_page']['content'],
154 154
                     'help-tip'    => true,
155 155
                 ),
156 156
                 'invoice_subscription_page' => array(
157 157
                     'id'          => 'invoice_subscription_page',
158
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
159
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
158
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
159
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
160 160
                     'type'        => 'select',
161 161
                     'options'     => $pages,
162 162
                     'class'       => 'wpi_select2',
163
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
164
-                    'default_content' => empty( $getpaid_pages['invoice_subscription_page'] ) ? '' : $getpaid_pages['invoice_subscription_page']['content'],
163
+                    'placeholder' => __('Select a page', 'invoicing'),
164
+                    'default_content' => empty($getpaid_pages['invoice_subscription_page']) ? '' : $getpaid_pages['invoice_subscription_page']['content'],
165 165
                     'help-tip'    => true,
166 166
                 ),
167 167
             ),
168 168
             'currency_section' => array(
169 169
                 'currency_settings' => array(
170 170
                     'id'   => 'currency_settings',
171
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
171
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
172 172
                     'desc' => '',
173 173
                     'type' => 'header',
174 174
                 ),
175 175
                 'currency' => array(
176 176
                     'id'      => 'currency',
177
-                    'name'    => __( 'Currency', 'invoicing' ),
178
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
177
+                    'name'    => __('Currency', 'invoicing'),
178
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
179 179
                     'type'    => 'select',
180 180
                     'class'       => 'wpi_select2',
181 181
                     'options' => $currency_code_options,
182 182
                 ),
183 183
                 'currency_position' => array(
184 184
                     'id'      => 'currency_position',
185
-                    'name'    => __( 'Currency Position', 'invoicing' ),
186
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
185
+                    'name'    => __('Currency Position', 'invoicing'),
186
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
187 187
                     'type'    => 'select',
188 188
                     'class'   => 'wpi_select2',
189 189
                     'options'  => array(
190
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
191
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
192
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
193
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
190
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
191
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
192
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
193
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
194 194
                     )
195 195
                 ),
196 196
                 'thousands_separator' => array(
197 197
                     'id'   => 'thousands_separator',
198
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
199
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
198
+                    'name' => __('Thousands Separator', 'invoicing'),
199
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
200 200
                     'type' => 'text',
201 201
                     'size' => 'small',
202 202
                     'std'  => ',',
203 203
                 ),
204 204
                 'decimal_separator' => array(
205 205
                     'id'   => 'decimal_separator',
206
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
207
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
206
+                    'name' => __('Decimal Separator', 'invoicing'),
207
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
208 208
                     'type' => 'text',
209 209
                     'size' => 'small',
210 210
                     'std'  => '.',
211 211
                 ),
212 212
                 'decimals' => array(
213 213
                     'id'   => 'decimals',
214
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
215
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
214
+                    'name' => __('Number of Decimals', 'invoicing'),
215
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
216 216
                     'type' => 'number',
217 217
                     'size' => 'small',
218 218
                     'std'  => '2',
@@ -224,21 +224,21 @@  discard block
 block discarded – undo
224 224
             'labels' => array(
225 225
                 'labels' => array(
226 226
                     'id'   => 'labels_settings',
227
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
227
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
228 228
                     'desc' => '',
229 229
                     'type' => 'header',
230 230
                 ),
231 231
                 'vat_invoice_notice_label' => array(
232 232
                     'id' => 'vat_invoice_notice_label',
233
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
234
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
233
+                    'name' => __('Invoice Notice Label', 'invoicing'),
234
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
235 235
                     'type' => 'text',
236 236
                     'size' => 'regular',
237 237
                 ),
238 238
                 'vat_invoice_notice' => array(
239 239
                     'id' => 'vat_invoice_notice',
240
-                    'name' => __( 'Invoice notice', 'invoicing' ),
241
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
240
+                    'name' => __('Invoice notice', 'invoicing'),
241
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
242 242
                     'type' => 'text',
243 243
                     'size' => 'regular',
244 244
                 ),
@@ -250,22 +250,22 @@  discard block
 block discarded – undo
250 250
             'main' => array(
251 251
                 'gateway_settings' => array(
252 252
                     'id'   => 'api_header',
253
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
253
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
254 254
                     'desc' => '',
255 255
                     'type' => 'header',
256 256
                 ),
257 257
                 'gateways' => array(
258 258
                     'id'      => 'gateways',
259
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
260
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
259
+                    'name'    => __('Payment Gateways', 'invoicing'),
260
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
261 261
                     'type'    => 'gateways',
262
-                    'std'     => array( 'manual'=>1 ),
262
+                    'std'     => array('manual'=>1),
263 263
                     'options' => wpinv_get_payment_gateways(),
264 264
                 ),
265 265
                 'default_gateway' => array(
266 266
                     'id'      => 'default_gateway',
267
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
268
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
267
+                    'name'    => __('Default Gateway', 'invoicing'),
268
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
269 269
                     'type'    => 'gateway_select',
270 270
                     'std'     => 'manual',
271 271
                     'class'   => 'wpi_select2',
@@ -280,32 +280,32 @@  discard block
 block discarded – undo
280 280
             'main' => array(
281 281
                 'tax_settings' => array(
282 282
                     'id'   => 'tax_settings',
283
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
283
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
284 284
                     'type' => 'header',
285 285
                 ),
286 286
 
287 287
                 'enable_taxes' => array(
288 288
                     'id'       => 'enable_taxes',
289
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
290
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
289
+                    'name'     => __('Enable Taxes', 'invoicing'),
290
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
291 291
                     'type'     => 'checkbox',
292 292
                     'std'      => 0,
293 293
                 ),
294 294
 
295 295
                 'tax_subtotal_rounding' => array(
296 296
                     'id'                => 'tax_subtotal_rounding',
297
-                    'name'              => __( 'Rounding', 'invoicing' ),
298
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
297
+                    'name'              => __('Rounding', 'invoicing'),
298
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
299 299
                     'type'              => 'checkbox',
300 300
                     'std'               => 1,
301 301
                 ),
302 302
 
303 303
                 'prices_include_tax' => array(
304 304
                     'id'      => 'prices_include_tax',
305
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
305
+                    'name'    => __('Prices entered with tax', 'invoicing'),
306 306
                     'options' => array(
307
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
308
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
307
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
308
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
309 309
                     ),
310 310
                     'type'    => 'select',
311 311
                     'std'     => 'no',
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 
314 314
                 'tax_base'              => array(
315 315
                     'id'                => 'tax_base',
316
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
316
+                    'name'              => __('Calculate tax based on', 'invoicing'),
317 317
                     'options'           => array(
318
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
319
-                        'base'          => __( 'Shop base address', 'invoicing' ),
318
+                        'billing'       => __('Customer billing address', 'invoicing'),
319
+                        'base'          => __('Shop base address', 'invoicing'),
320 320
                     ),
321 321
                     'type'              => 'select',
322 322
                     'std'               => 'billing',
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 
325 325
                 'tax_display_totals'    => array(
326 326
                     'id'                => 'tax_display_totals',
327
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
327
+                    'name'              => __('Display tax totals', 'invoicing'),
328 328
                     'options'           => array(
329
-                        'single'        => __( 'As a single total', 'invoicing' ),
330
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
329
+                        'single'        => __('As a single total', 'invoicing'),
330
+                        'individual'    => __('As individual tax rates', 'invoicing'),
331 331
                     ),
332 332
                     'type'              => 'select',
333 333
                     'std'               => 'individual',
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
 
336 336
                 'tax_rate' => array(
337 337
                     'id'   => 'tax_rate',
338
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
339
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
338
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
339
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
340 340
                     'type' => 'number',
341 341
                     'size' => 'small',
342 342
                     'min'  => '0',
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
             'rates' => array(
349 349
                 'tax_rates' => array(
350 350
                     'id'   => 'tax_rates',
351
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
352
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
351
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
352
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
353 353
                     'type' => 'tax_rates',
354 354
                 ),
355 355
             ),
@@ -358,45 +358,45 @@  discard block
 block discarded – undo
358 358
 
359 359
                 'vat_company_name' => array(
360 360
                     'id' => 'vat_company_name',
361
-                    'name' => __( 'Company Name', 'invoicing' ),
362
-                    '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>' ),
361
+                    'name' => __('Company Name', 'invoicing'),
362
+                    '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>'),
363 363
                     'type' => 'text',
364 364
                     'size' => 'regular',
365 365
                 ),
366 366
 
367 367
                 'vat_number' => array(
368 368
                     'id'   => 'vat_number',
369
-                    'name' => __( 'VAT Number', 'invoicing' ),
370
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
369
+                    'name' => __('VAT Number', 'invoicing'),
370
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
371 371
                     'type' => 'text',
372 372
                     'size' => 'regular',
373 373
                 ),
374 374
 
375 375
                 'vat_prevent_b2c_purchase' => array(
376 376
                     'id' => 'vat_prevent_b2c_purchase',
377
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
378
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
377
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
378
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
379 379
                     'type' => 'checkbox'
380 380
                 ),
381 381
 
382 382
                 'validate_vat_number' => array(
383 383
                     'id'   => 'validate_vat_number',
384
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
385
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
384
+                    'name' => __('Validate VAT Number', 'invoicing'),
385
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
386 386
                     'type' => 'checkbox'
387 387
                 ),
388 388
 
389 389
                 'vat_same_country_rule' => array(
390 390
                     'id'          => 'vat_same_country_rule',
391
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
392
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
391
+                    'name'        => __('Same Country Rule', 'invoicing'),
392
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
393 393
                     'type'        => 'select',
394 394
                     'options'     => array(
395
-                        'no'        => __( 'Do not charge tax', 'invoicing' ),
396
-                        'always'    => __( 'Charge tax unless vat number is validated', 'invoicing' ),
397
-                        'vat_too'   => __( 'Charge tax even if vat number is validated', 'invoicing' )
395
+                        'no'        => __('Do not charge tax', 'invoicing'),
396
+                        'always'    => __('Charge tax unless vat number is validated', 'invoicing'),
397
+                        'vat_too'   => __('Charge tax even if vat number is validated', 'invoicing')
398 398
                     ),
399
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
399
+                    'placeholder' => __('Select an option', 'invoicing'),
400 400
                     'std'         => 'vat_too',
401 401
                 ),
402 402
 
@@ -410,59 +410,59 @@  discard block
 block discarded – undo
410 410
             'main' => array(
411 411
                 'email_settings_header' => array(
412 412
                     'id'   => 'email_settings_header',
413
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
413
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
414 414
                     'type' => 'header',
415 415
                 ),
416 416
                 'email_from_name' => array(
417 417
                     'id'   => 'email_from_name',
418
-                    'name' => __( 'From Name', 'invoicing' ),
419
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
420
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
418
+                    'name' => __('From Name', 'invoicing'),
419
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
420
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
421 421
                     'type' => 'text',
422 422
                 ),
423 423
                 'email_from' => array(
424 424
                     'id'   => 'email_from',
425
-                    'name' => __( 'From Email', 'invoicing' ),
426
-                    'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" 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),
427
-                    'std' => get_option( 'admin_email' ),
425
+                    'name' => __('From Email', 'invoicing'),
426
+                    'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" 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),
427
+                    'std' => get_option('admin_email'),
428 428
                     'type' => 'text',
429 429
                 ),
430 430
                 'admin_email' => array(
431 431
                     'id'   => 'admin_email',
432
-                    'name' => __( 'Admin Email', 'invoicing' ),
433
-                    'desc' => __( 'Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing' ),
434
-                    'std' => get_option( 'admin_email' ),
432
+                    'name' => __('Admin Email', 'invoicing'),
433
+                    'desc' => __('Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing'),
434
+                    'std' => get_option('admin_email'),
435 435
                     'type' => 'text',
436 436
                 ),
437 437
                 'overdue_settings_header' => array(
438 438
                     'id'   => 'overdue_settings_header',
439
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
439
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
440 440
                     'type' => 'header',
441 441
                 ),
442 442
                 'overdue_active' => array(
443 443
                     'id'   => 'overdue_active',
444
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
445
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
444
+                    'name' => __('Enable Due Date', 'invoicing'),
445
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
446 446
                     'type' => 'checkbox',
447 447
                     'std'  => false,
448 448
                 ),
449 449
                 'email_template_header' => array(
450 450
                     'id'   => 'email_template_header',
451
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
451
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
452 452
                     'type' => 'header',
453 453
                 ),
454 454
                 'email_header_image' => array(
455 455
                     'id'   => 'email_header_image',
456
-                    'name' => __( 'Header Image', 'invoicing' ),
457
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
456
+                    'name' => __('Header Image', 'invoicing'),
457
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
458 458
                     'std' => '',
459 459
                     'type' => 'text',
460 460
                 ),
461 461
                 'email_footer_text' => array(
462 462
                     'id'   => 'email_footer_text',
463
-                    'name' => __( 'Footer Text', 'invoicing' ),
464
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
465
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ),
463
+                    'name' => __('Footer Text', 'invoicing'),
464
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
465
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'),
466 466
                     'type' => 'textarea',
467 467
                     'class' => 'regular-text',
468 468
                     'rows' => 2,
@@ -470,29 +470,29 @@  discard block
 block discarded – undo
470 470
                 ),
471 471
                 'email_base_color' => array(
472 472
                     'id'   => 'email_base_color',
473
-                    'name' => __( 'Base Color', 'invoicing' ),
474
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
473
+                    'name' => __('Base Color', 'invoicing'),
474
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
475 475
                     'std' => '#557da2',
476 476
                     'type' => 'color',
477 477
                 ),
478 478
                 'email_background_color' => array(
479 479
                     'id'   => 'email_background_color',
480
-                    'name' => __( 'Background Color', 'invoicing' ),
481
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
480
+                    'name' => __('Background Color', 'invoicing'),
481
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
482 482
                     'std' => '#f5f5f5',
483 483
                     'type' => 'color',
484 484
                 ),
485 485
                 'email_body_background_color' => array(
486 486
                     'id'   => 'email_body_background_color',
487
-                    'name' => __( 'Body Background Color', 'invoicing' ),
488
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
487
+                    'name' => __('Body Background Color', 'invoicing'),
488
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
489 489
                     'std' => '#fdfdfd',
490 490
                     'type' => 'color',
491 491
                 ),
492 492
                 'email_text_color' => array(
493 493
                     'id'   => 'email_text_color',
494
-                    'name' => __( 'Body Text Color', 'invoicing' ),
495
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
494
+                    'name' => __('Body Text Color', 'invoicing'),
495
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
496 496
                     'std' => '#505050',
497 497
                     'type' => 'color',
498 498
                 ),
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
     ),
508 508
 
509 509
     // Integrations.
510
-    'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ),
510
+    'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'),
511 511
 
512 512
     /** Privacy Settings */
513 513
     'privacy' => apply_filters('wpinv_settings_privacy',
@@ -515,17 +515,17 @@  discard block
 block discarded – undo
515 515
             'main' => array(
516 516
                 'invoicing_privacy_policy_settings' => array(
517 517
                     'id'   => 'invoicing_privacy_policy_settings',
518
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
518
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
519 519
                     'type' => 'header',
520 520
                 ),
521 521
                 'privacy_page' => array(
522 522
                     'id'          => 'privacy_page',
523
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
524
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
523
+                    'name'        => __('Privacy Page', 'invoicing'),
524
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
525 525
                     'type'        => 'select',
526
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
526
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
527 527
                     'class'       => 'wpi_select2',
528
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
528
+                    'placeholder' => __('Select a page', 'invoicing'),
529 529
                 ),
530 530
             ),
531 531
         )
@@ -536,19 +536,19 @@  discard block
 block discarded – undo
536 536
             'main' => array(
537 537
                 'invoice_number_format_settings' => array(
538 538
                     'id'   => 'invoice_number_format_settings',
539
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
539
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
540 540
                     'type' => 'header',
541 541
                 ),
542 542
                 'sequential_invoice_number' => array(
543 543
                     'id'   => 'sequential_invoice_number',
544
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
545
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
544
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
545
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
546 546
                     'type' => 'checkbox',
547 547
                 ),
548 548
                 'invoice_sequence_start' => array(
549 549
                     'id'   => 'invoice_sequence_start',
550
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
551
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
550
+                    'name' => __('Sequential Starting Number', 'invoicing'),
551
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
552 552
                     'type' => 'number',
553 553
                     'size' => 'small',
554 554
                     'std'  => '1',
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
                 ),
557 557
                 'invoice_number_padd' => array(
558 558
                     'id'      => 'invoice_number_padd',
559
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
560
-                    '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' ),
559
+                    'name'    => __('Minimum Digits', 'invoicing'),
560
+                    'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
561 561
                     'type'    => 'select',
562 562
                     'options' => $invoice_number_padd_options,
563 563
                     'std'     => 5,
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
                 ),
566 566
                 'invoice_number_prefix' => array(
567 567
                     'id' => 'invoice_number_prefix',
568
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
569
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
568
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
569
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
570 570
                     'type' => 'text',
571 571
                     'size' => 'regular',
572 572
                     'std' => 'INV-',
@@ -574,46 +574,46 @@  discard block
 block discarded – undo
574 574
                 ),
575 575
                 'invoice_number_postfix' => array(
576 576
                     'id' => 'invoice_number_postfix',
577
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
578
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
577
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
578
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
579 579
                     'type' => 'text',
580 580
                     'size' => 'regular',
581 581
                     'std' => ''
582 582
                 ),
583 583
                 'checkout_settings' => array(
584 584
                     'id'   => 'checkout_settings',
585
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
585
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
586 586
                     'type' => 'header',
587 587
                 ),
588 588
                 'disable_new_user_emails' => array(
589 589
                     'id'   => 'disable_new_user_emails',
590
-                    'name' => __( 'Disable new user emails', 'invoicing' ),
591
-                    'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ),
590
+                    'name' => __('Disable new user emails', 'invoicing'),
591
+                    'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'),
592 592
                     'type' => 'checkbox',
593 593
                 ),
594 594
                 'login_to_checkout' => array(
595 595
                     'id'   => 'login_to_checkout',
596
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
597
-                    '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' ),
596
+                    'name' => __('Require Login To Checkout', 'invoicing'),
597
+                    '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'),
598 598
                     'type' => 'checkbox',
599 599
                 ),
600 600
                 'maxmind_license_key' => array(
601 601
                     'id'   => 'maxmind_license_key',
602
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
602
+                    'name' => __('MaxMind License Key', 'invoicing'),
603 603
                     'type' => 'text',
604 604
                     'size' => 'regular',
605
-                    '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>',
605
+                    '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>',
606 606
                 ),
607 607
 
608 608
                 'uninstall_settings' => array(
609 609
                     'id'   => 'uninstall_settings',
610
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
610
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
611 611
                     'type' => 'header',
612 612
                 ),
613 613
                 'remove_data_on_unistall' => array(
614 614
                     'id'   => 'remove_data_on_unistall',
615
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
616
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
615
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
616
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
617 617
                     'type' => 'checkbox',
618 618
                     'std'  => ''
619 619
                 ),
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
             'custom-css' => array(
623 623
                 'css_settings' => array(
624 624
                     'id'   => 'css_settings',
625
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
625
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
626 626
                     'type' => 'header',
627 627
                 ),
628 628
                 'template_custom_css' => array(
629 629
                     'id' => 'template_custom_css',
630
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
631
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
630
+                    'name' => __('Invoice Template CSS', 'invoicing'),
631
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
632 632
                     'type' => 'textarea',
633 633
                     'class'=> 'regular-text',
634 634
                     'rows' => 10,
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
             'main' => array(
643 643
                 'tool_settings' => array(
644 644
                     'id'   => 'tool_settings',
645
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
646
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
645
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
646
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
647 647
                     'type' => 'tools',
648 648
                 ),
649 649
             ),
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Spacing   +141 added lines, -141 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,146 +190,146 @@  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
-    $name = wpinv_get_option( 'store_name', wpinv_get_blogname() );
202
+    $name = wpinv_get_option('store_name', wpinv_get_blogname());
203 203
 
204
-    if ( empty( $name ) ) {
204
+    if (empty($name)) {
205 205
         $name = wpinv_get_blogname();
206 206
     }
207 207
 
208
-    return apply_filters( 'wpinv_get_business_name', $name );
208
+    return apply_filters('wpinv_get_business_name', $name);
209 209
 }
210 210
 
211 211
 function wpinv_get_blogname() {
212
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
212
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
213 213
 }
214 214
 
215 215
 function wpinv_get_admin_email() {
216
-    $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) );
217
-    return apply_filters( 'wpinv_admin_email', $admin_email );
216
+    $admin_email = wpinv_get_option('admin_email', get_option('admin_email'));
217
+    return apply_filters('wpinv_admin_email', $admin_email);
218 218
 }
219 219
 
220 220
 function wpinv_get_business_website() {
221
-    $business_website = home_url( '/' );
222
-    return apply_filters( 'wpinv_get_business_website', $business_website );
221
+    $business_website = home_url('/');
222
+    return apply_filters('wpinv_get_business_website', $business_website);
223 223
 }
224 224
 
225
-function wpinv_get_terms_text( $invoice_id = 0 ) {
225
+function wpinv_get_terms_text($invoice_id = 0) {
226 226
     $terms_text = '';
227
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
227
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
228 228
 }
229 229
 
230 230
 function wpinv_get_business_footer() {
231
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
232
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
233
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
231
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
232
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
233
+    return apply_filters('wpinv_get_business_footer', $business_footer);
234 234
 }
235 235
 
236 236
 function wpinv_checkout_required_fields() {
237 237
     $required_fields = array();
238 238
     
239 239
     // Let payment gateways and other extensions determine if address fields should be required
240
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
240
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
241 241
     
242
-    if ( $require_billing_details ) {
243
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
242
+    if ($require_billing_details) {
243
+		if ((bool) wpinv_get_option('fname_mandatory')) {
244 244
 			$required_fields['first_name'] = array(
245 245
 				'error_id' => 'invalid_first_name',
246
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
246
+				'error_message' => __('Please enter your first name', 'invoicing')
247 247
 			);
248 248
 		}
249
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
249
+		if ((bool) wpinv_get_option('address_mandatory')) {
250 250
 			$required_fields['address'] = array(
251 251
 				'error_id' => 'invalid_address',
252
-				'error_message' => __( 'Please enter your address', 'invoicing' )
252
+				'error_message' => __('Please enter your address', 'invoicing')
253 253
 			);
254 254
 		}
255
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
255
+		if ((bool) wpinv_get_option('city_mandatory')) {
256 256
 			$required_fields['city'] = array(
257 257
 				'error_id' => 'invalid_city',
258
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
258
+				'error_message' => __('Please enter your billing city', 'invoicing')
259 259
 			);
260 260
 		}
261
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
261
+		if ((bool) wpinv_get_option('state_mandatory')) {
262 262
 			$required_fields['state'] = array(
263 263
 				'error_id' => 'invalid_state',
264
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
264
+				'error_message' => __('Please enter billing state / province', 'invoicing')
265 265
 			);
266 266
 		}
267
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
267
+		if ((bool) wpinv_get_option('country_mandatory')) {
268 268
 			$required_fields['country'] = array(
269 269
 				'error_id' => 'invalid_country',
270
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
270
+				'error_message' => __('Please select your billing country', 'invoicing')
271 271
 			);
272 272
 		}
273 273
     }
274 274
 
275
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
275
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
276 276
 }
277 277
 
278 278
 function wpinv_is_ssl_enforced() {
279
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
280
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
279
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
280
+    return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
281 281
 }
282 282
 
283 283
 function wpinv_schedule_event_twicedaily() {
284 284
     wpinv_email_payment_reminders();
285 285
 }
286
-add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' );
286
+add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily');
287 287
 
288 288
 function wpinv_require_login_to_checkout() {
289
-    $return = wpinv_get_option( 'login_to_checkout', false );
290
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
289
+    $return = wpinv_get_option('login_to_checkout', false);
290
+    return (bool) apply_filters('wpinv_require_login_to_checkout', $return);
291 291
 }
292 292
 
293
-function wpinv_sequential_number_active( $type = '' ) {
294
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
295
-    if ( null !== $check ) {
293
+function wpinv_sequential_number_active($type = '') {
294
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
295
+    if (null !== $check) {
296 296
         return $check;
297 297
     }
298 298
     
299
-    return wpinv_get_option( 'sequential_invoice_number' );
299
+    return wpinv_get_option('sequential_invoice_number');
300 300
 }
301 301
 
302
-function wpinv_switch_to_locale( $locale = NULL ) {
302
+function wpinv_switch_to_locale($locale = NULL) {
303 303
     global $invoicing, $wpi_switch_locale;
304 304
 
305
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
306
-        $locale = empty( $locale ) ? get_locale() : $locale;
305
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
306
+        $locale = empty($locale) ? get_locale() : $locale;
307 307
 
308
-        switch_to_locale( $locale );
308
+        switch_to_locale($locale);
309 309
 
310 310
         $wpi_switch_locale = $locale;
311 311
 
312
-        add_filter( 'plugin_locale', 'get_locale' );
312
+        add_filter('plugin_locale', 'get_locale');
313 313
 
314 314
         $invoicing->load_textdomain();
315 315
 
316
-        do_action( 'wpinv_switch_to_locale', $locale );
316
+        do_action('wpinv_switch_to_locale', $locale);
317 317
     }
318 318
 }
319 319
 
320 320
 function wpinv_restore_locale() {
321 321
     global $invoicing, $wpi_switch_locale;
322 322
     
323
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
323
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
324 324
         restore_previous_locale();
325 325
 
326 326
         $wpi_switch_locale = NULL;
327 327
 
328
-        remove_filter( 'plugin_locale', 'get_locale' );
328
+        remove_filter('plugin_locale', 'get_locale');
329 329
 
330 330
         $invoicing->load_textdomain();
331 331
 
332
-        do_action( 'wpinv_restore_locale' );
332
+        do_action('wpinv_restore_locale');
333 333
     }
334 334
 }
335 335
 
@@ -337,26 +337,26 @@  discard block
 block discarded – undo
337 337
  * Returns the default form's id.
338 338
  */
339 339
 function wpinv_get_default_payment_form() {
340
-    $form = get_option( 'wpinv_default_payment_form' );
340
+    $form = get_option('wpinv_default_payment_form');
341 341
 
342
-    if ( empty( $form ) || 'publish' != get_post_status( $form ) ) {
342
+    if (empty($form) || 'publish' != get_post_status($form)) {
343 343
         $form = wp_insert_post(
344 344
             array(
345 345
                 'post_type'   => 'wpi_payment_form',
346
-                'post_title'  => __( 'Checkout (default)', 'invoicing' ),
346
+                'post_title'  => __('Checkout (default)', 'invoicing'),
347 347
                 'post_status' => 'publish',
348 348
                 'meta_input'  => array(
349
-                    'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ),
349
+                    'wpinv_form_elements' => wpinv_get_data('default-payment-form'),
350 350
                     'wpinv_form_items'    => array(),
351 351
                 )
352 352
             )
353 353
         );
354 354
 
355
-        update_option( 'wpinv_default_payment_form', $form );
355
+        update_option('wpinv_default_payment_form', $form);
356 356
     }
357 357
 
358 358
     // WPML support.
359
-    $form = apply_filters( 'wpml_object_id', $form, 'wpi_payment_form', TRUE  );
359
+    $form = apply_filters('wpml_object_id', $form, 'wpi_payment_form', TRUE);
360 360
     return $form;
361 361
 }
362 362
 
@@ -365,19 +365,19 @@  discard block
 block discarded – undo
365 365
  * 
366 366
  * @param int $payment_form
367 367
  */
368
-function getpaid_get_payment_form_elements( $payment_form ) {
368
+function getpaid_get_payment_form_elements($payment_form) {
369 369
 
370
-    if ( empty( $payment_form ) ) {
371
-        return wpinv_get_data( 'sample-payment-form' );
370
+    if (empty($payment_form)) {
371
+        return wpinv_get_data('sample-payment-form');
372 372
     }
373 373
 
374
-    $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true );
374
+    $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true);
375 375
 
376
-    if ( is_array( $form_elements ) ) {
376
+    if (is_array($form_elements)) {
377 377
         return $form_elements;
378 378
     }
379 379
 
380
-    return wpinv_get_data( 'sample-payment-form' );
380
+    return wpinv_get_data('sample-payment-form');
381 381
 
382 382
 }
383 383
 
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
  * 
387 387
  * @param int $payment_form
388 388
  */
389
-function gepaid_get_form_items( $id ) {
390
-    $form = new GetPaid_Payment_Form( $id );
389
+function gepaid_get_form_items($id) {
390
+    $form = new GetPaid_Payment_Form($id);
391 391
 
392 392
     // Is this a default form?
393
-    if ( $form->is_default() ) {
393
+    if ($form->is_default()) {
394 394
         return array();
395 395
     }
396 396
 
397
-    return $form->get_items( 'view', 'arrays' );
397
+    return $form->get_items('view', 'arrays');
398 398
 }
399 399
 
400 400
 /**
401 401
  * Trims each line in a paragraph.
402 402
  * 
403 403
  */
404
-function gepaid_trim_lines( $content ) {
405
-    return implode( "\n", array_map( 'trim', explode( "\n", $content ) ) );
404
+function gepaid_trim_lines($content) {
405
+    return implode("\n", array_map('trim', explode("\n", $content)));
406 406
 }
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
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'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = wpinv_clean( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228 228
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229 229
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
231
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
232
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
230
+            'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
231
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
232
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
233 233
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
234 234
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
235 235
         )
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
  * @return array
244 244
  */
245 245
 function wpinv_get_registered_settings() {
246
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
246
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
247 247
 }
248 248
 
249 249
 /**
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function wpinv_settings_sanitize( $input = array() ) {
264 264
 
265
-	$wpinv_options = wpinv_get_options();
266
-	$raw_referrer  = wp_get_raw_referer();
265
+    $wpinv_options = wpinv_get_options();
266
+    $raw_referrer  = wp_get_raw_referer();
267 267
 
268 268
     if ( empty( $raw_referrer ) ) {
269 269
         return $input;
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 
272 272
     wp_parse_str( $raw_referrer, $referrer );
273 273
 
274
-	if ( empty( $referrer['tab'] ) ) {
274
+    if ( empty( $referrer['tab'] ) ) {
275 275
         return $input;
276
-	}
276
+    }
277 277
 
278 278
     $settings = wpinv_get_registered_settings();
279 279
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
         }
296 296
 
297 297
         // General filter
298
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
298
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
299 299
 
300
-		// Key specific filter.
301
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
300
+        // Key specific filter.
301
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
302 302
     }
303 303
 
304 304
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 
355 355
     foreach ( $new_rates as $rate ) {
356 356
 
357
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
358
-		$rate['name']    = sanitize_text_field( $rate['name'] );
359
-		$rate['state']   = sanitize_text_field( $rate['state'] );
360
-		$rate['country'] = sanitize_text_field( $rate['country'] );
361
-		$rate['global']  = empty( $rate['state'] );
362
-		$tax_rates[]     = $rate;
357
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
358
+        $rate['name']    = sanitize_text_field( $rate['name'] );
359
+        $rate['state']   = sanitize_text_field( $rate['state'] );
360
+        $rate['country'] = sanitize_text_field( $rate['country'] );
361
+        $rate['global']  = empty( $rate['state'] );
362
+        $tax_rates[]     = $rate;
363 363
 
364
-	}
364
+    }
365 365
 
366 366
     update_option( 'wpinv_tax_rates', $tax_rates );
367 367
 
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
     $tabs['general']  = __( 'General', 'invoicing' );
380 380
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
381 381
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
382
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
382
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
383 383
 
384
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
385
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
386
-	}
384
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
385
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
386
+    }
387 387
 
388 388
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
389 389
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
         ) ),
422 422
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
423 423
             'main'  => __( 'Tax Settings', 'invoicing' ),
424
-			'rates' => __( 'Tax Rates', 'invoicing' ),
425
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
424
+            'rates' => __( 'Tax Rates', 'invoicing' ),
425
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
426 426
         ) ),
427 427
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
428 428
             'main' => __( 'Email Settings', 'invoicing' ),
429
-		) ),
429
+        ) ),
430 430
 
431
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
431
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
432 432
 
433 433
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
434 434
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -448,51 +448,51 @@  discard block
 block discarded – undo
448 448
 }
449 449
 
450 450
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
451
-	$pages_options = array();
451
+    $pages_options = array();
452 452
 
453
-	if( $default_label !== NULL && $default_label !== false ) {
454
-		$pages_options = array( '' => $default_label ); // Blank option
455
-	}
453
+    if( $default_label !== NULL && $default_label !== false ) {
454
+        $pages_options = array( '' => $default_label ); // Blank option
455
+    }
456 456
 
457
-	$pages = get_pages();
458
-	if ( $pages ) {
459
-		foreach ( $pages as $page ) {
460
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
457
+    $pages = get_pages();
458
+    if ( $pages ) {
459
+        foreach ( $pages as $page ) {
460
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
461 461
             $pages_options[ $page->ID ] = $title;
462
-		}
463
-	}
462
+        }
463
+    }
464 464
 
465
-	return $pages_options;
465
+    return $pages_options;
466 466
 }
467 467
 
468 468
 function wpinv_header_callback( $args ) {
469
-	if ( !empty( $args['desc'] ) ) {
469
+    if ( !empty( $args['desc'] ) ) {
470 470
         echo $args['desc'];
471 471
     }
472 472
 }
473 473
 
474 474
 function wpinv_hidden_callback( $args ) {
475
-	global $wpinv_options;
476
-
477
-	if ( isset( $args['set_value'] ) ) {
478
-		$value = $args['set_value'];
479
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
480
-		$value = $wpinv_options[ $args['id'] ];
481
-	} else {
482
-		$value = isset( $args['std'] ) ? $args['std'] : '';
483
-	}
484
-
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
-		$args['readonly'] = true;
487
-		$value = isset( $args['std'] ) ? $args['std'] : '';
488
-		$name  = '';
489
-	} else {
490
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
491
-	}
492
-
493
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
475
+    global $wpinv_options;
476
+
477
+    if ( isset( $args['set_value'] ) ) {
478
+        $value = $args['set_value'];
479
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
480
+        $value = $wpinv_options[ $args['id'] ];
481
+    } else {
482
+        $value = isset( $args['std'] ) ? $args['std'] : '';
483
+    }
484
+
485
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
+        $args['readonly'] = true;
487
+        $value = isset( $args['std'] ) ? $args['std'] : '';
488
+        $name  = '';
489
+    } else {
490
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
491
+    }
492
+
493
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
494 494
     
495
-	echo $html;
495
+    echo $html;
496 496
 }
497 497
 
498 498
 /**
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
  */
501 501
 function wpinv_checkbox_callback( $args ) {
502 502
 
503
-	$std = isset( $args['std'] ) ? $args['std'] : '';
504
-	$std = wpinv_get_option( $args['id'], $std );
505
-	$id  = esc_attr( $args['id'] );
503
+    $std = isset( $args['std'] ) ? $args['std'] : '';
504
+    $std = wpinv_get_option( $args['id'], $std );
505
+    $id  = esc_attr( $args['id'] );
506 506
 
507
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
508
-	?>
507
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
508
+    ?>
509 509
 		<fieldset>
510 510
 			<label>
511 511
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -517,77 +517,77 @@  discard block
 block discarded – undo
517 517
 
518 518
 function wpinv_multicheck_callback( $args ) {
519 519
 	
520
-	global $wpinv_options;
520
+    global $wpinv_options;
521 521
 
522
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
523
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
522
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
523
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
524 524
 
525
-	if ( ! empty( $args['options'] ) ) {
525
+    if ( ! empty( $args['options'] ) ) {
526 526
 
527
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
528
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
527
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
528
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
529 529
 
530
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
530
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
531 531
         foreach( $args['options'] as $key => $option ):
532
-			$sanitize_key = wpinv_sanitize_key( $key );
533
-			if ( in_array( $sanitize_key, $value ) ) { 
534
-				$enabled = $sanitize_key;
535
-			} else { 
536
-				$enabled = NULL; 
537
-			}
538
-			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;';
539
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
540
-		endforeach;
541
-		echo '</div>';
542
-		echo '<p class="description">' . $args['desc'] . '</p>';
543
-	}
532
+            $sanitize_key = wpinv_sanitize_key( $key );
533
+            if ( in_array( $sanitize_key, $value ) ) { 
534
+                $enabled = $sanitize_key;
535
+            } else { 
536
+                $enabled = NULL; 
537
+            }
538
+            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;';
539
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
540
+        endforeach;
541
+        echo '</div>';
542
+        echo '<p class="description">' . $args['desc'] . '</p>';
543
+    }
544 544
 }
545 545
 
546 546
 function wpinv_payment_icons_callback( $args ) {
547
-	global $wpinv_options;
547
+    global $wpinv_options;
548 548
     
549 549
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
550 550
 
551
-	if ( ! empty( $args['options'] ) ) {
552
-		foreach( $args['options'] as $key => $option ) {
551
+    if ( ! empty( $args['options'] ) ) {
552
+        foreach( $args['options'] as $key => $option ) {
553 553
             $sanitize_key = wpinv_sanitize_key( $key );
554 554
             
555
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
556
-				$enabled = $option;
557
-			} else {
558
-				$enabled = NULL;
559
-			}
560
-
561
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
562
-
563
-				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;';
564
-
565
-				if ( wpinv_string_is_image_url( $key ) ) {
566
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
567
-				} else {
568
-					$card = strtolower( str_replace( ' ', '', $option ) );
569
-
570
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
571
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
572
-					} else {
573
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
574
-						$content_dir = WP_CONTENT_DIR;
575
-
576
-						if ( function_exists( 'wp_normalize_path' ) ) {
577
-							// Replaces backslashes with forward slashes for Windows systems
578
-							$image = wp_normalize_path( $image );
579
-							$content_dir = wp_normalize_path( $content_dir );
580
-						}
581
-
582
-						$image = str_replace( $content_dir, content_url(), $image );
583
-					}
584
-
585
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
586
-				}
587
-			echo $option . '</label>';
588
-		}
589
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
590
-	}
555
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
556
+                $enabled = $option;
557
+            } else {
558
+                $enabled = NULL;
559
+            }
560
+
561
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
562
+
563
+                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;';
564
+
565
+                if ( wpinv_string_is_image_url( $key ) ) {
566
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
567
+                } else {
568
+                    $card = strtolower( str_replace( ' ', '', $option ) );
569
+
570
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
571
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
572
+                    } else {
573
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
574
+                        $content_dir = WP_CONTENT_DIR;
575
+
576
+                        if ( function_exists( 'wp_normalize_path' ) ) {
577
+                            // Replaces backslashes with forward slashes for Windows systems
578
+                            $image = wp_normalize_path( $image );
579
+                            $content_dir = wp_normalize_path( $content_dir );
580
+                        }
581
+
582
+                        $image = str_replace( $content_dir, content_url(), $image );
583
+                    }
584
+
585
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
586
+                }
587
+            echo $option . '</label>';
588
+        }
589
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
590
+    }
591 591
 }
592 592
 
593 593
 /**
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
  */
596 596
 function wpinv_radio_callback( $args ) {
597 597
 
598
-	$std = isset( $args['std'] ) ? $args['std'] : '';
599
-	$std = wpinv_get_option( $args['id'], $std );
600
-	?>
598
+    $std = isset( $args['std'] ) ? $args['std'] : '';
599
+    $std = wpinv_get_option( $args['id'], $std );
600
+    ?>
601 601
 		<fieldset>
602 602
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
603 603
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 			</ul>
612 612
 		</fieldset>
613 613
 	<?php
614
-	getpaid_settings_description_callback( $args );
614
+    getpaid_settings_description_callback( $args );
615 615
 }
616 616
 
617 617
 /**
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
  */
620 620
 function getpaid_settings_description_callback( $args ) {
621 621
 
622
-	if ( ! empty( $args['desc'] ) ) {
623
-		$description = wp_kses_post( $args['desc'] );
624
-		echo "<p class='description'>$description</p>";
625
-	}
622
+    if ( ! empty( $args['desc'] ) ) {
623
+        $description = wp_kses_post( $args['desc'] );
624
+        echo "<p class='description'>$description</p>";
625
+    }
626 626
 
627 627
 }
628 628
 
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
  */
632 632
 function wpinv_gateways_callback() {
633 633
 
634
-	?>
634
+    ?>
635 635
 		</td>
636 636
 	</tr>
637 637
 	<tr class="bsui">
@@ -642,24 +642,24 @@  discard block
 block discarded – undo
642 642
 }
643 643
 
644 644
 function wpinv_gateway_select_callback($args) {
645
-	global $wpinv_options;
645
+    global $wpinv_options;
646 646
     
647 647
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
648 648
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
649 649
 
650
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
650
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
651 651
 
652
-	foreach ( $args['options'] as $key => $option ) :
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
652
+    foreach ( $args['options'] as $key => $option ) :
653
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654 654
             $selected = selected( $key, $args['selected'], false );
655 655
         } else {
656 656
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
657 657
         }
658
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
659
-	endforeach;
658
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
659
+    endforeach;
660 660
 
661
-	echo '</select>';
662
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
661
+    echo '</select>';
662
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
663 663
 }
664 664
 
665 665
 /**
@@ -670,29 +670,29 @@  discard block
 block discarded – undo
670 670
  */
671 671
 function wpinv_settings_attrs_helper( $args ) {
672 672
 
673
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
674
-	$id           = esc_attr( $args['id'] );
675
-	$placeholder  = esc_attr( $args['placeholder'] );
673
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
674
+    $id           = esc_attr( $args['id'] );
675
+    $placeholder  = esc_attr( $args['placeholder'] );
676 676
 
677
-	if ( ! empty( $args['faux'] ) ) {
678
-		$args['readonly'] = true;
679
-		$name             = '';
680
-	} else {
681
-		$value  = wpinv_get_option( $args['id'], $value );
682
-		$name   = "wpinv_settings[$id]";
683
-	}
677
+    if ( ! empty( $args['faux'] ) ) {
678
+        $args['readonly'] = true;
679
+        $name             = '';
680
+    } else {
681
+        $value  = wpinv_get_option( $args['id'], $value );
682
+        $name   = "wpinv_settings[$id]";
683
+    }
684 684
 
685
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
686
-	$class    = esc_attr( $args['class'] );
687
-	$style    = esc_attr( $args['style'] );
688
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
685
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
686
+    $class    = esc_attr( $args['class'] );
687
+    $style    = esc_attr( $args['style'] );
688
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
689 689
 
690
-	$onchange = '';
690
+    $onchange = '';
691 691
     if ( ! empty( $args['onchange'] ) ) {
692 692
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
693
-	}
693
+    }
694 694
 
695
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
695
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
696 696
 }
697 697
 
698 698
 /**
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
  */
701 701
 function wpinv_text_callback( $args ) {
702 702
 
703
-	$desc = wp_kses_post( $args['desc'] );
704
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
705
-	$attr = wpinv_settings_attrs_helper( $args );
703
+    $desc = wp_kses_post( $args['desc'] );
704
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
705
+    $attr = wpinv_settings_attrs_helper( $args );
706 706
 
707
-	?>
707
+    ?>
708 708
 		<label style="width: 100%;">
709 709
 			<input type="text" <?php echo $attr; ?>>
710 710
 			<?php echo $desc; ?>
@@ -718,14 +718,14 @@  discard block
 block discarded – undo
718 718
  */
719 719
 function wpinv_number_callback( $args ) {
720 720
 
721
-	$desc = wp_kses_post( $args['desc'] );
722
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
723
-	$attr = wpinv_settings_attrs_helper( $args );
724
-	$max  = intval( $args['max'] );
725
-	$min  = intval( $args['min'] );
726
-	$step = floatval( $args['step'] );
721
+    $desc = wp_kses_post( $args['desc'] );
722
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
723
+    $attr = wpinv_settings_attrs_helper( $args );
724
+    $max  = intval( $args['max'] );
725
+    $min  = intval( $args['min'] );
726
+    $step = floatval( $args['step'] );
727 727
 
728
-	?>
728
+    ?>
729 729
 		<label style="width: 100%;">
730 730
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
731 731
 			<?php echo $desc; ?>
@@ -735,48 +735,48 @@  discard block
 block discarded – undo
735 735
 }
736 736
 
737 737
 function wpinv_textarea_callback( $args ) {
738
-	global $wpinv_options;
738
+    global $wpinv_options;
739 739
     
740 740
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
741 741
 
742
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
743
-		$value = $wpinv_options[ $args['id'] ];
744
-	} else {
745
-		$value = isset( $args['std'] ) ? $args['std'] : '';
746
-	}
742
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
743
+        $value = $wpinv_options[ $args['id'] ];
744
+    } else {
745
+        $value = isset( $args['std'] ) ? $args['std'] : '';
746
+    }
747 747
     
748 748
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
749 749
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
750 750
 
751
-	$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>';
752
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
751
+    $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>';
752
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
753 753
 
754
-	echo $html;
754
+    echo $html;
755 755
 }
756 756
 
757 757
 function wpinv_password_callback( $args ) {
758
-	global $wpinv_options;
758
+    global $wpinv_options;
759 759
     
760 760
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
761 761
 
762
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
763
-		$value = $wpinv_options[ $args['id'] ];
764
-	} else {
765
-		$value = isset( $args['std'] ) ? $args['std'] : '';
766
-	}
762
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
763
+        $value = $wpinv_options[ $args['id'] ];
764
+    } else {
765
+        $value = isset( $args['std'] ) ? $args['std'] : '';
766
+    }
767 767
 
768
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
769
-	$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 ) . '"/>';
770
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
768
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
769
+    $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 ) . '"/>';
770
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
771 771
 
772
-	echo $html;
772
+    echo $html;
773 773
 }
774 774
 
775 775
 function wpinv_missing_callback($args) {
776
-	printf(
777
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
778
-		'<strong>' . $args['id'] . '</strong>'
779
-	);
776
+    printf(
777
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
778
+        '<strong>' . $args['id'] . '</strong>'
779
+    );
780 780
 }
781 781
 
782 782
 /**
@@ -784,14 +784,14 @@  discard block
 block discarded – undo
784 784
  */
785 785
 function wpinv_select_callback( $args ) {
786 786
 
787
-	$desc   = wp_kses_post( $args['desc'] );
788
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
789
-	$attr   = wpinv_settings_attrs_helper( $args );
790
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
791
-	$value  = wpinv_get_option( $args['id'], $value );
792
-	$rand   = uniqid( 'random_id' );
787
+    $desc   = wp_kses_post( $args['desc'] );
788
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
789
+    $attr   = wpinv_settings_attrs_helper( $args );
790
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
791
+    $value  = wpinv_get_option( $args['id'], $value );
792
+    $rand   = uniqid( 'random_id' );
793 793
 
794
-	?>
794
+    ?>
795 795
 		<label style="width: 100%;">
796 796
 			<select <?php echo $attr; ?>>
797 797
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -822,123 +822,123 @@  discard block
 block discarded – undo
822 822
 }
823 823
 
824 824
 function wpinv_color_select_callback( $args ) {
825
-	global $wpinv_options;
825
+    global $wpinv_options;
826 826
     
827 827
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
828 828
 
829
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
830
-		$value = $wpinv_options[ $args['id'] ];
831
-	} else {
832
-		$value = isset( $args['std'] ) ? $args['std'] : '';
833
-	}
829
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
830
+        $value = $wpinv_options[ $args['id'] ];
831
+    } else {
832
+        $value = isset( $args['std'] ) ? $args['std'] : '';
833
+    }
834 834
 
835
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
835
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
836 836
 
837
-	foreach ( $args['options'] as $option => $color ) {
838
-		$selected = selected( $option, $value, false );
839
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
840
-	}
837
+    foreach ( $args['options'] as $option => $color ) {
838
+        $selected = selected( $option, $value, false );
839
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
840
+    }
841 841
 
842
-	$html .= '</select>';
843
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
842
+    $html .= '</select>';
843
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
844 844
 
845
-	echo $html;
845
+    echo $html;
846 846
 }
847 847
 
848 848
 function wpinv_rich_editor_callback( $args ) {
849
-	global $wpinv_options, $wp_version;
849
+    global $wpinv_options, $wp_version;
850 850
     
851 851
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
852 852
 
853
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
854
-		$value = $wpinv_options[ $args['id'] ];
853
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
854
+        $value = $wpinv_options[ $args['id'] ];
855 855
 
856
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
857
-			$value = isset( $args['std'] ) ? $args['std'] : '';
858
-		}
859
-	} else {
860
-		$value = isset( $args['std'] ) ? $args['std'] : '';
861
-	}
856
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
857
+            $value = isset( $args['std'] ) ? $args['std'] : '';
858
+        }
859
+    } else {
860
+        $value = isset( $args['std'] ) ? $args['std'] : '';
861
+    }
862 862
 
863
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
863
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
864 864
 
865
-	$html = '<div class="getpaid-settings-editor-input">';
866
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
867
-		ob_start();
868
-		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 ) );
869
-		$html .= ob_get_clean();
870
-	} else {
871
-		$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>';
872
-	}
865
+    $html = '<div class="getpaid-settings-editor-input">';
866
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
867
+        ob_start();
868
+        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 ) );
869
+        $html .= ob_get_clean();
870
+    } else {
871
+        $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>';
872
+    }
873 873
 
874
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
874
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
875 875
 
876
-	echo $html;
876
+    echo $html;
877 877
 }
878 878
 
879 879
 function wpinv_upload_callback( $args ) {
880
-	global $wpinv_options;
880
+    global $wpinv_options;
881 881
     
882 882
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[$args['id']];
886
-	} else {
887
-		$value = isset($args['std']) ? $args['std'] : '';
888
-	}
884
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
+        $value = $wpinv_options[$args['id']];
886
+    } else {
887
+        $value = isset($args['std']) ? $args['std'] : '';
888
+    }
889 889
 
890
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
891
-	$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 ) ) . '"/>';
892
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
890
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
891
+    $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 ) ) . '"/>';
892
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
893
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
894 894
 
895
-	echo $html;
895
+    echo $html;
896 896
 }
897 897
 
898 898
 function wpinv_color_callback( $args ) {
899
-	global $wpinv_options;
899
+    global $wpinv_options;
900 900
     
901 901
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
902 902
 
903
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
904
-		$value = $wpinv_options[ $args['id'] ];
905
-	} else {
906
-		$value = isset( $args['std'] ) ? $args['std'] : '';
907
-	}
903
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
904
+        $value = $wpinv_options[ $args['id'] ];
905
+    } else {
906
+        $value = isset( $args['std'] ) ? $args['std'] : '';
907
+    }
908 908
 
909
-	$default = isset( $args['std'] ) ? $args['std'] : '';
909
+    $default = isset( $args['std'] ) ? $args['std'] : '';
910 910
 
911
-	$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 ) . '" />';
912
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
911
+    $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 ) . '" />';
912
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
913 913
 
914
-	echo $html;
914
+    echo $html;
915 915
 }
916 916
 
917 917
 function wpinv_country_states_callback($args) {
918
-	global $wpinv_options;
918
+    global $wpinv_options;
919 919
     
920 920
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
921 921
 
922
-	if ( isset( $args['placeholder'] ) ) {
923
-		$placeholder = $args['placeholder'];
924
-	} else {
925
-		$placeholder = '';
926
-	}
922
+    if ( isset( $args['placeholder'] ) ) {
923
+        $placeholder = $args['placeholder'];
924
+    } else {
925
+        $placeholder = '';
926
+    }
927 927
 
928
-	$states = wpinv_get_country_states();
928
+    $states = wpinv_get_country_states();
929 929
 
930
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
931
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
930
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
931
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
932 932
 
933
-	foreach ( $states as $option => $name ) {
934
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
935
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
936
-	}
933
+    foreach ( $states as $option => $name ) {
934
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
935
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
936
+    }
937 937
 
938
-	$html .= '</select>';
939
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
938
+    $html .= '</select>';
939
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
940 940
 
941
-	echo $html;
941
+    echo $html;
942 942
 }
943 943
 
944 944
 /**
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
  */
947 947
 function wpinv_tax_rates_callback() {
948 948
 	
949
-	?>
949
+    ?>
950 950
 		</td>
951 951
 	</tr>
952 952
 	<tr class="bsui">
@@ -961,17 +961,17 @@  discard block
 block discarded – undo
961 961
  * Displays a tax rate' edit row.
962 962
  */
963 963
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
964
-	ob_start();
964
+    ob_start();
965 965
 
966
-	$key                      = sanitize_key( $key );
967
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
968
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
966
+    $key                      = sanitize_key( $key );
967
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
968
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
969 969
 
970
-	if ( $echo ) {
971
-		echo ob_get_clean();
972
-	} else {
973
-		return ob_get_clean(); 
974
-	}
970
+    if ( $echo ) {
971
+        echo ob_get_clean();
972
+    } else {
973
+        return ob_get_clean(); 
974
+    }
975 975
 
976 976
 }
977 977
 
@@ -999,14 +999,14 @@  discard block
 block discarded – undo
999 999
                 </td>
1000 1000
                 <td>
1001 1001
 					<a href="<?php
1002
-						echo esc_url(
1003
-							wp_nonce_url(
1004
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1005
-								'getpaid-nonce',
1006
-								'getpaid-nonce'
1007
-							)
1008
-						);
1009
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1002
+                        echo esc_url(
1003
+                            wp_nonce_url(
1004
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1005
+                                'getpaid-nonce',
1006
+                                'getpaid-nonce'
1007
+                            )
1008
+                        );
1009
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1010 1010
                 </td>
1011 1011
             </tr>
1012 1012
 			<tr>
@@ -1016,14 +1016,14 @@  discard block
 block discarded – undo
1016 1016
                 </td>
1017 1017
                 <td>
1018 1018
 					<a href="<?php
1019
-						echo esc_url(
1020
-							wp_nonce_url(
1021
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1022
-								'getpaid-nonce',
1023
-								'getpaid-nonce'
1024
-							)
1025
-						);
1026
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1019
+                        echo esc_url(
1020
+                            wp_nonce_url(
1021
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1022
+                                'getpaid-nonce',
1023
+                                'getpaid-nonce'
1024
+                            )
1025
+                        );
1026
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1027 1027
                 </td>
1028 1028
             </tr>
1029 1029
 			<tr>
@@ -1033,14 +1033,14 @@  discard block
 block discarded – undo
1033 1033
                 </td>
1034 1034
                 <td>
1035 1035
 					<a href="<?php
1036
-						echo esc_url(
1037
-							wp_nonce_url(
1038
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1039
-								'getpaid-nonce',
1040
-								'getpaid-nonce'
1041
-							)
1042
-						);
1043
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1036
+                        echo esc_url(
1037
+                            wp_nonce_url(
1038
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1039
+                                'getpaid-nonce',
1040
+                                'getpaid-nonce'
1041
+                            )
1042
+                        );
1043
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1044 1044
                 </td>
1045 1045
             </tr>
1046 1046
 
@@ -1051,14 +1051,14 @@  discard block
 block discarded – undo
1051 1051
                 </td>
1052 1052
                 <td>
1053 1053
 					<a href="<?php
1054
-						echo esc_url(
1055
-							wp_nonce_url(
1056
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1057
-								'getpaid-nonce',
1058
-								'getpaid-nonce'
1059
-							)
1060
-						);
1061
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1054
+                        echo esc_url(
1055
+                            wp_nonce_url(
1056
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1057
+                                'getpaid-nonce',
1058
+                                'getpaid-nonce'
1059
+                            )
1060
+                        );
1061
+                    ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1062 1062
                 </td>
1063 1063
             </tr>
1064 1064
 
@@ -1072,19 +1072,19 @@  discard block
 block discarded – undo
1072 1072
 
1073 1073
 
1074 1074
 function wpinv_descriptive_text_callback( $args ) {
1075
-	echo wp_kses_post( $args['desc'] );
1075
+    echo wp_kses_post( $args['desc'] );
1076 1076
 }
1077 1077
 
1078 1078
 function wpinv_raw_html_callback( $args ) {
1079
-	echo $args['desc'];
1079
+    echo $args['desc'];
1080 1080
 }
1081 1081
 
1082 1082
 function wpinv_hook_callback( $args ) {
1083
-	do_action( 'wpinv_' . $args['id'], $args );
1083
+    do_action( 'wpinv_' . $args['id'], $args );
1084 1084
 }
1085 1085
 
1086 1086
 function wpinv_set_settings_cap() {
1087
-	return wpinv_get_capability();
1087
+    return wpinv_get_capability();
1088 1088
 }
1089 1089
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1090 1090
 
@@ -1118,15 +1118,15 @@  discard block
 block discarded – undo
1118 1118
  */
1119 1119
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1120 1120
 
1121
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1122
-	$link = sprintf(
1123
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1124
-		$url,
1125
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1126
-	);
1121
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1122
+    $link = sprintf(
1123
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1124
+        $url,
1125
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1126
+    );
1127 1127
 
1128
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1128
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1129 1129
 
1130
-	return "$description $link";
1130
+    return "$description $link";
1131 1131
 
1132 1132
 }
Please login to merge, or discard this patch.
Spacing   +378 added lines, -378 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,48 +190,48 @@  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
-			'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
231
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
232
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
233
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
234
-            '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
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
231
+			'class'       => isset($option['class']) ? $option['class'] : '',
232
+			'style'       => isset($option['style']) ? $option['style'] : '',
233
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
234
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
235 235
         )
236 236
     );
237 237
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
  * @return array
244 244
  */
245 245
 function wpinv_get_registered_settings() {
246
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
246
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
247 247
 }
248 248
 
249 249
 /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
  * @return array
253 253
  */
254 254
 function getpaid_get_integration_settings() {
255
-    return apply_filters( 'getpaid_integration_settings', array() );
255
+    return apply_filters('getpaid_integration_settings', array());
256 256
 }
257 257
 
258 258
 /**
@@ -260,144 +260,144 @@  discard block
 block discarded – undo
260 260
  * 
261 261
  * @return array
262 262
  */
263
-function wpinv_settings_sanitize( $input = array() ) {
263
+function wpinv_settings_sanitize($input = array()) {
264 264
 
265 265
 	$wpinv_options = wpinv_get_options();
266 266
 	$raw_referrer  = wp_get_raw_referer();
267 267
 
268
-    if ( empty( $raw_referrer ) ) {
268
+    if (empty($raw_referrer)) {
269 269
         return $input;
270 270
     }
271 271
 
272
-    wp_parse_str( $raw_referrer, $referrer );
272
+    wp_parse_str($raw_referrer, $referrer);
273 273
 
274
-	if ( empty( $referrer['tab'] ) ) {
274
+	if (empty($referrer['tab'])) {
275 275
         return $input;
276 276
 	}
277 277
 
278 278
     $settings = wpinv_get_registered_settings();
279
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
280
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
279
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
280
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
281 281
 
282 282
     $input = $input ? $input : array();
283
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
284
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
283
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
284
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
285 285
 
286 286
     // Loop through each setting being saved and pass it through a sanitization filter
287
-    foreach ( $input as $key => $value ) {
287
+    foreach ($input as $key => $value) {
288 288
 
289 289
         // Get the setting type (checkbox, select, etc)
290
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
290
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
291 291
 
292
-        if ( $type ) {
292
+        if ($type) {
293 293
             // Field type specific filter
294
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
294
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
295 295
         }
296 296
 
297 297
         // General filter
298
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
298
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
299 299
 
300 300
 		// Key specific filter.
301
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
301
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
302 302
     }
303 303
 
304 304
     // Loop through the whitelist and unset any that are empty for the tab being saved
305
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
306
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
305
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
306
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
307 307
 
308
-    $found_settings   = array_merge( $main_settings, $section_settings );
308
+    $found_settings   = array_merge($main_settings, $section_settings);
309 309
 
310
-    if ( ! empty( $found_settings ) ) {
311
-        foreach ( $found_settings as $key => $value ) {
310
+    if (!empty($found_settings)) {
311
+        foreach ($found_settings as $key => $value) {
312 312
 
313 313
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
314
-            if ( is_numeric( $key ) ) {
314
+            if (is_numeric($key)) {
315 315
                 $key = $value['id'];
316 316
             }
317 317
 
318
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
319
-                unset( $wpinv_options[ $key ] );
318
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
319
+                unset($wpinv_options[$key]);
320 320
             }
321 321
         }
322 322
     }
323 323
 
324 324
     // Merge our new settings with the existing
325
-    $output = array_merge( $wpinv_options, $input );
325
+    $output = array_merge($wpinv_options, $input);
326 326
 
327
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
327
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_settings_sanitize_misc_accounting( $input ) {
332
+function wpinv_settings_sanitize_misc_accounting($input) {
333 333
 
334
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
334
+    if (!wpinv_current_user_can_manage_invoicing()) {
335 335
         return $input;
336 336
     }
337 337
 
338
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
338
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
339 339
         // Shows an admin notice about upgrading previous order numbers
340
-        getpaid_session()->set( 'upgrade_sequential', '1' );
340
+        getpaid_session()->set('upgrade_sequential', '1');
341 341
     }
342 342
 
343 343
     return $input;
344 344
 }
345
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
345
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
346 346
 
347
-function wpinv_settings_sanitize_tax_rates( $input ) {
348
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
347
+function wpinv_settings_sanitize_tax_rates($input) {
348
+    if (!wpinv_current_user_can_manage_invoicing()) {
349 349
         return $input;
350 350
     }
351 351
 
352
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
352
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
353 353
     $tax_rates = array();
354 354
 
355
-    foreach ( $new_rates as $rate ) {
355
+    foreach ($new_rates as $rate) {
356 356
 
357
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
358
-		$rate['name']    = sanitize_text_field( $rate['name'] );
359
-		$rate['state']   = sanitize_text_field( $rate['state'] );
360
-		$rate['country'] = sanitize_text_field( $rate['country'] );
361
-		$rate['global']  = empty( $rate['state'] );
357
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
358
+		$rate['name']    = sanitize_text_field($rate['name']);
359
+		$rate['state']   = sanitize_text_field($rate['state']);
360
+		$rate['country'] = sanitize_text_field($rate['country']);
361
+		$rate['global']  = empty($rate['state']);
362 362
 		$tax_rates[]     = $rate;
363 363
 
364 364
 	}
365 365
 
366
-    update_option( 'wpinv_tax_rates', $tax_rates );
366
+    update_option('wpinv_tax_rates', $tax_rates);
367 367
 
368 368
     return $input;
369 369
 }
370
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
370
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
371 371
 
372
-function wpinv_sanitize_text_field( $input ) {
373
-    return trim( $input );
372
+function wpinv_sanitize_text_field($input) {
373
+    return trim($input);
374 374
 }
375
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
375
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
376 376
 
377 377
 function wpinv_get_settings_tabs() {
378 378
     $tabs             = array();
379
-    $tabs['general']  = __( 'General', 'invoicing' );
380
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
381
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
382
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
379
+    $tabs['general']  = __('General', 'invoicing');
380
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
381
+    $tabs['taxes']    = __('Taxes', 'invoicing');
382
+	$tabs['emails'] = __('Emails', 'invoicing');
383 383
 
384
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
385
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
384
+	if (count(getpaid_get_integration_settings()) > 0) {
385
+		$tabs['integrations'] = __('Integrations', 'invoicing');
386 386
 	}
387 387
 
388
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
389
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
390
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
388
+    $tabs['privacy']  = __('Privacy', 'invoicing');
389
+    $tabs['misc']     = __('Misc', 'invoicing');
390
+    $tabs['tools']    = __('Tools', 'invoicing');
391 391
 
392
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
392
+    return apply_filters('wpinv_settings_tabs', $tabs);
393 393
 }
394 394
 
395
-function wpinv_get_settings_tab_sections( $tab = false ) {
395
+function wpinv_get_settings_tab_sections($tab = false) {
396 396
     $tabs     = false;
397 397
     $sections = wpinv_get_registered_settings_sections();
398 398
 
399
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
400
-        $tabs = $sections[ $tab ];
399
+    if ($tab && !empty($sections[$tab])) {
400
+        $tabs = $sections[$tab];
401 401
     }
402 402
 
403 403
     return $tabs;
@@ -406,91 +406,91 @@  discard block
 block discarded – undo
406 406
 function wpinv_get_registered_settings_sections() {
407 407
     static $sections = false;
408 408
 
409
-    if ( false !== $sections ) {
409
+    if (false !== $sections) {
410 410
         return $sections;
411 411
     }
412 412
 
413 413
     $sections = array(
414
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
415
-            'main' => __( 'General Settings', 'invoicing' ),
416
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
417
-            'labels' => __( 'Label Texts', 'invoicing' ),
418
-        ) ),
419
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
420
-            'main' => __( 'Gateway Settings', 'invoicing' ),
421
-        ) ),
422
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
423
-            'main'  => __( 'Tax Settings', 'invoicing' ),
424
-			'rates' => __( 'Tax Rates', 'invoicing' ),
425
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
426
-        ) ),
427
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
428
-            'main' => __( 'Email Settings', 'invoicing' ),
429
-		) ),
430
-
431
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
432
-
433
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
434
-            'main' => __( 'Privacy policy', 'invoicing' ),
435
-        ) ),
436
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
437
-            'main' => __( 'Miscellaneous', 'invoicing' ),
438
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
439
-        ) ),
440
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
441
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
-        ) ),
414
+        'general' => apply_filters('wpinv_settings_sections_general', array(
415
+            'main' => __('General Settings', 'invoicing'),
416
+            'currency_section' => __('Currency Settings', 'invoicing'),
417
+            'labels' => __('Label Texts', 'invoicing'),
418
+        )),
419
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
420
+            'main' => __('Gateway Settings', 'invoicing'),
421
+        )),
422
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
423
+            'main'  => __('Tax Settings', 'invoicing'),
424
+			'rates' => __('Tax Rates', 'invoicing'),
425
+			'vat'   => __('EU VAT Settings', 'invoicing')
426
+        )),
427
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
428
+            'main' => __('Email Settings', 'invoicing'),
429
+		)),
430
+
431
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
432
+
433
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
434
+            'main' => __('Privacy policy', 'invoicing'),
435
+        )),
436
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
437
+            'main' => __('Miscellaneous', 'invoicing'),
438
+            'custom-css' => __('Custom CSS', 'invoicing'),
439
+        )),
440
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
441
+            'main' => __('Diagnostic Tools', 'invoicing'),
442
+        )),
443 443
     );
444 444
 
445
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
445
+    $sections = apply_filters('wpinv_settings_sections', $sections);
446 446
 
447 447
     return $sections;
448 448
 }
449 449
 
450
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
450
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
451 451
 	$pages_options = array();
452 452
 
453
-	if( $default_label !== NULL && $default_label !== false ) {
454
-		$pages_options = array( '' => $default_label ); // Blank option
453
+	if ($default_label !== NULL && $default_label !== false) {
454
+		$pages_options = array('' => $default_label); // Blank option
455 455
 	}
456 456
 
457 457
 	$pages = get_pages();
458
-	if ( $pages ) {
459
-		foreach ( $pages as $page ) {
458
+	if ($pages) {
459
+		foreach ($pages as $page) {
460 460
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
461
-            $pages_options[ $page->ID ] = $title;
461
+            $pages_options[$page->ID] = $title;
462 462
 		}
463 463
 	}
464 464
 
465 465
 	return $pages_options;
466 466
 }
467 467
 
468
-function wpinv_header_callback( $args ) {
469
-	if ( !empty( $args['desc'] ) ) {
468
+function wpinv_header_callback($args) {
469
+	if (!empty($args['desc'])) {
470 470
         echo $args['desc'];
471 471
     }
472 472
 }
473 473
 
474
-function wpinv_hidden_callback( $args ) {
474
+function wpinv_hidden_callback($args) {
475 475
 	global $wpinv_options;
476 476
 
477
-	if ( isset( $args['set_value'] ) ) {
477
+	if (isset($args['set_value'])) {
478 478
 		$value = $args['set_value'];
479
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
480
-		$value = $wpinv_options[ $args['id'] ];
479
+	} elseif (isset($wpinv_options[$args['id']])) {
480
+		$value = $wpinv_options[$args['id']];
481 481
 	} else {
482
-		$value = isset( $args['std'] ) ? $args['std'] : '';
482
+		$value = isset($args['std']) ? $args['std'] : '';
483 483
 	}
484 484
 
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
485
+	if (isset($args['faux']) && true === $args['faux']) {
486 486
 		$args['readonly'] = true;
487
-		$value = isset( $args['std'] ) ? $args['std'] : '';
487
+		$value = isset($args['std']) ? $args['std'] : '';
488 488
 		$name  = '';
489 489
 	} else {
490
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
490
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
491 491
 	}
492 492
 
493
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
493
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
494 494
     
495 495
 	echo $html;
496 496
 }
@@ -498,61 +498,61 @@  discard block
 block discarded – undo
498 498
 /**
499 499
  * Displays a checkbox settings callback.
500 500
  */
501
-function wpinv_checkbox_callback( $args ) {
501
+function wpinv_checkbox_callback($args) {
502 502
 
503
-	$std = isset( $args['std'] ) ? $args['std'] : '';
504
-	$std = wpinv_get_option( $args['id'], $std );
505
-	$id  = esc_attr( $args['id'] );
503
+	$std = isset($args['std']) ? $args['std'] : '';
504
+	$std = wpinv_get_option($args['id'], $std);
505
+	$id  = esc_attr($args['id']);
506 506
 
507
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
507
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
508 508
 	?>
509 509
 		<fieldset>
510 510
 			<label>
511
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
512
-				<?php echo wp_kses_post( $args['desc'] ); ?>
511
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
512
+				<?php echo wp_kses_post($args['desc']); ?>
513 513
 			</label>
514 514
 		</fieldset>
515 515
 	<?php
516 516
 }
517 517
 
518
-function wpinv_multicheck_callback( $args ) {
518
+function wpinv_multicheck_callback($args) {
519 519
 	
520 520
 	global $wpinv_options;
521 521
 
522
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
523
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
522
+	$sanitize_id = wpinv_sanitize_key($args['id']);
523
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
524 524
 
525
-	if ( ! empty( $args['options'] ) ) {
525
+	if (!empty($args['options'])) {
526 526
 
527
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
528
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
527
+		$std     = isset($args['std']) ? $args['std'] : array();
528
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
529 529
 
530 530
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
531
-        foreach( $args['options'] as $key => $option ):
532
-			$sanitize_key = wpinv_sanitize_key( $key );
533
-			if ( in_array( $sanitize_key, $value ) ) { 
531
+        foreach ($args['options'] as $key => $option):
532
+			$sanitize_key = wpinv_sanitize_key($key);
533
+			if (in_array($sanitize_key, $value)) { 
534 534
 				$enabled = $sanitize_key;
535 535
 			} else { 
536 536
 				$enabled = NULL; 
537 537
 			}
538
-			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;';
539
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
538
+			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;';
539
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
540 540
 		endforeach;
541 541
 		echo '</div>';
542 542
 		echo '<p class="description">' . $args['desc'] . '</p>';
543 543
 	}
544 544
 }
545 545
 
546
-function wpinv_payment_icons_callback( $args ) {
546
+function wpinv_payment_icons_callback($args) {
547 547
 	global $wpinv_options;
548 548
     
549
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
549
+    $sanitize_id = wpinv_sanitize_key($args['id']);
550 550
 
551
-	if ( ! empty( $args['options'] ) ) {
552
-		foreach( $args['options'] as $key => $option ) {
553
-            $sanitize_key = wpinv_sanitize_key( $key );
551
+	if (!empty($args['options'])) {
552
+		foreach ($args['options'] as $key => $option) {
553
+            $sanitize_key = wpinv_sanitize_key($key);
554 554
             
555
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
555
+			if (isset($wpinv_options[$args['id']][$key])) {
556 556
 				$enabled = $option;
557 557
 			} else {
558 558
 				$enabled = NULL;
@@ -560,67 +560,67 @@  discard block
 block discarded – undo
560 560
 
561 561
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
562 562
 
563
-				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;';
563
+				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;';
564 564
 
565
-				if ( wpinv_string_is_image_url( $key ) ) {
566
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565
+				if (wpinv_string_is_image_url($key)) {
566
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
567 567
 				} else {
568
-					$card = strtolower( str_replace( ' ', '', $option ) );
568
+					$card = strtolower(str_replace(' ', '', $option));
569 569
 
570
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
571
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
570
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
571
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
572 572
 					} else {
573
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
573
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
574 574
 						$content_dir = WP_CONTENT_DIR;
575 575
 
576
-						if ( function_exists( 'wp_normalize_path' ) ) {
576
+						if (function_exists('wp_normalize_path')) {
577 577
 							// Replaces backslashes with forward slashes for Windows systems
578
-							$image = wp_normalize_path( $image );
579
-							$content_dir = wp_normalize_path( $content_dir );
578
+							$image = wp_normalize_path($image);
579
+							$content_dir = wp_normalize_path($content_dir);
580 580
 						}
581 581
 
582
-						$image = str_replace( $content_dir, content_url(), $image );
582
+						$image = str_replace($content_dir, content_url(), $image);
583 583
 					}
584 584
 
585
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
585
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
586 586
 				}
587 587
 			echo $option . '</label>';
588 588
 		}
589
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
589
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
590 590
 	}
591 591
 }
592 592
 
593 593
 /**
594 594
  * Displays a radio settings field.
595 595
  */
596
-function wpinv_radio_callback( $args ) {
596
+function wpinv_radio_callback($args) {
597 597
 
598
-	$std = isset( $args['std'] ) ? $args['std'] : '';
599
-	$std = wpinv_get_option( $args['id'], $std );
598
+	$std = isset($args['std']) ? $args['std'] : '';
599
+	$std = wpinv_get_option($args['id'], $std);
600 600
 	?>
601 601
 		<fieldset>
602
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
603
-				<?php foreach( $args['options'] as $key => $option ) : ?>
602
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
603
+				<?php foreach ($args['options'] as $key => $option) : ?>
604 604
 					<li>
605 605
 						<label>
606
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
607
-							<?php echo wp_kses_post( $option ); ?>
606
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
607
+							<?php echo wp_kses_post($option); ?>
608 608
 						</label>
609 609
 					</li>
610 610
 				<?php endforeach; ?>
611 611
 			</ul>
612 612
 		</fieldset>
613 613
 	<?php
614
-	getpaid_settings_description_callback( $args );
614
+	getpaid_settings_description_callback($args);
615 615
 }
616 616
 
617 617
 /**
618 618
  * Displays a description if available.
619 619
  */
620
-function getpaid_settings_description_callback( $args ) {
620
+function getpaid_settings_description_callback($args) {
621 621
 
622
-	if ( ! empty( $args['desc'] ) ) {
623
-		$description = wp_kses_post( $args['desc'] );
622
+	if (!empty($args['desc'])) {
623
+		$description = wp_kses_post($args['desc']);
624 624
 		echo "<p class='description'>$description</p>";
625 625
 	}
626 626
 
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 	</tr>
637 637
 	<tr class="bsui">
638 638
     	<td colspan="2" class="p-0">
639
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
639
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
640 640
 
641 641
 	<?php
642 642
 }
@@ -644,22 +644,22 @@  discard block
 block discarded – undo
644 644
 function wpinv_gateway_select_callback($args) {
645 645
 	global $wpinv_options;
646 646
     
647
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
648
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
647
+    $sanitize_id = wpinv_sanitize_key($args['id']);
648
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
649 649
 
650
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
650
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
651 651
 
652
-	foreach ( $args['options'] as $key => $option ) :
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654
-            $selected = selected( $key, $args['selected'], false );
652
+	foreach ($args['options'] as $key => $option) :
653
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
654
+            $selected = selected($key, $args['selected'], false);
655 655
         } else {
656
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
656
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
657 657
         }
658
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
658
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
659 659
 	endforeach;
660 660
 
661 661
 	echo '</select>';
662
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
662
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
663 663
 }
664 664
 
665 665
 /**
@@ -668,28 +668,28 @@  discard block
 block discarded – undo
668 668
  * @param array $args
669 669
  * @return string
670 670
  */
671
-function wpinv_settings_attrs_helper( $args ) {
671
+function wpinv_settings_attrs_helper($args) {
672 672
 
673
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
674
-	$id           = esc_attr( $args['id'] );
675
-	$placeholder  = esc_attr( $args['placeholder'] );
673
+	$value        = isset($args['std']) ? $args['std'] : '';
674
+	$id           = esc_attr($args['id']);
675
+	$placeholder  = esc_attr($args['placeholder']);
676 676
 
677
-	if ( ! empty( $args['faux'] ) ) {
677
+	if (!empty($args['faux'])) {
678 678
 		$args['readonly'] = true;
679 679
 		$name             = '';
680 680
 	} else {
681
-		$value  = wpinv_get_option( $args['id'], $value );
681
+		$value  = wpinv_get_option($args['id'], $value);
682 682
 		$name   = "wpinv_settings[$id]";
683 683
 	}
684 684
 
685
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
686
-	$class    = esc_attr( $args['class'] );
687
-	$style    = esc_attr( $args['style'] );
688
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
685
+	$value    = is_scalar($value) ? esc_attr($value) : '';
686
+	$class    = esc_attr($args['class']);
687
+	$style    = esc_attr($args['style']);
688
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
689 689
 
690 690
 	$onchange = '';
691
-    if ( ! empty( $args['onchange'] ) ) {
692
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
691
+    if (!empty($args['onchange'])) {
692
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
693 693
 	}
694 694
 
695 695
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -698,11 +698,11 @@  discard block
 block discarded – undo
698 698
 /**
699 699
  * Displays a text input settings callback.
700 700
  */
701
-function wpinv_text_callback( $args ) {
701
+function wpinv_text_callback($args) {
702 702
 
703
-	$desc = wp_kses_post( $args['desc'] );
704
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
705
-	$attr = wpinv_settings_attrs_helper( $args );
703
+	$desc = wp_kses_post($args['desc']);
704
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
705
+	$attr = wpinv_settings_attrs_helper($args);
706 706
 
707 707
 	?>
708 708
 		<label style="width: 100%;">
@@ -716,14 +716,14 @@  discard block
 block discarded – undo
716 716
 /**
717 717
  * Displays a number input settings callback.
718 718
  */
719
-function wpinv_number_callback( $args ) {
719
+function wpinv_number_callback($args) {
720 720
 
721
-	$desc = wp_kses_post( $args['desc'] );
722
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
723
-	$attr = wpinv_settings_attrs_helper( $args );
724
-	$max  = intval( $args['max'] );
725
-	$min  = intval( $args['min'] );
726
-	$step = floatval( $args['step'] );
721
+	$desc = wp_kses_post($args['desc']);
722
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
723
+	$attr = wpinv_settings_attrs_helper($args);
724
+	$max  = intval($args['max']);
725
+	$min  = intval($args['min']);
726
+	$step = floatval($args['step']);
727 727
 
728 728
 	?>
729 729
 		<label style="width: 100%;">
@@ -734,47 +734,47 @@  discard block
 block discarded – undo
734 734
 
735 735
 }
736 736
 
737
-function wpinv_textarea_callback( $args ) {
737
+function wpinv_textarea_callback($args) {
738 738
 	global $wpinv_options;
739 739
     
740
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
740
+    $sanitize_id = wpinv_sanitize_key($args['id']);
741 741
 
742
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
743
-		$value = $wpinv_options[ $args['id'] ];
742
+	if (isset($wpinv_options[$args['id']])) {
743
+		$value = $wpinv_options[$args['id']];
744 744
 	} else {
745
-		$value = isset( $args['std'] ) ? $args['std'] : '';
745
+		$value = isset($args['std']) ? $args['std'] : '';
746 746
 	}
747 747
     
748
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
749
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
748
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
749
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
750 750
 
751
-	$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>';
752
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
751
+	$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>';
752
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
753 753
 
754 754
 	echo $html;
755 755
 }
756 756
 
757
-function wpinv_password_callback( $args ) {
757
+function wpinv_password_callback($args) {
758 758
 	global $wpinv_options;
759 759
     
760
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
760
+    $sanitize_id = wpinv_sanitize_key($args['id']);
761 761
 
762
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
763
-		$value = $wpinv_options[ $args['id'] ];
762
+	if (isset($wpinv_options[$args['id']])) {
763
+		$value = $wpinv_options[$args['id']];
764 764
 	} else {
765
-		$value = isset( $args['std'] ) ? $args['std'] : '';
765
+		$value = isset($args['std']) ? $args['std'] : '';
766 766
 	}
767 767
 
768
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
769
-	$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 ) . '"/>';
770
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
768
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
769
+	$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) . '"/>';
770
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
771 771
 
772 772
 	echo $html;
773 773
 }
774 774
 
775 775
 function wpinv_missing_callback($args) {
776 776
 	printf(
777
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
777
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
778 778
 		'<strong>' . $args['id'] . '</strong>'
779 779
 	);
780 780
 }
@@ -782,35 +782,35 @@  discard block
 block discarded – undo
782 782
 /**
783 783
  * Displays a number input settings callback.
784 784
  */
785
-function wpinv_select_callback( $args ) {
785
+function wpinv_select_callback($args) {
786 786
 
787
-	$desc   = wp_kses_post( $args['desc'] );
788
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
789
-	$attr   = wpinv_settings_attrs_helper( $args );
790
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
791
-	$value  = wpinv_get_option( $args['id'], $value );
792
-	$rand   = uniqid( 'random_id' );
787
+	$desc   = wp_kses_post($args['desc']);
788
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
789
+	$attr   = wpinv_settings_attrs_helper($args);
790
+	$value  = isset($args['std']) ? $args['std'] : '';
791
+	$value  = wpinv_get_option($args['id'], $value);
792
+	$rand   = uniqid('random_id');
793 793
 
794 794
 	?>
795 795
 		<label style="width: 100%;">
796 796
 			<select <?php echo $attr; ?>>
797
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
798
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
799
-				<?php endforeach;?>
797
+				<?php foreach ($args['options'] as $option => $name) : ?>
798
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option>
799
+				<?php endforeach; ?>
800 800
 			</select>
801 801
 
802
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
803
-				<a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a>
802
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
803
+				<a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing') ?></a>
804 804
 			<?php endif; ?>
805 805
 
806
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
807
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a>
806
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
807
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing') ?></a>
808 808
 				<div id='<?php echo $rand; ?>' style='display:none;'>
809 809
 					<div>
810
-						<h3><?php _e( 'Original Content', 'invoicing' ) ?></h3>
811
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea>
812
-						<h3><?php _e( 'Current Content', 'invoicing' ) ?></h3>
813
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea>
810
+						<h3><?php _e('Original Content', 'invoicing') ?></h3>
811
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea>
812
+						<h3><?php _e('Current Content', 'invoicing') ?></h3>
813
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea>
814 814
 					</div>
815 815
 				</div>
816 816
 			<?php endif; ?>
@@ -821,95 +821,95 @@  discard block
 block discarded – undo
821 821
 
822 822
 }
823 823
 
824
-function wpinv_color_select_callback( $args ) {
824
+function wpinv_color_select_callback($args) {
825 825
 	global $wpinv_options;
826 826
     
827
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
827
+    $sanitize_id = wpinv_sanitize_key($args['id']);
828 828
 
829
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
830
-		$value = $wpinv_options[ $args['id'] ];
829
+	if (isset($wpinv_options[$args['id']])) {
830
+		$value = $wpinv_options[$args['id']];
831 831
 	} else {
832
-		$value = isset( $args['std'] ) ? $args['std'] : '';
832
+		$value = isset($args['std']) ? $args['std'] : '';
833 833
 	}
834 834
 
835
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
835
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
836 836
 
837
-	foreach ( $args['options'] as $option => $color ) {
838
-		$selected = selected( $option, $value, false );
839
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
837
+	foreach ($args['options'] as $option => $color) {
838
+		$selected = selected($option, $value, false);
839
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
840 840
 	}
841 841
 
842 842
 	$html .= '</select>';
843
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
843
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
844 844
 
845 845
 	echo $html;
846 846
 }
847 847
 
848
-function wpinv_rich_editor_callback( $args ) {
848
+function wpinv_rich_editor_callback($args) {
849 849
 	global $wpinv_options, $wp_version;
850 850
     
851
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
851
+    $sanitize_id = wpinv_sanitize_key($args['id']);
852 852
 
853
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
854
-		$value = $wpinv_options[ $args['id'] ];
853
+	if (isset($wpinv_options[$args['id']])) {
854
+		$value = $wpinv_options[$args['id']];
855 855
 
856
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
857
-			$value = isset( $args['std'] ) ? $args['std'] : '';
856
+		if (empty($args['allow_blank']) && empty($value)) {
857
+			$value = isset($args['std']) ? $args['std'] : '';
858 858
 		}
859 859
 	} else {
860
-		$value = isset( $args['std'] ) ? $args['std'] : '';
860
+		$value = isset($args['std']) ? $args['std'] : '';
861 861
 	}
862 862
 
863
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
863
+	$rows = isset($args['size']) ? $args['size'] : 20;
864 864
 
865 865
 	$html = '<div class="getpaid-settings-editor-input">';
866
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
866
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
867 867
 		ob_start();
868
-		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 ) );
868
+		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));
869 869
 		$html .= ob_get_clean();
870 870
 	} else {
871
-		$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>';
871
+		$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>';
872 872
 	}
873 873
 
874
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
874
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
875 875
 
876 876
 	echo $html;
877 877
 }
878 878
 
879
-function wpinv_upload_callback( $args ) {
879
+function wpinv_upload_callback($args) {
880 880
 	global $wpinv_options;
881 881
     
882
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
882
+    $sanitize_id = wpinv_sanitize_key($args['id']);
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
884
+	if (isset($wpinv_options[$args['id']])) {
885 885
 		$value = $wpinv_options[$args['id']];
886 886
 	} else {
887 887
 		$value = isset($args['std']) ? $args['std'] : '';
888 888
 	}
889 889
 
890
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
891
-	$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 ) ) . '"/>';
892
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
890
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
891
+	$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)) . '"/>';
892
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
893
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
894 894
 
895 895
 	echo $html;
896 896
 }
897 897
 
898
-function wpinv_color_callback( $args ) {
898
+function wpinv_color_callback($args) {
899 899
 	global $wpinv_options;
900 900
     
901
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
901
+    $sanitize_id = wpinv_sanitize_key($args['id']);
902 902
 
903
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
904
-		$value = $wpinv_options[ $args['id'] ];
903
+	if (isset($wpinv_options[$args['id']])) {
904
+		$value = $wpinv_options[$args['id']];
905 905
 	} else {
906
-		$value = isset( $args['std'] ) ? $args['std'] : '';
906
+		$value = isset($args['std']) ? $args['std'] : '';
907 907
 	}
908 908
 
909
-	$default = isset( $args['std'] ) ? $args['std'] : '';
909
+	$default = isset($args['std']) ? $args['std'] : '';
910 910
 
911
-	$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 ) . '" />';
912
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
911
+	$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) . '" />';
912
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
913 913
 
914 914
 	echo $html;
915 915
 }
@@ -917,9 +917,9 @@  discard block
 block discarded – undo
917 917
 function wpinv_country_states_callback($args) {
918 918
 	global $wpinv_options;
919 919
     
920
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
920
+    $sanitize_id = wpinv_sanitize_key($args['id']);
921 921
 
922
-	if ( isset( $args['placeholder'] ) ) {
922
+	if (isset($args['placeholder'])) {
923 923
 		$placeholder = $args['placeholder'];
924 924
 	} else {
925 925
 		$placeholder = '';
@@ -927,16 +927,16 @@  discard block
 block discarded – undo
927 927
 
928 928
 	$states = wpinv_get_country_states();
929 929
 
930
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
931
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
930
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
931
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
932 932
 
933
-	foreach ( $states as $option => $name ) {
934
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
935
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
933
+	foreach ($states as $option => $name) {
934
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
935
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
936 936
 	}
937 937
 
938 938
 	$html .= '</select>';
939
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
939
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
940 940
 
941 941
 	echo $html;
942 942
 }
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 	</tr>
952 952
 	<tr class="bsui">
953 953
     	<td colspan="2" class="p-0">
954
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
954
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
955 955
 
956 956
 	<?php
957 957
 
@@ -960,14 +960,14 @@  discard block
 block discarded – undo
960 960
 /**
961 961
  * Displays a tax rate' edit row.
962 962
  */
963
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
963
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
964 964
 	ob_start();
965 965
 
966
-	$key                      = sanitize_key( $key );
967
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
968
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
966
+	$key                      = sanitize_key($key);
967
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
968
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
969 969
 
970
-	if ( $echo ) {
970
+	if ($echo) {
971 971
 		echo ob_get_clean();
972 972
 	} else {
973 973
 		return ob_get_clean(); 
@@ -980,134 +980,134 @@  discard block
 block discarded – undo
980 980
     ob_start(); ?>
981 981
     </td><tr>
982 982
     <td colspan="2" class="wpinv_tools_tdbox">
983
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
984
-    <?php do_action( 'wpinv_tools_before' ); ?>
983
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
984
+    <?php do_action('wpinv_tools_before'); ?>
985 985
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
986 986
         <thead>
987 987
             <tr>
988
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
989
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
990
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
988
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
989
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
990
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
991 991
             </tr>
992 992
         </thead>
993 993
 
994 994
         <tbody>
995 995
 			<tr>
996
-                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
996
+                <td><?php _e('Check Pages', 'invoicing'); ?></td>
997 997
                 <td>
998
-                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
998
+                    <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
999 999
                 </td>
1000 1000
                 <td>
1001 1001
 					<a href="<?php
1002 1002
 						echo esc_url(
1003 1003
 							wp_nonce_url(
1004
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1004
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
1005 1005
 								'getpaid-nonce',
1006 1006
 								'getpaid-nonce'
1007 1007
 							)
1008 1008
 						);
1009
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1009
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1010 1010
                 </td>
1011 1011
             </tr>
1012 1012
 			<tr>
1013
-                <td><?php _e( 'Create Database Tables', 'invoicing' );?></td>
1013
+                <td><?php _e('Create Database Tables', 'invoicing'); ?></td>
1014 1014
                 <td>
1015
-                    <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
1015
+                    <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
1016 1016
                 </td>
1017 1017
                 <td>
1018 1018
 					<a href="<?php
1019 1019
 						echo esc_url(
1020 1020
 							wp_nonce_url(
1021
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1021
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
1022 1022
 								'getpaid-nonce',
1023 1023
 								'getpaid-nonce'
1024 1024
 							)
1025 1025
 						);
1026
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1026
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1027 1027
                 </td>
1028 1028
             </tr>
1029 1029
 			<tr>
1030
-                <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td>
1030
+                <td><?php _e('Migrate old invoices', 'invoicing'); ?></td>
1031 1031
                 <td>
1032
-                    <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>
1032
+                    <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>
1033 1033
                 </td>
1034 1034
                 <td>
1035 1035
 					<a href="<?php
1036 1036
 						echo esc_url(
1037 1037
 							wp_nonce_url(
1038
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1038
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
1039 1039
 								'getpaid-nonce',
1040 1040
 								'getpaid-nonce'
1041 1041
 							)
1042 1042
 						);
1043
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1043
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1044 1044
                 </td>
1045 1045
             </tr>
1046 1046
 
1047 1047
 			<tr>
1048
-                <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td>
1048
+                <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td>
1049 1049
                 <td>
1050
-                    <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1050
+                    <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1051 1051
                 </td>
1052 1052
                 <td>
1053 1053
 					<a href="<?php
1054 1054
 						echo esc_url(
1055 1055
 							wp_nonce_url(
1056
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1056
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1057 1057
 								'getpaid-nonce',
1058 1058
 								'getpaid-nonce'
1059 1059
 							)
1060 1060
 						);
1061
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1061
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1062 1062
                 </td>
1063 1063
             </tr>
1064 1064
 
1065
-			<?php do_action( 'wpinv_tools_row' ); ?>
1065
+			<?php do_action('wpinv_tools_row'); ?>
1066 1066
         </tbody>
1067 1067
     </table>
1068
-    <?php do_action( 'wpinv_tools_after' ); ?>
1068
+    <?php do_action('wpinv_tools_after'); ?>
1069 1069
     <?php
1070 1070
     echo ob_get_clean();
1071 1071
 }
1072 1072
 
1073 1073
 
1074
-function wpinv_descriptive_text_callback( $args ) {
1075
-	echo wp_kses_post( $args['desc'] );
1074
+function wpinv_descriptive_text_callback($args) {
1075
+	echo wp_kses_post($args['desc']);
1076 1076
 }
1077 1077
 
1078
-function wpinv_raw_html_callback( $args ) {
1078
+function wpinv_raw_html_callback($args) {
1079 1079
 	echo $args['desc'];
1080 1080
 }
1081 1081
 
1082
-function wpinv_hook_callback( $args ) {
1083
-	do_action( 'wpinv_' . $args['id'], $args );
1082
+function wpinv_hook_callback($args) {
1083
+	do_action('wpinv_' . $args['id'], $args);
1084 1084
 }
1085 1085
 
1086 1086
 function wpinv_set_settings_cap() {
1087 1087
 	return wpinv_get_capability();
1088 1088
 }
1089
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1089
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1090 1090
 
1091
-function wpinv_settings_sanitize_input( $value, $key ) {
1091
+function wpinv_settings_sanitize_input($value, $key) {
1092 1092
 
1093
-    if ( $key == 'tax_rate' ) {
1094
-        $value = wpinv_sanitize_amount( $value );
1095
-        $value = absint( min( $value, 99 ) );
1093
+    if ($key == 'tax_rate') {
1094
+        $value = wpinv_sanitize_amount($value);
1095
+        $value = absint(min($value, 99));
1096 1096
     }
1097 1097
 
1098 1098
     return $value;
1099 1099
 }
1100
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1100
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1101 1101
 
1102
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1103
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1104
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1102
+function wpinv_on_update_settings($old_value, $value, $option) {
1103
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1104
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1105 1105
     
1106
-    if ( $old != $new ) {
1107
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1106
+    if ($old != $new) {
1107
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1108 1108
     }
1109 1109
 }
1110
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1110
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1111 1111
 
1112 1112
 /**
1113 1113
  * Returns the merge tags help text.
@@ -1116,16 +1116,16 @@  discard block
 block discarded – undo
1116 1116
  * 
1117 1117
  * @return string
1118 1118
  */
1119
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1119
+function wpinv_get_merge_tags_help_text($subscription = false) {
1120 1120
 
1121 1121
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1122 1122
 	$link = sprintf(
1123 1123
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1124 1124
 		$url,
1125
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1125
+		esc_html__('View available merge tags.', 'wpinv-quotes')
1126 1126
 	);
1127 1127
 
1128
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1128
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1129 1129
 
1130 1130
 	return "$description $link";
1131 1131
 
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
23
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
23
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
24 24
     }
25 25
 
26 26
     /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function set_admin_menu_class() {
30 30
 		global $current_screen, $parent_file, $submenu_file;
31 31
 
32
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
32
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
33 33
 			$parent_file = 'wpinv';
34 34
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
35 35
         }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function admin_menu() {
40 40
 
41
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
41
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
42 42
         add_menu_page(
43
-            __( 'GetPaid', 'invoicing' ),
44
-            __( 'GetPaid', 'invoicing' ),
43
+            __('GetPaid', 'invoicing'),
44
+            __('GetPaid', 'invoicing'),
45 45
             $capability,
46 46
             'wpinv',
47 47
             null,
48
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
48
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
49 49
             '54.123460'
50 50
         );
51 51
 
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
     public function add_customers_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Customers', 'invoicing' ),
61
-            __( 'Customers', 'invoicing' ),
60
+            __('Customers', 'invoicing'),
61
+            __('Customers', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-customers',
64
-            array( $this, 'customers_page' )
64
+            array($this, 'customers_page')
65 65
         );
66 66
     }
67 67
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     public function add_subscriptions_menu() {
72 72
         add_submenu_page(
73 73
             'wpinv',
74
-            __( 'Subscriptions', 'invoicing' ),
75
-            __( 'Subscriptions', 'invoicing' ),
74
+            __('Subscriptions', 'invoicing'),
75
+            __('Subscriptions', 'invoicing'),
76 76
             wpinv_get_capability(),
77 77
             'wpinv-subscriptions',
78 78
             'wpinv_subscriptions_page'
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * Displays the customers page.
84 84
      */
85 85
     public function customers_page() {
86
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
86
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
87 87
         ?>
88 88
         <div class="wrap wpi-customers-wrap">
89 89
             <style>
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
                     width: 30%;
92 92
                 }
93 93
             </style>
94
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1>
94
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1>
95 95
             <form method="post">
96 96
             <?php
97 97
                 $table = new WPInv_Customers_Table();
98 98
                 $table->prepare_items();
99
-                $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
99
+                $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
100 100
                 $table->display();
101 101
             ?>
102 102
             </form>
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
     public function add_settings_menu() {
111 111
         add_submenu_page(
112 112
             'wpinv',
113
-            __( 'Invoice Settings', 'invoicing' ),
114
-            __( 'Settings', 'invoicing' ),
115
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
113
+            __('Invoice Settings', 'invoicing'),
114
+            __('Settings', 'invoicing'),
115
+            apply_filters('invoicing_capability', wpinv_get_capability()),
116 116
             'wpinv-settings',
117
-            array( $this, 'options_page' )
117
+            array($this, 'options_page')
118 118
         );
119 119
     }
120 120
 
121
-    public function add_addons_menu(){
122
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
121
+    public function add_addons_menu() {
122
+        if (!apply_filters('wpi_show_addons_page', true)) {
123 123
             return;
124 124
         }
125 125
 
@@ -129,80 +129,80 @@  discard block
 block discarded – undo
129 129
             __('Extensions', 'invoicing'),
130 130
             'manage_options',
131 131
             'wpi-addons',
132
-            array( $this, 'addons_page' )
132
+            array($this, 'addons_page')
133 133
         );
134 134
     }
135 135
 
136
-    public function addons_page(){
136
+    public function addons_page() {
137 137
         $addon_obj = new WPInv_Admin_Addons();
138 138
         $addon_obj->output();
139 139
     }
140 140
 
141 141
     function options_page() {
142
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
142
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
143 143
 
144
-        if ( $page !== 'wpinv-settings' ) {
144
+        if ($page !== 'wpinv-settings') {
145 145
             return;
146 146
         }
147 147
 
148 148
         $settings_tabs = wpinv_get_settings_tabs();
149 149
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
150
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
151
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
150
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
151
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
152 152
         $key           = 'main';
153 153
 
154
-        if ( is_array( $sections ) ) {
155
-            $key = key( $sections );
154
+        if (is_array($sections)) {
155
+            $key = key($sections);
156 156
         }
157 157
 
158 158
         add_thickbox();
159 159
 
160
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
161
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
160
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
161
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
162 162
         ob_start();
163 163
         ?>
164 164
         <div class="wrap">
165 165
             <h1 class="nav-tab-wrapper">
166 166
                 <?php
167
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
168
-                    $tab_url = add_query_arg( array(
167
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
168
+                    $tab_url = add_query_arg(array(
169 169
                         'settings-updated' => false,
170 170
                         'tab' => $tab_id,
171
-                    ) );
171
+                    ));
172 172
 
173 173
                     // Remove the section from the tabs so we always end up at the main section
174
-                    $tab_url = remove_query_arg( 'section', $tab_url );
175
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
174
+                    $tab_url = remove_query_arg('section', $tab_url);
175
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
176 176
 
177 177
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
178 178
 
179
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
180
-                    echo esc_html( $tab_name );
179
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
180
+                    echo esc_html($tab_name);
181 181
                     echo '</a>';
182 182
                 }
183 183
                 ?>
184 184
             </h1>
185 185
             <?php
186
-            $number_of_sections = count( $sections );
186
+            $number_of_sections = count($sections);
187 187
             $number = 0;
188
-            if ( $number_of_sections > 1 ) {
188
+            if ($number_of_sections > 1) {
189 189
                 echo '<div><ul class="subsubsub">';
190
-                foreach( $sections as $section_id => $section_name ) {
190
+                foreach ($sections as $section_id => $section_name) {
191 191
                     echo '<li>';
192 192
                     $number++;
193
-                    $tab_url = add_query_arg( array(
193
+                    $tab_url = add_query_arg(array(
194 194
                         'settings-updated' => false,
195 195
                         'tab' => $active_tab,
196 196
                         'section' => $section_id
197
-                    ) );
198
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
197
+                    ));
198
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
199 199
                     $class = '';
200
-                    if ( $section == $section_id ) {
200
+                    if ($section == $section_id) {
201 201
                         $class = 'current';
202 202
                     }
203
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
203
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
204 204
 
205
-                    if ( $number != $number_of_sections ) {
205
+                    if ($number != $number_of_sections) {
206 206
                         echo ' | ';
207 207
                     }
208 208
                     echo '</li>';
@@ -214,20 +214,20 @@  discard block
 block discarded – undo
214 214
                 <form method="post" action="options.php">
215 215
                     <table class="form-table">
216 216
                         <?php
217
-                        settings_fields( 'wpinv_settings' );
217
+                        settings_fields('wpinv_settings');
218 218
 
219
-                        if ( 'main' === $section ) {
220
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
219
+                        if ('main' === $section) {
220
+                            do_action('wpinv_settings_tab_top', $active_tab);
221 221
                         }
222 222
 
223
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
224
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
225
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
226
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
223
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
224
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
225
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
226
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
227 227
 
228 228
                         // For backwards compatibility
229
-                        if ( 'main' === $section ) {
230
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
229
+                        if ('main' === $section) {
230
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
231 231
                         }
232 232
                         ?>
233 233
                     </table>
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     }
242 242
 
243 243
     public function remove_admin_submenus() {
244
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
244
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
245 245
     }
246 246
 
247 247
     /**
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 
252 252
         add_meta_box(
253 253
             'wpinv_endpoints_nav_link',
254
-            __( 'GetPaid endpoints', 'invoicing' ),
255
-            array( $this, 'nav_menu_links' ),
254
+            __('GetPaid endpoints', 'invoicing'),
255
+            array($this, 'nav_menu_links'),
256 256
             'nav-menus',
257 257
             'side',
258 258
             'low'
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         $endpoints = $this->get_menu_items();
268 268
         ?>
269 269
         <div id="invoicing-endpoints" class="posttypediv">
270
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
270
+            <?php if (!empty($endpoints['pages'])) : ?>
271 271
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
272 272
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
273 273
                         <?php
274
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
275
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
274
+                            $walker = new Walker_Nav_Menu_Checklist(array());
275
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
276 276
                         ?>
277 277
                     </ul>
278 278
                 </div>
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
282 282
                 <span class="list-controls hide-if-no-js">
283 283
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
284
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
284
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
285 285
                 </span>
286 286
 
287 287
                 <span class="add-to-menu">
288
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
288
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
289 289
                     <span class="spinner"></span>
290 290
                 </span>
291 291
             </p>
@@ -298,35 +298,35 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return array.
300 300
      */
301
-    public function get_menu_items(){
301
+    public function get_menu_items() {
302 302
         $items = array();
303 303
 
304 304
         $pages = array(
305 305
             array(
306
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
307
-                'label' => __( 'My Invoices', 'invoicing' ),
306
+                'id'    => wpinv_get_option('invoice_history_page'),
307
+                'label' => __('My Invoices', 'invoicing'),
308 308
             ),
309 309
             array(
310
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
311
-                'label' => __( 'My Subscriptions', 'invoicing' ),
310
+                'id'    => wpinv_get_option('invoice_subscription_page'),
311
+                'label' => __('My Subscriptions', 'invoicing'),
312 312
             )
313 313
         );
314 314
 
315
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
315
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
316 316
 
317
-            if ( (int) $page['id'] > 0 ) {
317
+            if ((int) $page['id'] > 0) {
318 318
 
319 319
                 $item                   = new stdClass();
320 320
                 $item->object_id        = (int) $page['id'];
321 321
                 $item->db_id            = 0;
322
-                $item->object           =  'page';
322
+                $item->object           = 'page';
323 323
                 $item->menu_item_parent = 0;
324 324
                 $item->type             = 'post_type';
325
-                $item->title            = sanitize_text_field( $page['label'] );
326
-                $item->url              = get_permalink( (int) $page['id'] );
325
+                $item->title            = sanitize_text_field($page['label']);
326
+                $item->url              = get_permalink((int) $page['id']);
327 327
                 $item->target           = '';
328 328
                 $item->attr_title       = '';
329
-                $item->classes          = array( 'wpinv-menu-item' );
329
+                $item->classes          = array('wpinv-menu-item');
330 330
                 $item->xfn              = '';
331 331
 
332 332
                 $items['pages'][]       = $item;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 
336 336
         }
337 337
 
338
-        return apply_filters( 'wpinv_menu_items', $items );
338
+        return apply_filters('wpinv_menu_items', $items);
339 339
     }
340 340
 
341 341
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 2 patches
Indentation   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -20,222 +20,222 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class GetPaid_Installer {
22 22
 
23
-	/**
24
-	 * Upgrades the install.
25
-	 *
26
-	 * @param string $upgrade_from The current invoicing version.
27
-	 */
28
-	public function upgrade_db( $upgrade_from ) {
29
-
30
-		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
32
-
33
-		// Setup the invoice Custom Post Type.
34
-		GetPaid_Post_Types::register_post_types();
35
-
36
-		// Clear the permalinks
37
-		flush_rewrite_rules();
38
-
39
-		// Maybe create new/missing pages.
40
-		$this->create_pages();
41
-
42
-		// Maybe re(add) admin capabilities.
43
-		$this->add_capabilities();
44
-
45
-		// Maybe create the default payment form.
46
-		wpinv_get_default_payment_form();
47
-
48
-		// Create any missing database tables.
49
-		$method = "upgrade_from_$upgrade_from";
50
-
51
-		if ( method_exists( $this, $method ) ) {
52
-			$this->$method();
53
-		}
54
-
55
-	}
56
-
57
-	/**
58
-	 * Do a fresh install.
59
-	 *
60
-	 */
61
-	public function upgrade_from_0() {
62
-		$this->create_subscriptions_table();
63
-		$this->create_invoices_table();
64
-		$this->create_invoice_items_table();
65
-
66
-		// Save default tax rates.
67
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
68
-	}
69
-
70
-	/**
71
-	 * Upgrade to 0.0.5
72
-	 *
73
-	 */
74
-	public function upgrade_from_004() {
75
-		global $wpdb;
76
-
77
-		// Invoices.
78
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
79
-		if ( ! empty( $results ) ) {
80
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
81
-
82
-			// Clean post cache
83
-			foreach ( $results as $row ) {
84
-				clean_post_cache( $row->ID );
85
-			}
86
-
87
-		}
88
-
89
-		// Item meta key changes
90
-		$query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
91
-		$results = $wpdb->get_results( $query );
92
-
93
-		if ( ! empty( $results ) ) {
94
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
95
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
96
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
97
-
98
-			foreach ( $results as $row ) {
99
-				clean_post_cache( $row->post_id );
100
-			}
101
-
102
-		}
103
-
104
-		$this->upgrade_from_102();
105
-	}
106
-
107
-	/**
108
-	 * Upgrade to 1.0.3
109
-	 *
110
-	 */
111
-	public function upgrade_from_102() {
112
-		$this->create_subscriptions_table();
113
-		$this->upgrade_from_118();
114
-	}
115
-
116
-	/**
117
-	 * Upgrade to version 2.0.0.
118
-	 *
119
-	 */
120
-	public function upgrade_from_118() {
121
-		$this->create_invoices_table();
122
-		$this->create_invoice_items_table();
123
-		$this->migrate_old_invoices();
124
-	}
125
-
126
-	/**
127
-	 * Upgrade to version 2.0.8.
128
-	 *
129
-	 */
130
-	public function upgrade_from_207() {
131
-		global $wpdb;
132
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
133
-	}
134
-
135
-	/**
136
-	 * Give administrators the capability to manage GetPaid.
137
-	 *
138
-	 */
139
-	public function add_capabilities() {
140
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
141
-	}
142
-
143
-	/**
144
-	 * Retreives GetPaid pages.
145
-	 *
146
-	 */
147
-	public static function get_pages() {
148
-
149
-		return apply_filters(
150
-			'wpinv_create_pages',
151
-			array(
152
-
153
-				// Checkout page.
154
-				'checkout_page' => array(
155
-					'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
156
-					'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
157
-					'content'   => '
23
+    /**
24
+     * Upgrades the install.
25
+     *
26
+     * @param string $upgrade_from The current invoicing version.
27
+     */
28
+    public function upgrade_db( $upgrade_from ) {
29
+
30
+        // Save the current invoicing version.
31
+        update_option( 'wpinv_version', WPINV_VERSION );
32
+
33
+        // Setup the invoice Custom Post Type.
34
+        GetPaid_Post_Types::register_post_types();
35
+
36
+        // Clear the permalinks
37
+        flush_rewrite_rules();
38
+
39
+        // Maybe create new/missing pages.
40
+        $this->create_pages();
41
+
42
+        // Maybe re(add) admin capabilities.
43
+        $this->add_capabilities();
44
+
45
+        // Maybe create the default payment form.
46
+        wpinv_get_default_payment_form();
47
+
48
+        // Create any missing database tables.
49
+        $method = "upgrade_from_$upgrade_from";
50
+
51
+        if ( method_exists( $this, $method ) ) {
52
+            $this->$method();
53
+        }
54
+
55
+    }
56
+
57
+    /**
58
+     * Do a fresh install.
59
+     *
60
+     */
61
+    public function upgrade_from_0() {
62
+        $this->create_subscriptions_table();
63
+        $this->create_invoices_table();
64
+        $this->create_invoice_items_table();
65
+
66
+        // Save default tax rates.
67
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
68
+    }
69
+
70
+    /**
71
+     * Upgrade to 0.0.5
72
+     *
73
+     */
74
+    public function upgrade_from_004() {
75
+        global $wpdb;
76
+
77
+        // Invoices.
78
+        $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
79
+        if ( ! empty( $results ) ) {
80
+            $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
81
+
82
+            // Clean post cache
83
+            foreach ( $results as $row ) {
84
+                clean_post_cache( $row->ID );
85
+            }
86
+
87
+        }
88
+
89
+        // Item meta key changes
90
+        $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
91
+        $results = $wpdb->get_results( $query );
92
+
93
+        if ( ! empty( $results ) ) {
94
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
95
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
96
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
97
+
98
+            foreach ( $results as $row ) {
99
+                clean_post_cache( $row->post_id );
100
+            }
101
+
102
+        }
103
+
104
+        $this->upgrade_from_102();
105
+    }
106
+
107
+    /**
108
+     * Upgrade to 1.0.3
109
+     *
110
+     */
111
+    public function upgrade_from_102() {
112
+        $this->create_subscriptions_table();
113
+        $this->upgrade_from_118();
114
+    }
115
+
116
+    /**
117
+     * Upgrade to version 2.0.0.
118
+     *
119
+     */
120
+    public function upgrade_from_118() {
121
+        $this->create_invoices_table();
122
+        $this->create_invoice_items_table();
123
+        $this->migrate_old_invoices();
124
+    }
125
+
126
+    /**
127
+     * Upgrade to version 2.0.8.
128
+     *
129
+     */
130
+    public function upgrade_from_207() {
131
+        global $wpdb;
132
+        $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
133
+    }
134
+
135
+    /**
136
+     * Give administrators the capability to manage GetPaid.
137
+     *
138
+     */
139
+    public function add_capabilities() {
140
+        $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
141
+    }
142
+
143
+    /**
144
+     * Retreives GetPaid pages.
145
+     *
146
+     */
147
+    public static function get_pages() {
148
+
149
+        return apply_filters(
150
+            'wpinv_create_pages',
151
+            array(
152
+
153
+                // Checkout page.
154
+                'checkout_page' => array(
155
+                    'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
156
+                    'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
157
+                    'content'   => '
158 158
 						<!-- wp:shortcode -->
159 159
 						[wpinv_checkout]
160 160
 						<!-- /wp:shortcode -->
161 161
 					',
162
-					'parent'    => '',
163
-				),
164
-
165
-				// Invoice history page.
166
-				'invoice_history_page' => array(
167
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
168
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
169
-					'content' => '
162
+                    'parent'    => '',
163
+                ),
164
+
165
+                // Invoice history page.
166
+                'invoice_history_page' => array(
167
+                    'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
168
+                    'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
169
+                    'content' => '
170 170
 					<!-- wp:shortcode -->
171 171
 					[wpinv_history]
172 172
 					<!-- /wp:shortcode -->
173 173
 				',
174
-					'parent'  => '',
175
-				),
176
-
177
-				// Success page content.
178
-				'success_page' => array(
179
-					'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
180
-					'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
181
-					'content'  => '
174
+                    'parent'  => '',
175
+                ),
176
+
177
+                // Success page content.
178
+                'success_page' => array(
179
+                    'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
180
+                    'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
181
+                    'content'  => '
182 182
 					<!-- wp:shortcode -->
183 183
 					[wpinv_receipt]
184 184
 					<!-- /wp:shortcode -->
185 185
 				',
186
-					'parent'   => 'gp-checkout',
187
-				),
188
-
189
-				// Failure page content.
190
-				'failure_page' => array(
191
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
192
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
193
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
194
-					'parent'  => 'gp-checkout',
195
-				),
196
-
197
-				// Subscriptions history page.
198
-				'invoice_subscription_page' => array(
199
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
200
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
201
-					'content' => '
186
+                    'parent'   => 'gp-checkout',
187
+                ),
188
+
189
+                // Failure page content.
190
+                'failure_page' => array(
191
+                    'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
192
+                    'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
193
+                    'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
194
+                    'parent'  => 'gp-checkout',
195
+                ),
196
+
197
+                // Subscriptions history page.
198
+                'invoice_subscription_page' => array(
199
+                    'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
200
+                    'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
201
+                    'content' => '
202 202
 					<!-- wp:shortcode -->
203 203
 					[wpinv_subscriptions]
204 204
 					<!-- /wp:shortcode -->
205 205
 				',
206
-					'parent' => '',
207
-				),
206
+                    'parent' => '',
207
+                ),
208 208
 
209
-			)
210
-		);
209
+            )
210
+        );
211 211
 
212
-	}
212
+    }
213 213
 
214
-	/**
215
-	 * Re-create GetPaid pages.
216
-	 *
217
-	 */
218
-	public function create_pages() {
214
+    /**
215
+     * Re-create GetPaid pages.
216
+     *
217
+     */
218
+    public function create_pages() {
219 219
 
220
-		foreach ( self::get_pages() as $key => $page ) {
221
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
222
-		}
220
+        foreach ( self::get_pages() as $key => $page ) {
221
+            wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
222
+        }
223 223
 
224
-	}
224
+    }
225 225
 
226
-	/**
227
-	 * Create subscriptions table.
228
-	 *
229
-	 */
230
-	public function create_subscriptions_table() {
226
+    /**
227
+     * Create subscriptions table.
228
+     *
229
+     */
230
+    public function create_subscriptions_table() {
231 231
 
232
-		global $wpdb;
232
+        global $wpdb;
233 233
 
234
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
234
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
235 235
 
236
-		// Create tables.
237
-		$charset_collate = $wpdb->get_charset_collate();
238
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
236
+        // Create tables.
237
+        $charset_collate = $wpdb->get_charset_collate();
238
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
239 239
 			id bigint(20) unsigned NOT NULL auto_increment,
240 240
 			customer_id bigint(20) NOT NULL,
241 241
 			frequency int(11) NOT NULL DEFAULT '1',
@@ -258,22 +258,22 @@  discard block
 block discarded – undo
258 258
 			KEY customer_and_status (customer_id, status)
259 259
 		  ) $charset_collate;";
260 260
 
261
-		dbDelta( $sql );
261
+        dbDelta( $sql );
262 262
 
263
-	}
263
+    }
264 264
 
265
-	/**
266
-	 * Create invoices table.
267
-	 *
268
-	 */
269
-	public function create_invoices_table() {
270
-		global $wpdb;
265
+    /**
266
+     * Create invoices table.
267
+     *
268
+     */
269
+    public function create_invoices_table() {
270
+        global $wpdb;
271 271
 
272
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
272
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
273 273
 
274
-		// Create tables.
275
-		$charset_collate = $wpdb->get_charset_collate();
276
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
274
+        // Create tables.
275
+        $charset_collate = $wpdb->get_charset_collate();
276
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
277 277
 			post_id BIGINT(20) NOT NULL,
278 278
             `number` VARCHAR(100),
279 279
             `key` VARCHAR(100),
@@ -309,22 +309,22 @@  discard block
 block discarded – undo
309 309
 			KEY `key` (`key`)
310 310
 		  ) $charset_collate;";
311 311
 
312
-		dbDelta( $sql );
312
+        dbDelta( $sql );
313 313
 
314
-	}
314
+    }
315 315
 
316
-	/**
317
-	 * Create invoice items table.
318
-	 *
319
-	 */
320
-	public function create_invoice_items_table() {
321
-		global $wpdb;
316
+    /**
317
+     * Create invoice items table.
318
+     *
319
+     */
320
+    public function create_invoice_items_table() {
321
+        global $wpdb;
322 322
 
323
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
323
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
324 324
 
325
-		// Create tables.
326
-		$charset_collate = $wpdb->get_charset_collate();
327
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
325
+        // Create tables.
326
+        $charset_collate = $wpdb->get_charset_collate();
327
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
328 328
 			ID BIGINT(20) NOT NULL AUTO_INCREMENT,
329 329
             post_id BIGINT(20) NOT NULL,
330 330
             item_id BIGINT(20) NOT NULL,
@@ -346,159 +346,159 @@  discard block
 block discarded – undo
346 346
 			KEY post_id (post_id)
347 347
 		  ) $charset_collate;";
348 348
 
349
-		dbDelta( $sql );
350
-
351
-	}
352
-
353
-	/**
354
-	 * Migrates old invoices to new invoices.
355
-	 *
356
-	 */
357
-	public function migrate_old_invoices() {
358
-		global $wpdb;
359
-
360
-		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
361
-		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
362
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
363
-		$invoices            = array_unique(
364
-			get_posts(
365
-				array(
366
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
367
-					'posts_per_page' => -1,
368
-					'fields'         => 'ids',
369
-					'post_status'    => array_keys( get_post_stati() ),
370
-					'exclude'        => (array) $migrated,
371
-				)
372
-			)
373
-		);
374
-
375
-		// Abort if we do not have any invoices.
376
-		if ( empty( $invoices ) ) {
377
-			return;
378
-		}
379
-
380
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
381
-
382
-		$invoice_rows = array();
383
-		foreach ( $invoices as $invoice ) {
384
-
385
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
386
-
387
-			if ( empty( $invoice->ID ) ) {
388
-				return;
389
-			}
390
-
391
-			$fields = array (
392
-				'post_id'        => $invoice->ID,
393
-				'number'         => $invoice->get_number(),
394
-				'key'            => $invoice->get_key(),
395
-				'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
396
-				'mode'           => $invoice->mode,
397
-				'user_ip'        => $invoice->get_ip(),
398
-				'first_name'     => $invoice->get_first_name(),
399
-				'last_name'      => $invoice->get_last_name(),
400
-				'address'        => $invoice->get_address(),
401
-				'city'           => $invoice->city,
402
-				'state'          => $invoice->state,
403
-				'country'        => $invoice->country,
404
-				'zip'            => $invoice->zip,
405
-				'adddress_confirmed' => (int) $invoice->adddress_confirmed,
406
-				'gateway'        => $invoice->get_gateway(),
407
-				'transaction_id' => $invoice->get_transaction_id(),
408
-				'currency'       => $invoice->get_currency(),
409
-				'subtotal'       => $invoice->get_subtotal(),
410
-				'tax'            => $invoice->get_tax(),
411
-				'fees_total'     => $invoice->get_fees_total(),
412
-				'total'          => $invoice->get_total(),
413
-				'discount'       => $invoice->get_discount(),
414
-				'discount_code'  => $invoice->get_discount_code(),
415
-				'disable_taxes'  => $invoice->disable_taxes,
416
-				'due_date'       => $invoice->get_due_date(),
417
-				'completed_date' => $invoice->get_completed_date(),
418
-				'company'        => $invoice->company,
419
-				'vat_number'     => $invoice->vat_number,
420
-				'vat_rate'       => $invoice->vat_rate,
421
-				'custom_meta'    => $invoice->payment_meta
422
-			);
423
-
424
-			foreach ( $fields as $key => $val ) {
425
-				if ( is_null( $val ) ) {
426
-					$val = '';
427
-				}
428
-				$val = maybe_serialize( $val );
429
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
430
-			}
431
-
432
-			$fields = implode( ', ', $fields );
433
-			$invoice_rows[] = "($fields)";
434
-
435
-			$item_rows    = array();
436
-			$item_columns = array();
437
-			foreach ( $invoice->get_cart_details() as $details ) {
438
-				$fields = array(
439
-					'post_id'          => $invoice->ID,
440
-					'item_id'          => $details['id'],
441
-					'item_name'        => $details['name'],
442
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
443
-					'vat_rate'         => $details['vat_rate'],
444
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
445
-					'tax'              => $details['tax'],
446
-					'item_price'       => $details['item_price'],
447
-					'custom_price'     => $details['custom_price'],
448
-					'quantity'         => $details['quantity'],
449
-					'discount'         => $details['discount'],
450
-					'subtotal'         => $details['subtotal'],
451
-					'price'            => $details['price'],
452
-					'meta'             => $details['meta'],
453
-					'fees'             => $details['fees'],
454
-				);
455
-
456
-				$item_columns = array_keys ( $fields );
457
-
458
-				foreach ( $fields as $key => $val ) {
459
-					if ( is_null( $val ) ) {
460
-						$val = '';
461
-					}
462
-					$val = maybe_serialize( $val );
463
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
464
-				}
465
-
466
-				$fields = implode( ', ', $fields );
467
-				$item_rows[] = "($fields)";
468
-			}
469
-
470
-			$item_rows    = implode( ', ', $item_rows );
471
-			$item_columns = implode( ', ', $item_columns );
472
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
473
-		}
474
-
475
-		if ( empty( $invoice_rows ) ) {
476
-			return;
477
-		}
478
-
479
-		$invoice_rows = implode( ', ', $invoice_rows );
480
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
481
-
482
-	}
483
-
484
-	/**
485
-	 * Migrates old invoices to new invoices.
486
-	 *
487
-	 */
488
-	public static function rename_gateways_label() {
489
-		global $wpdb;
490
-
491
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
492
-
493
-			$wpdb->update(
494
-				$wpdb->prefix . 'getpaid_invoices',
495
-				array( 'gateway' => $gateway ),
496
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
497
-				'%s',
498
-				'%s'
499
-			);
500
-
501
-		}
502
-	}
349
+        dbDelta( $sql );
350
+
351
+    }
352
+
353
+    /**
354
+     * Migrates old invoices to new invoices.
355
+     *
356
+     */
357
+    public function migrate_old_invoices() {
358
+        global $wpdb;
359
+
360
+        $invoices_table      = $wpdb->prefix . 'getpaid_invoices';
361
+        $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
362
+        $migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
363
+        $invoices            = array_unique(
364
+            get_posts(
365
+                array(
366
+                    'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
367
+                    'posts_per_page' => -1,
368
+                    'fields'         => 'ids',
369
+                    'post_status'    => array_keys( get_post_stati() ),
370
+                    'exclude'        => (array) $migrated,
371
+                )
372
+            )
373
+        );
374
+
375
+        // Abort if we do not have any invoices.
376
+        if ( empty( $invoices ) ) {
377
+            return;
378
+        }
379
+
380
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
381
+
382
+        $invoice_rows = array();
383
+        foreach ( $invoices as $invoice ) {
384
+
385
+            $invoice = new WPInv_Legacy_Invoice( $invoice );
386
+
387
+            if ( empty( $invoice->ID ) ) {
388
+                return;
389
+            }
390
+
391
+            $fields = array (
392
+                'post_id'        => $invoice->ID,
393
+                'number'         => $invoice->get_number(),
394
+                'key'            => $invoice->get_key(),
395
+                'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
396
+                'mode'           => $invoice->mode,
397
+                'user_ip'        => $invoice->get_ip(),
398
+                'first_name'     => $invoice->get_first_name(),
399
+                'last_name'      => $invoice->get_last_name(),
400
+                'address'        => $invoice->get_address(),
401
+                'city'           => $invoice->city,
402
+                'state'          => $invoice->state,
403
+                'country'        => $invoice->country,
404
+                'zip'            => $invoice->zip,
405
+                'adddress_confirmed' => (int) $invoice->adddress_confirmed,
406
+                'gateway'        => $invoice->get_gateway(),
407
+                'transaction_id' => $invoice->get_transaction_id(),
408
+                'currency'       => $invoice->get_currency(),
409
+                'subtotal'       => $invoice->get_subtotal(),
410
+                'tax'            => $invoice->get_tax(),
411
+                'fees_total'     => $invoice->get_fees_total(),
412
+                'total'          => $invoice->get_total(),
413
+                'discount'       => $invoice->get_discount(),
414
+                'discount_code'  => $invoice->get_discount_code(),
415
+                'disable_taxes'  => $invoice->disable_taxes,
416
+                'due_date'       => $invoice->get_due_date(),
417
+                'completed_date' => $invoice->get_completed_date(),
418
+                'company'        => $invoice->company,
419
+                'vat_number'     => $invoice->vat_number,
420
+                'vat_rate'       => $invoice->vat_rate,
421
+                'custom_meta'    => $invoice->payment_meta
422
+            );
423
+
424
+            foreach ( $fields as $key => $val ) {
425
+                if ( is_null( $val ) ) {
426
+                    $val = '';
427
+                }
428
+                $val = maybe_serialize( $val );
429
+                $fields[ $key ] = $wpdb->prepare( '%s', $val );
430
+            }
431
+
432
+            $fields = implode( ', ', $fields );
433
+            $invoice_rows[] = "($fields)";
434
+
435
+            $item_rows    = array();
436
+            $item_columns = array();
437
+            foreach ( $invoice->get_cart_details() as $details ) {
438
+                $fields = array(
439
+                    'post_id'          => $invoice->ID,
440
+                    'item_id'          => $details['id'],
441
+                    'item_name'        => $details['name'],
442
+                    'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
443
+                    'vat_rate'         => $details['vat_rate'],
444
+                    'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
445
+                    'tax'              => $details['tax'],
446
+                    'item_price'       => $details['item_price'],
447
+                    'custom_price'     => $details['custom_price'],
448
+                    'quantity'         => $details['quantity'],
449
+                    'discount'         => $details['discount'],
450
+                    'subtotal'         => $details['subtotal'],
451
+                    'price'            => $details['price'],
452
+                    'meta'             => $details['meta'],
453
+                    'fees'             => $details['fees'],
454
+                );
455
+
456
+                $item_columns = array_keys ( $fields );
457
+
458
+                foreach ( $fields as $key => $val ) {
459
+                    if ( is_null( $val ) ) {
460
+                        $val = '';
461
+                    }
462
+                    $val = maybe_serialize( $val );
463
+                    $fields[ $key ] = $wpdb->prepare( '%s', $val );
464
+                }
465
+
466
+                $fields = implode( ', ', $fields );
467
+                $item_rows[] = "($fields)";
468
+            }
469
+
470
+            $item_rows    = implode( ', ', $item_rows );
471
+            $item_columns = implode( ', ', $item_columns );
472
+            $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
473
+        }
474
+
475
+        if ( empty( $invoice_rows ) ) {
476
+            return;
477
+        }
478
+
479
+        $invoice_rows = implode( ', ', $invoice_rows );
480
+        $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
481
+
482
+    }
483
+
484
+    /**
485
+     * Migrates old invoices to new invoices.
486
+     *
487
+     */
488
+    public static function rename_gateways_label() {
489
+        global $wpdb;
490
+
491
+        foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
492
+
493
+            $wpdb->update(
494
+                $wpdb->prefix . 'getpaid_invoices',
495
+                array( 'gateway' => $gateway ),
496
+                array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
497
+                '%s',
498
+                '%s'
499
+            );
500
+
501
+        }
502
+    }
503 503
 
504 504
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.0.2
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * The main installer/updater class.
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param string $upgrade_from The current invoicing version.
27 27
 	 */
28
-	public function upgrade_db( $upgrade_from ) {
28
+	public function upgrade_db($upgrade_from) {
29 29
 
30 30
 		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
31
+		update_option('wpinv_version', WPINV_VERSION);
32 32
 
33 33
 		// Setup the invoice Custom Post Type.
34 34
 		GetPaid_Post_Types::register_post_types();
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		// Create any missing database tables.
49 49
 		$method = "upgrade_from_$upgrade_from";
50 50
 
51
-		if ( method_exists( $this, $method ) ) {
51
+		if (method_exists($this, $method)) {
52 52
 			$this->$method();
53 53
 		}
54 54
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		$this->create_invoice_items_table();
65 65
 
66 66
 		// Save default tax rates.
67
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
67
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
68 68
 	}
69 69
 
70 70
 	/**
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
 		global $wpdb;
76 76
 
77 77
 		// Invoices.
78
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
79
-		if ( ! empty( $results ) ) {
80
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
78
+		$results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
79
+		if (!empty($results)) {
80
+			$wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
81 81
 
82 82
 			// Clean post cache
83
-			foreach ( $results as $row ) {
84
-				clean_post_cache( $row->ID );
83
+			foreach ($results as $row) {
84
+				clean_post_cache($row->ID);
85 85
 			}
86 86
 
87 87
 		}
88 88
 
89 89
 		// Item meta key changes
90 90
 		$query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
91
-		$results = $wpdb->get_results( $query );
91
+		$results = $wpdb->get_results($query);
92 92
 
93
-		if ( ! empty( $results ) ) {
94
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
95
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
96
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
93
+		if (!empty($results)) {
94
+			$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
95
+			$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
96
+			$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
97 97
 
98
-			foreach ( $results as $row ) {
99
-				clean_post_cache( $row->post_id );
98
+			foreach ($results as $row) {
99
+				clean_post_cache($row->post_id);
100 100
 			}
101 101
 
102 102
 		}
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function upgrade_from_207() {
131 131
 		global $wpdb;
132
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
132
+		$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);");
133 133
 	}
134 134
 
135 135
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 */
139 139
 	public function add_capabilities() {
140
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
140
+		$GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing');
141 141
 	}
142 142
 
143 143
 	/**
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 
153 153
 				// Checkout page.
154 154
 				'checkout_page' => array(
155
-					'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
156
-					'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
155
+					'name'      => _x('gp-checkout', 'Page slug', 'invoicing'),
156
+					'title'     => _x('Checkout', 'Page title', 'invoicing'),
157 157
 					'content'   => '
158 158
 						<!-- wp:shortcode -->
159 159
 						[wpinv_checkout]
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 
165 165
 				// Invoice history page.
166 166
 				'invoice_history_page' => array(
167
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
168
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
167
+					'name'    => _x('gp-invoices', 'Page slug', 'invoicing'),
168
+					'title'   => _x('My Invoices', 'Page title', 'invoicing'),
169 169
 					'content' => '
170 170
 					<!-- wp:shortcode -->
171 171
 					[wpinv_history]
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 
177 177
 				// Success page content.
178 178
 				'success_page' => array(
179
-					'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
180
-					'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
179
+					'name'     => _x('gp-receipt', 'Page slug', 'invoicing'),
180
+					'title'    => _x('Payment Confirmation', 'Page title', 'invoicing'),
181 181
 					'content'  => '
182 182
 					<!-- wp:shortcode -->
183 183
 					[wpinv_receipt]
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 
189 189
 				// Failure page content.
190 190
 				'failure_page' => array(
191
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
192
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
193
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
191
+					'name'    => _x('gp-transaction-failed', 'Page slug', 'invoicing'),
192
+					'title'   => _x('Transaction Failed', 'Page title', 'invoicing'),
193
+					'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
194 194
 					'parent'  => 'gp-checkout',
195 195
 				),
196 196
 
197 197
 				// Subscriptions history page.
198 198
 				'invoice_subscription_page' => array(
199
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
200
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
199
+					'name'    => _x('gp-subscriptions', 'Page slug', 'invoicing'),
200
+					'title'   => _x('My Subscriptions', 'Page title', 'invoicing'),
201 201
 					'content' => '
202 202
 					<!-- wp:shortcode -->
203 203
 					[wpinv_subscriptions]
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	public function create_pages() {
219 219
 
220
-		foreach ( self::get_pages() as $key => $page ) {
221
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
220
+		foreach (self::get_pages() as $key => $page) {
221
+			wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']);
222 222
 		}
223 223
 
224 224
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 		global $wpdb;
233 233
 
234
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
234
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
235 235
 
236 236
 		// Create tables.
237 237
 		$charset_collate = $wpdb->get_charset_collate();
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			KEY customer_and_status (customer_id, status)
259 259
 		  ) $charset_collate;";
260 260
 
261
-		dbDelta( $sql );
261
+		dbDelta($sql);
262 262
 
263 263
 	}
264 264
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	public function create_invoices_table() {
270 270
 		global $wpdb;
271 271
 
272
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
272
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
273 273
 
274 274
 		// Create tables.
275 275
 		$charset_collate = $wpdb->get_charset_collate();
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 			KEY `key` (`key`)
310 310
 		  ) $charset_collate;";
311 311
 
312
-		dbDelta( $sql );
312
+		dbDelta($sql);
313 313
 
314 314
 	}
315 315
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	public function create_invoice_items_table() {
321 321
 		global $wpdb;
322 322
 
323
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
323
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
324 324
 
325 325
 		// Create tables.
326 326
 		$charset_collate = $wpdb->get_charset_collate();
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 			KEY post_id (post_id)
347 347
 		  ) $charset_collate;";
348 348
 
349
-		dbDelta( $sql );
349
+		dbDelta($sql);
350 350
 
351 351
 	}
352 352
 
@@ -359,40 +359,40 @@  discard block
 block discarded – undo
359 359
 
360 360
 		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
361 361
 		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
362
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
362
+		$migrated            = $wpdb->get_col("SELECT post_id FROM $invoices_table");
363 363
 		$invoices            = array_unique(
364 364
 			get_posts(
365 365
 				array(
366
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
366
+					'post_type'      => array('wpi_invoice', 'wpi_quote'),
367 367
 					'posts_per_page' => -1,
368 368
 					'fields'         => 'ids',
369
-					'post_status'    => array_keys( get_post_stati() ),
369
+					'post_status'    => array_keys(get_post_stati()),
370 370
 					'exclude'        => (array) $migrated,
371 371
 				)
372 372
 			)
373 373
 		);
374 374
 
375 375
 		// Abort if we do not have any invoices.
376
-		if ( empty( $invoices ) ) {
376
+		if (empty($invoices)) {
377 377
 			return;
378 378
 		}
379 379
 
380
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
380
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php');
381 381
 
382 382
 		$invoice_rows = array();
383
-		foreach ( $invoices as $invoice ) {
383
+		foreach ($invoices as $invoice) {
384 384
 
385
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
385
+			$invoice = new WPInv_Legacy_Invoice($invoice);
386 386
 
387
-			if ( empty( $invoice->ID ) ) {
387
+			if (empty($invoice->ID)) {
388 388
 				return;
389 389
 			}
390 390
 
391
-			$fields = array (
391
+			$fields = array(
392 392
 				'post_id'        => $invoice->ID,
393 393
 				'number'         => $invoice->get_number(),
394 394
 				'key'            => $invoice->get_key(),
395
-				'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
395
+				'type'           => str_replace('wpi_', '', $invoice->post_type),
396 396
 				'mode'           => $invoice->mode,
397 397
 				'user_ip'        => $invoice->get_ip(),
398 398
 				'first_name'     => $invoice->get_first_name(),
@@ -421,27 +421,27 @@  discard block
 block discarded – undo
421 421
 				'custom_meta'    => $invoice->payment_meta
422 422
 			);
423 423
 
424
-			foreach ( $fields as $key => $val ) {
425
-				if ( is_null( $val ) ) {
424
+			foreach ($fields as $key => $val) {
425
+				if (is_null($val)) {
426 426
 					$val = '';
427 427
 				}
428
-				$val = maybe_serialize( $val );
429
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
428
+				$val = maybe_serialize($val);
429
+				$fields[$key] = $wpdb->prepare('%s', $val);
430 430
 			}
431 431
 
432
-			$fields = implode( ', ', $fields );
432
+			$fields = implode(', ', $fields);
433 433
 			$invoice_rows[] = "($fields)";
434 434
 
435 435
 			$item_rows    = array();
436 436
 			$item_columns = array();
437
-			foreach ( $invoice->get_cart_details() as $details ) {
437
+			foreach ($invoice->get_cart_details() as $details) {
438 438
 				$fields = array(
439 439
 					'post_id'          => $invoice->ID,
440 440
 					'item_id'          => $details['id'],
441 441
 					'item_name'        => $details['name'],
442
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
442
+					'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
443 443
 					'vat_rate'         => $details['vat_rate'],
444
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
444
+					'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
445 445
 					'tax'              => $details['tax'],
446 446
 					'item_price'       => $details['item_price'],
447 447
 					'custom_price'     => $details['custom_price'],
@@ -453,31 +453,31 @@  discard block
 block discarded – undo
453 453
 					'fees'             => $details['fees'],
454 454
 				);
455 455
 
456
-				$item_columns = array_keys ( $fields );
456
+				$item_columns = array_keys($fields);
457 457
 
458
-				foreach ( $fields as $key => $val ) {
459
-					if ( is_null( $val ) ) {
458
+				foreach ($fields as $key => $val) {
459
+					if (is_null($val)) {
460 460
 						$val = '';
461 461
 					}
462
-					$val = maybe_serialize( $val );
463
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
462
+					$val = maybe_serialize($val);
463
+					$fields[$key] = $wpdb->prepare('%s', $val);
464 464
 				}
465 465
 
466
-				$fields = implode( ', ', $fields );
466
+				$fields = implode(', ', $fields);
467 467
 				$item_rows[] = "($fields)";
468 468
 			}
469 469
 
470
-			$item_rows    = implode( ', ', $item_rows );
471
-			$item_columns = implode( ', ', $item_columns );
472
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
470
+			$item_rows    = implode(', ', $item_rows);
471
+			$item_columns = implode(', ', $item_columns);
472
+			$wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
473 473
 		}
474 474
 
475
-		if ( empty( $invoice_rows ) ) {
475
+		if (empty($invoice_rows)) {
476 476
 			return;
477 477
 		}
478 478
 
479
-		$invoice_rows = implode( ', ', $invoice_rows );
480
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
479
+		$invoice_rows = implode(', ', $invoice_rows);
480
+		$wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
481 481
 
482 482
 	}
483 483
 
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
 	public static function rename_gateways_label() {
489 489
 		global $wpdb;
490 490
 
491
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
491
+		foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) {
492 492
 
493 493
 			$wpdb->update(
494 494
 				$wpdb->prefix . 'getpaid_invoices',
495
-				array( 'gateway' => $gateway ),
496
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
495
+				array('gateway' => $gateway),
496
+				array('gateway' => wpinv_get_gateway_admin_label($gateway)),
497 497
 				'%s',
498 498
 				'%s'
499 499
 			);
Please login to merge, or discard this patch.