Passed
Push — master ( ae5aa5...55fff1 )
by Brian
05:20
created
includes/wpinv-payment-functions.php 2 patches
Indentation   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -1,196 +1,196 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 function wpinv_is_subscription_payment( $invoice = '' ) {
3
-	if ( empty( $invoice ) ) {
4
-		return false;
5
-	}
3
+    if ( empty( $invoice ) ) {
4
+        return false;
5
+    }
6 6
 
7
-	if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) {
8
-		$invoice = wpinv_get_invoice( $invoice );
9
-	}
7
+    if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) {
8
+        $invoice = wpinv_get_invoice( $invoice );
9
+    }
10 10
 
11
-	if ( empty( $invoice ) ) {
12
-		return false;
13
-	}
11
+    if ( empty( $invoice ) ) {
12
+        return false;
13
+    }
14 14
 
15
-	if ( $invoice->is_renewal() ) {
16
-		return true;
17
-	}
15
+    if ( $invoice->is_renewal() ) {
16
+        return true;
17
+    }
18 18
 
19
-	return false;
19
+    return false;
20 20
 }
21 21
 
22 22
 function wpinv_payment_link_transaction_id( $invoice = '' ) {
23
-	if ( empty( $invoice ) ) {
24
-		return false;
25
-	}
23
+    if ( empty( $invoice ) ) {
24
+        return false;
25
+    }
26 26
 
27
-	if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) {
28
-		$invoice = wpinv_get_invoice( $invoice );
29
-	}
27
+    if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) {
28
+        $invoice = wpinv_get_invoice( $invoice );
29
+    }
30 30
 
31
-	if ( empty( $invoice ) ) {
32
-		return false;
33
-	}
31
+    if ( empty( $invoice ) ) {
32
+        return false;
33
+    }
34 34
 
35
-	return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice );
35
+    return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice );
36 36
 }
37 37
 
38 38
 function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) {
39
-	$interval   = (int)$interval > 0 ? (int)$interval : 1;
40
-
41
-	if ( $trial_interval > 0 && ! empty( $trial_period ) ) {
42
-		$amount = __( 'Free', 'invoicing' );
43
-		$interval = $trial_interval;
44
-		$period = $trial_period;
45
-	}
46
-
47
-	$description = '';
48
-	switch ( $period ) {
49
-		case 'D':
50
-		case 'day':
51
-			$description = wp_sprintf( _n( '%s for the first day.', '%1$s for the first %2$d days.', $interval, 'invoicing' ), $amount, $interval );
52
-			break;
53
-		case 'W':
54
-		case 'week':
55
-			$description = wp_sprintf( _n( '%s for the first week.', '%1$s for the first %2$d weeks.', $interval, 'invoicing' ), $amount, $interval );
56
-			break;
57
-		case 'M':
58
-		case 'month':
59
-			$description = wp_sprintf( _n( '%s for the first month.', '%1$s for the first %2$d months.', $interval, 'invoicing' ), $amount, $interval );
60
-			break;
61
-		case 'Y':
62
-		case 'year':
63
-			$description = wp_sprintf( _n( '%s for the first year.', '%1$s for the first %2$d years.', $interval, 'invoicing' ), $amount, $interval );
64
-			break;
65
-	}
66
-
67
-	return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval );
39
+    $interval   = (int)$interval > 0 ? (int)$interval : 1;
40
+
41
+    if ( $trial_interval > 0 && ! empty( $trial_period ) ) {
42
+        $amount = __( 'Free', 'invoicing' );
43
+        $interval = $trial_interval;
44
+        $period = $trial_period;
45
+    }
46
+
47
+    $description = '';
48
+    switch ( $period ) {
49
+        case 'D':
50
+        case 'day':
51
+            $description = wp_sprintf( _n( '%s for the first day.', '%1$s for the first %2$d days.', $interval, 'invoicing' ), $amount, $interval );
52
+            break;
53
+        case 'W':
54
+        case 'week':
55
+            $description = wp_sprintf( _n( '%s for the first week.', '%1$s for the first %2$d weeks.', $interval, 'invoicing' ), $amount, $interval );
56
+            break;
57
+        case 'M':
58
+        case 'month':
59
+            $description = wp_sprintf( _n( '%s for the first month.', '%1$s for the first %2$d months.', $interval, 'invoicing' ), $amount, $interval );
60
+            break;
61
+        case 'Y':
62
+        case 'year':
63
+            $description = wp_sprintf( _n( '%s for the first year.', '%1$s for the first %2$d years.', $interval, 'invoicing' ), $amount, $interval );
64
+            break;
65
+    }
66
+
67
+    return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval );
68 68
 }
69 69
 
