Passed
Pull Request — master (#481)
by Patrik
04:37
created
includes/admin/register-settings.php 3 patches
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -628,10 +628,11 @@
 block discarded – undo
628 628
 	foreach ( $args['options'] as $key => $option ) :
629 629
 		$sanitize_key = wpinv_sanitize_key( $key );
630 630
         
631
-        if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
632
-			$enabled = '1';
633
-		else
634
-			$enabled = null;
631
+        if ( is_array( $gateways ) && isset( $gateways[ $key ] ) ) {
632
+        			$enabled = '1';
633
+        } else {
634
+					$enabled = null;
635
+		}
635 636
 
636 637
 		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 638
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
Please login to merge, or discard this patch.
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = wpinv_clean( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228 228
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229 229
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
230
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
232 232
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233 233
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
@@ -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
 /**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
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
-		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
294
+        // Key specific filter.
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
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 
349 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'] );
356
-		$tax_rates[]     = $rate;
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
+        $tax_rates[]     = $rate;
357 357
 
358
-	}
358
+    }
359 359
 
360 360
     update_option( 'wpinv_tax_rates', $tax_rates );
361 361
 
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
     $tabs['general']  = __( 'General', 'invoicing' );
374 374
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375 375
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
376
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
-	}
378
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
+    }
381 381
 
382 382
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383 383
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
         ) ),
416 416
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
417 417
             'main'  => __( 'Tax Settings', 'invoicing' ),
418
-			'rates' => __( 'Tax Rates', 'invoicing' ),
419
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
418
+            'rates' => __( 'Tax Rates', 'invoicing' ),
419
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
420 420
         ) ),
421 421
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
422 422
             'main' => __( 'Email Settings', 'invoicing' ),
423
-		) ),
423
+        ) ),
424 424
 
425
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
425
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
426 426
 
427 427
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
428 428
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -442,51 +442,51 @@  discard block
 block discarded – undo
442 442
 }
443 443
 
444 444
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
445
-	$pages_options = array();
445
+    $pages_options = array();
446 446
 
447
-	if( $default_label !== NULL && $default_label !== false ) {
448
-		$pages_options = array( '' => $default_label ); // Blank option
449
-	}
447
+    if( $default_label !== NULL && $default_label !== false ) {
448
+        $pages_options = array( '' => $default_label ); // Blank option
449
+    }
450 450
 
451
-	$pages = get_pages();
452
-	if ( $pages ) {
453
-		foreach ( $pages as $page ) {
454
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
451
+    $pages = get_pages();
452
+    if ( $pages ) {
453
+        foreach ( $pages as $page ) {
454
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
455 455
             $pages_options[ $page->ID ] = $title;
456
-		}
457
-	}
456
+        }
457
+    }
458 458
 
459
-	return $pages_options;
459
+    return $pages_options;
460 460
 }
461 461
 
462 462
 function wpinv_header_callback( $args ) {
463
-	if ( !empty( $args['desc'] ) ) {
463
+    if ( !empty( $args['desc'] ) ) {
464 464
         echo $args['desc'];
465 465
     }
466 466
 }
467 467
 
468 468
 function wpinv_hidden_callback( $args ) {
469
-	global $wpinv_options;
470
-
471
-	if ( isset( $args['set_value'] ) ) {
472
-		$value = $args['set_value'];
473
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
-		$value = $wpinv_options[ $args['id'] ];
475
-	} else {
476
-		$value = isset( $args['std'] ) ? $args['std'] : '';
477
-	}
478
-
479
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
480
-		$args['readonly'] = true;
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
482
-		$name  = '';
483
-	} else {
484
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
485
-	}
486
-
487
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
469
+    global $wpinv_options;
470
+
471
+    if ( isset( $args['set_value'] ) ) {
472
+        $value = $args['set_value'];
473
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
+        $value = $wpinv_options[ $args['id'] ];
475
+    } else {
476
+        $value = isset( $args['std'] ) ? $args['std'] : '';
477
+    }
478
+
479
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
480
+        $args['readonly'] = true;
481
+        $value = isset( $args['std'] ) ? $args['std'] : '';
482
+        $name  = '';
483
+    } else {
484
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
485
+    }
486
+
487
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
488 488
     
489
-	echo $html;
489
+    echo $html;
490 490
 }
491 491
 
492 492
 /**
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
  */
495 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' );
502
-	?>
501
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
502
+    ?>
503 503
 		<fieldset>
504 504
 			<label>
505 505
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -511,77 +511,77 @@  discard block
 block discarded – undo
511 511
 
512 512
 function wpinv_multicheck_callback( $args ) {
513 513
 	
514
-	global $wpinv_options;
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
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
524
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
525 525
         foreach( $args['options'] as $key => $option ):
526
-			$sanitize_key = wpinv_sanitize_key( $key );
527
-			if ( in_array( $sanitize_key, $value ) ) { 
528
-				$enabled = $sanitize_key;
529
-			} else { 
530
-				$enabled = NULL; 
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>';
534
-		endforeach;
535
-		echo '</div>';
536
-		echo '<p class="description">' . $args['desc'] . '</p>';
537
-	}
526
+            $sanitize_key = wpinv_sanitize_key( $key );
527
+            if ( in_array( $sanitize_key, $value ) ) { 
528
+                $enabled = $sanitize_key;
529
+            } else { 
530
+                $enabled = NULL; 
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>';
534
+        endforeach;
535
+        echo '</div>';
536
+        echo '<p class="description">' . $args['desc'] . '</p>';
537
+    }
538 538
 }
539 539
 
540 540
 function wpinv_payment_icons_callback( $args ) {
541
-	global $wpinv_options;
541
+    global $wpinv_options;
542 542
     
543 543
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
544 544
 
545
-	if ( ! empty( $args['options'] ) ) {
546
-		foreach( $args['options'] as $key => $option ) {
545
+    if ( ! empty( $args['options'] ) ) {
546
+        foreach( $args['options'] as $key => $option ) {
547 547
             $sanitize_key = wpinv_sanitize_key( $key );
548 548
             
549
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
550
-				$enabled = $option;
551
-			} else {
552
-				$enabled = NULL;
553
-			}
554
-
555
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
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;';
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;"/>';
561
-				} else {
562
-					$card = strtolower( str_replace( ' ', '', $option ) );
563
-
564
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
-					} else {
567
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
568
-						$content_dir = WP_CONTENT_DIR;
569
-
570
-						if ( function_exists( 'wp_normalize_path' ) ) {
571
-							// Replaces backslashes with forward slashes for Windows systems
572
-							$image = wp_normalize_path( $image );
573
-							$content_dir = wp_normalize_path( $content_dir );
574
-						}
575
-
576
-						$image = str_replace( $content_dir, content_url(), $image );
577
-					}
578
-
579
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580
-				}
581
-			echo $option . '</label>';
582
-		}
583
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
584
-	}
549
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
550
+                $enabled = $option;
551
+            } else {
552
+                $enabled = NULL;
553
+            }
554
+
555
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
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;';
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;"/>';
561
+                } else {
562
+                    $card = strtolower( str_replace( ' ', '', $option ) );
563
+
564
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+                    } else {
567
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
568
+                        $content_dir = WP_CONTENT_DIR;
569
+
570
+                        if ( function_exists( 'wp_normalize_path' ) ) {
571
+                            // Replaces backslashes with forward slashes for Windows systems
572
+                            $image = wp_normalize_path( $image );
573
+                            $content_dir = wp_normalize_path( $content_dir );
574
+                        }
575
+
576
+                        $image = str_replace( $content_dir, content_url(), $image );
577
+                    }
578
+
579
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580
+                }
581
+            echo $option . '</label>';
582
+        }
583
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
584
+    }
585 585
 }
586 586
 
587 587
 /**
@@ -589,9 +589,9 @@  discard block
 block discarded – undo
589 589
  */
590 590
 function wpinv_radio_callback( $args ) {
591 591
 
592
-	$std = isset( $args['std'] ) ? $args['std'] : '';
593
-	$std = wpinv_get_option( $args['id'], $std );
594
-	?>
592
+    $std = isset( $args['std'] ) ? $args['std'] : '';
593
+    $std = wpinv_get_option( $args['id'], $std );
594
+    ?>
595 595
 		<fieldset>
596 596
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
597 597
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
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
 /**
@@ -613,50 +613,50 @@  discard block
 block discarded – undo
613 613
  */
614 614
 function getpaid_settings_description_callback( $args ) {
615 615
 
616
-	if ( ! empty( $args['desc'] ) ) {
617
-		$description = wp_kses_post( $args['desc'] );
618
-		echo "<p class='description'>$description</p>";
619
-	}
616
+    if ( ! empty( $args['desc'] ) ) {
617
+        $description = wp_kses_post( $args['desc'] );
618
+        echo "<p class='description'>$description</p>";
619
+    }
620 620
 
621 621
 }
622 622
 
623 623
 function wpinv_gateways_callback( $args ) {
624 624
 
625
-	$gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
625
+    $gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
626 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 631
         if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
632
-			$enabled = '1';
633
-		else
634
-			$enabled = null;
632
+            $enabled = '1';
633
+        else
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/>';
638
-	endforeach;
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
+    endforeach;
639 639
 }
640 640
 
641 641
 function wpinv_gateway_select_callback($args) {
642
-	global $wpinv_options;
642
+    global $wpinv_options;
643 643
     
644 644
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
645 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 ) {
649
+    foreach ( $args['options'] as $key => $option ) :
650
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651 651
             $selected = selected( $key, $args['selected'], false );
652 652
         } else {
653 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>';
656
-	endforeach;
655
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
656
+    endforeach;
657 657
 
658
-	echo '</select>';
659
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
658
+    echo '</select>';
659
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
660 660
 }
661 661
 
662 662
 /**
@@ -667,29 +667,29 @@  discard block
 block discarded – undo
667 667
  */
668 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'] ) ) {
675
-		$args['readonly'] = true;
676
-		$name             = '';
677
-	} else {
678
-		$value  = wpinv_get_option( $args['id'], $value );
679
-		$name   = "wpinv_settings[$id]";
680
-	}
674
+    if ( ! empty( $args['faux'] ) ) {
675
+        $args['readonly'] = true;
676
+        $name             = '';
677
+    } else {
678
+        $value  = wpinv_get_option( $args['id'], $value );
679
+        $name   = "wpinv_settings[$id]";
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
-	$onchange = '';
687
+    $onchange = '';
688 688
     if ( ! empty( $args['onchange'] ) ) {
689 689
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
690
-	}
690
+    }
691 691
 
692
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
692
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
693 693
 }
694 694
 
695 695
 /**
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
  */
698 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%;">
706 706
 			<input type="text" <?php echo $attr; ?>>
707 707
 			<?php echo $desc; ?>
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
  */
716 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%;">
727 727
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
728 728
 			<?php echo $desc; ?>
@@ -732,48 +732,48 @@  discard block
 block discarded – undo
732 732
 }
733 733
 
734 734
 function wpinv_textarea_callback( $args ) {
735
-	global $wpinv_options;
735
+    global $wpinv_options;
736 736
     
737 737
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
738 738
 
739
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
-		$value = $wpinv_options[ $args['id'] ];
741
-	} else {
742
-		$value = isset( $args['std'] ) ? $args['std'] : '';
743
-	}
739
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
+        $value = $wpinv_options[ $args['id'] ];
741
+    } else {
742
+        $value = isset( $args['std'] ) ? $args['std'] : '';
743
+    }
744 744
     
745 745
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
746 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
-	echo $html;
751
+    echo $html;
752 752
 }
753 753
 
754 754
 function wpinv_password_callback( $args ) {
755
-	global $wpinv_options;
755
+    global $wpinv_options;
756 756
     
757 757
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
758 758
 
759
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
-		$value = $wpinv_options[ $args['id'] ];
761
-	} else {
762
-		$value = isset( $args['std'] ) ? $args['std'] : '';
763
-	}
759
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
+        $value = $wpinv_options[ $args['id'] ];
761
+    } else {
762
+        $value = isset( $args['std'] ) ? $args['std'] : '';
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
-	echo $html;
769
+    echo $html;
770 770
 }
771 771
 
772 772
 function wpinv_missing_callback($args) {
773
-	printf(
774
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
775
-		'<strong>' . $args['id'] . '</strong>'
776
-	);
773
+    printf(
774
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
775
+        '<strong>' . $args['id'] . '</strong>'
776
+    );
777 777
 }
778 778
 
779 779
 /**
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
  */
782 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 793
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -801,123 +801,123 @@  discard block
 block discarded – undo
801 801
 }
802 802
 
803 803
 function wpinv_color_select_callback( $args ) {
804
-	global $wpinv_options;
804
+    global $wpinv_options;
805 805
     
806 806
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
807 807
 
808
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
-		$value = $wpinv_options[ $args['id'] ];
810
-	} else {
811
-		$value = isset( $args['std'] ) ? $args['std'] : '';
812
-	}
808
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
+        $value = $wpinv_options[ $args['id'] ];
810
+    } else {
811
+        $value = isset( $args['std'] ) ? $args['std'] : '';
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>';
819
-	}
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
+    }
820 820
 
821
-	$html .= '</select>';
822
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
821
+    $html .= '</select>';
822
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
823 823
 
824
-	echo $html;
824
+    echo $html;
825 825
 }
826 826
 
827 827
 function wpinv_rich_editor_callback( $args ) {
828
-	global $wpinv_options, $wp_version;
828
+    global $wpinv_options, $wp_version;
829 829
     
830 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'] : '';
837
-		}
838
-	} else {
839
-		$value = isset( $args['std'] ) ? $args['std'] : '';
840
-	}
835
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
+            $value = isset( $args['std'] ) ? $args['std'] : '';
837
+        }
838
+    } else {
839
+        $value = isset( $args['std'] ) ? $args['std'] : '';
840
+    }
841 841
 
842
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
842
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
843 843
 
844
-	$html = '<div class="getpaid-settings-editor-input">';
845
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
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 ) );
848
-		$html .= ob_get_clean();
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>';
851
-	}
844
+    $html = '<div class="getpaid-settings-editor-input">';
845
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
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 ) );
848
+        $html .= ob_get_clean();
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>';
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
-	echo $html;
855
+    echo $html;
856 856
 }
857 857
 
858 858
 function wpinv_upload_callback( $args ) {
859
-	global $wpinv_options;
859
+    global $wpinv_options;
860 860
     
861 861
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
862 862
 
863
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
864
-		$value = $wpinv_options[$args['id']];
865
-	} else {
866
-		$value = isset($args['std']) ? $args['std'] : '';
867
-	}
863
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
864
+        $value = $wpinv_options[$args['id']];
865
+    } else {
866
+        $value = isset($args['std']) ? $args['std'] : '';
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
-	echo $html;
874
+    echo $html;
875 875
 }
876 876
 
877 877
 function wpinv_color_callback( $args ) {
878
-	global $wpinv_options;
878
+    global $wpinv_options;
879 879
     
880 880
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
881 881
 
882
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
-		$value = $wpinv_options[ $args['id'] ];
884
-	} else {
885
-		$value = isset( $args['std'] ) ? $args['std'] : '';
886
-	}
882
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
+        $value = $wpinv_options[ $args['id'] ];
884
+    } else {
885
+        $value = isset( $args['std'] ) ? $args['std'] : '';
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
-	echo $html;
893
+    echo $html;
894 894
 }
895 895
 
896 896
 function wpinv_country_states_callback($args) {
897
-	global $wpinv_options;
897
+    global $wpinv_options;
898 898
     
899 899
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
900 900
 
901
-	if ( isset( $args['placeholder'] ) ) {
902
-		$placeholder = $args['placeholder'];
903
-	} else {
904
-		$placeholder = '';
905
-	}
901
+    if ( isset( $args['placeholder'] ) ) {
902
+        $placeholder = $args['placeholder'];
903
+    } else {
904
+        $placeholder = '';
905
+    }
906 906
 
907
-	$states = wpinv_get_country_states();
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>';
915
-	}
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
+    }
916 916
 
917
-	$html .= '</select>';
918
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
917
+    $html .= '</select>';
918
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
919 919
 
920
-	echo $html;
920
+    echo $html;
921 921
 }
922 922
 
923 923
 /**
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  */
926 926
 function wpinv_tax_rates_callback() {
927 927
 	
928
-	?>
928
+    ?>
929 929
 		</td>
930 930
 	</tr>
931 931
 	<tr class="bsui">
@@ -940,17 +940,17 @@  discard block
 block discarded – undo
940 940
  * Displays a tax rate' edit row.
941 941
  */
942 942
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
943
-	ob_start();
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 ) {
950
-		echo ob_get_clean();
951
-	} else {
952
-		return ob_get_clean(); 
953
-	}
949
+    if ( $echo ) {
950
+        echo ob_get_clean();
951
+    } else {
952
+        return ob_get_clean(); 
953
+    }
954 954
 
955 955
 }
956 956
 
@@ -977,14 +977,14 @@  discard block
 block discarded – undo
977 977
                 </td>
978 978
                 <td>
979 979
 					<a href="<?php
980
-						echo esc_url(
981
-							wp_nonce_url(
982
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
983
-								'getpaid-nonce',
984
-								'getpaid-nonce'
985
-							)
986
-						);
987
-					?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a>
980
+                        echo esc_url(
981
+                            wp_nonce_url(
982
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
983
+                                'getpaid-nonce',
984
+                                'getpaid-nonce'
985
+                            )
986
+                        );
987
+                    ?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a>
988 988
                 </td>
989 989
             </tr>
990 990
 			<?php do_action( 'wpinv_tools_row' ); ?>
@@ -996,19 +996,19 @@  discard block
 block discarded – undo
996 996
 }
997 997
 
998 998
 function wpinv_descriptive_text_callback( $args ) {
999
-	echo wp_kses_post( $args['desc'] );
999
+    echo wp_kses_post( $args['desc'] );
1000 1000
 }
1001 1001
 
1002 1002
 function wpinv_raw_html_callback( $args ) {
1003
-	echo $args['desc'];
1003
+    echo $args['desc'];
1004 1004
 }
1005 1005
 
1006 1006
 function wpinv_hook_callback( $args ) {
1007
-	do_action( 'wpinv_' . $args['id'], $args );
1007
+    do_action( 'wpinv_' . $args['id'], $args );
1008 1008
 }
1009 1009
 
1010 1010
 function wpinv_set_settings_cap() {
1011
-	return wpinv_get_capability();
1011
+    return wpinv_get_capability();
1012 1012
 }
1013 1013
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1014 1014
 
Please login to merge, or discard this 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/data/admin-settings.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -8,197 +8,197 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-$pages = wpinv_get_pages( true );
13
+$pages = wpinv_get_pages(true);
14 14
     
15 15
 $currencies = wpinv_get_currencies();
16 16
     
17 17
 $currency_code_options = array();
