Passed
Push — master ( 57b9dd...cc2e7c )
by Brian
04:45
created
includes/admin/register-settings.php 1 patch
Spacing   +373 added lines, -373 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( ! is_array( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (!is_array($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,47 +190,47 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name    = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name    = isset($option['name']) ? $option['name'] : '';
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
199
+	if (isset($option['desc']) && !empty($option['help-tip'])) {
200
+		$tip   = wpinv_clean($option['desc']);
201 201
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
202
+		unset($option['desc']);
203 203
 	}
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
207 207
         'wpinv_settings[' . $option['id'] . ']',
208 208
         $name,
209
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
209
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
210 210
         $section,
211 211
         $section,
212 212
         array(
213 213
             'section'     => $section,
214
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
215
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
216 216
             'name'        => $name,
217
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
218
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
219
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
220
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
221
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
224
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
225
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
226
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
227
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
232
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
217
+            'size'        => isset($option['size']) ? $option['size'] : null,
218
+            'options'     => isset($option['options']) ? $option['options'] : '',
219
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
220
+            'std'         => isset($option['std']) ? $option['std'] : '',
221
+            'min'         => isset($option['min']) ? $option['min'] : 0,
222
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
223
+            'step'        => isset($option['step']) ? $option['step'] : 1,
224
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
225
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
226
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
227
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
228
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
229
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
230
+			'class'       => isset($option['class']) ? $option['class'] : '',
231
+			'style'       => isset($option['style']) ? $option['style'] : '',
232
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
235 235
     );
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
246 246
 }
247 247
 
248 248
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function getpaid_get_integration_settings() {
254
-    return apply_filters( 'getpaid_integration_settings', array() );
254
+    return apply_filters('getpaid_integration_settings', array());
255 255
 }
256 256
 
257 257
 /**
@@ -259,139 +259,139 @@  discard block
 block discarded – undo
259 259
  * 
260 260
  * @return array
261 261
  */
262
-function wpinv_settings_sanitize( $input = array() ) {
262
+function wpinv_settings_sanitize($input = array()) {
263 263
 
264 264
     $wpinv_options = wpinv_get_options();
265 265
 
266
-    if ( empty( wp_get_raw_referer() ) ) {
266
+    if (empty(wp_get_raw_referer())) {
267 267
         return $input;
268 268
     }
269 269
 
270
-    wp_parse_str( wp_get_raw_referer(), $referrer );
270
+    wp_parse_str(wp_get_raw_referer(), $referrer);
271 271
 
272 272
     $settings = wpinv_get_registered_settings();
273
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
274
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
273
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
274
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
275 275
 
276 276
     $input = $input ? $input : array();
277
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
278
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
277
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
278
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
279 279
 
280 280
     // Loop through each setting being saved and pass it through a sanitization filter
281
-    foreach ( $input as $key => $value ) {
281
+    foreach ($input as $key => $value) {
282 282
 
283 283
         // Get the setting type (checkbox, select, etc)
284
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
284
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
285 285
 
286
-        if ( $type ) {
286
+        if ($type) {
287 287
             // Field type specific filter
288
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
288
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
293 293
 
294 294
 		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
295
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
299
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
300
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
299
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
300
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
301 301
 
302
-    $found_settings = array_merge( $main_settings, $section_settings );
302
+    $found_settings = array_merge($main_settings, $section_settings);
303 303
 
304
-    if ( ! empty( $found_settings ) ) {
305
-        foreach ( $found_settings as $key => $value ) {
304
+    if (!empty($found_settings)) {
305
+        foreach ($found_settings as $key => $value) {
306 306
 
307 307
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
308
-            if ( is_numeric( $key ) ) {
308
+            if (is_numeric($key)) {
309 309
                 $key = $value['id'];
310 310
             }
311 311
 
312
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
313
-                unset( $wpinv_options[ $key ] );
312
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
313
+                unset($wpinv_options[$key]);
314 314
             }
315 315
         }
316 316
     }
317 317
 
318 318
     // Merge our new settings with the existing
319
-    $output = array_merge( $wpinv_options, $input );
319
+    $output = array_merge($wpinv_options, $input);
320 320
 
321
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
321
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
322 322
 
323 323
     return $output;
324 324
 }
325 325
 
326
-function wpinv_settings_sanitize_misc_accounting( $input ) {
326
+function wpinv_settings_sanitize_misc_accounting($input) {
327 327
 
328
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
328
+    if (!wpinv_current_user_can_manage_invoicing()) {
329 329
         return $input;
330 330
     }
331 331
 
332
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
332
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
333 333
         // Shows an admin notice about upgrading previous order numbers
334
-        getpaid_session()->set( 'upgrade_sequential', '1' );
334
+        getpaid_session()->set('upgrade_sequential', '1');
335 335
     }
336 336
 
337 337
     return $input;
338 338
 }
339
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
339
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
340 340
 
341
-function wpinv_settings_sanitize_tax_rates( $input ) {
342
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
341
+function wpinv_settings_sanitize_tax_rates($input) {
342
+    if (!wpinv_current_user_can_manage_invoicing()) {
343 343
         return $input;
344 344
     }
345 345
 
346
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
346
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
347 347
     $tax_rates = array();
348 348
 
349
-    foreach ( $new_rates as $rate ) {
349
+    foreach ($new_rates as $rate) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
351
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
352
+		$rate['name']    = sanitize_text_field($rate['name']);
353
+		$rate['state']   = sanitize_text_field($rate['state']);
354
+		$rate['country'] = sanitize_text_field($rate['country']);
355
+		$rate['global']  = empty($rate['state']);
356 356
 		$tax_rates[]     = $rate;
357 357
 
358 358
 	}
359 359
 
360
-    update_option( 'wpinv_tax_rates', $tax_rates );
360
+    update_option('wpinv_tax_rates', $tax_rates);
361 361
 
362 362
     return $input;
363 363
 }
364
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
364
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
365 365
 
366
-function wpinv_sanitize_text_field( $input ) {
367
-    return trim( $input );
366
+function wpinv_sanitize_text_field($input) {
367
+    return trim($input);
368 368
 }
369
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
369
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
370 370
 
371 371
 function wpinv_get_settings_tabs() {
372 372
     $tabs             = array();
373
-    $tabs['general']  = __( 'General', 'invoicing' );
374
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
373
+    $tabs['general']  = __('General', 'invoicing');
374
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
375
+    $tabs['taxes']    = __('Taxes', 'invoicing');
376
+	$tabs['emails'] = __('Emails', 'invoicing');
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
378
+	if (count(getpaid_get_integration_settings()) > 0) {
379
+		$tabs['integrations'] = __('Integrations', 'invoicing');
380 380
 	}
381 381
 
382
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
384
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
382
+    $tabs['privacy']  = __('Privacy', 'invoicing');
383
+    $tabs['misc']     = __('Misc', 'invoicing');
384
+    $tabs['tools']    = __('Tools', 'invoicing');
385 385
 
386
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
386
+    return apply_filters('wpinv_settings_tabs', $tabs);
387 387
 }
388 388
 
389
-function wpinv_get_settings_tab_sections( $tab = false ) {
389
+function wpinv_get_settings_tab_sections($tab = false) {
390 390
     $tabs     = false;
391 391
     $sections = wpinv_get_registered_settings_sections();
392 392
 
393
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
394
-        $tabs = $sections[ $tab ];
393
+    if ($tab && !empty($sections[$tab])) {
394
+        $tabs = $sections[$tab];
395 395
     }
396 396
 
397 397
     return $tabs;
@@ -400,91 +400,91 @@  discard block
 block discarded – undo
400 400
 function wpinv_get_registered_settings_sections() {
401 401
     static $sections = false;
402 402
 
403
-    if ( false !== $sections ) {
403
+    if (false !== $sections) {
404 404
         return $sections;
405 405
     }
406 406
 
407 407
     $sections = array(
408
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
409
-            'main' => __( 'General Settings', 'invoicing' ),
410
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
411
-            'labels' => __( 'Label Texts', 'invoicing' ),
412
-        ) ),
413
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
414
-            'main' => __( 'Gateway Settings', 'invoicing' ),
415
-        ) ),
416
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
417
-            'main'  => __( 'Tax Settings', 'invoicing' ),
418
-			'rates' => __( 'Tax Rates', 'invoicing' ),
419
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
420
-        ) ),
421
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
422
-            'main' => __( 'Email Settings', 'invoicing' ),
423
-		) ),
424
-
425
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
426
-
427
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
428
-            'main' => __( 'Privacy policy', 'invoicing' ),
429
-        ) ),
430
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
431
-            'main' => __( 'Miscellaneous', 'invoicing' ),
432
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
433
-        ) ),
434
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
435
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
436
-        ) ),
408
+        'general' => apply_filters('wpinv_settings_sections_general', array(
409
+            'main' => __('General Settings', 'invoicing'),
410
+            'currency_section' => __('Currency Settings', 'invoicing'),
411
+            'labels' => __('Label Texts', 'invoicing'),
412
+        )),
413
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
414
+            'main' => __('Gateway Settings', 'invoicing'),
415
+        )),
416
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
417
+            'main'  => __('Tax Settings', 'invoicing'),
418
+			'rates' => __('Tax Rates', 'invoicing'),
419
+			'vat'   => __('EU VAT Settings', 'invoicing')
420
+        )),
421
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
422
+            'main' => __('Email Settings', 'invoicing'),
423
+		)),
424
+
425
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
426
+
427
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
428
+            'main' => __('Privacy policy', 'invoicing'),
429
+        )),
430
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
431
+            'main' => __('Miscellaneous', 'invoicing'),
432
+            'custom-css' => __('Custom CSS', 'invoicing'),
433
+        )),
434
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
435
+            'main' => __('Diagnostic Tools', 'invoicing'),
436
+        )),
437 437
     );