70 70
 function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) {
71
-	$interval   = (int)$interval > 0 ? (int)$interval : 1;
72
-	$bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0;
73
-
74
-	$description = '';
75
-	switch ( $period ) {
76
-		case 'D':
77
-		case 'day':
78
-			if ( (int)$bill_times > 0 ) {
79
-				if ( $interval > 1 ) {
80
-					if ( $bill_times > 1 ) {
81
-						$description = wp_sprintf( __( '%1$s for each %2$d days, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
82
-					} else {
83
-						$description = wp_sprintf( __( '%1$s for %2$d days.', 'invoicing' ), $amount, $interval );
84
-					}
85
-				} else {
86
-					$description = wp_sprintf( _n( '%s for one day.', '%1$s for each day, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
87
-				}
88
-			} else {
89
-				$description = wp_sprintf( _n( '%s for each day.', '%1$s for each %2$d days.', $interval, 'invoicing' ), $amount, $interval );
90
-			}
91
-			break;
92
-		case 'W':
93
-		case 'week':
94
-			if ( (int)$bill_times > 0 ) {
95
-				if ( $interval > 1 ) {
96
-					if ( $bill_times > 1 ) {
97
-						$description = wp_sprintf( __( '%1$s for each %2$d weeks, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
98
-					} else {
99
-						$description = wp_sprintf( __( '%1$s for %2$d weeks.', 'invoicing' ), $amount, $interval );
100
-					}
101
-				} else {
102
-					$description = wp_sprintf( _n( '%s for one week.', '%1$s for each week, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
103
-				}
104
-			} else {
105
-				$description = wp_sprintf( _n( '%s for each week.', '%1$s for each %2$d weeks.', $interval, 'invoicing' ), $amount, $interval );
106
-			}
107
-			break;
108
-		case 'M':
109
-		case 'month':
110
-			if ( (int)$bill_times > 0 ) {
111
-				if ( $interval > 1 ) {
112
-					if ( $bill_times > 1 ) {
113
-						$description = wp_sprintf( __( '%1$s for each %2$d months, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
114
-					} else {
115
-						$description = wp_sprintf( __( '%1$s for %2$d months.', 'invoicing' ), $amount, $interval );
116
-					}
117
-				} else {
118
-					$description = wp_sprintf( _n( '%s for one month.', '%1$s for each month, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
119
-				}
120
-			} else {
121
-				$description = wp_sprintf( _n( '%s for each month.', '%1$s for each %2$d months.', $interval, 'invoicing' ), $amount, $interval );
122
-			}
123
-			break;
124
-		case 'Y':
125
-		case 'year':
126
-			if ( (int)$bill_times > 0 ) {
127
-				if ( $interval > 1 ) {
128
-					if ( $bill_times > 1 ) {
129
-						$description = wp_sprintf( __( '%1$s for each %2$d years, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
130
-					} else {
131
-						$description = wp_sprintf( __( '%1$s for %2$d years.', 'invoicing' ), $amount, $interval );
132
-					}
133
-				} else {
134
-					$description = wp_sprintf( _n( '%s for one year.', '%1$s for each year, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
135
-				}
136
-			} else {
137
-				$description = wp_sprintf( _n( '%s for each year.', '%1$s for each %2$d years.', $interval, 'invoicing' ), $amount, $interval );
138
-			}
139
-			break;
140
-	}
141
-
142
-	return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
71
+    $interval   = (int)$interval > 0 ? (int)$interval : 1;
72
+    $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0;
73
+
74
+    $description = '';
75
+    switch ( $period ) {
76
+        case 'D':
77
+        case 'day':
78
+            if ( (int)$bill_times > 0 ) {
79
+                if ( $interval > 1 ) {
80
+                    if ( $bill_times > 1 ) {
81
+                        $description = wp_sprintf( __( '%1$s for each %2$d days, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
82
+                    } else {
83
+                        $description = wp_sprintf( __( '%1$s for %2$d days.', 'invoicing' ), $amount, $interval );
84
+                    }
85
+                } else {
86
+                    $description = wp_sprintf( _n( '%s for one day.', '%1$s for each day, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
87
+                }
88
+            } else {
89
+                $description = wp_sprintf( _n( '%s for each day.', '%1$s for each %2$d days.', $interval, 'invoicing' ), $amount, $interval );
90
+            }
91
+            break;
92
+        case 'W':
93
+        case 'week':
94
+            if ( (int)$bill_times > 0 ) {
95
+                if ( $interval > 1 ) {
96
+                    if ( $bill_times > 1 ) {
97
+                        $description = wp_sprintf( __( '%1$s for each %2$d weeks, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
98
+                    } else {
99
+                        $description = wp_sprintf( __( '%1$s for %2$d weeks.', 'invoicing' ), $amount, $interval );
100
+                    }
101
+                } else {
102
+                    $description = wp_sprintf( _n( '%s for one week.', '%1$s for each week, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
103
+                }
104
+            } else {
105
+                $description = wp_sprintf( _n( '%s for each week.', '%1$s for each %2$d weeks.', $interval, 'invoicing' ), $amount, $interval );
106
+            }
107
+            break;
108
+        case 'M':
109
+        case 'month':
110
+            if ( (int)$bill_times > 0 ) {
111
+                if ( $interval > 1 ) {
112
+                    if ( $bill_times > 1 ) {
113
+                        $description = wp_sprintf( __( '%1$s for each %2$d months, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
114
+                    } else {
115
+                        $description = wp_sprintf( __( '%1$s for %2$d months.', 'invoicing' ), $amount, $interval );
116
+                    }
117
+                } else {
118
+                    $description = wp_sprintf( _n( '%s for one month.', '%1$s for each month, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
119
+                }
120
+            } else {
121
+                $description = wp_sprintf( _n( '%s for each month.', '%1$s for each %2$d months.', $interval, 'invoicing' ), $amount, $interval );
122
+            }
123
+            break;
124
+        case 'Y':
125
+        case 'year':
126
+            if ( (int)$bill_times > 0 ) {
127
+                if ( $interval > 1 ) {
128
+                    if ( $bill_times > 1 ) {
129
+                        $description = wp_sprintf( __( '%1$s for each %2$d years, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
130
+                    } else {
131
+                        $description = wp_sprintf( __( '%1$s for %2$d years.', 'invoicing' ), $amount, $interval );
132
+                    }
133
+                } else {
134
+                    $description = wp_sprintf( _n( '%s for one year.', '%1$s for each year, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
135
+                }
136
+            } else {
137
+                $description = wp_sprintf( _n( '%s for each year.', '%1$s for each %2$d years.', $interval, 'invoicing' ), $amount, $interval );
138
+            }
139
+            break;
140
+    }
141
+
142
+    return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
143 143
 }
144 144
 
145 145
 function wpinv_subscription_payment_desc( $invoice ) {
146
-	if ( empty( $invoice ) ) {
147
-		return null;
148
-	}
149
-
150
-	$description = '';
151
-	if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) {
152
-		if ( $item->has_free_trial() ) {
153
-			$trial_period = $item->get_trial_period();
154
-			$trial_interval = $item->get_trial_interval();
155
-		} else {
156
-			$trial_period = '';
157
-			$trial_interval = 0;
158
-		}
159
-
160
-		$description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() );
161
-	}
162
-
163
-	return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice );
146
+    if ( empty( $invoice ) ) {
147
+        return null;
148
+    }
149
+
150
+    $description = '';
151
+    if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) {
152
+        if ( $item->has_free_trial() ) {
153
+            $trial_period = $item->get_trial_period();
154
+            $trial_interval = $item->get_trial_interval();
155
+        } else {
156
+            $trial_period = '';
157
+            $trial_interval = 0;
158
+        }
159
+
160
+        $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() );
161
+    }
162
+
163
+    return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice );
164 164
 }
165 165
 
166 166
 function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) {
167
-	$initial_total      = wpinv_round_amount( $initial );
168
-	$recurring_total    = wpinv_round_amount( $recurring );
167
+    $initial_total      = wpinv_round_amount( $initial );
168
+    $recurring_total    = wpinv_round_amount( $recurring );
169 169
 
170
-	if ( $trial_interval > 0 && ! empty( $trial_period ) ) {
171
-		// Free trial
172
-	} else {
173
-		if ( $bill_times == 1 ) {
174
-			$recurring_total = $initial_total;
175
-		} elseif ( $bill_times > 1 && $initial_total != $recurring_total ) {
176
-			$bill_times--;
177
-		}
178
-	}
170
+    if ( $trial_interval > 0 && ! empty( $trial_period ) ) {
171
+        // Free trial
172
+    } else {
173
+        if ( $bill_times == 1 ) {
174
+            $recurring_total = $initial_total;
175
+        } elseif ( $bill_times > 1 && $initial_total != $recurring_total ) {
176
+            $bill_times--;
177
+        }
178
+    }
179 179
 
180
-	$initial_amount     = wpinv_price( $initial_total, $currency );
181
-	$recurring_amount   = wpinv_price( $recurring_total, $currency );
180
+    $initial_amount     = wpinv_price( $initial_total, $currency );
181
+    $recurring_amount   = wpinv_price( $recurring_total, $currency );
182 182
 
183
-	$recurring          = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
183
+    $recurring          = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
184 184
 
185
-	if ( $initial_total != $recurring_total ) {
186
-		$initial        = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval );
185
+    if ( $initial_total != $recurring_total ) {
186
+        $initial        = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval );
187 187
 
188
-		$description    = wp_sprintf( __( '%1$s Then %2$s', 'invoicing' ), $initial, $recurring );
189
-	} else {
190
-		$description    = $recurring;
191
-	}
188
+        $description    = wp_sprintf( __( '%1$s Then %2$s', 'invoicing' ), $initial, $recurring );
189
+    } else {
190
+        $description    = $recurring;
191
+    }
192 192
 
193
-	return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency );
193
+    return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency );
194 194
 }
195 195
 
196 196
 /**
@@ -202,25 +202,25 @@  discard block
 block discarded – undo
202 202
  */
203 203
 function getpaid_get_card_name( $card_number ) {
204 204
 
205
-	// Known regexes.
206
-	$regexes = array(
207
-		'/^4/'                     => __( 'Visa', 'invoicing' ),
208
-		'/^5[1-5]/'                => __( 'Mastercard', 'invoicing' ),
209
-		'/^3[47]/'                 => __( 'Amex', 'invoicing' ),
210
-		'/^3(?:0[0-5]|[68])/'      => __( 'Diners Club', 'invoicing' ),
211
-		'/^6(?:011|5)/'            => __( 'Discover', 'invoicing' ),
212
-		'/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ),
213
-	);
214
-
215
-	// Confirm if one matches.
216
-	foreach ( $regexes as $regex => $card ) {
217
-		if ( preg_match( $regex, $card_number ) >= 1 ) {
218
-			return $card;
219
-		}
220
-	}
221
-
222
-	// None matched.
223
-	return __( 'Card', 'invoicing' );
205
+    // Known regexes.
206
+    $regexes = array(
207
+        '/^4/'                     => __( 'Visa', 'invoicing' ),
208
+        '/^5[1-5]/'                => __( 'Mastercard', 'invoicing' ),
209
+        '/^3[47]/'                 => __( 'Amex', 'invoicing' ),
210
+        '/^3(?:0[0-5]|[68])/'      => __( 'Diners Club', 'invoicing' ),
211
+        '/^6(?:011|5)/'            => __( 'Discover', 'invoicing' ),
212
+        '/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ),
213
+    );
214
+
215
+    // Confirm if one matches.
216
+    foreach ( $regexes as $regex => $card ) {
217
+        if ( preg_match( $regex, $card_number ) >= 1 ) {
218
+            return $card;
219
+        }
220
+    }
221
+
222
+    // None matched.
223
+    return __( 'Card', 'invoicing' );
224 224
 
225 225
 }
226 226
 
@@ -230,24 +230,24 @@  discard block
 block discarded – undo
230 230
  * @param WPInv_Invoice|int|null $invoice
231 231
  */
232 232
 function wpinv_send_back_to_checkout( $invoice = null ) {
233
-	$response = array( 'success' => false );
234
-	$invoice  = wpinv_get_invoice( $invoice );
235
-
236
-	// Was an invoice created?
237
-	if ( ! empty( $invoice ) ) {
238
-		$invoice             = is_scalar( $invoice ) ? new WPInv_Invoice( $invoice ) : $invoice;
239
-		$response['invoice'] = $invoice->get_id();
240
-		do_action( 'getpaid_checkout_invoice_exception', $invoice );
241
-	}
242
-
243
-	// Do we have any errors?
244
-	if ( wpinv_get_errors() ) {
245
-		$response['data'] = getpaid_get_errors_html( true, false );
246
-	} else {
247
-		$response['data'] = __( 'An error occured while processing your payment. Please try again.', 'invoicing' );
248
-	}
249
-
250
-	wp_send_json( $response );
233
+    $response = array( 'success' => false );
234
+    $invoice  = wpinv_get_invoice( $invoice );
235
+
236
+    // Was an invoice created?
237
+    if ( ! empty( $invoice ) ) {
238
+        $invoice             = is_scalar( $invoice ) ? new WPInv_Invoice( $invoice ) : $invoice;
239
+        $response['invoice'] = $invoice->get_id();
240
+        do_action( 'getpaid_checkout_invoice_exception', $invoice );
241
+    }
242
+
243
+    // Do we have any errors?
244
+    if ( wpinv_get_errors() ) {
245
+        $response['data'] = getpaid_get_errors_html( true, false );
246
+    } else {
247
+        $response['data'] = __( 'An error occured while processing your payment. Please try again.', 'invoicing' );
248
+    }
249
+
250
+    wp_send_json( $response );
251 251
 }
252 252
 
253 253
 /**
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
  * @return string
257 257
  */
258 258
 function getpaid_get_recaptcha_site_key() {
259
-	return apply_filters( 'getpaid_recaptcha_site_key', wpinv_get_option( 'recaptcha_site_key', '' ) );
259
+    return apply_filters( 'getpaid_recaptcha_site_key', wpinv_get_option( 'recaptcha_site_key', '' ) );
260 260
 }
261 261
 
262 262
 /**
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
  * @return string
266 266
  */
267 267
 function getpaid_get_recaptcha_secret_key() {
268
-	return apply_filters( 'getpaid_recaptcha_secret_key', wpinv_get_option( 'recaptcha_secret_key', '' ) );
268
+    return apply_filters( 'getpaid_recaptcha_secret_key', wpinv_get_option( 'recaptcha_secret_key', '' ) );
269 269
 }
270 270
 
271 271
 /**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
  * @return bool
275 275
  */
276 276
 function getpaid_is_recaptcha_enabled() {
277
-	return wpinv_get_option( 'enable_recaptcha', false ) && getpaid_get_recaptcha_site_key() && getpaid_get_recaptcha_secret_key();
277
+    return wpinv_get_option( 'enable_recaptcha', false ) && getpaid_get_recaptcha_site_key() && getpaid_get_recaptcha_secret_key();
278 278
 }
279 279
 
280 280
 /**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
  * @return string
284 284
  */
285 285
 function getpaid_get_recaptcha_version() {
286
-	return apply_filters( 'getpaid_recaptcha_version', wpinv_get_option( 'recaptcha_version', 'v2' ) );
286
+    return apply_filters( 'getpaid_recaptcha_version', wpinv_get_option( 'recaptcha_version', 'v2' ) );
287 287
 }
288 288
 
289 289
 /**
@@ -292,42 +292,42 @@  discard block
 block discarded – undo
292 292
  * @return array
293 293
  */
294 294
 function getpaid_get_recaptcha_settings() {
295
-	$settings = array(
296
-		'enabled' => getpaid_is_recaptcha_enabled(),
297
-		'version' => getpaid_get_recaptcha_version(),
298
-	);
299
-
300
-	if ( ! getpaid_is_recaptcha_enabled() ) {
301
-		return $settings;
302
-	}
303
-
304
-	$settings['sitekey'] = getpaid_get_recaptcha_site_key();
305
-
306
-	// Version 2 render params.
307
-	if ( 'v2' === getpaid_get_recaptcha_version() ) {
308
-		$settings['render_params'] = array(
309
-			'sitekey'  => getpaid_get_recaptcha_site_key(),
310
-			'theme'    => 'light',
311
-			'size'     => 'normal',
312
-			'tabindex' => 0,
313
-		);
314
-	}
315
-
316
-	return apply_filters( 'getpaid_recaptcha_settings', $settings );
295
+    $settings = array(
296
+        'enabled' => getpaid_is_recaptcha_enabled(),
297
+        'version' => getpaid_get_recaptcha_version(),
298
+    );
299
+
300
+    if ( ! getpaid_is_recaptcha_enabled() ) {
301
+        return $settings;
302
+    }
303
+
304
+    $settings['sitekey'] = getpaid_get_recaptcha_site_key();
305
+
306
+    // Version 2 render params.
307
+    if ( 'v2' === getpaid_get_recaptcha_version() ) {
308
+        $settings['render_params'] = array(
309
+            'sitekey'  => getpaid_get_recaptcha_site_key(),
310
+            'theme'    => 'light',
311
+            'size'     => 'normal',
312
+            'tabindex' => 0,
313
+        );
314
+    }
315
+
316
+    return apply_filters( 'getpaid_recaptcha_settings', $settings );
317 317
 }
318 318
 
319 319
 /**
320 320
  * Displays reCAPTCHA before payment button.
321 321
  */
322 322
 function getpaid_display_recaptcha_before_payment_button() {
323
-	if ( ! getpaid_is_recaptcha_enabled() || 'v2' !== getpaid_get_recaptcha_version() ) {
324
-		return;
325
-	}
326
-
327
-	printf(
328
-		'<div class="getpaid-recaptcha-wrapper"><div class="g-recaptcha mw-100 overflow-hidden my-2" id="getpaid-recaptcha-%s"></div></div>',
329
-		esc_attr( wp_unique_id() )
330
-	);
323
+    if ( ! getpaid_is_recaptcha_enabled() || 'v2' !== getpaid_get_recaptcha_version() ) {
324
+        return;
325
+    }
326
+
327
+    printf(
328
+        '<div class="getpaid-recaptcha-wrapper"><div class="g-recaptcha mw-100 overflow-hidden my-2" id="getpaid-recaptcha-%s"></div></div>',
329
+        esc_attr( wp_unique_id() )
330
+    );
331 331
 }
332 332
 add_action( 'getpaid_before_payment_form_pay_button', 'getpaid_display_recaptcha_before_payment_button' );
333 333
 
@@ -338,43 +338,43 @@  discard block
 block discarded – undo
338 338
  */
339 339
 function getpaid_validate_recaptcha_response( $submission ) {
340 340
 
341
-	// Check if reCAPTCHA is enabled.
342
-	if ( ! getpaid_is_recaptcha_enabled() ) {
343
-		return;
344
-	}
345
-
346
-	$token = $submission->get_field( 'g-recaptcha-response' );
347
-
348
-	// Abort if no token was provided.
349
-	if ( empty( $token ) ) {
350
-		wp_send_json_error( 'v2' === getpaid_get_recaptcha_version() ? __( 'Please confirm that you are not a robot.', 'invoicing' ) : __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
351
-	}
352
-
353
-	$result = wp_remote_post(
354
-		'https://www.google.com/recaptcha/api/siteverify',
355
-		array(
356
-			'body' => array(
357
-				'secret'   => getpaid_get_recaptcha_secret_key(),
358
-				'response' => $token,
359
-			),
360
-		)
361
-	);
362
-
363
-	// Site not reachable, give benefit of doubt.
364
-	if ( is_wp_error( $result ) ) {
365
-		return;
366
-	}
367
-
368
-	$result = json_decode( wp_remote_retrieve_body( $result ), true );
369
-
370
-	if ( empty( $result['success'] ) && ! in_array( 'missing-input-secret', $result['error-codes'], true ) && ! in_array( 'invalid-input-secret', $result['error-codes'], true ) ) {
371
-		wp_send_json_error( __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
372
-	}
373
-
374
-	// For v3, check the score.
375
-	$minimum_score = apply_filters( 'getpaid_recaptcha_minimum_score', 0.4 );
376
-	if ( 'v3' === getpaid_get_recaptcha_version() && ( empty( $result['score'] ) || $result['score'] < $minimum_score ) ) {
377
-		wp_send_json_error( __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
378
-	}
341
+    // Check if reCAPTCHA is enabled.
342
+    if ( ! getpaid_is_recaptcha_enabled() ) {
343
+        return;
344
+    }
345
+
346
+    $token = $submission->get_field( 'g-recaptcha-response' );
347
+
348
+    // Abort if no token was provided.
349
+    if ( empty( $token ) ) {
350
+        wp_send_json_error( 'v2' === getpaid_get_recaptcha_version() ? __( 'Please confirm that you are not a robot.', 'invoicing' ) : __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
351
+    }
352
+
353
+    $result = wp_remote_post(
354
+        'https://www.google.com/recaptcha/api/siteverify',
355
+        array(
356
+            'body' => array(
357
+                'secret'   => getpaid_get_recaptcha_secret_key(),
358
+                'response' => $token,
359
+            ),
360
+        )
361
+    );
362
+
363
+    // Site not reachable, give benefit of doubt.
364
+    if ( is_wp_error( $result ) ) {
365
+        return;
366
+    }
367
+
368
+    $result = json_decode( wp_remote_retrieve_body( $result ), true );
369
+
370
+    if ( empty( $result['success'] ) && ! in_array( 'missing-input-secret', $result['error-codes'], true ) && ! in_array( 'invalid-input-secret', $result['error-codes'], true ) ) {
371
+        wp_send_json_error( __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
372
+    }
373
+
374
+    // For v3, check the score.
375
+    $minimum_score = apply_filters( 'getpaid_recaptcha_minimum_score', 0.4 );
376
+    if ( 'v3' === getpaid_get_recaptcha_version() && ( empty( $result['score'] ) || $result['score'] < $minimum_score ) ) {
377
+        wp_send_json_error( __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
378
+    }
379 379
 }
380 380
 add_action( 'getpaid_checkout_error_checks', 'getpaid_validate_recaptcha_response' );
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -1,155 +1,155 @@  discard block
 block discarded – undo
1 1
 <?php
2
-function wpinv_is_subscription_payment( $invoice = '' ) {
3
-	if ( empty( $invoice ) ) {
2
+function wpinv_is_subscription_payment($invoice = '') {
3
+	if (empty($invoice)) {
4 4
 		return false;
5 5
 	}
6 6
 
7
-	if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) {
8
-		$invoice = wpinv_get_invoice( $invoice );
7
+	if (!is_object($invoice) && is_scalar($invoice)) {
8
+		$invoice = wpinv_get_invoice($invoice);
9 9
 	}
10 10
 
11
-	if ( empty( $invoice ) ) {
11
+	if (empty($invoice)) {
12 12
 		return false;
13 13
 	}
14 14
 
15
-	if ( $invoice->is_renewal() ) {
15
+	if ($invoice->is_renewal()) {
16 16
 		return true;
17 17
 	}
18 18
 
19 19
 	return false;
20 20
 }
21 21
 
22
-function wpinv_payment_link_transaction_id( $invoice = '' ) {
23
-	if ( empty( $invoice ) ) {
22
+function wpinv_payment_link_transaction_id($invoice = '') {
23
+	if (empty($invoice)) {
24 24
 		return false;
25 25
 	}
26 26
 
27
-	if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) {
28
-		$invoice = wpinv_get_invoice( $invoice );
27
+	if (!is_object($invoice) && is_scalar($invoice)) {
28
+		$invoice = wpinv_get_invoice($invoice);
29 29
 	}
30 30
 
31
-	if ( empty( $invoice ) ) {
31
+	if (empty($invoice)) {
32 32
 		return false;
33 33
 	}
34 34
 
35
-	return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice );
35
+	return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice);
36 36
 }
37 37
 
38
-function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) {
39
-	$interval   = (int)$interval > 0 ? (int)$interval : 1;
38
+function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) {
39
+	$interval = (int) $interval > 0 ? (int) $interval : 1;
40 40
 
41
-	if ( $trial_interval > 0 && ! empty( $trial_period ) ) {
42
-		$amount = __( 'Free', 'invoicing' );
41
+	if ($trial_interval > 0 && !empty($trial_period)) {
42
+		$amount = __('Free', 'invoicing');
43 43
 		$interval = $trial_interval;
44 44
 		$period = $trial_period;
45 45
 	}
46 46
 
47 47
 	$description = '';
48
-	switch ( $period ) {
48
+	switch ($period) {
49 49
 		case 'D':
50 50
 		case 'day':
51
-			$description = wp_sprintf( _n( '%s for the first day.', '%1$s for the first %2$d days.', $interval, 'invoicing' ), $amount, $interval );
51
+			$description = wp_sprintf(_n('%s for the first day.', '%1$s for the first %2$d days.', $interval, 'invoicing'), $amount, $interval);
52 52
 			break;
53 53
 		case 'W':
54 54
 		case 'week':
55
-			$description = wp_sprintf( _n( '%s for the first week.', '%1$s for the first %2$d weeks.', $interval, 'invoicing' ), $amount, $interval );
55
+			$description = wp_sprintf(_n('%s for the first week.', '%1$s for the first %2$d weeks.', $interval, 'invoicing'), $amount, $interval);
56 56
 			break;
57 57
 		case 'M':
58 58
 		case 'month':
59
-			$description = wp_sprintf( _n( '%s for the first month.', '%1$s for the first %2$d months.', $interval, 'invoicing' ), $amount, $interval );
59
+			$description = wp_sprintf(_n('%s for the first month.', '%1$s for the first %2$d months.', $interval, 'invoicing'), $amount, $interval);
60 60
 			break;
61 61
 		case 'Y':
62 62
 		case 'year':
63
-			$description = wp_sprintf( _n( '%s for the first year.', '%1$s for the first %2$d years.', $interval, 'invoicing' ), $amount, $interval );
63
+			$description = wp_sprintf(_n('%s for the first year.', '%1$s for the first %2$d years.', $interval, 'invoicing'), $amount, $interval);
64 64
 			break;
65 65
 	}
66 66
 
67
-	return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval );
67
+	return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval);
68 68
 }
69 69
 
70
-function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) {
71
-	$interval   = (int)$interval > 0 ? (int)$interval : 1;
72
-	$bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0;
70
+function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) {
71
+	$interval   = (int) $interval > 0 ? (int) $interval : 1;
72
+	$bill_times = (int) $bill_times > 0 ? (int) $bill_times : 0;
73 73
 
74 74
 	$description = '';
75
-	switch ( $period ) {
75
+	switch ($period) {
76 76
 		case 'D':
77 77
 		case 'day':
78
-			if ( (int)$bill_times > 0 ) {
79
-				if ( $interval > 1 ) {
80
-					if ( $bill_times > 1 ) {
81
-						$description = wp_sprintf( __( '%1$s for each %2$d days, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
78
+			if ((int) $bill_times > 0) {
79
+				if ($interval > 1) {
80
+					if ($bill_times > 1) {
81
+						$description = wp_sprintf(__('%1$s for each %2$d days, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times);
82 82
 					} else {
83
-						$description = wp_sprintf( __( '%1$s for %2$d days.', 'invoicing' ), $amount, $interval );
83
+						$description = wp_sprintf(__('%1$s for %2$d days.', 'invoicing'), $amount, $interval);
84 84
 					}
85 85
 				} else {
86
-					$description = wp_sprintf( _n( '%s for one day.', '%1$s for each day, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
86
+					$description = wp_sprintf(_n('%s for one day.', '%1$s for each day, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
87 87
 				}
88 88
 			} else {
89
-				$description = wp_sprintf( _n( '%s for each day.', '%1$s for each %2$d days.', $interval, 'invoicing' ), $amount, $interval );
89
+				$description = wp_sprintf(_n('%s for each day.', '%1$s for each %2$d days.', $interval, 'invoicing'), $amount, $interval);
90 90
 			}
91 91
 			break;
92 92
 		case 'W':
93 93
 		case 'week':
94
-			if ( (int)$bill_times > 0 ) {
95
-				if ( $interval > 1 ) {
96
-					if ( $bill_times > 1 ) {
97
-						$description = wp_sprintf( __( '%1$s for each %2$d weeks, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
94
+			if ((int) $bill_times > 0) {
95
+				if ($interval > 1) {
96
+					if ($bill_times > 1) {
97
+						$description = wp_sprintf(__('%1$s for each %2$d weeks, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times);
98 98
 					} else {
99
-						$description = wp_sprintf( __( '%1$s for %2$d weeks.', 'invoicing' ), $amount, $interval );
99
+						$description = wp_sprintf(__('%1$s for %2$d weeks.', 'invoicing'), $amount, $interval);
100 100
 					}
101 101
 				} else {
102
-					$description = wp_sprintf( _n( '%s for one week.', '%1$s for each week, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
102
+					$description = wp_sprintf(_n('%s for one week.', '%1$s for each week, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
103 103
 				}
104 104
 			} else {
105
-				$description = wp_sprintf( _n( '%s for each week.', '%1$s for each %2$d weeks.', $interval, 'invoicing' ), $amount, $interval );
105
+				$description = wp_sprintf(_n('%s for each week.', '%1$s for each %2$d weeks.', $interval, 'invoicing'), $amount, $interval);
106 106
 			}
107 107
 			break;
108 108
 		case 'M':
109 109
 		case 'month':
110
-			if ( (int)$bill_times > 0 ) {
111
-				if ( $interval > 1 ) {
112
-					if ( $bill_times > 1 ) {
113
-						$description = wp_sprintf( __( '%1$s for each %2$d months, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
110
+			if ((int) $bill_times > 0) {
111
+				if ($interval > 1) {
112
+					if ($bill_times > 1) {
113
+						$description = wp_sprintf(__('%1$s for each %2$d months, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times);
114 114
 					} else {
115
-						$description = wp_sprintf( __( '%1$s for %2$d months.', 'invoicing' ), $amount, $interval );
115
+						$description = wp_sprintf(__('%1$s for %2$d months.', 'invoicing'), $amount, $interval);
116 116
 					}
117 117
 				} else {
118
-					$description = wp_sprintf( _n( '%s for one month.', '%1$s for each month, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
118
+					$description = wp_sprintf(_n('%s for one month.', '%1$s for each month, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
119 119
 				}
120 120
 			} else {
121
-				$description = wp_sprintf( _n( '%s for each month.', '%1$s for each %2$d months.', $interval, 'invoicing' ), $amount, $interval );
121
+				$description = wp_sprintf(_n('%s for each month.', '%1$s for each %2$d months.', $interval, 'invoicing'), $amount, $interval);
122 122
 			}
123 123
 			break;
124 124
 		case 'Y':
125 125
 		case 'year':
126
-			if ( (int)$bill_times > 0 ) {
127
-				if ( $interval > 1 ) {
128
-					if ( $bill_times > 1 ) {
129
-						$description = wp_sprintf( __( '%1$s for each %2$d years, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times );
126
+			if ((int) $bill_times > 0) {
127
+				if ($interval > 1) {
128
+					if ($bill_times > 1) {
129
+						$description = wp_sprintf(__('%1$s for each %2$d years, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times);
130 130
 					} else {
131
-						$description = wp_sprintf( __( '%1$s for %2$d years.', 'invoicing' ), $amount, $interval );
131
+						$description = wp_sprintf(__('%1$s for %2$d years.', 'invoicing'), $amount, $interval);
132 132
 					}
133 133
 				} else {
134
-					$description = wp_sprintf( _n( '%s for one year.', '%1$s for each year, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
134
+					$description = wp_sprintf(_n('%s for one year.', '%1$s for each year, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
135 135
 				}
136 136
 			} else {
137
-				$description = wp_sprintf( _n( '%s for each year.', '%1$s for each %2$d years.', $interval, 'invoicing' ), $amount, $interval );
137
+				$description = wp_sprintf(_n('%s for each year.', '%1$s for each %2$d years.', $interval, 'invoicing'), $amount, $interval);
138 138
 			}
139 139
 			break;
140 140
 	}
141 141
 
142
-	return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
142
+	return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
143 143
 }
144 144
 
145
-function wpinv_subscription_payment_desc( $invoice ) {
146
-	if ( empty( $invoice ) ) {
145
+function wpinv_subscription_payment_desc($invoice) {
146
+	if (empty($invoice)) {
147 147
 		return null;
148 148
 	}
149 149
 
150 150
 	$description = '';
151
-	if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) {
152
-		if ( $item->has_free_trial() ) {
151
+	if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) {
152
+		if ($item->has_free_trial()) {
153 153
 			$trial_period = $item->get_trial_period();
154 154
 			$trial_interval = $item->get_trial_interval();
155 155
 		} else {
@@ -157,40 +157,40 @@  discard block
 block discarded – undo
157 157
 			$trial_interval = 0;
158 158
 		}
159 159
 
160
-		$description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() );
160
+		$description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency());
161 161
 	}
162 162
 
163
-	return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice );
163
+	return apply_filters('wpinv_subscription_payment_desc', $description, $invoice);
164 164
 }
165 165
 
166
-function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) {
167
-	$initial_total      = wpinv_round_amount( $initial );
168
-	$recurring_total    = wpinv_round_amount( $recurring );
166
+function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') {
167
+	$initial_total      = wpinv_round_amount($initial);
168
+	$recurring_total    = wpinv_round_amount($recurring);
169 169
 
170
-	if ( $trial_interval > 0 && ! empty( $trial_period ) ) {
170
+	if ($trial_interval > 0 && !empty($trial_period)) {
171 171
 		// Free trial
172 172
 	} else {
173
-		if ( $bill_times == 1 ) {
173
+		if ($bill_times == 1) {
174 174
 			$recurring_total = $initial_total;
175
-		} elseif ( $bill_times > 1 && $initial_total != $recurring_total ) {
175
+		} elseif ($bill_times > 1 && $initial_total != $recurring_total) {
176 176
 			$bill_times--;
177 177
 		}
178 178
 	}
179 179
 
180
-	$initial_amount     = wpinv_price( $initial_total, $currency );
181
-	$recurring_amount   = wpinv_price( $recurring_total, $currency );
180
+	$initial_amount     = wpinv_price($initial_total, $currency);
181
+	$recurring_amount   = wpinv_price($recurring_total, $currency);
182 182
 
183
-	$recurring          = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
183
+	$recurring          = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
184 184
 
185
-	if ( $initial_total != $recurring_total ) {
186
-		$initial        = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval );
185
+	if ($initial_total != $recurring_total) {
186
+		$initial        = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval);
187 187
 
188
-		$description    = wp_sprintf( __( '%1$s Then %2$s', 'invoicing' ), $initial, $recurring );
188
+		$description    = wp_sprintf(__('%1$s Then %2$s', 'invoicing'), $initial, $recurring);
189 189
 	} else {
190 190
 		$description    = $recurring;
191 191
 	}
192 192
 
193
-	return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency );
193
+	return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency);
194 194
 }
195 195
 
196 196
 /**
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
  * @param string $card_number Card number.
201 201
  * @return string
202 202
  */
203
-function getpaid_get_card_name( $card_number ) {
203
+function getpaid_get_card_name($card_number) {
204 204
 
205 205
 	// Known regexes.
206 206
 	$regexes = array(
207
-		'/^4/'                     => __( 'Visa', 'invoicing' ),
208
-		'/^5[1-5]/'                => __( 'Mastercard', 'invoicing' ),
209
-		'/^3[47]/'                 => __( 'Amex', 'invoicing' ),
210
-		'/^3(?:0[0-5]|[68])/'      => __( 'Diners Club', 'invoicing' ),
211
-		'/^6(?:011|5)/'            => __( 'Discover', 'invoicing' ),
212
-		'/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ),
207
+		'/^4/'                     => __('Visa', 'invoicing'),
208
+		'/^5[1-5]/'                => __('Mastercard', 'invoicing'),
209
+		'/^3[47]/'                 => __('Amex', 'invoicing'),
210
+		'/^3(?:0[0-5]|[68])/'      => __('Diners Club', 'invoicing'),
211
+		'/^6(?:011|5)/'            => __('Discover', 'invoicing'),
212
+		'/^(?:2131|1800|35\d{3})/' => __('JCB', 'invoicing'),
213 213
 	);
214 214
 
215 215
 	// Confirm if one matches.
216
-	foreach ( $regexes as $regex => $card ) {
217
-		if ( preg_match( $regex, $card_number ) >= 1 ) {
216
+	foreach ($regexes as $regex => $card) {
217
+		if (preg_match($regex, $card_number) >= 1) {
218 218
 			return $card;
219 219
 		}
220 220
 	}
221 221
 
222 222
 	// None matched.
223
-	return __( 'Card', 'invoicing' );
223
+	return __('Card', 'invoicing');
224 224
 
225 225
 }
226 226
 
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
  *
230 230
  * @param WPInv_Invoice|int|null $invoice
231 231
  */
232
-function wpinv_send_back_to_checkout( $invoice = null ) {
233
-	$response = array( 'success' => false );
234
-	$invoice  = wpinv_get_invoice( $invoice );
232
+function wpinv_send_back_to_checkout($invoice = null) {
233
+	$response = array('success' => false);
234
+	$invoice  = wpinv_get_invoice($invoice);
235 235
 
236 236
 	// Was an invoice created?
237
-	if ( ! empty( $invoice ) ) {
238
-		$invoice             = is_scalar( $invoice ) ? new WPInv_Invoice( $invoice ) : $invoice;
237
+	if (!empty($invoice)) {
238
+		$invoice             = is_scalar($invoice) ? new WPInv_Invoice($invoice) : $invoice;
239 239
 		$response['invoice'] = $invoice->get_id();
240
-		do_action( 'getpaid_checkout_invoice_exception', $invoice );
240
+		do_action('getpaid_checkout_invoice_exception', $invoice);
241 241
 	}
242 242
 
243 243
 	// Do we have any errors?
244
-	if ( wpinv_get_errors() ) {
245
-		$response['data'] = getpaid_get_errors_html( true, false );
244
+	if (wpinv_get_errors()) {
245
+		$response['data'] = getpaid_get_errors_html(true, false);
246 246
 	} else {
247
-		$response['data'] = __( 'An error occured while processing your payment. Please try again.', 'invoicing' );
247
+		$response['data'] = __('An error occured while processing your payment. Please try again.', 'invoicing');
248 248
 	}
249 249
 
250
-	wp_send_json( $response );
250
+	wp_send_json($response);
251 251
 }
252 252
 
253 253
 /**
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
  * @return string
257 257
  */
258 258
 function getpaid_get_recaptcha_site_key() {
259
-	return apply_filters( 'getpaid_recaptcha_site_key', wpinv_get_option( 'recaptcha_site_key', '' ) );
259
+	return apply_filters('getpaid_recaptcha_site_key', wpinv_get_option('recaptcha_site_key', ''));
260 260
 }
261 261
 
262 262
 /**
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
  * @return string
266 266
  */
267 267
 function getpaid_get_recaptcha_secret_key() {
268
-	return apply_filters( 'getpaid_recaptcha_secret_key', wpinv_get_option( 'recaptcha_secret_key', '' ) );
268
+	return apply_filters('getpaid_recaptcha_secret_key', wpinv_get_option('recaptcha_secret_key', ''));
269 269
 }
270 270
 
271 271
 /**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
  * @return bool
275 275
  */
276 276
 function getpaid_is_recaptcha_enabled() {
277
-	return wpinv_get_option( 'enable_recaptcha', false ) && getpaid_get_recaptcha_site_key() && getpaid_get_recaptcha_secret_key();
277
+	return wpinv_get_option('enable_recaptcha', false) && getpaid_get_recaptcha_site_key() && getpaid_get_recaptcha_secret_key();
278 278
 }
279 279
 
280 280
 /**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
  * @return string
284 284
  */
285 285
 function getpaid_get_recaptcha_version() {
286
-	return apply_filters( 'getpaid_recaptcha_version', wpinv_get_option( 'recaptcha_version', 'v2' ) );
286
+	return apply_filters('getpaid_recaptcha_version', wpinv_get_option('recaptcha_version', 'v2'));
287 287
 }
288 288
 
289 289
 /**
@@ -297,14 +297,14 @@  discard block
 block discarded – undo
297 297
 		'version' => getpaid_get_recaptcha_version(),
298 298
 	);
299 299
 
300
-	if ( ! getpaid_is_recaptcha_enabled() ) {
300
+	if (!getpaid_is_recaptcha_enabled()) {
301 301
 		return $settings;
302 302
 	}
303 303
 
304 304
 	$settings['sitekey'] = getpaid_get_recaptcha_site_key();
305 305
 
306 306
 	// Version 2 render params.
307
-	if ( 'v2' === getpaid_get_recaptcha_version() ) {
307
+	if ('v2' === getpaid_get_recaptcha_version()) {
308 308
 		$settings['render_params'] = array(
309 309
 			'sitekey'  => getpaid_get_recaptcha_site_key(),
310 310
 			'theme'    => 'light',
@@ -313,41 +313,41 @@  discard block
 block discarded – undo
313 313
 		);
314 314
 	}
315 315
 
316
-	return apply_filters( 'getpaid_recaptcha_settings', $settings );
316
+	return apply_filters('getpaid_recaptcha_settings', $settings);
317 317
 }
318 318
 
319 319
 /**
320 320
  * Displays reCAPTCHA before payment button.
321 321
  */
322 322
 function getpaid_display_recaptcha_before_payment_button() {
323
-	if ( ! getpaid_is_recaptcha_enabled() || 'v2' !== getpaid_get_recaptcha_version() ) {
323
+	if (!getpaid_is_recaptcha_enabled() || 'v2' !== getpaid_get_recaptcha_version()) {
324 324
 		return;
325 325
 	}
326 326
 
327 327
 	printf(
328 328
 		'<div class="getpaid-recaptcha-wrapper"><div class="g-recaptcha mw-100 overflow-hidden my-2" id="getpaid-recaptcha-%s"></div></div>',
329
-		esc_attr( wp_unique_id() )
329
+		esc_attr(wp_unique_id())
330 330
 	);
331 331
 }
332
-add_action( 'getpaid_before_payment_form_pay_button', 'getpaid_display_recaptcha_before_payment_button' );
332
+add_action('getpaid_before_payment_form_pay_button', 'getpaid_display_recaptcha_before_payment_button');
333 333
 
334 334
 /**
335 335
  * Validates the reCAPTCHA response.
336 336
  *
337 337
  * @param GetPaid_Payment_Form_Submission $submission
338 338
  */
339
-function getpaid_validate_recaptcha_response( $submission ) {
339
+function getpaid_validate_recaptcha_response($submission) {
340 340
 
341 341
 	// Check if reCAPTCHA is enabled.
342
-	if ( ! getpaid_is_recaptcha_enabled() ) {
342
+	if (!getpaid_is_recaptcha_enabled()) {
343 343
 		return;
344 344
 	}
345 345
 
346
-	$token = $submission->get_field( 'g-recaptcha-response' );
346
+	$token = $submission->get_field('g-recaptcha-response');
347 347
 
348 348
 	// Abort if no token was provided.
349
-	if ( empty( $token ) ) {
350
-		wp_send_json_error( 'v2' === getpaid_get_recaptcha_version() ? __( 'Please confirm that you are not a robot.', 'invoicing' ) : __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
349
+	if (empty($token)) {
350
+		wp_send_json_error('v2' === getpaid_get_recaptcha_version() ? __('Please confirm that you are not a robot.', 'invoicing') : __("Unable to verify that you're not a robot. Please try again.", 'invoicing'));
351 351
 	}
352 352
 
353 353
 	$result = wp_remote_post(
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
 	);
362 362
 
363 363
 	// Site not reachable, give benefit of doubt.
364
-	if ( is_wp_error( $result ) ) {
364
+	if (is_wp_error($result)) {
365 365
 		return;
366 366
 	}
367 367
 
368
-	$result = json_decode( wp_remote_retrieve_body( $result ), true );
368
+	$result = json_decode(wp_remote_retrieve_body($result), true);
369 369
 
370
-	if ( empty( $result['success'] ) && ! in_array( 'missing-input-secret', $result['error-codes'], true ) && ! in_array( 'invalid-input-secret', $result['error-codes'], true ) ) {
371
-		wp_send_json_error( __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
370
+	if (empty($result['success']) && !in_array('missing-input-secret', $result['error-codes'], true) && !in_array('invalid-input-secret', $result['error-codes'], true)) {
371
+		wp_send_json_error(__("Unable to verify that you're not a robot. Please try again.", 'invoicing'));
372 372
 	}
373 373
 
374 374
 	// For v3, check the score.
375
-	$minimum_score = apply_filters( 'getpaid_recaptcha_minimum_score', 0.4 );
376
-	if ( 'v3' === getpaid_get_recaptcha_version() && ( empty( $result['score'] ) || $result['score'] < $minimum_score ) ) {
377
-		wp_send_json_error( __( "Unable to verify that you're not a robot. Please try again.", 'invoicing' ) );
375
+	$minimum_score = apply_filters('getpaid_recaptcha_minimum_score', 0.4);
376
+	if ('v3' === getpaid_get_recaptcha_version() && (empty($result['score']) || $result['score'] < $minimum_score)) {
377
+		wp_send_json_error(__("Unable to verify that you're not a robot. Please try again.", 'invoicing'));
378 378
 	}
379 379
 }
380
-add_action( 'getpaid_checkout_error_checks', 'getpaid_validate_recaptcha_response' );
380
+add_action('getpaid_checkout_error_checks', 'getpaid_validate_recaptcha_response');
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,103 +1,103 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.6";
22
+        public $version = "1.0.6";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> 'Quick Feedback',
59
-				'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
-				'better_plugins_name'		=> 'Please tell us which plugin?',
61
-				'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
-				'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
-				'brief_description'			=> 'Please give us any feedback that could help us improve',
64
-				'cancel'					=> 'Cancel',
65
-				'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
-				'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
-				'please_wait'				=> 'Please wait',
68
-				'get_support'				=> 'Get Support',
69
-				'documentation'				=> 'Documentation',
70
-				'thank_you'					=> 'Thank you!',
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
-				'plugin-broke-site'			=> 'The plugin broke my site',
80
-				'plugin-setup-difficult'	=> 'Too difficult to setup',
81
-				'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
-				'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
-				'found-better-plugin'		=> 'I found a better plugin',
84
-				'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
-				'other'						=> 'Other',
86
-			);
87
-
88
-			foreach($plugins as $plugin)
89
-			{
90
-				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
-				$plugin->url = home_url();
92
-				$plugin->activated = 0;
93
-			}
94
-
95
-			// Send plugin data
96
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
-
98
-		}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> 'Quick Feedback',
59
+                'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
+                'better_plugins_name'		=> 'Please tell us which plugin?',
61
+                'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
+                'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
+                'brief_description'			=> 'Please give us any feedback that could help us improve',
64
+                'cancel'					=> 'Cancel',
65
+                'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
+                'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
+                'please_wait'				=> 'Please wait',
68
+                'get_support'				=> 'Get Support',
69
+                'documentation'				=> 'Documentation',
70
+                'thank_you'					=> 'Thank you!',
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
+                'plugin-broke-site'			=> 'The plugin broke my site',
80
+                'plugin-setup-difficult'	=> 'Too difficult to setup',
81
+                'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
+                'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
+                'found-better-plugin'		=> 'I found a better plugin',
84
+                'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
+                'other'						=> 'Other',
86
+            );
87
+
88
+            foreach($plugins as $plugin)
89
+            {
90
+                $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
+                $plugin->url = home_url();
92
+                $plugin->activated = 0;
93
+            }
94
+
95
+            // Send plugin data
96
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
+
98
+        }
99 99
 		
100 100
 
101
-	}
101
+    }
102 102
 
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
7
+if (!class_exists('AyeCode_Deactivation_Survey')) {
8 8
 
9 9
 	class AyeCode_Deactivation_Survey {
10 10
 
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 
22 22
 		public $version = "1.0.6";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
24
+		public static function instance($plugin = array()) {
25
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_Deactivation_Survey)) {
26 26
 				self::$instance = new AyeCode_Deactivation_Survey;
27 27
 				self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+				add_action('admin_enqueue_scripts', array(self::$instance, 'scripts'));
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
31
+				do_action('ayecode_deactivation_survey_loaded');
32 32
 			}
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
34
+			if (!empty($plugin)) {
35
+				self::$plugins[] = (object) $plugin;
36 36
 			}
37 37
 
38 38
 			return self::$instance;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			global $pagenow;
43 43
 
44 44
 			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
45
+			if ($pagenow != "plugins.php") {
46 46
 				return;
47 47
 			}
48 48
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				'other'						=> 'Other',
86 86
 			);
87 87
 
88
-			foreach($plugins as $plugin)
88
+			foreach ($plugins as $plugin)
89 89
 			{
90 90
 				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91 91
 				$plugin->url = home_url();
Please login to merge, or discard this patch.
templates/payment-forms/form.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
         // And the optional invoice id.
59 59
         if ( ! empty( $form->invoice ) ) {
60
-		    getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() );
60
+            getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() );
61 61
         }
62 62
 
63 63
         // We also want to include the form id.
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                 <?php
77 77
 
78 78
                     foreach ( $form->get_elements() as $element ) {
79
-					    if ( isset( $element['type'] ) ) {
79
+                        if ( isset( $element['type'] ) ) {
80 80
                             $grid_class = getpaid_get_form_element_grid_class( $element );
81 81
                             do_action( 'getpaid_payment_form_element_before', $element, $form );
82 82
                             do_action( "getpaid_payment_form_element_before_{$element['type']}_template", $element, $form );
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Standardize IDs.
13 13
 global $rendered_getpaid_forms;
14 14
 
15 15
 // Make sure that the form is active.
16
-if ( ! $form->is_active() ) {
16
+if (!$form->is_active()) {
17 17
     aui()->alert(
18 18
         array(
19 19
             'type'    => 'warning',
20
-            'content' => __( 'This payment form is no longer active', 'invoicing' ),
20
+            'content' => __('This payment form is no longer active', 'invoicing'),
21 21
         ),
22 22
         true
23 23
     );
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 }
26 26
 
27 27
 // Require login to checkout.
28
-if ( wpinv_require_login_to_checkout() && ! get_current_user_id() ) {
28
+if (wpinv_require_login_to_checkout() && !get_current_user_id()) {
29 29
 
30 30
     aui()->alert(
31 31
         array(
32 32
             'type'    => 'danger',
33
-            'content' => __( 'You must be logged in to checkout.', 'invoicing' ),
33
+            'content' => __('You must be logged in to checkout.', 'invoicing'),
34 34
         ),
35 35
         true
36 36
     );
@@ -38,36 +38,36 @@  discard block
 block discarded – undo
38 38
 
39 39
 }
40 40
 
41
-if ( ! is_array( $rendered_getpaid_forms ) ) {
41
+if (!is_array($rendered_getpaid_forms)) {
42 42
     $rendered_getpaid_forms = array();
43 43
 }
44 44
 
45
-$rendered_getpaid_forms[ $form->get_id() ] = isset( $rendered_getpaid_forms[ $form->get_id() ] ) ? $rendered_getpaid_forms[ $form->get_id() ] + 1 : 0;
45
+$rendered_getpaid_forms[$form->get_id()] = isset($rendered_getpaid_forms[$form->get_id()]) ? $rendered_getpaid_forms[$form->get_id()] + 1 : 0;
46 46
 
47 47
 // Fires before displaying a payment form.
48
-do_action( 'getpaid_before_payment_form', $form );
48
+do_action('getpaid_before_payment_form', $form);
49 49
 ?>
50 50
 
51
-<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui position-relative' method='POST' data-key='<?php echo esc_attr( uniqid( 'gpf' ) ); ?>' data-currency='<?php echo esc_attr( empty( $form->invoice ) ? wpinv_get_currency() : $form->invoice->get_currency() ); ?>' novalidate>
51
+<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui position-relative' method='POST' data-key='<?php echo esc_attr(uniqid('gpf')); ?>' data-currency='<?php echo esc_attr(empty($form->invoice) ? wpinv_get_currency() : $form->invoice->get_currency()); ?>' novalidate>
52 52
 
53 53
     <?php
54 54
 
55 55
         // Fires when printing the top of a payment form.
56
-        do_action( 'getpaid_payment_form_top', $form );
56
+        do_action('getpaid_payment_form_top', $form);
57 57
 
58 58
         // And the optional invoice id.
59
-        if ( ! empty( $form->invoice ) ) {
60
-		    getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() );
59
+        if (!empty($form->invoice)) {
60
+		    getpaid_hidden_field('invoice_id', $form->invoice->get_id());
61 61
         }
62 62
 
63 63
         // We also want to include the form id.
64
-        getpaid_hidden_field( 'form_id', $form->get_id() );
64
+        getpaid_hidden_field('form_id', $form->get_id());
65 65
 
66 66
         // And an indication that this is a payment form submission.
67
-        getpaid_hidden_field( 'getpaid_payment_form_submission', '1' );
67
+        getpaid_hidden_field('getpaid_payment_form_submission', '1');
68 68
 
69 69
         // Fires before displaying payment form elements.
70
-        do_action( 'getpaid_payment_form_before_elements', $form );
70
+        do_action('getpaid_payment_form_before_elements', $form);
71 71
 
72 72
         // Display the elements.
73 73
         ?>
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
             <div class="row">
76 76
                 <?php
77 77
 
78
-                    foreach ( $form->get_elements() as $element ) {
79
-					    if ( isset( $element['type'] ) ) {
80
-                            $grid_class = getpaid_get_form_element_grid_class( $element );
81
-                            do_action( 'getpaid_payment_form_element_before', $element, $form );
82
-                            do_action( "getpaid_payment_form_element_before_{$element['type']}_template", $element, $form );
83
-                            echo "<div class='" . esc_attr( $grid_class ) . "'>";
84
-                            do_action( 'getpaid_payment_form_element', $element, $form );
85
-                            do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form );
78
+                    foreach ($form->get_elements() as $element) {
79
+					    if (isset($element['type'])) {
80
+                            $grid_class = getpaid_get_form_element_grid_class($element);
81
+                            do_action('getpaid_payment_form_element_before', $element, $form);
82
+                            do_action("getpaid_payment_form_element_before_{$element['type']}_template", $element, $form);
83
+                            echo "<div class='" . esc_attr($grid_class) . "'>";
84
+                            do_action('getpaid_payment_form_element', $element, $form);
85
+                            do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form);
86 86
                             echo '</div>';
87
-                            do_action( 'getpaid_payment_form_element_after', $element, $form );
88
-                            do_action( "getpaid_payment_form_element_after_{$element['type']}_template", $element, $form );
87
+                            do_action('getpaid_payment_form_element_after', $element, $form);
88
+                            do_action("getpaid_payment_form_element_after_{$element['type']}_template", $element, $form);
89 89
                         }
90 90
                     }
91 91
 
@@ -95,28 +95,28 @@  discard block
 block discarded – undo
95 95
 
96 96
         <?php
97 97
         // Fires after displaying payment form elements.
98
-        do_action( 'getpaid_payment_form_after_elements', $form );
98
+        do_action('getpaid_payment_form_after_elements', $form);
99 99
 
100 100
         echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>";
101 101
 
102
-        if ( wpinv_current_user_can_manage_invoicing() ) {
102
+        if (wpinv_current_user_can_manage_invoicing()) {
103 103
 
104 104
             edit_post_link(
105
-                __( 'Edit this form.', 'invoicing' ),
105
+                __('Edit this form.', 'invoicing'),
106 106
                 '<small class="form-text text-muted">',
107
-                '&nbsp;' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>',
107
+                '&nbsp;' . __('This is only visible to website administators.', 'invoicing') . '</small>',
108 108
                 $form->get_id(),
109 109
                 'text-danger'
110 110
             );
111 111
 
112 112
         }
113 113
 
114
-        echo wp_kses( $extra_markup, getpaid_allowed_html() );
114
+        echo wp_kses($extra_markup, getpaid_allowed_html());
115 115
     ?>
116 116
 
117 117
     <div class="loading_div overlay overlay-black position-absolute row m-0 rounded overflow-hidden" style="height: 100%;width: 100%;top: 0px;z-index: 2;display:none;">
118 118
         <div class="spinner-border mx-auto align-self-center text-white" role="status">
119
-            <span class="sr-only"><?php esc_html_e( 'Loading...', 'invoicing' ); ?></span>
119
+            <span class="sr-only"><?php esc_html_e('Loading...', 'invoicing'); ?></span>
120 120
         </div>
121 121
     </div>
122 122
 
@@ -125,4 +125,4 @@  discard block
 block discarded – undo
125 125
 <?php
126 126
 
127 127
 // Fires after displaying a payment form.
128
-do_action( 'getpaid_after_payment_form', $form );
128
+do_action('getpaid_after_payment_form', $form);
Please login to merge, or discard this patch.
templates/payment-forms/cart-totals.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@  discard block
 block discarded – undo
11 11
 
12 12
 // Totals rows.
13 13
 $cart_totals = apply_filters(
14
-	'getpaid_payment_form_cart_table_totals',
15
-	array(
16
-		'subtotal' => __( 'Subtotal', 'invoicing' ),
17
-		'tax'      => __( 'Tax', 'invoicing' ),
18
-		'fees'     => __( 'Fee', 'invoicing' ),
19
-		'discount' => __( 'Discount', 'invoicing' ),
20
-		'total'    => __( 'Total', 'invoicing' ),
21
-	),
22
-	$form
14
+    'getpaid_payment_form_cart_table_totals',
15
+    array(
16
+        'subtotal' => __( 'Subtotal', 'invoicing' ),
17
+        'tax'      => __( 'Tax', 'invoicing' ),
18
+        'fees'     => __( 'Fee', 'invoicing' ),
19
+        'discount' => __( 'Discount', 'invoicing' ),
20
+        'total'    => __( 'Total', 'invoicing' ),
21
+    ),
22
+    $form
23 23
 );
24 24
 
25 25
 $currency = $form->get_currency();
26 26
 $country  = wpinv_get_default_country();
27 27
 
28 28
 if ( ! empty( $form->invoice ) ) {
29
-	$country  = $form->invoice->get_country();
29
+    $country  = $form->invoice->get_country();
30 30
 }
31 31
 
32 32
 if ( ! wpinv_use_taxes() && isset( $cart_totals['tax'] ) ) {
33
-	unset( $cart_totals['tax'] );
33
+    unset( $cart_totals['tax'] );
34 34
 }
35 35
 
36 36
 do_action( 'getpaid_before_payment_form_cart_totals', $form, $cart_totals );
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 
62 62
 							<?php
63 63
 
64
-								// Total tax.
65
-								if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ), true ) ) {
66
-									wpinv_the_price( 0, $currency );
67
-								}
64
+                                // Total tax.
65
+                                if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ), true ) ) {
66
+                                    wpinv_the_price( 0, $currency );
67
+                                }
68 68
 
69
-								do_action( "getpaid_payment_form_cart_totals_$key", $form );
70
-							?>
69
+                                do_action( "getpaid_payment_form_cart_totals_$key", $form );
70
+                            ?>
71 71
 
72 72
 						</div>
73 73
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Totals rows.
13 13
 $cart_totals = apply_filters(
14 14
 	'getpaid_payment_form_cart_table_totals',
15 15
 	array(
16
-		'subtotal' => __( 'Subtotal', 'invoicing' ),
17
-		'tax'      => __( 'Tax', 'invoicing' ),
18
-		'fees'     => __( 'Fee', 'invoicing' ),
19
-		'discount' => __( 'Discount', 'invoicing' ),
20
-		'total'    => __( 'Total', 'invoicing' ),
16
+		'subtotal' => __('Subtotal', 'invoicing'),
17
+		'tax'      => __('Tax', 'invoicing'),
18
+		'fees'     => __('Fee', 'invoicing'),
19
+		'discount' => __('Discount', 'invoicing'),
20
+		'total'    => __('Total', 'invoicing'),
21 21
 	),
22 22
 	$form
23 23
 );
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 $currency = $form->get_currency();
26 26
 $country  = wpinv_get_default_country();
27 27
 
28
-if ( ! empty( $form->invoice ) ) {
29
-	$country  = $form->invoice->get_country();
28
+if (!empty($form->invoice)) {
29
+	$country = $form->invoice->get_country();
30 30
 }
31 31
 
32
-if ( ! wpinv_use_taxes() && isset( $cart_totals['tax'] ) ) {
33
-	unset( $cart_totals['tax'] );
32
+if (!wpinv_use_taxes() && isset($cart_totals['tax'])) {
33
+	unset($cart_totals['tax']);
34 34
 }
35 35
 
36
-do_action( 'getpaid_before_payment_form_cart_totals', $form, $cart_totals );
36
+do_action('getpaid_before_payment_form_cart_totals', $form, $cart_totals);
37 37
 
38 38
 ?>
39 39
 <style>
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
 	<div class="row">
48 48
 		<div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0">
49 49
 
50
-			<?php foreach ( $cart_totals as $key => $label ) : ?>
50
+			<?php foreach ($cart_totals as $key => $label) : ?>
51 51
 
52
-				<div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr( $key ); ?> font-weight-bold py-2 px-3 <?php echo 'total' === $key ? 'bg-light' : 'border-bottom'; ?> <?php echo 'tax' === $key && wpinv_display_individual_tax_rates() ? 'getpaid-tax-template d-none' : ''; ?>">
52
+				<div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr($key); ?> font-weight-bold py-2 px-3 <?php echo 'total' === $key ? 'bg-light' : 'border-bottom'; ?> <?php echo 'tax' === $key && wpinv_display_individual_tax_rates() ? 'getpaid-tax-template d-none' : ''; ?>">
53 53
 
54 54
 					<div class="form-row row">
55 55
 
56 56
 						<div class="col-8 pl-sm-0 getpaid-payment-form-line-totals-label">
57
-							<?php echo esc_html( $label ); ?>
57
+							<?php echo esc_html($label); ?>
58 58
 						</div>
59 59
 
60
-						<div class="col-4 getpaid-payment-form-line-totals-value getpaid-form-cart-totals-total-<?php echo esc_attr( $key ); ?>">
60
+						<div class="col-4 getpaid-payment-form-line-totals-value getpaid-form-cart-totals-total-<?php echo esc_attr($key); ?>">
61 61
 
62 62
 							<?php
63 63
 
64 64
 								// Total tax.
65
-								if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ), true ) ) {
66
-									wpinv_the_price( 0, $currency );
65
+								if (in_array($key, array('tax', 'discount', 'subtotal', 'total', 'fees'), true)) {
66
+									wpinv_the_price(0, $currency);
67 67
 								}
68 68
 
69
-								do_action( "getpaid_payment_form_cart_totals_$key", $form );
69
+								do_action("getpaid_payment_form_cart_totals_$key", $form);
70 70
 							?>
71 71
 
72 72
 						</div>
@@ -82,4 +82,4 @@  discard block
 block discarded – undo
82 82
 </div>
83 83
 
84 84
 <?php
85
-do_action( 'getpaid_payment_form_cart_totals', $form, $cart_totals );
85
+do_action('getpaid_payment_form_cart_totals', $form, $cart_totals);
Please login to merge, or discard this patch.
templates/payment-forms/elements/address-fields.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -12,75 +12,75 @@  discard block
 block discarded – undo
12 12
  * @var GetPaid_Payment_Form $form
13 13
  */
14 14
 
15
-defined( 'ABSPATH' ) || exit;
15
+defined('ABSPATH') || exit;
16 16
 
17
-$field_type = sanitize_key( $field_type );
17
+$field_type = sanitize_key($field_type);
18 18
 
19
-echo "<div class='row " . esc_attr( $field_type ) . "'>";
19
+echo "<div class='row " . esc_attr($field_type) . "'>";
20 20
 
21 21
 // Prepare current user.
22
-if ( ! empty( $form->invoice ) ) {
22
+if (!empty($form->invoice)) {
23 23
     $user_id = $form->invoice->get_user_id();
24 24
 }
25 25
 
26
-if ( empty( $user_id ) && is_user_logged_in() ) {
26
+if (empty($user_id) && is_user_logged_in()) {
27 27
     $user_id = get_current_user_id();
28 28
 }
29 29
 
30
-if ( ! empty( $user_id ) ) {
31
-    $user  = wp_get_current_user();
30
+if (!empty($user_id)) {
31
+    $user = wp_get_current_user();
32 32
 }
33 33
 
34
-foreach ( $fields as $address_field ) {
34
+foreach ($fields as $address_field) {
35 35
 
36 36
     // Skip if it is hidden.
37
-    if ( empty( $address_field['visible'] ) ) {
37
+    if (empty($address_field['visible'])) {
38 38
         continue;
39 39
     }
40 40
 
41
-    do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field );
41
+    do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field);
42 42
 
43 43
     // Prepare variables.
44 44
     $field_name  = $address_field['name'];
45 45
     $field_name  = "{$field_type}[$field_name]";
46
-    $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
47
-    $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
48
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
49
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
50
-    $value       = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : '';
51
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
52
-
53
-    $method_name = 'get_' . str_replace( 'wpinv_', '', $address_field['name'] );
54
-    if ( ! empty( $form->invoice ) && is_callable( array( $form->invoice, $method_name ) ) ) {
55
-        $value = call_user_func( array( $form->invoice, $method_name ) );
46
+    $wrap_class  = getpaid_get_form_element_grid_class($address_field);
47
+    $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
48
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
49
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
50
+    $value       = !empty($user_id) ? get_user_meta($user_id, '_' . $address_field['name'], true) : '';
51
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
52
+
53
+    $method_name = 'get_' . str_replace('wpinv_', '', $address_field['name']);
54
+    if (!empty($form->invoice) && is_callable(array($form->invoice, $method_name))) {
55
+        $value = call_user_func(array($form->invoice, $method_name));
56 56
     }
57 57
 
58
-    if ( empty( $value ) && 'wpinv_first_name' === $address_field['name'] && ! empty( $user ) ) {
58
+    if (empty($value) && 'wpinv_first_name' === $address_field['name'] && !empty($user)) {
59 59
         $value = $user->first_name;
60 60
     }
61 61
 
62
-    if ( empty( $value ) && 'wpinv_last_name' === $address_field['name'] && ! empty( $user ) ) {
62
+    if (empty($value) && 'wpinv_last_name' === $address_field['name'] && !empty($user)) {
63 63
         $value = $user->last_name;
64 64
     }
65 65
 
66
-    if ( ! empty( $address_field['required'] ) ) {
66
+    if (!empty($address_field['required'])) {
67 67
         $label .= "<span class='text-danger'> *</span>";
68 68
     }
69 69
 
70 70
     // Display the country.
71
-    if ( 'wpinv_country' === $address_field['name'] ) {
71
+    if ('wpinv_country' === $address_field['name']) {
72 72
 
73
-        echo "<div class='form-group mb-3 " . esc_attr( $wrap_class ) . " getpaid-address-field-wrapper__country'";
73
+        echo "<div class='form-group mb-3 " . esc_attr($wrap_class) . " getpaid-address-field-wrapper__country'";
74 74
 
75 75
         aui()->select(
76 76
             array(
77 77
                 'options'          => wpinv_get_country_list(),
78
-                'name'             => esc_attr( $field_name ),
79
-                'id'               => sanitize_html_class( $field_name ) . $uniqid,
80
-                'value'            => esc_attr( $country ),
78
+                'name'             => esc_attr($field_name),
79
+                'id'               => sanitize_html_class($field_name) . $uniqid,
80
+                'value'            => esc_attr($country),
81 81
                 'placeholder'      => $placeholder,
82
-                'required'         => ! empty( $address_field['required'] ),
83
-                'label'            => wp_kses_post( $label ),
82
+                'required'         => !empty($address_field['required']),
83
+                'label'            => wp_kses_post($label),
84 84
                 'label_type'       => 'vertical',
85 85
                 'help_text'        => $description,
86 86
                 'class'            => 'getpaid-address-field wpinv_country',
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
             true
95 95
         );
96 96
 
97
-        if ( wpinv_should_validate_vat_number() ) {
97
+        if (wpinv_should_validate_vat_number()) {
98 98
 
99 99
             aui()->input(
100 100
                 array(
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                     'id'         => "shipping-toggle$uniqid",
104 104
                     'wrap_class' => 'getpaid-address-field-wrapper__address-confirm mt-1 d-none',
105 105
                     'required'   => false,
106
-                    'label'      => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>",
106
+                    'label'      => __('I certify that I live in the country selected above', 'invoicing') . "<span class='text-danger'> *</span>",
107 107
                     'value'      => 1,
108 108
                     'checked'    => true,
109 109
                     'class'      => 'w-auto',
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
     }
119 119
 
120 120
     // Display the state.
121
-    elseif ( 'wpinv_state' == $address_field['name'] ) {
121
+    elseif ('wpinv_state' == $address_field['name']) {
122 122
 
123
-        if ( empty( $value ) ) {
123
+        if (empty($value)) {
124 124
             $value = wpinv_get_default_state();
125 125
         }
126 126
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $placeholder,
131 131
             $label,
132 132
             $description,
133
-            ! empty( $address_field['required'] ),
133
+            !empty($address_field['required']),
134 134
             $wrap_class,
135 135
             $field_name,
136 136
             true
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 
139 139
     } else {
140 140
 
141
-        $key      = str_replace( 'wpinv_', '', $address_field['name'] );
142
-        $key      = esc_attr( str_replace( '_', '-', $key ) );
141
+        $key      = str_replace('wpinv_', '', $address_field['name']);
142
+        $key      = esc_attr(str_replace('_', '-', $key));
143 143
         $autocomplete = '';
144 144
         $replacements = array(
145 145
             'zip'        => 'postal-code',
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
         );
153 153
 
154 154
 
155
-        if ( isset( $replacements[ $key ] ) ) {
155
+        if (isset($replacements[$key])) {
156 156
             $autocomplete = array(
157
-                'autocomplete' => "$field_type {$replacements[ $key ]}",
157
+                'autocomplete' => "$field_type {$replacements[$key]}",
158 158
             );
159 159
         }
160 160
 
161 161
         $append = '';
162 162
 
163
-        if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) {
164
-            $valid    = esc_attr__( 'Valid', 'invoicing' );
165
-            $invalid  = esc_attr__( 'Invalid', 'invoicing' );
166
-            $validate = esc_attr__( 'Validate', 'invoicing' );
163
+        if ('billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key) {
164
+            $valid    = esc_attr__('Valid', 'invoicing');
165
+            $invalid  = esc_attr__('Invalid', 'invoicing');
166
+            $validate = esc_attr__('Validate', 'invoicing');
167 167
             $append   = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>";
168 168
         }
169 169
 
170
-        if ( 'billing' === $field_type ) {
171
-            $description .= '<div class="getpaid-error-' . esc_attr( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>';
170
+        if ('billing' === $field_type) {
171
+            $description .= '<div class="getpaid-error-' . esc_attr($field_name) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>';
172 172
         }
173 173
 
174 174
         aui()->input(
175 175
             array(
176
-                'name'              => esc_attr( $field_name ),
177
-                'id'                => sanitize_html_class( $field_name ) . $uniqid,
178
-                'required'          => ! empty( $address_field['required'] ),
176
+                'name'              => esc_attr($field_name),
177
+                'id'                => sanitize_html_class($field_name) . $uniqid,
178
+                'required'          => !empty($address_field['required']),
179 179
                 'placeholder'       => $placeholder,
180
-                'label'             => wp_kses_post( $label ),
180
+                'label'             => wp_kses_post($label),
181 181
                 'label_type'        => 'vertical',
182 182
                 'help_text'         => $description,
183 183
                 'type'              => 'text',
184
-                'value'             => apply_filters( 'getpaid_payment_form_value_' . $address_field['name'], esc_attr( $value ) ),
185
-                'class'             => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
184
+                'value'             => apply_filters('getpaid_payment_form_value_' . $address_field['name'], esc_attr($value)),
185
+                'class'             => 'getpaid-address-field ' . esc_attr($address_field['name']),
186 186
                 'wrap_class'        => "$wrap_class getpaid-address-field-wrapper__$key",
187 187
                 'label_class'       => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
188 188
                 'extra_attributes'  => $autocomplete,
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
     }
195 195
 
196
-    do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field );
196
+    do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field);
197 197
 }
198 198
 
199 199
 echo '</div>';
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 defined( 'ABSPATH' ) || exit;
11 11
 
12 12
 if ( empty( $fields ) ) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 // A prefix for all ids (so that a form can be included in the same page multiple times).
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 
19 19
 // Prepare the user's country.
20 20
 if ( ! empty( $form->invoice ) ) {
21
-	$country = $form->invoice->get_country();
21
+    $country = $form->invoice->get_country();
22 22
 }
23 23
 
24 24
 if ( empty( $country ) ) {
25
-	$country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
-	$country = empty( $country ) ? wpinv_get_default_country() : $country;
25
+    $country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
+    $country = empty( $country ) ? wpinv_get_default_country() : $country;
27 27
 }
28 28
 
29 29
 // A prefix for all ids (so that a form can be included in the same page multiple times).
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	<!-- Start Billing Address -->
56 56
 	<div class="getpaid-billing-address-wrapper">
57 57
 		<?php
58
-			$field_type = 'billing';
59
-			include plugin_dir_path( __FILE__ ) . 'address-fields.php';
60
-			do_action( 'getpaid_after_payment_form_billing_fields', $form );
61
-		?>
58
+            $field_type = 'billing';
59
+            include plugin_dir_path( __FILE__ ) . 'address-fields.php';
60
+            do_action( 'getpaid_after_payment_form_billing_fields', $form );
61
+        ?>
62 62
 	</div>
63 63
 	<!-- End Billing Address -->
64 64
 
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 
71 71
 	<?php
72 72
 
73
-		aui()->input(
74
-		    array(
75
-			    'type'     => 'checkbox',
76
-			    'name'     => 'same-shipping-address',
77
-			    'id'       => "shipping-toggle$uniqid",
78
-			    'required' => false,
79
-			    'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
80
-			    'value'    => 1,
81
-			    'checked'  => true,
82
-				'class'    => 'w-auto',
83
-		    ),
84
-			true
85
-		);
73
+        aui()->input(
74
+            array(
75
+                'type'     => 'checkbox',
76
+                'name'     => 'same-shipping-address',
77
+                'id'       => "shipping-toggle$uniqid",
78
+                'required' => false,
79
+                'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
80
+                'value'    => 1,
81
+                'checked'  => true,
82
+                'class'    => 'w-auto',
83
+            ),
84
+            true
85
+        );
86 86
 
87
-	?>
87
+    ?>
88 88
 
89 89
 
90 90
 	<!-- Start Shipping Address Title -->
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 	<!-- Start Shipping Address -->
104 104
 	<div class="getpaid-shipping-address-wrapper">
105 105
 		<?php
106
-			$field_type = 'shipping';
107
-			include plugin_dir_path( __FILE__ ) . 'address-fields.php';
108
-			do_action( 'getpaid_after_payment_form_shipping_fields', $form );
109
-		?>
106
+            $field_type = 'shipping';
107
+            include plugin_dir_path( __FILE__ ) . 'address-fields.php';
108
+            do_action( 'getpaid_after_payment_form_shipping_fields', $form );
109
+        ?>
110 110
 	</div>
111 111
 	<!-- End Shipping Address -->
112 112
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,57 +7,57 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( empty( $fields ) ) {
12
+if (empty($fields)) {
13 13
 	return;
14 14
 }
15 15
 
16 16
 // A prefix for all ids (so that a form can be included in the same page multiple times).
17
-$uniqid = uniqid( '_' );
17
+$uniqid = uniqid('_');
18 18
 
19 19
 // Prepare the user's country.
20
-if ( ! empty( $form->invoice ) ) {
20
+if (!empty($form->invoice)) {
21 21
 	$country = $form->invoice->get_country();
22 22
 }
23 23
 
24
-if ( empty( $country ) ) {
25
-	$country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
-	$country = empty( $country ) ? wpinv_get_default_country() : $country;
24
+if (empty($country)) {
25
+	$country = empty($country) ? getpaid_get_ip_country() : $country;
26
+	$country = empty($country) ? wpinv_get_default_country() : $country;
27 27
 }
28 28
 
29 29
 // A prefix for all ids (so that a form can be included in the same page multiple times).
30
-$uniqid = uniqid( '_' );
30
+$uniqid = uniqid('_');
31 31
 
32
-$address_type = empty( $address_type ) ? 'billing' : $address_type;
32
+$address_type = empty($address_type) ? 'billing' : $address_type;
33 33
 
34 34
 ?>
35 35
 
36
-<?php if ( 'both' === $address_type ) : ?>
36
+<?php if ('both' === $address_type) : ?>
37 37
 
38 38
 	<!-- Start Billing/Shipping Address Title -->
39 39
 	<h4 class="mb-3 getpaid-shipping-billing-address-title">
40
-		<?php esc_html_e( 'Billing / Shipping Address', 'invoicing' ); ?>
40
+		<?php esc_html_e('Billing / Shipping Address', 'invoicing'); ?>
41 41
 	</h4>
42 42
 	<!-- End Billing Address Title -->
43 43
 
44 44
 	<!-- Start Billing Address Title -->
45 45
 	<h4 class="mb-3 getpaid-billing-address-title">
46
-		<?php esc_html_e( 'Billing Address', 'invoicing' ); ?>
46
+		<?php esc_html_e('Billing Address', 'invoicing'); ?>
47 47
 	</h4>
48 48
 	<!-- End Billing Address Title -->
49 49
 
50 50
 <?php endif; ?>
51 51
 
52 52
 
53
-<?php if ( 'both' === $address_type || 'billing' === $address_type ) : ?>
53
+<?php if ('both' === $address_type || 'billing' === $address_type) : ?>
54 54
 
55 55
 	<!-- Start Billing Address -->
56 56
 	<div class="getpaid-billing-address-wrapper">
57 57
 		<?php
58 58
 			$field_type = 'billing';
59
-			include plugin_dir_path( __FILE__ ) . 'address-fields.php';
60
-			do_action( 'getpaid_after_payment_form_billing_fields', $form );
59
+			include plugin_dir_path(__FILE__) . 'address-fields.php';
60
+			do_action('getpaid_after_payment_form_billing_fields', $form);
61 61
 		?>
62 62
 	</div>
63 63
 	<!-- End Billing Address -->
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 <?php endif; ?>
66 66
 
67 67
 
68
-<?php if ( 'both' === $address_type ) : ?>
68
+<?php if ('both' === $address_type) : ?>
69 69
 
70 70
 
71 71
 	<?php
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			    'name'     => 'same-shipping-address',
77 77
 			    'id'       => "shipping-toggle$uniqid",
78 78
 			    'required' => false,
79
-			    'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
79
+			    'label'    => empty($shipping_address_toggle) ? esc_html__('Same billing & shipping address.', 'invoicing') : wp_kses_post($shipping_address_toggle),
80 80
 			    'value'    => 1,
81 81
 			    'checked'  => true,
82 82
 				'class'    => 'w-auto',
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 	<!-- Start Shipping Address Title -->
91 91
 	<h4 class="mb-3 getpaid-shipping-address-title">
92
-		<?php esc_html_e( 'Shipping Address', 'invoicing' ); ?>
92
+		<?php esc_html_e('Shipping Address', 'invoicing'); ?>
93 93
 	</h4>
94 94
 	<!-- End Shipping Address Title -->
95 95
 
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 
99 99
 
100 100
 	
101
-<?php if ( 'both' === $address_type || 'shipping' === $address_type ) : ?>
101
+<?php if ('both' === $address_type || 'shipping' === $address_type) : ?>
102 102
 
103 103
 	<!-- Start Shipping Address -->
104 104
 	<div class="getpaid-shipping-address-wrapper">
105 105
 		<?php
106 106
 			$field_type = 'shipping';
107
-			include plugin_dir_path( __FILE__ ) . 'address-fields.php';
108
-			do_action( 'getpaid_after_payment_form_shipping_fields', $form );
107
+			include plugin_dir_path(__FILE__) . 'address-fields.php';
108
+			do_action('getpaid_after_payment_form_shipping_fields', $form);
109 109
 		?>
110 110
 	</div>
111 111
 	<!-- End Shipping Address -->
Please login to merge, or discard this patch.
templates/payment-forms/elements/billing_email.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,37 +7,37 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 $value = $query_value;
13 13
 $class = '';
14 14
 
15
-if ( ! empty( $form->invoice ) ) {
16
-    $value   = sanitize_email( $form->invoice->get_email() );
17
-} elseif ( is_user_logged_in() ) {
15
+if (!empty($form->invoice)) {
16
+    $value = sanitize_email($form->invoice->get_email());
17
+} elseif (is_user_logged_in()) {
18 18
     $user  = wp_get_current_user();
19
-    $value = sanitize_email( $user->user_email );
19
+    $value = sanitize_email($user->user_email);
20 20
 }
21 21
 
22
-if ( ! empty( $value ) && ! empty( $hide_billing_email ) ) {
22
+if (!empty($value) && !empty($hide_billing_email)) {
23 23
     $class = 'd-none';
24 24
 }
25 25
 
26
-do_action( 'getpaid_before_payment_form_billing_email', $form );
26
+do_action('getpaid_before_payment_form_billing_email', $form);
27 27
 
28
-echo "<span class='" . esc_attr( $class ) . "'>";
28
+echo "<span class='" . esc_attr($class) . "'>";
29 29
 
30 30
 aui()->input(
31 31
     array(
32 32
         'name'             => 'billing_email',
33
-        'id'               => esc_attr( $element_id ),
34
-        'placeholder'      => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
35
-        'required'         => ! empty( $required ),
36
-        'label'            => empty( $label ) ? '' : wp_kses_post( $label ) . '<span class="text-danger"> *</span>',
33
+        'id'               => esc_attr($element_id),
34
+        'placeholder'      => empty($placeholder) ? '' : esc_attr($placeholder),
35
+        'required'         => !empty($required),
36
+        'label'            => empty($label) ? '' : wp_kses_post($label) . '<span class="text-danger"> *</span>',
37 37
         'label_type'       => 'vertical',
38
-        'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
38
+        'help_text'        => empty($description) ? '' : wp_kses_post($description),
39 39
         'type'             => 'email',
40
-        'value'            => apply_filters ( 'getpaid_payment_form_billing_email_value', $value ),
40
+        'value'            => apply_filters('getpaid_payment_form_billing_email_value', $value),
41 41
         'class'            => 'wpinv_billing_email getpaid-refresh-on-change',
42 42
         'extra_attributes' => array(
43 43
             'autocomplete' => 'billing email',
@@ -48,4 +48,4 @@  discard block
 block discarded – undo
48 48
 
49 49
 echo '</span>';
50 50
 
51
-do_action( 'getpaid_after_payment_form_billing_email', $form );
51
+do_action('getpaid_after_payment_form_billing_email', $form);
Please login to merge, or discard this patch.
includes/wpinv-discount-functions.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -160,50 +160,50 @@
 block discarded – undo
160 160
  */
161 161
 function getpaid_calculate_invoice_discount( $invoice, $discount ) {
162 162
 
163
-	$initial_discount   = 0;
164
-	$recurring_discount = 0;
163
+    $initial_discount   = 0;
164
+    $recurring_discount = 0;
165 165
 
166
-	foreach ( $invoice->get_items() as $item ) {
166
+    foreach ( $invoice->get_items() as $item ) {
167 167
 
168
-		// Abort if it is not valid for this item.
169
-		if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) {
170
-			continue;
171
-		}
168
+        // Abort if it is not valid for this item.
169
+        if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) {
170
+            continue;
171
+        }
172 172
 
173
-		// Calculate the initial amount...
174
-		$item_discount           = $discount->get_discounted_amount( $item->get_sub_total() );
175
-		$recurring_item_discount = 0;
173
+        // Calculate the initial amount...
174
+        $item_discount           = $discount->get_discounted_amount( $item->get_sub_total() );
175
+        $recurring_item_discount = 0;
176 176
 
177
-		// ... and maybe the recurring amount.
178
-		if ( $item->is_recurring() && $discount->is_recurring() ) {
179
-			$recurring_item_discount = $discount->get_discounted_amount( $item->get_recurring_sub_total() );
180
-		}
177
+        // ... and maybe the recurring amount.
178
+        if ( $item->is_recurring() && $discount->is_recurring() ) {
179
+            $recurring_item_discount = $discount->get_discounted_amount( $item->get_recurring_sub_total() );
180
+        }
181 181
 
182
-		// Discount should not exceed discounted amount.
183
-		if ( ! $discount->is_type( 'percent' ) ) {
182
+        // Discount should not exceed discounted amount.
183
+        if ( ! $discount->is_type( 'percent' ) ) {
184 184
 
185
-			if ( ( $initial_discount + $item_discount ) > $discount->get_amount() ) {
186
-				$item_discount = $discount->get_amount() - $initial_discount;
187
-			}
185
+            if ( ( $initial_discount + $item_discount ) > $discount->get_amount() ) {
186
+                $item_discount = $discount->get_amount() - $initial_discount;
187
+            }
188 188
 
189
-			if ( ( $recurring_discount + $recurring_item_discount ) > $discount->get_amount() ) {
190
-				$recurring_item_discount = $discount->get_amount() - $recurring_discount;
191
-			}
189
+            if ( ( $recurring_discount + $recurring_item_discount ) > $discount->get_amount() ) {
190
+                $recurring_item_discount = $discount->get_amount() - $recurring_discount;
191
+            }
192 192
         }
193 193
 
194
-		$initial_discount             += $item_discount;
195
-		$recurring_discount           += $recurring_item_discount;
196
-		$item->item_discount           = $item_discount;
197
-		$item->recurring_item_discount = $recurring_item_discount;
194
+        $initial_discount             += $item_discount;
195
+        $recurring_discount           += $recurring_item_discount;
196
+        $item->item_discount           = $item_discount;
197
+        $item->recurring_item_discount = $recurring_item_discount;
198 198
 
199
-	}
199
+    }
200 200
 
201
-	return array(
202
-		'name'               => 'discount_code',
203
-		'discount_code'      => $discount->get_code(),
204
-		'initial_discount'   => $initial_discount,
205
-		'recurring_discount' => $recurring_discount,
206
-	);
201
+    return array(
202
+        'name'               => 'discount_code',
203
+        'discount_code'      => $discount->get_code(),
204
+        'initial_discount'   => $initial_discount,
205
+        'recurring_discount' => $recurring_discount,
206
+    );
207 207
 
208 208
 }
209 209
 
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Returns an array of discount type.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
     return apply_filters(
18 18
         'wpinv_discount_types',
19 19
         array(
20
-            'percent' => __( 'Percentage', 'invoicing' ),
21
-            'flat'    => __( 'Flat Amount', 'invoicing' ),
20
+            'percent' => __('Percentage', 'invoicing'),
21
+            'flat'    => __('Flat Amount', 'invoicing'),
22 22
         )
23 23
     );
24 24
 }
@@ -28,46 +28,46 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return string
30 30
  */
31
-function wpinv_get_discount_type_name( $type = '' ) {
31
+function wpinv_get_discount_type_name($type = '') {
32 32
     $types = wpinv_get_discount_types();
33
-    return isset( $types[ $type ] ) ? $types[ $type ] : $type;
33
+    return isset($types[$type]) ? $types[$type] : $type;
34 34
 }
35 35
 
36 36
 /**
37 37
  * Deletes a discount via the admin page.
38 38
  *
39 39
  */
40
-function wpinv_delete_discount( $data ) {
40
+function wpinv_delete_discount($data) {
41 41
 
42
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
43
-    $discount->delete( true );
42
+    $discount = new WPInv_Discount(absint($data['discount']));
43
+    $discount->delete(true);
44 44
 
45 45
 }
46
-add_action( 'getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount' );
46
+add_action('getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount');
47 47
 
48 48
 /**
49 49
  * Deactivates a discount via the admin page.
50 50
  */
51
-function wpinv_activate_discount( $data ) {
51
+function wpinv_activate_discount($data) {
52 52
 
53
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
54
-    $discount->set_status( 'publish' );
53
+    $discount = new WPInv_Discount(absint($data['discount']));
54
+    $discount->set_status('publish');
55 55
     $discount->save();
56 56
 
57 57
 }
58
-add_action( 'getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount' );
58
+add_action('getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount');
59 59
 
60 60
 /**
61 61
  * Activates a discount via the admin page.
62 62
  */
63
-function wpinv_deactivate_discount( $data ) {
63
+function wpinv_deactivate_discount($data) {
64 64
 
65
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
66
-    $discount->set_status( 'pending' );
65
+    $discount = new WPInv_Discount(absint($data['discount']));
66
+    $discount->set_status('pending');
67 67
     $discount->save();
68 68
 
69 69
 }
70
-add_action( 'getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount' );
70
+add_action('getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount');
71 71
 
72 72
 /**
73 73
  * Fetches a discount object.
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
  * @since 1.0.15
77 77
  * @return WPInv_Discount
78 78
  */
79
-function wpinv_get_discount( $discount ) {
80
-    return new WPInv_Discount( $discount );
79
+function wpinv_get_discount($discount) {
80
+    return new WPInv_Discount($discount);
81 81
 }
82 82
 
83 83
 /**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
  * @since 1.0.15
88 88
  * @return WPInv_Discount
89 89
  */
90
-function wpinv_get_discount_obj( $discount = 0 ) {
91
-    return new WPInv_Discount( $discount );
90
+function wpinv_get_discount_obj($discount = 0) {
91
+    return new WPInv_Discount($discount);
92 92
 }
93 93
 
94 94
 /**
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
  * @param string|int $value The field value
99 99
  * @return bool|WPInv_Discount
100 100
  */
101
-function wpinv_get_discount_by( $deprecated = null, $value = '' ) {
102
-    $discount = new WPInv_Discount( $value );
101
+function wpinv_get_discount_by($deprecated = null, $value = '') {
102
+    $discount = new WPInv_Discount($value);
103 103
 
104
-    if ( $discount->get_id() != 0 ) {
104
+    if ($discount->get_id() != 0) {
105 105
         return $discount;
106 106
     }
107 107
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 function wpinv_get_discount_statuses() {
117 117
 
118 118
     return array(
119
-        'expired'  => __( 'Expired', 'invoicing' ),
120
-        'publish'  => __( 'Active', 'invoicing' ),
121
-        'inactive' => __( 'Inactive', 'invoicing' ),
119
+        'expired'  => __('Expired', 'invoicing'),
120
+        'publish'  => __('Active', 'invoicing'),
121
+        'inactive' => __('Inactive', 'invoicing'),
122 122
     );
123 123
 
124 124
 }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 /**
127 127
  * Retrieves an invoice status label.
128 128
  */
129
-function wpinv_discount_status( $status ) {
129
+function wpinv_discount_status($status) {
130 130
     $statuses = wpinv_get_discount_statuses();
131
-    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : __( 'Inactive', 'invoicing' );
131
+    return isset($statuses[$status]) ? $statuses[$status] : __('Inactive', 'invoicing');
132 132
 }
133 133
 
134 134
 /**
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
  * @param int|array|string|WPInv_Discount $code discount data, object, ID or code.
139 139
  * @return bool
140 140
  */
141
-function wpinv_discount_is_recurring( $discount = 0, $code = 0 ) {
141
+function wpinv_discount_is_recurring($discount = 0, $code = 0) {
142 142
 
143
-    if ( ! empty( $discount ) ) {
144
-        $discount    = wpinv_get_discount_obj( $discount );
143
+    if (!empty($discount)) {
144
+        $discount    = wpinv_get_discount_obj($discount);
145 145
     } else {
146
-        $discount    = wpinv_get_discount_obj( $code );
146
+        $discount    = wpinv_get_discount_obj($code);
147 147
     }
148 148
 
149 149
     return $discount->get_is_recurring();
@@ -158,35 +158,35 @@  discard block
 block discarded – undo
158 158
  * @param WPInv_Discount $discount
159 159
  * @return array
160 160
  */
161
-function getpaid_calculate_invoice_discount( $invoice, $discount ) {
161
+function getpaid_calculate_invoice_discount($invoice, $discount) {
162 162
 
163 163
 	$initial_discount   = 0;
164 164
 	$recurring_discount = 0;
165 165
 
166
-	foreach ( $invoice->get_items() as $item ) {
166
+	foreach ($invoice->get_items() as $item) {
167 167
 
168 168
 		// Abort if it is not valid for this item.
169
-		if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) {
169
+		if (!$discount->is_valid_for_items(array($item->get_id()))) {
170 170
 			continue;
171 171
 		}
172 172
 
173 173
 		// Calculate the initial amount...
174
-		$item_discount           = $discount->get_discounted_amount( $item->get_sub_total() );
174
+		$item_discount           = $discount->get_discounted_amount($item->get_sub_total());
175 175
 		$recurring_item_discount = 0;
176 176
 
177 177
 		// ... and maybe the recurring amount.
178
-		if ( $item->is_recurring() && $discount->is_recurring() ) {
179
-			$recurring_item_discount = $discount->get_discounted_amount( $item->get_recurring_sub_total() );
178
+		if ($item->is_recurring() && $discount->is_recurring()) {
179
+			$recurring_item_discount = $discount->get_discounted_amount($item->get_recurring_sub_total());
180 180
 		}
181 181
 
182 182
 		// Discount should not exceed discounted amount.
183
-		if ( ! $discount->is_type( 'percent' ) ) {
183
+		if (!$discount->is_type('percent')) {
184 184
 
185
-			if ( ( $initial_discount + $item_discount ) > $discount->get_amount() ) {
185
+			if (($initial_discount + $item_discount) > $discount->get_amount()) {
186 186
 				$item_discount = $discount->get_amount() - $initial_discount;
187 187
 			}
188 188
 
189
-			if ( ( $recurring_discount + $recurring_item_discount ) > $discount->get_amount() ) {
189
+			if (($recurring_discount + $recurring_item_discount) > $discount->get_amount()) {
190 190
 				$recurring_item_discount = $discount->get_amount() - $recurring_discount;
191 191
 			}
192 192
         }
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
         array(
219 219
             'post_type'   => 'wpi_discount',
220 220
             'numberposts' => 1,
221
-            'fields'      => array( 'ids' ),
221
+            'fields'      => array('ids'),
222 222
         )
223 223
     );
224 224
 
225
-    return ! empty( $discounts );
225
+    return !empty($discounts);
226 226
 
227 227
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form.php 2 patches
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,55 +10,55 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'payment_form';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'payment_form';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'payment_form';
25 25
 
26 26
     /**
27
-	 * Form Data array. This is the core form data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'status'        => 'draft',
34
-		'version'       => '',
35
-		'date_created'  => null,
27
+     * Form Data array. This is the core form data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'status'        => 'draft',
34
+        'version'       => '',
35
+        'date_created'  => null,
36 36
         'date_modified' => null,
37 37
         'name'          => '',
38 38
         'author'        => 1,
39 39
         'elements'      => null,
40
-		'items'         => null,
41
-		'earned'        => 0,
42
-		'refunded'      => 0,
43
-		'cancelled'     => 0,
44
-		'failed'        => 0,
45
-	);
46
-
47
-    /**
48
-	 * Stores meta in cache for future reads.
49
-	 *
50
-	 * A group must be set to to enable caching.
51
-	 *
52
-	 * @var string
53
-	 */
54
-	protected $cache_group = 'getpaid_forms';
55
-
56
-	/**
57
-	 * Stores a reference to the invoice if the form is for an invoice..
58
-	 *
59
-	 * @var WPInv_Invoice
60
-	 */
61
-	public $invoice = 0;
40
+        'items'         => null,
41
+        'earned'        => 0,
42
+        'refunded'      => 0,
43
+        'cancelled'     => 0,
44
+        'failed'        => 0,
45
+    );
46
+
47
+    /**
48
+     * Stores meta in cache for future reads.
49
+     *
50
+     * A group must be set to to enable caching.
51
+     *
52
+     * @var string
53
+     */
54
+    protected $cache_group = 'getpaid_forms';
55
+
56
+    /**
57
+     * Stores a reference to the invoice if the form is for an invoice..
58
+     *
59
+     * @var WPInv_Invoice
60
+     */
61
+    public $invoice = 0;
62 62
 
63 63
     /**
64 64
      * Stores a reference to the original WP_Post object
@@ -68,35 +68,35 @@  discard block
 block discarded – undo
68 68
     protected $post = null;
69 69
 
70 70
     /**
71
-	 * Get the form if ID is passed, otherwise the form is new and empty.
72
-	 *
73
-	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
-	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
71
+     * Get the form if ID is passed, otherwise the form is new and empty.
72
+     *
73
+     * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
+     */
75
+    public function __construct( $form = 0 ) {
76
+        parent::__construct( $form );
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+        if ( is_numeric( $form ) && $form > 0 ) {
79
+            $this->set_id( $form );
80
+        } elseif ( $form instanceof self ) {
81 81
 
82
-			$this->set_id( $form->get_id() );
83
-			$this->invoice = $form->invoice;
82
+            $this->set_id( $form->get_id() );
83
+            $this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
87
-		} else {
88
-			$this->set_object_read( true );
89
-		}
85
+        } elseif ( ! empty( $form->ID ) ) {
86
+            $this->set_id( $form->ID );
87
+        } else {
88
+            $this->set_object_read( true );
89
+        }
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
93 93
 
94
-		if ( $this->get_id() > 0 ) {
94
+        if ( $this->get_id() > 0 ) {
95 95
             $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
96
+            $this->data_store->read( $this );
97 97
         }
98 98
 
99
-	}
99
+    }
100 100
 
101 101
     /*
102 102
 	|--------------------------------------------------------------------------
@@ -114,356 +114,356 @@  discard block
 block discarded – undo
114 114
     */
115 115
 
116 116
     /**
117
-	 * Get plugin version when the form was created.
118
-	 *
119
-	 * @since 1.0.19
120
-	 * @param  string $context View or edit context.
121
-	 * @return string
122
-	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
117
+     * Get plugin version when the form was created.
118
+     *
119
+     * @since 1.0.19
120
+     * @param  string $context View or edit context.
121
+     * @return string
122
+     */
123
+    public function get_version( $context = 'view' ) {
124
+        return $this->get_prop( 'version', $context );
125 125
     }
126 126
 
127 127
     /**
128
-	 * Get date when the form was created.
129
-	 *
130
-	 * @since 1.0.19
131
-	 * @param  string $context View or edit context.
132
-	 * @return string
133
-	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
128
+     * Get date when the form was created.
129
+     *
130
+     * @since 1.0.19
131
+     * @param  string $context View or edit context.
132
+     * @return string
133
+     */
134
+    public function get_date_created( $context = 'view' ) {
135
+        return $this->get_prop( 'date_created', $context );
136 136
     }
137 137
 
138 138
     /**
139
-	 * Get GMT date when the form was created.
140
-	 *
141
-	 * @since 1.0.19
142
-	 * @param  string $context View or edit context.
143
-	 * @return string
144
-	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
139
+     * Get GMT date when the form was created.
140
+     *
141
+     * @since 1.0.19
142
+     * @param  string $context View or edit context.
143
+     * @return string
144
+     */
145
+    public function get_date_created_gmt( $context = 'view' ) {
146 146
         $date = $this->get_date_created( $context );
147 147
 
148 148
         if ( $date ) {
149 149
             $date = get_gmt_from_date( $date );
150 150
         }
151
-		return $date;
151
+        return $date;
152 152
     }
153 153
 
154 154
     /**
155
-	 * Get date when the form was last modified.
156
-	 *
157
-	 * @since 1.0.19
158
-	 * @param  string $context View or edit context.
159
-	 * @return string
160
-	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
155
+     * Get date when the form was last modified.
156
+     *
157
+     * @since 1.0.19
158
+     * @param  string $context View or edit context.
159
+     * @return string
160
+     */
161
+    public function get_date_modified( $context = 'view' ) {
162
+        return $this->get_prop( 'date_modified', $context );
163 163
     }
164 164
 
165 165
     /**
166
-	 * Get GMT date when the form was last modified.
167
-	 *
168
-	 * @since 1.0.19
169
-	 * @param  string $context View or edit context.
170
-	 * @return string
171
-	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
166
+     * Get GMT date when the form was last modified.
167
+     *
168
+     * @since 1.0.19
169
+     * @param  string $context View or edit context.
170
+     * @return string
171
+     */
172
+    public function get_date_modified_gmt( $context = 'view' ) {
173 173
         $date = $this->get_date_modified( $context );
174 174
 
175 175
         if ( $date ) {
176 176
             $date = get_gmt_from_date( $date );
177 177
         }
178
-		return $date;
178
+        return $date;
179 179
     }
180 180
 
181 181
     /**
182
-	 * Get the form name.
183
-	 *
184
-	 * @since 1.0.19
185
-	 * @param  string $context View or edit context.
186
-	 * @return string
187
-	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
182
+     * Get the form name.
183
+     *
184
+     * @since 1.0.19
185
+     * @param  string $context View or edit context.
186
+     * @return string
187
+     */
188
+    public function get_name( $context = 'view' ) {
189
+        return $this->get_prop( 'name', $context );
190 190
     }
191 191
 
192 192
     /**
193
-	 * Alias of self::get_name().
194
-	 *
195
-	 * @since 1.0.19
196
-	 * @param  string $context View or edit context.
197
-	 * @return string
198
-	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
201
-	}
193
+     * Alias of self::get_name().
194
+     *
195
+     * @since 1.0.19
196
+     * @param  string $context View or edit context.
197
+     * @return string
198
+     */
199
+    public function get_title( $context = 'view' ) {
200
+        return $this->get_name( $context );
201
+    }
202 202
 
203 203
     /**
204
-	 * Get the owner of the form.
205
-	 *
206
-	 * @since 1.0.19
207
-	 * @param  string $context View or edit context.
208
-	 * @return int
209
-	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
204
+     * Get the owner of the form.
205
+     *
206
+     * @since 1.0.19
207
+     * @param  string $context View or edit context.
208
+     * @return int
209
+     */
210
+    public function get_author( $context = 'view' ) {
211
+        return (int) $this->get_prop( 'author', $context );
212 212
     }
213 213
 
214 214
     /**
215
-	 * Get the elements that make up the form.
216
-	 *
217
-	 * @since 1.0.19
218
-	 * @param  string $context View or edit context.
219
-	 * @return array
220
-	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
215
+     * Get the elements that make up the form.
216
+     *
217
+     * @since 1.0.19
218
+     * @param  string $context View or edit context.
219
+     * @return array
220
+     */
221
+    public function get_elements( $context = 'view' ) {
222
+        $elements = $this->get_prop( 'elements', $context );
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
224
+        if ( empty( $elements ) || ! is_array( $elements ) ) {
225 225
             return wpinv_get_data( 'sample-payment-form' );
226
-		}
226
+        }
227 227
 
228
-		// Ensure that all required elements exist.
229
-		$_elements = array();
230
-		foreach ( $elements as $element ) {
228
+        // Ensure that all required elements exist.
229
+        $_elements = array();
230
+        foreach ( $elements as $element ) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+            if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
233 233
 
234
-				$_elements[] = array(
235
-					'text'    => __( 'Select Payment Method', 'invoicing' ),
236
-					'id'      => 'gtscicd',
237
-					'name'    => 'gtscicd',
238
-					'type'    => 'gateway_select',
239
-					'premade' => true,
234
+                $_elements[] = array(
235
+                    'text'    => __( 'Select Payment Method', 'invoicing' ),
236
+                    'id'      => 'gtscicd',
237
+                    'name'    => 'gtscicd',
238
+                    'type'    => 'gateway_select',
239
+                    'premade' => true,
240 240
 
241
-				);
241
+                );
242 242
 
243
-			}
243
+            }
244 244
 
245
-			$_elements[] = $element;
245
+            $_elements[] = $element;
246 246
 
247
-		}
247
+        }
248 248
 
249 249
         return $_elements;
250
-	}
251
-
252
-	/**
253
-	 * Get the items sold via the form.
254
-	 *
255
-	 * @since 1.0.19
256
-	 * @param  string $context View or edit context.
257
-	 * @param  string $return objects or arrays.
258
-	 * @return GetPaid_Form_Item[]
259
-	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
262
-
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
250
+    }
251
+
252
+    /**
253
+     * Get the items sold via the form.
254
+     *
255
+     * @since 1.0.19
256
+     * @param  string $context View or edit context.
257
+     * @param  string $return objects or arrays.
258
+     * @return GetPaid_Form_Item[]
259
+     */
260
+    public function get_items( $context = 'view', $return = 'objects' ) {
261
+        $items = $this->get_prop( 'items', $context );
262
+
263
+        if ( empty( $items ) || ! is_array( $items ) ) {
264 264
             $items = wpinv_get_data( 'sample-payment-form-items' );
265
-		}
265
+        }
266
+
267
+        // Convert the items.
268
+        $prepared = array();
269
+
270
+        foreach ( $items as $key => $value ) {
271
+
272
+            // Form items.
273
+            if ( $value instanceof GetPaid_Form_Item ) {
274
+
275
+                if ( $value->can_purchase() ) {
276
+                    $prepared[] = $value;
277
+                }
266 278
 
267
-		// Convert the items.
268
-		$prepared = array();
279
+                continue;
269 280
 
270
-		foreach ( $items as $key => $value ) {
281
+            }
271 282
 
272
-			// Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
283
+            // $item_id => $quantity (buy buttons)
284
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
+                $item = new GetPaid_Form_Item( $key );
274 286
 
275
-				if ( $value->can_purchase() ) {
276
-					$prepared[] = $value;
277
-				}
287
+                if ( $item->can_purchase() ) {
278 288
 
279
-				continue;
289
+                    $value = (float) $value;
290
+                    $item->set_quantity( $value );
291
+                    if ( 0 == $value ) {
292
+                        $item->set_quantity( 1 );
293
+                        $item->set_allow_quantities( true );
294
+                    }
280 295
 
281
-			}
296
+                    $prepared[] = $item;
297
+                }
282 298
 
283
-			// $item_id => $quantity (buy buttons)
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
299
+                continue;
300
+            }
286 301
 
287
-				if ( $item->can_purchase() ) {
302
+            // Items saved via payment forms editor.
303
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
288 304
 
289
-					$value = (float) $value;
290
-					$item->set_quantity( $value );
291
-					if ( 0 == $value ) {
292
-						$item->set_quantity( 1 );
293
-						$item->set_allow_quantities( true );
294
-					}
305
+                $item = new GetPaid_Form_Item( $value['id'] );
295 306
 
296
-					$prepared[] = $item;
297
-				}
307
+                if ( ! $item->can_purchase() ) {
308
+                    continue;
309
+                }
298 310
 
299
-				continue;
300
-			}
311
+                // Sub-total (Cart items).
312
+                if ( isset( $value['subtotal'] ) ) {
313
+                    $item->set_price( $value['subtotal'] );
314
+                }
301 315
 
302
-			// Items saved via payment forms editor.
303
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
316
+                if ( isset( $value['quantity'] ) ) {
317
+                    $item->set_quantity( $value['quantity'] );
318
+                }
304 319
 
305
-				$item = new GetPaid_Form_Item( $value['id'] );
320
+                if ( isset( $value['allow_quantities'] ) ) {
321
+                    $item->set_allow_quantities( $value['allow_quantities'] );
322
+                }
306 323
 
307
-				if ( ! $item->can_purchase() ) {
308
-					continue;
309
-				}
324
+                if ( isset( $value['required'] ) ) {
325
+                    $item->set_is_required( $value['required'] );
326
+                }
310 327
 
311
-				// Sub-total (Cart items).
312
-				if ( isset( $value['subtotal'] ) ) {
313
-					$item->set_price( $value['subtotal'] );
314
-				}
328
+                if ( isset( $value['description'] ) ) {
329
+                    $item->set_custom_description( $value['description'] );
330
+                }
315 331
 
316
-				if ( isset( $value['quantity'] ) ) {
317
-					$item->set_quantity( $value['quantity'] );
318
-				}
332
+                $prepared[] = $item;
333
+                continue;
319 334
 
320
-				if ( isset( $value['allow_quantities'] ) ) {
321
-					$item->set_allow_quantities( $value['allow_quantities'] );
322
-				}
335
+            }
323 336
 
324
-				if ( isset( $value['required'] ) ) {
325
-					$item->set_is_required( $value['required'] );
326
-				}
337
+            // $item_id => array( 'price' => 10 ) (item variations)
338
+            if ( is_numeric( $key ) && is_array( $value ) ) {
339
+                $item = new GetPaid_Form_Item( $key );
327 340
 
328
-				if ( isset( $value['description'] ) ) {
329
-					$item->set_custom_description( $value['description'] );
330
-				}
341
+                if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
342
+                    $item->set_price( $value['price'] );
343
+                }
331 344
 
332
-				$prepared[] = $item;
333
-				continue;
345
+                if ( $item->can_purchase() ) {
346
+                    $prepared[] = $item;
347
+                }
334 348
 
335
-			}
336
-
337
-			// $item_id => array( 'price' => 10 ) (item variations)
338
-			if ( is_numeric( $key ) && is_array( $value ) ) {
339
-				$item = new GetPaid_Form_Item( $key );
340
-
341
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
342
-					$item->set_price( $value['price'] );
343
-				}
344
-
345
-				if ( $item->can_purchase() ) {
346
-					$prepared[] = $item;
347
-				}
348
-
349
-				continue;
350
-			}
351
-		}
352
-
353
-		if ( 'objects' == $return && 'view' == $context ) {
354
-			return $prepared;
355
-		}
356
-
357
-		$items = array();
358
-		foreach ( $prepared as $item ) {
359
-			$items[] = $item->prepare_data_for_use();
360
-		}
361
-
362
-		return $items;
363
-	}
364
-
365
-	/**
366
-	 * Get a single item belonging to the form.
367
-	 *
368
-	 * @since 1.0.19
369
-	 * @param  int $item_id The item id to return.
370
-	 * @return GetPaid_Form_Item|bool
371
-	 */
372
-	public function get_item( $item_id ) {
373
-
374
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
375
-			return false;
376
-		}
377
-
378
-		foreach ( $this->get_items() as $item ) {
379
-			if ( $item->get_id() == (int) $item_id ) {
380
-				return $item;
381
-			}
382
-		}
383
-
384
-		return false;
385
-
386
-	}
387
-
388
-	/**
389
-	 * Gets a single element.
390
-	 *
391
-	 * @since 1.0.19
392
-	 * @param  string $element_type The element type to return.
393
-	 * @return array|bool
394
-	 */
395
-	public function get_element_type( $element_type ) {
396
-
397
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
398
-			return false;
399
-		}
400
-
401
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
402
-
403
-			if ( $element['type'] === $element_type ) {
404
-				return $element;
405
-			}
406
-		}
407
-
408
-		return false;
409
-
410
-	}
411
-
412
-	/**
413
-	 * Get the total amount earned via this form.
414
-	 *
415
-	 * @since 1.0.19
416
-	 * @param  string $context View or edit context.
417
-	 * @return float
418
-	 */
419
-	public function get_earned( $context = 'view' ) {
420
-		return $this->get_prop( 'earned', $context );
421
-	}
422
-
423
-	/**
424
-	 * Get the total amount refunded via this form.
425
-	 *
426
-	 * @since 1.0.19
427
-	 * @param  string $context View or edit context.
428
-	 * @return float
429
-	 */
430
-	public function get_refunded( $context = 'view' ) {
431
-		return $this->get_prop( 'refunded', $context );
432
-	}
433
-
434
-	/**
435
-	 * Get the total amount cancelled via this form.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @param  string $context View or edit context.
439
-	 * @return float
440
-	 */
441
-	public function get_cancelled( $context = 'view' ) {
442
-		return $this->get_prop( 'cancelled', $context );
443
-	}
444
-
445
-	/**
446
-	 * Get the total amount failed via this form.
447
-	 *
448
-	 * @since 1.0.19
449
-	 * @param  string $context View or edit context.
450
-	 * @return float
451
-	 */
452
-	public function get_failed( $context = 'view' ) {
453
-		return $this->get_prop( 'failed', $context );
454
-	}
455
-
456
-	/**
457
-	 * Get the currency.
458
-	 *
459
-	 * @since 1.0.19
460
-	 * @param  string $context View or edit context.
461
-	 * @return string
462
-	 */
463
-	public function get_currency() {
464
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
465
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
466
-	}
349
+                continue;
350
+            }
351
+        }
352
+
353
+        if ( 'objects' == $return && 'view' == $context ) {
354
+            return $prepared;
355
+        }
356
+
357
+        $items = array();
358
+        foreach ( $prepared as $item ) {
359
+            $items[] = $item->prepare_data_for_use();
360
+        }
361
+
362
+        return $items;
363
+    }
364
+
365
+    /**
366
+     * Get a single item belonging to the form.
367
+     *
368
+     * @since 1.0.19
369
+     * @param  int $item_id The item id to return.
370
+     * @return GetPaid_Form_Item|bool
371
+     */
372
+    public function get_item( $item_id ) {
373
+
374
+        if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
375
+            return false;
376
+        }
377
+
378
+        foreach ( $this->get_items() as $item ) {
379
+            if ( $item->get_id() == (int) $item_id ) {
380
+                return $item;
381
+            }
382
+        }
383
+
384
+        return false;
385
+
386
+    }
387
+
388
+    /**
389
+     * Gets a single element.
390
+     *
391
+     * @since 1.0.19
392
+     * @param  string $element_type The element type to return.
393
+     * @return array|bool
394
+     */
395
+    public function get_element_type( $element_type ) {
396
+
397
+        if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
398
+            return false;
399
+        }
400
+
401
+        foreach ( $this->get_prop( 'elements' ) as $element ) {
402
+
403
+            if ( $element['type'] === $element_type ) {
404
+                return $element;
405
+            }
406
+        }
407
+
408
+        return false;
409
+
410
+    }
411
+
412
+    /**
413
+     * Get the total amount earned via this form.
414
+     *
415
+     * @since 1.0.19
416
+     * @param  string $context View or edit context.
417
+     * @return float
418
+     */
419
+    public function get_earned( $context = 'view' ) {
420
+        return $this->get_prop( 'earned', $context );
421
+    }
422
+
423
+    /**
424
+     * Get the total amount refunded via this form.
425
+     *
426
+     * @since 1.0.19
427
+     * @param  string $context View or edit context.
428
+     * @return float
429
+     */
430
+    public function get_refunded( $context = 'view' ) {
431
+        return $this->get_prop( 'refunded', $context );
432
+    }
433
+
434
+    /**
435
+     * Get the total amount cancelled via this form.
436
+     *
437
+     * @since 1.0.19
438
+     * @param  string $context View or edit context.
439
+     * @return float
440
+     */
441
+    public function get_cancelled( $context = 'view' ) {
442
+        return $this->get_prop( 'cancelled', $context );
443
+    }
444
+
445
+    /**
446
+     * Get the total amount failed via this form.
447
+     *
448
+     * @since 1.0.19
449
+     * @param  string $context View or edit context.
450
+     * @return float
451
+     */
452
+    public function get_failed( $context = 'view' ) {
453
+        return $this->get_prop( 'failed', $context );
454
+    }
455
+
456
+    /**
457
+     * Get the currency.
458
+     *
459
+     * @since 1.0.19
460
+     * @param  string $context View or edit context.
461
+     * @return string
462
+     */
463
+    public function get_currency() {
464
+        $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
465
+        return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
466
+    }
467 467
 
468 468
     /*
469 469
 	|--------------------------------------------------------------------------
@@ -476,22 +476,22 @@  discard block
 block discarded – undo
476 476
     */
477 477
 
478 478
     /**
479
-	 * Set plugin version when the item was created.
480
-	 *
481
-	 * @since 1.0.19
482
-	 */
483
-	public function set_version( $value ) {
484
-		$this->set_prop( 'version', $value );
479
+     * Set plugin version when the item was created.
480
+     *
481
+     * @since 1.0.19
482
+     */
483
+    public function set_version( $value ) {
484
+        $this->set_prop( 'version', $value );
485 485
     }
486 486
 
487 487
     /**
488
-	 * Set date when the item was created.
489
-	 *
490
-	 * @since 1.0.19
491
-	 * @param string $value Value to set.
488
+     * Set date when the item was created.
489
+     *
490
+     * @since 1.0.19
491
+     * @param string $value Value to set.
492 492
      * @return bool Whether or not the date was set.
493
-	 */
494
-	public function set_date_created( $value ) {
493
+     */
494
+    public function set_date_created( $value ) {
495 495
         $date = strtotime( $value );
496 496
 
497 497
         if ( $date ) {
@@ -504,13 +504,13 @@  discard block
 block discarded – undo
504 504
     }
505 505
 
506 506
     /**
507
-	 * Set date when the item was last modified.
508
-	 *
509
-	 * @since 1.0.19
510
-	 * @param string $value Value to set.
507
+     * Set date when the item was last modified.
508
+     *
509
+     * @since 1.0.19
510
+     * @param string $value Value to set.
511 511
      * @return bool Whether or not the date was set.
512
-	 */
513
-	public function set_date_modified( $value ) {
512
+     */
513
+    public function set_date_modified( $value ) {
514 514
         $date = strtotime( $value );
515 515
 
516 516
         if ( $date ) {
@@ -523,164 +523,164 @@  discard block
 block discarded – undo
523 523
     }
524 524
 
525 525
     /**
526
-	 * Set the item name.
527
-	 *
528
-	 * @since 1.0.19
529
-	 * @param  string $value New name.
530
-	 */
531
-	public function set_name( $value ) {
532
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
533
-    }
534
-
535
-    /**
536
-	 * Alias of self::set_name().
537
-	 *
538
-	 * @since 1.0.19
539
-	 * @param  string $value New name.
540
-	 */
541
-	public function set_title( $value ) {
542
-		$this->set_name( $value );
543
-    }
544
-
545
-    /**
546
-	 * Set the owner of the item.
547
-	 *
548
-	 * @since 1.0.19
549
-	 * @param  int $value New author.
550
-	 */
551
-	public function set_author( $value ) {
552
-		$this->set_prop( 'author', (int) $value );
553
-	}
554
-
555
-	/**
556
-	 * Set the form elements.
557
-	 *
558
-	 * @since 1.0.19
559
-	 * @sinve 2.3.4 Array values sanitized.
560
-	 * @param  array $value Form elements.
561
-	 */
562
-	public function set_elements( $value ) {
563
-		if ( is_array( $value ) ) {
564
-			$this->set_prop( 'elements', wp_kses_post_deep( $value ) );
565
-		}
566
-	}
567
-
568
-	/**
569
-	 * Sanitize array values.
570
-	 *
571
-	 * @param $value
572
-	 *
573
-	 * @return mixed
574
-	 */
575
-	public function sanitize_array_values( $value ) {
576
-
577
-		// sanitize
578
-		if ( ! empty( $value ) ) {
579
-
580
-			foreach ( $value as $key => $val_arr ) {
581
-
582
-				if ( is_array( $val_arr ) ) {
583
-					// check if we have sub array items.
584
-					$sub_arr = array();
585
-					foreach ( $val_arr as $key2 => $val2 ) {
586
-						if ( is_array( $val2 ) ) {
587
-							$sub_arr[ $key2 ] = $this->sanitize_array_values( $val2 );
588
-							unset( $val_arr[ $key ][ $key2 ] );
589
-						}
590
-					}
591
-
592
-					// we allow some html in description so we sanitize it separately.
593
-					$help_text = ! empty( $val_arr['description'] ) ? wp_kses_post( $val_arr['description'] ) : '';
594
-
595
-					// sanitize array elements
596
-					$value[ $key ] = array_map( 'sanitize_text_field', $val_arr );
597
-
598
-					// add back the description if set
599
-					if ( isset( $val_arr['description'] ) ) {
526
+     * Set the item name.
527
+     *
528
+     * @since 1.0.19
529
+     * @param  string $value New name.
530
+     */
531
+    public function set_name( $value ) {
532
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
533
+    }
534
+
535
+    /**
536
+     * Alias of self::set_name().
537
+     *
538
+     * @since 1.0.19
539
+     * @param  string $value New name.
540
+     */
541
+    public function set_title( $value ) {
542
+        $this->set_name( $value );
543
+    }
544
+
545
+    /**
546
+     * Set the owner of the item.
547
+     *
548
+     * @since 1.0.19
549
+     * @param  int $value New author.
550
+     */
551
+    public function set_author( $value ) {
552
+        $this->set_prop( 'author', (int) $value );
553
+    }
554
+
555
+    /**
556
+     * Set the form elements.
557
+     *
558
+     * @since 1.0.19
559
+     * @sinve 2.3.4 Array values sanitized.
560
+     * @param  array $value Form elements.
561
+     */
562
+    public function set_elements( $value ) {
563
+        if ( is_array( $value ) ) {
564
+            $this->set_prop( 'elements', wp_kses_post_deep( $value ) );
565
+        }
566
+    }
567
+
568
+    /**
569
+     * Sanitize array values.
570
+     *
571
+     * @param $value
572
+     *
573
+     * @return mixed
574
+     */
575
+    public function sanitize_array_values( $value ) {
576
+
577
+        // sanitize
578
+        if ( ! empty( $value ) ) {
579
+
580
+            foreach ( $value as $key => $val_arr ) {
581
+
582
+                if ( is_array( $val_arr ) ) {
583
+                    // check if we have sub array items.
584
+                    $sub_arr = array();
585
+                    foreach ( $val_arr as $key2 => $val2 ) {
586
+                        if ( is_array( $val2 ) ) {
587
+                            $sub_arr[ $key2 ] = $this->sanitize_array_values( $val2 );
588
+                            unset( $val_arr[ $key ][ $key2 ] );
589
+                        }
590
+                    }
591
+
592
+                    // we allow some html in description so we sanitize it separately.
593
+                    $help_text = ! empty( $val_arr['description'] ) ? wp_kses_post( $val_arr['description'] ) : '';
594
+
595
+                    // sanitize array elements
596
+                    $value[ $key ] = array_map( 'sanitize_text_field', $val_arr );
597
+
598
+                    // add back the description if set
599
+                    if ( isset( $val_arr['description'] ) ) {
600 600
 $value[ $key ]['description'] = $help_text;}
601 601
 
602
-					// add back sub array items after its been sanitized.
603
-					if ( ! empty( $sub_arr ) ) {
604
-						$value[ $key ] = array_merge( $value[ $key ], $sub_arr );
605
-					}
606
-				}
602
+                    // add back sub array items after its been sanitized.
603
+                    if ( ! empty( $sub_arr ) ) {
604
+                        $value[ $key ] = array_merge( $value[ $key ], $sub_arr );
605
+                    }
606
+                }
607 607
 }
608 608
 }
609 609
 
610
-		return $value;
611
-	}
612
-
613
-	/**
614
-	 * Set the form items.
615
-	 *
616
-	 * @since 1.0.19
617
-	 * @param  array $value Form elements.
618
-	 */
619
-	public function set_items( $value ) {
620
-		if ( is_array( $value ) ) {
621
-			$this->set_prop( 'items', $value );
622
-		}
623
-	}
624
-
625
-	/**
626
-	 * Set the total amount earned via this form.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param  float $value Amount earned.
630
-	 */
631
-	public function set_earned( $value ) {
632
-		$value = max( (float) $value, 0 );
633
-		$this->set_prop( 'earned', $value );
634
-	}
635
-
636
-	/**
637
-	 * Set the total amount refunded via this form.
638
-	 *
639
-	 * @since 1.0.19
640
-	 * @param  float $value Amount refunded.
641
-	 */
642
-	public function set_refunded( $value ) {
643
-		$value = max( (float) $value, 0 );
644
-		$this->set_prop( 'refunded', $value );
645
-	}
646
-
647
-	/**
648
-	 * Set the total amount cancelled via this form.
649
-	 *
650
-	 * @since 1.0.19
651
-	 * @param  float $value Amount cancelled.
652
-	 */
653
-	public function set_cancelled( $value ) {
654
-		$value = max( (float) $value, 0 );
655
-		$this->set_prop( 'cancelled', $value );
656
-	}
657
-
658
-	/**
659
-	 * Set the total amount failed via this form.
660
-	 *
661
-	 * @since 1.0.19
662
-	 * @param  float $value Amount cancelled.
663
-	 */
664
-	public function set_failed( $value ) {
665
-		$value = max( (float) $value, 0 );
666
-		$this->set_prop( 'failed', $value );
667
-	}
610
+        return $value;
611
+    }
612
+
613
+    /**
614
+     * Set the form items.
615
+     *
616
+     * @since 1.0.19
617
+     * @param  array $value Form elements.
618
+     */
619
+    public function set_items( $value ) {
620
+        if ( is_array( $value ) ) {
621
+            $this->set_prop( 'items', $value );
622
+        }
623
+    }
624
+
625
+    /**
626
+     * Set the total amount earned via this form.
627
+     *
628
+     * @since 1.0.19
629
+     * @param  float $value Amount earned.
630
+     */
631
+    public function set_earned( $value ) {
632
+        $value = max( (float) $value, 0 );
633
+        $this->set_prop( 'earned', $value );
634
+    }
635
+
636
+    /**
637
+     * Set the total amount refunded via this form.
638
+     *
639
+     * @since 1.0.19
640
+     * @param  float $value Amount refunded.
641
+     */
642
+    public function set_refunded( $value ) {
643
+        $value = max( (float) $value, 0 );
644
+        $this->set_prop( 'refunded', $value );
645
+    }
646
+
647
+    /**
648
+     * Set the total amount cancelled via this form.
649
+     *
650
+     * @since 1.0.19
651
+     * @param  float $value Amount cancelled.
652
+     */
653
+    public function set_cancelled( $value ) {
654
+        $value = max( (float) $value, 0 );
655
+        $this->set_prop( 'cancelled', $value );
656
+    }
657
+
658
+    /**
659
+     * Set the total amount failed via this form.
660
+     *
661
+     * @since 1.0.19
662
+     * @param  float $value Amount cancelled.
663
+     */
664
+    public function set_failed( $value ) {
665
+        $value = max( (float) $value, 0 );
666
+        $this->set_prop( 'failed', $value );
667
+    }
668 668
 
669 669
     /**
670 670
      * Create an item. For backwards compatibilty.
671 671
      *
672 672
      * @deprecated
673
-	 * @return int item id
673
+     * @return int item id
674 674
      */
675 675
     public function create( $data = array() ) {
676 676
 
677
-		// Set the properties.
678
-		if ( is_array( $data ) ) {
679
-			$this->set_props( $data );
680
-		}
677
+        // Set the properties.
678
+        if ( is_array( $data ) ) {
679
+            $this->set_props( $data );
680
+        }
681 681
 
682
-		// Save the item.
683
-		return $this->save();
682
+        // Save the item.
683
+        return $this->save();
684 684
 
685 685
     }
686 686
 
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
      * Updates an item. For backwards compatibilty.
689 689
      *
690 690
      * @deprecated
691
-	 * @return int item id
691
+     * @return int item id
692 692
      */
693 693
     public function update( $data = array() ) {
694 694
         return $this->create( $data );
@@ -704,22 +704,22 @@  discard block
 block discarded – undo
704 704
 	*/
705 705
 
706 706
     /**
707
-	 * Checks whether this is the default payment form.
708
-	 *
709
-	 * @since 1.0.19
710
-	 * @return bool
711
-	 */
707
+     * Checks whether this is the default payment form.
708
+     *
709
+     * @since 1.0.19
710
+     * @return bool
711
+     */
712 712
     public function is_default() {
713 713
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
714 714
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
715
-	}
715
+    }
716 716
 
717 717
     /**
718
-	 * Checks whether the form is active.
719
-	 *
720
-	 * @since 1.0.19
721
-	 * @return bool
722
-	 */
718
+     * Checks whether the form is active.
719
+     *
720
+     * @since 1.0.19
721
+     * @return bool
722
+     */
723 723
     public function is_active() {
724 724
         $is_active = 0 !== (int) $this->get_id();
725 725
 
@@ -728,81 +728,81 @@  discard block
 block discarded – undo
728 728
         }
729 729
 
730 730
         return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
731
-	}
732
-
733
-	/**
734
-	 * Checks whether the form has a given item.
735
-	 *
736
-	 * @since 1.0.19
737
-	 * @return bool
738
-	 */
731
+    }
732
+
733
+    /**
734
+     * Checks whether the form has a given item.
735
+     *
736
+     * @since 1.0.19
737
+     * @return bool
738
+     */
739 739
     public function has_item( $item_id ) {
740 740
         return false !== $this->get_item( $item_id );
741
-	}
742
-
743
-	/**
744
-	 * Checks whether the form has a given element.
745
-	 *
746
-	 * @since 1.0.19
747
-	 * @return bool
748
-	 */
741
+    }
742
+
743
+    /**
744
+     * Checks whether the form has a given element.
745
+     *
746
+     * @since 1.0.19
747
+     * @return bool
748
+     */
749 749
     public function has_element_type( $element_type ) {
750 750
         return false !== $this->get_element_type( $element_type );
751
-	}
752
-
753
-	/**
754
-	 * Checks whether this form is recurring or not.
755
-	 *
756
-	 * @since 1.0.19
757
-	 * @return bool
758
-	 */
751
+    }
752
+
753
+    /**
754
+     * Checks whether this form is recurring or not.
755
+     *
756
+     * @since 1.0.19
757
+     * @return bool
758
+     */
759 759
     public function is_recurring() {
760 760
 
761
-		if ( ! empty( $this->invoice ) ) {
762
-			return $this->invoice->is_recurring();
763
-		}
761
+        if ( ! empty( $this->invoice ) ) {
762
+            return $this->invoice->is_recurring();
763
+        }
764 764
 
765
-		foreach ( $this->get_items() as $item ) {
765
+        foreach ( $this->get_items() as $item ) {
766 766
 
767
-			if ( $item->is_recurring() ) {
768
-				return true;
769
-			}
767
+            if ( $item->is_recurring() ) {
768
+                return true;
769
+            }
770 770
 }
771 771
 
772 772
         return false;
773
-	}
773
+    }
774 774
 
775
-	/**
776
-	 * Retrieves the form's html.
777
-	 *
778
-	 * @since 1.0.19
779
-	 */
775
+    /**
776
+     * Retrieves the form's html.
777
+     *
778
+     * @since 1.0.19
779
+     */
780 780
     public function get_html( $extra_markup = '' ) {
781 781
 
782
-		// Return the HTML.
783
-		return wpinv_get_template_html(
784
-			'payment-forms/form.php',
785
-			array(
786
-				'form'         => $this,
787
-				'extra_markup' => $extra_markup,
788
-			)
789
-		);
790
-
791
-	}
792
-
793
-	/**
794
-	 * Displays the payment form.
795
-	 *
796
-	 * @since 1.0.19
797
-	 */
782
+        // Return the HTML.
783
+        return wpinv_get_template_html(
784
+            'payment-forms/form.php',
785
+            array(
786
+                'form'         => $this,
787
+                'extra_markup' => $extra_markup,
788
+            )
789
+        );
790
+
791
+    }
792
+
793
+    /**
794
+     * Displays the payment form.
795
+     *
796
+     * @since 1.0.19
797
+     */
798 798
     public function display( $extra_markup = '' ) {
799
-		wpinv_get_template(
800
-			'payment-forms/form.php',
801
-			array(
802
-				'form'         => $this,
803
-				'extra_markup' => $extra_markup,
804
-			)
805
-		);
799
+        wpinv_get_template(
800
+            'payment-forms/form.php',
801
+            array(
802
+                'form'         => $this,
803
+                'extra_markup' => $extra_markup,
804
+            )
805
+        );
806 806
     }
807 807
 
808 808
 }
Please login to merge, or discard this patch.
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -72,28 +72,28 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74 74
 	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
75
+	public function __construct($form = 0) {
76
+		parent::__construct($form);
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+		if (is_numeric($form) && $form > 0) {
79
+			$this->set_id($form);
80
+		} elseif ($form instanceof self) {
81 81
 
82
-			$this->set_id( $form->get_id() );
82
+			$this->set_id($form->get_id());
83 83
 			$this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
85
+		} elseif (!empty($form->ID)) {
86
+			$this->set_id($form->ID);
87 87
 		} else {
88
-			$this->set_object_read( true );
88
+			$this->set_object_read(true);
89 89
 		}
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
93 93
 
94
-		if ( $this->get_id() > 0 ) {
95
-            $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
94
+		if ($this->get_id() > 0) {
95
+            $this->post = get_post($this->get_id());
96
+			$this->data_store->read($this);
97 97
         }
98 98
 
99 99
 	}
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 * @param  string $context View or edit context.
121 121
 	 * @return string
122 122
 	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
123
+	public function get_version($context = 'view') {
124
+		return $this->get_prop('version', $context);
125 125
     }
126 126
 
127 127
     /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param  string $context View or edit context.
132 132
 	 * @return string
133 133
 	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
134
+	public function get_date_created($context = 'view') {
135
+		return $this->get_prop('date_created', $context);
136 136
     }
137 137
 
138 138
     /**
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @param  string $context View or edit context.
143 143
 	 * @return string
144 144
 	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
146
-        $date = $this->get_date_created( $context );
145
+	public function get_date_created_gmt($context = 'view') {
146
+        $date = $this->get_date_created($context);
147 147
 
148
-        if ( $date ) {
149
-            $date = get_gmt_from_date( $date );
148
+        if ($date) {
149
+            $date = get_gmt_from_date($date);
150 150
         }
151 151
 		return $date;
152 152
     }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param  string $context View or edit context.
159 159
 	 * @return string
160 160
 	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
161
+	public function get_date_modified($context = 'view') {
162
+		return $this->get_prop('date_modified', $context);
163 163
     }
164 164
 
165 165
     /**
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @param  string $context View or edit context.
170 170
 	 * @return string
171 171
 	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
173
-        $date = $this->get_date_modified( $context );
172
+	public function get_date_modified_gmt($context = 'view') {
173
+        $date = $this->get_date_modified($context);
174 174
 
175
-        if ( $date ) {
176
-            $date = get_gmt_from_date( $date );
175
+        if ($date) {
176
+            $date = get_gmt_from_date($date);
177 177
         }
178 178
 		return $date;
179 179
     }
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	 * @param  string $context View or edit context.
186 186
 	 * @return string
187 187
 	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
188
+	public function get_name($context = 'view') {
189
+		return $this->get_prop('name', $context);
190 190
     }
191 191
 
192 192
     /**
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 * @param  string $context View or edit context.
197 197
 	 * @return string
198 198
 	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
199
+	public function get_title($context = 'view') {
200
+		return $this->get_name($context);
201 201
 	}
202 202
 
203 203
     /**
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @param  string $context View or edit context.
208 208
 	 * @return int
209 209
 	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
210
+	public function get_author($context = 'view') {
211
+		return (int) $this->get_prop('author', $context);
212 212
     }
213 213
 
214 214
     /**
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
 	 * @param  string $context View or edit context.
219 219
 	 * @return array
220 220
 	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
221
+	public function get_elements($context = 'view') {
222
+		$elements = $this->get_prop('elements', $context);
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
225
-            return wpinv_get_data( 'sample-payment-form' );
224
+		if (empty($elements) || !is_array($elements)) {
225
+            return wpinv_get_data('sample-payment-form');
226 226
 		}
227 227
 
228 228
 		// Ensure that all required elements exist.
229 229
 		$_elements = array();
230
-		foreach ( $elements as $element ) {
230
+		foreach ($elements as $element) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+			if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) {
233 233
 
234 234
 				$_elements[] = array(
235
-					'text'    => __( 'Select Payment Method', 'invoicing' ),
235
+					'text'    => __('Select Payment Method', 'invoicing'),
236 236
 					'id'      => 'gtscicd',
237 237
 					'name'    => 'gtscicd',
238 238
 					'type'    => 'gateway_select',
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $return objects or arrays.
258 258
 	 * @return GetPaid_Form_Item[]
259 259
 	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
260
+	public function get_items($context = 'view', $return = 'objects') {
261
+		$items = $this->get_prop('items', $context);
262 262
 
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
264
-            $items = wpinv_get_data( 'sample-payment-form-items' );
263
+		if (empty($items) || !is_array($items)) {
264
+            $items = wpinv_get_data('sample-payment-form-items');
265 265
 		}
266 266
 
267 267
 		// Convert the items.
268 268
 		$prepared = array();
269 269
 
270
-		foreach ( $items as $key => $value ) {
270
+		foreach ($items as $key => $value) {
271 271
 
272 272
 			// Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
273
+			if ($value instanceof GetPaid_Form_Item) {
274 274
 
275
-				if ( $value->can_purchase() ) {
275
+				if ($value->can_purchase()) {
276 276
 					$prepared[] = $value;
277 277
 				}
278 278
 
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			// $item_id => $quantity (buy buttons)
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
284
+			if (is_numeric($key) && is_numeric($value)) {
285
+				$item = new GetPaid_Form_Item($key);
286 286
 
287
-				if ( $item->can_purchase() ) {
287
+				if ($item->can_purchase()) {
288 288
 
289 289
 					$value = (float) $value;
290
-					$item->set_quantity( $value );
291
-					if ( 0 == $value ) {
292
-						$item->set_quantity( 1 );
293
-						$item->set_allow_quantities( true );
290
+					$item->set_quantity($value);
291
+					if (0 == $value) {
292
+						$item->set_quantity(1);
293
+						$item->set_allow_quantities(true);
294 294
 					}
295 295
 
296 296
 					$prepared[] = $item;
@@ -300,33 +300,33 @@  discard block
 block discarded – undo
300 300
 			}
301 301
 
302 302
 			// Items saved via payment forms editor.
303
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
303
+			if (is_array($value) && isset($value['id'])) {
304 304
 
305
-				$item = new GetPaid_Form_Item( $value['id'] );
305
+				$item = new GetPaid_Form_Item($value['id']);
306 306
 
307
-				if ( ! $item->can_purchase() ) {
307
+				if (!$item->can_purchase()) {
308 308
 					continue;
309 309
 				}
310 310
 
311 311
 				// Sub-total (Cart items).
312
-				if ( isset( $value['subtotal'] ) ) {
313
-					$item->set_price( $value['subtotal'] );
312
+				if (isset($value['subtotal'])) {
313
+					$item->set_price($value['subtotal']);
314 314
 				}
315 315
 
316
-				if ( isset( $value['quantity'] ) ) {
317
-					$item->set_quantity( $value['quantity'] );
316
+				if (isset($value['quantity'])) {
317
+					$item->set_quantity($value['quantity']);
318 318
 				}
319 319
 
320
-				if ( isset( $value['allow_quantities'] ) ) {
321
-					$item->set_allow_quantities( $value['allow_quantities'] );
320
+				if (isset($value['allow_quantities'])) {
321
+					$item->set_allow_quantities($value['allow_quantities']);
322 322
 				}
323 323
 
324
-				if ( isset( $value['required'] ) ) {
325
-					$item->set_is_required( $value['required'] );
324
+				if (isset($value['required'])) {
325
+					$item->set_is_required($value['required']);
326 326
 				}
327 327
 
328
-				if ( isset( $value['description'] ) ) {
329
-					$item->set_custom_description( $value['description'] );
328
+				if (isset($value['description'])) {
329
+					$item->set_custom_description($value['description']);
330 330
 				}
331 331
 
332 332
 				$prepared[] = $item;
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 			}
336 336
 
337 337
 			// $item_id => array( 'price' => 10 ) (item variations)
338
-			if ( is_numeric( $key ) && is_array( $value ) ) {
339
-				$item = new GetPaid_Form_Item( $key );
338
+			if (is_numeric($key) && is_array($value)) {
339
+				$item = new GetPaid_Form_Item($key);
340 340
 
341
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
342
-					$item->set_price( $value['price'] );
341
+				if (isset($value['price']) && $item->user_can_set_their_price()) {
342
+					$item->set_price($value['price']);
343 343
 				}
344 344
 
345
-				if ( $item->can_purchase() ) {
345
+				if ($item->can_purchase()) {
346 346
 					$prepared[] = $item;
347 347
 				}
348 348
 
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 			}
351 351
 		}
352 352
 
353
-		if ( 'objects' == $return && 'view' == $context ) {
353
+		if ('objects' == $return && 'view' == $context) {
354 354
 			return $prepared;
355 355
 		}
356 356
 
357 357
 		$items = array();
358
-		foreach ( $prepared as $item ) {
358
+		foreach ($prepared as $item) {
359 359
 			$items[] = $item->prepare_data_for_use();
360 360
 		}
361 361
 
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
 	 * @param  int $item_id The item id to return.
370 370
 	 * @return GetPaid_Form_Item|bool
371 371
 	 */
372
-	public function get_item( $item_id ) {
372
+	public function get_item($item_id) {
373 373
 
374
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
374
+		if (empty($item_id) || !is_numeric($item_id)) {
375 375
 			return false;
376 376
 		}
377 377
 
378
-		foreach ( $this->get_items() as $item ) {
379
-			if ( $item->get_id() == (int) $item_id ) {
378
+		foreach ($this->get_items() as $item) {
379
+			if ($item->get_id() == (int) $item_id) {
380 380
 				return $item;
381 381
 			}
382 382
 		}
@@ -392,15 +392,15 @@  discard block
 block discarded – undo
392 392
 	 * @param  string $element_type The element type to return.
393 393
 	 * @return array|bool
394 394
 	 */
395
-	public function get_element_type( $element_type ) {
395
+	public function get_element_type($element_type) {
396 396
 
397
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
397
+		if (empty($element_type) || !is_scalar($element_type)) {
398 398
 			return false;
399 399
 		}
400 400
 
401
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
401
+		foreach ($this->get_prop('elements') as $element) {
402 402
 
403
-			if ( $element['type'] === $element_type ) {
403
+			if ($element['type'] === $element_type) {
404 404
 				return $element;
405 405
 			}
406 406
 		}
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $context View or edit context.
417 417
 	 * @return float
418 418
 	 */
419
-	public function get_earned( $context = 'view' ) {
420
-		return $this->get_prop( 'earned', $context );
419
+	public function get_earned($context = 'view') {
420
+		return $this->get_prop('earned', $context);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @param  string $context View or edit context.
428 428
 	 * @return float
429 429
 	 */
430
-	public function get_refunded( $context = 'view' ) {
431
-		return $this->get_prop( 'refunded', $context );
430
+	public function get_refunded($context = 'view') {
431
+		return $this->get_prop('refunded', $context);
432 432
 	}
433 433
 
434 434
 	/**
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 * @param  string $context View or edit context.
439 439
 	 * @return float
440 440
 	 */
441
-	public function get_cancelled( $context = 'view' ) {
442
-		return $this->get_prop( 'cancelled', $context );
441
+	public function get_cancelled($context = 'view') {
442
+		return $this->get_prop('cancelled', $context);
443 443
 	}
444 444
 
445 445
 	/**
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @param  string $context View or edit context.
450 450
 	 * @return float
451 451
 	 */
452
-	public function get_failed( $context = 'view' ) {
453
-		return $this->get_prop( 'failed', $context );
452
+	public function get_failed($context = 'view') {
453
+		return $this->get_prop('failed', $context);
454 454
 	}
455 455
 
456 456
 	/**
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	 * @return string
462 462
 	 */
463 463
 	public function get_currency() {
464
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
465
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
464
+		$currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency();
465
+		return apply_filters('getpaid-payment-form-currency', $currency, $this);
466 466
 	}
467 467
 
468 468
     /*
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @since 1.0.19
482 482
 	 */
483
-	public function set_version( $value ) {
484
-		$this->set_prop( 'version', $value );
483
+	public function set_version($value) {
484
+		$this->set_prop('version', $value);
485 485
     }
486 486
 
487 487
     /**
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	 * @param string $value Value to set.
492 492
      * @return bool Whether or not the date was set.
493 493
 	 */
494
-	public function set_date_created( $value ) {
495
-        $date = strtotime( $value );
494
+	public function set_date_created($value) {
495
+        $date = strtotime($value);
496 496
 
497
-        if ( $date ) {
498
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
497
+        if ($date) {
498
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
499 499
             return true;
500 500
         }
501 501
 
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 	 * @param string $value Value to set.
511 511
      * @return bool Whether or not the date was set.
512 512
 	 */
513
-	public function set_date_modified( $value ) {
514
-        $date = strtotime( $value );
513
+	public function set_date_modified($value) {
514
+        $date = strtotime($value);
515 515
 
516
-        if ( $date ) {
517
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
516
+        if ($date) {
517
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
518 518
             return true;
519 519
         }
520 520
 
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 	 * @since 1.0.19
529 529
 	 * @param  string $value New name.
530 530
 	 */
531
-	public function set_name( $value ) {
532
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
531
+	public function set_name($value) {
532
+		$this->set_prop('name', sanitize_text_field($value));
533 533
     }
534 534
 
535 535
     /**
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * @since 1.0.19
539 539
 	 * @param  string $value New name.
540 540
 	 */
541
-	public function set_title( $value ) {
542
-		$this->set_name( $value );
541
+	public function set_title($value) {
542
+		$this->set_name($value);
543 543
     }
544 544
 
545 545
     /**
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 	 * @since 1.0.19
549 549
 	 * @param  int $value New author.
550 550
 	 */
551
-	public function set_author( $value ) {
552
-		$this->set_prop( 'author', (int) $value );
551
+	public function set_author($value) {
552
+		$this->set_prop('author', (int) $value);
553 553
 	}
554 554
 
555 555
 	/**
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 	 * @sinve 2.3.4 Array values sanitized.
560 560
 	 * @param  array $value Form elements.
561 561
 	 */
562
-	public function set_elements( $value ) {
563
-		if ( is_array( $value ) ) {
564
-			$this->set_prop( 'elements', wp_kses_post_deep( $value ) );
562
+	public function set_elements($value) {
563
+		if (is_array($value)) {
564
+			$this->set_prop('elements', wp_kses_post_deep($value));
565 565
 		}
566 566
 	}
567 567
 
@@ -572,36 +572,36 @@  discard block
 block discarded – undo
572 572
 	 *
573 573
 	 * @return mixed
574 574
 	 */
575
-	public function sanitize_array_values( $value ) {
575
+	public function sanitize_array_values($value) {
576 576
 
577 577
 		// sanitize
578
-		if ( ! empty( $value ) ) {
578
+		if (!empty($value)) {
579 579
 
580
-			foreach ( $value as $key => $val_arr ) {
580
+			foreach ($value as $key => $val_arr) {
581 581
 
582
-				if ( is_array( $val_arr ) ) {
582
+				if (is_array($val_arr)) {
583 583
 					// check if we have sub array items.
584 584
 					$sub_arr = array();
585
-					foreach ( $val_arr as $key2 => $val2 ) {
586
-						if ( is_array( $val2 ) ) {
587
-							$sub_arr[ $key2 ] = $this->sanitize_array_values( $val2 );
588
-							unset( $val_arr[ $key ][ $key2 ] );
585
+					foreach ($val_arr as $key2 => $val2) {
586
+						if (is_array($val2)) {
587
+							$sub_arr[$key2] = $this->sanitize_array_values($val2);
588
+							unset($val_arr[$key][$key2]);
589 589
 						}
590 590
 					}
591 591
 
592 592
 					// we allow some html in description so we sanitize it separately.
593
-					$help_text = ! empty( $val_arr['description'] ) ? wp_kses_post( $val_arr['description'] ) : '';
593
+					$help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : '';
594 594
 
595 595
 					// sanitize array elements
596
-					$value[ $key ] = array_map( 'sanitize_text_field', $val_arr );
596
+					$value[$key] = array_map('sanitize_text_field', $val_arr);
597 597
 
598 598
 					// add back the description if set
599
-					if ( isset( $val_arr['description'] ) ) {
600
-$value[ $key ]['description'] = $help_text;}
599
+					if (isset($val_arr['description'])) {
600
+$value[$key]['description'] = $help_text; }
601 601
 
602 602
 					// add back sub array items after its been sanitized.
603
-					if ( ! empty( $sub_arr ) ) {
604
-						$value[ $key ] = array_merge( $value[ $key ], $sub_arr );
603
+					if (!empty($sub_arr)) {
604
+						$value[$key] = array_merge($value[$key], $sub_arr);
605 605
 					}
606 606
 				}
607 607
 }
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
 	 * @since 1.0.19
617 617
 	 * @param  array $value Form elements.
618 618
 	 */
619
-	public function set_items( $value ) {
620
-		if ( is_array( $value ) ) {
621
-			$this->set_prop( 'items', $value );
619
+	public function set_items($value) {
620
+		if (is_array($value)) {
621
+			$this->set_prop('items', $value);
622 622
 		}
623 623
 	}
624 624
 
@@ -628,9 +628,9 @@  discard block
 block discarded – undo
628 628
 	 * @since 1.0.19
629 629
 	 * @param  float $value Amount earned.
630 630
 	 */
631
-	public function set_earned( $value ) {
632
-		$value = max( (float) $value, 0 );
633
-		$this->set_prop( 'earned', $value );
631
+	public function set_earned($value) {
632
+		$value = max((float) $value, 0);
633
+		$this->set_prop('earned', $value);
634 634
 	}
635 635
 
636 636
 	/**
@@ -639,9 +639,9 @@  discard block
 block discarded – undo
639 639
 	 * @since 1.0.19
640 640
 	 * @param  float $value Amount refunded.
641 641
 	 */
642
-	public function set_refunded( $value ) {
643
-		$value = max( (float) $value, 0 );
644
-		$this->set_prop( 'refunded', $value );
642
+	public function set_refunded($value) {
643
+		$value = max((float) $value, 0);
644
+		$this->set_prop('refunded', $value);
645 645
 	}
646 646
 
647 647
 	/**
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 	 * @since 1.0.19
651 651
 	 * @param  float $value Amount cancelled.
652 652
 	 */
653
-	public function set_cancelled( $value ) {
654
-		$value = max( (float) $value, 0 );
655
-		$this->set_prop( 'cancelled', $value );
653
+	public function set_cancelled($value) {
654
+		$value = max((float) $value, 0);
655
+		$this->set_prop('cancelled', $value);
656 656
 	}
657 657
 
658 658
 	/**
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 	 * @since 1.0.19
662 662
 	 * @param  float $value Amount cancelled.
663 663
 	 */
664
-	public function set_failed( $value ) {
665
-		$value = max( (float) $value, 0 );
666
-		$this->set_prop( 'failed', $value );
664
+	public function set_failed($value) {
665
+		$value = max((float) $value, 0);
666
+		$this->set_prop('failed', $value);
667 667
 	}
668 668
 
669 669
     /**
@@ -672,11 +672,11 @@  discard block
 block discarded – undo
672 672
      * @deprecated
673 673
 	 * @return int item id
674 674
      */
675
-    public function create( $data = array() ) {
675
+    public function create($data = array()) {
676 676
 
677 677
 		// Set the properties.
678
-		if ( is_array( $data ) ) {
679
-			$this->set_props( $data );
678
+		if (is_array($data)) {
679
+			$this->set_props($data);
680 680
 		}
681 681
 
682 682
 		// Save the item.
@@ -690,8 +690,8 @@  discard block
 block discarded – undo
690 690
      * @deprecated
691 691
 	 * @return int item id
692 692
      */
693
-    public function update( $data = array() ) {
694
-        return $this->create( $data );
693
+    public function update($data = array()) {
694
+        return $this->create($data);
695 695
     }
696 696
 
697 697
     /*
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 */
712 712
     public function is_default() {
713 713
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
714
-        return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
714
+        return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this);
715 715
 	}
716 716
 
717 717
     /**
@@ -723,11 +723,11 @@  discard block
 block discarded – undo
723 723
     public function is_active() {
724 724
         $is_active = 0 !== (int) $this->get_id();
725 725
 
726
-        if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) {
726
+        if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') {
727 727
             $is_active = false;
728 728
         }
729 729
 
730
-        return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
730
+        return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this);
731 731
 	}
732 732
 
733 733
 	/**
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 	 * @since 1.0.19
737 737
 	 * @return bool
738 738
 	 */
739
-    public function has_item( $item_id ) {
740
-        return false !== $this->get_item( $item_id );
739
+    public function has_item($item_id) {
740
+        return false !== $this->get_item($item_id);
741 741
 	}
742 742
 
743 743
 	/**
@@ -746,8 +746,8 @@  discard block
 block discarded – undo
746 746
 	 * @since 1.0.19
747 747
 	 * @return bool
748 748
 	 */
749
-    public function has_element_type( $element_type ) {
750
-        return false !== $this->get_element_type( $element_type );
749
+    public function has_element_type($element_type) {
750
+        return false !== $this->get_element_type($element_type);
751 751
 	}
752 752
 
753 753
 	/**
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
 	 */
759 759
     public function is_recurring() {
760 760
 
761
-		if ( ! empty( $this->invoice ) ) {
761
+		if (!empty($this->invoice)) {
762 762
 			return $this->invoice->is_recurring();
763 763
 		}
764 764
 
765
-		foreach ( $this->get_items() as $item ) {
765
+		foreach ($this->get_items() as $item) {
766 766
 
767
-			if ( $item->is_recurring() ) {
767
+			if ($item->is_recurring()) {
768 768
 				return true;
769 769
 			}
770 770
 }
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	 *
778 778
 	 * @since 1.0.19
779 779
 	 */
780
-    public function get_html( $extra_markup = '' ) {
780
+    public function get_html($extra_markup = '') {
781 781
 
782 782
 		// Return the HTML.
783 783
 		return wpinv_get_template_html(
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	 *
796 796
 	 * @since 1.0.19
797 797
 	 */
798
-    public function display( $extra_markup = '' ) {
798
+    public function display($extra_markup = '') {
799 799
 		wpinv_get_template(
800 800
 			'payment-forms/form.php',
801 801
 			array(
Please login to merge, or discard this patch.