Passed
Push — master ( 1ce22f...41fbb9 )
by Brian
09:44 queued 04:28
created
includes/admin/register-settings.php 1 patch
Indentation   +341 added lines, -341 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   = esc_attr( $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   = esc_attr( $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(
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
         }
280 280
 
281 281
         // General filter
282
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
282
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
283 283
 
284
-		// Key specific filter.
285
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
284
+        // Key specific filter.
285
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
286 286
     }
287 287
 
288 288
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -427,333 +427,333 @@  discard block
 block discarded – undo
427 427
 }
428 428
 
429 429
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
430
-	$pages_options = array();
430
+    $pages_options = array();
431 431
 
432
-	if( $default_label !== NULL && $default_label !== false ) {
433
-		$pages_options = array( '' => $default_label ); // Blank option
434
-	}
432
+    if( $default_label !== NULL && $default_label !== false ) {
433
+        $pages_options = array( '' => $default_label ); // Blank option
434
+    }
435 435
 
436
-	$pages = get_pages();
437
-	if ( $pages ) {
438
-		foreach ( $pages as $page ) {
439
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
436
+    $pages = get_pages();
437
+    if ( $pages ) {
438
+        foreach ( $pages as $page ) {
439
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
440 440
             $pages_options[ $page->ID ] = $title;
441
-		}
442
-	}
441
+        }
442
+    }
443 443
 
444
-	return $pages_options;
444
+    return $pages_options;
445 445
 }
446 446
 
447 447
 function wpinv_header_callback( $args ) {
448
-	if ( !empty( $args['desc'] ) ) {
448
+    if ( !empty( $args['desc'] ) ) {
449 449
         echo $args['desc'];
450 450
     }
451 451
 }
452 452
 
453 453
 function wpinv_hidden_callback( $args ) {
454
-	global $wpinv_options;
455
-
456
-	if ( isset( $args['set_value'] ) ) {
457
-		$value = $args['set_value'];
458
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
459
-		$value = $wpinv_options[ $args['id'] ];
460
-	} else {
461
-		$value = isset( $args['std'] ) ? $args['std'] : '';
462
-	}
463
-
464
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
465
-		$args['readonly'] = true;
466
-		$value = isset( $args['std'] ) ? $args['std'] : '';
467
-		$name  = '';
468
-	} else {
469
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
470
-	}
471
-
472
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
454
+    global $wpinv_options;
455
+
456
+    if ( isset( $args['set_value'] ) ) {
457
+        $value = $args['set_value'];
458
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
459
+        $value = $wpinv_options[ $args['id'] ];
460
+    } else {
461
+        $value = isset( $args['std'] ) ? $args['std'] : '';
462
+    }
463
+
464
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
465
+        $args['readonly'] = true;
466
+        $value = isset( $args['std'] ) ? $args['std'] : '';
467
+        $name  = '';
468
+    } else {
469
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
470
+    }
471
+
472
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
473 473
     
474
-	echo $html;
474
+    echo $html;
475 475
 }
476 476
 
477 477
 function wpinv_checkbox_callback( $args ) {
478
-	global $wpinv_options;
478
+    global $wpinv_options;
479 479
     
480 480
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
481 481
 
482
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
483
-		$name = '';
484
-	} else {
485
-		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
486
-	}
482
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
483
+        $name = '';
484
+    } else {
485
+        $name = 'name="wpinv_settings[' . $sanitize_id . ']"';
486
+    }
487 487
 
488
-	$std     = isset( $args['std'] ) ? $args['std'] : 0;
489
-	$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
490
-	$checked = checked( empty( $value ), false, false );
488
+    $std     = isset( $args['std'] ) ? $args['std'] : 0;
489
+    $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
490
+    $checked = checked( empty( $value ), false, false );
491 491
 
492
-	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
493
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
492
+    $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
493
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
494 494
 
495
-	echo $html;
495
+    echo $html;
496 496
 }
497 497
 
498 498
 function wpinv_multicheck_callback( $args ) {
499
-	global $wpinv_options;
499
+    global $wpinv_options;
500 500
 
501
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
502
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
501
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
502
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
503 503
 
504
-	if ( ! empty( $args['options'] ) ) {
504
+    if ( ! empty( $args['options'] ) ) {
505 505
 
506
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
507
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
506
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
507
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
508 508
 
509
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
509
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
510 510
         foreach( $args['options'] as $key => $option ):
511
-			$sanitize_key = wpinv_sanitize_key( $key );
512
-			if ( in_array( $sanitize_key, $value ) ) { 
513
-				$enabled = $sanitize_key;
514
-			} else { 
515
-				$enabled = NULL; 
516
-			}
517
-			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;';
518
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
519
-		endforeach;
520
-		echo '</div>';
521
-		echo '<p class="description">' . $args['desc'] . '</p>';
522
-	}
511
+            $sanitize_key = wpinv_sanitize_key( $key );
512
+            if ( in_array( $sanitize_key, $value ) ) { 
513
+                $enabled = $sanitize_key;
514
+            } else { 
515
+                $enabled = NULL; 
516
+            }
517
+            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;';
518
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
519
+        endforeach;
520
+        echo '</div>';
521
+        echo '<p class="description">' . $args['desc'] . '</p>';
522
+    }
523 523
 }
524 524
 
525 525
 function wpinv_payment_icons_callback( $args ) {
526
-	global $wpinv_options;
526
+    global $wpinv_options;
527 527
     
528 528
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
529 529
 
530
-	if ( ! empty( $args['options'] ) ) {
531
-		foreach( $args['options'] as $key => $option ) {
530
+    if ( ! empty( $args['options'] ) ) {
531
+        foreach( $args['options'] as $key => $option ) {
532 532
             $sanitize_key = wpinv_sanitize_key( $key );
533 533
             
534
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
535
-				$enabled = $option;
536
-			} else {
537
-				$enabled = NULL;
538
-			}
539
-
540
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541
-
542
-				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;';
543
-
544
-				if ( wpinv_string_is_image_url( $key ) ) {
545
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546
-				} else {
547
-					$card = strtolower( str_replace( ' ', '', $option ) );
548
-
549
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
551
-					} else {
552
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
553
-						$content_dir = WP_CONTENT_DIR;
554
-
555
-						if ( function_exists( 'wp_normalize_path' ) ) {
556
-							// Replaces backslashes with forward slashes for Windows systems
557
-							$image = wp_normalize_path( $image );
558
-							$content_dir = wp_normalize_path( $content_dir );
559
-						}
560
-
561
-						$image = str_replace( $content_dir, content_url(), $image );
562
-					}
563
-
564
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565
-				}
566
-			echo $option . '</label>';
567
-		}
568
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
569
-	}
534
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
535
+                $enabled = $option;
536
+            } else {
537
+                $enabled = NULL;
538
+            }
539
+
540
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541
+
542
+                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;';
543
+
544
+                if ( wpinv_string_is_image_url( $key ) ) {
545
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546
+                } else {
547
+                    $card = strtolower( str_replace( ' ', '', $option ) );
548
+
549
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
551
+                    } else {
552
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
553
+                        $content_dir = WP_CONTENT_DIR;
554
+
555
+                        if ( function_exists( 'wp_normalize_path' ) ) {
556
+                            // Replaces backslashes with forward slashes for Windows systems
557
+                            $image = wp_normalize_path( $image );
558
+                            $content_dir = wp_normalize_path( $content_dir );
559
+                        }
560
+
561
+                        $image = str_replace( $content_dir, content_url(), $image );
562
+                    }
563
+
564
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565
+                }
566
+            echo $option . '</label>';
567
+        }
568
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
569
+    }
570 570
 }
571 571
 
572 572
 function wpinv_radio_callback( $args ) {
573
-	global $wpinv_options;
573
+    global $wpinv_options;
574 574
     
575 575
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
576 576
     
577 577
     foreach ( $args['options'] as $key => $option ) :
578
-		$sanitize_key = wpinv_sanitize_key( $key );
578
+        $sanitize_key = wpinv_sanitize_key( $key );
579 579
         
580 580
         $checked = false;
581 581
 
582
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
583
-			$checked = true;
584
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
585
-			$checked = true;
582
+        if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
583
+            $checked = true;
584
+        elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
585
+            $checked = true;
586 586
 
587
-		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
588
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
589
-	endforeach;
587
+        echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
588
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
589
+    endforeach;
590 590
 
591
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
591
+    echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
592 592
 }
593 593
 
594 594
 function wpinv_gateways_callback( $args ) {
595
-	global $wpinv_options;
595
+    global $wpinv_options;
596 596
     
597 597
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
598 598
 
599
-	foreach ( $args['options'] as $key => $option ) :
600
-		$sanitize_key = wpinv_sanitize_key( $key );
599
+    foreach ( $args['options'] as $key => $option ) :
600
+        $sanitize_key = wpinv_sanitize_key( $key );
601 601
         
602 602
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
603
-			$enabled = '1';
604
-		else
605
-			$enabled = null;
603
+            $enabled = '1';
604
+        else
605
+            $enabled = null;
606 606
 
607
-		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;';
608
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
609
-	endforeach;
607
+        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;';
608
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
609
+    endforeach;
610 610
 }
611 611
 
612 612
 function wpinv_gateway_select_callback($args) {
613
-	global $wpinv_options;
613
+    global $wpinv_options;
614 614
     
615 615
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
616 616
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
617 617
 
618
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
618
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
619 619
 
620
-	foreach ( $args['options'] as $key => $option ) :
621
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
620
+    foreach ( $args['options'] as $key => $option ) :
621
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
622 622
             $selected = selected( $key, $args['selected'], false );
623 623
         } else {
624 624
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
625 625
         }
626
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
627
-	endforeach;
626
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
627
+    endforeach;
628 628
 
629
-	echo '</select>';
630
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
629
+    echo '</select>';
630
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
631 631
 }
632 632
 
633 633
 function wpinv_text_callback( $args ) {
634
-	global $wpinv_options;
634
+    global $wpinv_options;
635 635
     
636 636
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
637 637
 
638
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
639
-		$value = $wpinv_options[ $args['id'] ];
640
-	} else {
641
-		$value = isset( $args['std'] ) ? $args['std'] : '';
642
-	}
643
-
644
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
645
-		$args['readonly'] = true;
646
-		$value = isset( $args['std'] ) ? $args['std'] : '';
647
-		$name  = '';
648
-	} else {
649
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
650
-	}
651
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
652
-
653
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
654
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
655
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
656
-	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
657
-
658
-	echo $html;
638
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
639
+        $value = $wpinv_options[ $args['id'] ];
640
+    } else {
641
+        $value = isset( $args['std'] ) ? $args['std'] : '';
642
+    }
643
+
644
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
645
+        $args['readonly'] = true;
646
+        $value = isset( $args['std'] ) ? $args['std'] : '';
647
+        $name  = '';
648
+    } else {
649
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
650
+    }
651
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
652
+
653
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
654
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
655
+    $html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
656
+    $html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
657
+
658
+    echo $html;
659 659
 }
660 660
 