18
-foreach ( $currencies as $code => $name ) {
19
-    $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
18
+foreach ($currencies as $code => $name) {
19
+    $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
20 20
 }
21 21
     
22 22
 $due_payment_options       = array();
23
-$due_payment_options[0]    = __( 'Now', 'invoicing' );
24
-for ( $i = 1; $i <= 30; $i++ ) {
23
+$due_payment_options[0]    = __('Now', 'invoicing');
24
+for ($i = 1; $i <= 30; $i++) {
25 25
     $due_payment_options[$i] = $i;
26 26
 }
27 27
     
28 28
 $invoice_number_padd_options = array();
29
-for ( $i = 0; $i <= 20; $i++ ) {
29
+for ($i = 0; $i <= 20; $i++) {
30 30
     $invoice_number_padd_options[$i] = $i;
31 31
 }
32 32
     
33 33
 $currency_symbol = wpinv_currency_symbol();
34 34
     
35 35
 $last_number = $reset_number = '';
36
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
37
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
36
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
37
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
38 38
 
39
-    if ( !empty( $last_invoice_number ) ) {
40
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
39
+    if (!empty($last_invoice_number)) {
40
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
41 41
     }
42 42
 
43 43
     $nonce = wp_create_nonce('reset_invoice_count');
44
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
44
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
45 45
 }
46 46
     
47 47
 $alert_wrapper_start = '<p style="color: #F00">';
48 48
 $alert_wrapper_close = '</p>';
49 49
 
50 50
 return array(
51
-    'general' => apply_filters( 'wpinv_settings_general',
51
+    'general' => apply_filters('wpinv_settings_general',
52 52
         array(
53 53
             'main' => array(
54 54
                 'location_settings' => array(
55 55
                     'id'   => 'location_settings',
56
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
56
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
57 57
                     'desc' => '',
58 58
                     'type' => 'header',
59 59
                 ),
60 60
                 'default_country' => array(
61 61
                     'id'      => 'default_country',
62
-                    'name'    => __( 'Default Country', 'invoicing' ),
63
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
62
+                    'name'    => __('Default Country', 'invoicing'),
63
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
64 64
                     'type'    => 'select',
65 65
                     'options' => wpinv_get_country_list(),
66 66
                     'std'     => 'GB',
67 67
                     'class'   => 'wpi_select2',
68
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
68
+                    'placeholder' => __('Select a country', 'invoicing'),
69 69
                 ),
70 70
                 'default_state' => array(
71 71
                     'id'      => 'default_state',
72
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
73
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
72
+                    'name'    => __('Default State / Province', 'invoicing'),
73
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
74 74
                     'type'    => 'country_states',
75 75
                     'class'   => 'wpi_select2',
76
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
76
+                    'placeholder' => __('Select a state', 'invoicing'),
77 77
                 ),
78 78
                 'store_name' => array(
79 79
                     'id'   => 'store_name',
80
-                    'name' => __( 'Store Name', 'invoicing' ),
81
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
80
+                    'name' => __('Store Name', 'invoicing'),
81
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
82 82
                     'std'     => get_option('blogname'),
83 83
                     'type' => 'text',
84 84
                 ),
85 85
                 'logo' => array(
86 86
                     'id'   => 'logo',
87
-                    'name' => __( 'Logo URL', 'invoicing' ),
88
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
87
+                    'name' => __('Logo URL', 'invoicing'),
88
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
89 89
                     'type' => 'text',
90 90
                 ),
91 91
                 'store_address' => array(
92 92
                     'id'   => 'store_address',
93
-                    'name' => __( 'Store Address', 'invoicing' ),
94
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
93
+                    'name' => __('Store Address', 'invoicing'),
94
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
95 95
                     'type' => 'textarea',
96 96
                 ),
97 97
                 'page_settings' => array(
98 98
                     'id'   => 'page_settings',
99
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
99
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
100 100
                     'desc' => '',
101 101
                     'type' => 'header',
102 102
                 ),
103 103
                 'checkout_page' => array(
104 104
                     'id'          => 'checkout_page',
105
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
106
-                    'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
105
+                    'name'        => __('Checkout Page', 'invoicing'),
106
+                    'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
107 107
                     'type'        => 'select',
108 108
                     'options'     => $pages,
109 109
                     'class'       => 'wpi_select2',
110
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
110
+                    'placeholder' => __('Select a page', 'invoicing'),
111 111
                     'help-tip'    => true,
112 112
                 ),
113 113
                 'success_page' => array(
114 114
                     'id'          => 'success_page',
115
-                    'name'        => __( 'Success Page', 'invoicing' ),
116
-                    'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
115
+                    'name'        => __('Success Page', 'invoicing'),
116
+                    'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
117 117
                     'type'        => 'select',
118 118
                     'options'     => $pages,
119 119
                     'class'       => 'wpi_select2',
120
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
120
+                    'placeholder' => __('Select a page', 'invoicing'),
121 121
                     'help-tip'    => true,
122 122
                 ),
123 123
                 'failure_page' => array(
124 124
                     'id'          => 'failure_page',
125
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
126
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
125
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
126
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
127 127
                     'type'        => 'select',
128 128
                     'options'     => $pages,
129 129
                     'class'       => 'wpi_select2',
130
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
130
+                    'placeholder' => __('Select a page', 'invoicing'),
131 131
                     'help-tip'    => true,
132 132
                 ),
133 133
                 'invoice_history_page' => array(
134 134
                     'id'          => 'invoice_history_page',
135
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
136
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
135
+                    'name'        => __('Invoice History Page', 'invoicing'),
136
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
137 137
                     'type'        => 'select',
138 138
                     'options'     => $pages,
139 139
                     'class'       => 'wpi_select2',
140
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
140
+                    'placeholder' => __('Select a page', 'invoicing'),
141 141
                     'help-tip'    => true,
142 142
                 ),
143 143
                 'invoice_subscription_page' => array(
144 144
                     'id'          => 'invoice_subscription_page',
145
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
146
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
145
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
146
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
147 147
                     'type'        => 'select',
148 148
                     'options'     => $pages,
149 149
                     'class'       => 'wpi_select2',
150
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
150
+                    'placeholder' => __('Select a page', 'invoicing'),
151 151
                     'help-tip'    => true,
152 152
                 ),
153 153
             ),
154 154
             'currency_section' => array(
155 155
                 'currency_settings' => array(
156 156
                     'id'   => 'currency_settings',
157
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
157
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
158 158
                     'desc' => '',
159 159
                     'type' => 'header',
160 160
                 ),
161 161
                 'currency' => array(
162 162
                     'id'      => 'currency',
163
-                    'name'    => __( 'Currency', 'invoicing' ),
164
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
163
+                    'name'    => __('Currency', 'invoicing'),
164
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
165 165
                     'type'    => 'select',
166 166
                     'class'       => 'wpi_select2',
167 167
                     'options' => $currency_code_options,
168 168
                 ),
169 169
                 'currency_position' => array(
170 170
                     'id'      => 'currency_position',
171
-                    'name'    => __( 'Currency Position', 'invoicing' ),
172
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
171
+                    'name'    => __('Currency Position', 'invoicing'),
172
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
173 173
                     'type'    => 'select',
174 174
                     'class'   => 'wpi_select2',
175 175
                     'options'  => array(
176
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
177
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
178
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
179
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
176
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
177
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
178
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
179
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
180 180
                     )
181 181
                 ),
182 182
                 'thousands_separator' => array(
183 183
                     'id'   => 'thousands_separator',
184
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
185
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
184
+                    'name' => __('Thousands Separator', 'invoicing'),
185
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
186 186
                     'type' => 'text',
187 187
                     'size' => 'small',
188 188
                     'std'  => ',',
189 189
                 ),
190 190
                 'decimal_separator' => array(
191 191
                     'id'   => 'decimal_separator',
192
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
193
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
192
+                    'name' => __('Decimal Separator', 'invoicing'),
193
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
194 194
                     'type' => 'text',
195 195
                     'size' => 'small',
196 196
                     'std'  => '.',
197 197
                 ),
198 198
                 'decimals' => array(
199 199
                     'id'   => 'decimals',
200
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
201
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
200
+                    'name' => __('Number of Decimals', 'invoicing'),
201
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
202 202
                     'type' => 'number',
203 203
                     'size' => 'small',
204 204
                     'std'  => '2',
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
             'labels' => array(
211 211
                 'labels' => array(
212 212
                     'id'   => 'labels_settings',
213
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
213
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
214 214
                     'desc' => '',
215 215
                     'type' => 'header',
216 216
                 ),
217 217
                 'vat_invoice_notice_label' => array(
218 218
                     'id' => 'vat_invoice_notice_label',
219
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
220
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
219
+                    'name' => __('Invoice Notice Label', 'invoicing'),
220
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
221 221
                     'type' => 'text',
222 222
                     'size' => 'regular',
223 223
                 ),
224 224
                 'vat_invoice_notice' => array(
225 225
                     'id' => 'vat_invoice_notice',
226
-                    'name' => __( 'Invoice notice', 'invoicing' ),
227
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
226
+                    'name' => __('Invoice notice', 'invoicing'),
227
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
228 228
                     'type' => 'text',
229 229
                     'size' => 'regular',
230 230
                 ),
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
             'main' => array(
237 237
                 'gateway_settings' => array(
238 238
                     'id'   => 'api_header',
239
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
239
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
240 240
                     'desc' => '',
241 241
                     'type' => 'header',
242 242
                 ),
243 243
                 'gateways' => array(
244 244
                     'id'      => 'gateways',
245
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
246
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
245
+                    'name'    => __('Payment Gateways', 'invoicing'),
246
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
247 247
                     'type'    => 'gateways',
248 248
                     'std'     => array('manual'=>1),
249 249
                     'options' => wpinv_get_payment_gateways(),
250 250
                 ),
251 251
                 'default_gateway' => array(
252 252
                     'id'      => 'default_gateway',
253
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
254
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
253
+                    'name'    => __('Default Gateway', 'invoicing'),
254
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
255 255
                     'type'    => 'gateway_select',
256 256
                     'std'     => 'manual',
257 257
                     'class'   => 'wpi_select2',
@@ -266,32 +266,32 @@  discard block
 block discarded – undo
266 266
             'main' => array(
267 267
                 'tax_settings' => array(
268 268
                     'id'   => 'tax_settings',
269
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
269
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
270 270
                     'type' => 'header',
271 271
                 ),
272 272
 
273 273
                 'enable_taxes' => array(
274 274
                     'id'       => 'enable_taxes',
275
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
276
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
275
+                    'name'     => __('Enable Taxes', 'invoicing'),
276
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
277 277
                     'type'     => 'checkbox',
278 278
                     'std'      => 0,
279 279
                 ),
280 280
 
281 281
                 'tax_subtotal_rounding' => array(
282 282
                     'id'                => 'tax_subtotal_rounding',
283
-                    'name'              => __( 'Rounding', 'invoicing' ),
284
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
283
+                    'name'              => __('Rounding', 'invoicing'),
284
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
285 285
                     'type'              => 'checkbox',
286 286
                     'std'               => 1,
287 287
                 ),
288 288
 
289 289
                 'prices_include_tax' => array(
290 290
                     'id'      => 'prices_include_tax',
291
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
291
+                    'name'    => __('Prices entered with tax', 'invoicing'),
292 292
                     'options' => array(
293
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
294
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
293
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
294
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
295 295
                     ),
296 296
                     'type'    => 'select',
297 297
                     'std'     => 'no',
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 
300 300
                 'tax_base'              => array(
301 301
                     'id'                => 'tax_base',
302
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
302
+                    'name'              => __('Calculate tax based on', 'invoicing'),
303 303
                     'options'           => array(
304
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
305
-                        'base'          => __( 'Shop base address', 'invoicing' ),
304
+                        'billing'       => __('Customer billing address', 'invoicing'),
305
+                        'base'          => __('Shop base address', 'invoicing'),
306 306
                     ),
307 307
                     'type'              => 'select',
308 308
                     'std'               => 'billing',
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 
311 311
                 'tax_display_totals'    => array(
312 312
                     'id'                => 'tax_display_totals',
313
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
313
+                    'name'              => __('Display tax totals', 'invoicing'),
314 314
                     'options'           => array(
315
-                        'single'        => __( 'As a single total', 'invoicing' ),
316
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
315
+                        'single'        => __('As a single total', 'invoicing'),
316
+                        'individual'    => __('As individual tax rates', 'invoicing'),
317 317
                     ),
318 318
                     'type'              => 'select',
319 319
                     'std'               => 'individual',
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 
322 322
                 'tax_rate' => array(
323 323
                     'id'   => 'tax_rate',
324
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
325
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
324
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
325
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
326 326
                     'type' => 'number',
327 327
                     'size' => 'small',
328 328
                     'min'  => '0',
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
             'rates' => array(
335 335
                 'tax_rates' => array(
336 336
                     'id'   => 'tax_rates',
337
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
338
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
337
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
338
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
339 339
                     'type' => 'tax_rates',
340 340
                 ),
341 341
             ),
@@ -344,44 +344,44 @@  discard block
 block discarded – undo
344 344
 
345 345
                 'vat_company_name' => array(
346 346
                     'id' => 'vat_company_name',
347
-                    'name' => __( 'Company Name', 'invoicing' ),
348
-                    'desc' => wp_sprintf(__( 'Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
347
+                    'name' => __('Company Name', 'invoicing'),
348
+                    'desc' => wp_sprintf(__('Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
349 349
                     'type' => 'text',
350 350
                     'size' => 'regular',
351 351
                 ),
352 352
 
353 353
                 'vat_number' => array(
354 354
                     'id'   => 'vat_number',
355
-                    'name' => __( 'VAT Number', 'invoicing' ),
356
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
355
+                    'name' => __('VAT Number', 'invoicing'),
356
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
357 357
                     'type' => 'text',
358 358
                     'size' => 'regular',
359 359
                 ),
360 360
 
361 361
                 'vat_prevent_b2c_purchase' => array(
362 362
                     'id' => 'vat_prevent_b2c_purchase',
363
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
364
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
363
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
364
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
365 365
                     'type' => 'checkbox'
366 366
                 ),
367 367
 
368 368
                 'validate_vat_number' => array(
369 369
                     'id'   => 'validate_vat_number',
370
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
371
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
370
+                    'name' => __('Validate VAT Number', 'invoicing'),
371
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
372 372
                     'type' => 'checkbox'
373 373
                 ),
374 374
 
375 375
                 'vat_same_country_rule' => array(
376 376
                     'id'          => 'vat_same_country_rule',
377
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
378
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
377
+                    'name'        => __('Same Country Rule', 'invoicing'),
378
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
379 379
                     'type'        => 'select',
380 380
                     'options'     => array(
381
-                        'no'        => __( 'Do not charge Tax', 'invoicing' ),
382
-                        'always'    => __( 'Charge Tax', 'invoicing' ),
381
+                        'no'        => __('Do not charge Tax', 'invoicing'),
382
+                        'always'    => __('Charge Tax', 'invoicing'),
383 383
                     ),
384
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
384
+                    'placeholder' => __('Select an option', 'invoicing'),
385 385
                     'std'         => 'always',
386 386
                 ),
387 387
 
@@ -395,68 +395,68 @@  discard block
 block discarded – undo
395 395
             'main' => array(
396 396
                 'email_settings_header' => array(
397 397
                     'id'   => 'email_settings_header',
398
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
398
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
399 399
                     'type' => 'header',
400 400
                 ),
401 401
                 'email_from_name' => array(
402 402
                     'id'   => 'email_from_name',
403
-                    'name' => __( 'From Name', 'invoicing' ),
404
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
405
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
403
+                    'name' => __('From Name', 'invoicing'),
404
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
405
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
406 406
                     'type' => 'text',
407 407
                 ),
408 408
                 'email_from' => array(
409 409
                     'id'   => 'email_from',
410
-                    'name' => __( 'From Email', 'invoicing' ),
411
-                    'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
412
-                    'std' => get_option( 'admin_email' ),
410
+                    'name' => __('From Email', 'invoicing'),
411
+                    'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
412
+                    'std' => get_option('admin_email'),
413 413
                     'type' => 'text',
414 414
                 ),
415 415
                 'admin_email' => array(
416 416
                     'id'   => 'admin_email',
417
-                    'name' => __( 'Admin Email', 'invoicing' ),
418
-                    'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
419
-                    'std' => get_option( 'admin_email' ),
417
+                    'name' => __('Admin Email', 'invoicing'),
418
+                    'desc' => __('Where should we send admin notifications?', 'invoicing'),
419
+                    'std' => get_option('admin_email'),
420 420
                     'type' => 'text',
421 421
                 ),
422 422
                 'overdue_settings_header' => array(
423 423
                     'id'   => 'overdue_settings_header',
424
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
424
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
425 425
                     'type' => 'header',
426 426
                 ),
427 427
                 'overdue_active' => array(
428 428
                     'id'   => 'overdue_active',
429
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
430
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
429
+                    'name' => __('Enable Due Date', 'invoicing'),
430
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
431 431
                     'type' => 'checkbox',
432 432
                     'std'  => false,
433 433
                 ),
434 434
                 'overdue_days' => array(
435 435
                     'id'          => 'overdue_days',
436
-                    'name'        => __( 'Default Due Date', 'invoicing' ),
437
-                    'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
436
+                    'name'        => __('Default Due Date', 'invoicing'),
437
+                    'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
438 438
                     'type'        => 'select',
439 439
                     'options'     => $due_payment_options,
440 440
                     'std'         => 0,
441
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
441
+                    'placeholder' => __('Select a page', 'invoicing'),
442 442
                 ),
443 443
                 'email_template_header' => array(
444 444
                     'id'   => 'email_template_header',
445
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
445
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
446 446
                     'type' => 'header',
447 447
                 ),
448 448
                 'email_header_image' => array(
449 449
                     'id'   => 'email_header_image',
450
-                    'name' => __( 'Header Image', 'invoicing' ),
451
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
450
+                    'name' => __('Header Image', 'invoicing'),
451
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
452 452
                     'std' => '',
453 453
                     'type' => 'text',
454 454
                 ),
455 455
                 'email_footer_text' => array(
456 456
                     'id'   => 'email_footer_text',
457
-                    'name' => __( 'Footer Text', 'invoicing' ),
458
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
459
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ),
457
+                    'name' => __('Footer Text', 'invoicing'),
458
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
459
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'),
460 460
                     'type' => 'textarea',
461 461
                     'class' => 'regular-text',
462 462
                     'rows' => 2,
@@ -464,29 +464,29 @@  discard block
 block discarded – undo
464 464
                 ),
465 465
                 'email_base_color' => array(
466 466
                     'id'   => 'email_base_color',
467
-                    'name' => __( 'Base Color', 'invoicing' ),
468
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
467
+                    'name' => __('Base Color', 'invoicing'),
468
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
469 469
                     'std' => '#557da2',
470 470
                     'type' => 'color',
471 471
                 ),
472 472
                 'email_background_color' => array(
473 473
                     'id'   => 'email_background_color',
474
-                    'name' => __( 'Background Color', 'invoicing' ),
475
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
474
+                    'name' => __('Background Color', 'invoicing'),
475
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
476 476
                     'std' => '#f5f5f5',
477 477
                     'type' => 'color',
478 478
                 ),
479 479
                 'email_body_background_color' => array(
480 480
                     'id'   => 'email_body_background_color',
481
-                    'name' => __( 'Body Background Color', 'invoicing' ),
482
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
481
+                    'name' => __('Body Background Color', 'invoicing'),
482
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
483 483
                     'std' => '#fdfdfd',
484 484
                     'type' => 'color',
485 485
                 ),
486 486
                 'email_text_color' => array(
487 487
                     'id'   => 'email_text_color',
488
-                    'name' => __( 'Body Text Color', 'invoicing' ),
489
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
488
+                    'name' => __('Body Text Color', 'invoicing'),
489
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
490 490
                     'std' => '#505050',
491 491
                     'type' => 'color',
492 492
                 ),
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
     ),
502 502
 
503 503
     // Integrations.
504
-    'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ),
504
+    'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'),
505 505
 
506 506
     /** Privacy Settings */
507 507
     'privacy' => apply_filters('wpinv_settings_privacy',
@@ -509,17 +509,17 @@  discard block
 block discarded – undo
509 509
             'main' => array(
510 510
                 'invoicing_privacy_policy_settings' => array(
511 511
                     'id'   => 'invoicing_privacy_policy_settings',
512
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
512
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
513 513
                     'type' => 'header',
514 514
                 ),
515 515
                 'privacy_page' => array(
516 516
                     'id'          => 'privacy_page',
517
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
518
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
517
+                    'name'        => __('Privacy Page', 'invoicing'),
518
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
519 519
                     'type'        => 'select',
520
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
520
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
521 521
                     'class'       => 'wpi_select2',
522
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
522
+                    'placeholder' => __('Select a page', 'invoicing'),
523 523
                 ),
524 524
             ),
525 525
         )
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
             'main' => array(
531 531
                 'invoice_number_format_settings' => array(
532 532
                     'id'   => 'invoice_number_format_settings',
533
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
533
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
534 534
                     'type' => 'header',
535 535
                 ),
536 536
                 'sequential_invoice_number' => array(
537 537
                     'id'   => 'sequential_invoice_number',
538
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
539
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
538
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
539
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
540 540
                     'type' => 'checkbox',
541 541
                 ),
542 542
                 'invoice_sequence_start' => array(
543 543
                     'id'   => 'invoice_sequence_start',
544
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
545
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
544
+                    'name' => __('Sequential Starting Number', 'invoicing'),
545
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
546 546
                     'type' => 'number',
547 547
                     'size' => 'small',
548 548
                     'std'  => '1',
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
                 ),
551 551
                 'invoice_number_padd' => array(
552 552
                     'id'      => 'invoice_number_padd',
553
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
554
-                    'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
553
+                    'name'    => __('Minimum Digits', 'invoicing'),
554
+                    'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
555 555
                     'type'    => 'select',
556 556
                     'options' => $invoice_number_padd_options,
557 557
                     'std'     => 5,
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
                 ),
560 560
                 'invoice_number_prefix' => array(
561 561
                     'id' => 'invoice_number_prefix',
562
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
563
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
562
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
563
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
564 564
                     'type' => 'text',
565 565
                     'size' => 'regular',
566 566
                     'std' => 'INV-',
@@ -568,41 +568,41 @@  discard block
 block discarded – undo
568 568
                 ),
569 569
                 'invoice_number_postfix' => array(
570 570
                     'id' => 'invoice_number_postfix',
571
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
572
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
571
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
572
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
573 573
                     'type' => 'text',
574 574
                     'size' => 'regular',
575 575
                     'std' => ''
576 576
                 ),
577 577
                 'checkout_settings' => array(
578 578
                     'id'   => 'checkout_settings',
579
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
579
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
580 580
                     'type' => 'header',
581 581
                 ),
582 582
                 'login_to_checkout' => array(
583 583
                     'id'   => 'login_to_checkout',
584
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
585
-                    'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
584
+                    'name' => __('Require Login To Checkout', 'invoicing'),
585
+                    'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
586 586
                     'type' => 'checkbox',
587 587
                 ),
588 588
 
589 589
                 'maxmind_license_key' => array(
590 590
                     'id'   => 'maxmind_license_key',
591
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
591
+                    'name' => __('MaxMind License Key', 'invoicing'),
592 592
                     'type' => 'text',
593 593
                     'size' => 'regular',
594
-                    'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>',
594
+                    'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>',
595 595
                 ),
596 596
 
597 597
                 'uninstall_settings' => array(
598 598
                     'id'   => 'uninstall_settings',
599
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
599
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
600 600
                     'type' => 'header',
601 601
                 ),
602 602
                 'remove_data_on_unistall' => array(
603 603
                     'id'   => 'remove_data_on_unistall',
604
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
605
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
604
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
605
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
606 606
                     'type' => 'checkbox',
607 607
                     'std'  => ''
608 608
                 ),
@@ -611,13 +611,13 @@  discard block
 block discarded – undo
611 611
             'custom-css' => array(
612 612
                 'css_settings' => array(
613 613
                     'id'   => 'css_settings',
614
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
614
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
615 615
                     'type' => 'header',
616 616
                 ),
617 617
                 'template_custom_css' => array(
618 618
                     'id' => 'template_custom_css',
619
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
620
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
619
+                    'name' => __('Invoice Template CSS', 'invoicing'),
620
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
621 621
                     'type' => 'textarea',
622 622
                     'class'=> 'regular-text',
623 623
                     'rows' => 10,
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
             'main' => array(
632 632
                 'tool_settings' => array(
633 633
                     'id'   => 'tool_settings',
634
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
635
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
634
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
635
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
636 636
                     'type' => 'tools',
637 637
                 ),
638 638
             ),
Please login to merge, or discard this patch.
includes/class-getpaid-post-types.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -15,319 +15,319 @@
 block discarded – undo
15 15
 class GetPaid_Post_Types {
16 16
 
17 17
     /**
18
-	 * Hook in methods.
19
-	 */
20
-	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
-	}
18
+     * Hook in methods.
19
+     */
20
+    public function __construct() {
21
+        add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
+        add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
+        add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
+        add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
+    }
26 26
 
27
-	/**
28
-	 * Register core post types.
29
-	 */
30
-	public static function register_post_types() {
27
+    /**
28
+     * Register core post types.
29
+     */
30
+    public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
-			return;
34
-		}
32
+        if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
+            return;
34
+        }
35 35
 
36
-		// Fires before registering post types.
37
-		do_action( 'getpaid_register_post_types' );
36
+        // Fires before registering post types.
37
+        do_action( 'getpaid_register_post_types' );
38 38
 
39
-		// Register item post type.
40
-		register_post_type(
41
-			'wpi_item',
42
-			apply_filters(
43
-				'wpinv_register_post_type_invoice_item',
44
-				array(
45
-					'labels'             => array(
46
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
-						'new_item'           => __( 'New Item', 'invoicing' ),
53
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
-						'view_item'          => __( 'View Item', 'invoicing' ),
55
-						'all_items'          => __( 'Items', 'invoicing' ),
56
-						'search_items'       => __( 'Search items', 'invoicing' ),
57
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
-						'not_found'          => __( 'No items found.', 'invoicing' ),
59
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
60
-					),
61
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
62
-					'public'                => false,
63
-					'has_archive'           => false,
64
-					'_builtin'              => false,
65
-					'show_ui'               => true,
66
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67
-					'show_in_nav_menus'     => false,
68
-					'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
69
-					'rewrite'               => false,
70
-					'query_var'             => false,
71
-					'map_meta_cap'          => true,
72
-					'show_in_admin_bar'     => true,
73
-					'can_export'            => true,
74
-				)
75
-			)
76
-		);
39
+        // Register item post type.
40
+        register_post_type(
41
+            'wpi_item',
42
+            apply_filters(
43
+                'wpinv_register_post_type_invoice_item',
44
+                array(
45
+                    'labels'             => array(
46
+                        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
+                        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
+                        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
+                        'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
+                        'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
+                        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
+                        'new_item'           => __( 'New Item', 'invoicing' ),
53
+                        'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
+                        'view_item'          => __( 'View Item', 'invoicing' ),
55
+                        'all_items'          => __( 'Items', 'invoicing' ),
56
+                        'search_items'       => __( 'Search items', 'invoicing' ),
57
+                        'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
+                        'not_found'          => __( 'No items found.', 'invoicing' ),
59
+                        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
60
+                    ),
61
+                    'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
62
+                    'public'                => false,
63
+                    'has_archive'           => false,
64
+                    '_builtin'              => false,
65
+                    'show_ui'               => true,
66
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67
+                    'show_in_nav_menus'     => false,
68
+                    'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
69
+                    'rewrite'               => false,
70
+                    'query_var'             => false,
71
+                    'map_meta_cap'          => true,
72
+                    'show_in_admin_bar'     => true,
73
+                    'can_export'            => true,
74
+                )
75
+            )
76
+        );
77 77
 
78
-		// Register payment form post type.
79
-		register_post_type(
80
-			'wpi_payment_form',
81
-			apply_filters(
82
-				'wpinv_register_post_type_payment_form',
83
-				array(
84
-					'labels'             => array(
85
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
86
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
87
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
88
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
89
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
90
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
91
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
92
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
93
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
94
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
95
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
96
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
97
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
98
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
99
-					),
100
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
101
-					'public'             => false,
102
-					'show_ui'            => true,
103
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
104
-					'show_in_nav_menus'  => false,
105
-					'query_var'          => false,
106
-					'rewrite'            => true,
107
-					'map_meta_cap'       => true,
108
-					'has_archive'        => false,
109
-					'hierarchical'       => false,
110
-					'menu_position'      => null,
111
-					'supports'           => array( 'title' ),
112
-					'menu_icon'          => 'dashicons-media-form',
113
-				)
114
-			)
115
-		);
78
+        // Register payment form post type.
79
+        register_post_type(
80
+            'wpi_payment_form',
81
+            apply_filters(
82
+                'wpinv_register_post_type_payment_form',
83
+                array(
84
+                    'labels'             => array(
85
+                        'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
86
+                        'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
87
+                        'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
88
+                        'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
89
+                        'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
90
+                        'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
91
+                        'new_item'           => __( 'New Payment Form', 'invoicing' ),
92
+                        'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
93
+                        'view_item'          => __( 'View Payment Form', 'invoicing' ),
94
+                        'all_items'          => __( 'Payment Forms', 'invoicing' ),
95
+                        'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
96
+                        'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
97
+                        'not_found'          => __( 'No payment forms found.', 'invoicing' ),
98
+                        'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
99
+                    ),
100
+                    'description'        => __( 'Add new payment forms.', 'invoicing' ),
101
+                    'public'             => false,
102
+                    'show_ui'            => true,
103
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
104
+                    'show_in_nav_menus'  => false,
105
+                    'query_var'          => false,
106
+                    'rewrite'            => true,
107
+                    'map_meta_cap'       => true,
108
+                    'has_archive'        => false,
109
+                    'hierarchical'       => false,
110
+                    'menu_position'      => null,
111
+                    'supports'           => array( 'title' ),
112
+                    'menu_icon'          => 'dashicons-media-form',
113
+                )
114
+            )
115
+        );
116 116
 
117
-		// Register invoice post type.
118
-		register_post_type(
119
-			'wpi_invoice',
120
-			apply_filters(
121
-				'wpinv_register_post_type_invoice',
122
-				array(
123
-					'labels'                 => array(
124
-						'name'                  => __( 'Invoices', 'invoicing' ),
125
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
126
-						'all_items'             => __( 'Invoices', 'invoicing' ),
127
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
128
-						'add_new'               => __( 'Add New', 'invoicing' ),
129
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
130
-						'edit'                  => __( 'Edit', 'invoicing' ),
131
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
132
-						'new_item'              => __( 'New invoice', 'invoicing' ),
133
-						'view_item'             => __( 'View invoice', 'invoicing' ),
134
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
135
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
136
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
137
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
138
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
139
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
140
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
141
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
142
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
143
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
144
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
145
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
146
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
147
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
148
-					),
149
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
150
-					'public'                => true,
151
-					'has_archive'           => false,
152
-					'publicly_queryable'    => true,
153
-        			'exclude_from_search'   => true,
154
-        			'show_ui'               => true,
155
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
156
-					'show_in_nav_menus'     => false,
157
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
158
-					'rewrite'               => array(
159
-						'slug'              => 'invoice',
160
-						'with_front'        => false,
161
-					),
162
-					'query_var'             => false,
163
-					'map_meta_cap'          => true,
164
-					'show_in_admin_bar'     => true,
165
-					'can_export'            => true,
166
-					'hierarchical'          => false,
167
-					'menu_position'         => null,
168
-					'menu_icon'             => 'dashicons-media-spreadsheet',
169
-				)
170
-			)
171
-		);
117
+        // Register invoice post type.
118
+        register_post_type(
119
+            'wpi_invoice',
120
+            apply_filters(
121
+                'wpinv_register_post_type_invoice',
122
+                array(
123
+                    'labels'                 => array(
124
+                        'name'                  => __( 'Invoices', 'invoicing' ),
125
+                        'singular_name'         => __( 'Invoice', 'invoicing' ),
126
+                        'all_items'             => __( 'Invoices', 'invoicing' ),
127
+                        'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
128
+                        'add_new'               => __( 'Add New', 'invoicing' ),
129
+                        'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
130
+                        'edit'                  => __( 'Edit', 'invoicing' ),
131
+                        'edit_item'             => __( 'Edit invoice', 'invoicing' ),
132
+                        'new_item'              => __( 'New invoice', 'invoicing' ),
133
+                        'view_item'             => __( 'View invoice', 'invoicing' ),
134
+                        'view_items'            => __( 'View Invoices', 'invoicing' ),
135
+                        'search_items'          => __( 'Search invoices', 'invoicing' ),
136
+                        'not_found'             => __( 'No invoices found', 'invoicing' ),
137
+                        'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
138
+                        'parent'                => __( 'Parent invoice', 'invoicing' ),
139
+                        'featured_image'        => __( 'Invoice image', 'invoicing' ),
140
+                        'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
141
+                        'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
142
+                        'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
143
+                        'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
144
+                        'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
145
+                        'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
146
+                        'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
147
+                        'items_list'            => __( 'Invoices list', 'invoicing' ),
148
+                    ),
149
+                    'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
150
+                    'public'                => true,
151
+                    'has_archive'           => false,
152
+                    'publicly_queryable'    => true,
153
+                    'exclude_from_search'   => true,
154
+                    'show_ui'               => true,
155
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
156
+                    'show_in_nav_menus'     => false,
157
+                    'supports'              => array( 'title', 'author', 'excerpt'  ),
158
+                    'rewrite'               => array(
159
+                        'slug'              => 'invoice',
160
+                        'with_front'        => false,
161
+                    ),
162
+                    'query_var'             => false,
163
+                    'map_meta_cap'          => true,
164
+                    'show_in_admin_bar'     => true,
165
+                    'can_export'            => true,
166
+                    'hierarchical'          => false,
167
+                    'menu_position'         => null,
168
+                    'menu_icon'             => 'dashicons-media-spreadsheet',
169
+                )
170
+            )
171
+        );
172 172
 
173
-		// Register discount post type.
174
-		register_post_type(
175
-			'wpi_discount',
176
-			apply_filters(
177
-				'wpinv_register_post_type_discount',
178
-				array(
179
-					'labels'                 => array(
180
-						'name'                  => __( 'Discounts', 'invoicing' ),
181
-						'singular_name'         => __( 'Discount', 'invoicing' ),
182
-						'all_items'             => __( 'Discounts', 'invoicing' ),
183
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
184
-						'add_new'               => __( 'Add New', 'invoicing' ),
185
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
186
-						'edit'                  => __( 'Edit', 'invoicing' ),
187
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
188
-						'new_item'              => __( 'New discount', 'invoicing' ),
189
-						'view_item'             => __( 'View discount', 'invoicing' ),
190
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
191
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
192
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
193
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
194
-						'parent'                => __( 'Parent discount', 'invoicing' ),
195
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
196
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
197
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
198
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
199
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
200
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
201
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
202
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
203
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
204
-					),
205
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
206
-					'public'             => false,
207
-					'can_export'         => true,
208
-					'_builtin'           => false,
209
-					'publicly_queryable' => false,
210
-					'exclude_from_search'=> true,
211
-					'show_ui'            => true,
212
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
213
-					'query_var'          => false,
214
-					'rewrite'            => false,
215
-					'map_meta_cap'       => true,
216
-					'has_archive'        => false,
217
-					'hierarchical'       => false,
218
-					'supports'           => array( 'title', 'excerpt' ),
219
-					'show_in_nav_menus'  => false,
220
-					'show_in_admin_bar'  => true,
221
-					'menu_position'      => null,
222
-				)
223
-			)
224
-		);
173
+        // Register discount post type.
174
+        register_post_type(
175
+            'wpi_discount',
176
+            apply_filters(
177
+                'wpinv_register_post_type_discount',
178
+                array(
179
+                    'labels'                 => array(
180
+                        'name'                  => __( 'Discounts', 'invoicing' ),
181
+                        'singular_name'         => __( 'Discount', 'invoicing' ),
182
+                        'all_items'             => __( 'Discounts', 'invoicing' ),
183
+                        'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
184
+                        'add_new'               => __( 'Add New', 'invoicing' ),
185
+                        'add_new_item'          => __( 'Add new discount', 'invoicing' ),
186
+                        'edit'                  => __( 'Edit', 'invoicing' ),
187
+                        'edit_item'             => __( 'Edit discount', 'invoicing' ),
188
+                        'new_item'              => __( 'New discount', 'invoicing' ),
189
+                        'view_item'             => __( 'View discount', 'invoicing' ),
190
+                        'view_items'            => __( 'View Discounts', 'invoicing' ),
191
+                        'search_items'          => __( 'Search discounts', 'invoicing' ),
192
+                        'not_found'             => __( 'No discounts found', 'invoicing' ),
193
+                        'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
194
+                        'parent'                => __( 'Parent discount', 'invoicing' ),
195
+                        'featured_image'        => __( 'Discount image', 'invoicing' ),
196
+                        'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
197
+                        'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
198
+                        'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
199
+                        'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
200
+                        'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
201
+                        'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
202
+                        'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
203
+                        'items_list'            => __( 'Discounts list', 'invoicing' ),
204
+                    ),
205
+                    'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
206
+                    'public'             => false,
207
+                    'can_export'         => true,
208
+                    '_builtin'           => false,
209
+                    'publicly_queryable' => false,
210
+                    'exclude_from_search'=> true,
211
+                    'show_ui'            => true,
212
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
213
+                    'query_var'          => false,
214
+                    'rewrite'            => false,
215
+                    'map_meta_cap'       => true,
216
+                    'has_archive'        => false,
217
+                    'hierarchical'       => false,
218
+                    'supports'           => array( 'title', 'excerpt' ),
219
+                    'show_in_nav_menus'  => false,
220
+                    'show_in_admin_bar'  => true,
221
+                    'menu_position'      => null,
222
+                )
223
+            )
224
+        );
225 225
 
226
-		do_action( 'getpaid_after_register_post_types' );
227
-	}
226
+        do_action( 'getpaid_after_register_post_types' );
227
+    }
228 228
 
229
-	/**
230
-	 * Register our custom post statuses.
231
-	 */
232
-	public static function register_post_status() {
229
+    /**
230
+     * Register our custom post statuses.
231
+     */
232
+    public static function register_post_status() {
233 233
 
234
-		$invoice_statuses = apply_filters(
235
-			'getpaid_register_invoice_post_statuses',
236
-			array(
234
+        $invoice_statuses = apply_filters(
235
+            'getpaid_register_invoice_post_statuses',
236
+            array(
237 237
 
238
-				'wpi-pending' => array(
239
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
240
-        			'public'                    => true,
241
-        			'exclude_from_search'       => true,
242
-        			'show_in_admin_all_list'    => true,
243
-					'show_in_admin_status_list' => true,
244
-					/* translators: %s: number of invoices */
245
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
246
-				),
238
+                'wpi-pending' => array(
239
+                    'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
240
+                    'public'                    => true,
241
+                    'exclude_from_search'       => true,
242
+                    'show_in_admin_all_list'    => true,
243
+                    'show_in_admin_status_list' => true,
244
+                    /* translators: %s: number of invoices */
245
+                    'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
246
+                ),
247 247
 
248
-				'wpi-processing' => array(
249
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
250
-        			'public'                    => true,
251
-        			'exclude_from_search'       => true,
252
-        			'show_in_admin_all_list'    => true,
253
-					'show_in_admin_status_list' => true,
254
-					/* translators: %s: number of invoices */
255
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
256
-				),
248
+                'wpi-processing' => array(
249
+                    'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
250
+                    'public'                    => true,
251
+                    'exclude_from_search'       => true,
252
+                    'show_in_admin_all_list'    => true,
253
+                    'show_in_admin_status_list' => true,
254
+                    /* translators: %s: number of invoices */
255
+                    'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
256
+                ),
257 257
 
258
-				'wpi-onhold' => array(
259
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
260
-        			'public'                    => true,
261
-        			'exclude_from_search'       => true,
262
-        			'show_in_admin_all_list'    => true,
263
-					'show_in_admin_status_list' => true,
264
-					/* translators: %s: number of invoices */
265
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
266
-				),
258
+                'wpi-onhold' => array(
259
+                    'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
260
+                    'public'                    => true,
261
+                    'exclude_from_search'       => true,
262
+                    'show_in_admin_all_list'    => true,
263
+                    'show_in_admin_status_list' => true,
264
+                    /* translators: %s: number of invoices */
265
+                    'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
266
+                ),
267 267
 
268
-				'wpi-cancelled' => array(
269
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
270
-        			'public'                    => true,
271
-        			'exclude_from_search'       => true,
272
-        			'show_in_admin_all_list'    => true,
273
-					'show_in_admin_status_list' => true,
274
-					/* translators: %s: number of invoices */
275
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
276
-				),
268
+                'wpi-cancelled' => array(
269
+                    'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
270
+                    'public'                    => true,
271
+                    'exclude_from_search'       => true,
272
+                    'show_in_admin_all_list'    => true,
273
+                    'show_in_admin_status_list' => true,
274
+                    /* translators: %s: number of invoices */
275
+                    'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
276
+                ),
277 277
 
278
-				'wpi-refunded' => array(
279
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
280
-        			'public'                    => true,
281
-        			'exclude_from_search'       => true,
282
-        			'show_in_admin_all_list'    => true,
283
-					'show_in_admin_status_list' => true,
284
-					/* translators: %s: number of invoices */
285
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
286
-				),
278
+                'wpi-refunded' => array(
279
+                    'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
280
+                    'public'                    => true,
281
+                    'exclude_from_search'       => true,
282
+                    'show_in_admin_all_list'    => true,
283
+                    'show_in_admin_status_list' => true,
284
+                    /* translators: %s: number of invoices */
285
+                    'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
286
+                ),
287 287
 
288
-				'wpi-failed' => array(
289
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
290
-        			'public'                    => true,
291
-        			'exclude_from_search'       => true,
292
-        			'show_in_admin_all_list'    => true,
293
-					'show_in_admin_status_list' => true,
294
-					/* translators: %s: number of invoices */
295
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
296
-				),
288
+                'wpi-failed' => array(
289
+                    'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
290
+                    'public'                    => true,
291
+                    'exclude_from_search'       => true,
292
+                    'show_in_admin_all_list'    => true,
293
+                    'show_in_admin_status_list' => true,
294
+                    /* translators: %s: number of invoices */
295
+                    'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
296
+                ),
297 297
 
298
-				'wpi-renewal' => array(
299
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
300
-        			'public'                    => true,
301
-        			'exclude_from_search'       => true,
302
-        			'show_in_admin_all_list'    => true,
303
-					'show_in_admin_status_list' => true,
304
-					/* translators: %s: number of invoices */
305
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
306
-				)
307
-			)
308
-		);
298
+                'wpi-renewal' => array(
299
+                    'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
300
+                    'public'                    => true,
301
+                    'exclude_from_search'       => true,
302
+                    'show_in_admin_all_list'    => true,
303
+                    'show_in_admin_status_list' => true,
304
+                    /* translators: %s: number of invoices */
305
+                    'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
306
+                )
307
+            )
308
+        );
309 309
 
310
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
-			register_post_status( $invoice_statuse, $args );
312
-		}
313
-	}
310
+        foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
+            register_post_status( $invoice_statuse, $args );
312
+        }
313
+    }
314 314
 
315
-	/**
316
-	 * Flush rewrite rules.
317
-	 */
318
-	public static function flush_rewrite_rules() {
319
-		flush_rewrite_rules();
320
-	}
315
+    /**
316
+     * Flush rewrite rules.
317
+     */
318
+    public static function flush_rewrite_rules() {
319
+        flush_rewrite_rules();
320
+    }
321 321
 
322
-	/**
323
-	 * Flush rules to prevent 404.
324
-	 *
325
-	 */
326
-	public static function maybe_flush_rewrite_rules() {
327
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
329
-			self::flush_rewrite_rules();
330
-		}
331
-	}
322
+    /**
323
+     * Flush rules to prevent 404.
324
+     *
325
+     */
326
+    public static function maybe_flush_rewrite_rules() {
327
+        if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
+            update_option( 'getpaid_flushed_rewrite_rules', '1' );
329
+            self::flush_rewrite_rules();
330
+        }
331
+    }
332 332
 
333 333
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Post types Class
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	 * Hook in methods.
19 19
 	 */
20 20
 	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
21
+		add_action('init', array(__CLASS__, 'register_post_types'), 1);
22
+		add_action('init', array(__CLASS__, 'register_post_status'), 4);
23
+		add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules'));
24
+		add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules'));
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
32
+		if (!is_blog_installed() || post_type_exists('wpi_item')) {
33 33
 			return;
34 34
 		}
35 35
 
36 36
 		// Fires before registering post types.
37
-		do_action( 'getpaid_register_post_types' );
37
+		do_action('getpaid_register_post_types');
38 38
 
39 39
 		// Register item post type.
40 40
 		register_post_type(
@@ -43,29 +43,29 @@  discard block
 block discarded – undo
43 43
 				'wpinv_register_post_type_invoice_item',
44 44
 				array(
45 45
 					'labels'             => array(
46
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
-						'new_item'           => __( 'New Item', 'invoicing' ),
53
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
-						'view_item'          => __( 'View Item', 'invoicing' ),
55
-						'all_items'          => __( 'Items', 'invoicing' ),
56
-						'search_items'       => __( 'Search items', 'invoicing' ),
57
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
-						'not_found'          => __( 'No items found.', 'invoicing' ),
59
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
46
+						'name'               => _x('Items', 'post type general name', 'invoicing'),
47
+						'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
48
+						'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
49
+						'name_admin_bar'     => _x('Item', 'add new on admin bar', 'invoicing'),
50
+						'add_new'            => _x('Add New', 'Item', 'invoicing'),
51
+						'add_new_item'       => __('Add New Item', 'invoicing'),
52
+						'new_item'           => __('New Item', 'invoicing'),
53
+						'edit_item'          => __('Edit Item', 'invoicing'),
54
+						'view_item'          => __('View Item', 'invoicing'),
55
+						'all_items'          => __('Items', 'invoicing'),
56
+						'search_items'       => __('Search items', 'invoicing'),
57
+						'parent_item_colon'  => __('Parent item:', 'invoicing'),
58
+						'not_found'          => __('No items found.', 'invoicing'),
59
+						'not_found_in_trash' => __('No items found in trash.', 'invoicing')
60 60
 					),
61
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
61
+					'description'           => __('This is where you can add new invoice items.', 'invoicing'),
62 62
 					'public'                => false,
63 63
 					'has_archive'           => false,
64 64
 					'_builtin'              => false,
65 65
 					'show_ui'               => true,
66 66
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67 67
 					'show_in_nav_menus'     => false,
68
-					'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
68
+					'supports'              => array('title', 'excerpt', 'thumbnail'),
69 69
 					'rewrite'               => false,
70 70
 					'query_var'             => false,
71 71
 					'map_meta_cap'          => true,
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
 				'wpinv_register_post_type_payment_form',
83 83
 				array(
84 84
 					'labels'             => array(
85
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
86
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
87
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
88
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
89
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
90
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
91
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
92
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
93
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
94
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
95
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
96
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
97
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
98
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
85
+						'name'               => _x('Payment Forms', 'post type general name', 'invoicing'),
86
+						'singular_name'      => _x('Payment Form', 'post type singular name', 'invoicing'),
87
+						'menu_name'          => _x('Payment Forms', 'admin menu', 'invoicing'),
88
+						'name_admin_bar'     => _x('Payment Form', 'add new on admin bar', 'invoicing'),
89
+						'add_new'            => _x('Add New', 'Payment Form', 'invoicing'),
90
+						'add_new_item'       => __('Add New Payment Form', 'invoicing'),
91
+						'new_item'           => __('New Payment Form', 'invoicing'),
92
+						'edit_item'          => __('Edit Payment Form', 'invoicing'),
93
+						'view_item'          => __('View Payment Form', 'invoicing'),
94
+						'all_items'          => __('Payment Forms', 'invoicing'),
95
+						'search_items'       => __('Search Payment Forms', 'invoicing'),
96
+						'parent_item_colon'  => __('Parent Payment Forms:', 'invoicing'),
97
+						'not_found'          => __('No payment forms found.', 'invoicing'),
98
+						'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing')
99 99
 					),
100
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
100
+					'description'        => __('Add new payment forms.', 'invoicing'),
101 101
 					'public'             => false,
102 102
 					'show_ui'            => true,
103 103
 					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 					'has_archive'        => false,
109 109
 					'hierarchical'       => false,
110 110
 					'menu_position'      => null,
111
-					'supports'           => array( 'title' ),
111
+					'supports'           => array('title'),
112 112
 					'menu_icon'          => 'dashicons-media-form',
113 113
 				)
114 114
 			)
@@ -121,32 +121,32 @@  discard block
 block discarded – undo
121 121
 				'wpinv_register_post_type_invoice',
122 122
 				array(
123 123
 					'labels'                 => array(
124
-						'name'                  => __( 'Invoices', 'invoicing' ),
125
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
126
-						'all_items'             => __( 'Invoices', 'invoicing' ),
127
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
128
-						'add_new'               => __( 'Add New', 'invoicing' ),
129
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
130
-						'edit'                  => __( 'Edit', 'invoicing' ),
131
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
132
-						'new_item'              => __( 'New invoice', 'invoicing' ),
133
-						'view_item'             => __( 'View invoice', 'invoicing' ),
134
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
135
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
136
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
137
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
138
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
139
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
140
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
141
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
142
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
143
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
144
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
145
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
146
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
147
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
124
+						'name'                  => __('Invoices', 'invoicing'),
125
+						'singular_name'         => __('Invoice', 'invoicing'),
126
+						'all_items'             => __('Invoices', 'invoicing'),
127
+						'menu_name'             => _x('Invoices', 'Admin menu name', 'invoicing'),
128
+						'add_new'               => __('Add New', 'invoicing'),
129
+						'add_new_item'          => __('Add new invoice', 'invoicing'),
130
+						'edit'                  => __('Edit', 'invoicing'),
131
+						'edit_item'             => __('Edit invoice', 'invoicing'),
132
+						'new_item'              => __('New invoice', 'invoicing'),
133
+						'view_item'             => __('View invoice', 'invoicing'),
134
+						'view_items'            => __('View Invoices', 'invoicing'),
135
+						'search_items'          => __('Search invoices', 'invoicing'),
136
+						'not_found'             => __('No invoices found', 'invoicing'),
137
+						'not_found_in_trash'    => __('No invoices found in trash', 'invoicing'),
138
+						'parent'                => __('Parent invoice', 'invoicing'),
139
+						'featured_image'        => __('Invoice image', 'invoicing'),
140
+						'set_featured_image'    => __('Set invoice image', 'invoicing'),
141
+						'remove_featured_image' => __('Remove invoice image', 'invoicing'),
142
+						'use_featured_image'    => __('Use as invoice image', 'invoicing'),
143
+						'insert_into_item'      => __('Insert into invoice', 'invoicing'),
144
+						'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'),
145
+						'filter_items_list'     => __('Filter invoices', 'invoicing'),
146
+						'items_list_navigation' => __('Invoices navigation', 'invoicing'),
147
+						'items_list'            => __('Invoices list', 'invoicing'),
148 148
 					),
149
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
149
+					'description'           => __('This is where invoices are stored.', 'invoicing'),
150 150
 					'public'                => true,
151 151
 					'has_archive'           => false,
152 152
 					'publicly_queryable'    => true,
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         			'show_ui'               => true,
155 155
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
156 156
 					'show_in_nav_menus'     => false,
157
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
157
+					'supports'              => array('title', 'author', 'excerpt'),
158 158
 					'rewrite'               => array(
159 159
 						'slug'              => 'invoice',
160 160
 						'with_front'        => false,
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
 				'wpinv_register_post_type_discount',
178 178
 				array(
179 179
 					'labels'                 => array(
180
-						'name'                  => __( 'Discounts', 'invoicing' ),
181
-						'singular_name'         => __( 'Discount', 'invoicing' ),
182
-						'all_items'             => __( 'Discounts', 'invoicing' ),
183
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
184
-						'add_new'               => __( 'Add New', 'invoicing' ),
185
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
186
-						'edit'                  => __( 'Edit', 'invoicing' ),
187
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
188
-						'new_item'              => __( 'New discount', 'invoicing' ),
189
-						'view_item'             => __( 'View discount', 'invoicing' ),
190
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
191
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
192
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
193
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
194
-						'parent'                => __( 'Parent discount', 'invoicing' ),
195
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
196
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
197
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
198
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
199
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
200
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
201
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
202
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
203
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
180
+						'name'                  => __('Discounts', 'invoicing'),
181
+						'singular_name'         => __('Discount', 'invoicing'),
182
+						'all_items'             => __('Discounts', 'invoicing'),
183
+						'menu_name'             => _x('Discounts', 'Admin menu name', 'invoicing'),
184
+						'add_new'               => __('Add New', 'invoicing'),
185
+						'add_new_item'          => __('Add new discount', 'invoicing'),
186
+						'edit'                  => __('Edit', 'invoicing'),
187
+						'edit_item'             => __('Edit discount', 'invoicing'),
188
+						'new_item'              => __('New discount', 'invoicing'),
189
+						'view_item'             => __('View discount', 'invoicing'),
190
+						'view_items'            => __('View Discounts', 'invoicing'),
191
+						'search_items'          => __('Search discounts', 'invoicing'),
192
+						'not_found'             => __('No discounts found', 'invoicing'),
193
+						'not_found_in_trash'    => __('No discounts found in trash', 'invoicing'),
194
+						'parent'                => __('Parent discount', 'invoicing'),
195
+						'featured_image'        => __('Discount image', 'invoicing'),
196
+						'set_featured_image'    => __('Set discount image', 'invoicing'),
197
+						'remove_featured_image' => __('Remove discount image', 'invoicing'),
198
+						'use_featured_image'    => __('Use as discount image', 'invoicing'),
199
+						'insert_into_item'      => __('Insert into discount', 'invoicing'),
200
+						'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'),
201
+						'filter_items_list'     => __('Filter discounts', 'invoicing'),
202
+						'items_list_navigation' => __('Discount navigation', 'invoicing'),
203
+						'items_list'            => __('Discounts list', 'invoicing'),
204 204
 					),
205
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
205
+					'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
206 206
 					'public'             => false,
207 207
 					'can_export'         => true,
208 208
 					'_builtin'           => false,
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 					'map_meta_cap'       => true,
216 216
 					'has_archive'        => false,
217 217
 					'hierarchical'       => false,
218
-					'supports'           => array( 'title', 'excerpt' ),
218
+					'supports'           => array('title', 'excerpt'),
219 219
 					'show_in_nav_menus'  => false,
220 220
 					'show_in_admin_bar'  => true,
221 221
 					'menu_position'      => null,
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			)
224 224
 		);
225 225
 
226
-		do_action( 'getpaid_after_register_post_types' );
226
+		do_action('getpaid_after_register_post_types');
227 227
 	}
228 228
 
229 229
 	/**
@@ -236,79 +236,79 @@  discard block
 block discarded – undo
236 236
 			array(
237 237
 
238 238
 				'wpi-pending' => array(
239
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
239
+					'label'                     => _x('Pending Payment', 'Invoice status', 'invoicing'),
240 240
         			'public'                    => true,
241 241
         			'exclude_from_search'       => true,
242 242
         			'show_in_admin_all_list'    => true,
243 243
 					'show_in_admin_status_list' => true,
244 244
 					/* translators: %s: number of invoices */
245
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
245
+        			'label_count'               => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing')
246 246
 				),
247 247
 
248 248
 				'wpi-processing' => array(
249
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
249
+					'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
250 250
         			'public'                    => true,
251 251
         			'exclude_from_search'       => true,
252 252
         			'show_in_admin_all_list'    => true,
253 253
 					'show_in_admin_status_list' => true,
254 254
 					/* translators: %s: number of invoices */
255
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
255
+        			'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
256 256
 				),
257 257
 
258 258
 				'wpi-onhold' => array(
259
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
259
+					'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
260 260
         			'public'                    => true,
261 261
         			'exclude_from_search'       => true,
262 262
         			'show_in_admin_all_list'    => true,
263 263
 					'show_in_admin_status_list' => true,
264 264
 					/* translators: %s: number of invoices */
265
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
265
+        			'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
266 266
 				),
267 267
 
268 268
 				'wpi-cancelled' => array(
269
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
269
+					'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
270 270
         			'public'                    => true,
271 271
         			'exclude_from_search'       => true,
272 272
         			'show_in_admin_all_list'    => true,
273 273
 					'show_in_admin_status_list' => true,
274 274
 					/* translators: %s: number of invoices */
275
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
275
+        			'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
276 276
 				),
277 277
 
278 278
 				'wpi-refunded' => array(
279
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
279
+					'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
280 280
         			'public'                    => true,
281 281
         			'exclude_from_search'       => true,
282 282
         			'show_in_admin_all_list'    => true,
283 283
 					'show_in_admin_status_list' => true,
284 284
 					/* translators: %s: number of invoices */
285
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
285
+        			'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
286 286
 				),
287 287
 
288 288
 				'wpi-failed' => array(
289
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
289
+					'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
290 290
         			'public'                    => true,
291 291
         			'exclude_from_search'       => true,
292 292
         			'show_in_admin_all_list'    => true,
293 293
 					'show_in_admin_status_list' => true,
294 294
 					/* translators: %s: number of invoices */
295
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
295
+        			'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
296 296
 				),
297 297
 
298 298
 				'wpi-renewal' => array(
299
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
299
+					'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
300 300
         			'public'                    => true,
301 301
         			'exclude_from_search'       => true,
302 302
         			'show_in_admin_all_list'    => true,
303 303
 					'show_in_admin_status_list' => true,
304 304
 					/* translators: %s: number of invoices */
305
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
305
+        			'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
306 306
 				)
307 307
 			)
308 308
 		);
309 309
 
310
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
-			register_post_status( $invoice_statuse, $args );
310
+		foreach ($invoice_statuses as $invoice_statuse => $args) {
311
+			register_post_status($invoice_statuse, $args);
312 312
 		}
313 313
 	}
314 314
 
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 */
326 326
 	public static function maybe_flush_rewrite_rules() {
327
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
327
+		if (!get_option('getpaid_flushed_rewrite_rules')) {
328
+			update_option('getpaid_flushed_rewrite_rules', '1');
329 329
 			self::flush_rewrite_rules();
330 330
 		}
331 331
 	}
Please login to merge, or discard this patch.
templates/emails/wpinv-email-footer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text', get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ) ) );
7
-$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : '';
6
+$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text', get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing')));
7
+$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : '';
8 8
 ?>
9 9
                                                             </div>
10 10
                                                         </td>
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text', get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ) ) );
7 8
 $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : '';
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-geolocation.php 2 patches
Indentation   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -13,266 +13,266 @@
 block discarded – undo
13 13
  */
14 14
 class GetPaid_Geolocation {
15 15
 
16
-	/**
17
-	 * Holds the current user's IP Address.
18
-	 *
19
-	 * @var string
20
-	 */
21
-	public static $current_user_ip;
22
-
23
-	/**
24
-	 * API endpoints for looking up a user IP address.
25
-	 *
26
-	 * For example, in case a user is on localhost.
27
-	 *
28
-	 * @var array
29
-	 */
30
-	protected static $ip_lookup_apis = array(
31
-		'ipify'             => 'http://api.ipify.org/',
32
-		'ipecho'            => 'http://ipecho.net/plain',
33
-		'ident'             => 'http://ident.me',
34
-		'whatismyipaddress' => 'http://bot.whatismyipaddress.com',
35
-	);
36
-
37
-	/**
38
-	 * API endpoints for geolocating an IP address
39
-	 *
40
-	 * @var array
41
-	 */
42
-	protected static $geoip_apis = array(
43
-		'ip-api.com' => 'http://ip-api.com/json/%s',
44
-		'ipinfo.io'  => 'https://ipinfo.io/%s/json',
45
-	);
46
-
47
-	/**
48
-	 * Get current user IP Address.
49
-	 *
50
-	 * @return string
51
-	 */
52
-	public static function get_ip_address() {
53
-		return wpinv_get_ip();
54
-	}
55
-
56
-	/**
57
-	 * Get user IP Address using an external service.
58
-	 * This can be used as a fallback for users on localhost where
59
-	 * get_ip_address() will be a local IP and non-geolocatable.
60
-	 *
61
-	 * @return string
62
-	 */
63
-	public static function get_external_ip_address() {
64
-
65
-		$transient_name = 'external_ip_address_0.0.0.0';
66
-
67
-		if ( '' !== self::get_ip_address() ) {
68
-			$transient_name      = 'external_ip_address_' . self::get_ip_address();
69
-		}
70
-
71
-		// Try retrieving from cache.
72
-		$external_ip_address = get_transient( $transient_name );
73
-
74
-		if ( false === $external_ip_address ) {
75
-			$external_ip_address     = '0.0.0.0';
76
-			$ip_lookup_services      = apply_filters( 'getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis );
77
-			$ip_lookup_services_keys = array_keys( $ip_lookup_services );
78
-			shuffle( $ip_lookup_services_keys );
79
-
80
-			foreach ( $ip_lookup_services_keys as $service_name ) {
81
-				$service_endpoint = $ip_lookup_services[ $service_name ];
82
-				$response         = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) );
83
-
84
-				if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) {
85
-					$external_ip_address = apply_filters( 'getpaid_geolocation_ip_lookup_api_response', wpinv_clean( $response['body'] ), $service_name );
86
-					break;
87
-				}
88
-
89
-			}
90
-
91
-			set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS );
92
-		}
93
-
94
-		return $external_ip_address;
95
-	}
96
-
97
-	/**
98
-	 * Geolocate an IP address.
99
-	 *
100
-	 * @param  string $ip_address   IP Address.
101
-	 * @param  bool   $fallback     If true, fallbacks to alternative IP detection (can be slower).
102
-	 * @param  bool   $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower).
103
-	 * @return array
104
-	 */
105
-	public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) {
106
-
107
-		if ( empty( $ip_address ) ) {
108
-			$ip_address = self::get_ip_address();
109
-		}
110
-
111
-		// Update the current user's IP Address.
112
-		self::$current_user_ip = $ip_address;
113
-
114
-		// Filter to allow custom geolocation of the IP address.
115
-		$country_code = apply_filters( 'getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback );
116
-
117
-		if ( false !== $country_code ) {
118
-
119
-			return array(
120
-				'country'  => $country_code,
121
-				'state'    => '',
122
-				'city'     => '',
123
-				'postcode' => '',
124
-			);
125
-
126
-		}
127
-
128
-		$country_code = self::get_country_code_from_headers();
129
-
130
-		/**
131
-		 * Get geolocation filter.
132
-		 *
133
-		 * @since 1.0.19
134
-		 * @param array  $geolocation Geolocation data, including country, state, city, and postcode.
135
-		 * @param string $ip_address  IP Address.
136
-		 */
137
-		$geolocation  = apply_filters(
138
-			'getpaid_get_geolocation',
139
-			array(
140
-				'country'  => $country_code,
141
-				'state'    => '',
142
-				'city'     => '',
143
-				'postcode' => '',
144
-			),
145
-			$ip_address
146
-		);
147
-
148
-		// If we still haven't found a country code, let's consider doing an API lookup.
149
-		if ( '' === $geolocation['country'] && $api_fallback ) {
150
-			$geolocation['country'] = self::geolocate_via_api( $ip_address );
151
-		}
152
-
153
-		// It's possible that we're in a local environment, in which case the geolocation needs to be done from the
154
-		// external address.
155
-		if ( '' === $geolocation['country'] && $fallback ) {
156
-			$external_ip_address = self::get_external_ip_address();
157
-
158
-			// Only bother with this if the external IP differs.
159
-			if ( '0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address ) {
160
-				return self::geolocate_ip( $external_ip_address, false, $api_fallback );
161
-			}
162
-
163
-		}
164
-
165
-		return array(
166
-			'country'  => $geolocation['country'],
167
-			'state'    => $geolocation['state'],
168
-			'city'     => $geolocation['city'],
169
-			'postcode' => $geolocation['postcode'],
170
-		);
171
-
172
-	}
173
-
174
-	/**
175
-	 * Fetches the country code from the request headers, if one is available.
176
-	 *
177
-	 * @since 1.0.19
178
-	 * @return string The country code pulled from the headers, or empty string if one was not found.
179
-	 */
180
-	protected static function get_country_code_from_headers() {
181
-		$country_code = '';
182
-
183
-		$headers = array(
184
-			'MM_COUNTRY_CODE',
185
-			'GEOIP_COUNTRY_CODE',
186
-			'HTTP_CF_IPCOUNTRY',
187
-			'HTTP_X_COUNTRY_CODE',
188
-		);
189
-
190
-		foreach ( $headers as $header ) {
191
-			if ( empty( $_SERVER[ $header ] ) ) {
192
-				continue;
193
-			}
194
-
195
-			$country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) );
196
-			break;
197
-		}
198
-
199
-		return $country_code;
200
-	}
201
-
202
-	/**
203
-	 * Use APIs to Geolocate the user.
204
-	 *
205
-	 * Geolocation APIs can be added through the use of the getpaid_geolocation_geoip_apis filter.
206
-	 * Provide a name=>value pair for service-slug=>endpoint.
207
-	 *
208
-	 * If APIs are defined, one will be chosen at random to fulfil the request. After completing, the result
209
-	 * will be cached in a transient.
210
-	 *
211
-	 * @param  string $ip_address IP address.
212
-	 * @return string
213
-	 */
214
-	protected static function geolocate_via_api( $ip_address ) {
215
-
216
-		// Retrieve from cache...
217
-		$country_code = get_transient( 'geoip_' . $ip_address );
218
-
219
-		// If missing, retrieve from the API.
220
-		if ( false === $country_code ) {
221
-			$geoip_services = apply_filters( 'getpaid_geolocation_geoip_apis', self::$geoip_apis );
222
-
223
-			if ( empty( $geoip_services ) ) {
224
-				return '';
225
-			}
226
-
227
-			$geoip_services_keys = array_keys( $geoip_services );
228
-
229
-			shuffle( $geoip_services_keys );
230
-
231
-			foreach ( $geoip_services_keys as $service_name ) {
232
-
233
-				$service_endpoint = $geoip_services[ $service_name ];
234
-				$response         = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) );
235
-				$country_code     = sanitize_text_field( strtoupper( self::handle_geolocation_response( $response, $service_name ) ) );
236
-
237
-				if ( ! empty( $country_code ) ) {
238
-					break;
239
-				}
240
-
241
-			}
242
-
243
-			set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS );
244
-		}
245
-
246
-		return $country_code;
247
-	}
248
-
249
-	/**
250
-	 * Handles geolocation response
251
-	 *
252
-	 * @param  WP_Error|String $geolocation_response
253
-	 * @param  String $geolocation_service
254
-	 * @return string Country code
255
-	 */
256
-	protected static function handle_geolocation_response( $geolocation_response, $geolocation_service ) {
257
-
258
-		if ( is_wp_error( $geolocation_response ) || empty( $geolocation_response['body'] ) ) {
259
-			return '';
260
-		}
261
-
262
-		if ( $geolocation_service === 'ipinfo.io' ) {
263
-			$data = json_decode( $geolocation_response['body'] );
264
-			wpinv_error_log( $data );
265
-			return empty( $data ) || empty( $data->country ) ? '' : $data->country;
266
-		}
267
-
268
-		if ( $geolocation_service === 'ip-api.com' ) {
269
-			$data = json_decode( $geolocation_response['body'] );
270
-			wpinv_error_log( $data );
271
-			return empty( $data ) || empty( $data->countryCode ) ? '' : $data->countryCode;
272
-		}
273
-
274
-		return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] );
275
-
276
-	}
16
+    /**
17
+     * Holds the current user's IP Address.
18
+     *
19
+     * @var string
20
+     */
21
+    public static $current_user_ip;
22
+
23
+    /**
24
+     * API endpoints for looking up a user IP address.
25
+     *
26
+     * For example, in case a user is on localhost.
27
+     *
28
+     * @var array
29
+     */
30
+    protected static $ip_lookup_apis = array(
31
+        'ipify'             => 'http://api.ipify.org/',
32
+        'ipecho'            => 'http://ipecho.net/plain',
33
+        'ident'             => 'http://ident.me',
34
+        'whatismyipaddress' => 'http://bot.whatismyipaddress.com',
35
+    );
36
+
37
+    /**
38
+     * API endpoints for geolocating an IP address
39
+     *
40
+     * @var array
41
+     */
42
+    protected static $geoip_apis = array(
43
+        'ip-api.com' => 'http://ip-api.com/json/%s',
44
+        'ipinfo.io'  => 'https://ipinfo.io/%s/json',
45
+    );
46
+
47
+    /**
48
+     * Get current user IP Address.
49
+     *
50
+     * @return string
51
+     */
52
+    public static function get_ip_address() {
53
+        return wpinv_get_ip();
54
+    }
55
+
56
+    /**
57
+     * Get user IP Address using an external service.
58
+     * This can be used as a fallback for users on localhost where
59
+     * get_ip_address() will be a local IP and non-geolocatable.
60
+     *
61
+     * @return string
62
+     */
63
+    public static function get_external_ip_address() {
64
+
65
+        $transient_name = 'external_ip_address_0.0.0.0';
66
+
67
+        if ( '' !== self::get_ip_address() ) {
68
+            $transient_name      = 'external_ip_address_' . self::get_ip_address();
69
+        }
70
+
71
+        // Try retrieving from cache.
72
+        $external_ip_address = get_transient( $transient_name );
73
+
74
+        if ( false === $external_ip_address ) {
75
+            $external_ip_address     = '0.0.0.0';
76
+            $ip_lookup_services      = apply_filters( 'getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis );
77
+            $ip_lookup_services_keys = array_keys( $ip_lookup_services );
78
+            shuffle( $ip_lookup_services_keys );
79
+
80
+            foreach ( $ip_lookup_services_keys as $service_name ) {
81
+                $service_endpoint = $ip_lookup_services[ $service_name ];
82
+                $response         = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) );
83
+
84
+                if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) {
85
+                    $external_ip_address = apply_filters( 'getpaid_geolocation_ip_lookup_api_response', wpinv_clean( $response['body'] ), $service_name );
86
+                    break;
87
+                }
88
+
89
+            }
90
+
91
+            set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS );
92
+        }
93
+
94
+        return $external_ip_address;
95
+    }
96
+
97
+    /**
98
+     * Geolocate an IP address.
99
+     *
100
+     * @param  string $ip_address   IP Address.
101
+     * @param  bool   $fallback     If true, fallbacks to alternative IP detection (can be slower).
102
+     * @param  bool   $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower).
103
+     * @return array
104
+     */
105
+    public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) {
106
+
107
+        if ( empty( $ip_address ) ) {
108
+            $ip_address = self::get_ip_address();
109
+        }
110
+
111
+        // Update the current user's IP Address.
112
+        self::$current_user_ip = $ip_address;
113
+
114
+        // Filter to allow custom geolocation of the IP address.
115
+        $country_code = apply_filters( 'getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback );
116
+
117
+        if ( false !== $country_code ) {
118
+
119
+            return array(
120
+                'country'  => $country_code,
121
+                'state'    => '',
122
+                'city'     => '',
123
+                'postcode' => '',
124
+            );
125
+
126
+        }
127
+
128
+        $country_code = self::get_country_code_from_headers();
129
+
130
+        /**
131
+         * Get geolocation filter.
132
+         *
133
+         * @since 1.0.19
134
+         * @param array  $geolocation Geolocation data, including country, state, city, and postcode.
135
+         * @param string $ip_address  IP Address.
136
+         */
137
+        $geolocation  = apply_filters(
138
+            'getpaid_get_geolocation',
139
+            array(
140
+                'country'  => $country_code,
141
+                'state'    => '',
142
+                'city'     => '',
143
+                'postcode' => '',
144
+            ),
145
+            $ip_address
146
+        );
147
+
148
+        // If we still haven't found a country code, let's consider doing an API lookup.
149
+        if ( '' === $geolocation['country'] && $api_fallback ) {
150
+            $geolocation['country'] = self::geolocate_via_api( $ip_address );
151
+        }
152
+
153
+        // It's possible that we're in a local environment, in which case the geolocation needs to be done from the
154
+        // external address.
155
+        if ( '' === $geolocation['country'] && $fallback ) {
156
+            $external_ip_address = self::get_external_ip_address();
157
+
158
+            // Only bother with this if the external IP differs.
159
+            if ( '0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address ) {
160
+                return self::geolocate_ip( $external_ip_address, false, $api_fallback );
161
+            }
162
+
163
+        }
164
+
165
+        return array(
166
+            'country'  => $geolocation['country'],
167
+            'state'    => $geolocation['state'],
168
+            'city'     => $geolocation['city'],
169
+            'postcode' => $geolocation['postcode'],
170
+        );
171
+
172
+    }
173
+
174
+    /**
175
+     * Fetches the country code from the request headers, if one is available.
176
+     *
177
+     * @since 1.0.19
178
+     * @return string The country code pulled from the headers, or empty string if one was not found.
179
+     */
180
+    protected static function get_country_code_from_headers() {
181
+        $country_code = '';
182
+
183
+        $headers = array(
184
+            'MM_COUNTRY_CODE',
185
+            'GEOIP_COUNTRY_CODE',
186
+            'HTTP_CF_IPCOUNTRY',
187
+            'HTTP_X_COUNTRY_CODE',
188
+        );
189
+
190
+        foreach ( $headers as $header ) {
191
+            if ( empty( $_SERVER[ $header ] ) ) {
192
+                continue;
193
+            }
194
+
195
+            $country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) );
196
+            break;
197
+        }
198
+
199
+        return $country_code;
200
+    }
201
+
202
+    /**
203
+     * Use APIs to Geolocate the user.
204
+     *
205
+     * Geolocation APIs can be added through the use of the getpaid_geolocation_geoip_apis filter.
206
+     * Provide a name=>value pair for service-slug=>endpoint.
207
+     *
208
+     * If APIs are defined, one will be chosen at random to fulfil the request. After completing, the result
209
+     * will be cached in a transient.
210
+     *
211
+     * @param  string $ip_address IP address.
212
+     * @return string
213
+     */
214
+    protected static function geolocate_via_api( $ip_address ) {
215
+
216
+        // Retrieve from cache...
217
+        $country_code = get_transient( 'geoip_' . $ip_address );
218
+
219
+        // If missing, retrieve from the API.
220
+        if ( false === $country_code ) {
221
+            $geoip_services = apply_filters( 'getpaid_geolocation_geoip_apis', self::$geoip_apis );
222
+
223
+            if ( empty( $geoip_services ) ) {
224
+                return '';
225
+            }
226
+
227
+            $geoip_services_keys = array_keys( $geoip_services );
228
+
229
+            shuffle( $geoip_services_keys );
230
+
231
+            foreach ( $geoip_services_keys as $service_name ) {
232
+
233
+                $service_endpoint = $geoip_services[ $service_name ];
234
+                $response         = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) );
235
+                $country_code     = sanitize_text_field( strtoupper( self::handle_geolocation_response( $response, $service_name ) ) );
236
+
237
+                if ( ! empty( $country_code ) ) {
238
+                    break;
239
+                }
240
+
241
+            }
242
+
243
+            set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS );
244
+        }
245
+
246
+        return $country_code;
247
+    }
248
+
249
+    /**
250
+     * Handles geolocation response
251
+     *
252
+     * @param  WP_Error|String $geolocation_response
253
+     * @param  String $geolocation_service
254
+     * @return string Country code
255
+     */
256
+    protected static function handle_geolocation_response( $geolocation_response, $geolocation_service ) {
257
+
258
+        if ( is_wp_error( $geolocation_response ) || empty( $geolocation_response['body'] ) ) {
259
+            return '';
260
+        }
261
+
262
+        if ( $geolocation_service === 'ipinfo.io' ) {
263
+            $data = json_decode( $geolocation_response['body'] );
264
+            wpinv_error_log( $data );
265
+            return empty( $data ) || empty( $data->country ) ? '' : $data->country;
266
+        }
267
+
268
+        if ( $geolocation_service === 'ip-api.com' ) {
269
+            $data = json_decode( $geolocation_response['body'] );
270
+            wpinv_error_log( $data );
271
+            return empty( $data ) || empty( $data->countryCode ) ? '' : $data->countryCode;
272
+        }
273
+
274
+        return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] );
275
+
276
+    }
277 277
 
