Passed
Push — master ( 24d4c3...a419ab )
by Stiofan
12:50
created
includes/wpinv-invoice-functions.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 }
670 670
 
671 671
 function wpinv_get_payment_key( $invoice_id = 0 ) {
672
-	$invoice = new WPInv_Invoice( $invoice_id );
672
+    $invoice = new WPInv_Invoice( $invoice_id );
673 673
     return $invoice->get_key();
674 674
 }
675 675
 
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
         return false;
920 920
     }
921 921
     $invoice = wpinv_get_invoice_cart();
922
-	if ( empty( $invoice ) ) {
922
+    if ( empty( $invoice ) ) {
923 923
         return false;
924 924
     }
925 925
 
@@ -1212,20 +1212,20 @@  discard block
 block discarded – undo
1212 1212
 }
1213 1213
 
1214 1214
 function wpinv_checkout_get_cc_info() {
1215
-	$cc_info = array();
1216
-	$cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
1217
-	$cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
1218
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
1219
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
1220
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
1221
-	$cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
1222
-	$cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
1223
-	$cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
1224
-	$cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
1225
-	$cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
1226
-
1227
-	// Return cc info
1228
-	return $cc_info;
1215
+    $cc_info = array();
1216
+    $cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
1217
+    $cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
1218
+    $cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
1219
+    $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
1220
+    $cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
1221
+    $cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
1222
+    $cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
1223
+    $cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
1224
+    $cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
1225
+    $cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
1226
+
1227
+    // Return cc info
1228
+    return $cc_info;
1229 1229
 }
1230 1230
 
1231 1231
 function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
         $required_fields  = wpinv_checkout_required_fields();
1423 1423
 
1424 1424
         // Loop through required fields and show error messages
1425
-         if ( !empty( $required_fields ) ) {
1425
+            if ( !empty( $required_fields ) ) {
1426 1426
             foreach ( $required_fields as $field_name => $value ) {
1427 1427
                 if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
1428 1428
                     wpinv_set_error( $value['error_id'], $value['error_message'] );
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 }
1529 1529
 
1530 1530
 function wpinv_get_checkout_session() {
1531
-	global $wpi_session;
1531
+    global $wpi_session;
1532 1532
     
1533 1533
     return $wpi_session->get( 'wpinv_checkout' );
1534 1534
 }
@@ -1891,57 +1891,57 @@  discard block
 block discarded – undo
1891 1891
 }
1892 1892
 
1893 1893
 function wpinv_get_invoice_id_by_key( $key ) {
1894
-	global $wpdb;
1894
+    global $wpdb;
1895 1895
 
1896
-	$invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) );
1896
+    $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) );
1897 1897
 
1898
-	if ( $invoice_id != NULL )
1899
-		return $invoice_id;
1898
+    if ( $invoice_id != NULL )
1899
+        return $invoice_id;
1900 1900
 
1901
-	return 0;
1901
+    return 0;
1902 1902
 }
1903 1903
 
1904 1904
 function wpinv_can_view_receipt( $invoice_key = '' ) {
1905
-	$return = false;
1906
-
1907
-	if ( empty( $invoice_key ) ) {
1908
-		return $return;
1909
-	}
1910
-
1911
-	global $wpinv_receipt_args;
1912
-
1913
-	$wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key );
1914
-	if ( isset( $_GET['invoice-id'] ) ) {
1915
-		$wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0;
1916
-	}
1917
-
1918
-	if ( empty( $wpinv_receipt_args['id'] ) ) {
1919
-		return $return;
1920
-	}
1921
-
1922
-	$invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] );
1923
-	if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) {
1924
-		return $return;
1925
-	}
1926
-
1927
-	if ( is_user_logged_in() ) {
1928
-		if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) {
1929
-			$return = true;
1930
-		}
1931
-	}
1932
-
1933
-	$session = wpinv_get_checkout_session();
1934
-	if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) {
1935
-		$check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key'];
1936
-
1937
-		if ( wpinv_require_login_to_checkout() ) {
1938
-			$return = $return && $check_key === $invoice_key;
1939
-		} else {
1940
-			$return = $check_key === $invoice_key;
1941
-		}
1942
-	}
1943
-
1944
-	return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key );
1905
+    $return = false;
1906
+
1907
+    if ( empty( $invoice_key ) ) {
1908
+        return $return;
1909
+    }
1910
+
1911
+    global $wpinv_receipt_args;
1912
+
1913
+    $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key );
1914
+    if ( isset( $_GET['invoice-id'] ) ) {
1915
+        $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0;
1916
+    }
1917
+
1918
+    if ( empty( $wpinv_receipt_args['id'] ) ) {
1919
+        return $return;
1920
+    }
1921
+
1922
+    $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] );
1923
+    if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) {
1924
+        return $return;
1925
+    }
1926
+
1927
+    if ( is_user_logged_in() ) {
1928
+        if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) {
1929
+            $return = true;
1930
+        }
1931
+    }
1932
+
1933
+    $session = wpinv_get_checkout_session();
1934
+    if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) {
1935
+        $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key'];
1936
+
1937
+        if ( wpinv_require_login_to_checkout() ) {
1938
+            $return = $return && $check_key === $invoice_key;
1939
+        } else {
1940
+            $return = $check_key === $invoice_key;
1941
+        }
1942
+    }
1943
+
1944
+    return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key );
1945 1945
 }
1946 1946
 
1947 1947
 function wpinv_pay_for_invoice() {
Please login to merge, or discard this patch.