661 661
 function wpinv_number_callback( $args ) {
662
-	global $wpinv_options;
662
+    global $wpinv_options;
663 663
     
664 664
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
665 665
 
666
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
667
-		$value = $wpinv_options[ $args['id'] ];
668
-	} else {
669
-		$value = isset( $args['std'] ) ? $args['std'] : '';
670
-	}
671
-
672
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
673
-		$args['readonly'] = true;
674
-		$value = isset( $args['std'] ) ? $args['std'] : '';
675
-		$name  = '';
676
-	} else {
677
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
678
-	}
679
-
680
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
681
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
682
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
683
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
684
-
685
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
686
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
687
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
688
-
689
-	echo $html;
666
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
667
+        $value = $wpinv_options[ $args['id'] ];
668
+    } else {
669
+        $value = isset( $args['std'] ) ? $args['std'] : '';
670
+    }
671
+
672
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
673
+        $args['readonly'] = true;
674
+        $value = isset( $args['std'] ) ? $args['std'] : '';
675
+        $name  = '';
676
+    } else {
677
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
678
+    }
679
+
680
+    $max  = isset( $args['max'] ) ? $args['max'] : 999999;
681
+    $min  = isset( $args['min'] ) ? $args['min'] : 0;
682
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
683
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
684
+
685
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
686
+    $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
687
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
688
+
689
+    echo $html;
690 690
 }
691 691
 
692 692
 function wpinv_textarea_callback( $args ) {
693
-	global $wpinv_options;
693
+    global $wpinv_options;
694 694
     
695 695
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
696 696
 
697
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
698
-		$value = $wpinv_options[ $args['id'] ];
699
-	} else {
700
-		$value = isset( $args['std'] ) ? $args['std'] : '';
701
-	}
697
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
698
+        $value = $wpinv_options[ $args['id'] ];
699
+    } else {
700
+        $value = isset( $args['std'] ) ? $args['std'] : '';
701
+    }
702 702
     
703 703
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
704 704
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
705 705
 
706
-	$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>';
707
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
706
+    $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>';
707
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
708 708
 
709
-	echo $html;
709
+    echo $html;
710 710
 }
711 711
 
712 712
 function wpinv_password_callback( $args ) {
713
-	global $wpinv_options;
713
+    global $wpinv_options;
714 714
     
715 715
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
716 716
 
717
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
718
-		$value = $wpinv_options[ $args['id'] ];
719
-	} else {
720
-		$value = isset( $args['std'] ) ? $args['std'] : '';
721
-	}
717
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
718
+        $value = $wpinv_options[ $args['id'] ];
719
+    } else {
720
+        $value = isset( $args['std'] ) ? $args['std'] : '';
721
+    }
722 722
 
723
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
724
-	$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 ) . '"/>';
725
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
723
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
724
+    $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 ) . '"/>';
725
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
726 726
 
727
-	echo $html;
727
+    echo $html;
728 728
 }
729 729
 
730 730
 function wpinv_missing_callback($args) {
731
-	printf(
732
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
733
-		'<strong>' . $args['id'] . '</strong>'
734
-	);
731
+    printf(
732
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
733
+        '<strong>' . $args['id'] . '</strong>'
734
+    );
735 735
 }
736 736
 
737 737
 function wpinv_select_callback($args) {
738
-	global $wpinv_options;
738
+    global $wpinv_options;
739 739
     
740 740
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
741 741
 
742
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
743
-		$value = $wpinv_options[ $args['id'] ];
744
-	} else {
745
-		$value = isset( $args['std'] ) ? $args['std'] : '';
746
-	}
742
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
743
+        $value = $wpinv_options[ $args['id'] ];
744
+    } else {
745
+        $value = isset( $args['std'] ) ? $args['std'] : '';
746
+    }
747 747
     
748 748
     if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
749 749
         $value = $args['selected'];
750 750
     }
751 751
 
752
-	if ( isset( $args['placeholder'] ) ) {
753
-		$placeholder = $args['placeholder'];
754
-	} else {
755
-		$placeholder = '';
756
-	}
752
+    if ( isset( $args['placeholder'] ) ) {
753
+        $placeholder = $args['placeholder'];
754
+    } else {
755
+        $placeholder = '';
756
+    }
757 757
     
758 758
     if( !empty( $args['onchange'] ) ) {
759 759
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
@@ -763,143 +763,143 @@  discard block
 block discarded – undo
763 763
 
764 764
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
765 765
 
766
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
766
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
767 767
 
768
-	foreach ( $args['options'] as $option => $name ) {
769
-		$selected = selected( $option, $value, false );
770
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
771
-	}
768
+    foreach ( $args['options'] as $option => $name ) {
769
+        $selected = selected( $option, $value, false );
770
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
771
+    }
772 772
 
773
-	$html .= '</select>';
774
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
773
+    $html .= '</select>';
774
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
775 775
 
776
-	echo $html;
776
+    echo $html;
777 777
 }
778 778
 
779 779
 function wpinv_color_select_callback( $args ) {
780
-	global $wpinv_options;
780
+    global $wpinv_options;
781 781
     
782 782
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
783 783
 
784
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
785
-		$value = $wpinv_options[ $args['id'] ];
786
-	} else {
787
-		$value = isset( $args['std'] ) ? $args['std'] : '';
788
-	}
784
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
785
+        $value = $wpinv_options[ $args['id'] ];
786
+    } else {
787
+        $value = isset( $args['std'] ) ? $args['std'] : '';
788
+    }
789 789
 
790
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
790
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
791 791
 
792
-	foreach ( $args['options'] as $option => $color ) {
793
-		$selected = selected( $option, $value, false );
794
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
795
-	}
792
+    foreach ( $args['options'] as $option => $color ) {
793
+        $selected = selected( $option, $value, false );
794
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
795
+    }
796 796
 
797
-	$html .= '</select>';
798
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
797
+    $html .= '</select>';
798
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
799 799
 
800
-	echo $html;
800
+    echo $html;
801 801
 }
802 802
 
803 803
 function wpinv_rich_editor_callback( $args ) {
804
-	global $wpinv_options, $wp_version;
804
+    global $wpinv_options, $wp_version;
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'] ];
808
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
+        $value = $wpinv_options[ $args['id'] ];
810 810
 
811
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
812
-			$value = isset( $args['std'] ) ? $args['std'] : '';
813
-		}
814
-	} else {
815
-		$value = isset( $args['std'] ) ? $args['std'] : '';
816
-	}
811
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
812
+            $value = isset( $args['std'] ) ? $args['std'] : '';
813
+        }
814
+    } else {
815
+        $value = isset( $args['std'] ) ? $args['std'] : '';
816
+    }
817 817
 
818
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
818
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
819 819
 
820
-	$html = '<div class="getpaid-settings-editor-input">';
821
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
822
-		ob_start();
823
-		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 ) );
824
-		$html .= ob_get_clean();
825
-	} else {
826
-		$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>';
827
-	}
820
+    $html = '<div class="getpaid-settings-editor-input">';
821
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
822
+        ob_start();
823
+        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 ) );
824
+        $html .= ob_get_clean();
825
+    } else {
826
+        $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>';
827
+    }
828 828
 
829
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
829
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
830 830
 
831
-	echo $html;
831
+    echo $html;
832 832
 }
833 833
 
834 834
 function wpinv_upload_callback( $args ) {
835
-	global $wpinv_options;
835
+    global $wpinv_options;
836 836
     
837 837
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
838 838
 
839
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
840
-		$value = $wpinv_options[$args['id']];
841
-	} else {
842
-		$value = isset($args['std']) ? $args['std'] : '';
843
-	}
839
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
840
+        $value = $wpinv_options[$args['id']];
841
+    } else {
842
+        $value = isset($args['std']) ? $args['std'] : '';
843
+    }
844 844
 
845
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
846
-	$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 ) ) . '"/>';
847
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
848
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
845
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
846
+    $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 ) ) . '"/>';
847
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
848
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
849 849
 
850
-	echo $html;
850
+    echo $html;
851 851
 }
852 852
 
853 853
 function wpinv_color_callback( $args ) {
854
-	global $wpinv_options;
854
+    global $wpinv_options;
855 855
     
856 856
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
857 857
 
858
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
859
-		$value = $wpinv_options[ $args['id'] ];
860
-	} else {
861
-		$value = isset( $args['std'] ) ? $args['std'] : '';
862
-	}
858
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
859
+        $value = $wpinv_options[ $args['id'] ];
860
+    } else {
861
+        $value = isset( $args['std'] ) ? $args['std'] : '';
862
+    }
863 863
 
864
-	$default = isset( $args['std'] ) ? $args['std'] : '';
864
+    $default = isset( $args['std'] ) ? $args['std'] : '';
865 865
 
866
-	$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 ) . '" />';
867
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
866
+    $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 ) . '" />';
867
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
868 868
 
869
-	echo $html;
869
+    echo $html;
870 870
 }
871 871
 
872 872
 function wpinv_country_states_callback($args) {
873
-	global $wpinv_options;
873
+    global $wpinv_options;
874 874
     
875 875
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
876 876
 
877
-	if ( isset( $args['placeholder'] ) ) {
878
-		$placeholder = $args['placeholder'];
879
-	} else {
880
-		$placeholder = '';
881
-	}
877
+    if ( isset( $args['placeholder'] ) ) {
878
+        $placeholder = $args['placeholder'];
879
+    } else {
880
+        $placeholder = '';
881
+    }
882 882
 
883
-	$states = wpinv_get_country_states();
883
+    $states = wpinv_get_country_states();
884 884
 
885
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
886
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
885
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
886
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
887 887
 
888
-	foreach ( $states as $option => $name ) {
889
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
890
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
891
-	}
888
+    foreach ( $states as $option => $name ) {
889
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
890
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
891
+    }
892 892
 
893
-	$html .= '</select>';
894
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
893
+    $html .= '</select>';
894
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
895 895
 
896
-	echo $html;
896
+    echo $html;
897 897
 }
898 898
 