278 278
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * GetPaid_Geolocation Class.
@@ -64,31 +64,31 @@  discard block
 block discarded – undo
64 64
 
65 65
 		$transient_name = 'external_ip_address_0.0.0.0';
66 66
 
67
-		if ( '' !== self::get_ip_address() ) {
68
-			$transient_name      = 'external_ip_address_' . self::get_ip_address();
67
+		if ('' !== self::get_ip_address()) {
68
+			$transient_name = 'external_ip_address_' . self::get_ip_address();
69 69
 		}
70 70
 
71 71
 		// Try retrieving from cache.
72
-		$external_ip_address = get_transient( $transient_name );
72
+		$external_ip_address = get_transient($transient_name);
73 73
 
74
-		if ( false === $external_ip_address ) {
74
+		if (false === $external_ip_address) {
75 75
 			$external_ip_address     = '0.0.0.0';
76
-			$ip_lookup_services      = apply_filters( 'getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis );
77
-			$ip_lookup_services_keys = array_keys( $ip_lookup_services );
78
-			shuffle( $ip_lookup_services_keys );
76
+			$ip_lookup_services      = apply_filters('getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis);
77
+			$ip_lookup_services_keys = array_keys($ip_lookup_services);
78
+			shuffle($ip_lookup_services_keys);
79 79
 
80
-			foreach ( $ip_lookup_services_keys as $service_name ) {
81
-				$service_endpoint = $ip_lookup_services[ $service_name ];
82
-				$response         = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) );
80
+			foreach ($ip_lookup_services_keys as $service_name) {
81
+				$service_endpoint = $ip_lookup_services[$service_name];
82
+				$response         = wp_safe_remote_get($service_endpoint, array('timeout' => 2));
83 83
 
84
-				if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) {
85
-					$external_ip_address = apply_filters( 'getpaid_geolocation_ip_lookup_api_response', wpinv_clean( $response['body'] ), $service_name );
84
+				if (!is_wp_error($response) && rest_is_ip_address($response['body'])) {
85
+					$external_ip_address = apply_filters('getpaid_geolocation_ip_lookup_api_response', wpinv_clean($response['body']), $service_name);
86 86
 					break;
87 87
 				}
88 88
 
89 89
 			}
90 90
 
91
-			set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS );
91
+			set_transient($transient_name, $external_ip_address, WEEK_IN_SECONDS);
92 92
 		}
93 93
 
94 94
 		return $external_ip_address;
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	 * @param  bool   $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower).
103 103
 	 * @return array
104 104
 	 */
105
-	public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) {
105
+	public static function geolocate_ip($ip_address = '', $fallback = false, $api_fallback = true) {
106 106
 
107
-		if ( empty( $ip_address ) ) {
107
+		if (empty($ip_address)) {
108 108
 			$ip_address = self::get_ip_address();
109 109
 		}
110 110
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		self::$current_user_ip = $ip_address;
113 113
 
114 114
 		// Filter to allow custom geolocation of the IP address.
115
-		$country_code = apply_filters( 'getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback );
115
+		$country_code = apply_filters('getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback);
116 116
 
117
-		if ( false !== $country_code ) {
117
+		if (false !== $country_code) {
118 118
 
119 119
 			return array(
120 120
 				'country'  => $country_code,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 * @param array  $geolocation Geolocation data, including country, state, city, and postcode.
135 135
 		 * @param string $ip_address  IP Address.
136 136
 		 */
137
-		$geolocation  = apply_filters(
137
+		$geolocation = apply_filters(
138 138
 			'getpaid_get_geolocation',
139 139
 			array(
140 140
 				'country'  => $country_code,
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 		);
147 147
 
148 148
 		// If we still haven't found a country code, let's consider doing an API lookup.
149
-		if ( '' === $geolocation['country'] && $api_fallback ) {
150
-			$geolocation['country'] = self::geolocate_via_api( $ip_address );
149
+		if ('' === $geolocation['country'] && $api_fallback) {
150
+			$geolocation['country'] = self::geolocate_via_api($ip_address);
151 151
 		}
152 152
 
153 153
 		// It's possible that we're in a local environment, in which case the geolocation needs to be done from the
154 154
 		// external address.
155
-		if ( '' === $geolocation['country'] && $fallback ) {
155
+		if ('' === $geolocation['country'] && $fallback) {
156 156
 			$external_ip_address = self::get_external_ip_address();
157 157
 
158 158
 			// Only bother with this if the external IP differs.
159
-			if ( '0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address ) {
160
-				return self::geolocate_ip( $external_ip_address, false, $api_fallback );
159
+			if ('0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address) {
160
+				return self::geolocate_ip($external_ip_address, false, $api_fallback);
161 161
 			}
162 162
 
163 163
 		}
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 			'HTTP_X_COUNTRY_CODE',
188 188
 		);
189 189
 
190
-		foreach ( $headers as $header ) {
191
-			if ( empty( $_SERVER[ $header ] ) ) {
190
+		foreach ($headers as $header) {
191
+			if (empty($_SERVER[$header])) {
192 192
 				continue;
193 193
 			}
194 194
 
195
-			$country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) );
195
+			$country_code = strtoupper(sanitize_text_field(wp_unslash($_SERVER[$header])));
196 196
 			break;
197 197
 		}
198 198
 
@@ -211,36 +211,36 @@  discard block
 block discarded – undo
211 211
 	 * @param  string $ip_address IP address.
212 212
 	 * @return string
213 213
 	 */
214
-	protected static function geolocate_via_api( $ip_address ) {
214
+	protected static function geolocate_via_api($ip_address) {
215 215
 
216 216
 		// Retrieve from cache...
217
-		$country_code = get_transient( 'geoip_' . $ip_address );
217
+		$country_code = get_transient('geoip_' . $ip_address);
218 218
 
219 219
 		// If missing, retrieve from the API.
220
-		if ( false === $country_code ) {
221
-			$geoip_services = apply_filters( 'getpaid_geolocation_geoip_apis', self::$geoip_apis );
220
+		if (false === $country_code) {
221
+			$geoip_services = apply_filters('getpaid_geolocation_geoip_apis', self::$geoip_apis);
222 222
 
223
-			if ( empty( $geoip_services ) ) {
223
+			if (empty($geoip_services)) {
224 224
 				return '';
225 225
 			}
226 226
 
227
-			$geoip_services_keys = array_keys( $geoip_services );
227
+			$geoip_services_keys = array_keys($geoip_services);
228 228
 
229
-			shuffle( $geoip_services_keys );
229
+			shuffle($geoip_services_keys);
230 230
 
231
-			foreach ( $geoip_services_keys as $service_name ) {
231
+			foreach ($geoip_services_keys as $service_name) {
232 232
 
233
-				$service_endpoint = $geoip_services[ $service_name ];
234
-				$response         = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) );
235
-				$country_code     = sanitize_text_field( strtoupper( self::handle_geolocation_response( $response, $service_name ) ) );
233
+				$service_endpoint = $geoip_services[$service_name];
234
+				$response         = wp_safe_remote_get(sprintf($service_endpoint, $ip_address), array('timeout' => 2));
235
+				$country_code     = sanitize_text_field(strtoupper(self::handle_geolocation_response($response, $service_name)));
236 236
 
237
-				if ( ! empty( $country_code ) ) {
237
+				if (!empty($country_code)) {
238 238
 					break;
239 239
 				}
240 240
 
241 241
 			}
242 242
 
243
-			set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS );
243
+			set_transient('geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS);
244 244
 		}
245 245
 
246 246
 		return $country_code;
@@ -253,25 +253,25 @@  discard block
 block discarded – undo
253 253
 	 * @param  String $geolocation_service
254 254
 	 * @return string Country code
255 255
 	 */
256
-	protected static function handle_geolocation_response( $geolocation_response, $geolocation_service ) {
256
+	protected static function handle_geolocation_response($geolocation_response, $geolocation_service) {
257 257
 
258
-		if ( is_wp_error( $geolocation_response ) || empty( $geolocation_response['body'] ) ) {
258
+		if (is_wp_error($geolocation_response) || empty($geolocation_response['body'])) {
259 259
 			return '';
260 260
 		}
261 261
 
262
-		if ( $geolocation_service === 'ipinfo.io' ) {
263
-			$data = json_decode( $geolocation_response['body'] );
264
-			wpinv_error_log( $data );
265
-			return empty( $data ) || empty( $data->country ) ? '' : $data->country;
262
+		if ($geolocation_service === 'ipinfo.io') {
263
+			$data = json_decode($geolocation_response['body']);
264
+			wpinv_error_log($data);
265
+			return empty($data) || empty($data->country) ? '' : $data->country;
266 266
 		}
267 267
 
268
-		if ( $geolocation_service === 'ip-api.com' ) {
269
-			$data = json_decode( $geolocation_response['body'] );
270
-			wpinv_error_log( $data );
271
-			return empty( $data ) || empty( $data->countryCode ) ? '' : $data->countryCode;
268
+		if ($geolocation_service === 'ip-api.com') {
269
+			$data = json_decode($geolocation_response['body']);
270
+			wpinv_error_log($data);
271
+			return empty($data) || empty($data->countryCode) ? '' : $data->countryCode;
272 272
 		}
273 273
 
274
-		return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] );
274
+		return apply_filters('getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body']);
275 275
 
276 276
 	}
277 277
 
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +479 added lines, -479 removed lines patch added patch discarded remove patch
@@ -14,521 +14,521 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * @param array An array of payment gateways.
40
-	 */
41
-	public $gateways;
42
-
43
-	/**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
47
-		$this->define_constants();
48
-		$this->includes();
49
-		$this->init_hooks();
50
-		$this->set_properties();
51
-	}
52
-
53
-	/**
54
-	 * Sets a custom data property.
55
-	 * 
56
-	 * @param string $prop The prop to set.
57
-	 * @param mixed $value The value to retrieve.
58
-	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
61
-	}
62
-
63
-	/**
64
-	 * Gets a custom data property.
65
-	 *
66
-	 * @param string $prop The prop to set.
67
-	 * @return mixed The value.
68
-	 */
69
-	public function get( $prop ) {
70
-
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
73
-		}
74
-
75
-		return null;
76
-	}
77
-
78
-	/**
79
-	 * Define class properties.
80
-	 */
81
-	public function set_properties() {
82
-
83
-		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
-		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
-
88
-		// Init other objects.
89
-		$this->set( 'session', new WPInv_Session_Handler() );
90
-		$this->set( 'notes', new WPInv_Notes() );
91
-		$this->set( 'api', new WPInv_API() );
92
-		$this->set( 'post_types', new GetPaid_Post_Types() );
93
-		$this->set( 'template', new GetPaid_Template() );
94
-		$this->set( 'admin', new GetPaid_Admin() );
95
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
96
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
-
102
-	}
103
-
104
-	 /**
105
-	 * Define plugin constants.
106
-	 */
107
-	public function define_constants() {
108
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
-		$this->version = WPINV_VERSION;
111
-	}
112
-
113
-	/**
114
-	 * Hook into actions and filters.
115
-	 *
116
-	 * @since 1.0.19
117
-	 */
118
-	protected function init_hooks() {
119
-		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
-
122
-		// Init the plugin after WordPress inits.
123
-		add_action( 'init', array( $this, 'init' ), 1 );
124
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
126
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
-
128
-		if ( class_exists( 'BuddyPress' ) ) {
129
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
130
-		}
131
-
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
133
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
134
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
135
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
136
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
137
-
138
-		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
141
-
142
-	}
143
-
144
-	public function plugins_loaded() {
145
-		/* Internationalize the text strings used. */
146
-		$this->load_textdomain();
147
-
148
-		do_action( 'wpinv_loaded' );
149
-
150
-		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
152
-			wpinv_oxygen_fix_conflict();
153
-		}
154
-	}
155
-
156
-	/**
157
-	 * Load the translation of the plugin.
158
-	 *
159
-	 * @since 1.0
160
-	 */
161
-	public function load_textdomain( $locale = NULL ) {
162
-		if ( empty( $locale ) ) {
163
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
164
-		}
165
-
166
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
167
-
168
-		unload_textdomain( 'invoicing' );
169
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
171
-
172
-		/**
173
-		 * Define language constants.
174
-		 */
175
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
176
-	}
177
-
178
-	/**
179
-	 * Include required core files used in admin and on the frontend.
180
-	 */
181
-	public function includes() {
182
-
183
-		// Start with the settings.
184
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
185
-
186
-		// Packages/libraries.
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
188
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
189
-
190
-		// Load functions.
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
206
-
207
-		// Register autoloader.
208
-		try {
209
-			spl_autoload_register( array( $this, 'autoload' ), true );
210
-		} catch ( Exception $e ) {
211
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
212
-		}
213
-
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
234
-
235
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
236
-			GetPaid_Post_Types_Admin::init();
237
-
238
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
245
-			// load the user class only on the users.php page
246
-			global $pagenow;
247
-			if($pagenow=='users.php'){
248
-				new WPInv_Admin_Users();
249
-			}
250
-		}
251
-
252
-		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
-		}
257
-
258
-	}
259
-
260
-	/**
261
-	 * Class autoloader
262
-	 *
263
-	 * @param       string $class_name The name of the class to load.
264
-	 * @access      public
265
-	 * @since       1.0.19
266
-	 * @return      void
267
-	 */
268
-	public function autoload( $class_name ) {
269
-
270
-		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
272
-
273
-		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
-			return;
276
-		}
277
-
278
-		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
280
-
281
-		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
283
-
284
-		// And an array of possible locations in order of importance.
285
-		$locations = array(
286
-			"$plugin_path/includes",
287
-			"$plugin_path/includes/data-stores",
288
-			"$plugin_path/includes/gateways",
289
-			"$plugin_path/includes/payments",
290
-			"$plugin_path/includes/geolocation",
291
-			"$plugin_path/includes/reports",
292
-			"$plugin_path/includes/api",
293
-			"$plugin_path/includes/admin",
294
-			"$plugin_path/includes/admin/meta-boxes",
295
-		);
296
-
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
-
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
301
-				break;
302
-			}
303
-
304
-		}
305
-
306
-	}
307
-
308
-	/**
309
-	 * Inits hooks etc.
310
-	 */
311
-	public function init() {
312
-
313
-		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
315
-
316
-		// Maybe upgrade.
317
-		$this->maybe_upgrade_database();
318
-
319
-		// Load default gateways.
320
-		$gateways = apply_filters(
321
-			'getpaid_default_gateways',
322
-			array(
323
-				'manual'        => 'GetPaid_Manual_Gateway',
324
-				'paypal'        => 'GetPaid_Paypal_Gateway',
325
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
-			)
329
-		);
330
-
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
333
-		}
334
-
335
-		// Fires after getpaid inits.
336
-		do_action( 'getpaid_init', $this );
337
-
338
-	}
339
-
340
-	/**
341
-	 * Checks if this is an IPN request and processes it.
342
-	 */
343
-	public function maybe_process_ipn() {
344
-
345
-		// Ensure that this is an IPN request.
346
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
347
-			return;
348
-		}
349
-
350
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
351
-
352
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
353
-		do_action( "wpinv_verify_{$gateway}_ipn" );
354
-		exit;
355
-
356
-	}
357
-
358
-	public function enqueue_scripts() {
359
-		$suffix  = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
360
-
361
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
362
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
363
-		wp_enqueue_style( 'wpinv_front_style' );
364
-
365
-		// Register scripts
366
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
367
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ), true );
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * @param array An array of payment gateways.
40
+     */
41
+    public $gateways;
42
+
43
+    /**
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47
+        $this->define_constants();
48
+        $this->includes();
49
+        $this->init_hooks();
50
+        $this->set_properties();
51
+    }
52
+
53
+    /**
54
+     * Sets a custom data property.
55
+     * 
56
+     * @param string $prop The prop to set.
57
+     * @param mixed $value The value to retrieve.
58
+     */
59
+    public function set( $prop, $value ) {
60
+        $this->data[ $prop ] = $value;
61
+    }
62
+
63
+    /**
64
+     * Gets a custom data property.
65
+     *
66
+     * @param string $prop The prop to set.
67
+     * @return mixed The value.
68
+     */
69
+    public function get( $prop ) {
70
+
71
+        if ( isset( $this->data[ $prop ] ) ) {
72
+            return $this->data[ $prop ];
73
+        }
74
+
75
+        return null;
76
+    }
77
+
78
+    /**
79
+     * Define class properties.
80
+     */
81
+    public function set_properties() {
82
+
83
+        // Sessions.
84
+        $this->set( 'session', new WPInv_Session_Handler() );
85
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
+        $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
+
88
+        // Init other objects.
89
+        $this->set( 'session', new WPInv_Session_Handler() );
90
+        $this->set( 'notes', new WPInv_Notes() );
91
+        $this->set( 'api', new WPInv_API() );
92
+        $this->set( 'post_types', new GetPaid_Post_Types() );
93
+        $this->set( 'template', new GetPaid_Template() );
94
+        $this->set( 'admin', new GetPaid_Admin() );
95
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
96
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
+
102
+    }
103
+
104
+        /**
105
+         * Define plugin constants.
106
+         */
107
+    public function define_constants() {
108
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
+        $this->version = WPINV_VERSION;
111
+    }
112
+
113
+    /**
114
+     * Hook into actions and filters.
115
+     *
116
+     * @since 1.0.19
117
+     */
118
+    protected function init_hooks() {
119
+        /* Internationalize the text strings used. */
120
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
+
122
+        // Init the plugin after WordPress inits.
123
+        add_action( 'init', array( $this, 'init' ), 1 );
124
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
126
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
+
128
+        if ( class_exists( 'BuddyPress' ) ) {
129
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
130
+        }
131
+
132
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
133
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
134
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
135
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
136
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
137
+
138
+        // Fires after registering actions.
139
+        do_action( 'wpinv_actions', $this );
140
+        do_action( 'getpaid_actions', $this );
141
+
142
+    }
143
+
144
+    public function plugins_loaded() {
145
+        /* Internationalize the text strings used. */
146
+        $this->load_textdomain();
147
+
148
+        do_action( 'wpinv_loaded' );
149
+
150
+        // Fix oxygen page builder conflict
151
+        if ( function_exists( 'ct_css_output' ) ) {
152
+            wpinv_oxygen_fix_conflict();
153
+        }
154
+    }
155
+
156
+    /**
157
+     * Load the translation of the plugin.
158
+     *
159
+     * @since 1.0
160
+     */
161
+    public function load_textdomain( $locale = NULL ) {
162
+        if ( empty( $locale ) ) {
163
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
164
+        }
165
+
166
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
167
+
168
+        unload_textdomain( 'invoicing' );
169
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
171
+
172
+        /**
173
+         * Define language constants.
174
+         */
175
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
176
+    }
177
+
178
+    /**
179
+     * Include required core files used in admin and on the frontend.
180
+     */
181
+    public function includes() {
182
+
183
+        // Start with the settings.
184
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
185
+
186
+        // Packages/libraries.
187
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
188
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
189
+
190
+        // Load functions.
191
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
192
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
193
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
194
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
195
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
196
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
197
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
199
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
200
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
206
+
207
+        // Register autoloader.
208
+        try {
209
+            spl_autoload_register( array( $this, 'autoload' ), true );
210
+        } catch ( Exception $e ) {
211
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
212
+        }
213
+
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
215
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
216
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
217
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
218
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
219
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
220
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
221
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
222
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
223
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
234
+
235
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
236
+            GetPaid_Post_Types_Admin::init();
237
+
238
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
242
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
245
+            // load the user class only on the users.php page
246
+            global $pagenow;
247
+            if($pagenow=='users.php'){
248
+                new WPInv_Admin_Users();
249
+            }
250
+        }
251
+
252
+        // Register cli commands
253
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
+        }
257
+
258
+    }
259
+
260
+    /**
261
+     * Class autoloader
262
+     *
263
+     * @param       string $class_name The name of the class to load.
264
+     * @access      public
265
+     * @since       1.0.19
266
+     * @return      void
267
+     */
268
+    public function autoload( $class_name ) {
269
+
270
+        // Normalize the class name...
271
+        $class_name  = strtolower( $class_name );
272
+
273
+        // ... and make sure it is our class.
274
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
+            return;
276
+        }
368 277
 
369
-		$localize                         = array();
370
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
371
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
-		$localize['UseTaxes']             = wpinv_use_taxes();
374
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
375
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
278
+        // Next, prepare the file name from the class.
279
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
377 280
 
378
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
-
380
-		wp_enqueue_script( 'jquery-blockui' );
381
-
382
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' );
383
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
384
-
385
-		wp_enqueue_script( 'wpinv-front-script' );
386
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
387
-
388
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
389
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script' ),  $version, true );
390
-	}
281
+        // Base path of the classes.
282
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
391 283
 
392
-	public function wpinv_actions() {
393
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
394
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
395
-		}
396
-	}
284
+        // And an array of possible locations in order of importance.
285
+        $locations = array(
286
+            "$plugin_path/includes",
287
+            "$plugin_path/includes/data-stores",
288
+            "$plugin_path/includes/gateways",
289
+            "$plugin_path/includes/payments",
290
+            "$plugin_path/includes/geolocation",
291
+            "$plugin_path/includes/reports",
292
+            "$plugin_path/includes/api",
293
+            "$plugin_path/includes/admin",
294
+            "$plugin_path/includes/admin/meta-boxes",
295
+        );
397 296
 
398
-	/**
297
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
+
299
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
+                include trailingslashit( $location ) . $file_name;
301
+                break;
302
+            }
303
+
304
+        }
305
+
306
+    }
307
+
308
+    /**
309
+     * Inits hooks etc.
310
+     */
311
+    public function init() {
312
+
313
+        // Fires before getpaid inits.
314
+        do_action( 'before_getpaid_init', $this );
315
+
316
+        // Maybe upgrade.
317
+        $this->maybe_upgrade_database();
318
+
319
+        // Load default gateways.
320
+        $gateways = apply_filters(
321
+            'getpaid_default_gateways',
322
+            array(
323
+                'manual'        => 'GetPaid_Manual_Gateway',
324
+                'paypal'        => 'GetPaid_Paypal_Gateway',
325
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
+            )
329
+        );
330
+
331
+        foreach ( $gateways as $id => $class ) {
332
+            $this->gateways[ $id ] = new $class();
333
+        }
334
+
335
+        // Fires after getpaid inits.
336
+        do_action( 'getpaid_init', $this );
337
+
338
+    }
339
+
340
+    /**
341
+     * Checks if this is an IPN request and processes it.
342
+     */
343
+    public function maybe_process_ipn() {
344
+
345
+        // Ensure that this is an IPN request.
346
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
347
+            return;
348
+        }
349
+
350
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
351
+
352
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
353
+        do_action( "wpinv_verify_{$gateway}_ipn" );
354
+        exit;
355
+
356
+    }
357
+
358
+    public function enqueue_scripts() {
359
+        $suffix  = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
360
+
361
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
362
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
363
+        wp_enqueue_style( 'wpinv_front_style' );
364
+
365
+        // Register scripts
366
+        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
367
+        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ), true );
368
+
369
+        $localize                         = array();
370
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
371
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
+        $localize['UseTaxes']             = wpinv_use_taxes();
374
+        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
375
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
377
+
378
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
+
380
+        wp_enqueue_script( 'jquery-blockui' );
381
+
382
+        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' );
383
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
384
+
385
+        wp_enqueue_script( 'wpinv-front-script' );
386
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
387
+
388
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
389
+        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script' ),  $version, true );
390
+    }
391
+
392
+    public function wpinv_actions() {
393
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
394
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
395
+        }
396
+    }
397
+
398
+    /**
399 399
      * Fires an action after verifying that a user can fire them.
400
-	 *
401
-	 * Note: If the action is on an invoice, subscription etc, esure that the
402
-	 * current user owns the invoice/subscription.
400
+     *
401
+     * Note: If the action is on an invoice, subscription etc, esure that the
402
+     * current user owns the invoice/subscription.
403 403
      */
