Passed
Push — master ( f7b81c...169dfd )
by Stiofan
04:09
created
includes/wpinv-invoice-functions.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 }
665 665
 
666 666
 function wpinv_get_payment_key( $invoice_id = 0 ) {
667
-	$invoice = new WPInv_Invoice( $invoice_id );
667
+    $invoice = new WPInv_Invoice( $invoice_id );
668 668
     return $invoice->get_key();
669 669
 }
670 670
 
@@ -1197,20 +1197,20 @@  discard block
 block discarded – undo
1197 1197
 }
1198 1198
 
1199 1199
 function wpinv_checkout_get_cc_info() {
1200
-	$cc_info = array();
1201
-	$cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
1202
-	$cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
1203
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
1204
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
1205
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
1206
-	$cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
1207
-	$cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
1208
-	$cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
1209
-	$cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
1210
-	$cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
1211
-
1212
-	// Return cc info
1213
-	return $cc_info;
1200
+    $cc_info = array();
1201
+    $cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
1202
+    $cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
1203
+    $cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
1204
+    $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
1205
+    $cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
1206
+    $cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
1207
+    $cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
1208
+    $cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
1209
+    $cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
1210
+    $cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
1211
+
1212
+    // Return cc info
1213
+    return $cc_info;
1214 1214
 }
1215 1215
 
1216 1216
 function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
         $required_fields  = wpinv_checkout_required_fields();
1408 1408
 
1409 1409
         // Loop through required fields and show error messages
1410
-         if ( !empty( $required_fields ) ) {
1410
+            if ( !empty( $required_fields ) ) {
1411 1411
             foreach ( $required_fields as $field_name => $value ) {
1412 1412
                 if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
1413 1413
                     wpinv_set_error( $value['error_id'], $value['error_message'] );
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 }
1508 1508
 
1509 1509
 function wpinv_get_checkout_session() {
1510
-	global $wpi_session;
1510
+    global $wpi_session;
1511 1511
     
1512 1512
     return $wpi_session->get( 'wpinv_checkout' );
1513 1513
 }
@@ -1859,53 +1859,53 @@  discard block
 block discarded – undo
1859 1859
 }
1860 1860
 
1861 1861
 function wpinv_get_invoice_id_by_key( $key ) {
1862
-	global $wpdb;
1862
+    global $wpdb;
1863 1863
 
1864
-	$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 ) );
1864
+    $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 ) );
1865 1865
 
1866
-	if ( $invoice_id != NULL )
1867
-		return $invoice_id;
1866
+    if ( $invoice_id != NULL )
1867
+        return $invoice_id;
1868 1868
 
1869
-	return 0;
1869
+    return 0;
1870 1870
 }
1871 1871
 
1872 1872
 function wpinv_can_view_receipt( $invoice_key = '' ) {
1873
-	$return = false;
1873
+    $return = false;
1874 1874
 
1875
-	if ( empty( $invoice_key ) ) {
1876
-		return $return;
1877
-	}
1875
+    if ( empty( $invoice_key ) ) {
1876
+        return $return;
1877
+    }
1878 1878
 
1879
-	global $wpinv_receipt_args;
1879
+    global $wpinv_receipt_args;
1880 1880
 
1881
-	$wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key );
1882
-	if ( isset( $_GET['invoice-id'] ) ) {
1883
-		$wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0;
1884
-	}
1881
+    $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key );
1882
+    if ( isset( $_GET['invoice-id'] ) ) {
1883
+        $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0;
1884
+    }
1885 1885
 
1886
-	if ( empty( $wpinv_receipt_args['id'] ) ) {
1887
-		return $return;
1888
-	}
1886
+    if ( empty( $wpinv_receipt_args['id'] ) ) {
1887
+        return $return;
1888
+    }
1889 1889
 
1890
-	$invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] );
1891
-	if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) {
1892
-		return $return;
1893
-	}
1890
+    $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] );
1891
+    if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) {
1892
+        return $return;
1893
+    }
1894 1894
 
1895 1895
     if ( is_user_logged_in() ) {
1896
-		if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) {
1897
-			$return = true;
1898
-		}
1899
-	}
1900
-
1901
-	$session = wpinv_get_checkout_session();
1902
-	if ( isset( $_GET['invoice_key'] ) ) {
1903
-		$return = $_GET['invoice_key'] === $invoice_key;
1904
-	} else if ( $session && isset( $session['invoice_key'] ) ) {
1905
-		$return = $session['invoice_key'] === $invoice_key;
1906
-	}
1907
-
1908
-	return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key );
1896
+        if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) {
1897
+            $return = true;
1898
+        }
1899
+    }
1900
+
1901
+    $session = wpinv_get_checkout_session();
1902
+    if ( isset( $_GET['invoice_key'] ) ) {
1903
+        $return = $_GET['invoice_key'] === $invoice_key;
1904
+    } else if ( $session && isset( $session['invoice_key'] ) ) {
1905
+        $return = $session['invoice_key'] === $invoice_key;
1906
+    }
1907
+
1908
+    return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key );
1909 1909
 }