899 899
 function wpinv_tax_rates_callback($args) {
900
-	global $wpinv_options;
901
-	$rates = wpinv_get_tax_rates();
902
-	ob_start(); ?>
900
+    global $wpinv_options;
901
+    $rates = wpinv_get_tax_rates();
902
+    ob_start(); ?>
903 903
     </td><tr>
904 904
     <td colspan="2" class="wpinv_tax_tdbox">
905 905
 	<p><?php echo $args['desc']; ?></p>
@@ -923,40 +923,40 @@  discard block
 block discarded – undo
923 923
 			<tr>
924 924
 				<td class="wpinv_tax_country">
925 925
 					<?php
926
-					echo wpinv_html_select( array(
927
-						'options'          => wpinv_get_country_list( true ),
928
-						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
926
+                    echo wpinv_html_select( array(
927
+                        'options'          => wpinv_get_country_list( true ),
928
+                        'name'             => 'tax_rates[' . $sanitized_key . '][country]',
929 929
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
930
-						'selected'         => $rate['country'],
931
-						'show_option_all'  => false,
932
-						'show_option_none' => false,
933
-						'class'            => 'wpinv-tax-country wpi_select2',
934
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
935
-					) );
936
-					?>
930
+                        'selected'         => $rate['country'],
931
+                        'show_option_all'  => false,
932
+                        'show_option_none' => false,
933
+                        'class'            => 'wpinv-tax-country wpi_select2',
934
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
935
+                    ) );
936
+                    ?>
937 937
 				</td>
938 938
 				<td class="wpinv_tax_state">
939 939
 					<?php
940
-					$states = wpinv_get_country_states( $rate['country'] );
941
-					if( !empty( $states ) ) {
942
-						echo wpinv_html_select( array(
943
-							'options'          => array_merge( array( '' => '' ), $states ),
944
-							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
940
+                    $states = wpinv_get_country_states( $rate['country'] );
941
+                    if( !empty( $states ) ) {
942
+                        echo wpinv_html_select( array(
943
+                            'options'          => array_merge( array( '' => '' ), $states ),
944
+                            'name'             => 'tax_rates[' . $sanitized_key . '][state]',
945 945
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
946
-							'selected'         => $rate['state'],
947
-							'show_option_all'  => false,
948
-							'show_option_none' => false,
946
+                            'selected'         => $rate['state'],
947
+                            'show_option_all'  => false,
948
+                            'show_option_none' => false,
949 949
                             'class'            => 'wpi_select2',
950
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
951
-						) );
952
-					} else {
953
-						echo wpinv_html_text( array(
954
-							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
955
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
950
+                            'placeholder'      => __( 'Choose a state', 'invoicing' )
951
+                        ) );
952
+                    } else {
953
+                        echo wpinv_html_text( array(
954
+                            'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
955
+                            'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
956 956
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
957
-						) );
958
-					}
959
-					?>
957
+                        ) );
958
+                    }
959
+                    ?>
960 960
 				</td>
961 961
 				<td class="wpinv_tax_global">
962 962
 					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
@@ -971,19 +971,19 @@  discard block
 block discarded – undo
971 971
 			<tr>
972 972
 				<td class="wpinv_tax_country">
973 973
 					<?php
974
-					echo wpinv_html_select( array(
975
-						'options'          => wpinv_get_country_list( true ),
976
-						'name'             => 'tax_rates[0][country]',
977
-						'show_option_all'  => false,
978
-						'show_option_none' => false,
979
-						'class'            => 'wpinv-tax-country wpi_select2',
980
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
981
-					) ); ?>
974
+                    echo wpinv_html_select( array(
975
+                        'options'          => wpinv_get_country_list( true ),
976
+                        'name'             => 'tax_rates[0][country]',
977
+                        'show_option_all'  => false,
978
+                        'show_option_none' => false,
979
+                        'class'            => 'wpinv-tax-country wpi_select2',
980
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
981
+                    ) ); ?>
982 982
 				</td>
983 983
 				<td class="wpinv_tax_state">
984 984
 					<?php echo wpinv_html_text( array(
985
-						'name' => 'tax_rates[0][state]'
986
-					) ); ?>
985
+                        'name' => 'tax_rates[0][state]'
986
+                    ) ); ?>
987 987
 				</td>
988 988
 				<td class="wpinv_tax_global">
989 989
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
         <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
999 999
 	</table>
1000 1000
 	<?php
1001
-	echo ob_get_clean();
1001
+    echo ob_get_clean();
1002 1002
 }
1003 1003
 
1004 1004
 function wpinv_tools_callback($args) {
@@ -1026,15 +1026,15 @@  discard block
 block discarded – undo
1026 1026
 }
1027 1027
 
1028 1028
 function wpinv_descriptive_text_callback( $args ) {
1029
-	echo wp_kses_post( $args['desc'] );
1029
+    echo wp_kses_post( $args['desc'] );
1030 1030
 }
1031 1031
 
1032 1032
 function wpinv_hook_callback( $args ) {
1033
-	do_action( 'wpinv_' . $args['id'], $args );
1033
+    do_action( 'wpinv_' . $args['id'], $args );
1034 1034
 }
1035 1035
 
1036 1036
 function wpinv_set_settings_cap() {
1037
-	return wpinv_get_capability();
1037
+    return wpinv_get_capability();
1038 1038
 }
1039 1039
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1040 1040
 
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-maxmind-geolocation.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -16,164 +16,164 @@
 block discarded – undo
16 16
  */
17 17
 class GetPaid_MaxMind_Geolocation {
18 18
 
19
-	/**
20
-	 * The service responsible for interacting with the MaxMind database.
21
-	 *
22
-	 * @var GetPaid_MaxMind_Database_Service
23
-	 */
24
-	private $database_service;
25
-
26
-	/**
27
-	 * Initialize the integration.
28
-	 */
29
-	public function __construct() {
30
-
31
-		/**
32
-		 * Supports overriding the database service to be used.
33
-		 *
34
-		 * @since 1.0.19
35
-		 * @return mixed|null The geolocation database service.
36
-		 */
37
-		$this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
-		if ( null === $this->database_service ) {
39
-			$this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
-		}
41
-
42
-		// Bind to the scheduled updater action.
43
-		add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
-
45
-		// Bind to the geolocation filter for MaxMind database lookups.
46
-		add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
-
48
-		// Handle maxmind key updates.
49
-		add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Get database service.
55
-	 *
56
-	 * @return GetPaid_MaxMind_Database_Service|null
57
-	 */
58
-	public function get_database_service() {
59
-		return $this->database_service;
60
-	}
61
-
62
-	/**
63
-	 * Checks to make sure that the license key is valid.
64
-	 *
65
-	 * @param string $license_key The new license key.
66
-	 * @return string
67
-	 */
68
-	public function handle_key_updates( $license_key ) {
69
-
70
-		// Trim whitespaces and strip slashes.
71
-		$license_key = trim( $license_key );
72
-
73
-		// Abort if the license key is empty or unchanged.
74
-		if ( empty( $license_key ) ) {
75
-			return $license_key;
76
-		}
77
-
78
-		// Abort if a database exists and the license key is unchaged.
79
-		if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
-			return $license_key;
81
-		}
82
-
83
-		// Check the license key by attempting to download the Geolocation database.
84
-		$tmp_database_path = $this->database_service->download_database( $license_key );
85
-		if ( is_wp_error( $tmp_database_path ) ) {
86
-			getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
-			return $license_key;
88
-		}
89
-
90
-		$this->update_database( $tmp_database_path );
91
-
92
-	}
93
-
94
-	/**
95
-	 * Updates the database used for geolocation queries.
96
-	 *
97
-	 * @param string $tmp_database_path Temporary database path.
98
-	 */
99
-	public function update_database( $tmp_database_path = null ) {
100
-
101
-		// Allow us to easily interact with the filesystem.
102
-		require_once ABSPATH . 'wp-admin/includes/file.php';
103
-		WP_Filesystem();
104
-		global $wp_filesystem;
105
-
106
-		// Remove any existing archives to comply with the MaxMind TOS.
107
-		$target_database_path = $this->database_service->get_database_path();
108
-
109
-		// If there's no database path, we can't store the database.
110
-		if ( empty( $target_database_path ) ) {
111
-			return;
112
-		}
113
-
114
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
115
-			$wp_filesystem->delete( $target_database_path );
116
-		}
117
-
118
-		// We can't download a database if there's no license key configured.
119
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
120
-		if ( empty( $license_key ) ) {
121
-			return;
122
-		}
123
-
124
-		if ( empty( $tmp_database_path ) ) {
125
-			$tmp_database_path = $this->database_service->download_database( $license_key );
126
-		}
127
-
128
-		if ( is_wp_error( $tmp_database_path ) ) {
129
-			wpinv_error_log( $tmp_database_path->get_error_message() );
130
-			return;
131
-		}
132
-
133
-		// Move the new database into position.
134
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
136
-	}
137
-
138
-	/**
139
-	 * Performs a geolocation lookup against the MaxMind database for the given IP address.
140
-	 *
141
-	 * @param array  $data       Geolocation data.
142
-	 * @param string $ip_address The IP address to geolocate.
143
-	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
144
-	 */
145
-	public function get_geolocation( $data, $ip_address ) {
146
-
147
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
-			return $data;
149
-		}
150
-
151
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
-
153
-		return array(
154
-			'country'  => $country_code,
155
-			'state'    => '',
156
-			'city'     => '',
157
-			'postcode' => '',
158
-		);
159
-
160
-	}
161
-
162
-	/**
163
-	 * Fetches the prefix for the MaxMind database file.
164
-	 *
165
-	 * @return string
166
-	 */
167
-	private function get_database_prefix() {
168
-
169
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
-
171
-		if ( empty( $prefix ) ) {
172
-			$prefix = md5( uniqid( 'wpinv' ) );
173
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
174
-		}
175
-
176
-		return $prefix;
177
-	}
19
+    /**
20
+     * The service responsible for interacting with the MaxMind database.
21
+     *
22
+     * @var GetPaid_MaxMind_Database_Service
23
+     */
24
+    private $database_service;
25
+
26
+    /**
27
+     * Initialize the integration.
28
+     */
29
+    public function __construct() {
30
+
31
+        /**
32
+         * Supports overriding the database service to be used.
33
+         *
34
+         * @since 1.0.19
35
+         * @return mixed|null The geolocation database service.
36
+         */
37
+        $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
+        if ( null === $this->database_service ) {
39
+            $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
+        }
41
+
42
+        // Bind to the scheduled updater action.
43
+        add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
+
45
+        // Bind to the geolocation filter for MaxMind database lookups.
46
+        add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
+
48
+        // Handle maxmind key updates.
49
+        add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
+
51
+    }
52
+
53
+    /**
54
+     * Get database service.
55
+     *
56
+     * @return GetPaid_MaxMind_Database_Service|null
57
+     */
58
+    public function get_database_service() {
59
+        return $this->database_service;
60
+    }
61
+
62
+    /**
63
+     * Checks to make sure that the license key is valid.
64
+     *
65
+     * @param string $license_key The new license key.
66
+     * @return string
67
+     */
68
+    public function handle_key_updates( $license_key ) {
69
+
70
+        // Trim whitespaces and strip slashes.
71
+        $license_key = trim( $license_key );
72
+
73
+        // Abort if the license key is empty or unchanged.
74
+        if ( empty( $license_key ) ) {
75
+            return $license_key;
76
+        }
77
+
78
+        // Abort if a database exists and the license key is unchaged.
79
+        if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
+            return $license_key;
81
+        }
82
+
83
+        // Check the license key by attempting to download the Geolocation database.
84
+        $tmp_database_path = $this->database_service->download_database( $license_key );
85
+        if ( is_wp_error( $tmp_database_path ) ) {
86
+            getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
+            return $license_key;
88
+        }
89
+
90
+        $this->update_database( $tmp_database_path );
91
+
92
+    }
93
+
94
+    /**
95
+     * Updates the database used for geolocation queries.
96
+     *
97
+     * @param string $tmp_database_path Temporary database path.
98
+     */
99
+    public function update_database( $tmp_database_path = null ) {
100
+
101
+        // Allow us to easily interact with the filesystem.
102
+        require_once ABSPATH . 'wp-admin/includes/file.php';
103
+        WP_Filesystem();
104
+        global $wp_filesystem;
105
+
106
+        // Remove any existing archives to comply with the MaxMind TOS.
107
+        $target_database_path = $this->database_service->get_database_path();
108
+
109
+        // If there's no database path, we can't store the database.
110
+        if ( empty( $target_database_path ) ) {
111
+            return;
112
+        }
113
+
114
+        if ( $wp_filesystem->exists( $target_database_path ) ) {
115
+            $wp_filesystem->delete( $target_database_path );
116
+        }
117
+
118
+        // We can't download a database if there's no license key configured.
119
+        $license_key = wpinv_get_option( 'maxmind_license_key' );
120
+        if ( empty( $license_key ) ) {
121
+            return;
122
+        }
123
+
124
+        if ( empty( $tmp_database_path ) ) {
125
+            $tmp_database_path = $this->database_service->download_database( $license_key );
126
+        }
127
+
128
+        if ( is_wp_error( $tmp_database_path ) ) {
129
+            wpinv_error_log( $tmp_database_path->get_error_message() );
130
+            return;
131
+        }
132
+
133
+        // Move the new database into position.
134
+        $wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
+        $wp_filesystem->delete( dirname( $tmp_database_path ) );
136
+    }
137
+
138
+    /**
139
+     * Performs a geolocation lookup against the MaxMind database for the given IP address.
140
+     *
141
+     * @param array  $data       Geolocation data.
142
+     * @param string $ip_address The IP address to geolocate.
143
+     * @return array Geolocation including country code, state, city and postcode based on an IP address.
144
+     */
145
+    public function get_geolocation( $data, $ip_address ) {
146
+
147
+        if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
+            return $data;
149
+        }
150
+
151
+        $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
+
153
+        return array(
154
+            'country'  => $country_code,
155
+            'state'    => '',
156
+            'city'     => '',
157
+            'postcode' => '',
158
+        );
159
+
160
+    }
161
+
162
+    /**
163
+     * Fetches the prefix for the MaxMind database file.
164
+     *
165
+     * @return string
166
+     */
167
+    private function get_database_prefix() {
168
+
169
+        $prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
+
171
+        if ( empty( $prefix ) ) {
172
+            $prefix = md5( uniqid( 'wpinv' ) );
173
+            update_option( 'wpinv_maxmind_database_prefix', $prefix );
174
+        }
175
+
176
+        return $prefix;
177
+    }
178 178
 