404 404
     public function maybe_do_authenticated_action() {
405 405
 
406
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
406
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
407 407
 
408
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
409
-			$data = wp_unslash( $_REQUEST );
410
-			if ( is_user_logged_in() ) {
411
-				do_action( "getpaid_authenticated_action_$key", $data );
412
-			}
408
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
409
+            $data = wp_unslash( $_REQUEST );
410
+            if ( is_user_logged_in() ) {
411
+                do_action( "getpaid_authenticated_action_$key", $data );
412
+            }
413 413
 
414
-			do_action( "getpaid_unauthenticated_action_$key", $data );
414
+            do_action( "getpaid_unauthenticated_action_$key", $data );
415 415
 
416
-		}
416
+        }
417 417
 
418 418
     }
419 419
 
420
-	public function pre_get_posts( $wp_query ) {
421
-
422
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
423
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
424
-		}
425
-
426
-		return $wp_query;
427
-	}
428
-
429
-	public function bp_invoicing_init() {
430
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
431
-	}
432
-
433
-	/**
434
-	 * Register widgets
435
-	 *
436
-	 */
437
-	public function register_widgets() {
438
-		$widgets = apply_filters(
439
-			'getpaid_widget_classes',
440
-			array(
441
-				'WPInv_Checkout_Widget',
442
-				'WPInv_History_Widget',
443
-				'WPInv_Receipt_Widget',
444
-				'WPInv_Subscriptions_Widget',
445
-				'WPInv_Buy_Item_Widget',
446
-				'WPInv_Messages_Widget',
447
-				'WPInv_GetPaid_Widget'
448
-			)
449
-		);
450
-
451
-		foreach ( $widgets as $widget ) {
452
-			register_widget( $widget );
453
-		}
420
+    public function pre_get_posts( $wp_query ) {
421
+
422
+        if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
423
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
424
+        }
425
+
426
+        return $wp_query;
427
+    }
428
+
429
+    public function bp_invoicing_init() {
430
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
431
+    }
432
+
433
+    /**
434
+     * Register widgets
435
+     *
436
+     */
437
+    public function register_widgets() {
438
+        $widgets = apply_filters(
439
+            'getpaid_widget_classes',
440
+            array(
441
+                'WPInv_Checkout_Widget',
442
+                'WPInv_History_Widget',
443
+                'WPInv_Receipt_Widget',
444
+                'WPInv_Subscriptions_Widget',
445
+                'WPInv_Buy_Item_Widget',
446
+                'WPInv_Messages_Widget',
447
+                'WPInv_GetPaid_Widget'
448
+            )
449
+        );
450
+
451
+        foreach ( $widgets as $widget ) {
452
+            register_widget( $widget );
453
+        }
454 454
 		
455
-	}
455
+    }
456 456
 