1910 1910
 
1911 1911
 function wpinv_pay_for_invoice() {
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Braces   +26 added lines, -17 removed lines patch added patch discarded remove patch
@@ -169,8 +169,9 @@  discard block
 block discarded – undo
169 169
 
170 170
 	// Setup possible parts
171 171
 	$templates = array();
172
-	if ( isset( $name ) )
173
-		$templates[] = $slug . '-' . $name . '.php';
172
+	if ( isset( $name ) ) {
173
+			$templates[] = $slug . '-' . $name . '.php';
174
+	}
174 175
 	$templates[] = $slug . '.php';
175 176
 
176 177
 	// Allow template parts to be filtered
@@ -188,8 +189,9 @@  discard block
 block discarded – undo
188 189
 	foreach ( (array)$template_names as $template_name ) {
189 190
 
190 191
 		// Continue if template is empty
191
-		if ( empty( $template_name ) )
192
-			continue;
192
+		if ( empty( $template_name ) ) {
193
+					continue;
194
+		}
193 195
 
194 196
 		// Trim off any slashes from the template name
195 197
 		$template_name = ltrim( $template_name, '/' );
@@ -208,8 +210,9 @@  discard block
 block discarded – undo
208 210
 		}
209 211
 	}
210 212
 
211
-	if ( ( true == $load ) && ! empty( $located ) )
212
-		load_template( $located, $require_once );
213
+	if ( ( true == $load ) && ! empty( $located ) ) {
214
+			load_template( $located, $require_once );
215
+	}
213 216
 
214 217
 	return $located;
215 218
 }
@@ -285,8 +288,9 @@  discard block
 block discarded – undo
285 288
 function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
286 289
     $args = array( 'nopaging' => true );
287 290
 
288
-    if ( ! empty( $status ) )
289
-        $args['post_status'] = $status;
291
+    if ( ! empty( $status ) ) {
292
+            $args['post_status'] = $status;
293
+    }
290 294
 
291 295
     $discounts = wpinv_get_discounts( $args );
292 296
     $options   = array();
@@ -893,8 +897,11 @@  discard block
 block discarded – undo
893 897
     
894 898
     $invoice_status = wpinv_get_invoice_status( $invoice_id );
895 899
     
896
-    if($invoice->post_type == 'wpi_invoice') $type = 'Invoice';
897
-    elseif($invoice->post_type == 'wpi_quote') $type = 'Quote';
900
+    if($invoice->post_type == 'wpi_invoice') {
901
+        $type = 'Invoice';
902
+    } elseif($invoice->post_type == 'wpi_quote') {
903
+        $type = 'Quote';
904
+    }
898 905
     ?>
899 906
     <table class="table table-bordered table-sm">
900 907
         <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
@@ -1461,17 +1468,19 @@  discard block
 block discarded – undo
1461 1468
 add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1462 1469
 
1463 1470
 function wpinv_save_cart_button() {
1464
-    if ( wpinv_is_cart_saving_disabled() )
1465
-        return;
1466
-?>
1471
+    if ( wpinv_is_cart_saving_disabled() ) {
1472
+            return;
1473
+    }
1474
+    ?>
1467 1475
     <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a>
1468 1476
 <?php
1469 1477
 }
1470 1478
 
1471 1479
 function wpinv_update_cart_button() {
1472
-    if ( !wpinv_item_quantities_enabled() )
1473
-        return;
1474
-?>
1480
+    if ( !wpinv_item_quantities_enabled() ) {
1481
+            return;
1482
+    }
1483
+    ?>
1475 1484
     <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1476 1485
     <input type="hidden" name="wpi_action" value="update_cart"/>
1477 1486
 <?php
@@ -1612,7 +1621,7 @@  discard block
 block discarded – undo
1612 1621
 		                    </div>
1613 1622
 		                    <?php
1614 1623
 	                    }
1615
-                    }else{
1624
+                    } else{
1616 1625
 	                    echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>';
1617 1626
                     }
1618 1627
 
Please login to merge, or discard this patch.