179 179
 }
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-geolocation.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -13,264 +13,264 @@
 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
-		'ipinfo.io'  => 'https://ipinfo.io/%s/json',
44
-		'ip-api.com' => 'http://ip-api.com/json/%s',
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
-			return empty( $data ) ? '' : $data->country;
265
-		}
266
-
267
-		if ( $geolocation_service === 'ip-api.com' ) {
268
-			$data = json_decode( $geolocation_response['body'] );
269
-			return empty( $data ) ? '' : $data->countryCode;
270
-		}
271
-
272
-		return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] );
273
-
274
-	}
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
+        'ipinfo.io'  => 'https://ipinfo.io/%s/json',
44
+        'ip-api.com' => 'http://ip-api.com/json/%s',
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
+            return empty( $data ) ? '' : $data->country;
265
+        }
266
+
267
+        if ( $geolocation_service === 'ip-api.com' ) {
268
+            $data = json_decode( $geolocation_response['body'] );
269
+            return empty( $data ) ? '' : $data->countryCode;
270
+        }
271
+
272
+        return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] );
273
+
274
+    }
275 275
 
276 276
 }
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-maxmind-database-service.php 1 patch
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -13,152 +13,152 @@
 block discarded – undo
13 13
  */
14 14
 class GetPaid_MaxMind_Database_Service {
15 15
 
16
-	/**
17
-	 * The name of the MaxMind database to utilize.
18
-	 */
19
-	const DATABASE = 'GeoLite2-Country';
20
-
21
-	/**
22
-	 * The extension for the MaxMind database.
23
-	 */
24
-	const DATABASE_EXTENSION = '.mmdb';
25
-
26
-	/**
27
-	 * A prefix for the MaxMind database filename.
28
-	 *
29
-	 * @var string
30
-	 */
31
-	private $database_prefix;
32
-
33
-	/**
34
-	 * Class constructor.
35
-	 *
36
-	 * @param string|null $database_prefix A prefix for the MaxMind database filename.
37
-	 */
38
-	public function __construct( $database_prefix ) {
39
-		$this->database_prefix = $database_prefix;
40
-	}
41
-
42
-	/**
43
-	 * Fetches the path that the database should be stored.
44
-	 *
45
-	 * @return string The local database path.
46
-	 */
47
-	public function get_database_path() {
48
-		$uploads_dir = wp_upload_dir();
49
-
50
-		$database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
-		if ( ! empty( $this->database_prefix ) ) {
52
-			$database_path .= $this->database_prefix . '-';
53
-		}
54
-		$database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55
-
56
-		// Filter the geolocation database storage path.
57
-		return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
58
-	}
59
-
60
-	/**
61
-	 * Fetches the database from the MaxMind service.
62
-	 *
63
-	 * @param string $license_key The license key to be used when downloading the database.
64
-	 * @return string|WP_Error The path to the database file or an error if invalid.
65
-	 */
66
-	public function download_database( $license_key ) {
67
-
68
-		$download_uri = add_query_arg(
69
-			array(
70
-				'edition_id'  => self::DATABASE,
71
-				'license_key' => urlencode( wpinv_clean( $license_key ) ),
72
-				'suffix'      => 'tar.gz',
73
-			),
74
-			'https://download.maxmind.com/app/geoip_download'
75
-		);
76
-
77
-		// Needed for the download_url call right below.
78
-		require_once ABSPATH . 'wp-admin/includes/file.php';
79
-
80
-		$tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
81
-
82
-		if ( is_wp_error( $tmp_archive_path ) ) {
83
-			// Transform the error into something more informative.
84
-			$error_data = $tmp_archive_path->get_error_data();
85
-			if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
86
-				return new WP_Error(
87
-					'getpaid_maxmind_geolocation_database_license_key',
88
-					__( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
89
-				);
90
-			}
91
-
92
-			return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
93
-		}
94
-
95
-		// Extract the database from the archive.
96
-		return $this->extract_downloaded_database( $tmp_archive_path );
97
-
98
-	}
99
-
100
-	/**
101
-	 * Extracts the downloaded database.
102
-	 *
103
-	 * @param string $tmp_archive_path The database archive path.
104
-	 * @return string|WP_Error The path to the database file or an error if invalid.
105
-	 */
106
-	protected function extract_downloaded_database( $tmp_archive_path ) {
107
-
108
-		// Extract the database from the archive.
109
-		try {
110
-
111
-			$file              = new PharData( $tmp_archive_path );
112
-			$tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
113
-
114
-			$file->extractTo(
115
-				dirname( $tmp_archive_path ),
116
-				trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
117
-				true
118
-			);
119
-
120
-		} catch ( Exception $exception ) {
121
-			return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
122
-		} finally {
123
-			// Remove the archive since we only care about a single file in it.
124
-			unlink( $tmp_archive_path );
125
-		}
126
-
127
-		return $tmp_database_path;
128
-	}
129
-
130
-	/**
131
-	 * Fetches the ISO country code associated with an IP address.
132
-	 *
133
-	 * @param string $ip_address The IP address to find the country code for.
134
-	 * @return string The country code for the IP address, or empty if not found.
135
-	 */
136
-	public function get_iso_country_code_for_ip( $ip_address ) {
137
-		$country_code = '';
138
-
139
-		if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
140
-			return $country_code;
141
-		}
142
-
143
-		$database_path = $this->get_database_path();
144
-		if ( ! file_exists( $database_path ) ) {
145
-			return $country_code;
146
-		}
147
-
148
-		try {
149
-			$reader = new MaxMind\Db\Reader( $database_path );
150
-			$data   = $reader->get( $ip_address );
151
-
152
-			if ( isset( $data['country']['iso_code'] ) ) {
153
-				$country_code = $data['country']['iso_code'];
154
-			}
155
-
156
-			$reader->close();
157
-		} catch ( Exception $e ) {
158
-			wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
159
-		}
160
-
161
-		return $country_code;
162
-	}
16
+    /**
17
+     * The name of the MaxMind database to utilize.
18
+     */
19
+    const DATABASE = 'GeoLite2-Country';
20
+
21
+    /**
22
+     * The extension for the MaxMind database.
23
+     */
24
+    const DATABASE_EXTENSION = '.mmdb';
25
+
26
+    /**
27
+     * A prefix for the MaxMind database filename.
28
+     *
29
+     * @var string
30
+     */
31
+    private $database_prefix;
32
+
33
+    /**
34
+     * Class constructor.
35
+     *
36
+     * @param string|null $database_prefix A prefix for the MaxMind database filename.
37
+     */
38
+    public function __construct( $database_prefix ) {
39
+        $this->database_prefix = $database_prefix;
40
+    }
41
+
42
+    /**
43
+     * Fetches the path that the database should be stored.
44
+     *
45
+     * @return string The local database path.
46
+     */
47
+    public function get_database_path() {
48
+        $uploads_dir = wp_upload_dir();
49
+
50
+        $database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
+        if ( ! empty( $this->database_prefix ) ) {
52
+            $database_path .= $this->database_prefix . '-';
53
+        }
54
+        $database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55
+
56
+        // Filter the geolocation database storage path.
57
+        return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
58
+    }
59
+
60
+    /**
61
+     * Fetches the database from the MaxMind service.
62
+     *
63
+     * @param string $license_key The license key to be used when downloading the database.
64
+     * @return string|WP_Error The path to the database file or an error if invalid.
65
+     */
66
+    public function download_database( $license_key ) {
67
+
68
+        $download_uri = add_query_arg(
69
+            array(
70
+                'edition_id'  => self::DATABASE,
71
+                'license_key' => urlencode( wpinv_clean( $license_key ) ),
72
+                'suffix'      => 'tar.gz',
73
+            ),
74
+            'https://download.maxmind.com/app/geoip_download'
75
+        );
76
+
77
+        // Needed for the download_url call right below.
78
+        require_once ABSPATH . 'wp-admin/includes/file.php';
79
+
80
+        $tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
81
+
82
+        if ( is_wp_error( $tmp_archive_path ) ) {
83
+            // Transform the error into something more informative.
84
+            $error_data = $tmp_archive_path->get_error_data();
85
+            if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
86
+                return new WP_Error(
87
+                    'getpaid_maxmind_geolocation_database_license_key',
88
+                    __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
89
+                );
90
+            }
91
+
92
+            return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
93
+        }
94
+
95
+        // Extract the database from the archive.
96
+        return $this->extract_downloaded_database( $tmp_archive_path );
97
+
98
+    }
99
+
100
+    /**
101
+     * Extracts the downloaded database.
102
+     *
103
+     * @param string $tmp_archive_path The database archive path.
104
+     * @return string|WP_Error The path to the database file or an error if invalid.
105
+     */
106
+    protected function extract_downloaded_database( $tmp_archive_path ) {
107
+
108
+        // Extract the database from the archive.
109
+        try {
110
+
111
+            $file              = new PharData( $tmp_archive_path );
112
+            $tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
113
+
114
+            $file->extractTo(
115
+                dirname( $tmp_archive_path ),
116
+                trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
117
+                true
118
+            );
119
+
120
+        } catch ( Exception $exception ) {
121
+            return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
122
+        } finally {
123
+            // Remove the archive since we only care about a single file in it.
124
+            unlink( $tmp_archive_path );
125
+        }
126
+
127
+        return $tmp_database_path;
128
+    }
129
+
130
+    /**
131
+     * Fetches the ISO country code associated with an IP address.
132
+     *
133
+     * @param string $ip_address The IP address to find the country code for.
134
+     * @return string The country code for the IP address, or empty if not found.
135
+     */
136
+    public function get_iso_country_code_for_ip( $ip_address ) {
137
+        $country_code = '';
138
+
139
+        if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
140
+            return $country_code;
141
+        }
142
+
143
+        $database_path = $this->get_database_path();
144
+        if ( ! file_exists( $database_path ) ) {
145
+            return $country_code;
146
+        }
147
+
148
+        try {
149
+            $reader = new MaxMind\Db\Reader( $database_path );
150
+            $data   = $reader->get( $ip_address );
151
+
152
+            if ( isset( $data['country']['iso_code'] ) ) {
153
+                $country_code = $data['country']['iso_code'];
154
+            }
155
+
156
+            $reader->close();
157
+        } catch ( Exception $e ) {
158
+            wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
159
+        }
160
+
161
+        return $country_code;
162
+    }
163 163
 