457
-	/**
458
-	 * Upgrades the database.
459
-	 *
460
-	 * @since 2.0.2
461
-	 */
462
-	public function maybe_upgrade_database() {
457
+    /**
458
+     * Upgrades the database.
459
+     *
460
+     * @since 2.0.2
461
+     */
462
+    public function maybe_upgrade_database() {
463 463
 
464
-		$wpi_version = get_option( 'wpinv_version', 0 );
464
+        $wpi_version = get_option( 'wpinv_version', 0 );
465 465
 
466
-		if ( $wpi_version == WPINV_VERSION ) {
467
-			return;
468
-		}
466
+        if ( $wpi_version == WPINV_VERSION ) {
467
+            return;
468
+        }
469 469
 
470
-		$installer = new GetPaid_Installer();
470
+        $installer = new GetPaid_Installer();
471 471
 
472
-		if ( empty( $wpi_version ) ) {
473
-			return $installer->upgrade_db( 0 );
474
-		}
472
+        if ( empty( $wpi_version ) ) {
473
+            return $installer->upgrade_db( 0 );
474
+        }
475 475
 
476
-		$upgrades  = array(
477
-			'0.0.5' => '004',
478
-			'1.0.3' => '102',
479
-			'2.0.0' => '118',
480
-		);
476
+        $upgrades  = array(
477
+            '0.0.5' => '004',
478
+            '1.0.3' => '102',
479
+            '2.0.0' => '118',
480
+        );
481 481
 
482
-		foreach ( $upgrades as $key => $method ) {
482
+        foreach ( $upgrades as $key => $method ) {
483 483
 
484
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
485
-				return $installer->upgrade_db( $method );
486
-			}
484
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
485
+                return $installer->upgrade_db( $method );
486
+            }
487 487
 
488
-		}
488
+        }
489 489
 
