Passed
Push — master ( 9525b5...c4c78b )
by Brian
05:18
created
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 1 patch
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway IPN handler class.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param GetPaid_Paypal_Gateway $gateway
33 33
 	 */
34
-	public function __construct( $gateway ) {
34
+	public function __construct($gateway) {
35 35
 		$this->gateway = $gateway;
36 36
 		$this->verify_ipn();
37 37
 	}
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function verify_ipn() {
45 45
 
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler', false);
47 47
 
48 48
 		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
49
+		if (empty($_POST) || !$this->validate_ipn()) {
50
+			wp_die('PayPal IPN Request Failure', 500);
51 51
 		}
52 52
 
53 53
 		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
54
+		$posted  = wp_unslash($_POST);
55
+		$invoice = $this->get_ipn_invoice($posted);
56 56
 
57 57
 		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
58
+		if ($this->id != $invoice->get_gateway()) {
59
+			wpinv_error_log('Aborting, Invoice was not paid via PayPal', false);
60
+			wp_die('Invoice not paid via PayPal', 200);
61 61
 		}
62 62
 
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
63
+		$posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : '';
64
+		$posted['txn_type']       = sanitize_key(strtolower($posted['txn_type']));
65 65
 
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status'], false);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type'], false);
68 68
 
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
69
+		if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
70
+			call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
71
+			wpinv_error_log('Done processing IPN', false);
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false);
76
+		wp_die('Unsupported IPN type', 200);
77 77
 
78 78
 	}
79 79
 
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
 	 * @param array $posted
84 84
 	 * @return WPInv_Invoice
85 85
 	 */
86
-	protected function get_ipn_invoice( $posted ) {
86
+	protected function get_ipn_invoice($posted) {
87 87
 
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice', false);
89 89
 
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
90
+		if (!empty($posted['custom'])) {
91
+			$invoice = new WPInv_Invoice($posted['custom']);
92 92
 
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number(), false);
95 95
 				return $invoice;
96 96
 			}
97 97
 		}
98 98
 
99
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
99
+		wpinv_error_log('Could not retrieve the associated invoice.', false);
100
+		wp_die('Could not retrieve the associated invoice.', 200);
101 101
 	}
102 102
 
103 103
 	/**
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function validate_ipn() {
107 107
 
108
-		wpinv_error_log( 'Validating PayPal IPN response', false );
108
+		wpinv_error_log('Validating PayPal IPN response', false);
109 109
 
110 110
 		// Retrieve the associated invoice.
111
-		$posted  = wp_unslash( $_POST );
112
-		$invoice = $this->get_ipn_invoice( $posted );
111
+		$posted  = wp_unslash($_POST);
112
+		$invoice = $this->get_ipn_invoice($posted);
113 113
 
114
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
115
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
114
+		if ($this->gateway->is_sandbox($invoice)) {
115
+			wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data', false);
116 116
 		}
117 117
 
118 118
 		// Validate the IPN.
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 		);
130 130
 
131 131
 		// Post back to get a response.
132
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
132
+		$response = wp_safe_remote_post($this->gateway->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
133 133
 
134 134
 		// Check to see if the request was valid.
135
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
135
+		if (!is_wp_error($response) && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
136
+			wpinv_error_log('Received valid response from PayPal IPN: ' . $response['body'], false);
137 137
 			return true;
138 138
 		}
139 139
 
140
-		if ( is_wp_error( $response ) ) {
141
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
140
+		if (is_wp_error($response)) {
141
+			wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN');
142 142
 			return false;
143 143
 		}
144 144
 
145
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
145
+		wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN');
146 146
 		return false;
147 147
 
148 148
 	}
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 	 * @param WPInv_Invoice $invoice          Invoice object.
154 154
 	 * @param string   $currency currency to validate.
155 155
 	 */
156
-	protected function validate_ipn_currency( $invoice, $currency ) {
156
+	protected function validate_ipn_currency($invoice, $currency) {
157 157
 
158
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
158
+		if (strtolower($invoice->get_currency()) !== strtolower($currency)) {
159 159
 
160 160
 			/* translators: %s: currency code. */
161
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
161
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency));
162 162
 
163
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
163
+			wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true);
164 164
 		}
165 165
 
166
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
166
+		wpinv_error_log($currency, 'Validated IPN Currency', false);
167 167
 	}
168 168
 
169 169
 	/**
@@ -172,16 +172,16 @@  discard block
 block discarded – undo
172 172
 	 * @param WPInv_Invoice $invoice          Invoice object.
173 173
 	 * @param float   $amount amount to validate.
174 174
 	 */
175
-	protected function validate_ipn_amount( $invoice, $amount ) {
176
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
175
+	protected function validate_ipn_amount($invoice, $amount) {
176
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
177 177
 
178 178
 			/* translators: %s: Amount. */
179
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
179
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount));
180 180
 
181
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
181
+			wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true);
182 182
 		}
183 183
 
184
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
184
+		wpinv_error_log($amount, 'Validated IPN Amount', false);
185 185
 	}
186 186
 
187 187
 	/**
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 	 * @param WPInv_Invoice $invoice          Invoice object.
191 191
 	 * @param string   $receiver_email Email to validate.
192 192
 	 */
193
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
194
-		$paypal_email = wpinv_get_option( 'paypal_email' );
193
+	protected function validate_ipn_receiver_email($invoice, $receiver_email) {
194
+		$paypal_email = wpinv_get_option('paypal_email');
195 195
 
196
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
197
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
196
+		if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) {
197
+			wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}");
198 198
 
199 199
 			/* translators: %s: email address . */
200
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
200
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email));
201 201
 
202
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
202
+			return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true);
203 203
 		}
204 204
 
205
-		wpinv_error_log( 'Validated PayPal Email', false );
205
+		wpinv_error_log('Validated PayPal Email', false);
206 206
 	}
207 207
 
208 208
 	/**
@@ -211,70 +211,70 @@  discard block
 block discarded – undo
211 211
 	 * @param WPInv_Invoice $invoice  Invoice object.
212 212
 	 * @param array    $posted Posted data.
213 213
 	 */