438 438
 
439
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
439
+    $sections = apply_filters('wpinv_settings_sections', $sections);
440 440
 
441 441
     return $sections;
442 442
 }
443 443
 
444
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
444
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
445 445
 	$pages_options = array();
446 446
 
447
-	if( $default_label !== NULL && $default_label !== false ) {
448
-		$pages_options = array( '' => $default_label ); // Blank option
447
+	if ($default_label !== NULL && $default_label !== false) {
448
+		$pages_options = array('' => $default_label); // Blank option
449 449
 	}
450 450
 
451 451
 	$pages = get_pages();
452
-	if ( $pages ) {
453
-		foreach ( $pages as $page ) {
452
+	if ($pages) {
453
+		foreach ($pages as $page) {
454 454
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
455
-            $pages_options[ $page->ID ] = $title;
455
+            $pages_options[$page->ID] = $title;
456 456
 		}
457 457
 	}
458 458
 
459 459
 	return $pages_options;
460 460
 }
461 461
 
462
-function wpinv_header_callback( $args ) {
463
-	if ( !empty( $args['desc'] ) ) {
462
+function wpinv_header_callback($args) {
463
+	if (!empty($args['desc'])) {
464 464
         echo $args['desc'];
465 465
     }
466 466
 }
467 467
 
468
-function wpinv_hidden_callback( $args ) {
468
+function wpinv_hidden_callback($args) {
469 469
 	global $wpinv_options;
470 470
 
471
-	if ( isset( $args['set_value'] ) ) {
471
+	if (isset($args['set_value'])) {
472 472
 		$value = $args['set_value'];
473
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
-		$value = $wpinv_options[ $args['id'] ];
473
+	} elseif (isset($wpinv_options[$args['id']])) {
474
+		$value = $wpinv_options[$args['id']];
475 475
 	} else {
476
-		$value = isset( $args['std'] ) ? $args['std'] : '';
476
+		$value = isset($args['std']) ? $args['std'] : '';
477 477
 	}
478 478
 
479
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
479
+	if (isset($args['faux']) && true === $args['faux']) {
480 480
 		$args['readonly'] = true;
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
481
+		$value = isset($args['std']) ? $args['std'] : '';
482 482
 		$name  = '';
483 483
 	} else {
484
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
484
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
485 485
 	}
486 486
 
487
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
487
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
488 488
     
489 489
 	echo $html;
490 490
 }
@@ -492,61 +492,61 @@  discard block
 block discarded – undo
492 492
 /**
493 493
  * Displays a checkbox settings callback.
494 494
  */
495
-function wpinv_checkbox_callback( $args ) {
495
+function wpinv_checkbox_callback($args) {
496 496
 
497
-	$std = isset( $args['std'] ) ? $args['std'] : '';
498
-	$std = wpinv_get_option( $args['id'], $std );
499
-	$id  = esc_attr( $args['id'] );
497
+	$std = isset($args['std']) ? $args['std'] : '';
498
+	$std = wpinv_get_option($args['id'], $std);
499
+	$id  = esc_attr($args['id']);
500 500
 
501
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
501
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
502 502
 	?>
503 503
 		<fieldset>
504 504
 			<label>
505
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
506
-				<?php echo wp_kses_post( $args['desc'] ); ?>
505
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
506
+				<?php echo wp_kses_post($args['desc']); ?>
507 507
 			</label>
508 508
 		</fieldset>
509 509
 	<?php
510 510
 }
511 511
 
512
-function wpinv_multicheck_callback( $args ) {
512
+function wpinv_multicheck_callback($args) {
513 513
 	
514 514
 	global $wpinv_options;
515 515
 
516
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
517
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
516
+	$sanitize_id = wpinv_sanitize_key($args['id']);
517
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
518 518
 
519
-	if ( ! empty( $args['options'] ) ) {
519
+	if (!empty($args['options'])) {
520 520
 
521
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
522
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
521
+		$std     = isset($args['std']) ? $args['std'] : array();
522
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
523 523
 
524 524
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
525
-        foreach( $args['options'] as $key => $option ):
526
-			$sanitize_key = wpinv_sanitize_key( $key );
527
-			if ( in_array( $sanitize_key, $value ) ) { 
525
+        foreach ($args['options'] as $key => $option):
526
+			$sanitize_key = wpinv_sanitize_key($key);
527
+			if (in_array($sanitize_key, $value)) { 
528 528
 				$enabled = $sanitize_key;
529 529
 			} else { 
530 530
 				$enabled = NULL; 
531 531
 			}
532
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
533
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
532
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
533
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
534 534
 		endforeach;
535 535
 		echo '</div>';
536 536
 		echo '<p class="description">' . $args['desc'] . '</p>';
537 537
 	}
538 538
 }
539 539
 
540
-function wpinv_payment_icons_callback( $args ) {
540
+function wpinv_payment_icons_callback($args) {
541 541
 	global $wpinv_options;
542 542
     
543
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
543
+    $sanitize_id = wpinv_sanitize_key($args['id']);
544 544
 
545
-	if ( ! empty( $args['options'] ) ) {
546
-		foreach( $args['options'] as $key => $option ) {
547
-            $sanitize_key = wpinv_sanitize_key( $key );
545
+	if (!empty($args['options'])) {
546
+		foreach ($args['options'] as $key => $option) {
547
+            $sanitize_key = wpinv_sanitize_key($key);
548 548
             
549
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
549
+			if (isset($wpinv_options[$args['id']][$key])) {
550 550
 				$enabled = $option;
551 551
 			} else {
552 552
 				$enabled = NULL;
@@ -554,109 +554,109 @@  discard block
 block discarded – undo
554 554
 
555 555
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
556 556
 
557
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
557
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
558 558
 
559
-				if ( wpinv_string_is_image_url( $key ) ) {
560
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
559
+				if (wpinv_string_is_image_url($key)) {
560
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561 561
 				} else {
562
-					$card = strtolower( str_replace( ' ', '', $option ) );
562
+					$card = strtolower(str_replace(' ', '', $option));
563 563
 
564
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
564
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
565
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
566 566
 					} else {
567
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
567
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
568 568
 						$content_dir = WP_CONTENT_DIR;
569 569
 
570
-						if ( function_exists( 'wp_normalize_path' ) ) {
570
+						if (function_exists('wp_normalize_path')) {
571 571
 							// Replaces backslashes with forward slashes for Windows systems
572
-							$image = wp_normalize_path( $image );
573
-							$content_dir = wp_normalize_path( $content_dir );
572
+							$image = wp_normalize_path($image);
573
+							$content_dir = wp_normalize_path($content_dir);
574 574
 						}
575 575
 
576
-						$image = str_replace( $content_dir, content_url(), $image );
576
+						$image = str_replace($content_dir, content_url(), $image);
577 577
 					}
578 578
 
579
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
579
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580 580
 				}
581 581
 			echo $option . '</label>';
582 582
 		}
583
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
583
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
584 584
 	}
585 585
 }
586 586
 
587 587
 /**
588 588
  * Displays a radio settings field.
589 589
  */
590
-function wpinv_radio_callback( $args ) {
590
+function wpinv_radio_callback($args) {
591 591
 
592
-	$std = isset( $args['std'] ) ? $args['std'] : '';
593
-	$std = wpinv_get_option( $args['id'], $std );
592
+	$std = isset($args['std']) ? $args['std'] : '';
593
+	$std = wpinv_get_option($args['id'], $std);
594 594
 	?>
595 595
 		<fieldset>
596
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
597
-				<?php foreach( $args['options'] as $key => $option ) : ?>
596
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
597
+				<?php foreach ($args['options'] as $key => $option) : ?>
598 598
 					<li>
599 599
 						<label>
600
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
601
-							<?php echo wp_kses_post( $option ); ?>
600
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
601
+							<?php echo wp_kses_post($option); ?>
602 602
 						</label>
603 603
 					</li>
604 604
 				<?php endforeach; ?>
605 605
 			</ul>
606 606
 		</fieldset>
607 607
 	<?php
608
-	getpaid_settings_description_callback( $args );
608
+	getpaid_settings_description_callback($args);
609 609
 }
610 610
 
611 611
 /**
612 612
  * Displays a description if available.
613 613
  */
614
-function getpaid_settings_description_callback( $args ) {
614
+function getpaid_settings_description_callback($args) {
615 615
 
616
-	if ( ! empty( $args['desc'] ) ) {
617
-		$description = wp_kses_post( $args['desc'] );
616
+	if (!empty($args['desc'])) {
617
+		$description = wp_kses_post($args['desc']);
618 618
 		echo "<p class='description'>$description</p>";
619 619
 	}
620 620
 
621 621
 }
622 622
 
623
-function wpinv_gateways_callback( $args ) {
623
+function wpinv_gateways_callback($args) {
624 624
 
625
-	$gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
626
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
625
+	$gateways = wpinv_get_option('gateways', array('manual' => 1));
626
+    $sanitize_id = wpinv_sanitize_key($args['id']);
627 627
 
628
-	foreach ( $args['options'] as $key => $option ) :
629
-		$sanitize_key = wpinv_sanitize_key( $key );
628
+	foreach ($args['options'] as $key => $option) :
629
+		$sanitize_key = wpinv_sanitize_key($key);
630 630
         
631
-        if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
631
+        if (is_array($gateways) && isset($gateways[$key]))
632 632
 			$enabled = '1';
633 633
 		else
634 634
 			$enabled = null;
635 635
 
636
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
636
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
638 638
 	endforeach;
639 639
 }
640 640
 
641 641
 function wpinv_gateway_select_callback($args) {
642 642
 	global $wpinv_options;
643 643
     
644
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
645
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
+    $sanitize_id = wpinv_sanitize_key($args['id']);
645
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
646 646
 
647
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
647
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
650
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651
-            $selected = selected( $key, $args['selected'], false );
649
+	foreach ($args['options'] as $key => $option) :
650
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
651
+            $selected = selected($key, $args['selected'], false);
652 652
         } else {
653
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
653
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
654 654
         }
655
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
655
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
656 656
 	endforeach;
657 657
 
658 658
 	echo '</select>';
659
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
659
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
660 660
 }
661 661
 
662 662
 /**
@@ -665,28 +665,28 @@  discard block
 block discarded – undo
665 665
  * @param array $args
666 666
  * @return string
667 667
  */
668
-function wpinv_settings_attrs_helper( $args ) {
668
+function wpinv_settings_attrs_helper($args) {
669 669
 
670
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
671
-	$id           = esc_attr( $args['id'] );
672
-	$placeholder  = esc_attr( $args['placeholder'] );
670
+	$value        = isset($args['std']) ? $args['std'] : '';
671
+	$id           = esc_attr($args['id']);
672
+	$placeholder  = esc_attr($args['placeholder']);
673 673
 
674
-	if ( ! empty( $args['faux'] ) ) {
674
+	if (!empty($args['faux'])) {
675 675
 		$args['readonly'] = true;
676 676
 		$name             = '';
677 677
 	} else {
678
-		$value  = wpinv_get_option( $args['id'], $value );
678
+		$value  = wpinv_get_option($args['id'], $value);
679 679
 		$name   = "wpinv_settings[$id]";
680 680
 	}
681 681
 
682
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
683
-	$class    = esc_attr( $args['class'] );
684
-	$style    = esc_attr( $args['style'] );
685
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
682
+	$value    = is_scalar($value) ? esc_attr($value) : '';
683
+	$class    = esc_attr($args['class']);
684
+	$style    = esc_attr($args['style']);
685
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
686 686
 
687 687
 	$onchange = '';
688
-    if ( ! empty( $args['onchange'] ) ) {
689
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
688
+    if (!empty($args['onchange'])) {
689
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
690 690
 	}
691 691
 
692 692
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 /**
696 696
  * Displays a text input settings callback.
697 697
  */
698
-function wpinv_text_callback( $args ) {
698
+function wpinv_text_callback($args) {
699 699
 
700
-	$desc = wp_kses_post( $args['desc'] );
701
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
702
-	$attr = wpinv_settings_attrs_helper( $args );
700
+	$desc = wp_kses_post($args['desc']);
701
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
702
+	$attr = wpinv_settings_attrs_helper($args);
703 703
 
704 704
 	?>
705 705
 		<label style="width: 100%;">
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
 /**
714 714
  * Displays a number input settings callback.
715 715
  */
716
-function wpinv_number_callback( $args ) {
716
+function wpinv_number_callback($args) {
717 717
 
718
-	$desc = wp_kses_post( $args['desc'] );
719
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
720
-	$attr = wpinv_settings_attrs_helper( $args );
721
-	$max  = intval( $args['max'] );
722
-	$min  = intval( $args['min'] );
723
-	$step = floatval( $args['step'] );
718
+	$desc = wp_kses_post($args['desc']);
719
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
720
+	$attr = wpinv_settings_attrs_helper($args);
721
+	$max  = intval($args['max']);
722
+	$min  = intval($args['min']);
723
+	$step = floatval($args['step']);
724 724
 
725 725
 	?>
726 726
 		<label style="width: 100%;">
@@ -731,47 +731,47 @@  discard block
 block discarded – undo
731 731
 
732 732
 }
733 733
 
734
-function wpinv_textarea_callback( $args ) {
734
+function wpinv_textarea_callback($args) {
735 735
 	global $wpinv_options;
736 736
     
737
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
737
+    $sanitize_id = wpinv_sanitize_key($args['id']);
738 738
 
739
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
-		$value = $wpinv_options[ $args['id'] ];
739
+	if (isset($wpinv_options[$args['id']])) {
740
+		$value = $wpinv_options[$args['id']];
741 741
 	} else {
742
-		$value = isset( $args['std'] ) ? $args['std'] : '';
742
+		$value = isset($args['std']) ? $args['std'] : '';
743 743
 	}
744 744
     
745
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
746
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
745
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
746
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
747 747
 
748
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
749
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
748
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
749
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
750 750
 
751 751
 	echo $html;
752 752
 }
753 753
 
754
-function wpinv_password_callback( $args ) {
754
+function wpinv_password_callback($args) {
755 755
 	global $wpinv_options;
756 756
     
757
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
757
+    $sanitize_id = wpinv_sanitize_key($args['id']);
758 758
 
759
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
-		$value = $wpinv_options[ $args['id'] ];
759
+	if (isset($wpinv_options[$args['id']])) {
760
+		$value = $wpinv_options[$args['id']];
761 761
 	} else {
762
-		$value = isset( $args['std'] ) ? $args['std'] : '';
762
+		$value = isset($args['std']) ? $args['std'] : '';
763 763
 	}
764 764
 
765
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
766
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
767
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
765
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
766
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
767
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
768 768
 
769 769
 	echo $html;
770 770
 }
771 771
 
772 772
 function wpinv_missing_callback($args) {
773 773
 	printf(
774
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
774
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
775 775
 		'<strong>' . $args['id'] . '</strong>'
776 776
 	);
777 777
 }
@@ -779,20 +779,20 @@  discard block
 block discarded – undo
779 779
 /**
780 780
  * Displays a number input settings callback.
781 781
  */
782
-function wpinv_select_callback( $args ) {
782
+function wpinv_select_callback($args) {
783 783
 
784
-	$desc   = wp_kses_post( $args['desc'] );
785
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
786
-	$attr   = wpinv_settings_attrs_helper( $args );
787
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
788
-	$value  = wpinv_get_option( $args['id'], $value );
784
+	$desc   = wp_kses_post($args['desc']);
785
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
786
+	$attr   = wpinv_settings_attrs_helper($args);
787
+	$value  = isset($args['std']) ? $args['std'] : '';
788
+	$value  = wpinv_get_option($args['id'], $value);
789 789
 
790 790
 	?>
791 791
 		<label style="width: 100%;">
792 792
 			<select <?php echo $attr; ?>>
793
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
794
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( is_array( $value ) ? in_array( "$option", $value, true ) : "$option" === $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
795
-				<?php endforeach;?>
793
+				<?php foreach ($args['options'] as $option => $name) : ?>
794
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected(is_array($value) ? in_array("$option", $value, true) : "$option" === $value); ?>><?php echo wpinv_clean($name); ?></option>
795
+				<?php endforeach; ?>
796 796
 			</select>
797 797
 			<?php echo $desc; ?>
798 798
 		</label>
@@ -800,95 +800,95 @@  discard block
 block discarded – undo
800 800
 
801 801
 }
802 802
 
803
-function wpinv_color_select_callback( $args ) {
803
+function wpinv_color_select_callback($args) {
804 804
 	global $wpinv_options;
805 805
     
806
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
806
+    $sanitize_id = wpinv_sanitize_key($args['id']);
807 807
 
808
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
-		$value = $wpinv_options[ $args['id'] ];
808
+	if (isset($wpinv_options[$args['id']])) {
809
+		$value = $wpinv_options[$args['id']];
810 810
 	} else {
811
-		$value = isset( $args['std'] ) ? $args['std'] : '';
811
+		$value = isset($args['std']) ? $args['std'] : '';
812 812
 	}
813 813
 
814
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
814
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
815 815
 
816
-	foreach ( $args['options'] as $option => $color ) {
817
-		$selected = selected( $option, $value, false );
818
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
816
+	foreach ($args['options'] as $option => $color) {
817
+		$selected = selected($option, $value, false);
818
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
819 819
 	}
820 820
 
821 821
 	$html .= '</select>';
822
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
822
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
823 823
 
824 824
 	echo $html;
825 825
 }
826 826
 
827
-function wpinv_rich_editor_callback( $args ) {
827
+function wpinv_rich_editor_callback($args) {
828 828
 	global $wpinv_options, $wp_version;
829 829
     
830
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
830
+    $sanitize_id = wpinv_sanitize_key($args['id']);
831 831
 
832
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
833
-		$value = $wpinv_options[ $args['id'] ];
832
+	if (isset($wpinv_options[$args['id']])) {
833
+		$value = $wpinv_options[$args['id']];
834 834
 
835
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
-			$value = isset( $args['std'] ) ? $args['std'] : '';
835
+		if (empty($args['allow_blank']) && empty($value)) {
836
+			$value = isset($args['std']) ? $args['std'] : '';
837 837
 		}
838 838
 	} else {
839
-		$value = isset( $args['std'] ) ? $args['std'] : '';
839
+		$value = isset($args['std']) ? $args['std'] : '';
840 840
 	}
841 841
 
842
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
842
+	$rows = isset($args['size']) ? $args['size'] : 20;
843 843
 
844 844
 	$html = '<div class="getpaid-settings-editor-input">';
845
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
845
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
846 846
 		ob_start();
847
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
847
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
848 848
 		$html .= ob_get_clean();
849 849
 	} else {
850
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
850
+		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
851 851
 	}
852 852
 
853
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
853
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
854 854
 
855 855
 	echo $html;
856 856
 }
857 857
 
858
-function wpinv_upload_callback( $args ) {
858
+function wpinv_upload_callback($args) {
859 859
 	global $wpinv_options;
860 860
     
861
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
861
+    $sanitize_id = wpinv_sanitize_key($args['id']);
862 862
 
863
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
+	if (isset($wpinv_options[$args['id']])) {
864 864
 		$value = $wpinv_options[$args['id']];
865 865
 	} else {
866 866
 		$value = isset($args['std']) ? $args['std'] : '';
867 867
 	}
868 868
 
869
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
870
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
871
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
872
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
869
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
870
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
871
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
872
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
873 873
 
874 874
 	echo $html;
875 875
 }
876 876
 
877
-function wpinv_color_callback( $args ) {
877
+function wpinv_color_callback($args) {
878 878
 	global $wpinv_options;
879 879
     
880
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
880
+    $sanitize_id = wpinv_sanitize_key($args['id']);
881 881
 
882
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
-		$value = $wpinv_options[ $args['id'] ];
882
+	if (isset($wpinv_options[$args['id']])) {
883
+		$value = $wpinv_options[$args['id']];
884 884
 	} else {
885
-		$value = isset( $args['std'] ) ? $args['std'] : '';
885
+		$value = isset($args['std']) ? $args['std'] : '';
886 886
 	}
887 887
 
888
-	$default = isset( $args['std'] ) ? $args['std'] : '';
888
+	$default = isset($args['std']) ? $args['std'] : '';
889 889
 
890
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
891
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
890
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
891
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
892 892
 
893 893
 	echo $html;
894 894
 }
@@ -896,9 +896,9 @@  discard block
 block discarded – undo
896 896
 function wpinv_country_states_callback($args) {
897 897
 	global $wpinv_options;
898 898
     
899
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
899
+    $sanitize_id = wpinv_sanitize_key($args['id']);
900 900
 
901
-	if ( isset( $args['placeholder'] ) ) {
901
+	if (isset($args['placeholder'])) {
902 902
 		$placeholder = $args['placeholder'];
903 903
 	} else {
904 904
 		$placeholder = '';
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 
907 907
 	$states = wpinv_get_country_states();
908 908
 
909
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
909
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
911 911
 
912
-	foreach ( $states as $option => $name ) {
913
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
914
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
912
+	foreach ($states as $option => $name) {
913
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
914
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
915 915
 	}
916 916
 
917 917
 	$html .= '</select>';
918
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
918
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
919 919
 
920 920
 	echo $html;
921 921
 }
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	</tr>
931 931
 	<tr class="bsui">
932 932
     	<td colspan="2" class="p-0">
933
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
933
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
934 934
 
935 935
 	<?php
936 936
 
@@ -939,14 +939,14 @@  discard block
 block discarded – undo
939 939
 /**
940 940
  * Displays a tax rate' edit row.
941 941
  */
942
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
942
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
943 943
 	ob_start();
944 944
 
945
-	$key                      = sanitize_key( $key );
946
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
947
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
945
+	$key                      = sanitize_key($key);
946
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
947
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
948 948
 
949
-	if ( $echo ) {
949
+	if ($echo) {
950 950
 		echo ob_get_clean();
951 951
 	} else {
952 952
 		return ob_get_clean(); 
@@ -958,99 +958,99 @@  discard block
 block discarded – undo
958 958
     ob_start(); ?>
959 959
     </td><tr>
960 960
     <td colspan="2" class="wpinv_tools_tdbox">
961
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
962
-    <?php do_action( 'wpinv_tools_before' ); ?>
961
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
962
+    <?php do_action('wpinv_tools_before'); ?>
963 963
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
964 964
         <thead>
965 965
             <tr>
966
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
967
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
968
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
966
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
967
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
968
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
969 969
             </tr>
970 970
         </thead>
971 971
 
972 972
         <tbody>
973 973
 			<tr>
974
-                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
974
+                <td><?php _e('Check Pages', 'invoicing'); ?></td>
975 975
                 <td>
976
-                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
976
+                    <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
977 977
                 </td>
978 978
                 <td>
979 979
 					<a href="<?php
980 980
 						echo esc_url(
981 981
 							wp_nonce_url(
982
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
982
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
983 983
 								'getpaid-nonce',
984 984
 								'getpaid-nonce'
985 985
 							)
986 986
 						);
987
-					?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a>
987
+					?>" class="button button-primary"><?php _e('Run', 'geodirectory'); ?></a>
988 988
                 </td>
989 989
             </tr>
990
-			<?php do_action( 'wpinv_tools_row' ); ?>
990
+			<?php do_action('wpinv_tools_row'); ?>
991 991
         </tbody>
992 992
     </table>
993
-    <?php do_action( 'wpinv_tools_after' ); ?>
993
+    <?php do_action('wpinv_tools_after'); ?>
994 994
     <?php
995 995
     echo ob_get_clean();
996 996
 }
997 997
 
998
-function wpinv_descriptive_text_callback( $args ) {
999
-	echo wp_kses_post( $args['desc'] );
998
+function wpinv_descriptive_text_callback($args) {
999
+	echo wp_kses_post($args['desc']);
1000 1000
 }
1001 1001
 
1002
-function wpinv_raw_html_callback( $args ) {
1002
+function wpinv_raw_html_callback($args) {
1003 1003
 	echo $args['desc'];
1004 1004
 }
1005 1005
 
1006
-function wpinv_hook_callback( $args ) {
1007
-	do_action( 'wpinv_' . $args['id'], $args );
1006
+function wpinv_hook_callback($args) {
1007
+	do_action('wpinv_' . $args['id'], $args);
1008 1008
 }
1009 1009
 
1010 1010
 function wpinv_set_settings_cap() {
1011 1011
 	return wpinv_get_capability();
1012 1012
 }
1013
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1013
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1014 1014
 
1015
-function wpinv_settings_sanitize_input( $value, $key ) {
1015
+function wpinv_settings_sanitize_input($value, $key) {
1016 1016
 
1017
-    if ( $key == 'tax_rate' ) {
1018
-        $value = wpinv_sanitize_amount( $value );
1017
+    if ($key == 'tax_rate') {
1018
+        $value = wpinv_sanitize_amount($value);
1019 1019
         $value = $value >= 100 ? 99 : $value;
1020 1020
     }
1021 1021
 
1022 1022
     return $value;
1023 1023
 }
1024
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1024
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1025 1025
 
1026
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1027
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1028
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1026
+function wpinv_on_update_settings($old_value, $value, $option) {
1027
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1028
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1029 1029
     
1030
-    if ( $old != $new ) {
1031
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1030
+    if ($old != $new) {
1031
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1032 1032
     }
1033 1033
 }
1034
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1035
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1036
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1037
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1038
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1039
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1040
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1041
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1042
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1043
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1044
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1045
-
1046
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1034
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1035
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1036
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1037
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1038
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1039
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1040
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1041
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1042
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1043
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1044
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1045
+
1046
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1047 1047
     ?>
1048 1048
     <div class="wpinv-email-wc-row ">
1049 1049
         <div class="wpinv-email-wc-td">
1050
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1050
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1051 1051
             <p class="wpinv-email-wc-description">
1052 1052
                 <?php
1053
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1053
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1054 1054
                     <strong>{site_title} :</strong> Site Title<br>
1055 1055
                     <strong>{name} :</strong> Customer\'s full name<br>
1056 1056
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1065 1065
                     <strong>{date} :</strong> Today\'s date.<br>
1066 1066
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1067
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1067
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1068 1068
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1069 1069
                 ?>
1070 1070
             </p>
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
69
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
65
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
66
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
67
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
68
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
69
+		do_action('getpaid_init_admin_hooks', $this);
70 70
 
71 71
     }
72 72
 
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
 	public function enqeue_scripts() {
78 78
         global $current_screen, $pagenow;
79 79
 
80
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
80
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
81 81
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
82 82
 
83
-        if ( ! empty( $current_screen->post_type ) ) {
83
+        if (!empty($current_screen->post_type)) {
84 84
 			$page = $current_screen->post_type;
85 85
         }
86 86
 
87 87
         // General styles.
88
-        if ( false !== stripos( $page, 'wpi' ) ) {
88
+        if (false !== stripos($page, 'wpi')) {
89 89
 
90 90
             // Styles.
91
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
92
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
93
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
94
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
91
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
92
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
93
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
94
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
95 95
 
96 96
             // Scripts.
97
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
98
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
97
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
98
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
99 99
 
100
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
101
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
102
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
100
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
101
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
102
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
103 103
 
104 104
         }
105 105
 
106 106
         // Payment form scripts.
107
-		if ( 'wpi_payment_form' == $page && $editing ) {
107
+		if ('wpi_payment_form' == $page && $editing) {
108 108
             $this->load_payment_form_scripts();
109 109
         }
110 110
 
111
-		if ( $page == 'wpinv-subscriptions' ) {
112
-			wp_enqueue_script( 'postbox' );
111
+		if ($page == 'wpinv-subscriptions') {
112
+			wp_enqueue_script('postbox');
113 113
 		}
114 114
 
115 115
     }
@@ -122,32 +122,32 @@  discard block
 block discarded – undo
122 122
         global $post;
123 123
 
124 124
 		$date_range = array(
125
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
125
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
126 126
 		);
127 127
 
128
-		if ( $date_range['period'] == 'custom' ) {
128
+		if ($date_range['period'] == 'custom') {
129 129
 			
130
-			if ( isset( $_GET['from'] ) ) {
131
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
130
+			if (isset($_GET['from'])) {
131
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
132 132
 			}
133 133
 
134
-			if ( isset( $_GET['to'] ) ) {
135
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
134
+			if (isset($_GET['to'])) {
135
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
136 136
 			}
137 137
 
138 138
 		}
139 139
 
140 140
         $i18n = array(
141
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
142
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
143
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
144
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
145
-			'rest_root'                 => esc_url_raw( rest_url() ),
141
+            'ajax_url'                  => admin_url('admin-ajax.php'),
142
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
143
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
144
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
145
+			'rest_root'                 => esc_url_raw(rest_url()),
146 146
 			'date_range'                => $date_range,
147
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
148
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
149
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
150
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
147
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
148
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
149
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
150
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
151 151
             'tax'                       => wpinv_tax_amount(),
152 152
             'discount'                  => 0,
153 153
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -156,35 +156,35 @@  discard block
 block discarded – undo
156 156
             'thousand_sep'              => wpinv_thousands_separator(),
157 157
             'decimal_sep'               => wpinv_decimal_separator(),
158 158
             'decimals'                  => wpinv_decimals(),
159
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
160
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
161
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
162
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
163
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
164
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
165
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
166
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
167
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
168
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
169
-            'action_edit'               => __( 'Edit', 'invoicing' ),
170
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
171
-            'item_description'          => __( 'Item Description', 'invoicing' ),
172
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
173
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
174
-            'searching'                 => __( 'Searching', 'invoicing' ),
159
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
160
+            'status_publish'            => wpinv_status_nicename('publish'),
161
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
162
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
163
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
164
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
165
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
166
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
167
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
168
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
169
+            'action_edit'               => __('Edit', 'invoicing'),
170
+            'action_cancel'             => __('Cancel', 'invoicing'),
171
+            'item_description'          => __('Item Description', 'invoicing'),
172
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
173
+            'discount_description'      => __('Discount Description', 'invoicing'),
174
+            'searching'                 => __('Searching', 'invoicing'),
175 175
         );
176 176
 
177
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
177
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
178 178
 
179
-			$invoice              = new WPInv_Invoice( $post );
179
+			$invoice              = new WPInv_Invoice($post);
180 180
 			$i18n['save_invoice'] = sprintf(
181
-				__( 'Save %s', 'invoicing' ),
182
-				ucfirst( $invoice->get_invoice_quote_type() )
181
+				__('Save %s', 'invoicing'),
182
+				ucfirst($invoice->get_invoice_quote_type())
183 183
 			);
184 184
 
185 185
 			$i18n['invoice_description'] = sprintf(
186
-				__( '%s Description', 'invoicing' ),
187
-				ucfirst( $invoice->get_invoice_quote_type() )
186
+				__('%s Description', 'invoicing'),
187
+				ucfirst($invoice->get_invoice_quote_type())
188 188
 			);
189 189
 
190 190
 		}
@@ -198,24 +198,24 @@  discard block
 block discarded – undo
198 198
 	 * @param  string $footer_text
199 199
 	 * @return string
200 200
 	 */
201
-	public function admin_footer_text( $footer_text ) {
201
+	public function admin_footer_text($footer_text) {
202 202
 		global $current_screen;
203 203
 
204
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
204
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
205 205
 
206
-        if ( ! empty( $current_screen->post_type ) ) {
206
+        if (!empty($current_screen->post_type)) {
207 207
 			$page = $current_screen->post_type;
208 208
         }
209 209
 
210 210
         // General styles.
211
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
211
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
212 212
 
213 213
 			// Change the footer text
214
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
214
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
215 215
 
216
-				$rating_url  = esc_url(
216
+				$rating_url = esc_url(
217 217
 					wp_nonce_url(
218
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
218
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
219 219
 						'getpaid-nonce',
220 220
 						'getpaid-nonce'
221 221
 						)
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 				$footer_text = sprintf(
225 225
 					/* translators: %s: five stars */
226
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
226
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
227 227
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
228 228
 				);
229 229
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 				$footer_text = sprintf(
233 233
 					/* translators: %s: GetPaid */
234
-					__( 'Thank you for using %s!', 'invoicing' ),
234
+					__('Thank you for using %s!', 'invoicing'),
235 235
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
236 236
 				);
237 237
 
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @since  2.0.0
249 249
 	 */
250 250
 	public function redirect_to_wordpress_rating_page() {
251
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
252
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
251
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
252
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
253 253
 		exit;
254 254
 	}
255 255
 
@@ -260,30 +260,30 @@  discard block
 block discarded – undo
260 260
 	protected function load_payment_form_scripts() {
261 261
         global $post;
262 262
 
263
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
264
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
265
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
263
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
264
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
265
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
266 266
 
267
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
268
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
267
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
268
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
269 269
 
270 270
 		wp_localize_script(
271 271
             'wpinv-admin-payment-form-script',
272 272
             'wpinvPaymentFormAdmin',
273 273
             array(
274
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
275
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
274
+				'elements'      => wpinv_get_data('payment-form-elements'),
275
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
276 276
 				'currency'      => wpinv_currency_symbol(),
277 277
 				'position'      => wpinv_currency_position(),
278 278
 				'decimals'      => (int) wpinv_decimals(),
279 279
 				'thousands_sep' => wpinv_thousands_separator(),
280 280
 				'decimals_sep'  => wpinv_decimal_separator(),
281
-				'form_items'    => gepaid_get_form_items( $post->ID ),
281
+				'form_items'    => gepaid_get_form_items($post->ID),
282 282
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
283 283
             )
284 284
         );
285 285
 
286
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
286
+        wp_enqueue_script('wpinv-admin-payment-form-script');
287 287
 
288 288
     }
289 289
 
@@ -294,25 +294,25 @@  discard block
 block discarded – undo
294 294
      * @return string
295 295
 	 *
296 296
 	 */
297
-    public function admin_body_class( $classes ) {
297
+    public function admin_body_class($classes) {
298 298
 		global $pagenow, $post, $current_screen;
299 299
 
300 300
 
301
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
301
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
302 302
 
303
-        if ( ! empty( $current_screen->post_type ) ) {
303
+        if (!empty($current_screen->post_type)) {
304 304
 			$page = $current_screen->post_type;
305 305
         }
306 306
 
307
-        if ( false !== stripos( $page, 'wpi' ) ) {
308
-            $classes .= ' wpi-' . sanitize_key( $page );
307
+        if (false !== stripos($page, 'wpi')) {
308
+            $classes .= ' wpi-' . sanitize_key($page);
309 309
         }
310 310
 
311
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
311
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
312 312
             $classes .= ' wpinv-cpt wpinv';
313 313
 		}
314 314
 		
315
-		if ( getpaid_is_invoice_post_type( $page ) ) {
315
+		if (getpaid_is_invoice_post_type($page)) {
316 316
             $classes .= ' getpaid-is-invoice-cpt';
317 317
         }
318 318
 
@@ -322,19 +322,19 @@  discard block
 block discarded – undo
322 322
     /**
323 323
 	 * Maybe show the AyeCode Connect Notice.
324 324
 	 */
325
-	public function init_ayecode_connect_helper(){
325
+	public function init_ayecode_connect_helper() {
326 326
 
327 327
         new AyeCode_Connect_Helper(
328 328
             array(
329
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
330
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
331
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
332
-				'connect_button'    => __("Connect Site","invoicing"),
333
-				'connecting_button'    => __("Connecting...","invoicing"),
334
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
335
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
329
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
330
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
331
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
332
+				'connect_button'    => __("Connect Site", "invoicing"),
333
+				'connecting_button'    => __("Connecting...", "invoicing"),
334
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
335
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
336 336
             ),
337
-            array( 'wpi-addons' )
337
+            array('wpi-addons')
338 338
         );
339 339
 
340 340
     }
@@ -346,20 +346,20 @@  discard block
 block discarded – undo
346 346
 	 */
347 347
 	public function activation_redirect() {
348 348
 
349
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
349
+		$redirected = get_option('wpinv_redirected_to_settings');
350 350
 
351
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
351
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
352 352
 			return;
353 353
 		}
354 354
 
355 355
 		// Bail if activating from network, or bulk
356
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
356
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
357 357
 			return;
358 358
 		}
359 359
 
360
-	    update_option( 'wpinv_redirected_to_settings', 1 );
360
+	    update_option('wpinv_redirected_to_settings', 1);
361 361
 
362
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
362
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
363 363
         exit;
364 364
 
365 365
 	}
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
      */
370 370
     public function maybe_do_admin_action() {
371 371
 
372
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
373
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
374
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
372
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
373
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
374
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
375 375
         }
376 376
 
377 377
     }
@@ -381,16 +381,16 @@  discard block
 block discarded – undo
381 381
 	 * 
382 382
 	 * @param array $args
383 383
      */
384
-    public function send_customer_invoice( $args ) {
385
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
384
+    public function send_customer_invoice($args) {
385
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
386 386
 
387
-		if ( $sent ) {
388
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
387
+		if ($sent) {
388
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
389 389
 		} else {
390
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
390
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
391 391
 		}
392 392
 
393
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
393
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
394 394
 		exit;
395 395
 	}
396 396
 
@@ -399,16 +399,16 @@  discard block
 block discarded – undo
399 399
 	 * 
400 400
 	 * @param array $args
401 401
      */
402
-    public function send_customer_payment_reminder( $args ) {
403
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
402
+    public function send_customer_payment_reminder($args) {
403
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
404 404
 
405
-		if ( $sent ) {
406
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
405
+		if ($sent) {
406
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
407 407
 		} else {
408
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
408
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
409 409
 		}
410 410
 
411
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
411
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
412 412
 		exit;
413 413
 	}
414 414
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
      */
419 419
     public function admin_reset_tax_rates() {
420 420
 
421
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
422
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
421
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
422
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
423 423
 		exit;
424 424
 
425 425
 	}
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
     public function admin_create_missing_pages() {
432 432
 		$installer = new GetPaid_Installer();
433 433
 		$installer->create_pages();
434
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
435
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
434
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
435
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
436 436
 		exit;
437 437
 	}
438 438
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
      * @return array
444 444
 	 */
445 445
 	public function get_notices() {
446
-		$notices = get_option( 'wpinv_admin_notices' );
447
-        return is_array( $notices ) ? $notices : array();
446
+		$notices = get_option('wpinv_admin_notices');
447
+        return is_array($notices) ? $notices : array();
448 448
 	}
449 449
 
450 450
 	/**
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 * @since       1.0.19
455 455
 	 */
456 456
 	public function clear_notices() {
457
-		delete_option( 'wpinv_admin_notices' );
457
+		delete_option('wpinv_admin_notices');
458 458
 	}
459 459
 
460 460
 	/**
@@ -463,16 +463,16 @@  discard block
 block discarded – undo
463 463
 	 * @access      public
464 464
 	 * @since       1.0.19
465 465
 	 */
466
-	public function save_notice( $type, $message ) {
466
+	public function save_notice($type, $message) {
467 467
 		$notices = $this->get_notices();
468 468
 
469
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
470
-			$notices[ $type ] = array();
469
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
470
+			$notices[$type] = array();
471 471
 		}
472 472
 
473
-		$notices[ $type ][] = $message;
473
+		$notices[$type][] = $message;
474 474
 
475
-		update_option( 'wpinv_admin_notices', $notices );
475
+		update_option('wpinv_admin_notices', $notices);
476 476
 	}
477 477
 
478 478
 	/**
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 * @access      public
483 483
 	 * @since       1.0.19
484 484
 	 */
485
-	public function show_success( $msg ) {
486
-		$this->save_notice( 'success', $msg );
485
+	public function show_success($msg) {
486
+		$this->save_notice('success', $msg);
487 487
 	}
488 488
 
489 489
 	/**
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	 * @param       string $msg The message to qeue.
494 494
 	 * @since       1.0.19
495 495
 	 */
496
-	public function show_error( $msg ) {
497
-		$this->save_notice( 'error', $msg );
496
+	public function show_error($msg) {
497
+		$this->save_notice('error', $msg);
498 498
 	}
499 499
 
500 500
 	/**
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 	 * @param       string $msg The message to qeue.
505 505
 	 * @since       1.0.19
506 506
 	 */
507
-	public function show_warning( $msg ) {
508
-		$this->save_notice( 'warning', $msg );
507
+	public function show_warning($msg) {
508
+		$this->save_notice('warning', $msg);
509 509
 	}
510 510
 
511 511
 	/**
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 	 * @param       string $msg The message to qeue.
516 516
 	 * @since       1.0.19
517 517
 	 */
518
-	public function show_info( $msg ) {
519
-		$this->save_notice( 'info', $msg );
518
+	public function show_info($msg) {
519
+		$this->save_notice('info', $msg);
520 520
 	}
521 521
 
522 522
 	/**
@@ -530,32 +530,32 @@  discard block
 block discarded – undo
530 530
         $notices = $this->get_notices();
531 531
         $this->clear_notices();
532 532
 
533
-		foreach ( $notices as $type => $messages ) {
533
+		foreach ($notices as $type => $messages) {
534 534
 
535
-			if ( ! is_array( $messages ) ) {
535
+			if (!is_array($messages)) {
536 536
 				continue;
537 537
 			}
538 538
 
539
-            $type  = sanitize_key( $type );
540
-			foreach ( $messages as $message ) {
541
-                $message = wp_kses_post( $message );
539
+            $type = sanitize_key($type);
540
+			foreach ($messages as $message) {
541
+                $message = wp_kses_post($message);
542 542
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
543 543
             }
544 544
 
545 545
         }
546 546
 
547
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
547
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
548 548
 
549
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
550
-				$url     = esc_url(
549
+			if (!is_numeric(wpinv_get_option($page, false))) {
550
+				$url = esc_url(
551 551
 					wp_nonce_url(
552
-						add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
552
+						add_query_arg('getpaid-admin-action', 'create_missing_pages'),
553 553
 						'getpaid-nonce',
554 554
 						'getpaid-nonce'
555 555
 					)
556 556
 				);
557
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
558
-				$message2 = __( 'Generate Pages', 'invoicing' );
557
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
558
+				$message2 = __('Generate Pages', 'invoicing');
559 559
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
560 560
 				break;
561 561
 			}
Please login to merge, or discard this patch.
invoicing.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.0.2' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.0.2');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
@@ -54,4 +54,4 @@  discard block
 block discarded – undo
54 54
 }
55 55
 
56 56
 // Kickstart the plugin.
57
-add_action( 'plugins_loaded', 'getpaid', -100 );
57
+add_action('plugins_loaded', 'getpaid', -100);
Please login to merge, or discard this patch.