164 164
 }
Please login to merge, or discard this patch.
includes/class-getpaid-daily-maintenance.php 1 patch
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -12,108 +12,108 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Daily_Maintenance {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 */
18
-	public function __construct(){
19
-
20
-		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
-
23
-		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
-
26
-		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
31
-
32
-	}
33
-
34
-	/**
35
-	 * Schedules a cron to run every day at 7 a.m
36
-	 *
37
-	 */
38
-	public function maybe_create_scheduled_event() {
39
-
40
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
41
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
42
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
43
-		}
44
-
45
-	}
46
-
47
-	/**
48
-	 * Clears deprecated events.
49
-	 *
50
-	 */
51
-	public function maybe_clear_deprecated_events() {
52
-
53
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
54
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
56
-			update_option( 'wpinv_cleared_old_events', 1 );
57
-		}
58
-
59
-	}
60
-
61
-	/**
62
-	 * Fires the old hook for backwards compatibility.
63
-	 *
64
-	 */
65
-	public function backwards_compat() {
66
-		do_action( 'wpinv_register_schedule_event_daily' );
67
-	}
68
-
69
-	/**
70
-	 * Expires expired subscriptions.
71
-	 *
72
-	 */
73
-	public function maybe_expire_subscriptions() {
74
-
75
-		// Fetch expired subscriptions (skips those that expire today).
76
-		$args  = array(
77
-			'number'             => -1,
78
-			'count_total'        => false,
79
-			'status'             => 'trialling active failing cancelled',
80
-			'date_expires_query' => array(
81
-				'before'    => 'today',
82
-				'inclusive' => false,
83
-			),
84
-		);
85
-
86
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
87
-
88
-		foreach ( $subscriptions->get_results() as $subscription ) {
89
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) {
90
-				$subscription->set_status( 'expired' );
91
-				$subscription->save();
92
-			}
93
-		}
94
-
95
-	}
96
-
97
-	/**
98
-	 * Logs cron runs.
99
-	 *
100
-	 */
101
-	public function log_cron_run() {
102
-		wpinv_error_log( 'GetPaid Daily Cron' );
103
-	}
104
-
105
-	/**
106
-	 * Updates GeoIP databases.
107
-	 *
108
-	 */
109
-	public function maybe_update_geoip_databases() {
110
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
111
-
112
-		if ( false === $updated ) {
113
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
114
-			do_action( 'getpaid_update_geoip_databases' );
115
-		}
116
-
117
-	}
15
+    /**
16
+     * Class constructor.
17
+     */
18
+    public function __construct(){
19
+
20
+        // Clear deprecated events.
21
+        add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
+
23
+        // (Maybe) schedule a cron that runs daily.
24
+        add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
+
26
+        // Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
+        add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
+        add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
31
+
32
+    }
33
+
34
+    /**
35
+     * Schedules a cron to run every day at 7 a.m
36
+     *
37
+     */
38
+    public function maybe_create_scheduled_event() {
39
+
40
+        if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
41
+            $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
42
+            wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
43
+        }
44
+
45
+    }
46
+
47
+    /**
48
+     * Clears deprecated events.
49
+     *
50
+     */
51
+    public function maybe_clear_deprecated_events() {
52
+
53
+        if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
54
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
55
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
56
+            update_option( 'wpinv_cleared_old_events', 1 );
57
+        }
58
+
59
+    }
60
+
61
+    /**
62
+     * Fires the old hook for backwards compatibility.
63
+     *
64
+     */
65
+    public function backwards_compat() {
66
+        do_action( 'wpinv_register_schedule_event_daily' );
67
+    }
68
+
69
+    /**
70
+     * Expires expired subscriptions.
71
+     *
72
+     */
73
+    public function maybe_expire_subscriptions() {
74
+
75
+        // Fetch expired subscriptions (skips those that expire today).
76
+        $args  = array(
77
+            'number'             => -1,
78
+            'count_total'        => false,
79
+            'status'             => 'trialling active failing cancelled',
80
+            'date_expires_query' => array(
81
+                'before'    => 'today',
82
+                'inclusive' => false,
83
+            ),
84
+        );
85
+
86
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
87
+
88
+        foreach ( $subscriptions->get_results() as $subscription ) {
89
+            if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) {
90
+                $subscription->set_status( 'expired' );
91
+                $subscription->save();
92
+            }
93
+        }
94
+
95
+    }
96
+
97
+    /**
98
+     * Logs cron runs.
99
+     *
100
+     */
101
+    public function log_cron_run() {
102
+        wpinv_error_log( 'GetPaid Daily Cron' );
103
+    }
104
+
105
+    /**
106
+     * Updates GeoIP databases.
107
+     *
108
+     */
109
+    public function maybe_update_geoip_databases() {
110
+        $updated = get_transient( 'getpaid_updated_geoip_databases' );
111
+
112
+        if ( false === $updated ) {
113
+            set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
114
+            do_action( 'getpaid_update_geoip_databases' );
115
+        }
116
+
117
+    }
118 118
 