214
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
214
+	protected function ipn_txn_web_accept($invoice, $posted) {
215 215
 
216 216
 		// Collect payment details
217
-		$payment_status = strtolower( $posted['payment_status'] );
218
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
217
+		$payment_status = strtolower($posted['payment_status']);
218
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
219 219
 
220
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
221
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
220
+		$this->validate_ipn_receiver_email($invoice, $business_email);
221
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
222 222
 
223 223
 		// Update the transaction id.
224
-		if ( ! empty( $posted['txn_id'] ) ) {
225
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
224
+		if (!empty($posted['txn_id'])) {
225
+			$invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
226 226
 			$invoice->save();
227 227
 		}
228 228
 
229
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
229
+		$invoice->add_system_note(__('Processing invoice IPN', 'invoicing'));
230 230
 
231 231
 		// Process a refund.
232
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
232
+		if ($payment_status == 'refunded' || $payment_status == 'reversed') {
233 233
 
234
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
234
+			update_post_meta($invoice->get_id(), 'refunded_remotely', 1);
235 235
 
236
-			if ( ! $invoice->is_refunded() ) {
237
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
236
+			if (!$invoice->is_refunded()) {
237
+				$invoice->update_status('wpi-refunded', $posted['reason_code']);
238 238
 			}
239 239
 
240
-			return wpinv_error_log( $posted['reason_code'], false );
240
+			return wpinv_error_log($posted['reason_code'], false);
241 241
 		}
242 242
 
243 243
 		// Process payments.
244
-		if ( $payment_status == 'completed' ) {
244
+		if ($payment_status == 'completed') {
245 245
 
246
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
247
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
246
+			if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
247
+				return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false);
248 248
 			}
249 249
 
250
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
250
+			$this->validate_ipn_amount($invoice, $posted['mc_gross']);
251 251
 
252 252
 			$note = '';
253 253
 
254
-			if ( ! empty( $posted['mc_fee'] ) ) {
255
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
254
+			if (!empty($posted['mc_fee'])) {
255
+				$note = sprintf(__('PayPal Transaction Fee %s.', 'invoicing'), sanitize_text_field($posted['mc_fee']));
256 256
 			}
257 257
 
258
-			if ( ! empty( $posted['payer_status'] ) ) {
259
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
258
+			if (!empty($posted['payer_status'])) {
259
+				$note = ' ' . sprintf(__('Buyer status %s.', 'invoicing'), sanitize_text_field($posted['payer_status']));
260 260
 			}
261 261
 
262
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
263
-			return wpinv_error_log( 'Invoice marked as paid.', false );
262
+			$invoice->mark_paid((!empty($posted['txn_id']) ? sanitize_text_field($posted['txn_id']) : ''), trim($note));
263
+			return wpinv_error_log('Invoice marked as paid.', false);
264 264
 
265 265
 		}
266 266
 
267 267
 		// Pending payments.
268
-		if ( $payment_status == 'pending' ) {
268
+		if ($payment_status == 'pending') {
269 269
 
270 270
 			/* translators: %s: pending reason. */
271
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
271
+			$invoice->update_status('wpi-onhold', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason']));
272 272
 
273
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
273
+			return wpinv_error_log('Invoice marked as "payment held".', false);
274 274
 		}
275 275
 
276 276
 		/* translators: %s: payment status. */
277
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
277
+		$invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), sanitize_text_field($posted['payment_status'])));
278 278
 
279 279
 	}
280 280
 
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	 * @param WPInv_Invoice $invoice  Invoice object.
285 285
 	 * @param array    $posted Posted data.
286 286
 	 */
287
-	protected function ipn_txn_cart( $invoice, $posted ) {
288
-		$this->ipn_txn_web_accept( $invoice, $posted );
287
+	protected function ipn_txn_cart($invoice, $posted) {
288
+		$this->ipn_txn_web_accept($invoice, $posted);
289 289
 	}
290 290
 
291 291
 	/**
@@ -294,43 +294,43 @@  discard block
 block discarded – undo
294 294
 	 * @param WPInv_Invoice $invoice  Invoice object.
295 295
 	 * @param array    $posted Posted data.
296 296
 	 */
297
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
297
+	protected function ipn_txn_subscr_signup($invoice, $posted) {
298 298
 
299
-		wpinv_error_log( 'Processing subscription signup', false );
299
+		wpinv_error_log('Processing subscription signup', false);
300 300
 
301 301
 		// Make sure the invoice has a subscription.
302
-		$subscription = getpaid_get_invoice_subscription( $invoice );
302
+		$subscription = getpaid_get_invoice_subscription($invoice);
303 303
 
304
-		if ( empty( $subscription ) ) {
305
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
304
+		if (empty($subscription)) {
305
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
306 306
 		}
307 307
 
308
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
308
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
309 309
 
310 310
 		// Validate the IPN.
311
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
312
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
313
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
311
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
312
+		$this->validate_ipn_receiver_email($invoice, $business_email);
313
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
314 314
 
315 315
 		// Activate the subscription.
316
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
317
-		$subscription->set_date_created( current_time( 'mysql' ) );
318
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
319
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
316
+		$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
317
+		$subscription->set_date_created(current_time('mysql'));
318
+		$subscription->set_expiration(date('Y-m-d H:i:s', (current_time('timestamp') + $duration)));
319
+		$subscription->set_profile_id(sanitize_text_field($posted['subscr_id']));
320 320
 		$subscription->activate();
321 321
 
322 322
 		// Set the transaction id.
323
-		if ( ! empty( $posted['txn_id'] ) ) {
324
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
325
-			$invoice->set_transaction_id( $posted['txn_id'] );
323
+		if (!empty($posted['txn_id'])) {
324
+			$invoice->add_note(sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
325
+			$invoice->set_transaction_id($posted['txn_id']);
326 326
 		}
327 327
 
328 328
 		// Update the payment status.
329 329
 		$invoice->mark_paid();
330 330
 
331
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
331
+		$invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
332 332
 
333
-		wpinv_error_log( 'Subscription started.', false );
333
+		wpinv_error_log('Subscription started.', false);
334 334
 	}
335 335
 
336 336
 	/**
@@ -339,45 +339,45 @@  discard block
 block discarded – undo
339 339
 	 * @param WPInv_Invoice $invoice  Invoice object.
340 340
 	 * @param array    $posted Posted data.
341 341
 	 */
342
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
342
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
343 343
 
344 344
 		// Make sure the invoice has a subscription.
345
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
345
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
346 346
 
347
-		if ( empty( $subscription ) ) {
348
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
347
+		if (empty($subscription)) {
348
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
349 349
 		}
350 350
 
351
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
351
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
352 352
 
353 353
 		// PayPal sends a subscr_payment for the first payment too.
354
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
355
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
356
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
357
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
358
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
359
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
354
+		$date_completed = getpaid_format_date($invoice->get_date_completed());
355
+		$date_created   = getpaid_format_date($invoice->get_date_created());
356
+		$today_date     = getpaid_format_date(current_time('mysql'));
357
+		$payment_date   = getpaid_format_date($posted['payment_date']);
358
+		$subscribe_date = getpaid_format_date($subscription->get_date_created());
359
+		$dates          = array_filter(compact('date_completed', 'date_created', 'subscribe_date'));
360 360
 
361
-		foreach ( $dates as $date ) {
361
+		foreach ($dates as $date) {
362 362
 
363
-			if ( $date !== $today_date && $date !== $payment_date ) {
363
+			if ($date !== $today_date && $date !== $payment_date) {
364 364
 				continue;
365 365
 			}
366 366
 
367
-			if ( ! empty( $posted['txn_id'] ) ) {
368
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
369
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
367
+			if (!empty($posted['txn_id'])) {
368
+				$invoice->set_transaction_id(sanitize_text_field($posted['txn_id']));
369
+				$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), sanitize_text_field($posted['txn_id'])), false, false, true);
370 370
 			}
371 371
 
372 372
 			return $invoice->mark_paid();
373 373
 
374 374
 		}
375 375
 
376
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
376
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false);
377 377
 
378 378
 		// Abort if the payment is already recorded.
379
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
380
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
379
+		if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
380
+			return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false);
381 381
 		}
382 382
 
383 383
 		$args = array(
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 			'gateway'        => $this->id,
386 386
 		);
387 387
 
388
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
388
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
389 389
 
390
-		if ( empty( $invoice ) ) {
390
+		if (empty($invoice)) {
391 391
 			return;
392 392
 		}
393 393
 
394
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
394
+		$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
395
+		$invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
396 396
 
397 397
 		$subscription->renew();
398
-		wpinv_error_log( 'Subscription renewed.', false );
398
+		wpinv_error_log('Subscription renewed.', false);
399 399
 
400 400
 	}
401 401
 
@@ -404,18 +404,18 @@  discard block
 block discarded – undo
404 404
 	 *
405 405
 	 * @param WPInv_Invoice $invoice  Invoice object.
406 406
 	 */
407
-	protected function ipn_txn_subscr_cancel( $invoice ) {
407
+	protected function ipn_txn_subscr_cancel($invoice) {
408 408
 
409 409
 		// Make sure the invoice has a subscription.
410
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
410
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
411 411
 
412
-		if ( empty( $subscription ) ) {
413
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
412
+		if (empty($subscription)) {
413
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
414 414
 		}
415 415
 
416
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
416
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false);
417 417
 		$subscription->cancel();
418
-		wpinv_error_log( 'Subscription cancelled.', false );
418
+		wpinv_error_log('Subscription cancelled.', false);
419 419
 
420 420
 	}
421 421
 
@@ -425,18 +425,18 @@  discard block
 block discarded – undo
425 425
 	 * @param WPInv_Invoice $invoice  Invoice object.
426 426
 	 * @param array    $posted Posted data.
427 427
 	 */
428
-	protected function ipn_txn_subscr_eot( $invoice ) {
428
+	protected function ipn_txn_subscr_eot($invoice) {
429 429
 
430 430
 		// Make sure the invoice has a subscription.
431
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
431
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
432 432
 
433
-		if ( empty( $subscription ) ) {
434
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
433
+		if (empty($subscription)) {
434
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
435 435
 		}
436 436
 
437
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
437
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false);
438 438
 		$subscription->complete();
439
-		wpinv_error_log( 'Subscription completed.', false );
439
+		wpinv_error_log('Subscription completed.', false);
440 440
 
441 441
 	}
442 442
 
@@ -446,18 +446,18 @@  discard block
 block discarded – undo
446 446
 	 * @param WPInv_Invoice $invoice  Invoice object.
447 447
 	 * @param array    $posted Posted data.
448 448
 	 */
449
-	protected function ipn_txn_subscr_failed( $invoice ) {
449
+	protected function ipn_txn_subscr_failed($invoice) {
450 450
 
451 451
 		// Make sure the invoice has a subscription.
452
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
452
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
453 453
 
454
-		if ( empty( $subscription ) ) {
455
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
454
+		if (empty($subscription)) {
455
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
456 456
 		}
457 457
 
458
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
458
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false);
459 459
 		$subscription->failing();
460
-		wpinv_error_log( 'Subscription marked as failing.', false );
460
+		wpinv_error_log('Subscription marked as failing.', false);
461 461
 
462 462
 	}
463 463
 
@@ -467,18 +467,18 @@  discard block
 block discarded – undo
467 467
 	 * @param WPInv_Invoice $invoice  Invoice object.
468 468
 	 * @param array    $posted Posted data.
469 469
 	 */
470
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
470
+	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment($invoice) {
471 471
 
472 472
 		// Make sure the invoice has a subscription.
473
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
473
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
474 474
 
475
-		if ( empty( $subscription ) ) {
476
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
475
+		if (empty($subscription)) {
476
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
477 477
 		}
478 478
 
479
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
479
+		wpinv_error_log('Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false);
480 480
 		$subscription->cancel();
481
-		wpinv_error_log( 'Subscription cancelled.', false );
481
+		wpinv_error_log('Subscription cancelled.', false);
482 482
 	}
483 483
 
484 484
 }
Please login to merge, or discard this patch.
includes/subscription-functions.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
  * @return      WPInv_Subscription[]|WPInv_Subscription|false
14 14
  * @since       2.3.0
15 15
  */
16
-function getpaid_get_invoice_subscriptions( $invoice ) {
16
+function getpaid_get_invoice_subscriptions($invoice) {
17 17
 
18 18
     // Retrieve subscription groups.
19
-    $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' );
19
+    $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id');
20 20
 
21 21
     // No subscription groups, normal subscription.
22
-    if ( empty( $subscription_ids ) ) {
23
-        return getpaid_subscriptions()->get_invoice_subscription( $invoice );
22
+    if (empty($subscription_ids)) {
23
+        return getpaid_subscriptions()->get_invoice_subscription($invoice);
24 24
     }
25 25
 
26 26
     // Subscription groups.
27
-    return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) );
27
+    return array_filter(array_map('getpaid_get_subscription', $subscription_ids));
28 28
 
29 29
 }
30 30
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  * @return      array
36 36
  * @since       2.3.0
37 37
  */
38
-function getpaid_get_invoice_subscription_groups( $invoice_id ) {
39
-    $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true );
40
-    return empty( $subscription_groups ) ? array() : $subscription_groups;
38
+function getpaid_get_invoice_subscription_groups($invoice_id) {
39
+    $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true);
40
+    return empty($subscription_groups) ? array() : $subscription_groups;
41 41
 }
42 42
 
43 43
 /**
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
  * @return      array|false
49 49
  * @since       2.3.0
50 50
  */
51
-function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52
-    $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54
-    return reset( $matching_group );
51
+function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) {
52
+    $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id);
53
+	$matching_group = wp_list_filter($subscription_groups, compact('subscription_id'));
54
+    return reset($matching_group);
55 55
 }
56 56
 
57 57
 /**
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
  * @since       2.3.0
62 62
  * @return WPInv_Subscription|false
63 63
  */
64
-function getpaid_get_subscription( $subscription ) {
64
+function getpaid_get_subscription($subscription) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
66
+	if (!is_a($subscription, 'WPInv_Subscription')) {
67
+		$subscription = new WPInv_Subscription($subscription);
68 68
 	}
69 69
 
70 70
 	return $subscription->exists() ? $subscription : false;
@@ -79,26 +79,26 @@  discard block
 block discarded – undo
79 79
  *
80 80
  * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query
81 81
  */
82
-function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
82
+function getpaid_get_subscriptions($args = array(), $return = 'results') {
83 83
 
84 84
 	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
85
+	if ('count' == $return) {
86 86
 		$args['fields'] = 'id';
87 87
 		$args['number'] = 1;
88 88
 	}
89 89
 
90 90
 	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
91
+	if ('results' == $return) {
92 92
 		$args['count_total'] = false;
93 93
 	}
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+	$query = new GetPaid_Subscriptions_Query($args);
96 96
 
97
-	if ( 'results' == $return ) {
97
+	if ('results' == $return) {
98 98
 		return $query->get_results();
99 99
 	}
100 100
 
101
-	if ( 'count' == $return ) {
101
+	if ('count' == $return) {
102 102
 		return $query->get_total();
103 103
 	}
104 104
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	return apply_filters(
116 116
 		'getpaid_get_subscription_statuses',
117 117
 		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
118
+			'pending'   => __('Pending', 'invoicing'),
119
+			'trialling' => __('Trialing', 'invoicing'),
120
+			'active'    => __('Active', 'invoicing'),
121
+			'failing'   => __('Failing', 'invoicing'),
122
+			'expired'   => __('Expired', 'invoicing'),
123
+			'completed' => __('Complete', 'invoicing'),
124
+			'cancelled' => __('Cancelled', 'invoicing'),
125 125
 		)
126 126
 	);
127 127
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return string
134 134
  */
135
-function getpaid_get_subscription_status_label( $status ) {
135
+function getpaid_get_subscription_status_label($status) {
136 136
 	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
137
+	return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status));
138 138
 }
139 139
 
140 140
 /**
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return array
166 166
  */
167
-function getpaid_get_subscription_status_counts( $args = array() ) {
167
+function getpaid_get_subscription_status_counts($args = array()) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
169
+	$statuses = array_keys(getpaid_get_subscription_statuses());
170 170
 	$counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
172
+	foreach ($statuses as $status) {
173
+		$_args             = wp_parse_args("status=$status", $args);
174
+		$counts[$status] = getpaid_get_subscriptions($_args, 'count');
175 175
 	}
176 176
 
177 177
 	return $counts;
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 		array(
191 191
 
192 192
 			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
193
+				'singular' => __('%s day', 'invoicing'),
194
+				'plural'   => __('%d days', 'invoicing'),
195 195
 			),
196 196
 
197 197
 			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
198
+				'singular' => __('%s week', 'invoicing'),
199
+				'plural'   => __('%d weeks', 'invoicing'),
200 200
 			),
201 201
 
202 202
 			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
203
+				'singular' => __('%s month', 'invoicing'),
204
+				'plural'   => __('%d months', 'invoicing'),
205 205
 			),
206 206
 
207 207
 			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
208
+				'singular' => __('%s year', 'invoicing'),
209
+				'plural'   => __('%d years', 'invoicing'),
210 210
 			),
211 211
 
212 212
 		)
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
  * @param string $trial_period
221 221
  * @return int
222 222
  */
223
-function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
223
+function getpaid_get_subscription_trial_period_interval($trial_period) {
224
+	return (int) preg_replace('/[^0-9]/', '', $trial_period);
225 225
 }
226 226
 
227 227
 /**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
  * @param string $trial_period
231 231
  * @return string
232 232
  */
233
-function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
233
+function getpaid_get_subscription_trial_period_period($trial_period) {
234
+	return preg_replace('/[^a-z]/', '', strtolower($trial_period));
235 235
 }
236 236
 
237 237
 /**
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
  * @param int $interval
242 242
  * @return string
243 243
  */
244
-function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
244
+function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') {
245
+	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix);
246
+	return strtolower(sanitize_text_field($label));
247 247
 }
248 248
 
249 249
 /**
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
  * @param string $period
253 253
  * @return string
254 254
  */
255
-function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
255
+function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') {
256 256
 
257 257
 	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
258
+	$period  = strtolower($period);
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
260
+	if (isset($periods[$period])) {
261
+		return sprintf($periods[$period]['singular'], $singular_prefix);
262 262
 	}
263 263
 
264 264
 	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
265
+	foreach ($periods as $key => $data) {
266
+		if (strpos($key, $period) === 0) {
267
+			return sprintf($data['singular'], $singular_prefix);
268 268
 		}
269 269
 	}
270 270
 
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
  * @param int $interval
280 280
  * @return string
281 281
  */
282
-function getpaid_get_plural_subscription_period_label( $period, $interval ) {
282
+function getpaid_get_plural_subscription_period_label($period, $interval) {
283 283
 
284 284
 	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
285
+	$period  = strtolower($period);
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
287
+	if (isset($periods[$period])) {
288
+		return sprintf($periods[$period]['plural'], $interval);
289 289
 	}
290 290
 
291 291
 	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
292
+	foreach ($periods as $key => $data) {
293
+		if (strpos($key, $period) === 0) {
294
+			return sprintf($data['plural'], $interval);
295 295
 		}
296 296
 	}
297 297
 
@@ -305,33 +305,33 @@  discard block
 block discarded – undo
305 305
  * @param WPInv_Subscription $subscription
306 306
  * @return string
307 307
  */
308
-function getpaid_get_formatted_subscription_amount( $subscription ) {
308
+function getpaid_get_formatted_subscription_amount($subscription) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
310
+	$initial    = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
311
+	$recurring  = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency());
312
+	$period     = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
313 313
 	$bill_times = $subscription->get_bill_times();
314 314
 	$bill_times_less = $bill_times - 1;
315 315
 
316
-	if ( ! empty( $bill_times ) ) {
316
+	if (!empty($bill_times)) {
317 317
 		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_frequency(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
318
+		$bill_times_less = getpaid_get_subscription_period_label($subscription->get_frequency(), $bill_times - $subscription->get_frequency());
319
+		$bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times);
320 320
 	}
321 321
 
322 322
 	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
323
+	if ($subscription->has_trial_period()) {
324 324
 
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
325
+		$trial_period   = getpaid_get_subscription_trial_period_period($subscription->get_trial_period());
326
+		$trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period());
327 327
 
328
-		if ( empty( $bill_times ) ) {
328
+		if (empty($bill_times)) {
329 329
 
330 330
 			return sprintf(
331 331
 				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
332
+				_x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'),
333 333
 				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
334
+				getpaid_get_subscription_period_label($trial_period, $trial_interval),
335 335
 				$recurring,
336 336
 				$period
337 337
 			);
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 
341 341
 		return sprintf(
342 342
 			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
343
+			_x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'),
344 344
 			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
345
+			getpaid_get_subscription_period_label($trial_period, $trial_interval),
346 346
 			$recurring,
347 347
 			$period,
348 348
 			$bill_times
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 
351 351
 	}
352 352
 
353
-	if ( $initial != $recurring ) {
353
+	if ($initial != $recurring) {
354 354
 
355
-		if ( empty( $bill_times ) ) {
355
+		if (empty($bill_times)) {
356 356
 
357 357
 			return sprintf(
358 358
 				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
359
+				_x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'),
360 360
 				$initial,
361 361
 				$recurring,
362 362
 				$period
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
 		return sprintf(
368 368
 			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
369
+			_x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'),
370 370
 			$initial,
371 371
 			$recurring,
372 372
 			$period,
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 
376 376
 	}
377 377
 
378
-	if ( empty( $bill_times ) ) {
378
+	if (empty($bill_times)) {
379 379
 
380 380
 		return sprintf(
381 381
 			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
382
+			_x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'),
383 383
 			$initial,
384 384
 			$period
385 385
 		);
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
 	return sprintf(
390 390
 		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
391
+		_x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
392 392
 		$bill_times,
393 393
 		$initial,
394 394
 		$period
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
  * @param WPInv_Invoice $invoice
403 403
  * @return WPInv_Subscription|false
404 404
  */
405
-function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
405
+function getpaid_get_invoice_subscription($invoice) {
406
+	return getpaid_subscriptions()->get_invoice_subscription($invoice);
407 407
 }
408 408
 
409 409
 /**
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414
-function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
414
+function getpaid_activate_invoice_subscription($invoice) {
415
+	$subscription = getpaid_get_invoice_subscription($invoice);
416
+	if (is_a($subscription, 'WPInv_Subscription')) {
417 417
 		$subscription->activate();
418 418
 	}
419 419
 }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+	return getpaid()->get('subscriptions');
428 428
 }
429 429
 
430 430
 /**
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
  * @since 2.3.0
434 434
  * @return WPInv_Subscription|bool
435 435
  */
436
-function wpinv_get_invoice_subscription( $invoice ) {
436
+function wpinv_get_invoice_subscription($invoice) {
437 437
 
438 438
     // Retrieve the invoice.
439
-    $invoice = new WPInv_Invoice( $invoice );
439
+    $invoice = new WPInv_Invoice($invoice);
440 440
 
441 441
     // Ensure it is a recurring invoice.
442
-    if ( ! $invoice->is_recurring() ) {
442
+    if (!$invoice->is_recurring()) {
443 443
         return false;
444 444
     }
445 445
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		)
452 452
 	);
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+	return empty($subscription) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -466,50 +466,50 @@  discard block
 block discarded – undo
466 466
  * @param GetPaid_Form_Item|WPInv_Item $cart_item
467 467
  * @return string
468 468
  */
469
-function getpaid_get_recurring_item_key( $cart_item ) {
469
+function getpaid_get_recurring_item_key($cart_item) {
470 470
 
471 471
 	$cart_key     = 'renews_';
472 472
 	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
473
+	$period       = $cart_item->get_recurring_period(true);
474 474
 	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
475
+	$trial_period = $cart_item->get_trial_period(true);
476 476
 	$trial_length = $cart_item->get_trial_interval();
477 477
 
478 478
 	// First start with the billing interval and period
479
-	switch ( $interval ) {
479
+	switch ($interval) {
480 480
 		case 1:
481
-			if ( 'day' == $period ) {
481
+			if ('day' == $period) {
482 482
 				$cart_key .= 'daily';
483 483
 			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
484
+				$cart_key .= sprintf('%sly', $period);
485 485
 			}
486 486
 			break;
487 487
 		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
488
+			$cart_key .= sprintf('every_2nd_%s', $period);
489 489
 			break;
490 490
 		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
491
+			$cart_key .= sprintf('every_3rd_%s', $period);
492 492
 		    break;
493 493
 		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
494
+			$cart_key .= sprintf('every_%dth_%s', $interval, $period);
495 495
 			break;
496 496
 	}
497 497
 
498 498
 	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
499
+	if ($length > 0) {
500 500
 		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
501
+		$cart_key .= sprintf('%d_%s', $length, $period);
502
+		if ($length > 1) {
503 503
 			$cart_key .= 's';
504 504
 		}
505 505
 	}
506 506
 
507 507
 	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
508
+	if ($cart_item->has_free_trial()) {
509
+		$cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period);
510 510
 	}
511 511
 
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
512
+	return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item);
513 513
 }
514 514
 
515 515
 /**
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
519 519
  * @return array
520 520
  */
521
-function getpaid_get_subscription_groups( $invoice ) {
521
+function getpaid_get_subscription_groups($invoice) {
522 522
 
523 523
 	// Generate subscription groups.
524 524
 	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
525
+	foreach ($invoice->get_items() as $item) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
527
+		if ($item->is_recurring()) {
528
+			$subscription_groups[getpaid_get_recurring_item_key($item)][] = $item;
529 529
 		}
530 530
 }
531 531
 
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
542 542
  * @return array
543 543
  */
544
-function getpaid_calculate_subscription_totals( $invoice ) {
544
+function getpaid_calculate_subscription_totals($invoice) {
545 545
 
546 546
 	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
547
+	$subscription_groups = getpaid_get_subscription_groups($invoice);
548 548
 
549 549
 	// Now let's calculate the totals for each group of subscriptions
550 550
 	$subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+	foreach ($subscription_groups as $subscription_key => $items) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+		if (empty($subscription_totals[$subscription_key])) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
556
+			$subscription_totals[$subscription_key] = array(
557 557
 				'initial_total'   => 0,
558 558
 				'recurring_total' => 0,
559 559
 				'items'           => array(),
@@ -566,33 +566,33 @@  discard block
 block discarded – undo
566 566
 		 * Get the totals of the group.
567 567
 		 * @var GetPaid_Form_Item $item
568 568
 		 */
569
-		foreach ( $items as $item ) {
569
+		foreach ($items as $item) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+			$subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving();
572
+			$subscription_totals[$subscription_key]['item_id']                 = $item->get_id();
573
+			$subscription_totals[$subscription_key]['period']                  = $item->get_recurring_period(true);
574
+			$subscription_totals[$subscription_key]['interval']                = $item->get_recurring_interval();
575
+			$subscription_totals[$subscription_key]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+			$subscription_totals[$subscription_key]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+			$subscription_totals[$subscription_key]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579 579
 			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
580
+			$period       = $item->get_recurring_period(true);
581 581
 			$interval     = $item->get_recurring_interval();
582 582
 
583 583
 			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
584
+			if ($item->has_free_trial()) {
585
+				$period   = $item->get_trial_period(true);
586 586
 				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
587
+				$subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period;
588 588
 			}
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+			$subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp')));
591 591
 
592 592
 		}
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+	return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice);
596 596
 }
597 597
 
598 598
 /**
@@ -601,18 +601,18 @@  discard block
 block discarded – undo
601 601
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
602 602
  * @return array
603 603
  */
604
-function getpaid_should_group_subscriptions( $invoice ) {
604
+function getpaid_should_group_subscriptions($invoice) {
605 605
 
606 606
 	$recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+	foreach ($invoice->get_items() as $item) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
610
+		if ($item->is_recurring()) {
611
+			$recurring_items++;
612 612
 		}
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+	return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice);
616 616
 }
617 617
 
618 618
 /**
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
  * @param int|false $subscription_id
623 623
  * @return int
624 624
  */
625
-function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
625
+function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) {
626 626
 	global $wpdb;
627 627
 
628 628
 	$parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+	if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) {
631 631
 
632 632
 		return (int) $wpdb->get_var(
633 633
 			$wpdb->prepare(
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
 
650 650
 	$count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+	foreach (wp_parse_id_list($invoice_ids) as $invoice_id) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
654
+		if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) {
655
+			$count++;
656 656
 			continue;
657 657
 		}
658 658
 }
Please login to merge, or discard this patch.
templates/payment-forms/elements/billing_email.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 $value = $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 40
         'value'            => $value,
41 41
         'class'            => 'wpinv_billing_email getpaid-refresh-on-change',
@@ -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.
templates/payment-forms/elements/date.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,63 +7,63 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label       = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14
-if ( ! empty( $required ) ) {
12
+$label       = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14
+if (!empty($required)) {
15 15
 	$label .= "<span class='text-danger'> *</span>";
16 16
 }
17 17
 
18 18
 $disable_dates = array();
19 19
 
20
-if ( ! empty( $disabled_dates ) ) {
21
-	$disabled_dates = preg_replace( '/\s+/', '', $disabled_dates );
22
-	$disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates );
23
-	$disabled_dates = array_filter( explode( ',', $disabled_dates ) );
20
+if (!empty($disabled_dates)) {
21
+	$disabled_dates = preg_replace('/\s+/', '', $disabled_dates);
22
+	$disabled_dates = str_ireplace('today', current_time('Y-m-d'), $disabled_dates);
23
+	$disabled_dates = array_filter(explode(',', $disabled_dates));
24 24
 
25
-	foreach ( $disabled_dates as $disabled_date ) {
25
+	foreach ($disabled_dates as $disabled_date) {
26 26
 
27
-		$disabled_date = trim( $disabled_date );
27
+		$disabled_date = trim($disabled_date);
28 28
 
29
-		if ( false === strpos( $disabled_date, '|' ) ) {
29
+		if (false === strpos($disabled_date, '|')) {
30 30
 			$disable_dates[] = $disabled_date;
31 31
 			continue;
32 32
 		}
33 33
 
34
-		$disabled_date   = explode( '|', $disabled_date );
34
+		$disabled_date   = explode('|', $disabled_date);
35 35
 		$disable_dates[] = array(
36
-			'from' => trim( $disabled_date[0] ),
37
-			'to'   => trim( $disabled_date[1] ),
36
+			'from' => trim($disabled_date[0]),
37
+			'to'   => trim($disabled_date[1]),
38 38
 		);
39 39
 
40 40
 	}
41 41
 }
42 42
 
43 43
 $options = array(
44
-	'data-default-date'     => empty( $default_date ) ? false : $default_date,
45
-	'data-min-date'         => empty( $min_date ) ? false : $min_date,
46
-	'data-max-date'         => empty( $max_date ) ? false : $max_date,
47
-	'data-mode'             => empty( $mode ) ? 'single' : $mode,
48
-	'data-alt-format'       => get_option( 'date_format', 'F j, Y' ),
44
+	'data-default-date'     => empty($default_date) ? false : $default_date,
45
+	'data-min-date'         => empty($min_date) ? false : $min_date,
46
+	'data-max-date'         => empty($max_date) ? false : $max_date,
47
+	'data-mode'             => empty($mode) ? 'single' : $mode,
48
+	'data-alt-format'       => get_option('date_format', 'F j, Y'),
49 49
 	'data-date-format'      => 'Y-m-d',
50 50
 	'data-alt-input'        => 'true',
51
-	'data-disable_alt'      => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ),
52
-	'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ),
51
+	'data-disable_alt'      => empty($disabled_dates) ? false : wp_json_encode($disable_dates),
52
+	'data-disable_days_alt' => empty($disable_days) ? false : wp_json_encode(wp_parse_id_list($disable_days)),
53 53
 );
54 54
 
55 55
 aui()->input(
56 56
 	array(
57
-		'name'             => esc_attr( $id ),
58
-		'id'               => esc_attr( $element_id ),
59
-		'placeholder'      => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
60
-		'required'         => ! empty( $required ),
57
+		'name'             => esc_attr($id),
58
+		'id'               => esc_attr($element_id),
59
+		'placeholder'      => empty($placeholder) ? '' : esc_attr($placeholder),
60
+		'required'         => !empty($required),
61 61
 		'label'            => $label,
62 62
 		'label_type'       => 'vertical',
63
-		'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
63
+		'help_text'        => empty($description) ? '' : wp_kses_post($description),
64 64
 		'type'             => 'datepicker',
65 65
 		'class'            => $label_class . ' getpaid-init-flatpickr flatpickr-input',
66
-		'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ),
66
+		'extra_attributes' => array_filter(apply_filters('getpaid_date_field_attributes', $options)),
67 67
 		'value'            => $query_value,
68 68
 	),
69 69
 	true
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.0.2
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * The main installer/updater class.
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param string $upgrade_from The current invoicing version.
27 27
 	 */
28
-	public function upgrade_db( $upgrade_from ) {
28
+	public function upgrade_db($upgrade_from) {
29 29
 
30 30
 		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
31
+		update_option('wpinv_version', WPINV_VERSION);
32 32
 
33 33
 		// Setup the invoice Custom Post Type.
34 34
 		GetPaid_Post_Types::register_post_types();
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		// Create any missing database tables.
49 49
 		$method = "upgrade_from_$upgrade_from";
50 50
 
51
-		$installed = get_option( 'gepaid_installed_on' );
51
+		$installed = get_option('gepaid_installed_on');
52 52
 
53
-		if ( empty( $installed ) ) {
54
-			update_option( 'gepaid_installed_on', time() );
53
+		if (empty($installed)) {
54
+			update_option('gepaid_installed_on', time());
55 55
 		}
56 56
 
57
-		if ( method_exists( $this, $method ) ) {
57
+		if (method_exists($this, $method)) {
58 58
 			$this->$method();
59 59
 		}
60 60
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		$this->create_invoice_items_table();
71 71
 
72 72
 		// Save default tax rates.
73
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
73
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
74 74
 	}
75 75
 
76 76
 	/**
@@ -81,27 +81,27 @@  discard block
 block discarded – undo
81 81
 		global $wpdb;
82 82
 
83 83
 		// Invoices.
84
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
-		if ( ! empty( $results ) ) {
86
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
84
+		$results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
85
+		if (!empty($results)) {
86
+			$wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
87 87
 
88 88
 			// Clean post cache
89
-			foreach ( $results as $row ) {
90
-				clean_post_cache( $row->ID );
89
+			foreach ($results as $row) {
90
+				clean_post_cache($row->ID);
91 91
 			}
92 92
 		}
93 93
 
94 94
 		// Item meta key changes
95 95
 		$query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
96
-		$results = $wpdb->get_results( $query );
96
+		$results = $wpdb->get_results($query);
97 97
 
98
-		if ( ! empty( $results ) ) {
99
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
98
+		if (!empty($results)) {
99
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
100
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
101
+			$wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
102 102
 
103
-			foreach ( $results as $row ) {
104
-				clean_post_cache( $row->post_id );
103
+			foreach ($results as $row) {
104
+				clean_post_cache($row->post_id);
105 105
 			}
106 106
 		}
107 107
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function upgrade_from_207() {
135 135
 		global $wpdb;
136
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
136
+		$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);");
137 137
 		$this->upgrade_from_2615();
138 138
 	}
139 139
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function upgrade_from_2615() {
145 145
 		global $wpdb;
146
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';" );
147
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';" );
146
+		$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';");
147
+		$wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';");
148 148
 	}
149 149
 
150 150
 	/**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 */
154 154
 	public function add_capabilities() {
155
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
155
+		$GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing');
156 156
 	}
157 157
 
158 158
 	/**
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 
168 168
 				// Checkout page.
169 169
 				'checkout_page'             => array(
170
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
171
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
170
+					'name'    => _x('gp-checkout', 'Page slug', 'invoicing'),
171
+					'title'   => _x('Checkout', 'Page title', 'invoicing'),
172 172
 					'content' => '
173 173
 						<!-- wp:shortcode -->
174 174
 						[wpinv_checkout]
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 
180 180
 				// Invoice history page.
181 181
 				'invoice_history_page'      => array(
182
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
183
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
182
+					'name'    => _x('gp-invoices', 'Page slug', 'invoicing'),
183
+					'title'   => _x('My Invoices', 'Page title', 'invoicing'),
184 184
 					'content' => '
185 185
 					<!-- wp:shortcode -->
186 186
 					[wpinv_history]
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 
192 192
 				// Success page content.
193 193
 				'success_page'              => array(
194
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
195
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
194
+					'name'    => _x('gp-receipt', 'Page slug', 'invoicing'),
195
+					'title'   => _x('Payment Confirmation', 'Page title', 'invoicing'),
196 196
 					'content' => '
197 197
 					<!-- wp:shortcode -->
198 198
 					[wpinv_receipt]
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
 
204 204
 				// Failure page content.
205 205
 				'failure_page'              => array(
206
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
207
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
208
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
206
+					'name'    => _x('gp-transaction-failed', 'Page slug', 'invoicing'),
207
+					'title'   => _x('Transaction Failed', 'Page title', 'invoicing'),
208
+					'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
209 209
 					'parent'  => 'gp-checkout',
210 210
 				),
211 211
 
212 212
 				// Subscriptions history page.
213 213
 				'invoice_subscription_page' => array(
214
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
215
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
214
+					'name'    => _x('gp-subscriptions', 'Page slug', 'invoicing'),
215
+					'title'   => _x('My Subscriptions', 'Page title', 'invoicing'),
216 216
 					'content' => '
217 217
 					<!-- wp:shortcode -->
218 218
 					[wpinv_subscriptions]
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	public function create_pages() {
234 234
 
235
-		foreach ( self::get_pages() as $key => $page ) {
236
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
235
+		foreach (self::get_pages() as $key => $page) {
236
+			wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']);
237 237
 		}
238 238
 
239 239
 	}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			KEY customer_and_status (customer_id, status)
274 274
 		  ) $charset_collate;";
275 275
 
276
-		dbDelta( $sql );
276
+		dbDelta($sql);
277 277
 
278 278
 	}
279 279
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			KEY `key` (`key`)
325 325
 		  ) $charset_collate;";
326 326
 
327
-		dbDelta( $sql );
327
+		dbDelta($sql);
328 328
 
329 329
 	}
330 330
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 			KEY post_id (post_id)
362 362
 		  ) $charset_collate;";
363 363
 
364
-		dbDelta( $sql );
364
+		dbDelta($sql);
365 365
 
366 366
 	}
367 367
 
@@ -374,32 +374,32 @@  discard block
 block discarded – undo
374 374
 
375 375
 		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
376 376
 		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
377
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
377
+		$migrated            = $wpdb->get_col("SELECT post_id FROM $invoices_table");
378 378
 		$invoices            = array_unique(
379 379
 			get_posts(
380 380
 				array(
381
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
381
+					'post_type'      => array('wpi_invoice', 'wpi_quote'),
382 382
 					'posts_per_page' => -1,
383 383
 					'fields'         => 'ids',
384
-					'post_status'    => array_keys( get_post_stati() ),
384
+					'post_status'    => array_keys(get_post_stati()),
385 385
 					'exclude'        => (array) $migrated,
386 386
 				)
387 387
 			)
388 388
 		);
389 389
 
390 390
 		// Abort if we do not have any invoices.
391
-		if ( empty( $invoices ) ) {
391
+		if (empty($invoices)) {
392 392
 			return;
393 393
 		}
394 394
 
395 395
 		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
396 396
 
397 397
 		$invoice_rows = array();
398
-		foreach ( $invoices as $invoice ) {
398
+		foreach ($invoices as $invoice) {
399 399
 
400
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
400
+			$invoice = new WPInv_Legacy_Invoice($invoice);
401 401
 
402
-			if ( empty( $invoice->ID ) ) {
402
+			if (empty($invoice->ID)) {
403 403
 				return;
404 404
 			}
405 405
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 				'post_id'            => $invoice->ID,
408 408
 				'number'             => $invoice->get_number(),
409 409
 				'key'                => $invoice->get_key(),
410
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
410
+				'type'               => str_replace('wpi_', '', $invoice->post_type),
411 411
 				'mode'               => $invoice->mode,
412 412
 				'user_ip'            => $invoice->get_ip(),
413 413
 				'first_name'         => $invoice->get_first_name(),
@@ -436,27 +436,27 @@  discard block
 block discarded – undo
436 436
 				'custom_meta'        => $invoice->payment_meta,
437 437
 			);
438 438
 
439
-			foreach ( $fields as $key => $val ) {
440
-				if ( is_null( $val ) ) {
439
+			foreach ($fields as $key => $val) {
440
+				if (is_null($val)) {
441 441
 					$val = '';
442 442
 				}
443
-				$val = maybe_serialize( $val );
444
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
443
+				$val = maybe_serialize($val);
444
+				$fields[$key] = $wpdb->prepare('%s', $val);
445 445
 			}
446 446
 
447
-			$fields = implode( ', ', $fields );
447
+			$fields = implode(', ', $fields);
448 448
 			$invoice_rows[] = "($fields)";
449 449
 
450 450
 			$item_rows    = array();
451 451
 			$item_columns = array();
452
-			foreach ( $invoice->get_cart_details() as $details ) {
452
+			foreach ($invoice->get_cart_details() as $details) {
453 453
 				$fields = array(
454 454
 					'post_id'          => $invoice->ID,
455 455
 					'item_id'          => $details['id'],
456 456
 					'item_name'        => $details['name'],
457
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
457
+					'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
458 458
 					'vat_rate'         => $details['vat_rate'],
459
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
459
+					'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
460 460
 					'tax'              => $details['tax'],
461 461
 					'item_price'       => $details['item_price'],
462 462
 					'custom_price'     => $details['custom_price'],
@@ -468,31 +468,31 @@  discard block
 block discarded – undo
468 468
 					'fees'             => $details['fees'],
469 469
 				);
470 470
 
471
-				$item_columns = array_keys( $fields );
471
+				$item_columns = array_keys($fields);
472 472
 
473
-				foreach ( $fields as $key => $val ) {
474
-					if ( is_null( $val ) ) {
473
+				foreach ($fields as $key => $val) {
474
+					if (is_null($val)) {
475 475
 						$val = '';
476 476
 					}
477
-					$val = maybe_serialize( $val );
478
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
477
+					$val = maybe_serialize($val);
478
+					$fields[$key] = $wpdb->prepare('%s', $val);
479 479
 				}
480 480
 
481
-				$fields = implode( ', ', $fields );
481
+				$fields = implode(', ', $fields);
482 482
 				$item_rows[] = "($fields)";
483 483
 			}
484 484
 
485
-			$item_rows    = implode( ', ', $item_rows );
486
-			$item_columns = implode( ', ', $item_columns );
487
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
485
+			$item_rows    = implode(', ', $item_rows);
486
+			$item_columns = implode(', ', $item_columns);
487
+			$wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
488 488
 		}
489 489
 
490
-		if ( empty( $invoice_rows ) ) {
490
+		if (empty($invoice_rows)) {
491 491
 			return;
492 492
 		}
493 493
 
494
-		$invoice_rows = implode( ', ', $invoice_rows );
495
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
494
+		$invoice_rows = implode(', ', $invoice_rows);
495
+		$wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
496 496
 
497 497
 	}
498 498
 
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
 	public static function rename_gateways_label() {
504 504
 		global $wpdb;
505 505
 
506
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
506
+		foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) {
507 507
 
508 508
 			$wpdb->update(
509 509
 				$wpdb->prefix . 'getpaid_invoices',
510
-				array( 'gateway' => $gateway ),
511
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
510
+				array('gateway' => $gateway),
511
+				array('gateway' => wpinv_get_gateway_admin_label($gateway)),
512 512
 				'%s',
513 513
 				'%s'
514 514
 			);
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Spacing   +131 added lines, -131 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
  * Retrieves an item by it's ID.
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param int the item ID to retrieve.
15 15
  * @return WPInv_Item|false
16 16
  */
17
-function wpinv_get_item_by_id( $id ) {
18
-    $item = wpinv_get_item( $id );
19
-    return empty( $item ) || $id != $item->get_id() ? false : $item;
17
+function wpinv_get_item_by_id($id) {
18
+    $item = wpinv_get_item($id);
19
+    return empty($item) || $id != $item->get_id() ? false : $item;
20 20
 }
21 21
 
22 22
 /**
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @return WPInv_Item|false
26 26
  */
27
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
27
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
28 28
 
29
-    if ( 'id' == strtolower( $field ) ) {
30
-        return wpinv_get_item_by_id( $field );
29
+    if ('id' == strtolower($field)) {
30
+        return wpinv_get_item_by_id($field);
31 31
     }
32 32
 
33
-    $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type );
34
-    return empty( $id ) ? false : wpinv_get_item( $id );
33
+    $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type);
34
+    return empty($id) ? false : wpinv_get_item($id);
35 35
 
36 36
 }
37 37
 
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
  * @param int|WPInv_Item the item to retrieve.
42 42
  * @return WPInv_Item|false
43 43
  */
44
-function wpinv_get_item( $item = 0 ) {
44
+function wpinv_get_item($item = 0) {
45 45
 
46
-    if ( empty( $item ) ) {
46
+    if (empty($item)) {
47 47
         return false;
48 48
     }
49 49
 
50
-    $item = new WPInv_Item( $item );
50
+    $item = new WPInv_Item($item);
51 51
     return $item->exists() ? $item : false;
52 52
 
53 53
 }
54 54
 
55
-function wpinv_get_all_items( $args = array() ) {
55
+function wpinv_get_all_items($args = array()) {
56 56
 
57 57
     $args = wp_parse_args(
58 58
         $args,
59 59
         array(
60
-			'status'     => array( 'publish' ),
61
-			'limit'      => get_option( 'posts_per_page' ),
60
+			'status'     => array('publish'),
61
+			'limit'      => get_option('posts_per_page'),
62 62
 			'page'       => 1,
63 63
 			'exclude'    => array(),
64 64
 			'orderby'    => 'date',
@@ -78,44 +78,44 @@  discard block
 block discarded – undo
78 78
         'fields'         => 'ids',
79 79
         'orderby'        => $args['orderby'],
80 80
         'order'          => $args['order'],
81
-        'paged'          => absint( $args['page'] ),
81
+        'paged'          => absint($args['page']),
82 82
     );
83 83
 
84
-    if ( ! empty( $args['exclude'] ) ) {
85
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
84
+    if (!empty($args['exclude'])) {
85
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
86 86
     }
87 87
 
88
-    if ( ! $args['paginate'] ) {
88
+    if (!$args['paginate']) {
89 89
         $wp_query_args['no_found_rows'] = true;
90 90
     }
91 91
 
92
-    if ( ! empty( $args['search'] ) ) {
92
+    if (!empty($args['search'])) {
93 93
         $wp_query_args['s'] = $args['search'];
94 94
     }
95 95
 
96
-    if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) {
97
-        $types = wpinv_parse_list( $args['type'] );
96
+    if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) {
97
+        $types = wpinv_parse_list($args['type']);
98 98
         $wp_query_args['meta_query'][] = array(
99 99
             'key'     => '_wpinv_type',
100
-            'value'   => implode( ',', $types ),
100
+            'value'   => implode(',', $types),
101 101
             'compare' => 'IN',
102 102
         );
103 103
     }
104 104
 
105
-    $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args );
105
+    $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args);
106 106
 
107 107
     // Get results.
108
-    $items = new WP_Query( $wp_query_args );
108
+    $items = new WP_Query($wp_query_args);
109 109
 
110
-    if ( 'objects' === $args['return'] ) {
111
-        $return = array_map( 'wpinv_get_item_by_id', $items->posts );
112
-    } elseif ( 'self' === $args['return'] ) {
110
+    if ('objects' === $args['return']) {
111
+        $return = array_map('wpinv_get_item_by_id', $items->posts);
112
+    } elseif ('self' === $args['return']) {
113 113
         return $items;
114 114
     } else {
115 115
         $return = $items->posts;
116 116
     }
117 117
 
118
-    if ( $args['paginate'] ) {
118
+    if ($args['paginate']) {
119 119
         return (object) array(
120 120
             'items'         => $return,
121 121
             'total'         => $items->found_posts,
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 
128 128
 }
129 129
 
130
-function wpinv_is_free_item( $item_id = 0 ) {
131
-    if ( empty( $item_id ) ) {
130
+function wpinv_is_free_item($item_id = 0) {
131
+    if (empty($item_id)) {
132 132
         return false;
133 133
     }
134 134
 
135
-    $item = new WPInv_Item( $item_id );
135
+    $item = new WPInv_Item($item_id);
136 136
 
137 137
     return $item->is_free();
138 138
 }
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
  *
143 143
  * @param WP_Post|WPInv_Item|Int $item The item to check for.
144 144
  */
145
-function wpinv_item_is_editable( $item = 0 ) {
145
+function wpinv_item_is_editable($item = 0) {
146 146
 
147 147
     // Fetch the item.
148
-    $item = new WPInv_Item( $item );
148
+    $item = new WPInv_Item($item);
149 149
 
150 150
     // Check if it is editable.
151 151
     return $item->is_editable();
152 152
 }
153 153
 
154
-function wpinv_get_item_price( $item_id = 0 ) {
155
-    if ( empty( $item_id ) ) {
154
+function wpinv_get_item_price($item_id = 0) {
155
+    if (empty($item_id)) {
156 156
         return false;
157 157
     }
158 158
 
159
-    $item = new WPInv_Item( $item_id );
159
+    $item = new WPInv_Item($item_id);
160 160
 
161 161
     return $item->get_price();
162 162
 }
@@ -166,88 +166,88 @@  discard block
 block discarded – undo
166 166
  *
167 167
  * @param WPInv_Item|int $item
168 168
  */
169
-function wpinv_is_recurring_item( $item = 0 ) {
170
-    $item = new WPInv_Item( $item );
169
+function wpinv_is_recurring_item($item = 0) {
170
+    $item = new WPInv_Item($item);
171 171
     return $item->is_recurring();
172 172
 }
173 173
 
174
-function wpinv_item_price( $item_id = 0 ) {
175
-    if ( empty( $item_id ) ) {
174
+function wpinv_item_price($item_id = 0) {
175
+    if (empty($item_id)) {
176 176
         return false;
177 177
     }
178 178
 
179
-    $price = wpinv_get_item_price( $item_id );
180
-    $price = wpinv_price( $price );
179
+    $price = wpinv_get_item_price($item_id);
180
+    $price = wpinv_price($price);
181 181
 
182
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
182
+    return apply_filters('wpinv_item_price', $price, $item_id);
183 183
 }
184 184
 
185
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
186
-    if ( is_null( $amount_override ) ) {
187
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
185
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
186
+    if (is_null($amount_override)) {
187
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
188 188
     } else {
189 189
         $original_price = $amount_override;
190 190
     }
191 191
 
192 192
     $price = $original_price;
193 193
 
194
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
194
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
195 195
 }
196 196
 
197
-function wpinv_item_custom_singular_name( $item_id ) {
198
-    if ( empty( $item_id ) ) {
197
+function wpinv_item_custom_singular_name($item_id) {
198
+    if (empty($item_id)) {
199 199
         return false;
200 200
     }
201 201
 
202
-    $item = new WPInv_Item( $item_id );
202
+    $item = new WPInv_Item($item_id);
203 203
 
204 204
     return $item->get_custom_singular_name();
205 205
 }
206 206
 
207 207
 function wpinv_get_item_types() {
208 208
     $item_types = array(
209
-		'custom' => __( 'Standard', 'invoicing' ),
210
-		'fee'    => __( 'Fee', 'invoicing' ),
209
+		'custom' => __('Standard', 'invoicing'),
210
+		'fee'    => __('Fee', 'invoicing'),
211 211
 	);
212
-    return apply_filters( 'wpinv_get_item_types', $item_types );
212
+    return apply_filters('wpinv_get_item_types', $item_types);
213 213
 }
214 214
 
215 215
 function wpinv_item_types() {
216 216
     $item_types = wpinv_get_item_types();
217 217
 
218
-    return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() );
218
+    return (!empty($item_types) ? array_keys($item_types) : array());
219 219
 }
220 220
 
221
-function wpinv_get_item_type( $item_id ) {
222
-    if ( empty( $item_id ) ) {
221
+function wpinv_get_item_type($item_id) {
222
+    if (empty($item_id)) {
223 223
         return false;
224 224
     }
225 225
 
226
-    $item = new WPInv_Item( $item_id );
226
+    $item = new WPInv_Item($item_id);
227 227
 
228 228
     return $item->get_type();
229 229
 }
230 230
 
231
-function wpinv_item_type( $item_id ) {
231
+function wpinv_item_type($item_id) {
232 232
     $item_types = wpinv_get_item_types();
233 233
 
234
-    $item_type = wpinv_get_item_type( $item_id );
234
+    $item_type = wpinv_get_item_type($item_id);
235 235
 
236
-    if ( empty( $item_type ) ) {
236
+    if (empty($item_type)) {
237 237
         $item_type = '-';
238 238
     }
239 239
 
240
-    $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' );
240
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
241 241
 
242
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
242
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
243 243
 }
244 244
 
245
-function wpinv_get_random_item( $post_ids = true ) {
246
-    wpinv_get_random_items( 1, $post_ids );
245
+function wpinv_get_random_item($post_ids = true) {
246
+    wpinv_get_random_items(1, $post_ids);
247 247
 }
248 248
 
249
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
250
-    if ( $post_ids ) {
249
+function wpinv_get_random_items($num = 3, $post_ids = true) {
250
+    if ($post_ids) {
251 251
         $args = array(
252 252
 			'post_type'  => 'wpi_item',
253 253
 			'orderby'    => 'rand',
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 		);
263 263
     }
264 264
 
265
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
265
+    $args = apply_filters('wpinv_get_random_items', $args);
266 266
 
267
-    return get_posts( $args );
267
+    return get_posts($args);
268 268
 }
269 269
 
270 270
 /**
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
  * @param WPInv_Item|int $item
274 274
  * @param bool $html
275 275
  */
276
-function wpinv_get_item_suffix( $item, $html = true ) {
276
+function wpinv_get_item_suffix($item, $html = true) {
277 277
 
278
-    $item   = new WPInv_Item( $item );
279
-    $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : '';
280
-    $suffix = $html ? $suffix : wp_strip_all_tags( $suffix );
278
+    $item   = new WPInv_Item($item);
279
+    $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : '';
280
+    $suffix = $html ? $suffix : wp_strip_all_tags($suffix);
281 281
 
282
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
282
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
283 283
 }
284 284
 
285 285
 /**
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
  * @param WPInv_Item|int $item
289 289
  * @param bool $force_delete
290 290
  */
291
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
292
-    $item = new WPInv_Item( $item );
293
-    $item->delete( $force_delete );
291
+function wpinv_remove_item($item = 0, $force_delete = false) {
292
+    $item = new WPInv_Item($item);
293
+    $item->delete($force_delete);
294 294
 }
295 295
 
296 296
 /**
@@ -329,44 +329,44 @@  discard block
 block discarded – undo
329 329
  * @param bool $wp_error whether or not to return a WP_Error on failure.
330 330
  * @return bool|WP_Error|WPInv_Item
331 331
  */
332
-function wpinv_create_item( $args = array(), $wp_error = false ) {
332
+function wpinv_create_item($args = array(), $wp_error = false) {
333 333
 
334 334
     // Prepare the item.
335
-    if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) {
336
-        $type = empty( $args['type'] ) ? 'custom' : $args['type'];
337
-        $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type );
335
+    if (!empty($args['custom_id']) && empty($args['ID'])) {
336
+        $type = empty($args['type']) ? 'custom' : $args['type'];
337
+        $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type);
338 338
 
339
-        if ( ! empty( $item ) ) {
339
+        if (!empty($item)) {
340 340
             $args['ID'] = $item->get_id();
341 341
         }
342 342
     }
343 343
 
344 344
     // Do we have an item?
345
-    if ( ! empty( $args['ID'] ) ) {
346
-        $item = new WPInv_Item( $args['ID'] );
345
+    if (!empty($args['ID'])) {
346
+        $item = new WPInv_Item($args['ID']);
347 347
     } else {
348 348
         $item = new WPInv_Item();
349 349
     }
350 350
 
351 351
     // Do we have an error?
352
-    if ( ! empty( $item->last_error ) ) {
353
-        return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false;
352
+    if (!empty($item->last_error)) {
353
+        return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false;
354 354
     }
355 355
 
356 356
     // Update item props.
357
-    $item->set_props( $args );
357
+    $item->set_props($args);
358 358
 
359 359
     // Save the item.
360 360
     $item->save();
361 361
 
362 362
     // Do we have an error?
363
-    if ( ! empty( $item->last_error ) ) {
364
-        return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false;
363
+    if (!empty($item->last_error)) {
364
+        return $wp_error ? new WP_Error('not_saved', $item->last_error) : false;
365 365
     }
366 366
 
367 367
     // Was the item saved?
368
-    if ( ! $item->get_id() ) {
369
-        return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false;
368
+    if (!$item->get_id()) {
369
+        return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false;
370 370
     }
371 371
 
372 372
     return $item;
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
  *
379 379
  * @see wpinv_create_item()
380 380
  */
381
-function wpinv_update_item( $args = array(), $wp_error = false ) {
382
-    return wpinv_create_item( $args, $wp_error );
381
+function wpinv_update_item($args = array(), $wp_error = false) {
382
+    return wpinv_create_item($args, $wp_error);
383 383
 }
384 384
 
385 385
 /**
386 386
  * Sanitizes a recurring period
387 387
  */
388
-function getpaid_sanitize_recurring_period( $period, $full = false ) {
388
+function getpaid_sanitize_recurring_period($period, $full = false) {
389 389
 
390 390
     $periods = array(
391 391
         'D' => 'day',
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
         'Y' => 'year',
395 395
     );
396 396
 
397
-    if ( ! isset( $periods[ $period ] ) ) {
397
+    if (!isset($periods[$period])) {
398 398
         $period = 'D';
399 399
     }
400 400
 
401
-    return $full ? $periods[ $period ] : $period;
401
+    return $full ? $periods[$period] : $period;
402 402
 
403 403
 }
404 404
 
405
-function wpinv_item_max_buyable_quantity( $item_id ) {
406
-    return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id );
405
+function wpinv_item_max_buyable_quantity($item_id) {
406
+    return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id);
407 407
 }
408 408
 
409 409
 /**
@@ -411,47 +411,47 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @param WPInv_Item|GetPaid_Form_Item $item
413 413
  */
414
-function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) {
414
+function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) {
415 415
 
416 416
     // Abort if it is not recurring.
417
-    if ( ! $item->is_recurring() ) {
417
+    if (!$item->is_recurring()) {
418 418
         return '';
419 419
     }
420 420
 
421
-    $initial_price   = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price;
422
-    $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price;
423
-    $period          = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' );
421
+    $initial_price   = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price;
422
+    $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price;
423
+    $period          = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '');
424 424
     $initial_class   = 'getpaid-item-initial-price';
425 425
     $recurring_class = 'getpaid-item-recurring-price';
426 426
     $bill_times      = $item->get_recurring_limit();
427 427
     $bill_times_less = $bill_times - 1;
428 428
 
429
-    if ( ! empty( $bill_times ) ) {
429
+    if (!empty($bill_times)) {
430 430
 		$bill_times = $item->get_recurring_interval() * $bill_times;
431
-        $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() );
432
-		$bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
431
+        $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval());
432
+		$bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times);
433 433
 	}
434 434
 
435
-    if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) {
436
-        $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
437
-        $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency );
435
+    if ($item instanceof GetPaid_Form_Item && false === $_initial_price) {
436
+        $initial_price   = wpinv_price($item->get_sub_total(), $currency);
437
+        $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency);
438 438
     }
439 439
 
440
-    if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) {
441
-        return __( 'Free forever', 'invoicing' );
440
+    if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) {
441
+        return __('Free forever', 'invoicing');
442 442
     }
443 443
 
444 444
     // For free trial items.
445
-    if ( $item->has_free_trial() ) {
446
-        $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() );
445
+    if ($item->has_free_trial()) {
446
+        $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval());
447 447
 
448
-        if ( wpinv_price( 0, $currency ) == $initial_price ) {
448
+        if (wpinv_price(0, $currency) == $initial_price) {
449 449
 
450
-            if ( empty( $bill_times ) ) {
450
+            if (empty($bill_times)) {
451 451
 
452 452
                 return sprintf(
453 453
                     // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period
454
-                    _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ),
454
+                    _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'),
455 455
                     "<span class='getpaid-item-trial-period'>$trial_period</span>",
456 456
                     "<span class='$recurring_class'>$recurring_price</span>",
457 457
                     "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
             return sprintf(
463 463
                 // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times
464
-                _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ),
464
+                _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'),
465 465
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
466 466
                 "<span class='$recurring_class'>$recurring_price</span>",
467 467
                 "<span class='getpaid-item-recurring-period'>$period</span>",
@@ -470,11 +470,11 @@  discard block
 block discarded – undo
470 470
 
471 471
         }
472 472
 
473
-        if ( empty( $bill_times ) ) {
473
+        if (empty($bill_times)) {
474 474
 
475 475
             return sprintf(
476 476
                 // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period
477
-                _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ),
477
+                _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'),
478 478
                 "<span class='$initial_class'>$initial_price</span>",
479 479
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
480 480
                 "<span class='$recurring_class'>$recurring_price</span>",
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 
486 486
         return sprintf(
487 487
             // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times
488
-            _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ),
488
+            _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'),
489 489
             "<span class='$initial_class'>$initial_price</span>",
490 490
             "<span class='getpaid-item-trial-period'>$trial_period</span>",
491 491
             "<span class='$recurring_class'>$recurring_price</span>",
@@ -495,13 +495,13 @@  discard block
 block discarded – undo
495 495
 
496 496
     }
497 497
 
498
-    if ( $initial_price == $recurring_price ) {
498
+    if ($initial_price == $recurring_price) {
499 499
 
500
-        if ( empty( $bill_times ) ) {
500
+        if (empty($bill_times)) {
501 501
 
502 502
             return sprintf(
503 503
                 // translators: $1: is the recurring price, $2: is the susbcription period
504
-                _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ),
504
+                _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'),
505 505
                 "<span class='$recurring_class'>$recurring_price</span>",
506 506
                 "<span class='getpaid-item-recurring-period'>$period</span>"
507 507
             );
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 
511 511
         return sprintf(
512 512
             // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times
513
-            _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
513
+            _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
514 514
             "<span class='$recurring_class'>$recurring_price</span>",
515 515
             "<span class='getpaid-item-recurring-period'>$period</span>",
516 516
             "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>"
@@ -518,13 +518,13 @@  discard block
 block discarded – undo
518 518
 
519 519
     }
520 520
 
521
-    if ( $initial_price == wpinv_price( 0, $currency ) ) {
521
+    if ($initial_price == wpinv_price(0, $currency)) {
522 522
 
523
-        if ( empty( $bill_times ) ) {
523
+        if (empty($bill_times)) {
524 524
 
525 525
             return sprintf(
526 526
                 // translators: $1: is the recurring period, $2: is the recurring price
527
-                _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ),
527
+                _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'),
528 528
                 "<span class='getpaid-item-recurring-period'>$period</span>",
529 529
                 "<span class='$recurring_class'>$recurring_price</span>"
530 530
             );
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
         return sprintf(
535 535
             // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times
536
-            _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ),
536
+            _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'),
537 537
             "<span class='getpaid-item-recurring-period'>$period</span>",
538 538
             "<span class='$recurring_class'>$recurring_price</span>",
539 539
             "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>"
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 
542 542
     }
543 543
 
544
-    if ( empty( $bill_times ) ) {
544
+    if (empty($bill_times)) {
545 545
 
546 546
         return sprintf(
547 547
             // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period
548
-            _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ),
548
+            _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'),
549 549
             "<span class='$initial_class'>$initial_price</span>",
550 550
             "<span class='$recurring_class'>$recurring_price</span>",
551 551
             "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
     return sprintf(
557 557
         // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times
558
-        _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ),
558
+        _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'),
559 559
         "<span class='$initial_class'>$initial_price</span>",
560 560
         "<span class='$recurring_class'>$recurring_price</span>",
561 561
         "<span class='getpaid-item-recurring-period'>$period</span>",
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 1 patch
Spacing   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input( $args = array() ) {
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'                     => 'text',
24 24
 			'name'                     => '',
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 		/**
66 66
 		 * Parse incoming $args into an array and merge it with $defaults
67 67
 		 */
68
-		$args   = wp_parse_args( $args, $defaults );
68
+		$args   = wp_parse_args($args, $defaults);
69 69
 		$output = '';
70
-		if ( ! empty( $args['type'] ) ) {
70
+		if (!empty($args['type'])) {
71 71
 			// hidden label option needs to be empty
72 72
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
73 73
 
74
-			$type = sanitize_html_class( $args['type'] );
74
+			$type = sanitize_html_class($args['type']);
75 75
 
76 76
 			$help_text   = '';
77 77
 			$label       = '';
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 			);
86 86
 
87 87
 			// floating labels need label after
88
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
88
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
89 89
 				$label_after         = true;
90 90
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
91 91
 			}
92 92
 
93 93
 			// size
94 94
 			$size = '';
95
-			if ( $args['size'] == 'lg' || $args['size'] == 'large' ) {
95
+			if ($args['size'] == 'lg' || $args['size'] == 'large') {
96 96
 				$size = 'lg';
97 97
 				$args['class'] .= ' form-control-lg';
98
-			}elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) {
98
+			}elseif ($args['size'] == 'sm' || $args['size'] == 'small') {
99 99
 				$size = 'sm';
100 100
 				$args['class'] .= ' form-control-sm';
101 101
 			}
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
 			$clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');';
105 105
 
106 106
 			// Some special sauce for files
107
-			if ( $type == 'file' ) {
107
+			if ($type == 'file') {
108 108
 				$label_after = true; // if type file we need the label after
109 109
 				$args['class'] .= ' custom-file-input ';
110
-			} elseif ( $type == 'checkbox' ) {
110
+			} elseif ($type == 'checkbox') {
111 111
 				$label_after = true; // if type file we need the label after
112 112
 				$args['class'] .= ' custom-control-input ';
113
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
113
+			} elseif ($type == 'datepicker' || $type == 'timepicker') {
114 114
 				$type = 'text';
115 115
 				$args['class'] .= ' bg-initial '; // @todo not sure why we have this?
116
-				$clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');";
116
+				$clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr($args['name']) . "\']').trigger('change');";
117 117
 
118 118
 				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
119 119
 
120 120
 				// set a way to clear field if empty
121
-				if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) {
121
+				if ($args['input_group_right'] === '' && $args['clear_icon'] !== false) {
122 122
 					$args['input_group_right_inside'] = true;
123 123
 					$args['clear_icon'] = true;
124 124
 				}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				// enqueue the script
127 127
 				$aui_settings = AyeCode_UI_Settings::instance();
128 128
 				$aui_settings->enqueue_flatpickr();
129
-			} elseif ( $type == 'iconpicker' ) {
129
+			} elseif ($type == 'iconpicker') {
130 130
 				$type = 'text';
131 131
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
132 132
 //				$args['class'] .= ' bg-initial ';
@@ -141,103 +141,103 @@  discard block
 block discarded – undo
141 141
 				$aui_settings->enqueue_iconpicker();
142 142
 			}
143 143
 
144
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
145
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
144
+			if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) {
145
+				$output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />';
146 146
 			}
147 147
 
148 148
 			// allow clear icon
149
-			if ( $args['input_group_right'] === '' && $args['clear_icon'] ) {
150
-				$font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' );
149
+			if ($args['input_group_right'] === '' && $args['clear_icon']) {
150
+				$font_size = $size == 'sm' ? '1.3' : ($size == 'lg' ? '1.65' : '1.5');
151 151
 				$args['input_group_right_inside'] = true;
152
-				$args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: '.$font_size.'rem" aria-hidden="true" class="close">&times;</span></span>';
152
+				$args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="close">&times;</span></span>';
153 153
 			}
154 154
 
155 155
 			// open/type
156 156
 			$output .= '<input type="' . $type . '" ';
157 157
 
158 158
 			// name
159
-			if ( ! empty( $args['name'] ) ) {
160
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
159
+			if (!empty($args['name'])) {
160
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
161 161
 			}
162 162
 
163 163
 			// id
164
-			if ( ! empty( $args['id'] ) ) {
165
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
164
+			if (!empty($args['id'])) {
165
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
166 166
 			}
167 167
 
168 168
 			// placeholder
169
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
170
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
169
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
170
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
171 171
 			}
172 172
 
173 173
 			// title
174
-			if ( ! empty( $args['title'] ) ) {
175
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
174
+			if (!empty($args['title'])) {
175
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
176 176
 			}
177 177
 
178 178
 			// value
179
-			if ( ! empty( $args['value'] ) ) {
180
-				$output .= AUI_Component_Helper::value( $args['value'] );
179
+			if (!empty($args['value'])) {
180
+				$output .= AUI_Component_Helper::value($args['value']);
181 181
 			}
182 182
 
183 183
 			// checked, for radio and checkboxes
184
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
184
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
185 185
 				$output .= ' checked ';
186 186
 			}
187 187
 
188 188
 			// validation text
189
-			if ( ! empty( $args['validation_text'] ) ) {
190
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
189
+			if (!empty($args['validation_text'])) {
190
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
191 191
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
192 192
 			}
193 193
 
194 194
 			// validation_pattern
195
-			if ( ! empty( $args['validation_pattern'] ) ) {
196
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
195
+			if (!empty($args['validation_pattern'])) {
196
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
197 197
 			}
198 198
 
199 199
 			// step (for numbers)
200
-			if ( ! empty( $args['step'] ) ) {
200
+			if (!empty($args['step'])) {
201 201
 				$output .= ' step="' . $args['step'] . '" ';
202 202
 			}
203 203
 
204 204
 			// required
205
-			if ( ! empty( $args['required'] ) ) {
205
+			if (!empty($args['required'])) {
206 206
 				$output .= ' required ';
207 207
 			}
208 208
 
209 209
 			// class
210
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
210
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
211 211
 			$output .= ' class="form-control ' . $class . '" ';
212 212
 
213 213
 			// data-attributes
214
-			$output .= AUI_Component_Helper::data_attributes( $args );
214
+			$output .= AUI_Component_Helper::data_attributes($args);
215 215
 
216 216
 			// extra attributes
217
-			if ( ! empty( $args['extra_attributes'] ) ) {
218
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
217
+			if (!empty($args['extra_attributes'])) {
218
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
219 219
 			}
220 220
 
221 221
 			// close
222 222
 			$output .= ' >';
223 223
 
224 224
 			// help text
225
-			if ( ! empty( $args['help_text'] ) ) {
226
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
225
+			if (!empty($args['help_text'])) {
226
+				$help_text = AUI_Component_Helper::help_text($args['help_text']);
227 227
 			}
228 228
 
229 229
 			// label
230
-			if ( ! empty( $args['label'] ) ) {
230
+			if (!empty($args['label'])) {
231 231
 				$label_base_class = '';
232
-				if ( $type == 'file' ) {
232
+				if ($type == 'file') {
233 233
 					$label_base_class = ' custom-file-label';
234
-				} elseif ( $type == 'checkbox' ) {
235
-					if ( ! empty( $args['label_force_left'] ) ) {
236
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
234
+				} elseif ($type == 'checkbox') {
235
+					if (!empty($args['label_force_left'])) {
236
+						$label_args['title'] = wp_kses_post($args['help_text']);
237 237
 						$help_text = '';
238 238
 						//$label_args['class'] .= ' d-inline ';
239 239
 						$args['wrap_class'] .= ' align-items-center ';
240
-					}else{
240
+					} else {
241 241
 
242 242
 					}
243 243
 
@@ -245,45 +245,45 @@  discard block
 block discarded – undo
245 245
 				}
246 246
 				$label_args['class'] .= $label_base_class;
247 247
 				$temp_label_args = $label_args;
248
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
249
-				$label = self::label( $temp_label_args, $type );
248
+				if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; }
249
+				$label = self::label($temp_label_args, $type);
250 250
 			}
251 251
 
252 252
 
253 253
 
254 254
 
255 255
 			// set help text in the correct position
256
-			if ( $label_after ) {
256
+			if ($label_after) {
257 257
 				$output .= $label . $help_text;
258 258
 			}
259 259
 
260 260
 			// some input types need a separate wrap
261
-			if ( $type == 'file' ) {
262
-				$output = self::wrap( array(
261
+			if ($type == 'file') {
262
+				$output = self::wrap(array(
263 263
 					'content' => $output,
264 264
 					'class'   => 'form-group custom-file'
265
-				) );
266
-			} elseif ( $type == 'checkbox' ) {
265
+				));
266
+			} elseif ($type == 'checkbox') {
267 267
 
268 268
 				$label_args['title'] = $args['label'];
269
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
270
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
271
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
272
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
273
-				if ( ! empty( $args['label_force_left'] ) ) {
269
+				$label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label');
270
+				$label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>';
271
+				$switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : '';
272
+				$wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox';
273
+				if (!empty($args['label_force_left'])) {
274 274
 					$wrap_class .= ' d-flex align-content-center';
275
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
275
+					$label = str_replace("custom-control-label", "", self::label($label_args, 'cb'));
276 276
 				}
277
-				$output     = self::wrap( array(
277
+				$output = self::wrap(array(
278 278
 					'content' => $output,
279 279
 					'class'   => 'custom-control ' . $wrap_class
280
-				) );
280
+				));
281 281
 
282
-				if ( $args['label_type'] == 'horizontal' ) {
283
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
282
+				if ($args['label_type'] == 'horizontal') {
283
+					$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
284 284
 					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
285 285
 				}
286
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
286
+			} elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
287 287
 
288 288
 
289 289
 				// allow password field to toggle view
@@ -297,65 +297,65 @@  discard block
 block discarded – undo
297 297
 			}
298 298
 
299 299
 			// input group wraps
300
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
301
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
300
+			if ($args['input_group_left'] || $args['input_group_right']) {
301
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
302 302
 				$group_size = $size == 'lg' ? ' input-group-lg' : '';
303 303
 				$group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size;
304 304
 
305
-				if ( $args['input_group_left'] ) {
306
-					$output = self::wrap( array(
305
+				if ($args['input_group_left']) {
306
+					$output = self::wrap(array(
307 307
 						'content'                 => $output,
308 308
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
309 309
 						'input_group_left'        => $args['input_group_left'],
310 310
 						'input_group_left_inside' => $args['input_group_left_inside']
311
-					) );
311
+					));
312 312
 				}
313
-				if ( $args['input_group_right'] ) {
314
-					$output = self::wrap( array(
313
+				if ($args['input_group_right']) {
314
+					$output = self::wrap(array(
315 315
 						'content'                  => $output,
316 316
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
317 317
 						'input_group_right'        => $args['input_group_right'],
318 318
 						'input_group_right_inside' => $args['input_group_right_inside']
319
-					) );
319
+					));
320 320
 				}
321 321
 
322 322
 			}
323 323
 
324
-			if ( ! $label_after ) {
324
+			if (!$label_after) {
325 325
 				$output .= $help_text;
326 326
 			}
327 327
 
328 328
 
329
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
330
-				$output = self::wrap( array(
329
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
330
+				$output = self::wrap(array(
331 331
 					'content' => $output,
332
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
333
-				) );
332
+					'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
333
+				));
334 334
 			}
335 335
 
336
-			if ( ! $label_after ) {
336
+			if (!$label_after) {
337 337
 				$output = $label . $output;
338 338
 			}
339 339
 
340 340
 			// wrap
341
-			if ( ! $args['no_wrap'] ) {
341
+			if (!$args['no_wrap']) {
342 342
 				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
343 343
 				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
344
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
345
-				$output           = self::wrap( array(
344
+				$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
345
+				$output           = self::wrap(array(
346 346
 					'content'         => $output,
347 347
 					'class'           => $wrap_class,
348 348
 					'element_require' => $args['element_require'],
349 349
 					'argument_id'     => $args['id'],
350 350
 					'wrap_attributes' => $args['wrap_attributes'],
351
-				) );
351
+				));
352 352
 			}
353 353
 		}
354 354
 
355 355
 		return $output;
356 356
 	}
357 357
 
358
-	public static function label( $args = array(), $type = '' ) {
358
+	public static function label($args = array(), $type = '') {
359 359
 		//<label for="exampleInputEmail1">Email address</label>
360 360
 		$defaults = array(
361 361
 			'title'      => 'div',
@@ -368,33 +368,33 @@  discard block
 block discarded – undo
368 368
 		/**
369 369
 		 * Parse incoming $args into an array and merge it with $defaults
370 370
 		 */
371
-		$args   = wp_parse_args( $args, $defaults );
371
+		$args   = wp_parse_args($args, $defaults);
372 372
 		$output = '';
373 373
 
374
-		if ( $args['title'] ) {
374
+		if ($args['title']) {
375 375
 
376 376
 			// maybe hide labels //@todo set a global option for visibility class
377
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
377
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
378 378
 				$class = $args['class'];
379 379
 			} else {
380 380
 				$class = 'sr-only ' . $args['class'];
381 381
 			}
382 382
 
383 383
 			// maybe horizontal
384
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
385
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
384
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
385
+				$class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label';
386 386
 			}
387 387
 
388 388
 			// open
389 389
 			$output .= '<label ';
390 390
 
391 391
 			// for
392
-			if ( ! empty( $args['for'] ) ) {
393
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
392
+			if (!empty($args['for'])) {
393
+				$output .= ' for="' . esc_attr($args['for']) . '" ';
394 394
 			}
395 395
 
396 396
 			// class
397
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
397
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
398 398
 			$output .= ' class="' . $class . '" ';
399 399
 
400 400
 			// close
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 
403 403
 
404 404
 			// title, don't escape fully as can contain html
405
-			if ( ! empty( $args['title'] ) ) {
406
-				$output .= wp_kses_post( $args['title'] );
405
+			if (!empty($args['title'])) {
406
+				$output .= wp_kses_post($args['title']);
407 407
 			}
408 408
 
409 409
 			// close wrap
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 *
424 424
 	 * @return string
425 425
 	 */
426
-	public static function wrap( $args = array() ) {
426
+	public static function wrap($args = array()) {
427 427
 		$defaults = array(
428 428
 			'type'                     => 'div',
429 429
 			'class'                    => 'form-group',
@@ -440,31 +440,31 @@  discard block
 block discarded – undo
440 440
 		/**
441 441
 		 * Parse incoming $args into an array and merge it with $defaults
442 442
 		 */
443
-		$args   = wp_parse_args( $args, $defaults );
443
+		$args   = wp_parse_args($args, $defaults);
444 444
 		$output = '';
445
-		if ( $args['type'] ) {
445
+		if ($args['type']) {
446 446
 
447 447
 			// open
448
-			$output .= '<' . sanitize_html_class( $args['type'] );
448
+			$output .= '<' . sanitize_html_class($args['type']);
449 449
 
450 450
 			// element require
451
-			if ( ! empty( $args['element_require'] ) ) {
452
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
451
+			if (!empty($args['element_require'])) {
452
+				$output .= AUI_Component_Helper::element_require($args['element_require']);
453 453
 				$args['class'] .= " aui-conditional-field";
454 454
 			}
455 455
 
456 456
 			// argument_id
457
-			if ( ! empty( $args['argument_id'] ) ) {
458
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
457
+			if (!empty($args['argument_id'])) {
458
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
459 459
 			}
460 460
 
461 461
 			// class
462
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
462
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
463 463
 			$output .= ' class="' . $class . '" ';
464 464
 
465 465
 			// Attributes
466
-			if ( ! empty( $args['wrap_attributes'] ) ) {
467
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
466
+			if (!empty($args['wrap_attributes'])) {
467
+				$output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']);
468 468
 			}
469 469
 
470 470
 			// close wrap
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 
473 473
 
474 474
 			// Input group left
475
-			if ( ! empty( $args['input_group_left'] ) ) {
476
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
477
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
475
+			if (!empty($args['input_group_left'])) {
476
+				$position_class   = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
477
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
478 478
 				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
479 479
 			}
480 480
 
@@ -482,15 +482,15 @@  discard block
 block discarded – undo
482 482
 			$output .= $args['content'];
483 483
 
484 484
 			// Input group right
485
-			if ( ! empty( $args['input_group_right'] ) ) {
486
-				$position_class    = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : '';
487
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
485
+			if (!empty($args['input_group_right'])) {
486
+				$position_class    = !empty($args['input_group_right_inside']) ? 'position-absolute h-100' : '';
487
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
488 488
 				$output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>';
489 489
 			}
490 490
 
491 491
 
492 492
 			// close wrap
493
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
493
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
494 494
 
495 495
 
496 496
 		} else {
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 *
508 508
 	 * @return string The rendered component.
509 509
 	 */
510
-	public static function textarea( $args = array() ) {
510
+	public static function textarea($args = array()) {
511 511
 		$defaults = array(
512 512
 			'name'               => '',
513 513
 			'class'              => '',
@@ -544,28 +544,28 @@  discard block
 block discarded – undo
544 544
 		/**
545 545
 		 * Parse incoming $args into an array and merge it with $defaults
546 546
 		 */
547
-		$args   = wp_parse_args( $args, $defaults );
547
+		$args   = wp_parse_args($args, $defaults);
548 548
 		$output = '';
549 549
 
550 550
 		// hidden label option needs to be empty
551 551
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
552 552
 
553 553
 		// floating labels don't work with wysiwyg so set it as top
554
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
554
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
555 555
 			$args['label_type'] = 'top';
556 556
 		}
557 557
 
558 558
 		$label_after = $args['label_after'];
559 559
 
560 560
 		// floating labels need label after
561
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
561
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
562 562
 			$label_after         = true;
563 563
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
564 564
 		}
565 565
 
566 566
 		// label
567
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
568
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
567
+		if (!empty($args['label']) && is_array($args['label'])) {
568
+		} elseif (!empty($args['label']) && !$label_after) {
569 569
 			$label_args = array(
570 570
 				'title'      => $args['label'],
571 571
 				'for'        => $args['id'],
@@ -573,34 +573,34 @@  discard block
 block discarded – undo
573 573
 				'label_type' => $args['label_type'],
574 574
 				'label_col'  => $args['label_col']
575 575
 			);
576
-			$output .= self::label( $label_args );
576
+			$output .= self::label($label_args);
577 577
 		}
578 578
 
579 579
 		// maybe horizontal label
580
-		if ( $args['label_type'] == 'horizontal' ) {
581
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
580
+		if ($args['label_type'] == 'horizontal') {
581
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
582 582
 			$output .= '<div class="' . $input_col . '">';
583 583
 		}
584 584
 
585
-		if ( ! empty( $args['wysiwyg'] ) ) {
585
+		if (!empty($args['wysiwyg'])) {
586 586
 			ob_start();
587 587
 			$content   = $args['value'];
588
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
588
+			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
589 589
 			$settings  = array(
590
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
590
+				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
591 591
 				'quicktags'     => false,
592 592
 				'media_buttons' => false,
593 593
 				'editor_class'  => 'form-control',
594
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
594
+				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
595 595
 				'teeny'         => true,
596 596
 			);
597 597
 
598 598
 			// maybe set settings if array
599
-			if ( is_array( $args['wysiwyg'] ) ) {
600
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
599
+			if (is_array($args['wysiwyg'])) {
600
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
601 601
 			}
602 602
 
603
-			wp_editor( $content, $editor_id, $settings );
603
+			wp_editor($content, $editor_id, $settings);
604 604
 			$output .= ob_get_clean();
605 605
 		} else {
606 606
 
@@ -608,65 +608,65 @@  discard block
 block discarded – undo
608 608
 			$output .= '<textarea ';
609 609
 
610 610
 			// name
611
-			if ( ! empty( $args['name'] ) ) {
612
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
611
+			if (!empty($args['name'])) {
612
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
613 613
 			}
614 614
 
615 615
 			// id
616
-			if ( ! empty( $args['id'] ) ) {
617
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
616
+			if (!empty($args['id'])) {
617
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
618 618
 			}
619 619
 
620 620
 			// placeholder
621
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
622
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
621
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
622
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
623 623
 			}
624 624
 
625 625
 			// title
626
-			if ( ! empty( $args['title'] ) ) {
627
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
626
+			if (!empty($args['title'])) {
627
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
628 628
 			}
629 629
 
630 630
 			// validation text
631
-			if ( ! empty( $args['validation_text'] ) ) {
632
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
631
+			if (!empty($args['validation_text'])) {
632
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
633 633
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
634 634
 			}
635 635
 
636 636
 			// validation_pattern
637
-			if ( ! empty( $args['validation_pattern'] ) ) {
638
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
637
+			if (!empty($args['validation_pattern'])) {
638
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
639 639
 			}
640 640
 
641 641
 			// required
642
-			if ( ! empty( $args['required'] ) ) {
642
+			if (!empty($args['required'])) {
643 643
 				$output .= ' required ';
644 644
 			}
645 645
 
646 646
 			// rows
647
-			if ( ! empty( $args['rows'] ) ) {
648
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
647
+			if (!empty($args['rows'])) {
648
+				$output .= ' rows="' . absint($args['rows']) . '" ';
649 649
 			}
650 650
 
651 651
 
652 652
 			// class
653
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
653
+			$class = !empty($args['class']) ? $args['class'] : '';
654 654
 			$output .= ' class="form-control ' . $class . '" ';
655 655
 
656 656
 			// extra attributes
657
-			if ( ! empty( $args['extra_attributes'] ) ) {
658
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
657
+			if (!empty($args['extra_attributes'])) {
658
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
659 659
 			}
660 660
 
661 661
 			// close tag
662 662
 			$output .= ' >';
663 663
 
664 664
 			// value
665
-			if ( ! empty( $args['value'] ) ) {
666
-				if ( ! empty( $args['allow_tags'] ) ) {
667
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
665
+			if (!empty($args['value'])) {
666
+				if (!empty($args['allow_tags'])) {
667
+					$output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML.
668 668
 				} else {
669
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
669
+					$output .= AUI_Component_Helper::sanitize_textarea_field($args['value']);
670 670
 				}
671 671
 			}
672 672
 
@@ -675,23 +675,23 @@  discard block
 block discarded – undo
675 675
 
676 676
 
677 677
 			// input group wraps
678
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
679
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
680
-				if ( $args['input_group_left'] ) {
681
-					$output = self::wrap( array(
678
+			if ($args['input_group_left'] || $args['input_group_right']) {
679
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
680
+				if ($args['input_group_left']) {
681
+					$output = self::wrap(array(
682 682
 						'content'                 => $output,
683 683
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
684 684
 						'input_group_left'        => $args['input_group_left'],
685 685
 						'input_group_left_inside' => $args['input_group_left_inside']
686
-					) );
686
+					));
687 687
 				}
688
-				if ( $args['input_group_right'] ) {
689
-					$output = self::wrap( array(
688
+				if ($args['input_group_right']) {
689
+					$output = self::wrap(array(
690 690
 						'content'                  => $output,
691 691
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
692 692
 						'input_group_right'        => $args['input_group_right'],
693 693
 						'input_group_right_inside' => $args['input_group_right_inside']
694
-					) );
694
+					));
695 695
 				}
696 696
 
697 697
 			}
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 
700 700
 		}
701 701
 
702
-		if ( ! empty( $args['label'] ) && $label_after ) {
702
+		if (!empty($args['label']) && $label_after) {
703 703
 			$label_args = array(
704 704
 				'title'      => $args['label'],
705 705
 				'for'        => $args['id'],
@@ -707,32 +707,32 @@  discard block
 block discarded – undo
707 707
 				'label_type' => $args['label_type'],
708 708
 				'label_col'  => $args['label_col']
709 709
 			);
710
-			$output .= self::label( $label_args );
710
+			$output .= self::label($label_args);
711 711
 		}
712 712
 
713 713
 		// help text
714
-		if ( ! empty( $args['help_text'] ) ) {
715
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
714
+		if (!empty($args['help_text'])) {
715
+			$output .= AUI_Component_Helper::help_text($args['help_text']);
716 716
 		}
717 717
 
718 718
 		// maybe horizontal label
719
-		if ( $args['label_type'] == 'horizontal' ) {
719
+		if ($args['label_type'] == 'horizontal') {
720 720
 			$output .= '</div>';
721 721
 		}
722 722
 
723 723
 
724 724
 		// wrap
725
-		if ( ! $args['no_wrap'] ) {
725
+		if (!$args['no_wrap']) {
726 726
 			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
727 727
 			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
728
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
729
-			$output           = self::wrap( array(
728
+			$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
729
+			$output           = self::wrap(array(
730 730
 				'content'         => $output,
731 731
 				'class'           => $wrap_class,
732 732
 				'element_require' => $args['element_require'],
733 733
 				'argument_id'     => $args['id'],
734 734
 				'wrap_attributes' => $args['wrap_attributes'],
735
-			) );
735
+			));
736 736
 		}
737 737
 
738 738
 
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 	 *
747 747
 	 * @return string The rendered component.
748 748
 	 */
749
-	public static function select( $args = array() ) {
749
+	public static function select($args = array()) {
750 750
 		$defaults = array(
751 751
 			'class'            => '',
752 752
 			'wrap_class'       => '',
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
 		/**
784 784
 		 * Parse incoming $args into an array and merge it with $defaults
785 785
 		 */
786
-		$args   = wp_parse_args( $args, $defaults );
786
+		$args   = wp_parse_args($args, $defaults);
787 787
 		$output = '';
788 788
 
789 789
 		// for now lets hide floating labels
790
-		if ( $args['label_type'] == 'floating' ) {
790
+		if ($args['label_type'] == 'floating') {
791 791
 			$args['label_type'] = 'hidden';
792 792
 		}
793 793
 
@@ -798,89 +798,89 @@  discard block
 block discarded – undo
798 798
 		$label_after = $args['label_after'];
799 799
 
800 800
 		// floating labels need label after
801
-		if ( $args['label_type'] == 'floating' ) {
801
+		if ($args['label_type'] == 'floating') {
802 802
 			$label_after         = true;
803 803
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
804 804
 		}
805 805
 
806 806
 		// Maybe setup select2
807 807
 		$is_select2 = false;
808
-		if ( ! empty( $args['select2'] ) ) {
808
+		if (!empty($args['select2'])) {
809 809
 			$args['class'] .= ' aui-select2';
810 810
 			$is_select2 = true;
811
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
811
+		} elseif (strpos($args['class'], 'aui-select2') !== false) {
812 812
 			$is_select2 = true;
813 813
 		}
814 814
 
815 815
 		// select2 tags
816
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
816
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
817 817
 			$args['data-tags']             = 'true';
818 818
 			$args['data-token-separators'] = "[',']";
819 819
 			$args['multiple']              = true;
820 820
 		}
821 821
 
822 822
 		// select2 placeholder
823
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
824
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
825
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
823
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
824
+			$args['data-placeholder'] = esc_attr($args['placeholder']);
825
+			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
826 826
 		}
827 827
 
828 828
 		// Set hidden input to save empty value for multiselect.
829
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
830
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>';
829
+		if (!empty($args['multiple']) && !empty($args['name'])) {
830
+			$output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value="" data-ignore-rule/>';
831 831
 		}
832 832
 
833 833
 		// open/type
834 834
 		$output .= '<select ';
835 835
 
836 836
 		// style
837
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
837
+		if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
838 838
 			$output .= " style='width:100%;' ";
839 839
 		}
840 840
 
841 841
 		// element require
842
-		if ( ! empty( $args['element_require'] ) ) {
843
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
842
+		if (!empty($args['element_require'])) {
843
+			$output .= AUI_Component_Helper::element_require($args['element_require']);
844 844
 			$args['class'] .= " aui-conditional-field";
845 845
 		}
846 846
 
847 847
 		// class
848
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
849
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
848
+		$class = !empty($args['class']) ? $args['class'] : '';
849
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
850 850
 
851 851
 		// name
852
-		if ( ! empty( $args['name'] ) ) {
853
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
852
+		if (!empty($args['name'])) {
853
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
854 854
 		}
855 855
 
856 856
 		// id
857
-		if ( ! empty( $args['id'] ) ) {
858
-			$output .= AUI_Component_Helper::id( $args['id'] );
857
+		if (!empty($args['id'])) {
858
+			$output .= AUI_Component_Helper::id($args['id']);
859 859
 		}
860 860
 
861 861
 		// title
862
-		if ( ! empty( $args['title'] ) ) {
863
-			$output .= AUI_Component_Helper::title( $args['title'] );
862
+		if (!empty($args['title'])) {
863
+			$output .= AUI_Component_Helper::title($args['title']);
864 864
 		}
865 865
 
866 866
 		// data-attributes
867
-		$output .= AUI_Component_Helper::data_attributes( $args );
867
+		$output .= AUI_Component_Helper::data_attributes($args);
868 868
 
869 869
 		// aria-attributes
870
-		$output .= AUI_Component_Helper::aria_attributes( $args );
870
+		$output .= AUI_Component_Helper::aria_attributes($args);
871 871
 
872 872
 		// extra attributes
873
-		if ( ! empty( $args['extra_attributes'] ) ) {
874
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
873
+		if (!empty($args['extra_attributes'])) {
874
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
875 875
 		}
876 876
 
877 877
 		// required
878
-		if ( ! empty( $args['required'] ) ) {
878
+		if (!empty($args['required'])) {
879 879
 			$output .= ' required ';
880 880
 		}
881 881
 
882 882
 		// multiple
883
-		if ( ! empty( $args['multiple'] ) ) {
883
+		if (!empty($args['multiple'])) {
884 884
 			$output .= ' multiple ';
885 885
 		}
886 886
 
@@ -888,50 +888,50 @@  discard block
 block discarded – undo
888 888
 		$output .= ' >';
889 889
 
890 890
 		// placeholder
891
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
892
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
893
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
891
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
892
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
893
+		} elseif ($is_select2 && !empty($args['placeholder'])) {
894 894
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
895 895
 		}
896 896
 
897 897
 		// Options
898
-		if ( ! empty( $args['options'] ) ) {
898
+		if (!empty($args['options'])) {
899 899
 
900
-			if ( ! is_array( $args['options'] ) ) {
900
+			if (!is_array($args['options'])) {
901 901
 				$output .= $args['options']; // not the preferred way but an option
902 902
 			} else {
903
-				foreach ( $args['options'] as $val => $name ) {
903
+				foreach ($args['options'] as $val => $name) {
904 904
 					$selected = '';
905
-					if ( is_array( $name ) ) {
906
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
907
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
905
+					if (is_array($name)) {
906
+						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
907
+							$option_label = isset($name['label']) ? $name['label'] : '';
908 908
 
909
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
909
+							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
910 910
 						} else {
911
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
912
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
913
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
914
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
915
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
916
-							} elseif ( ! empty( $args['value'] ) ) {
917
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
918
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
919
-								$selected = selected( $option_value, $args['value'], false );
911
+							$option_label = isset($name['label']) ? $name['label'] : '';
912
+							$option_value = isset($name['value']) ? $name['value'] : '';
913
+							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : '';
914
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
915
+								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
916
+							} elseif (!empty($args['value'])) {
917
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
918
+							} elseif (empty($args['value']) && $args['value'] === $option_value) {
919
+								$selected = selected($option_value, $args['value'], false);
920 920
 							}
921 921
 
922
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
922
+							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>';
923 923
 						}
924 924
 					} else {
925
-						if ( ! empty( $args['value'] ) ) {
926
-							if ( is_array( $args['value'] ) ) {
927
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
928
-							} elseif ( ! empty( $args['value'] ) ) {
929
-								$selected = selected( $args['value'], $val, false );
925
+						if (!empty($args['value'])) {
926
+							if (is_array($args['value'])) {
927
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
928
+							} elseif (!empty($args['value'])) {
929
+								$selected = selected($args['value'], $val, false);
930 930
 							}
931
-						} elseif ( $args['value'] === $val ) {
932
-							$selected = selected( $args['value'], $val, false );
931
+						} elseif ($args['value'] === $val) {
932
+							$selected = selected($args['value'], $val, false);
933 933
 						}
934
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
934
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
935 935
 					}
936 936
 				}
937 937
 			}
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
 		$label = '';
945 945
 		$help_text = '';
946 946
 		// label
947
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
948
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
947
+		if (!empty($args['label']) && is_array($args['label'])) {
948
+		} elseif (!empty($args['label']) && !$label_after) {
949 949
 			$label_args = array(
950 950
 				'title'      => $args['label'],
951 951
 				'for'        => $args['id'],
@@ -953,49 +953,49 @@  discard block
 block discarded – undo
953 953
 				'label_type' => $args['label_type'],
954 954
 				'label_col'  => $args['label_col']
955 955
 			);
956
-			$label = self::label( $label_args );
956
+			$label = self::label($label_args);
957 957
 		}
958 958
 
959 959
 		// help text
960
-		if ( ! empty( $args['help_text'] ) ) {
961
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
960
+		if (!empty($args['help_text'])) {
961
+			$help_text = AUI_Component_Helper::help_text($args['help_text']);
962 962
 		}
963 963
 
964 964
 		// input group wraps
965
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
966
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
967
-			if ( $args['input_group_left'] ) {
968
-				$output = self::wrap( array(
965
+		if ($args['input_group_left'] || $args['input_group_right']) {
966
+			$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
967
+			if ($args['input_group_left']) {
968
+				$output = self::wrap(array(
969 969
 					'content'                 => $output,
970 970
 					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
971 971
 					'input_group_left'        => $args['input_group_left'],
972 972
 					'input_group_left_inside' => $args['input_group_left_inside']
973
-				) );
973
+				));
974 974
 			}
975
-			if ( $args['input_group_right'] ) {
976
-				$output = self::wrap( array(
975
+			if ($args['input_group_right']) {
976
+				$output = self::wrap(array(
977 977
 					'content'                  => $output,
978 978
 					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
979 979
 					'input_group_right'        => $args['input_group_right'],
980 980
 					'input_group_right_inside' => $args['input_group_right_inside']
981
-				) );
981
+				));
982 982
 			}
983 983
 
984 984
 		}
985 985
 
986
-		if ( ! $label_after ) {
986
+		if (!$label_after) {
987 987
 			$output .= $help_text;
988 988
 		}
989 989
 
990 990
 
991
-		if ( $args['label_type'] == 'horizontal' ) {
992
-			$output = self::wrap( array(
991
+		if ($args['label_type'] == 'horizontal') {
992
+			$output = self::wrap(array(
993 993
 				'content' => $output,
994
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
995
-			) );
994
+				'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
995
+			));
996 996
 		}
997 997
 
998
-		if ( ! $label_after ) {
998
+		if (!$label_after) {
999 999
 			$output = $label . $output;
1000 1000
 		}
1001 1001
 
@@ -1006,16 +1006,16 @@  discard block
 block discarded – undo
1006 1006
 
1007 1007
 
1008 1008
 		// wrap
1009
-		if ( ! $args['no_wrap'] ) {
1009
+		if (!$args['no_wrap']) {
1010 1010
 			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1011
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1012
-			$output     = self::wrap( array(
1011
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1012
+			$output     = self::wrap(array(
1013 1013
 				'content'         => $output,
1014 1014
 				'class'           => $wrap_class,
1015 1015
 				'element_require' => $args['element_require'],
1016 1016
 				'argument_id'     => $args['id'],
1017 1017
 				'wrap_attributes' => $args['wrap_attributes'],
1018
-			) );
1018
+			));
1019 1019
 		}
1020 1020
 
1021 1021
 
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 	 *
1030 1030
 	 * @return string The rendered component.
1031 1031
 	 */
1032
-	public static function radio( $args = array() ) {
1032
+	public static function radio($args = array()) {
1033 1033
 		$defaults = array(
1034 1034
 			'class'            => '',
1035 1035
 			'wrap_class'       => '',
@@ -1059,10 +1059,10 @@  discard block
 block discarded – undo
1059 1059
 		/**
1060 1060
 		 * Parse incoming $args into an array and merge it with $defaults
1061 1061
 		 */
1062
-		$args = wp_parse_args( $args, $defaults );
1062
+		$args = wp_parse_args($args, $defaults);
1063 1063
 
1064 1064
 		// for now lets use horizontal for floating
1065
-		if ( $args['label_type'] == 'floating' ) {
1065
+		if ($args['label_type'] == 'floating') {
1066 1066
 			$args['label_type'] = 'horizontal';
1067 1067
 		}
1068 1068
 
@@ -1077,47 +1077,47 @@  discard block
 block discarded – undo
1077 1077
 
1078 1078
 
1079 1079
 		// label before
1080
-		if ( ! empty( $args['label'] ) ) {
1081
-			$output .= self::label( $label_args, 'radio' );
1080
+		if (!empty($args['label'])) {
1081
+			$output .= self::label($label_args, 'radio');
1082 1082
 		}
1083 1083
 
1084 1084
 		// maybe horizontal label
1085
-		if ( $args['label_type'] == 'horizontal' ) {
1086
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1085
+		if ($args['label_type'] == 'horizontal') {
1086
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
1087 1087
 			$output .= '<div class="' . $input_col . '">';
1088 1088
 		}
1089 1089
 
1090
-		if ( ! empty( $args['options'] ) ) {
1090
+		if (!empty($args['options'])) {
1091 1091
 			$count = 0;
1092
-			foreach ( $args['options'] as $value => $label ) {
1092
+			foreach ($args['options'] as $value => $label) {
1093 1093
 				$option_args            = $args;
1094 1094
 				$option_args['value']   = $value;
1095 1095
 				$option_args['label']   = $label;
1096 1096
 				$option_args['checked'] = $value == $args['value'] ? true : false;
1097
-				$output .= self::radio_option( $option_args, $count );
1098
-				$count ++;
1097
+				$output .= self::radio_option($option_args, $count);
1098
+				$count++;
1099 1099
 			}
1100 1100
 		}
1101 1101
 
1102 1102
 		// help text
1103
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1103
+		$help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : '';
1104 1104
 		$output .= $help_text;
1105 1105
 
1106 1106
 		// maybe horizontal label
1107
-		if ( $args['label_type'] == 'horizontal' ) {
1107
+		if ($args['label_type'] == 'horizontal') {
1108 1108
 			$output .= '</div>';
1109 1109
 		}
1110 1110
 
1111 1111
 		// wrap
1112 1112
 		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1113
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1114
-		$output     = self::wrap( array(
1113
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1114
+		$output     = self::wrap(array(
1115 1115
 			'content'         => $output,
1116 1116
 			'class'           => $wrap_class,
1117 1117
 			'element_require' => $args['element_require'],
1118 1118
 			'argument_id'     => $args['id'],
1119 1119
 			'wrap_attributes' => $args['wrap_attributes'],
1120
-		) );
1120
+		));
1121 1121
 
1122 1122
 
1123 1123
 		return $output;
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	 *
1131 1131
 	 * @return string The rendered component.
1132 1132
 	 */
1133
-	public static function radio_option( $args = array(), $count = '' ) {
1133
+	public static function radio_option($args = array(), $count = '') {
1134 1134
 		$defaults = array(
1135 1135
 			'class'            => '',
1136 1136
 			'id'               => '',
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 		/**
1149 1149
 		 * Parse incoming $args into an array and merge it with $defaults
1150 1150
 		 */
1151
-		$args = wp_parse_args( $args, $defaults );
1151
+		$args = wp_parse_args($args, $defaults);
1152 1152
 
1153 1153
 		$output = '';
1154 1154
 
@@ -1159,43 +1159,43 @@  discard block
 block discarded – undo
1159 1159
 		$output .= ' class="form-check-input" ';
1160 1160
 
1161 1161
 		// name
1162
-		if ( ! empty( $args['name'] ) ) {
1163
-			$output .= AUI_Component_Helper::name( $args['name'] );
1162
+		if (!empty($args['name'])) {
1163
+			$output .= AUI_Component_Helper::name($args['name']);
1164 1164
 		}
1165 1165
 
1166 1166
 		// id
1167
-		if ( ! empty( $args['id'] ) ) {
1168
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1167
+		if (!empty($args['id'])) {
1168
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
1169 1169
 		}
1170 1170
 
1171 1171
 		// title
1172
-		if ( ! empty( $args['title'] ) ) {
1173
-			$output .= AUI_Component_Helper::title( $args['title'] );
1172
+		if (!empty($args['title'])) {
1173
+			$output .= AUI_Component_Helper::title($args['title']);
1174 1174
 		}
1175 1175
 
1176 1176
 		// value
1177
-		if ( isset( $args['value'] ) ) {
1178
-			$output .= AUI_Component_Helper::value( $args['value'] );
1177
+		if (isset($args['value'])) {
1178
+			$output .= AUI_Component_Helper::value($args['value']);
1179 1179
 		}
1180 1180
 
1181 1181
 		// checked, for radio and checkboxes
1182
-		if ( $args['checked'] ) {
1182
+		if ($args['checked']) {
1183 1183
 			$output .= ' checked ';
1184 1184
 		}
1185 1185
 
1186 1186
 		// data-attributes
1187
-		$output .= AUI_Component_Helper::data_attributes( $args );
1187
+		$output .= AUI_Component_Helper::data_attributes($args);
1188 1188
 
1189 1189
 		// aria-attributes
1190
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1190
+		$output .= AUI_Component_Helper::aria_attributes($args);
1191 1191
 
1192 1192
 		// extra attributes
1193
-		if ( ! empty( $args['extra_attributes'] ) ) {
1194
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1193
+		if (!empty($args['extra_attributes'])) {
1194
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
1195 1195
 		}
1196 1196
 
1197 1197
 		// required
1198
-		if ( ! empty( $args['required'] ) ) {
1198
+		if (!empty($args['required'])) {
1199 1199
 			$output .= ' required ';
1200 1200
 		}
1201 1201
 
@@ -1203,38 +1203,38 @@  discard block
 block discarded – undo
1203 1203
 		$output .= ' >';
1204 1204
 
1205 1205
 		// label
1206
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1207
-		} elseif ( ! empty( $args['label'] ) ) {
1208
-			$output .= self::label( array(
1206
+		if (!empty($args['label']) && is_array($args['label'])) {
1207
+		} elseif (!empty($args['label'])) {
1208
+			$output .= self::label(array(
1209 1209
 				'title' => $args['label'],
1210 1210
 				'for'   => $args['id'] . $count,
1211 1211
 				'class' => 'form-check-label'
1212
-			), 'radio' );
1212
+			), 'radio');
1213 1213
 		}
1214 1214
 
1215 1215
 		// wrap
1216
-		if ( ! $args['no_wrap'] ) {
1216
+		if (!$args['no_wrap']) {
1217 1217
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1218 1218
 
1219 1219
 			// Unique wrap class
1220 1220
 			$uniq_class = 'fwrap';
1221
-			if ( ! empty( $args['name'] ) ) {
1221
+			if (!empty($args['name'])) {
1222 1222
 				$uniq_class .= '-' . $args['name'];
1223
-			} else if ( ! empty( $args['id'] ) ) {
1223
+			} else if (!empty($args['id'])) {
1224 1224
 				$uniq_class .= '-' . $args['id'];
1225 1225
 			}
1226 1226
 
1227
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1227
+			if (isset($args['value']) || $args['value'] !== "") {
1228 1228
 				$uniq_class .= '-' . $args['value'];
1229 1229
 			} else {
1230 1230
 				$uniq_class .= '-' . $count;
1231 1231
 			}
1232
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1232
+			$wrap_class .= ' ' . sanitize_html_class($uniq_class);
1233 1233
 
1234
-			$output = self::wrap( array(
1234
+			$output = self::wrap(array(
1235 1235
 				'content' => $output,
1236 1236
 				'class'   => $wrap_class
1237
-			) );
1237
+			));
1238 1238
 		}
1239 1239
 
1240 1240
 		return $output;
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +446 added lines, -446 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  *
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,58 +170,58 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) ) {
182
+	if (isset($name)) {
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
     }
185 185
 	$templates[] = $slug . '.php';
186 186
 
187 187
 	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
188
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
189 189
 
190 190
 	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
191
+	return wpinv_locate_tmpl($templates, $load, false);
192 192
 }
193 193
 
194
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
194
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
195 195
 	// No file found yet
196 196
 	$located = false;
197 197
 
198 198
 	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
199
+	foreach ((array) $template_names as $template_name) {
200 200
 
201 201
 		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
202
+		if (empty($template_name)) {
203 203
 			continue;
204 204
         }
205 205
 
206 206
 		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
207
+		$template_name = ltrim($template_name, '/');
208 208
 
209 209
 		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
210
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
212
+			if (file_exists($template_path . $template_name)) {
213 213
 				$located = $template_path . $template_name;
214 214
 				break;
215 215
 			}
216 216
 		}
217 217
 
218
-		if ( ! empty( $located ) ) {
218
+		if (!empty($located)) {
219 219
 			break;
220 220
 		}
221 221
 	}
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+	if ((true == $load) && !empty($located)) {
224
+		load_template($located, $require_once);
225 225
     }
226 226
 
227 227
 	return $located;
@@ -231,73 +231,73 @@  discard block
 block discarded – undo
231 231
 	$template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233 233
 	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
234
+		1   => trailingslashit(get_stylesheet_directory()) . $template_dir,
235
+		10  => trailingslashit(get_template_directory()) . $template_dir,
236 236
 		100 => wpinv_get_templates_dir(),
237 237
 	);
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
240 240
 
241 241
 	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
242
+	ksort($file_paths, SORT_NUMERIC);
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+	return array_map('trailingslashit', $file_paths);
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249 249
 	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
250
+	$pages[] = wpinv_get_option('success_page');
251
+	$pages[] = wpinv_get_option('failure_page');
252
+	$pages[] = wpinv_get_option('invoice_history_page');
253
+	$pages[] = wpinv_get_option('invoice_subscription_page');
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
255
+	if (!wpinv_is_checkout() && !is_page($pages)) {
256 256
 		return;
257 257
 	}
258 258
 
259 259
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
261
+add_action('wp_head', 'wpinv_checkout_meta_tags');
262 262
 
263
-function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
263
+function wpinv_add_body_classes($class) {
264
+	$classes = (array) $class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
266
+	if (wpinv_is_checkout()) {
267 267
 		$classes[] = 'wpinv-checkout';
268 268
 		$classes[] = 'wpinv-page';
269 269
 	}
270 270
 
271
-	if ( wpinv_is_success_page() ) {
271
+	if (wpinv_is_success_page()) {
272 272
 		$classes[] = 'wpinv-success';
273 273
 		$classes[] = 'wpinv-page';
274 274
 	}
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
276
+	if (wpinv_is_failed_transaction_page()) {
277 277
 		$classes[] = 'wpinv-failed-transaction';
278 278
 		$classes[] = 'wpinv-page';
279 279
 	}
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
281
+	if (wpinv_is_invoice_history_page()) {
282 282
 		$classes[] = 'wpinv-history';
283 283
 		$classes[] = 'wpinv-page';
284 284
 	}
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
286
+	if (wpinv_is_subscriptions_history_page()) {
287 287
 		$classes[] = 'wpinv-subscription';
288 288
 		$classes[] = 'wpinv-page';
289 289
 	}
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
291
+	if (wpinv_is_test_mode()) {
292 292
 		$classes[] = 'wpinv-test-mode';
293 293
 		$classes[] = 'wpinv-page';
294 294
 	}
295 295
 
296
-	return array_unique( $classes );
296
+	return array_unique($classes);
297 297
 }
298
-add_filter( 'body_class', 'wpinv_add_body_classes' );
298
+add_filter('body_class', 'wpinv_add_body_classes');
299 299
 
300
-function wpinv_html_select( $args = array() ) {
300
+function wpinv_html_select($args = array()) {
301 301
     $defaults = array(
302 302
         'options'          => array(),
303 303
         'name'             => null,
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
         'selected'         => 0,
307 307
         'placeholder'      => null,
308 308
         'multiple'         => false,
309
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
310
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
309
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
310
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
311 311
         'data'             => array(),
312 312
         'onchange'         => null,
313 313
         'required'         => false,
@@ -315,79 +315,79 @@  discard block
 block discarded – undo
315 315
         'readonly'         => false,
316 316
     );
317 317
 
318
-    $args = wp_parse_args( $args, $defaults );
318
+    $args = wp_parse_args($args, $defaults);
319 319
 
320 320
     $attrs = array(
321 321
         'name'     => $args['name'],
322 322
         'id'       => $args['id'],
323
-        'class'    => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ),
324
-        'multiple' => ! empty( $args['multiple'] ),
325
-        'readonly' => ! empty( $args['readonly'] ),
326
-        'disabled' => ! empty( $args['disabled'] ),
327
-        'required' => ! empty( $args['required'] ),
328
-        'onchange' => ! empty( $args['onchange'] ),
323
+        'class'    => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))),
324
+        'multiple' => !empty($args['multiple']),
325
+        'readonly' => !empty($args['readonly']),
326
+        'disabled' => !empty($args['disabled']),
327
+        'required' => !empty($args['required']),
328
+        'onchange' => !empty($args['onchange']),
329 329
     );
330 330
 
331
-    if ( $args['placeholder'] ) {
331
+    if ($args['placeholder']) {
332 332
         $attrs['data-placeholder'] = $args['placeholder'];
333 333
     }
334 334
 
335
-    if ( $args['onchange'] ) {
335
+    if ($args['onchange']) {
336 336
         $attrs['onchange'] = $args['onchange'];
337 337
     }
338 338
 
339
-    foreach ( $args['data'] as $key => $value ) {
339
+    foreach ($args['data'] as $key => $value) {
340 340
         $attrs["data-$key"] = $value;
341 341
     }
342 342
 
343 343
     echo '<select ';
344 344
 
345
-    foreach ( $attrs as $attr => $value ) {
345
+    foreach ($attrs as $attr => $value) {
346 346
 
347
-        if ( false === $value ) {
347
+        if (false === $value) {
348 348
             continue;
349 349
         }
350 350
 
351
-        if ( true === $value ) {
352
-            echo ' ' . esc_attr( $attr );
351
+        if (true === $value) {
352
+            echo ' ' . esc_attr($attr);
353 353
         } else {
354
-            echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"';
354
+            echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"';
355 355
         }
356 356
 
357 357
     }
358 358
 
359 359
     echo '>';
360 360
 
361
-    if ( $args['show_option_all'] ) {
362
-        if ( $args['multiple'] ) {
363
-            $selected = in_array( 0, $args['selected'] );
361
+    if ($args['show_option_all']) {
362
+        if ($args['multiple']) {
363
+            $selected = in_array(0, $args['selected']);
364 364
         } else {
365
-            $selected = empty( $args['selected'] );
365
+            $selected = empty($args['selected']);
366 366
         }
367
-        echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>';
367
+        echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>';
368 368
     }
369 369
 
370
-    if ( ! empty( $args['options'] ) ) {
370
+    if (!empty($args['options'])) {
371 371
 
372
-        if ( $args['show_option_none'] ) {
373
-            if ( $args['multiple'] ) {
374
-                $selected = in_array( '', $args['selected'], true );
372
+        if ($args['show_option_none']) {
373
+            if ($args['multiple']) {
374
+                $selected = in_array('', $args['selected'], true);
375 375
             } else {
376 376
                 $selected = $args['selected'] === '';
377 377
             }
378 378
 
379
-            echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>';
379
+            echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>';
380 380
         }
381 381
 
382
-        foreach ( $args['options'] as $key => $option ) {
382
+        foreach ($args['options'] as $key => $option) {
383 383
 
384
-            if ( $args['multiple'] && is_array( $args['selected'] ) ) {
385
-                $selected = in_array( $key, $args['selected'], true );
384
+            if ($args['multiple'] && is_array($args['selected'])) {
385
+                $selected = in_array($key, $args['selected'], true);
386 386
             } else {
387 387
                 $selected = $args['selected'] === $key;
388 388
             }
389 389
 
390
-            echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>';
390
+            echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>';
391 391
         }
392 392
     }
393 393
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
 }
397 397
 
398
-function wpinv_item_dropdown( $args = array() ) {
398
+function wpinv_item_dropdown($args = array()) {
399 399
     $defaults = array(
400 400
         'name'             => 'wpi_item',
401 401
         'id'               => 'wpi_item',
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
         'multiple'         => false,
404 404
         'selected'         => 0,
405 405
         'number'           => -1,
406
-        'placeholder'      => __( 'Choose a item', 'invoicing' ),
407
-        'data'             => array( 'search-type' => 'item' ),
406
+        'placeholder'      => __('Choose a item', 'invoicing'),
407
+        'data'             => array('search-type' => 'item'),
408 408
         'show_option_all'  => false,
409 409
         'show_option_none' => false,
410 410
         'show_recurring'   => false,
411 411
     );
412 412
 
413
-    $args = wp_parse_args( $args, $defaults );
413
+    $args = wp_parse_args($args, $defaults);
414 414
 
415 415
     $item_args = array(
416 416
         'post_type'      => 'wpi_item',
@@ -419,40 +419,40 @@  discard block
 block discarded – undo
419 419
         'posts_per_page' => $args['number'],
420 420
     );
421 421
 
422
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
422
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
423 423
 
424
-    $items      = get_posts( $item_args );
424
+    $items      = get_posts($item_args);
425 425
     $options    = array();
426
-    if ( $items ) {
427
-        foreach ( $items as $item ) {
428
-            $title = esc_html( $item->post_title );
426
+    if ($items) {
427
+        foreach ($items as $item) {
428
+            $title = esc_html($item->post_title);
429 429
 
430
-            if ( ! empty( $args['show_recurring'] ) ) {
431
-                $title .= wpinv_get_item_suffix( $item->ID, false );
430
+            if (!empty($args['show_recurring'])) {
431
+                $title .= wpinv_get_item_suffix($item->ID, false);
432 432
             }
433 433
 
434
-            $options[ absint( $item->ID ) ] = $title;
434
+            $options[absint($item->ID)] = $title;
435 435
         }
436 436
     }
437 437
 
438 438
     // This ensures that any selected items are included in the drop down
439
-    if ( is_array( $args['selected'] ) ) {
440
-        foreach ( $args['selected'] as $item ) {
441
-            if ( ! in_array( $item, $options ) ) {
442
-                $title = get_the_title( $item );
443
-                if ( ! empty( $args['show_recurring'] ) ) {
444
-                    $title .= wpinv_get_item_suffix( $item, false );
439
+    if (is_array($args['selected'])) {
440
+        foreach ($args['selected'] as $item) {
441
+            if (!in_array($item, $options)) {
442
+                $title = get_the_title($item);
443
+                if (!empty($args['show_recurring'])) {
444
+                    $title .= wpinv_get_item_suffix($item, false);
445 445
                 }
446
-                $options[ $item ] = $title;
446
+                $options[$item] = $title;
447 447
             }
448 448
         }
449
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
450
-        if ( ! in_array( $args['selected'], $options ) ) {
451
-            $title = get_the_title( $args['selected'] );
452
-            if ( ! empty( $args['show_recurring'] ) ) {
453
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
449
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
450
+        if (!in_array($args['selected'], $options)) {
451
+            $title = get_the_title($args['selected']);
452
+            if (!empty($args['show_recurring'])) {
453
+                $title .= wpinv_get_item_suffix($args['selected'], false);
454 454
             }
455
-            $options[ $args['selected'] ] = get_the_title( $args['selected'] );
455
+            $options[$args['selected']] = get_the_title($args['selected']);
456 456
         }
457 457
     }
458 458
 
@@ -488,16 +488,16 @@  discard block
 block discarded – undo
488 488
     );
489 489
 
490 490
     $options = array();
491
-    if ( $items ) {
492
-        foreach ( $items as $item ) {
493
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
491
+    if ($items) {
492
+        foreach ($items as $item) {
493
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
494 494
         }
495 495
     }
496 496
 
497 497
     return $options;
498 498
 }
499 499
 
500
-function wpinv_html_checkbox( $args = array() ) {
500
+function wpinv_html_checkbox($args = array()) {
501 501
     $defaults = array(
502 502
         'name'    => null,
503 503
         'current' => null,
@@ -508,17 +508,17 @@  discard block
 block discarded – undo
508 508
         ),
509 509
     );
510 510
 
511
-    $args = wp_parse_args( $args, $defaults );
511
+    $args = wp_parse_args($args, $defaults);
512 512
 
513
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
513
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
514 514
     $attr  = '';
515
-    if ( ! empty( $args['options']['disabled'] ) ) {
515
+    if (!empty($args['options']['disabled'])) {
516 516
         $attr .= ' disabled="disabled"';
517
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
517
+    } elseif (!empty($args['options']['readonly'])) {
518 518
         $attr .= ' readonly';
519 519
     }
520 520
 
521
-    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
521
+    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
522 522
 
523 523
     return $output;
524 524
 }
@@ -526,34 +526,34 @@  discard block
 block discarded – undo
526 526
 /**
527 527
  * Displays a hidden field.
528 528
  */
529
-function getpaid_hidden_field( $name, $value ) {
530
-    echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />";
529
+function getpaid_hidden_field($name, $value) {
530
+    echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />";
531 531
 }
532 532
 
533 533
 /**
534 534
  * Displays a submit field.
535 535
  */
536
-function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) {
537
-    echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />";
536
+function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') {
537
+    echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />";
538 538
 }
539 539
 
540
-function wpinv_html_text( $args = array() ) {
540
+function wpinv_html_text($args = array()) {
541 541
     // Backwards compatibility
542
-    if ( func_num_args() > 1 ) {
542
+    if (func_num_args() > 1) {
543 543
         $args = func_get_args();
544 544
 
545 545
         $name  = $args[0];
546
-        $value = isset( $args[1] ) ? $args[1] : '';
547
-        $label = isset( $args[2] ) ? $args[2] : '';
548
-        $desc  = isset( $args[3] ) ? $args[3] : '';
546
+        $value = isset($args[1]) ? $args[1] : '';
547
+        $label = isset($args[2]) ? $args[2] : '';
548
+        $desc  = isset($args[3]) ? $args[3] : '';
549 549
     }
550 550
 
551 551
     $defaults = array(
552 552
         'id'           => '',
553
-        'name'         => isset( $name ) ? $name : 'text',
554
-        'value'        => isset( $value ) ? $value : null,
555
-        'label'        => isset( $label ) ? $label : null,
556
-        'desc'         => isset( $desc ) ? $desc : null,
553
+        'name'         => isset($name) ? $name : 'text',
554
+        'value'        => isset($value) ? $value : null,
555
+        'label'        => isset($label) ? $label : null,
556
+        'desc'         => isset($desc) ? $desc : null,
557 557
         'placeholder'  => '',
558 558
         'class'        => 'regular-text',
559 559
         'disabled'     => false,
@@ -563,41 +563,41 @@  discard block
 block discarded – undo
563 563
         'data'         => false,
564 564
     );
565 565
 
566
-    $args = wp_parse_args( $args, $defaults );
566
+    $args = wp_parse_args($args, $defaults);
567 567
 
568
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
568
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
569 569
     $options = '';
570
-    if ( $args['required'] ) {
570
+    if ($args['required']) {
571 571
         $options .= ' required="required"';
572 572
     }
573
-    if ( $args['readonly'] ) {
573
+    if ($args['readonly']) {
574 574
         $options .= ' readonly';
575 575
     }
576
-    if ( $args['readonly'] ) {
576
+    if ($args['readonly']) {
577 577
         $options .= ' readonly';
578 578
     }
579 579
 
580 580
     $data = '';
581
-    if ( ! empty( $args['data'] ) ) {
582
-        foreach ( $args['data'] as $key => $value ) {
583
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
581
+    if (!empty($args['data'])) {
582
+        foreach ($args['data'] as $key => $value) {
583
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
584 584
         }
585 585
     }
586 586
 
587
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
588
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
589
-    if ( ! empty( $args['desc'] ) ) {
590
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
587
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
588
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
589
+    if (!empty($args['desc'])) {
590
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
591 591
     }
592 592
 
593
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
593
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
594 594
 
595 595
     $output .= '</span>';
596 596
 
597 597
     return $output;
598 598
 }
599 599
 
600
-function wpinv_html_textarea( $args = array() ) {
600
+function wpinv_html_textarea($args = array()) {
601 601
     $defaults = array(
602 602
         'name'        => 'textarea',
603 603
         'value'       => null,
@@ -608,31 +608,31 @@  discard block
 block discarded – undo
608 608
         'placeholder' => '',
609 609
     );
610 610
 
611
-    $args = wp_parse_args( $args, $defaults );
611
+    $args = wp_parse_args($args, $defaults);
612 612
 
613
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
613
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
614 614
     $disabled = '';
615
-    if ( $args['disabled'] ) {
615
+    if ($args['disabled']) {
616 616
         $disabled = ' disabled="disabled"';
617 617
     }
618 618
 
619
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
620
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
621
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
619
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
620
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
621
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
622 622
 
623
-    if ( ! empty( $args['desc'] ) ) {
624
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
623
+    if (!empty($args['desc'])) {
624
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
625 625
     }
626 626
     $output .= '</span>';
627 627
 
628 628
     return $output;
629 629
 }
630 630
 
631
-function wpinv_html_ajax_user_search( $args = array() ) {
631
+function wpinv_html_ajax_user_search($args = array()) {
632 632
     $defaults = array(
633 633
         'name'         => 'user_id',
634 634
         'value'        => null,
635
-        'placeholder'  => __( 'Enter username', 'invoicing' ),
635
+        'placeholder'  => __('Enter username', 'invoicing'),
636 636
         'label'        => null,
637 637
         'desc'         => null,
638 638
         'class'        => '',
@@ -641,13 +641,13 @@  discard block
 block discarded – undo
641 641
         'data'         => false,
642 642
     );
643 643
 
644
-    $args = wp_parse_args( $args, $defaults );
644
+    $args = wp_parse_args($args, $defaults);
645 645
 
646 646
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
647 647
 
648 648
     $output  = '<span class="wpinv_user_search_wrap">';
649
-        $output .= wpinv_html_text( $args );
650
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
649
+        $output .= wpinv_html_text($args);
650
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
651 651
     $output .= '</span>';
652 652
 
653 653
     return $output;
@@ -658,44 +658,44 @@  discard block
 block discarded – undo
658 658
  *
659 659
  * @param string $template the template that is currently being used.
660 660
  */
661
-function wpinv_template( $template ) {
661
+function wpinv_template($template) {
662 662
     global $post;
663 663
 
664
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
664
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
665 665
 
666 666
         // If the user can view this invoice, display it.
667
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
667
+        if (wpinv_user_can_view_invoice($post->ID)) {
668 668
 
669
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
669
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
670 670
 
671 671
         // Else display an error message.
672 672
         } else {
673 673
 
674
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
674
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
675 675
 
676 676
         }
677 677
 }
678 678
 
679 679
     return $template;
680 680
 }
681
-add_filter( 'template_include', 'wpinv_template', 1000, 1 );
681
+add_filter('template_include', 'wpinv_template', 1000, 1);
682 682
 
683 683
 function wpinv_get_business_address() {
684 684
     $business_address   = wpinv_store_address();
685
-    $business_address   = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : '';
685
+    $business_address   = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : '';
686 686
 
687 687
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
688 688
 
689
-    return apply_filters( 'wpinv_get_business_address', $business_address );
689
+    return apply_filters('wpinv_get_business_address', $business_address);
690 690
 }
691 691
 
692 692
 /**
693 693
  * Displays the company address.
694 694
  */
695 695
 function wpinv_display_from_address() {
696
-    wpinv_get_template( 'invoice/company-address.php' );
696
+    wpinv_get_template('invoice/company-address.php');
697 697
 }
698
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
698
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
699 699
 
700 700
 /**
701 701
  * Generates a watermark text for an invoice.
@@ -703,9 +703,9 @@  discard block
 block discarded – undo
703 703
  * @param WPInv_Invoice $invoice
704 704
  * @return string
705 705
  */
706
-function wpinv_watermark( $invoice ) {
707
-    $watermark = wpinv_get_watermark( $invoice );
708
-    return apply_filters( 'wpinv_get_watermark', $watermark, $invoice );
706
+function wpinv_watermark($invoice) {
707
+    $watermark = wpinv_get_watermark($invoice);
708
+    return apply_filters('wpinv_get_watermark', $watermark, $invoice);
709 709
 }
710 710
 
711 711
 /**
@@ -714,37 +714,37 @@  discard block
 block discarded – undo
714 714
  * @param WPInv_Invoice $invoice
715 715
  * @return string
716 716
  */
717
-function wpinv_get_watermark( $invoice ) {
717
+function wpinv_get_watermark($invoice) {
718 718
     return $invoice->get_status_nicename();
719 719
 }
720 720
 
721 721
 /**
722 722
  * @deprecated
723 723
  */
724
-function wpinv_display_invoice_details( $invoice ) {
725
-    return getpaid_invoice_meta( $invoice );
724
+function wpinv_display_invoice_details($invoice) {
725
+    return getpaid_invoice_meta($invoice);
726 726
 }
727 727
 
728 728
 /**
729 729
  * Displays invoice meta.
730 730
  */
731
-function getpaid_invoice_meta( $invoice ) {
731
+function getpaid_invoice_meta($invoice) {
732 732
 
733
-    $invoice = new WPInv_Invoice( $invoice );
733
+    $invoice = new WPInv_Invoice($invoice);
734 734
 
735 735
     // Ensure that we have an invoice.
736
-    if ( 0 == $invoice->get_id() ) {
736
+    if (0 == $invoice->get_id()) {
737 737
         return;
738 738
     }
739 739
 
740 740
     // Get the invoice meta.
741
-    $meta = getpaid_get_invoice_meta( $invoice );
741
+    $meta = getpaid_get_invoice_meta($invoice);
742 742
 
743 743
     // Display the meta.
744
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
744
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
745 745
 
746 746
 }
747
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
747
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
748 748
 
749 749
 /**
750 750
  * Retrieves the address markup to use on Invoices.
@@ -756,29 +756,29 @@  discard block
 block discarded – undo
756 756
  * @param  string $separator How to separate address lines.
757 757
  * @return string
758 758
  */
759
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
759
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
760 760
 
761 761
     // Retrieve the address markup...
762
-    $country = empty( $billing_details['country'] ) ? '' : $billing_details['country'];
763
-    $format = wpinv_get_full_address_format( $country );
762
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
763
+    $format = wpinv_get_full_address_format($country);
764 764
 
765 765
     // ... and the replacements.
766
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
766
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
767 767
 
768
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
768
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
769 769
 
770 770
 	// Remove unavailable tags.
771
-    $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
771
+    $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address);
772 772
 
773 773
     // Clean up white space.
774
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
775
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
774
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
775
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
776 776
 
777 777
     // Break newlines apart and remove empty lines/trim commas and white space.
778
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
778
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
779 779
 
780 780
     // Add html breaks.
781
-	$formatted_address = implode( $separator, $formatted_address );
781
+	$formatted_address = implode($separator, $formatted_address);
782 782
 
783 783
 	// We're done!
784 784
 	return $formatted_address;
@@ -790,118 +790,118 @@  discard block
 block discarded – undo
790 790
  *
791 791
  * @param WPInv_Invoice $invoice
792 792
  */
793
-function wpinv_display_to_address( $invoice = 0 ) {
794
-    if ( ! empty( $invoice ) ) {
795
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
793
+function wpinv_display_to_address($invoice = 0) {
794
+    if (!empty($invoice)) {
795
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
796 796
     }
797 797
 }
798
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
798
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
799 799
 
800 800
 
801 801
 /**
802 802
  * Displays invoice line items.
803 803
  */
804
-function wpinv_display_line_items( $invoice_id = 0 ) {
804
+function wpinv_display_line_items($invoice_id = 0) {
805 805
 
806 806
     // Prepare the invoice.
807
-    $invoice = new WPInv_Invoice( $invoice_id );
807
+    $invoice = new WPInv_Invoice($invoice_id);
808 808
 
809 809
     // Abort if there is no invoice.
810
-    if ( 0 == $invoice->get_id() ) {
810
+    if (0 == $invoice->get_id()) {
811 811
         return;
812 812
     }
813 813
 
814 814
     // Line item columns.
815
-    $columns = getpaid_invoice_item_columns( $invoice );
816
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
815
+    $columns = getpaid_invoice_item_columns($invoice);
816
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
817 817
 
818
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
818
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
819 819
 }
820
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
820
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
821 821
 
822 822
 /**
823 823
  * Displays invoice subscriptions.
824 824
  *
825 825
  * @param WPInv_Invoice $invoice
826 826
  */
827
-function getpaid_display_invoice_subscriptions( $invoice ) {
827
+function getpaid_display_invoice_subscriptions($invoice) {
828 828
 
829 829
     // Subscriptions.
830
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
830
+	$subscriptions = getpaid_get_invoice_subscriptions($invoice);
831 831
 
832
-    if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
832
+    if (empty($subscriptions) || !$invoice->is_recurring()) {
833 833
         return;
834 834
     }
835 835
 
836
-    $main_subscription = getpaid_get_invoice_subscription( $invoice );
836
+    $main_subscription = getpaid_get_invoice_subscription($invoice);
837 837
 
838 838
     // Display related subscriptions.
839
-    if ( is_array( $subscriptions ) ) {
840
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) );
841
-        getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false );
839
+    if (is_array($subscriptions)) {
840
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing'));
841
+        getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false);
842 842
     }
843 843
 
844
-    if ( $main_subscription->get_total_payments() > 1 ) {
845
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) );
846
-        getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false );
844
+    if ($main_subscription->get_total_payments() > 1) {
845
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing'));
846
+        getpaid_admin_subscription_invoice_details_metabox($main_subscription, false);
847 847
     }
848 848
 
849 849
 }
850
-add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 );
851
-add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 );
850
+add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55);
851
+add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11);
852 852
 
853 853
 /**
854 854
  * Displays invoice notices on invoices.
855 855
  */
856 856
 function wpinv_display_invoice_notice() {
857 857
 
858
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
859
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
858
+    $label  = wpinv_get_option('vat_invoice_notice_label');
859
+    $notice = wpinv_get_option('vat_invoice_notice');
860 860
 
861
-    if ( empty( $label ) && empty( $notice ) ) {
861
+    if (empty($label) && empty($notice)) {
862 862
         return;
863 863
     }
864 864
 
865 865
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
866 866
 
867
-    if ( ! empty( $label ) ) {
868
-        echo "<h5>" . esc_html( $label ) . "</h5>";
867
+    if (!empty($label)) {
868
+        echo "<h5>" . esc_html($label) . "</h5>";
869 869
     }
870 870
 
871
-    if ( ! empty( $notice ) ) {
872
-        echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>';
871
+    if (!empty($notice)) {
872
+        echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>';
873 873
     }
874 874
 
875 875
     echo '</div>';
876 876
 }
877
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
877
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
878 878
 
879 879
 /**
880 880
  * @param WPInv_Invoice $invoice
881 881
  */
882
-function wpinv_display_invoice_notes( $invoice ) {
882
+function wpinv_display_invoice_notes($invoice) {
883 883
 
884 884
     // Retrieve the notes.
885
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
885
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
886 886
 
887 887
     // Abort if we have non.
888
-    if ( empty( $notes ) ) {
888
+    if (empty($notes)) {
889 889
         return;
890 890
     }
891 891
 
892 892
     // Echo the note.
893 893
     echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">';
894
-    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>';
894
+    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>';
895 895
     echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">';
896 896
 
897
-    foreach ( $notes as $note ) {
898
-        wpinv_get_invoice_note_line_item( $note );
897
+    foreach ($notes as $note) {
898
+        wpinv_get_invoice_note_line_item($note);
899 899
     }
900 900
 
901 901
     echo '</ul>';
902 902
     echo '</div>';
903 903
 }
904
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
904
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
905 905
 
906 906
 /**
907 907
  * Loads scripts on our invoice templates.
@@ -909,32 +909,32 @@  discard block
 block discarded – undo
909 909
 function wpinv_display_style() {
910 910
 
911 911
     // Make sure that all scripts have been loaded.
912
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
913
-        do_action( 'wp_enqueue_scripts' );
912
+    if (!did_action('wp_enqueue_scripts')) {
913
+        do_action('wp_enqueue_scripts');
914 914
     }
915 915
 
916 916
     // Register the invoices style.
917
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
917
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
918 918
 
919 919
     // Load required styles
920
-    wp_print_styles( 'wpinv-single-style' );
921
-    wp_print_styles( 'ayecode-ui' );
920
+    wp_print_styles('wpinv-single-style');
921
+    wp_print_styles('ayecode-ui');
922 922
 
923 923
     // Maybe load custom css.
924
-    $custom_css = wpinv_get_option( 'template_custom_css' );
924
+    $custom_css = wpinv_get_option('template_custom_css');
925 925
 
926
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
927
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
928
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
926
+    if (isset($custom_css) && !empty($custom_css)) {
927
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
928
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
929 929
         echo '<style type="text/css">';
930
-        echo wp_kses_post( $custom_css );
930
+        echo wp_kses_post($custom_css);
931 931
         echo '</style>';
932 932
     }
933 933
 
934 934
     wp_site_icon();
935 935
 }
936
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
937
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
936
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
937
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
938 938
 
939 939
 
940 940
 /**
@@ -946,41 +946,41 @@  discard block
 block discarded – undo
946 946
     // Retrieve the current invoice.
947 947
     $invoice_id = getpaid_get_current_invoice_id();
948 948
 
949
-    if ( empty( $invoice_id ) ) {
949
+    if (empty($invoice_id)) {
950 950
 
951 951
         return aui()->alert(
952 952
             array(
953 953
                 'type'    => 'warning',
954
-                'content' => __( 'Invalid invoice', 'invoicing' ),
954
+                'content' => __('Invalid invoice', 'invoicing'),
955 955
             )
956 956
         );
957 957
 
958 958
     }
959 959
 
960 960
     // Can the user view this invoice?
961
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
961
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
962 962
 
963 963
         return aui()->alert(
964 964
             array(
965 965
                 'type'    => 'warning',
966
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
966
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
967 967
             )
968 968
         );
969 969
 
970 970
     }
971 971
 
972 972
     // Ensure that it is not yet paid for.
973
-    $invoice = new WPInv_Invoice( $invoice_id );
973
+    $invoice = new WPInv_Invoice($invoice_id);
974 974
 
975 975
     // Maybe mark it as viewed.
976
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
976
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
977 977
 
978
-    if ( $invoice->is_paid() ) {
978
+    if ($invoice->is_paid()) {
979 979
 
980 980
         return aui()->alert(
981 981
             array(
982 982
                 'type'    => 'success',
983
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
983
+                'content' => __('This invoice has already been paid.', 'invoicing'),
984 984
             )
985 985
         );
986 986
 
@@ -990,15 +990,15 @@  discard block
 block discarded – undo
990 990
     $wpi_checkout_id = $invoice_id;
991 991
 
992 992
     // Retrieve appropriate payment form.
993
-    $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) );
994
-    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
993
+    $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form'));
994
+    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
995 995
 
996
-    if ( ! $payment_form->exists() ) {
996
+    if (!$payment_form->exists()) {
997 997
 
998 998
         return aui()->alert(
999 999
             array(
1000 1000
                 'type'    => 'warning',
1001
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1001
+                'content' => __('Error loading the payment form', 'invoicing'),
1002 1002
             )
1003 1003
         );
1004 1004
 
@@ -1007,29 +1007,29 @@  discard block
 block discarded – undo
1007 1007
     // Set the invoice.
1008 1008
     $payment_form->invoice = $invoice;
1009 1009
 
1010
-    if ( ! $payment_form->is_default() ) {
1010
+    if (!$payment_form->is_default()) {
1011 1011
 
1012 1012
         $items    = array();
1013 1013
         $item_ids = array();
1014 1014
 
1015
-        foreach ( $invoice->get_items() as $item ) {
1016
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1015
+        foreach ($invoice->get_items() as $item) {
1016
+            if (!in_array($item->get_id(), $item_ids)) {
1017 1017
                 $item_ids[] = $item->get_id();
1018 1018
                 $items[]    = $item;
1019 1019
             }
1020 1020
         }
1021 1021
 
1022
-        foreach ( $payment_form->get_items() as $item ) {
1023
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1022
+        foreach ($payment_form->get_items() as $item) {
1023
+            if (!in_array($item->get_id(), $item_ids)) {
1024 1024
                 $item_ids[] = $item->get_id();
1025 1025
                 $items[]    = $item;
1026 1026
             }
1027 1027
         }
1028 1028
 
1029
-        $payment_form->set_items( $items );
1029
+        $payment_form->set_items($items);
1030 1030
 
1031 1031
     } else {
1032
-        $payment_form->set_items( $invoice->get_items() );
1032
+        $payment_form->set_items($invoice->get_items());
1033 1033
     }
1034 1034
 
1035 1035
     // Generate the html.
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 }
1039 1039
 
1040 1040
 function wpinv_empty_cart_message() {
1041
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1041
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1042 1042
 }
1043 1043
 
1044 1044
 /**
@@ -1056,76 +1056,76 @@  discard block
 block discarded – undo
1056 1056
         true
1057 1057
     );
1058 1058
 }
1059
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1059
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1060 1060
 
1061 1061
 /**
1062 1062
  * Filters the receipt page.
1063 1063
  */
1064
-function wpinv_filter_success_page_content( $content ) {
1064
+function wpinv_filter_success_page_content($content) {
1065 1065
 
1066 1066
     // Maybe abort early.
1067
-    if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) {
1067
+    if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) {
1068 1068
         return $content;
1069 1069
     }
1070 1070
 
1071 1071
     // Ensure this is our page.
1072
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1072
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1073 1073
 
1074
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1075
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1074
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1075
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1076 1076
 
1077 1077
     }
1078 1078
 
1079 1079
     return $content;
1080 1080
 }
1081
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1081
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1082 1082
 
1083
-function wpinv_invoice_link( $invoice_id ) {
1084
-    $invoice = wpinv_get_invoice( $invoice_id );
1083
+function wpinv_invoice_link($invoice_id) {
1084
+    $invoice = wpinv_get_invoice($invoice_id);
1085 1085
 
1086
-    if ( empty( $invoice ) ) {
1086
+    if (empty($invoice)) {
1087 1087
         return null;
1088 1088
     }
1089 1089
 
1090
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1090
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1091 1091
 
1092
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1092
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1093 1093
 }
1094 1094
 
1095
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1096
-    if ( empty( $note ) ) {
1095
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1096
+    if (empty($note)) {
1097 1097
         return null;
1098 1098
     }
1099 1099
 
1100
-    if ( is_int( $note ) ) {
1101
-        $note = get_comment( $note );
1100
+    if (is_int($note)) {
1101
+        $note = get_comment($note);
1102 1102
     }
1103 1103
 
1104
-    if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1104
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1105 1105
         return null;
1106 1106
     }
1107 1107
 
1108
-    $note_classes   = array( 'note' );
1109
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1108
+    $note_classes   = array('note');
1109
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1110 1110
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1111
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1112
-    $note_classes   = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1111
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1112
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1113 1113
 
1114 1114
     ob_start();
1115 1115
     ?>
1116
-    <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2">
1116
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2">
1117 1117
         <div class="note_content">
1118 1118
 
1119
-            <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?>
1119
+            <?php echo wp_kses_post(wptexturize($note->comment_content)); ?>
1120 1120
 
1121
-            <?php if ( ! is_admin() ) : ?>
1121
+            <?php if (!is_admin()) : ?>
1122 1122
                 <em class="small form-text text-muted mt-0">
1123 1123
                     <?php
1124 1124
                         printf(
1125
-                            esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ),
1126
-                            esc_html( $note->comment_author ),
1127
-                            esc_html( getpaid_format_date_value( $note->comment_date ) ),
1128
-                            esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) )
1125
+                            esc_html__('%1$s - %2$s at %3$s', 'invoicing'),
1126
+                            esc_html($note->comment_author),
1127
+                            esc_html(getpaid_format_date_value($note->comment_date)),
1128
+                            esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date)))
1129 1129
                         );
1130 1130
                     ?>
1131 1131
                 </em>
@@ -1133,21 +1133,21 @@  discard block
 block discarded – undo
1133 1133
 
1134 1134
         </div>
1135 1135
 
1136
-        <?php if ( is_admin() ) : ?>
1136
+        <?php if (is_admin()) : ?>
1137 1137
 
1138 1138
             <p class="meta px-4 py-2">
1139
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1139
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1140 1140
                     <?php
1141 1141
                         printf(
1142
-                            esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ),
1143
-                            esc_html( $note->comment_author ),
1144
-                            esc_html( getpaid_format_date_value( $note->comment_date ) ),
1145
-                            esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) )
1142
+                            esc_html__('%1$s - %2$s at %3$s', 'invoicing'),
1143
+                            esc_html($note->comment_author),
1144
+                            esc_html(getpaid_format_date_value($note->comment_date)),
1145
+                            esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date)))
1146 1146
                         );
1147 1147
                     ?>
1148 1148
                 </abbr>&nbsp;&nbsp;
1149
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1150
-                    <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a>
1149
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1150
+                    <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a>
1151 1151
                 <?php } ?>
1152 1152
             </p>
1153 1153
 
@@ -1156,10 +1156,10 @@  discard block
 block discarded – undo
1156 1156
     </li>
1157 1157
     <?php
1158 1158
     $note_content = ob_get_clean();
1159
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1159
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1160 1160
 
1161
-    if ( $echo ) {
1162
-        echo wp_kses_post( $note_content );
1161
+    if ($echo) {
1162
+        echo wp_kses_post($note_content);
1163 1163
     } else {
1164 1164
         return $note_content;
1165 1165
     }
@@ -1172,43 +1172,43 @@  discard block
 block discarded – undo
1172 1172
  * @return string
1173 1173
  */
1174 1174
 function wpinv_get_policy_text() {
1175
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1175
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1176 1176
 
1177
-    $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) );
1177
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1178 1178
 
1179
-    if ( ! $privacy_page_id ) {
1180
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1179
+    if (!$privacy_page_id) {
1180
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1181 1181
     }
1182 1182
 
1183
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1183
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1184 1184
 
1185 1185
     $find_replace = array(
1186 1186
         '[wpinv_privacy_policy]' => $privacy_link,
1187 1187
     );
1188 1188
 
1189
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1189
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1190 1190
 
1191
-    return wp_kses_post( wpautop( $privacy_text ) );
1191
+    return wp_kses_post(wpautop($privacy_text));
1192 1192
 }
1193 1193
 
1194 1194
 function wpinv_oxygen_fix_conflict() {
1195 1195
     global $ct_ignore_post_types;
1196 1196
 
1197
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1197
+    if (!is_array($ct_ignore_post_types)) {
1198 1198
         $ct_ignore_post_types = array();
1199 1199
     }
1200 1200
 
1201
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' );
1201
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form');
1202 1202
 
1203
-    foreach ( $post_types as $post_type ) {
1203
+    foreach ($post_types as $post_type) {
1204 1204
         $ct_ignore_post_types[] = $post_type;
1205 1205
 
1206 1206
         // Ignore post type
1207
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1207
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1208 1208
     }
1209 1209
 
1210
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1211
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1210
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1211
+    add_filter('template_include', 'wpinv_template', 999, 1);
1212 1212
 }
1213 1213
 
1214 1214
 /**
@@ -1216,10 +1216,10 @@  discard block
 block discarded – undo
1216 1216
  *
1217 1217
  * @param GetPaid_Payment_Form $form
1218 1218
  */
1219
-function getpaid_display_payment_form( $form ) {
1219
+function getpaid_display_payment_form($form) {
1220 1220
 
1221
-    if ( is_numeric( $form ) ) {
1222
-        $form = new GetPaid_Payment_Form( $form );
1221
+    if (is_numeric($form)) {
1222
+        $form = new GetPaid_Payment_Form($form);
1223 1223
     }
1224 1224
 
1225 1225
     $form->display();
@@ -1229,61 +1229,61 @@  discard block
 block discarded – undo
1229 1229
 /**
1230 1230
  * Helper function to display a item payment form on the frontend.
1231 1231
  */
1232
-function getpaid_display_item_payment_form( $items ) {
1232
+function getpaid_display_item_payment_form($items) {
1233 1233
 
1234
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1235
-    $form->set_items( $items );
1234
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1235
+    $form->set_items($items);
1236 1236
 
1237
-    if ( 0 == count( $form->get_items() ) ) {
1237
+    if (0 == count($form->get_items())) {
1238 1238
         aui()->alert(
1239 1239
 			array(
1240 1240
 				'type'    => 'warning',
1241
-				'content' => __( 'No published items found', 'invoicing' ),
1241
+				'content' => __('No published items found', 'invoicing'),
1242 1242
             ),
1243 1243
             true
1244 1244
         );
1245 1245
         return;
1246 1246
     }
1247 1247
 
1248
-    $extra_items     = esc_attr( getpaid_convert_items_to_string( $items ) );
1249
-    $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
1248
+    $extra_items     = esc_attr(getpaid_convert_items_to_string($items));
1249
+    $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
1250 1250
     $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
1251 1251
     $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
1252 1252
 
1253
-    $form->display( $extra_items );
1253
+    $form->display($extra_items);
1254 1254
 }
1255 1255
 
1256 1256
 /**
1257 1257
  * Helper function to display an invoice payment form on the frontend.
1258 1258
  */
1259
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1259
+function getpaid_display_invoice_payment_form($invoice_id) {
1260 1260
 
1261
-    $invoice = wpinv_get_invoice( $invoice_id );
1261
+    $invoice = wpinv_get_invoice($invoice_id);
1262 1262
 
1263
-    if ( empty( $invoice ) ) {
1263
+    if (empty($invoice)) {
1264 1264
 		aui()->alert(
1265 1265
 			array(
1266 1266
 				'type'    => 'warning',
1267
-				'content' => __( 'Invoice not found', 'invoicing' ),
1267
+				'content' => __('Invoice not found', 'invoicing'),
1268 1268
             ),
1269 1269
             true
1270 1270
         );
1271 1271
         return;
1272 1272
     }
1273 1273
 
1274
-    if ( $invoice->is_paid() ) {
1274
+    if ($invoice->is_paid()) {
1275 1275
 		aui()->alert(
1276 1276
 			array(
1277 1277
 				'type'    => 'warning',
1278
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1278
+				'content' => __('Invoice has already been paid', 'invoicing'),
1279 1279
             ),
1280 1280
             true
1281 1281
         );
1282 1282
         return;
1283 1283
     }
1284 1284
 
1285
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1286
-    $form->set_items( $invoice->get_items() );
1285
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1286
+    $form->set_items($invoice->get_items());
1287 1287
 
1288 1288
     $form->display();
1289 1289
 }
@@ -1291,25 +1291,25 @@  discard block
 block discarded – undo
1291 1291
 /**
1292 1292
  * Helper function to convert item string to array.
1293 1293
  */
1294
-function getpaid_convert_items_to_array( $items ) {
1295
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1294
+function getpaid_convert_items_to_array($items) {
1295
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1296 1296
     $prepared = array();
1297 1297
 
1298
-    foreach ( $items as $item ) {
1299
-        $data = array_map( 'trim', explode( '|', $item ) );
1298
+    foreach ($items as $item) {
1299
+        $data = array_map('trim', explode('|', $item));
1300 1300
 
1301
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1301
+        if (empty($data[0]) || !is_numeric($data[0])) {
1302 1302
             continue;
1303 1303
         }
1304 1304
 
1305 1305
         $quantity = 1;
1306
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1306
+        if (isset($data[1]) && is_numeric($data[1])) {
1307 1307
             $quantity = (float) $data[1];
1308 1308
         }
1309 1309
 
1310 1310
         // WPML support.
1311
-        $item_id              = apply_filters( 'wpml_object_id', $data[0], 'wpi_item', true );
1312
-        $prepared[ $item_id ] = $quantity;
1311
+        $item_id              = apply_filters('wpml_object_id', $data[0], 'wpi_item', true);
1312
+        $prepared[$item_id] = $quantity;
1313 1313
 
1314 1314
     }
1315 1315
 
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 /**
1320 1320
  * Helper function to convert item array to string.
1321 1321
  */
1322
-function getpaid_convert_items_to_string( $items ) {
1322
+function getpaid_convert_items_to_string($items) {
1323 1323
     $prepared = array();
1324 1324
 
1325
-    foreach ( $items as $item => $quantity ) {
1325
+    foreach ($items as $item => $quantity) {
1326 1326
         $prepared[] = "$item|$quantity";
1327 1327
     }
1328
-    return implode( ',', $prepared );
1328
+    return implode(',', $prepared);
1329 1329
 }
1330 1330
 
1331 1331
 /**
@@ -1333,21 +1333,21 @@  discard block
 block discarded – undo
1333 1333
  *
1334 1334
  * Provide a label and one of $form, $items or $invoice.
1335 1335
  */
1336
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1337
-    $label = sanitize_text_field( $label );
1336
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1337
+    $label = sanitize_text_field($label);
1338 1338
 
1339
-    if ( ! empty( $form ) ) {
1340
-        $form  = esc_attr( $form );
1339
+    if (!empty($form)) {
1340
+        $form = esc_attr($form);
1341 1341
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1342 1342
     }
1343 1343
 
1344
-	if ( ! empty( $items ) ) {
1345
-        $items  = esc_attr( $items );
1344
+	if (!empty($items)) {
1345
+        $items = esc_attr($items);
1346 1346
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1347 1347
     }
1348 1348
 
1349
-    if ( ! empty( $invoice ) ) {
1350
-        $invoice  = esc_attr( $invoice );
1349
+    if (!empty($invoice)) {
1350
+        $invoice = esc_attr($invoice);
1351 1351
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>";
1352 1352
     }
1353 1353
 
@@ -1358,17 +1358,17 @@  discard block
 block discarded – undo
1358 1358
  *
1359 1359
  * @param WPInv_Invoice $invoice
1360 1360
  */
1361
-function getpaid_the_invoice_description( $invoice ) {
1361
+function getpaid_the_invoice_description($invoice) {
1362 1362
     $description = $invoice->get_description();
1363 1363
 
1364
-    if ( empty( $description ) ) {
1364
+    if (empty($description)) {
1365 1365
         return;
1366 1366
     }
1367 1367
 
1368
-    echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>";
1368
+    echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post(wpautop($description)) . "</em></small>";
1369 1369
 }
1370
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1371
-add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 );
1370
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1371
+add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100);
1372 1372
 
1373 1373
 /**
1374 1374
  * Render element on a form.
@@ -1376,79 +1376,79 @@  discard block
 block discarded – undo
1376 1376
  * @param array $element
1377 1377
  * @param GetPaid_Payment_Form $form
1378 1378
  */
1379
-function getpaid_payment_form_element( $element, $form ) {
1379
+function getpaid_payment_form_element($element, $form) {
1380 1380
 
1381 1381
     // Set up the args.
1382
-    $element_type    = trim( $element['type'] );
1382
+    $element_type    = trim($element['type']);
1383 1383
     $element['form'] = $form;
1384
-    extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
1384
+    extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
1385 1385
 
1386 1386
     // Try to locate the appropriate template.
1387
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1387
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1388 1388
 
1389 1389
     // Abort if this is not our element.
1390
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1390
+    if (empty($located) || !file_exists($located)) {
1391 1391
         return;
1392 1392
     }
1393 1393
 
1394 1394
     // Generate the class and id of the element.
1395
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1396
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1395
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1396
+    $id            = isset($id) ? $id : uniqid('gp');
1397 1397
 
1398
-    $element_id    = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id;
1399
-    $query_value   = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1398
+    $element_id    = !empty($element['label']) ? sanitize_title($element['label']) : $id;
1399
+    $query_value   = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1400 1400
 
1401 1401
     $element_id    = 'getpaid-' . $element_id;
1402
-    if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) {
1403
-        $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ];
1402
+    if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) {
1403
+        $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()];
1404 1404
     }
1405 1405
 
1406 1406
     // Echo the opening wrapper.
1407
-    echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>";
1407
+    echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>";
1408 1408
 
1409 1409
     // Fires before displaying a given element type's content.
1410
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1410
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1411 1411
 
1412 1412
     // Include the template for the element.
1413 1413
     include $located;
1414 1414
 
1415 1415
     // Fires after displaying a given element type's content.
1416
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1416
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1417 1417
 
1418 1418
     // Echo the closing wrapper.
1419 1419
     echo '</div>';
1420 1420
 }
1421
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1421
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1422 1422
 
1423 1423
 /**
1424 1424
  * Render an element's edit page.
1425 1425
  *
1426 1426
  * @param WP_Post $post
1427 1427
  */
1428
-function getpaid_payment_form_edit_element_template( $post ) {
1428
+function getpaid_payment_form_edit_element_template($post) {
1429 1429
 
1430 1430
     // Retrieve all elements.
1431
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1431
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1432 1432
 
1433
-    foreach ( $all_elements as $element ) {
1433
+    foreach ($all_elements as $element) {
1434 1434
 
1435 1435
         // Try to locate the appropriate template.
1436
-        $element = esc_attr( sanitize_key( $element ) );
1437
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1436
+        $element = esc_attr(sanitize_key($element));
1437
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1438 1438
 
1439 1439
         // Continue if this is not our element.
1440
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1440
+        if (empty($located) || !file_exists($located)) {
1441 1441
             continue;
1442 1442
         }
1443 1443
 
1444 1444
         // Include the template for the element.
1445
-        echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">";
1445
+        echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">";
1446 1446
         include $located;
1447 1447
         echo '</div>';
1448 1448
     }
1449 1449
 
1450 1450
 }
1451
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1451
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1452 1452
 
1453 1453
 /**
1454 1454
  * Render an element's preview.
@@ -1457,27 +1457,27 @@  discard block
 block discarded – undo
1457 1457
 function getpaid_payment_form_render_element_preview_template() {
1458 1458
 
1459 1459
     // Retrieve all elements.
1460
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1460
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1461 1461
 
1462
-    foreach ( $all_elements as $element ) {
1462
+    foreach ($all_elements as $element) {
1463 1463
 
1464 1464
         // Try to locate the appropriate template.
1465
-        $element = sanitize_key( $element );
1466
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1465
+        $element = sanitize_key($element);
1466
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1467 1467
 
1468 1468
         // Continue if this is not our element.
1469
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1469
+        if (empty($located) || !file_exists($located)) {
1470 1470
             continue;
1471 1471
         }
1472 1472
 
1473 1473
         // Include the template for the element.
1474
-        echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">";
1474
+        echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">";
1475 1475
         include $located;
1476 1476
         echo '</div>';
1477 1477
     }
1478 1478
 
1479 1479
 }
1480
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1480
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1481 1481
 
1482 1482
 /**
1483 1483
  * Shows a list of gateways that support recurring payments.
@@ -1485,17 +1485,17 @@  discard block
 block discarded – undo
1485 1485
 function wpinv_get_recurring_gateways_text() {
1486 1486
     $gateways = array();
1487 1487
 
1488
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1489
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1490
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1488
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1489
+        if (wpinv_gateway_support_subscription($key)) {
1490
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1491 1491
         }
1492 1492
     }
1493 1493
 
1494
-    if ( empty( $gateways ) ) {
1495
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>';
1494
+    if (empty($gateways)) {
1495
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>';
1496 1496
     }
1497 1497
 
1498
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>';
1498
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>';
1499 1499
 
1500 1500
 }
1501 1501
 
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
  * @return GetPaid_Template
1506 1506
  */
1507 1507
 function getpaid_template() {
1508
-    return getpaid()->get( 'template' );
1508
+    return getpaid()->get('template');
1509 1509
 }
1510 1510
 
1511 1511
 /**
@@ -1514,8 +1514,8 @@  discard block
 block discarded – undo
1514 1514
  * @param array args
1515 1515
  * @return string
1516 1516
  */
1517
-function getpaid_paginate_links( $args ) {
1518
-    return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) );
1517
+function getpaid_paginate_links($args) {
1518
+    return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args));
1519 1519
 }
1520 1520
 
1521 1521
 /**
@@ -1525,22 +1525,22 @@  discard block
 block discarded – undo
1525 1525
  * @param string state
1526 1526
  * @return string
1527 1527
  */
1528
-function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) {
1528
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) {
1529 1529
 
1530
-    $states = wpinv_get_country_states( $country );
1531
-    $uniqid = uniqid( '_' );
1530
+    $states = wpinv_get_country_states($country);
1531
+    $uniqid = uniqid('_');
1532 1532
 
1533
-    if ( ! empty( $states ) ) {
1533
+    if (!empty($states)) {
1534 1534
 
1535 1535
         return aui()->select(
1536 1536
             array(
1537 1537
 				'options'          => $states,
1538
-				'name'             => esc_attr( $field_name ),
1539
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1540
-				'value'            => sanitize_text_field( $state ),
1538
+				'name'             => esc_attr($field_name),
1539
+				'id'               => sanitize_html_class($field_name) . $uniqid,
1540
+				'value'            => sanitize_text_field($state),
1541 1541
 				'placeholder'      => $placeholder,
1542 1542
 				'required'         => $required,
1543
-				'label'            => wp_kses_post( $label ),
1543
+				'label'            => wp_kses_post($label),
1544 1544
 				'label_type'       => 'vertical',
1545 1545
 				'help_text'        => $help_text,
1546 1546
 				'class'            => 'getpaid-address-field wpinv_state',
@@ -1557,14 +1557,14 @@  discard block
 block discarded – undo
1557 1557
 
1558 1558
     return aui()->input(
1559 1559
         array(
1560
-            'name'             => esc_attr( $field_name ),
1561
-            'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
+            'name'             => esc_attr($field_name),
1561
+            'id'               => sanitize_html_class($field_name) . $uniqid,
1562 1562
             'placeholder'      => $placeholder,
1563 1563
             'required'         => $required,
1564
-            'label'            => wp_kses_post( $label ),
1564
+            'label'            => wp_kses_post($label),
1565 1565
             'label_type'       => 'vertical',
1566 1566
             'help_text'        => $help_text,
1567
-            'value'            => sanitize_text_field( $state ),
1567
+            'value'            => sanitize_text_field($state),
1568 1568
             'class'            => 'getpaid-address-field wpinv_state',
1569 1569
             'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1570 1570
             'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
@@ -1583,16 +1583,16 @@  discard block
 block discarded – undo
1583 1583
  * @param array $element
1584 1584
  * @return string
1585 1585
  */
1586
-function getpaid_get_form_element_grid_class( $element ) {
1586
+function getpaid_get_form_element_grid_class($element) {
1587 1587
 
1588 1588
     $class = 'col-12';
1589
-    $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width'];
1589
+    $width = empty($element['grid_width']) ? 'full' : $element['grid_width'];
1590 1590
 
1591
-    if ( $width == 'half' ) {
1591
+    if ($width == 'half') {
1592 1592
         $class .= ' col-md-6';
1593 1593
     }
1594 1594
 
1595
-    if ( $width == 'third' ) {
1595
+    if ($width == 'third') {
1596 1596
         $class .= ' col-md-4';
1597 1597
     }
1598 1598
 
@@ -1607,15 +1607,15 @@  discard block
 block discarded – undo
1607 1607
  *
1608 1608
  * @return string
1609 1609
  */
1610
-function getpaid_embed_url( $payment_form = false, $items = false ) {
1610
+function getpaid_embed_url($payment_form = false, $items = false) {
1611 1611
 
1612 1612
     return add_query_arg(
1613 1613
         array(
1614 1614
             'getpaid_embed' => 1,
1615
-            'form'          => $payment_form ? absint( $payment_form ) : false,
1616
-            'item'          => $items ? urlencode( $items ) : false,
1615
+            'form'          => $payment_form ? absint($payment_form) : false,
1616
+            'item'          => $items ? urlencode($items) : false,
1617 1617
         ),
1618
-        home_url( 'index.php' )
1618
+        home_url('index.php')
1619 1619
     );
1620 1620
 
1621 1621
 }
@@ -1625,13 +1625,13 @@  discard block
 block discarded – undo
1625 1625
  *
1626 1626
  * @return string
1627 1627
  */
1628
-function getpaid_filter_embed_template( $template ) {
1628
+function getpaid_filter_embed_template($template) {
1629 1629
 
1630
-    if ( isset( $_GET['getpaid_embed'] ) ) {
1631
-        wpinv_get_template( 'payment-forms/embed.php' );
1630
+    if (isset($_GET['getpaid_embed'])) {
1631
+        wpinv_get_template('payment-forms/embed.php');
1632 1632
         exit;
1633 1633
     }
1634 1634
 
1635 1635
     return $template;
1636 1636
 }
1637
-add_filter( 'template_include', 'getpaid_filter_embed_template' );
1637
+add_filter('template_include', 'getpaid_filter_embed_template');
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-export.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Export Class.
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	public function display() {
20 20
 
21 21
 		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
22
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
23
+			$this->display_post_type_export($post_type);
24 24
 		}
25 25
 		$this->display_subscription_export();
26 26
 		echo '</div>';
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 * Retrieves the download url.
32 32
 	 *
33 33
 	 */
34
-	public function get_download_url( $post_type ) {
34
+	public function get_download_url($post_type) {
35 35
 
36 36
 		return wp_nonce_url(
37 37
 			add_query_arg(
38 38
 				array(
39 39
 					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
40
+					'post_type'            => urlencode($post_type),
41 41
 				)
42 42
 			),
43 43
 			'getpaid-nonce',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * Displays a single post type export card.
51 51
 	 *
52 52
 	 */
53
-	public function display_post_type_export( $post_type ) {
53
+	public function display_post_type_export($post_type) {
54 54
 
55 55
 		?>
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 					<strong>
62 62
 						<?php
63 63
 							printf(
64
-								esc_html__( 'Export %s', 'invoicing' ),
65
-								esc_html( getpaid_get_post_type_label( $post_type ) )
64
+								esc_html__('Export %s', 'invoicing'),
65
+								esc_html(getpaid_get_post_type_label($post_type))
66 66
 							);
67 67
 						?>
68 68
 					</strong>
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 				<div class="card-body">
72 72
 
73
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
73
+					<form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>">
74 74
 
75 75
 						<?php
76
-							$this->generate_from_date( $post_type );
77
-							$this->generate_to_date( $post_type );
78
-							$this->generate_post_status_select( $post_type );
79
-							$this->generate_file_type_select( $post_type );
80
-							submit_button( __( 'Download', 'invoicing' ) );
76
+							$this->generate_from_date($post_type);
77
+							$this->generate_to_date($post_type);
78
+							$this->generate_post_status_select($post_type);
79
+							$this->generate_file_type_select($post_type);
80
+							submit_button(__('Download', 'invoicing'));
81 81
 						?>
82 82
 
83 83
 					</form>
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 	 * Generates the from date input field.
96 96
 	 *
97 97
 	 */
98
-	public function generate_from_date( $post_type ) {
98
+	public function generate_from_date($post_type) {
99 99
 
100 100
 		aui()->input(
101 101
 			array(
102 102
 				'type'             => 'datepicker',
103
-				'id'               => esc_attr( "$post_type-from_date" ),
103
+				'id'               => esc_attr("$post_type-from_date"),
104 104
 				'name'             => 'from_date',
105
-				'label'            => __( 'From Date', 'invoicing' ),
105
+				'label'            => __('From Date', 'invoicing'),
106 106
 				'label_type'       => 'vertical',
107 107
 				'placeholder'      => 'YYYY-MM-DD',
108 108
 				'extra_attributes' => array(
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 	 * Generates the to date input field.
120 120
 	 *
121 121
 	 */
122
-	public function generate_to_date( $post_type ) {
122
+	public function generate_to_date($post_type) {
123 123
 
124 124
 		aui()->input(
125 125
 			array(
126 126
 				'type'             => 'datepicker',
127
-				'id'               => esc_attr( "$post_type-to_date" ),
127
+				'id'               => esc_attr("$post_type-to_date"),
128 128
 				'name'             => 'to_date',
129
-				'label'            => __( 'To Date', 'invoicing' ),
129
+				'label'            => __('To Date', 'invoicing'),
130 130
 				'label_type'       => 'vertical',
131 131
 				'placeholder'      => 'YYYY-MM-DD',
132 132
 				'extra_attributes' => array(
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 	 * Generates the to post status select field.
143 143
 	 *
144 144
 	 */
145
-	public function generate_post_status_select( $post_type ) {
145
+	public function generate_post_status_select($post_type) {
146 146
 
147
-		if ( 'subscriptions' === $post_type ) {
147
+		if ('subscriptions' === $post_type) {
148 148
 			$options = getpaid_get_subscription_statuses();
149 149
 		} else {
150
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
150
+			$options = wpinv_get_invoice_statuses(true, false, $post_type);
151 151
 		}
152 152
 
153 153
 		aui()->select(
154 154
 			array(
155 155
 				'name'        => 'status',
156
-				'id'          => esc_attr( "$post_type-status" ),
157
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
158
-				'label'       => __( 'Status', 'invoicing' ),
156
+				'id'          => esc_attr("$post_type-status"),
157
+				'placeholder' => __('All Statuses', 'invoicing'),
158
+				'label'       => __('Status', 'invoicing'),
159 159
 				'label_type'  => 'vertical',
160 160
 				'label_class' => 'd-block',
161 161
 				'options'     => $options,
@@ -169,21 +169,21 @@  discard block
 block discarded – undo
169 169
 	 * Generates the to file type select field.
170 170
 	 *
171 171
 	 */
172
-	public function generate_file_type_select( $post_type ) {
172
+	public function generate_file_type_select($post_type) {
173 173
 
174 174
 		aui()->select(
175 175
 			array(
176 176
 				'name'        => 'file_type',
177
-				'id'          => esc_attr( "$post_type-file_type" ),
178
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
179
-				'label'       => __( 'Export File', 'invoicing' ),
177
+				'id'          => esc_attr("$post_type-file_type"),
178
+				'placeholder' => __('Select File Type', 'invoicing'),
179
+				'label'       => __('Export File', 'invoicing'),
180 180
 				'label_type'  => 'vertical',
181 181
 				'label_class' => 'd-block',
182 182
 				'value'       => 'csv',
183 183
 				'options'     => array(
184
-					'csv'  => __( 'CSV', 'invoicing' ),
185
-					'xml'  => __( 'XML', 'invoicing' ),
186
-					'json' => __( 'JSON', 'invoicing' ),
184
+					'csv'  => __('CSV', 'invoicing'),
185
+					'xml'  => __('XML', 'invoicing'),
186
+					'json' => __('JSON', 'invoicing'),
187 187
 				),
188 188
 			),
189 189
 			true
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * Displays a field's markup.
196 196
 	 *
197 197
 	 */
198
-	public function display_markup( $markup ) {
198
+	public function display_markup($markup) {
199 199
 
200 200
 		echo wp_kses(
201 201
 			str_replace(
@@ -224,20 +224,20 @@  discard block
 block discarded – undo
224 224
 
225 225
 				<div class="card-header">
226 226
 					<strong>
227
-						<?php esc_html_e( 'Export Subscriptions', 'invoicing' ); ?>
227
+						<?php esc_html_e('Export Subscriptions', 'invoicing'); ?>
228 228
 					</strong>
229 229
 				</div>
230 230
 
231 231
 				<div class="card-body">
232 232
 
233
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
233
+					<form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>">
234 234
 
235 235
 						<?php
236
-							$this->generate_from_date( 'subscriptions' );
237
-							$this->generate_to_date( 'subscriptions' );
238
-							$this->generate_post_status_select( 'subscriptions' );
239
-							$this->generate_file_type_select( 'subscriptions' );
240
-							submit_button( __( 'Download', 'invoicing' ) );
236
+							$this->generate_from_date('subscriptions');
237
+							$this->generate_to_date('subscriptions');
238
+							$this->generate_post_status_select('subscriptions');
239
+							$this->generate_file_type_select('subscriptions');
240
+							submit_button(__('Download', 'invoicing'));
241 241
 						?>
242 242
 
243 243
 					</form>
Please login to merge, or discard this patch.