490
-	}
490
+    }
491 491
 
492
-	/**
493
-	 * Remove our pages from yoast sitemaps.
494
-	 *
495
-	 * @since 1.0.19
496
-	 * @param int[] $excluded_posts_ids
497
-	 */
498
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
492
+    /**
493
+     * Remove our pages from yoast sitemaps.
494
+     *
495
+     * @since 1.0.19
496
+     * @param int[] $excluded_posts_ids
497
+     */
498
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
499 499
 
500
-		// Ensure that we have an array.
501
-		if ( ! is_array( $excluded_posts_ids ) ) {
502
-			$excluded_posts_ids = array();
503
-		}
500
+        // Ensure that we have an array.
501
+        if ( ! is_array( $excluded_posts_ids ) ) {
502
+            $excluded_posts_ids = array();
503
+        }
504 504
 
505
-		// Prepare our pages.
506
-		$our_pages = array();
505
+        // Prepare our pages.
506
+        $our_pages = array();
507 507
 
508
-		// Checkout page.
509
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
508
+        // Checkout page.
509
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
510 510
 
511
-		// Success page.
512
-		$our_pages[] = wpinv_get_option( 'success_page', false );
511
+        // Success page.
512
+        $our_pages[] = wpinv_get_option( 'success_page', false );
513 513
 