119 119
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-taxes.php 1 patch
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -12,231 +12,231 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Taxes {
14 14
 
15
-	/**
16
-	 * Submission taxes.
17
-	 * @var array
18
-	 */
19
-	public $taxes = array();
20
-
21
-	/**
22
-	 * Initial tax.
23
-	 * @var float
24
-	 */
25
-	protected $initial_tax = 0;
26
-
27
-	/**
28
-	 * Recurring tax.
29
-	 * @var float
30
-	 */
31
-	protected $recurring_tax = 0;
15
+    /**
16
+     * Submission taxes.
17
+     * @var array
18
+     */
19
+    public $taxes = array();
20
+
21
+    /**
22
+     * Initial tax.
23
+     * @var float
24
+     */
25
+    protected $initial_tax = 0;
26
+
27
+    /**
28
+     * Recurring tax.
29
+     * @var float
30
+     */
31
+    protected $recurring_tax = 0;
32
+
33
+    /**
34
+     * Class constructor
35
+     *
36
+     * @param GetPaid_Payment_Form_Submission $submission
37
+     */
38
+    public function __construct( $submission ) {
39
+
40
+        // Validate VAT number.
41
+        $this->validate_vat( $submission );
42
+
43
+        foreach ( $submission->get_items() as $item ) {
44
+            $this->process_item_tax( $item, $submission );
45
+        }
46
+
47
+        // Process any existing invoice taxes.
48
+        if ( $submission->has_invoice() ) {
49
+            $this->taxes = $submission->get_invoice()->get_taxes();
50
+        }
51
+
52
+        // Add VAT.
53
+        $this->taxes['vat'] = array(
54
+            'name'          => 'vat',
55
+            'initial_tax'   => $this->initial_tax,
56
+            'recurring_tax' => $this->recurring_tax,
57
+        );
58
+
59
+    }
60
+
61
+    /**
62
+     * Maybe process tax.
63
+     *
64
+     * @since 1.0.19
65
+     * @param GetPaid_Form_Item $item
66
+     * @param GetPaid_Payment_Form_Submission $submission
67
+     */
68
+    public function process_item_tax( $item, $submission ) {
69
+
70
+        $rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
71
+        $price    = $item->get_sub_total();
72
+        $item_tax = $price * $rate * 0.01;
73
+
74
+        if ( wpinv_prices_include_tax() ) {
75
+            $item_tax = $price - ( $price - $price * $rate * 0.01 );
76
+        }
77
+
78
+        $this->initial_tax += $item_tax;
79
+
80
+        if ( $item->is_recurring() ) {
81
+            $this->recurring_tax += $item_tax;
82
+        }
83
+
84
+    }
85
+
86
+    /**
87
+     * Checks if the submission has a digital item.
88
+     *
89
+     * @param GetPaid_Payment_Form_Submission $submission
90
+     * @since 1.0.19
91
+     * @return bool
92
+     */
93
+    public function has_digital_item( $submission ) {
94
+
95
+        foreach ( $submission->get_items() as $item ) {
96
+
97
+            if ( 'digital' == $item->get_vat_rule() ) {
98
+                return true;
99
+            }
100
+
101
+        }
102
+
103
+        return false;
104
+    }
105
+
106
+    /**
107
+     * Checks if this is an eu store.
108
+     *
109
+     * @since 1.0.19
110
+     * @return bool
111
+     */
112
+    public function is_eu_store() {
113
+        return $this->is_eu_country( wpinv_get_default_country() );
114
+    }
115
+
116
+    /**
117
+     * Checks if this is an eu country.
118
+     *
119
+     * @param string $country
120
+     * @since 1.0.19
121
+     * @return bool
122
+     */
123
+    public function is_eu_country( $country ) {
124
+        return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
125
+    }
126
+
127
+    /**
128
+     * Checks if this is an eu purchase.
129
+     *
130
+     * @param string $customer_country
131
+     * @since 1.0.19
132
+     * @return bool
133
+     */
134
+    public function is_eu_transaction( $customer_country ) {
135
+        return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
136
+    }
137
+
138
+    /**
139
+     * Retrieves the vat number.
140
+     *
141
+     * @param GetPaid_Payment_Form_Submission $submission
142
+     * @since 1.0.19
143
+     * @return string
144
+     */
145
+    public function get_vat_number( $submission ) {
146
+
147
+        // Retrieve from the posted number.
148
+        $vat_number = $submission->get_field( 'wpinv_vat_number' );
149
+        if ( ! empty( $vat_number ) ) {
150
+            return wpinv_clean( $vat_number );
151
+        }
152
+
153
+        // Retrieve from the invoice.
154
+        return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
155
+    }
156
+
157
+    /**
158
+     * Retrieves the company.
159
+     *
160
+     * @param GetPaid_Payment_Form_Submission $submission
161
+     * @since 1.0.19
162
+     * @return string
163
+     */
164
+    public function get_company( $submission ) {
165
+
166
+        // Retrieve from the posted data.
167
+        $company = $submission->get_field( 'wpinv_company' );
168
+        if ( ! empty( $company ) ) {
169
+            return wpinv_clean( $company );
170
+        }
171
+
172
+        // Retrieve from the invoice.
173
+        return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
174
+    }
175
+
176
+    /**
177
+     * Checks if we requires a VAT number.
178
+     *
179
+     * @param bool $ip_in_eu Whether the customer IP is from the EU
180
+     * @param bool $country_in_eu Whether the customer country is from the EU
181
+     * @since 1.0.19
182
+     * @return string
183
+     */
184
+    public function requires_vat( $ip_in_eu, $country_in_eu ) {
185
+
186
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
187
+        $prevent_b2c = ! empty( $prevent_b2c );
188
+        $is_eu       = $ip_in_eu || $country_in_eu;
189
+
190
+        return $prevent_b2c && $is_eu;
191
+    }
32 192
 
33 193
     /**
34
-	 * Class constructor
35
-	 *
36
-	 * @param GetPaid_Payment_Form_Submission $submission
37
-	 */
38
-	public function __construct( $submission ) {
39
-
40
-		// Validate VAT number.
41
-		$this->validate_vat( $submission );
42
-
43
-		foreach ( $submission->get_items() as $item ) {
44
-			$this->process_item_tax( $item, $submission );
45
-		}
46
-
47
-		// Process any existing invoice taxes.
48
-		if ( $submission->has_invoice() ) {
49
-			$this->taxes = $submission->get_invoice()->get_taxes();
50
-		}
51
-
52
-		// Add VAT.
53
-		$this->taxes['vat'] = array(
54
-			'name'          => 'vat',
55
-			'initial_tax'   => $this->initial_tax,
56
-			'recurring_tax' => $this->recurring_tax,
57
-		);
58
-
59
-	}
60
-
61
-	/**
62
-	 * Maybe process tax.
63
-	 *
64
-	 * @since 1.0.19
65
-	 * @param GetPaid_Form_Item $item
66
-	 * @param GetPaid_Payment_Form_Submission $submission
67
-	 */
68
-	public function process_item_tax( $item, $submission ) {
69
-
70
-		$rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
71
-		$price    = $item->get_sub_total();
72
-		$item_tax = $price * $rate * 0.01;
73
-
74
-		if ( wpinv_prices_include_tax() ) {
75
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
76
-		}
77
-
78
-		$this->initial_tax += $item_tax;
79
-
80
-		if ( $item->is_recurring() ) {
81
-			$this->recurring_tax += $item_tax;
82
-		}
83
-
84
-	}
85
-
86
-	/**
87
-	 * Checks if the submission has a digital item.
88
-	 *
89
-	 * @param GetPaid_Payment_Form_Submission $submission
90
-	 * @since 1.0.19
91
-	 * @return bool
92
-	 */
93
-	public function has_digital_item( $submission ) {
94
-
95
-		foreach ( $submission->get_items() as $item ) {
96
-
97
-			if ( 'digital' == $item->get_vat_rule() ) {
98
-				return true;
99
-			}
100
-
101
-		}
102
-
103
-		return false;
104
-	}
105
-
106
-	/**
107
-	 * Checks if this is an eu store.
108
-	 *
109
-	 * @since 1.0.19
110
-	 * @return bool
111
-	 */
112
-	public function is_eu_store() {
113
-		return $this->is_eu_country( wpinv_get_default_country() );
114
-	}
115
-
116
-	/**
117
-	 * Checks if this is an eu country.
118
-	 *
119
-	 * @param string $country
120
-	 * @since 1.0.19
121
-	 * @return bool
122
-	 */
123
-	public function is_eu_country( $country ) {
124
-		return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
125
-	}
126
-
127
-	/**
128
-	 * Checks if this is an eu purchase.
129
-	 *
130
-	 * @param string $customer_country
131
-	 * @since 1.0.19
132
-	 * @return bool
133
-	 */
134
-	public function is_eu_transaction( $customer_country ) {
135
-		return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
136
-	}
137
-
138
-	/**
139
-	 * Retrieves the vat number.
140
-	 *
141
-	 * @param GetPaid_Payment_Form_Submission $submission
142
-	 * @since 1.0.19
143
-	 * @return string
144
-	 */
145
-	public function get_vat_number( $submission ) {
146
-
147
-		// Retrieve from the posted number.
148
-		$vat_number = $submission->get_field( 'wpinv_vat_number' );
149
-		if ( ! empty( $vat_number ) ) {
150
-			return wpinv_clean( $vat_number );
151
-		}
152
-
153
-		// Retrieve from the invoice.
154
-		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
155
-	}
156
-
157
-	/**
158
-	 * Retrieves the company.
159
-	 *
160
-	 * @param GetPaid_Payment_Form_Submission $submission
161
-	 * @since 1.0.19
162
-	 * @return string
163
-	 */
164
-	public function get_company( $submission ) {
165
-
166
-		// Retrieve from the posted data.
167
-		$company = $submission->get_field( 'wpinv_company' );
168
-		if ( ! empty( $company ) ) {
169
-			return wpinv_clean( $company );
170
-		}
171
-
172
-		// Retrieve from the invoice.
173
-		return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
174
-	}
175
-
176
-	/**
177
-	 * Checks if we requires a VAT number.
178
-	 *
179
-	 * @param bool $ip_in_eu Whether the customer IP is from the EU
180
-	 * @param bool $country_in_eu Whether the customer country is from the EU
181
-	 * @since 1.0.19
182
-	 * @return string
183
-	 */
184
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
185
-
186
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
187
-		$prevent_b2c = ! empty( $prevent_b2c );
188
-		$is_eu       = $ip_in_eu || $country_in_eu;
189
-
190
-		return $prevent_b2c && $is_eu;
191
-	}
192
-
193
-	/**
194
-	 * Validate VAT data.
195
-	 *
196
-	 * @param GetPaid_Payment_Form_Submission $submission
197
-	 * @since 1.0.19
198
-	 */
199
-	public function validate_vat( $submission ) {
200
-
201
-		$has_digital = $this->has_digital_item( $submission );
202
-		$in_eu       = $this->is_eu_transaction( $submission->country );
203
-
204
-		// Abort if we are not validating vat numbers.
205
-		if ( ! $has_digital && ! $in_eu ) {
194
+     * Validate VAT data.
195
+     *
196
+     * @param GetPaid_Payment_Form_Submission $submission
197
+     * @since 1.0.19
198
+     */
199
+    public function validate_vat( $submission ) {
200
+
201
+        $has_digital = $this->has_digital_item( $submission );
202
+        $in_eu       = $this->is_eu_transaction( $submission->country );
203
+
204
+        // Abort if we are not validating vat numbers.
205
+        if ( ! $has_digital && ! $in_eu ) {
206 206
             return;
207
-		}
207
+        }
208 208
 
209
-		// Prepare variables.
210
-		$vat_number  = $this->get_vat_number( $submission );
211
-		$company     = $this->get_company( $submission );
212
-		$ip_country  = getpaid_get_ip_country();
209
+        // Prepare variables.
210
+        $vat_number  = $this->get_vat_number( $submission );
211
+        $company     = $this->get_company( $submission );
212
+        $ip_country  = getpaid_get_ip_country();
213 213
         $is_eu       = $this->is_eu_country( $submission->country );
214 214
         $is_ip_eu    = $this->is_eu_country( $ip_country );
215 215
 
216
-		// If we're preventing business to consumer purchases, ensure
217
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
216
+        // If we're preventing business to consumer purchases, ensure
217
+        if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
218 218
 
219
-			// Ensure that a vat number has been specified.
220
-			throw new Exception(
221
-				wp_sprintf(
222
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
223
-					getpaid_vat_name()
224
-				)
225
-			);
219
+            // Ensure that a vat number has been specified.
220
+            throw new Exception(
221
+                wp_sprintf(
222
+                    __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
223
+                    getpaid_vat_name()
224
+                )
225
+            );
226 226
 
227
-		}
227
+        }
228 228
 
229
-		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
230
-		if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
229
+        // Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
230
+        if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
231 231
             return;
232
-		}
232
+        }
233 233
 
234
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
234
+        $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
235 235
 
236
-		if ( is_string( $is_valid ) ) {
237
-			throw new Exception( $is_valid );
238
-		}
236
+        if ( is_string( $is_valid ) ) {
237
+            throw new Exception( $is_valid );
238
+        }
239 239
 
240
-	}
240
+    }
241 241
 
242 242
 }
Please login to merge, or discard this patch.
includes/libraries/wpinv-euvat/class-wpinv-euvat.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -350,23 +350,23 @@  discard block
 block discarded – undo
350 350
     }
351 351
 
352 352
     /**
353
-	 *
354
-	 * @deprecated
355
-	 */
353
+     *
354
+     * @deprecated
355
+     */
356 356
     public static function maxmind_folder() {
357 357
         return false;
358 358
     }
359 359
 
360 360
     /**
361
-	 *
362
-	 * @deprecated
363
-	 */
361
+     *
362
+     * @deprecated
363
+     */
364 364
     public static function geoip2_download_database() {}
365 365
 
366 366
     /**
367
-	 *
368
-	 * @deprecated
369
-	 */
367
+     *
368
+     * @deprecated
369
+     */
370 370
     public static function geoip2_download_file() {}
371 371
 
372 372
     /**
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
         $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1518 1518
 
1519 1519
         if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) {
1520
-           return wp_sprintf(
1520
+            return wp_sprintf(
1521 1521
                 __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ),
1522 1522
                 getpaid_vat_name()
1523 1523
             );
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -14,502 +14,502 @@  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
-	 * Tax instance.
40
-	 *
41
-	 * @var WPInv_EUVat
42
-	 */
43
-	public $tax;
44
-
45
-	/**
46
-	 * @param array An array of payment gateways.
47
-	 */
48
-	public $gateways;
49
-
50
-	/**
51
-	 * Class constructor.
52
-	 */
53
-	public function __construct() {
54
-		$this->define_constants();
55
-		$this->includes();
56
-		$this->init_hooks();
57
-		$this->set_properties();
58
-	}
59
-
60
-	/**
61
-	 * Sets a custom data property.
62
-	 * 
63
-	 * @param string $prop The prop to set.
64
-	 * @param mixed $value The value to retrieve.
65
-	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
68
-	}
69
-
70
-	/**
71
-	 * Gets a custom data property.
72
-	 *
73
-	 * @param string $prop The prop to set.
74
-	 * @return mixed The value.
75
-	 */
76
-	public function get( $prop ) {
77
-
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
80
-		}
81
-
82
-		return null;
83
-	}
84
-
85
-	/**
86
-	 * Define class properties.
87
-	 */
88
-	public function set_properties() {
89
-
90
-		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
-		$this->tax              = new WPInv_EUVat();
94
-		$this->tax->init();
95
-		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
96
-
97
-		// Init other objects.
98
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
99
-		$this->set( 'session', new WPInv_Session_Handler() );
100
-		$this->set( 'notes', new WPInv_Notes() );
101
-		$this->set( 'api', new WPInv_API() );
102
-		$this->set( 'post_types', new GetPaid_Post_Types() );
103
-		$this->set( 'template', new GetPaid_Template() );
104
-		$this->set( 'admin', new GetPaid_Admin() );
105
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
106
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
107
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
108
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
109
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
110
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
111
-
112
-	}
113
-
114
-	 /**
115
-	 * Define plugin constants.
116
-	 */
117
-	public function define_constants() {
118
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
120
-		$this->version = WPINV_VERSION;
121
-	}
122
-
123
-	/**
124
-	 * Hook into actions and filters.
125
-	 *
126
-	 * @since 1.0.19
127
-	 */
128
-	protected function init_hooks() {
129
-		/* Internationalize the text strings used. */
130
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
131
-
132
-		// Init the plugin after WordPress inits.
133
-		add_action( 'init', array( $this, 'init' ), 1 );
134
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
135
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
136
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
137
-
138
-		if ( class_exists( 'BuddyPress' ) ) {
139
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
140
-		}
141
-
142
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
147
-
148
-		// Fires after registering actions.
149
-		do_action( 'wpinv_actions', $this );
150
-		do_action( 'getpaid_actions', $this );
151
-
152
-	}
153
-
154
-	public function plugins_loaded() {
155
-		/* Internationalize the text strings used. */
156
-		$this->load_textdomain();
157
-
158
-		do_action( 'wpinv_loaded' );
159
-
160
-		// Fix oxygen page builder conflict
161
-		if ( function_exists( 'ct_css_output' ) ) {
162
-			wpinv_oxygen_fix_conflict();
163
-		}
164
-	}
165
-
166
-	/**
167
-	 * Load the translation of the plugin.
168
-	 *
169
-	 * @since 1.0
170
-	 */
171
-	public function load_textdomain( $locale = NULL ) {
172
-		if ( empty( $locale ) ) {
173
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
174
-		}
175
-
176
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
-
178
-		unload_textdomain( 'invoicing' );
179
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
181
-
182
-		/**
183
-		 * Define language constants.
184
-		 */
185
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
186
-	}
187
-
188
-	/**
189
-	 * Include required core files used in admin and on the frontend.
190
-	 */
191
-	public function includes() {
192
-
193
-		// Start with the settings.
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
195
-
196
-		// Packages/libraries.
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
199
-
200
-		// Load functions.
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
216
-
217
-		// Register autoloader.
218
-		try {
219
-			spl_autoload_register( array( $this, 'autoload' ), true );
220
-		} catch ( Exception $e ) {
221
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
222
-		}
223
-
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
244
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
245
-
246
-		/**
247
-		 * Load the tax class.
248
-		 */
249
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
250
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
251
-		}
252
-
253
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
254
-			GetPaid_Post_Types_Admin::init();
255
-
256
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
257
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
263
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
264
-			// load the user class only on the users.php page
265
-			global $pagenow;
266
-			if($pagenow=='users.php'){
267
-				new WPInv_Admin_Users();
268
-			}
269
-		}
270
-
271
-		// Register cli commands
272
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
273
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
274
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
275
-		}
276
-
277
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
278
-	}
279
-
280
-	/**
281
-	 * Class autoloader
282
-	 *
283
-	 * @param       string $class_name The name of the class to load.
284
-	 * @access      public
285
-	 * @since       1.0.19
286
-	 * @return      void
287
-	 */
288
-	public function autoload( $class_name ) {
289
-
290
-		// Normalize the class name...
291
-		$class_name  = strtolower( $class_name );
292
-
293
-		// ... and make sure it is our class.
294
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
295
-			return;
296
-		}
297
-
298
-		// Next, prepare the file name from the class.
299
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
300
-
301
-		// Base path of the classes.
302
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
303
-
304
-		// And an array of possible locations in order of importance.
305
-		$locations = array(
306
-			"$plugin_path/includes",
307
-			"$plugin_path/includes/data-stores",
308
-			"$plugin_path/includes/gateways",
309
-			"$plugin_path/includes/payments",
310
-			"$plugin_path/includes/geolocation",
311
-			"$plugin_path/includes/api",
312
-			"$plugin_path/includes/admin",
313
-			"$plugin_path/includes/admin/meta-boxes",
314
-		);
315
-
316
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
317
-
318
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
319
-				include trailingslashit( $location ) . $file_name;
320
-				break;
321
-			}
322
-
323
-		}
324
-
325
-	}
326
-
327
-	/**
328
-	 * Inits hooks etc.
329
-	 */
330
-	public function init() {
331
-
332
-		// Fires before getpaid inits.
333
-		do_action( 'before_getpaid_init', $this );
334
-
335
-		// Load default gateways.
336
-		$gateways = apply_filters(
337
-			'getpaid_default_gateways',
338
-			array(
339
-				'manual'        => 'GetPaid_Manual_Gateway',
340
-				'paypal'        => 'GetPaid_Paypal_Gateway',
341
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
342
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
343
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
344
-			)
345
-		);
346
-
347
-		foreach ( $gateways as $id => $class ) {
348
-			$this->gateways[ $id ] = new $class();
349
-		}
350
-
351
-		// Fires after getpaid inits.
352
-		do_action( 'getpaid_init', $this );
353
-
354
-	}
355
-
356
-	/**
357
-	 * Checks if this is an IPN request and processes it.
358
-	 */
359
-	public function maybe_process_ipn() {
360
-
361
-		// Ensure that this is an IPN request.
362
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
363
-			return;
364
-		}
365
-
366
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
367
-
368
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
369
-		do_action( "wpinv_verify_{$gateway}_ipn" );
370
-		exit;
371
-
372
-	}
373
-
374
-	public function enqueue_scripts() {
375
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
376
-
377
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
378
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
379
-		wp_enqueue_style( 'wpinv_front_style' );
380
-
381
-		// Register scripts
382
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
383
-		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' ) );
384
-
385
-		$localize                         = array();
386
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
387
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
388
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
389
-		$localize['UseTaxes']             = wpinv_use_taxes();
390
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
391
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
392
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
393
-
394
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
395
-
396
-		wp_enqueue_script( 'jquery-blockui' );
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
+     * Tax instance.
40
+     *
41
+     * @var WPInv_EUVat
42
+     */
43
+    public $tax;
44
+
45
+    /**
46
+     * @param array An array of payment gateways.
47
+     */
48
+    public $gateways;
49
+
50
+    /**
51
+     * Class constructor.
52
+     */
53
+    public function __construct() {
54
+        $this->define_constants();
55
+        $this->includes();
56
+        $this->init_hooks();
57
+        $this->set_properties();
58
+    }
59
+
60
+    /**
61
+     * Sets a custom data property.
62
+     * 
63
+     * @param string $prop The prop to set.
64
+     * @param mixed $value The value to retrieve.
65
+     */
66
+    public function set( $prop, $value ) {
67
+        $this->data[ $prop ] = $value;
68
+    }
69
+
70
+    /**
71
+     * Gets a custom data property.
72
+     *
73
+     * @param string $prop The prop to set.
74
+     * @return mixed The value.
75
+     */
76
+    public function get( $prop ) {
77
+
78
+        if ( isset( $this->data[ $prop ] ) ) {
79
+            return $this->data[ $prop ];
80
+        }
81
+
82
+        return null;
83
+    }
84
+
85
+    /**
86
+     * Define class properties.
87
+     */
88
+    public function set_properties() {
89
+
90
+        // Sessions.
91
+        $this->set( 'session', new WPInv_Session_Handler() );
92
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
+        $this->tax              = new WPInv_EUVat();
94
+        $this->tax->init();
95
+        $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
96
+
97
+        // Init other objects.
98
+        $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
99
+        $this->set( 'session', new WPInv_Session_Handler() );
100
+        $this->set( 'notes', new WPInv_Notes() );
101
+        $this->set( 'api', new WPInv_API() );
102
+        $this->set( 'post_types', new GetPaid_Post_Types() );
103
+        $this->set( 'template', new GetPaid_Template() );
104
+        $this->set( 'admin', new GetPaid_Admin() );
105
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
106
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
107
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
108
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
109
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
110
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
397 111
 
398
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' );
399
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
112
+    }
113
+
114
+        /**
115
+         * Define plugin constants.
116
+         */
117
+    public function define_constants() {
118
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
120
+        $this->version = WPINV_VERSION;
121
+    }
122
+
123
+    /**
124
+     * Hook into actions and filters.
125
+     *
126
+     * @since 1.0.19
127
+     */
128
+    protected function init_hooks() {
129
+        /* Internationalize the text strings used. */
130
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
131
+
132
+        // Init the plugin after WordPress inits.
133
+        add_action( 'init', array( $this, 'init' ), 1 );
134
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
135
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
136
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
137
+
138
+        if ( class_exists( 'BuddyPress' ) ) {
139
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
140
+        }
141
+
142
+        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
147
+
148
+        // Fires after registering actions.
149
+        do_action( 'wpinv_actions', $this );
150
+        do_action( 'getpaid_actions', $this );
151
+
152
+    }
153
+
154
+    public function plugins_loaded() {
155
+        /* Internationalize the text strings used. */
156
+        $this->load_textdomain();
157
+
158
+        do_action( 'wpinv_loaded' );
159
+
160
+        // Fix oxygen page builder conflict
161
+        if ( function_exists( 'ct_css_output' ) ) {
162
+            wpinv_oxygen_fix_conflict();
163
+        }
164
+    }
165
+
166
+    /**
167
+     * Load the translation of the plugin.
168
+     *
169
+     * @since 1.0
170
+     */
171
+    public function load_textdomain( $locale = NULL ) {
172
+        if ( empty( $locale ) ) {
173
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
174
+        }
175
+
176
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
+
178
+        unload_textdomain( 'invoicing' );
179
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
181
+
182
+        /**
183
+         * Define language constants.
184
+         */
185
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
186
+    }
187
+
188
+    /**
189
+     * Include required core files used in admin and on the frontend.
190
+     */
191
+    public function includes() {
192
+
193
+        // Start with the settings.
194
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
195
+
196
+        // Packages/libraries.
197
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
199
+
200
+        // Load functions.
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
210
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
211
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
212
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
213
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
215
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
216
+
217
+        // Register autoloader.
218
+        try {
219
+            spl_autoload_register( array( $this, 'autoload' ), true );
220
+        } catch ( Exception $e ) {
221
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
222
+        }
223
+
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
234
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
235
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
236
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
237
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
238
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
239
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
240
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
241
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
242
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
243
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
244
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
245
+
246
+        /**
247
+         * Load the tax class.
248
+         */
249
+        if ( ! class_exists( 'WPInv_EUVat' ) ) {
250
+            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
251
+        }
252
+
253
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
254
+            GetPaid_Post_Types_Admin::init();
255
+
256
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
257
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
258
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
259
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
260
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
261
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
262
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
263
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
264
+            // load the user class only on the users.php page
265
+            global $pagenow;
266
+            if($pagenow=='users.php'){
267
+                new WPInv_Admin_Users();
268
+            }
269
+        }
270
+
271
+        // Register cli commands
272
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
273
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
274
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
275
+        }
276
+
277
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
278
+    }
279
+
280
+    /**
281
+     * Class autoloader
282
+     *
283
+     * @param       string $class_name The name of the class to load.
284
+     * @access      public
285
+     * @since       1.0.19
286
+     * @return      void
287
+     */
288
+    public function autoload( $class_name ) {
400 289
 
401
-		wp_enqueue_script( 'wpinv-front-script' );
402
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
403
-
404
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
405
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
406
-	}
407
-
408
-	public function wpinv_actions() {
409
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
410
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
411
-		}
412
-	}
290
+        // Normalize the class name...
291
+        $class_name  = strtolower( $class_name );
413 292
 