514
-		// Failure page.
515
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
514
+        // Failure page.
515
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
516 516
 
517
-		// History page.
518
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
517
+        // History page.
518
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
519 519
 
520
-		// Subscriptions page.
521
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
520
+        // Subscriptions page.
521
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
522 522
 
523
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
523
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
524 524
 
525
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
526
-		return array_unique( $excluded_posts_ids );
525
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
526
+        return array_unique( $excluded_posts_ids );
527 527
 
528
-	}
528
+    }
529 529
 
530
-	public function wp_footer() {
531
-		echo '
530
+    public function wp_footer() {
531
+        echo '
532 532
 			<div class="bsui">
533 533
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
534 534
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -544,6 +544,6 @@  discard block
 block discarded – undo
544 544
 				</div>
545 545
 			</div>
546 546
 		';
547
-	}
547
+    }
548 548
 
549 549
 }
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 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
  * Main Invoicing class.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
69
+	public function get($prop) {
70 70
 
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
71
+		if (isset($this->data[$prop])) {
72
+			return $this->data[$prop];
73 73
 		}
74 74
 
75 75
 		return null;
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function set_properties() {
82 82
 
83 83
 		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+		$this->set('session', new WPInv_Session_Handler());
85
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
86 86
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87 87
 
88 88
 		// Init other objects.
89
-		$this->set( 'session', new WPInv_Session_Handler() );
90
-		$this->set( 'notes', new WPInv_Notes() );
91
-		$this->set( 'api', new WPInv_API() );
92
-		$this->set( 'post_types', new GetPaid_Post_Types() );
93
-		$this->set( 'template', new GetPaid_Template() );
94
-		$this->set( 'admin', new GetPaid_Admin() );
95
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
96
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
89
+		$this->set('session', new WPInv_Session_Handler());
90
+		$this->set('notes', new WPInv_Notes());
91
+		$this->set('api', new WPInv_API());
92
+		$this->set('post_types', new GetPaid_Post_Types());
93
+		$this->set('template', new GetPaid_Template());
94
+		$this->set('admin', new GetPaid_Admin());
95
+		$this->set('subscriptions', new WPInv_Subscriptions());
96
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
97
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
98
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
99
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
100
+		$this->set('maxmind', new GetPaid_MaxMind_Geolocation());
101 101
 
102 102
 	}
103 103
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * Define plugin constants.
106 106
 	 */
107 107
 	public function define_constants() {
108
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
108
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
109
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
110 110
 		$this->version = WPINV_VERSION;
111 111
 	}
112 112
 
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function init_hooks() {
119 119
 		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
120
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
121 121
 
122 122
 		// Init the plugin after WordPress inits.
123
-		add_action( 'init', array( $this, 'init' ), 1 );
124
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
126
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
123
+		add_action('init', array($this, 'init'), 1);
124
+		add_action('init', array($this, 'maybe_process_ipn'), 10);
125
+		add_action('init', array($this, 'wpinv_actions'));
126
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
127 127
 
128
-		if ( class_exists( 'BuddyPress' ) ) {
129
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
128
+		if (class_exists('BuddyPress')) {
129
+			add_action('bp_include', array(&$this, 'bp_invoicing_init'));
130 130
 		}
131 131
 
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
133
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
134
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
135
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
136
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
132
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
133
+		add_action('wp_footer', array(&$this, 'wp_footer'));
134
+		add_action('widgets_init', array(&$this, 'register_widgets'));
135
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
136
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
137 137
 
138 138
 		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
139
+		do_action('wpinv_actions', $this);
140
+		do_action('getpaid_actions', $this);
141 141
 
142 142
 	}
143 143
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 		/* Internationalize the text strings used. */
146 146
 		$this->load_textdomain();
147 147
 
148
-		do_action( 'wpinv_loaded' );
148
+		do_action('wpinv_loaded');
149 149
 
150 150
 		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
151
+		if (function_exists('ct_css_output')) {
152 152
 			wpinv_oxygen_fix_conflict();
153 153
 		}
154 154
 	}
@@ -158,21 +158,21 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @since 1.0
160 160
 	 */
161
-	public function load_textdomain( $locale = NULL ) {
162
-		if ( empty( $locale ) ) {
163
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
161
+	public function load_textdomain($locale = NULL) {
162
+		if (empty($locale)) {
163
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
164 164
 		}
165 165
 
166
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
166
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
167 167
 
168
-		unload_textdomain( 'invoicing' );
169
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
168
+		unload_textdomain('invoicing');
169
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
170
+		load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
171 171
 
172 172
 		/**
173 173
 		 * Define language constants.
174 174
 		 */
175
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
175
+		require_once(WPINV_PLUGIN_DIR . 'language.php');
176 176
 	}
177 177
 
178 178
 	/**
@@ -181,78 +181,78 @@  discard block
 block discarded – undo
181 181
 	public function includes() {
182 182
 
183 183
 		// Start with the settings.
184
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
184
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
185 185
 
186 186
 		// Packages/libraries.
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
188
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
187
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
188
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
189 189
 
190 190
 		// Load functions.
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
191
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
192
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
193
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
194
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
195
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
196
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
197
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
199
+		require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php');
200
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php');
205
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
206 206
 
207 207
 		// Register autoloader.
208 208
 		try {
209
-			spl_autoload_register( array( $this, 'autoload' ), true );
210
-		} catch ( Exception $e ) {
211
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
209
+			spl_autoload_register(array($this, 'autoload'), true);
210
+		} catch (Exception $e) {
211
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
212 212
 		}
213 213
 
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
234
-
235
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
215
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
216
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
217
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
218
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
219
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
220
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
221
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
222
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
223
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
234
+
235
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
236 236
 			GetPaid_Post_Types_Admin::init();
237 237
 
238
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
238
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
239
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
240
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
241
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
242
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
243
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
244
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
245 245
 			// load the user class only on the users.php page
246 246
 			global $pagenow;
247
-			if($pagenow=='users.php'){
247
+			if ($pagenow == 'users.php') {
248 248
 				new WPInv_Admin_Users();
249 249
 			}
250 250
 		}
251 251
 
252 252
 		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
253
+		if (defined('WP_CLI') && WP_CLI) {
254
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
255
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
256 256
 		}
257 257
 
258 258
 	}
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	 * @since       1.0.19
266 266
 	 * @return      void
267 267
 	 */
268
-	public function autoload( $class_name ) {
268
+	public function autoload($class_name) {
269 269
 
270 270
 		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
271
+		$class_name = strtolower($class_name);
272 272
 
273 273
 		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
275 275
 			return;
276 276
 		}
277 277
 
278 278
 		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
280 280
 
281 281
 		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
283 283
 
284 284
 		// And an array of possible locations in order of importance.
285 285
 		$locations = array(
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 			"$plugin_path/includes/admin/meta-boxes",
295 295
 		);
296 296
 
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
298 298
 
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
299
+			if (file_exists(trailingslashit($location) . $file_name)) {
300
+				include trailingslashit($location) . $file_name;
301 301
 				break;
302 302
 			}
303 303
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	public function init() {
312 312
 
313 313
 		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
314
+		do_action('before_getpaid_init', $this);
315 315
 
316 316
 		// Maybe upgrade.
317 317
 		$this->maybe_upgrade_database();
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 			)
329 329
 		);
330 330
 
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
331
+		foreach ($gateways as $id => $class) {
332
+			$this->gateways[$id] = new $class();
333 333
 		}
334 334
 
335 335
 		// Fires after getpaid inits.
336
-		do_action( 'getpaid_init', $this );
336
+		do_action('getpaid_init', $this);
337 337
 
338 338
 	}
339 339
 
@@ -343,55 +343,55 @@  discard block
 block discarded – undo
343 343
 	public function maybe_process_ipn() {
344 344
 
345 345
 		// Ensure that this is an IPN request.
346
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
346
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
347 347
 			return;
348 348
 		}
349 349
 
350
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
350
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
351 351
 
352
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
353
-		do_action( "wpinv_verify_{$gateway}_ipn" );
352
+		do_action('wpinv_verify_payment_ipn', $gateway);
353
+		do_action("wpinv_verify_{$gateway}_ipn");
354 354
 		exit;
355 355
 
356 356
 	}
357 357
 
358 358
 	public function enqueue_scripts() {
359
-		$suffix  = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
359
+		$suffix  = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
360 360
 
361
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
362
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
363
-		wp_enqueue_style( 'wpinv_front_style' );
361
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
362
+		wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
363
+		wp_enqueue_style('wpinv_front_style');
364 364
 
365 365
 		// Register scripts
366
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
367
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ), true );
366
+		wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
367
+		wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'), true);
368 368
 
369 369
 		$localize                         = array();
370
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
371
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
370
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
371
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
372
+		$localize['txtComplete']          = __('Continue', 'invoicing');
373 373
 		$localize['UseTaxes']             = wpinv_use_taxes();
374
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
375
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
374
+		$localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
375
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
376
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
377 377
 
378
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
378
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
379 379
 
380
-		wp_enqueue_script( 'jquery-blockui' );
380
+		wp_enqueue_script('jquery-blockui');
381 381
 
382
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' );
383
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
382
+		wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all');
383
+		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
384 384
 
385
-		wp_enqueue_script( 'wpinv-front-script' );
386
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
385
+		wp_enqueue_script('wpinv-front-script');
386
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
387 387
 
388
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
389
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script' ),  $version, true );
388
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
389
+		wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script'), $version, true);
390 390
 	}
391 391
 
392 392
 	public function wpinv_actions() {
393
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
394
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
393
+		if (isset($_REQUEST['wpi_action'])) {
394
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
395 395
 		}
396 396
 	}
397 397
 
@@ -403,31 +403,31 @@  discard block
 block discarded – undo
403 403
      */
404 404
     public function maybe_do_authenticated_action() {
405 405
 
406
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
406
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
407 407
 
408
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
409
-			$data = wp_unslash( $_REQUEST );
410
-			if ( is_user_logged_in() ) {
411
-				do_action( "getpaid_authenticated_action_$key", $data );
408
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
409
+			$data = wp_unslash($_REQUEST);
410
+			if (is_user_logged_in()) {
411
+				do_action("getpaid_authenticated_action_$key", $data);
412 412
 			}
413 413
 
414
-			do_action( "getpaid_unauthenticated_action_$key", $data );
414
+			do_action("getpaid_unauthenticated_action_$key", $data);
415 415
 
416 416
 		}
417 417
 
418 418
     }
419 419
 
420
-	public function pre_get_posts( $wp_query ) {
420
+	public function pre_get_posts($wp_query) {
421 421
 
422
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
423
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
422
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
423
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
424 424
 		}
425 425
 
426 426
 		return $wp_query;
427 427
 	}
428 428
 
429 429
 	public function bp_invoicing_init() {
430
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
430
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
431 431
 	}
432 432
 
433 433
 	/**
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 			)
449 449
 		);
450 450
 
451
-		foreach ( $widgets as $widget ) {
452
-			register_widget( $widget );
451
+		foreach ($widgets as $widget) {
452
+			register_widget($widget);
453 453
 		}
454 454
 		
455 455
 	}
@@ -461,28 +461,28 @@  discard block
 block discarded – undo
461 461
 	 */