414
-	/**
293
+        // ... and make sure it is our class.
294
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
295
+            return;
296
+        }
297
+
298
+        // Next, prepare the file name from the class.
299
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
300
+
301
+        // Base path of the classes.
302
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
303
+
304
+        // And an array of possible locations in order of importance.
305
+        $locations = array(
306
+            "$plugin_path/includes",
307
+            "$plugin_path/includes/data-stores",
308
+            "$plugin_path/includes/gateways",
309
+            "$plugin_path/includes/payments",
310
+            "$plugin_path/includes/geolocation",
311
+            "$plugin_path/includes/api",
312
+            "$plugin_path/includes/admin",
313
+            "$plugin_path/includes/admin/meta-boxes",
314
+        );
315
+
316
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
317
+
318
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
319
+                include trailingslashit( $location ) . $file_name;
320
+                break;
321
+            }
322
+
323
+        }
324
+
325
+    }
326
+
327
+    /**
328
+     * Inits hooks etc.
329
+     */
330
+    public function init() {
331
+
332
+        // Fires before getpaid inits.
333
+        do_action( 'before_getpaid_init', $this );
334
+
335
+        // Load default gateways.
336
+        $gateways = apply_filters(
337
+            'getpaid_default_gateways',
338
+            array(
339
+                'manual'        => 'GetPaid_Manual_Gateway',
340
+                'paypal'        => 'GetPaid_Paypal_Gateway',
341
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
342
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
343
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
344
+            )
345
+        );
346
+
347
+        foreach ( $gateways as $id => $class ) {
348
+            $this->gateways[ $id ] = new $class();
349
+        }
350
+
351
+        // Fires after getpaid inits.
352
+        do_action( 'getpaid_init', $this );
353
+
354
+    }
355
+
356
+    /**
357
+     * Checks if this is an IPN request and processes it.
358
+     */
359
+    public function maybe_process_ipn() {
360
+
361
+        // Ensure that this is an IPN request.
362
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
363
+            return;
364
+        }
365
+
366
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
367
+
368
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
369
+        do_action( "wpinv_verify_{$gateway}_ipn" );
370
+        exit;
371
+
372
+    }
373
+
374
+    public function enqueue_scripts() {
375
+        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
376
+
377
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
378
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
379
+        wp_enqueue_style( 'wpinv_front_style' );
380
+
381
+        // Register scripts
382
+        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
383
+        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' ) );
384
+
385
+        $localize                         = array();
386
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
387
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
388
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
389
+        $localize['UseTaxes']             = wpinv_use_taxes();
390
+        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
391
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
392
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
393
+
394
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
395
+
396
+        wp_enqueue_script( 'jquery-blockui' );
397
+
398
+        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' );
399
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
400
+
401
+        wp_enqueue_script( 'wpinv-front-script' );
402
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
403
+
404
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
405
+        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
406
+    }
407
+
408
+    public function wpinv_actions() {
409
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
410
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
411
+        }
412
+    }
413
+
414
+    /**
415 415
      * Fires an action after verifying that a user can fire them.
416
-	 *
417
-	 * Note: If the action is on an invoice, subscription etc, esure that the
418
-	 * current user owns the invoice/subscription.
416
+     *
417
+     * Note: If the action is on an invoice, subscription etc, esure that the
418
+     * current user owns the invoice/subscription.
419 419
      */
420 420
     public function maybe_do_authenticated_action() {
421 421
 
422
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
422
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
423 423
 
424
-			$key = sanitize_key( $_REQUEST['getpaid-action'] );
425
-			if ( is_user_logged_in() ) {
426
-				do_action( "getpaid_authenticated_action_$key", $_REQUEST );
427
-			}
424
+            $key = sanitize_key( $_REQUEST['getpaid-action'] );
425
+            if ( is_user_logged_in() ) {
426
+                do_action( "getpaid_authenticated_action_$key", $_REQUEST );
427
+            }
428 428
 
429
-			do_action( "getpaid_unauthenticated_action_$key", $_REQUEST );
429
+            do_action( "getpaid_unauthenticated_action_$key", $_REQUEST );
430 430
 
431
-		}
431
+        }
432 432
         
433 433
 
434 434
     }
435 435
 
436
-	public function pre_get_posts( $wp_query ) {
437
-
438
-		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() ) {
439
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
440
-		}
441
-
442
-		return $wp_query;
443
-	}
444
-
445
-	public function bp_invoicing_init() {
446
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
447
-	}
448
-
449
-	/**
450
-	 * Register widgets
451
-	 *
452
-	 */
453
-	public function register_widgets() {
454
-		$widgets = apply_filters(
455
-			'getpaid_widget_classes',
456
-			array(
457
-				'WPInv_Checkout_Widget',
458
-				'WPInv_History_Widget',
459
-				'WPInv_Receipt_Widget',
460
-				'WPInv_Subscriptions_Widget',
461
-				'WPInv_Buy_Item_Widget',
462
-				'WPInv_Messages_Widget',
463
-				'WPInv_GetPaid_Widget'
464
-			)
465
-		);
466
-
467
-		foreach ( $widgets as $widget ) {
468
-			register_widget( $widget );
469
-		}
436
+    public function pre_get_posts( $wp_query ) {
437
+
438
+        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() ) {
439
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
440
+        }
441
+
442
+        return $wp_query;
443
+    }
444
+
445
+    public function bp_invoicing_init() {
446
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
447
+    }
448
+
449
+    /**
450
+     * Register widgets
451
+     *
452
+     */
453
+    public function register_widgets() {
454
+        $widgets = apply_filters(
455
+            'getpaid_widget_classes',
456
+            array(
457
+                'WPInv_Checkout_Widget',
458
+                'WPInv_History_Widget',
459
+                'WPInv_Receipt_Widget',
460
+                'WPInv_Subscriptions_Widget',
461
+                'WPInv_Buy_Item_Widget',
462
+                'WPInv_Messages_Widget',
463
+                'WPInv_GetPaid_Widget'
464
+            )
465
+        );
466
+
467
+        foreach ( $widgets as $widget ) {
468
+            register_widget( $widget );
469
+        }
470 470
 		
471
-	}
471
+    }
472 472
 
473
-	/**
474
-	 * Remove our pages from yoast sitemaps.
475
-	 *
476
-	 * @since 1.0.19
477
-	 * @param int[] $excluded_posts_ids
478
-	 */
479
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
473
+    /**
474
+     * Remove our pages from yoast sitemaps.
475
+     *
476
+     * @since 1.0.19
477
+     * @param int[] $excluded_posts_ids
478
+     */
479
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
480 480
 
481
-		// Ensure that we have an array.
482
-		if ( ! is_array( $excluded_posts_ids ) ) {
483
-			$excluded_posts_ids = array();
484
-		}
481
+        // Ensure that we have an array.
482
+        if ( ! is_array( $excluded_posts_ids ) ) {
483
+            $excluded_posts_ids = array();
484
+        }
485 485
 
486
-		// Prepare our pages.
487
-		$our_pages = array();
486
+        // Prepare our pages.
487
+        $our_pages = array();
488 488
 
489
-		// Checkout page.
490
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
489
+        // Checkout page.
490
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
491 491
 
492
-		// Success page.
493
-		$our_pages[] = wpinv_get_option( 'success_page', false );
492
+        // Success page.
493
+        $our_pages[] = wpinv_get_option( 'success_page', false );
494 494
 
495
-		// Failure page.
496
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
495
+        // Failure page.
496
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
497 497
 
498
-		// History page.
499
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
498
+        // History page.
499
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
500 500
 
501
-		// Subscriptions page.
502
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
501
+        // Subscriptions page.
502
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
503 503
 
504
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
504
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
505 505
 
506
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
507
-		return array_unique( $excluded_posts_ids );
506
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
507
+        return array_unique( $excluded_posts_ids );
508 508
 
509
-	}
509
+    }
510 510
 
511
-	public function wp_footer() {
512
-		echo '
511
+    public function wp_footer() {
512
+        echo '
513 513
 			<div class="bsui">
514 514
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
515 515
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -520,6 +520,6 @@  discard block
 block discarded – undo
520 520
 				</div>
521 521
 			</div>
522 522
 		';
523
-	}
523
+    }
524 524
 
525 525
 }
Please login to merge, or discard this patch.
vendor/composer/InstalledVersions.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 class InstalledVersions
13 13
 {
14 14
 private static $installed = array (
15
-  'root' => 
16
-  array (
15
+    'root' => 
16
+    array (
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
@@ -21,87 +21,87 @@  discard block
 block discarded – undo
21 21
     ),
22 22
     'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea',
23 23
     'name' => 'ayecode/invoicing',
24
-  ),
25
-  'versions' => 
26
-  array (
24
+    ),
25
+    'versions' => 
26
+    array (
27 27
     'ayecode/ayecode-connect-helper' => 
28 28
     array (
29
-      'pretty_version' => '1.0.3',
30
-      'version' => '1.0.3.0',
31
-      'aliases' => 
32
-      array (
33
-      ),
34
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
29
+        'pretty_version' => '1.0.3',
30
+        'version' => '1.0.3.0',
31
+        'aliases' => 
32
+        array (
33
+        ),
34
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37 37
     array (
38
-      'pretty_version' => 'dev-master',
39
-      'version' => 'dev-master',
40
-      'aliases' => 
41
-      array (
42
-      ),
43
-      'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea',
38
+        'pretty_version' => 'dev-master',
39
+        'version' => 'dev-master',
40
+        'aliases' => 
41
+        array (
42
+        ),
43
+        'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46 46
     array (
47
-      'pretty_version' => '0.1.35',
48
-      'version' => '0.1.35.0',
49
-      'aliases' => 
50
-      array (
51
-      ),
52
-      'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f',
47
+        'pretty_version' => '0.1.35',
48
+        'version' => '0.1.35.0',
49
+        'aliases' => 
50
+        array (
51
+        ),
52
+        'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f',
53 53
     ),
54 54
     'ayecode/wp-font-awesome-settings' => 
55 55
     array (
56
-      'pretty_version' => '1.0.12',
57
-      'version' => '1.0.12.0',
58
-      'aliases' => 
59
-      array (
60
-      ),
61
-      'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
56
+        'pretty_version' => '1.0.12',
57
+        'version' => '1.0.12.0',
58
+        'aliases' => 
59
+        array (
60
+        ),
61
+        'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
62 62
     ),
63 63
     'ayecode/wp-super-duper' => 
64 64
     array (
65
-      'pretty_version' => '1.0.22',
66
-      'version' => '1.0.22.0',
67
-      'aliases' => 
68
-      array (
69
-      ),
70
-      'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac',
65
+        'pretty_version' => '1.0.22',
66
+        'version' => '1.0.22.0',
67
+        'aliases' => 
68
+        array (
69
+        ),
70
+        'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac',
71 71
     ),
72 72
     'composer/installers' => 
73 73
     array (
74
-      'pretty_version' => 'v1.9.0',
75
-      'version' => '1.9.0.0',
76
-      'aliases' => 
77
-      array (
78
-      ),
79
-      'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca',
74
+        'pretty_version' => 'v1.9.0',
75
+        'version' => '1.9.0.0',
76
+        'aliases' => 
77
+        array (
78
+        ),
79
+        'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca',
80 80
     ),
81 81
     'maxmind-db/reader' => 
82 82
     array (
83
-      'pretty_version' => 'v1.6.0',
84
-      'version' => '1.6.0.0',
85
-      'aliases' => 
86
-      array (
87
-      ),
88
-      'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
83
+        'pretty_version' => 'v1.6.0',
84
+        'version' => '1.6.0.0',
85
+        'aliases' => 
86
+        array (
87
+        ),
88
+        'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
89 89
     ),
90 90
     'roundcube/plugin-installer' => 
91 91
     array (
92
-      'replaced' => 
93
-      array (
92
+        'replaced' => 
93
+        array (
94 94
         0 => '*',
95
-      ),
95
+        ),
96 96
     ),
97 97
     'shama/baton' => 
98 98
     array (
99
-      'replaced' => 
100
-      array (
99
+        'replaced' => 
100
+        array (
101 101
         0 => '*',
102
-      ),
102
+        ),
103
+    ),
103 104
     ),
104
-  ),
105 105
 );
106 106
 
107 107
 
Please login to merge, or discard this patch.