462 462
 	public function maybe_upgrade_database() {
463 463
 
464
-		$wpi_version = get_option( 'wpinv_version', 0 );
464
+		$wpi_version = get_option('wpinv_version', 0);
465 465
 
466
-		if ( $wpi_version == WPINV_VERSION ) {
466
+		if ($wpi_version == WPINV_VERSION) {
467 467
 			return;
468 468
 		}
469 469
 
470 470
 		$installer = new GetPaid_Installer();
471 471
 
472
-		if ( empty( $wpi_version ) ) {
473
-			return $installer->upgrade_db( 0 );
472
+		if (empty($wpi_version)) {
473
+			return $installer->upgrade_db(0);
474 474
 		}
475 475
 
476
-		$upgrades  = array(
476
+		$upgrades = array(
477 477
 			'0.0.5' => '004',
478 478
 			'1.0.3' => '102',
479 479
 			'2.0.0' => '118',
480 480
 		);
481 481
 
482
-		foreach ( $upgrades as $key => $method ) {
482
+		foreach ($upgrades as $key => $method) {
483 483
 
484
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
485
-				return $installer->upgrade_db( $method );
484
+			if (version_compare($wpi_version, $key, '<')) {
485
+				return $installer->upgrade_db($method);
486 486
 			}
487 487
 
488 488
 		}
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
 	 * @since 1.0.19
496 496
 	 * @param int[] $excluded_posts_ids
497 497
 	 */
498
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
498
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
499 499
 
500 500
 		// Ensure that we have an array.
501
-		if ( ! is_array( $excluded_posts_ids ) ) {
501
+		if (!is_array($excluded_posts_ids)) {
502 502
 			$excluded_posts_ids = array();
503 503
 		}
504 504
 
@@ -506,24 +506,24 @@  discard block
 block discarded – undo
506 506
 		$our_pages = array();
507 507
 
508 508
 		// Checkout page.
509
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
509
+		$our_pages[] = wpinv_get_option('checkout_page', false);
510 510
 
511 511
 		// Success page.
512
-		$our_pages[] = wpinv_get_option( 'success_page', false );
512
+		$our_pages[] = wpinv_get_option('success_page', false);
513 513
 
514 514
 		// Failure page.
515
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
515
+		$our_pages[] = wpinv_get_option('failure_page', false);
516 516
 
517 517
 		// History page.
518
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
518
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
519 519
 
520 520
 		// Subscriptions page.
521
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
521
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
522 522
 
523
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
523
+		$our_pages   = array_map('intval', array_filter($our_pages));
524 524
 
525 525
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
526
-		return array_unique( $excluded_posts_ids );
526
+		return array_unique($excluded_posts_ids);
527 527
 
528 528
 	}
529 529
 
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
535 535
 						<div class="modal-content">
536 536
 							<div class="modal-body">
537
-								<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__( 'Close', 'invoicing' ) . '">
537
+								<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__('Close', 'invoicing') . '">
538 538
 									<i class="fa fa-times" aria-hidden="true"></i>
539 539
 								</button>
540 540
 								<div class="modal-body-wrapper"></div>
Please login to merge, or discard this patch.
templates/payment-forms/elements/address-fields.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,56 +11,56 @@  discard block
 block discarded – undo
11 11
  * @var string $country The current user's country
12 12
  */
13 13
 
14
-defined( 'ABSPATH' ) || exit;
14
+defined('ABSPATH') || exit;
15 15
 
16 16
 
17
-$field_type = sanitize_key( $field_type );
17
+$field_type = sanitize_key($field_type);
18 18
 
19 19
 echo "<div class='row $field_type'>";
20 20
 
21
-foreach ( $fields as $address_field ) {
21
+foreach ($fields as $address_field) {
22 22
 
23 23
     // Skip if it is hidden.
24
-    if ( empty( $address_field['visible'] ) ) {
24
+    if (empty($address_field['visible'])) {
25 25
         continue;
26 26
     }
27 27
 
28
-    do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field );
28
+    do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field);
29 29
 
30 30
     // Prepare variables.
31
-    if ( ! empty( $form->invoice ) ) {
31
+    if (!empty($form->invoice)) {
32 32
         $user_id = $form->invoice->get_user_id();
33 33
     }
34 34
 
35
-    if ( empty( $user_id ) && is_user_logged_in() ) {
35
+    if (empty($user_id) && is_user_logged_in()) {
36 36
         $user_id = get_current_user_id();
37 37
     }
38 38
 
39 39
     $field_name  = $address_field['name'];
40 40
     $field_name  = "{$field_type}[$field_name]";
41
-    $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
42
-    $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
43
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
44
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
45
-    $value       = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : '';
46
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
47
-
48
-    if ( ! empty( $address_field['required'] ) ) {
41
+    $wrap_class  = getpaid_get_form_element_grid_class($address_field);
42
+    $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
43
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
44
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
45
+    $value       = !empty($user_id) ? get_user_meta($user_id, '_' . $address_field['name'], true) : '';
46
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
47
+
48
+    if (!empty($address_field['required'])) {
49 49
         $label .= "<span class='text-danger'> *</span>";
50 50
     }
51 51
 
52 52
     // Display the country.
53
-    if ( 'wpinv_country' == $address_field['name'] ) {
53
+    if ('wpinv_country' == $address_field['name']) {
54 54
 
55 55
         echo aui()->select(
56 56
             array(
57 57
                 'options'     => wpinv_get_country_list(),
58
-                'name'        => esc_attr( $field_name ),
59
-                'id'          => sanitize_html_class( $field_name ) . $uniqid,
60
-                'value'       => sanitize_text_field( $country ),
58
+                'name'        => esc_attr($field_name),
59
+                'id'          => sanitize_html_class($field_name) . $uniqid,
60
+                'value'       => sanitize_text_field($country),
61 61
                 'placeholder' => $placeholder,
62
-                'required'    => ! empty( $address_field['required'] ),
63
-                'label'       => wp_kses_post( $label ),
62
+                'required'    => !empty($address_field['required']),
63
+                'label'       => wp_kses_post($label),
64 64
                 'label_type'  => 'vertical',
65 65
                 'help_text'   => $description,
66 66
                 'class'       => 'getpaid-address-field wpinv_country',
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
     }
76 76
 
77 77
     // Display the state.
78
-    else if ( 'wpinv_state' == $address_field['name'] ) {
78
+    else if ('wpinv_state' == $address_field['name']) {
79 79
 
80
-        if ( empty( $value ) ) {
80
+        if (empty($value)) {
81 81
             $value = wpinv_get_default_state();
82 82
         }
83 83
 
84
-        echo getpaid_get_states_select_markup (
84
+        echo getpaid_get_states_select_markup(
85 85
             $country,
86 86
             $value,
87 87
             $placeholder,
88 88
             $label,
89 89
             $description,
90
-            ! empty( $address_field['required'] ),
90
+            !empty($address_field['required']),
91 91
             $wrap_class,
92 92
             $field_name
93 93
         );
94 94
 
95 95
     } else {
96 96
 
97
-        $key      = str_replace( 'wpinv_', '', $address_field['name'] );
98
-        $key      = esc_attr( str_replace( '_', '-', $key ) );
97
+        $key      = str_replace('wpinv_', '', $address_field['name']);
98
+        $key      = esc_attr(str_replace('_', '-', $key));
99 99
         $autocomplete = '';
100 100
         $replacements = array(
101 101
             'zip'        => 'postal-code',
@@ -108,24 +108,24 @@  discard block
 block discarded – undo
108 108
         );
109 109
 
110 110
 
111
-        if ( isset( $replacements[ $key ] ) ) {
111
+        if (isset($replacements[$key])) {
112 112
             $autocomplete = array(
113
-                'autocomplete' => "$field_type {$replacements[ $key ]}",
113
+                'autocomplete' => "$field_type {$replacements[$key]}",
114 114
             );
115 115
         }
116 116
 
117 117
         echo aui()->input(
118 118
             array(
119
-                'name'        => esc_attr( $field_name ),
120
-                'id'          => sanitize_html_class( $field_name ) . $uniqid,
121
-                'required'    => ! empty( $address_field['required'] ),
119
+                'name'        => esc_attr($field_name),
120
+                'id'          => sanitize_html_class($field_name) . $uniqid,
121
+                'required'    => !empty($address_field['required']),
122 122
                 'placeholder' => $placeholder,
123
-                'label'       => wp_kses_post( $label ),
123
+                'label'       => wp_kses_post($label),
124 124
                 'label_type'  => 'vertical',
125 125
                 'help_text'   => $description,
126 126
                 'type'        => 'text',
127
-                'value'       => sanitize_text_field( $value ),
128
-                'class'       => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
127
+                'value'       => sanitize_text_field($value),
128
+                'class'       => 'getpaid-address-field ' . esc_attr($address_field['name']),
129 129
                 'wrap_class'  => "$wrap_class getpaid-address-field-wrapper__$key",
130 130
                 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
131 131
                 'extra_attributes' => $autocomplete,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     }
136 136
 
137
-    do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field );
137
+    do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field);
138 138
 }
139 139
 
140 140
 echo "</div>";
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-refresh-prices.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -12,227 +12,227 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Refresh_Prices {
14 14
 
15
-	/**
16
-	 * Contains the response for refreshing prices.
17
-	 * @var array
18
-	 */
19
-	public $response = array();
15
+    /**
16
+     * Contains the response for refreshing prices.
17
+     * @var array
18
+     */
19
+    public $response = array();
20 20
 
21 21
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$this->response = array(
29
-			'submission_id' => $submission->id,
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $this->response = array(
29
+            'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31 31
             'is_free'       => ! $submission->should_collect_payment_details(),
32
-		);
33
-
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
41
-
42
-	}
43
-
44
-	/**
45
-	 * Adds totals to a response for submission refresh prices.
46
-	 *
47
-	 * @param GetPaid_Payment_Form_Submission $submission
48
-	 */
49
-	public function add_totals( $submission ) {
50
-
51
-		$this->response = array_merge(
52
-			$this->response,
53
-			array(
54
-
55
-				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
-				),
63
-
64
-				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
-				),
71
-
72
-				'initial_amt'   => wpinv_round_amount( $submission->get_total(), null, true ),
73
-				'currency'      => $submission->get_currency(),
74
-
75
-			)
76
-		);
77
-
78
-	}
79
-
80
-	/**
81
-	 * Adds texts to a response for submission refresh prices.
82
-	 *
83
-	 * @param GetPaid_Payment_Form_Submission $submission
84
-	 */
85
-	public function add_texts( $submission ) {
86
-
87
-		$payable = $submission->format_amount( $submission->get_total() );
88
-
89
-		if ( $submission->has_recurring != 0 ) {
90
-
91
-			$recurring = new WPInv_Item( $submission->has_recurring );
92
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
93
-
94
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
95
-				$payable = "$payable / $period";
96
-			} else {
97
-				$payable = sprintf(
98
-					__( '%1$s (renews at %2$s / %3$s)'),
99
-					$submission->format_amount( $submission->get_total() ),
100
-					$submission->format_amount( $submission->get_recurring_total() ),
101
-					$period
102
-				);
103
-			}
104
-
105
-		}
106
-
107
-		$texts = array(
108
-			'.getpaid-checkout-total-payable' => $payable,
109
-		);
110
-
111
-		foreach ( $submission->get_items() as $item_id => $item ) {
112
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
113
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
114
-		}
115
-
116
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
117
-
118
-	}
119
-
120
-	/**
121
-	 * Adds items to a response for submission refresh prices.
122
-	 *
123
-	 * @param GetPaid_Payment_Form_Submission $submission
124
-	 */
125
-	public function add_items( $submission ) {
126
-
127
-		// Add items.
128
-		$items = array();
32
+        );
33
+
34
+        $this->add_totals( $submission );
35
+        $this->add_texts( $submission );
36
+        $this->add_items( $submission );
37
+        $this->add_fees( $submission );
38
+        $this->add_discounts( $submission );
39
+        $this->add_taxes( $submission );
40
+        $this->add_gateways( $submission );
41
+
42
+    }
43
+
44
+    /**
45
+     * Adds totals to a response for submission refresh prices.
46
+     *
47
+     * @param GetPaid_Payment_Form_Submission $submission
48
+     */
49
+    public function add_totals( $submission ) {
50
+
51
+        $this->response = array_merge(
52
+            $this->response,
53
+            array(
54
+
55
+                'totals'        => array(
56
+                    'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
+                    'discount'  => $submission->format_amount( $submission->get_discount() ),
58
+                    'fees'      => $submission->format_amount( $submission->get_fee() ),
59
+                    'tax'       => $submission->format_amount( $submission->get_tax() ),
60
+                    'total'     => $submission->format_amount( $submission->get_total() ),
61
+                    'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
+                ),
63
+
64
+                'recurring'     => array(
65
+                    'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
+                    'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
+                    'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
+                    'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
+                    'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
+                ),
71
+
72
+                'initial_amt'   => wpinv_round_amount( $submission->get_total(), null, true ),
73
+                'currency'      => $submission->get_currency(),
74
+
75
+            )
76
+        );
77
+
78
+    }
79
+
80
+    /**
81
+     * Adds texts to a response for submission refresh prices.
82
+     *
83
+     * @param GetPaid_Payment_Form_Submission $submission
84
+     */
85
+    public function add_texts( $submission ) {
86
+
87
+        $payable = $submission->format_amount( $submission->get_total() );
88
+
89
+        if ( $submission->has_recurring != 0 ) {
90
+
91
+            $recurring = new WPInv_Item( $submission->has_recurring );
92
+            $period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
93
+
94
+            if ( $submission->get_total() == $submission->get_recurring_total() ) {
95
+                $payable = "$payable / $period";
96
+            } else {
97
+                $payable = sprintf(
98
+                    __( '%1$s (renews at %2$s / %3$s)'),
99
+                    $submission->format_amount( $submission->get_total() ),
100
+                    $submission->format_amount( $submission->get_recurring_total() ),
101
+                    $period
102
+                );
103
+            }
104
+
105
+        }
106
+
107
+        $texts = array(
108
+            '.getpaid-checkout-total-payable' => $payable,
109
+        );
129 110
 
130 111
         foreach ( $submission->get_items() as $item_id => $item ) {
131
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
132
-		}
112
+            $texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
113
+            $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
114
+        }
133 115
 
134
-		$this->response = array_merge(
135
-			$this->response,
136
-			array( 'items' => $items )
137
-		);
116
+        $this->response = array_merge( $this->response, array( 'texts' => $texts ) );
138 117
 
139
-	}
118
+    }
140 119
 
141
-	/**
142
-	 * Adds fees to a response for submission refresh prices.
143
-	 *
144
-	 * @param GetPaid_Payment_Form_Submission $submission
145
-	 */
146
-	public function add_fees( $submission ) {
120
+    /**
121
+     * Adds items to a response for submission refresh prices.
122
+     *
123
+     * @param GetPaid_Payment_Form_Submission $submission
124
+     */
125
+    public function add_items( $submission ) {
126
+
127
+        // Add items.
128
+        $items = array();
129
+
130
+        foreach ( $submission->get_items() as $item_id => $item ) {
131
+            $items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
132
+        }
133
+
134
+        $this->response = array_merge(
135
+            $this->response,
136
+            array( 'items' => $items )
137
+        );
138
+
139
+    }
147 140
 
148
-		$fees = array();
141
+    /**
142
+     * Adds fees to a response for submission refresh prices.
143
+     *
144
+     * @param GetPaid_Payment_Form_Submission $submission
145
+     */
146
+    public function add_fees( $submission ) {
147
+
148
+        $fees = array();
149 149
 
150 150
         foreach ( $submission->get_fees() as $name => $data ) {
151
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
152
-		}
151
+            $fees[$name] = $submission->format_amount( $data['initial_fee'] );
152
+        }
153 153
 
154
-		$this->response = array_merge(
155
-			$this->response,
156
-			array( 'fees' => $fees )
157
-		);
154
+        $this->response = array_merge(
155
+            $this->response,
156
+            array( 'fees' => $fees )
157
+        );
158 158
 
159
-	}
159
+    }
160 160
 
161
-	/**
162
-	 * Adds discounts to a response for submission refresh prices.
163
-	 *
164
-	 * @param GetPaid_Payment_Form_Submission $submission
165
-	 */
166
-	public function add_discounts( $submission ) {
161
+    /**
162
+     * Adds discounts to a response for submission refresh prices.
163
+     *
164
+     * @param GetPaid_Payment_Form_Submission $submission
165
+     */
166
+    public function add_discounts( $submission ) {
167 167
 
168
-		$discounts = array();
168
+        $discounts = array();
169 169
 
170 170
         foreach ( $submission->get_discounts() as $name => $data ) {
171
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
172
-		}
171
+            $discounts[$name] = $submission->format_amount( $data['initial_discount'] );
172
+        }
173 173
 
174
-		$this->response = array_merge(
175
-			$this->response,
176
-			array( 'discounts' => $discounts )
177
-		);
174
+        $this->response = array_merge(
175
+            $this->response,
176
+            array( 'discounts' => $discounts )
177
+        );
178 178
 
179
-	}
179
+    }
180 180
 
181
-	/**
182
-	 * Adds taxes to a response for submission refresh prices.
183
-	 *
184
-	 * @param GetPaid_Payment_Form_Submission $submission
185
-	 */
186
-	public function add_taxes( $submission ) {
187
-
188
-		$taxes  = array();
189
-		$markup = '';
181
+    /**
182
+     * Adds taxes to a response for submission refresh prices.
183
+     *
184
+     * @param GetPaid_Payment_Form_Submission $submission
185
+     */
186
+    public function add_taxes( $submission ) {
187
+
188
+        $taxes  = array();
189
+        $markup = '';
190 190
         foreach ( $submission->get_taxes() as $name => $data ) {
191
-			$name          = sanitize_text_field( $name );
192
-			$amount        = $submission->format_amount( $data['initial_tax'] );
193
-			$taxes[$name]  = $amount;
194
-			$markup       .= "<small class='form-text'>$name : $amount</small>";
195
-		}
191
+            $name          = sanitize_text_field( $name );
192
+            $amount        = $submission->format_amount( $data['initial_tax'] );
193
+            $taxes[$name]  = $amount;
194
+            $markup       .= "<small class='form-text'>$name : $amount</small>";
195
+        }
196 196
 
197
-		if ( wpinv_display_individual_tax_rates() ) {
198
-			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
199
-		}
197
+        if ( wpinv_display_individual_tax_rates() ) {
198
+            $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
199
+        }
200 200
 
201
-		$this->response = array_merge(
202
-			$this->response,
203
-			array( 'taxes' => $taxes )
204
-		);
201
+        $this->response = array_merge(
202
+            $this->response,
203
+            array( 'taxes' => $taxes )
204
+        );
205 205
 
206
-	}
206
+    }
207 207
 
208
-	/**
209
-	 * Adds gateways to a response for submission refresh prices.
210
-	 *
211
-	 * @param GetPaid_Payment_Form_Submission $submission
212
-	 */
213
-	public function add_gateways( $submission ) {
208
+    /**
209
+     * Adds gateways to a response for submission refresh prices.
210
+     *
211
+     * @param GetPaid_Payment_Form_Submission $submission
212
+     */
213
+    public function add_gateways( $submission ) {
214 214
 
215
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
215
+        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
216 216
 
217
-		if ( $this->response['has_recurring'] ) {
217
+        if ( $this->response['has_recurring'] ) {
218 218
 
219
-			foreach ( $gateways as $i => $gateway ) {
219
+            foreach ( $gateways as $i => $gateway ) {
220 220
 
221
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
222
-					unset( $gateways[ $i ] );
223
-				}
221
+                if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
222
+                    unset( $gateways[ $i ] );
223
+                }
224 224
 
225
-			}
225
+            }
226 226
 
227
-		}
227
+        }
228 228
 
229 229
 
230
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
231
-		$this->response = array_merge(
232
-			$this->response,
233
-			array( 'gateways' => $gateways )
234
-		);
230
+        $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
231
+        $this->response = array_merge(
232
+            $this->response,
233
+            array( 'gateways' => $gateways )
234
+        );
235 235
 
236
-	}
236
+    }
237 237
 
238 238
 }
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 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
  * Payment form submission refresh prices class
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$this->response = array(
29 29
 			'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31
-            'is_free'       => ! $submission->should_collect_payment_details(),
31
+            'is_free'       => !$submission->should_collect_payment_details(),
32 32
 		);
33 33
 
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
34
+		$this->add_totals($submission);
35
+		$this->add_texts($submission);
36
+		$this->add_items($submission);
37
+		$this->add_fees($submission);
38
+		$this->add_discounts($submission);
39
+		$this->add_taxes($submission);
40
+		$this->add_gateways($submission);
41 41
 
42 42
 	}
43 43
 
@@ -46,30 +46,30 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param GetPaid_Payment_Form_Submission $submission
48 48
 	 */
49
-	public function add_totals( $submission ) {
49
+	public function add_totals($submission) {
50 50
 
51 51
 		$this->response = array_merge(
52 52
 			$this->response,
53 53
 			array(
54 54
 
55 55
 				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
56
+					'subtotal'  => $submission->format_amount($submission->get_subtotal()),
57
+					'discount'  => $submission->format_amount($submission->get_discount()),
58
+					'fees'      => $submission->format_amount($submission->get_fee()),
59
+					'tax'       => $submission->format_amount($submission->get_tax()),
60
+					'total'     => $submission->format_amount($submission->get_total()),
61
+					'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES),
62 62
 				),
63 63
 
64 64
 				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
65
+					'subtotal'  => $submission->format_amount($submission->get_recurring_subtotal()),
66
+					'discount'  => $submission->format_amount($submission->get_recurring_discount()),
67
+					'fees'      => $submission->format_amount($submission->get_recurring_fee()),
68
+					'tax'       => $submission->format_amount($submission->get_recurring_tax()),
69
+					'total'     => $submission->format_amount($submission->get_recurring_total()),
70 70
 				),
71 71
 
72
-				'initial_amt'   => wpinv_round_amount( $submission->get_total(), null, true ),
72
+				'initial_amt'   => wpinv_round_amount($submission->get_total(), null, true),
73 73
 				'currency'      => $submission->get_currency(),
74 74
 
75 75
 			)
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @param GetPaid_Payment_Form_Submission $submission
84 84
 	 */
85
-	public function add_texts( $submission ) {
85
+	public function add_texts($submission) {
86 86
 
87
-		$payable = $submission->format_amount( $submission->get_total() );
87
+		$payable = $submission->format_amount($submission->get_total());
88 88
 
89
-		if ( $submission->has_recurring != 0 ) {
89
+		if ($submission->has_recurring != 0) {
90 90
 
91
-			$recurring = new WPInv_Item( $submission->has_recurring );
92
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
91
+			$recurring = new WPInv_Item($submission->has_recurring);
92
+			$period    = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), '');
93 93
 
94
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
94
+			if ($submission->get_total() == $submission->get_recurring_total()) {
95 95
 				$payable = "$payable / $period";
96 96
 			} else {
97 97
 				$payable = sprintf(
98
-					__( '%1$s (renews at %2$s / %3$s)'),
99
-					$submission->format_amount( $submission->get_total() ),
100
-					$submission->format_amount( $submission->get_recurring_total() ),
98
+					__('%1$s (renews at %2$s / %3$s)'),
99
+					$submission->format_amount($submission->get_total()),
100
+					$submission->format_amount($submission->get_recurring_total()),
101 101
 					$period
102 102
 				);
103 103
 			}
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 			'.getpaid-checkout-total-payable' => $payable,
109 109
 		);
110 110
 
111
-		foreach ( $submission->get_items() as $item_id => $item ) {
112
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
113
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
111
+		foreach ($submission->get_items() as $item_id => $item) {
112
+			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount($item->get_sub_total());
113
+			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total());
114 114
 		}
115 115
 
116
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
116
+		$this->response = array_merge($this->response, array('texts' => $texts));
117 117
 
118 118
 	}
119 119
 
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param GetPaid_Payment_Form_Submission $submission
124 124
 	 */
125
-	public function add_items( $submission ) {
125
+	public function add_items($submission) {
126 126
 
127 127
 		// Add items.
128 128
 		$items = array();
129 129
 
130
-        foreach ( $submission->get_items() as $item_id => $item ) {
131
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
130
+        foreach ($submission->get_items() as $item_id => $item) {
131
+			$items["$item_id"] = $submission->format_amount($item->get_sub_total());
132 132
 		}
133 133
 
134 134
 		$this->response = array_merge(
135 135
 			$this->response,
136
-			array( 'items' => $items )
136
+			array('items' => $items)
137 137
 		);
138 138
 
139 139
 	}
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param GetPaid_Payment_Form_Submission $submission
145 145
 	 */
146
-	public function add_fees( $submission ) {
146
+	public function add_fees($submission) {
147 147
 
148 148
 		$fees = array();
149 149
 
150
-        foreach ( $submission->get_fees() as $name => $data ) {
151
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
150
+        foreach ($submission->get_fees() as $name => $data) {
151
+			$fees[$name] = $submission->format_amount($data['initial_fee']);
152 152
 		}
153 153
 
154 154
 		$this->response = array_merge(
155 155
 			$this->response,
156
-			array( 'fees' => $fees )
156
+			array('fees' => $fees)
157 157
 		);
158 158
 
159 159
 	}
@@ -163,17 +163,17 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @param GetPaid_Payment_Form_Submission $submission
165 165
 	 */
166
-	public function add_discounts( $submission ) {
166
+	public function add_discounts($submission) {
167 167
 
168 168
 		$discounts = array();
169 169
 
170
-        foreach ( $submission->get_discounts() as $name => $data ) {
171
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
170
+        foreach ($submission->get_discounts() as $name => $data) {
171
+			$discounts[$name] = $submission->format_amount($data['initial_discount']);
172 172
 		}
173 173
 
174 174
 		$this->response = array_merge(
175 175
 			$this->response,
176
-			array( 'discounts' => $discounts )
176
+			array('discounts' => $discounts)
177 177
 		);
178 178
 
179 179
 	}
@@ -183,24 +183,24 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param GetPaid_Payment_Form_Submission $submission
185 185
 	 */
186
-	public function add_taxes( $submission ) {
186
+	public function add_taxes($submission) {
187 187
 
188 188
 		$taxes  = array();
189 189
 		$markup = '';
190
-        foreach ( $submission->get_taxes() as $name => $data ) {
191
-			$name          = sanitize_text_field( $name );
192
-			$amount        = $submission->format_amount( $data['initial_tax'] );
190
+        foreach ($submission->get_taxes() as $name => $data) {
191
+			$name          = sanitize_text_field($name);
192
+			$amount        = $submission->format_amount($data['initial_tax']);
193 193
 			$taxes[$name]  = $amount;
194 194
 			$markup       .= "<small class='form-text'>$name : $amount</small>";
195 195
 		}
196 196
 
197
-		if ( wpinv_display_individual_tax_rates() ) {
197
+		if (wpinv_display_individual_tax_rates()) {
198 198
 			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
199 199
 		}
200 200
 
201 201
 		$this->response = array_merge(
202 202
 			$this->response,
203
-			array( 'taxes' => $taxes )
203
+			array('taxes' => $taxes)
204 204
 		);
205 205
 
206 206
 	}
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
 	 *
211 211
 	 * @param GetPaid_Payment_Form_Submission $submission
212 212
 	 */
213
-	public function add_gateways( $submission ) {
213
+	public function add_gateways($submission) {
214 214
 
215
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
215
+		$gateways = array_keys(wpinv_get_enabled_payment_gateways());
216 216
 
217
-		if ( $this->response['has_recurring'] ) {
217
+		if ($this->response['has_recurring']) {
218 218
 
219
-			foreach ( $gateways as $i => $gateway ) {
219
+			foreach ($gateways as $i => $gateway) {
220 220
 
221
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
222
-					unset( $gateways[ $i ] );
221
+				if (!wpinv_gateway_support_subscription($gateway)) {
222
+					unset($gateways[$i]);
223 223
 				}
224 224
 
225 225
 			}
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 		}
228 228
 
229 229
 
230
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
230
+		$gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission);
231 231
 		$this->response = array_merge(
232 232
 			$this->response,
233
-			array( 'gateways' => $gateways )
233
+			array('gateways' => $gateways)
234 234
 		);
235 235
 
236 236
 	}
Please login to merge, or discard this patch.
templates/payment-forms/elements/billing_email.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 $value = '';
13 13
 $class = '';
14 14
 
15
-if ( ! empty( $form->invoice ) ) {
16
-    $value   = sanitize_email( $form->invoice->get_email() );
17
-} else if ( is_user_logged_in() ) {
15
+if (!empty($form->invoice)) {
16
+    $value = sanitize_email($form->invoice->get_email());
17
+} else if (is_user_logged_in()) {
18 18
     $user  = wp_get_current_user();
19
-    $value = sanitize_email( $user->user_email );
19
+    $value = sanitize_email($user->user_email);
20 20
 }
21 21
 
22
-if ( ! empty( $value ) && ! empty( $hide_billing_email ) ) {
22
+if (!empty($value) && !empty($hide_billing_email)) {
23 23
     $class = 'd-none';
24 24
 }
25 25
 
26
-do_action( 'getpaid_before_payment_form_billing_email', $form );
26
+do_action('getpaid_before_payment_form_billing_email', $form);
27 27
 
28 28
 echo "<span class='$class'>";
29 29
 
30 30
 echo aui()->input(
31 31
     array(
32 32
         'name'       => 'billing_email',
33
-        'id'         => esc_attr( $id ) . uniqid( '_' ),
34
-        'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ),
35
-        'required'   => ! empty( $required ),
36
-        'label'      => empty( $label ) ? '' : wp_kses_post( $label ) . '<span class="text-danger"> *</span>',
33
+        'id'         => esc_attr($id) . uniqid('_'),
34
+        'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder),
35
+        'required'   => !empty($required),
36
+        'label'      => empty($label) ? '' : wp_kses_post($label) . '<span class="text-danger"> *</span>',
37 37
         'label_type' => 'vertical',
38
-        'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
38
+        'help_text'  => empty($description) ? '' : wp_kses_post($description),
39 39
         'type'       => 'email',
40 40
         'value'      => $value,
41 41
         'class'      => 'wpinv_billing_email',
@@ -47,4 +47,4 @@  discard block
 block discarded – undo
47 47
 
48 48
 echo '</span>';
49 49
 
50
-do_action( 'getpaid_after_payment_form_billing_email', $form );
50
+do_action('getpaid_after_payment_form_billing_email', $form);
Please login to merge, or discard this patch.