Passed
Push — master ( 9c638d...a63e48 )
by Brian
10:33
created
includes/gateways/class-getpaid-payment-gateway.php 1 patch
Spacing   +118 added lines, -118 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
  * Abstaract Payment Gateway class.
@@ -139,49 +139,49 @@  discard block
 block discarded – undo
139 139
 	public function __construct() {
140 140
 
141 141
 		// Register gateway.
142
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
142
+		add_filter('wpinv_payment_gateways', array($this, 'register_gateway'));
143 143
 
144
-		$this->enabled = wpinv_is_gateway_active( $this->id );
144
+		$this->enabled = wpinv_is_gateway_active($this->id);
145 145
 
146 146
 		// Enable Subscriptions.
147
-		if ( $this->supports( 'subscription' ) ) {
148
-			add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
147
+		if ($this->supports('subscription')) {
148
+			add_filter("wpinv_{$this->id}_support_subscription", '__return_true');
149 149
 		}
150 150
 
151 151
 		// Enable sandbox.
152
-		if ( $this->supports( 'sandbox' ) ) {
153
-			add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' );
152
+		if ($this->supports('sandbox')) {
153
+			add_filter("wpinv_{$this->id}_supports_sandbox", '__return_true');
154 154
 		}
155 155
 
156 156
 		// Gateway settings.
157
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
157
+		add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings'));
158 158
 		
159 159
 
160 160
 		// Gateway checkout fiellds.
161
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
161
+		add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2);
162 162
 
163 163
 		// Process payment.
164
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
164
+		add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3);
165 165
 
166 166
 		// Change the checkout button text.
167
-		if ( ! empty( $this->checkout_button_text ) ) {
168
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
167
+		if (!empty($this->checkout_button_text)) {
168
+			add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button'));
169 169
 		}
170 170
 
171 171
 		// Check if a gateway is valid for a given currency.
172
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
172
+		add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2);
173 173
 
174 174
 		// Generate the transaction url.
175
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
175
+		add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2);
176 176
 
177 177
 		// Generate the subscription url.
178
-		add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
178
+		add_filter("getpaid_gateway_{$this->id}_subscription_url", array($this, 'filter_subscription_url'), 10, 2);
179 179
 
180 180
 		// Confirm payments.
181
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
181
+		add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2);
182 182
 
183 183
 		// Verify IPNs.
184
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
184
+		add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn'));
185 185
 
186 186
 	}
187 187
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @since 1.0.19
192 192
 	 * @return bool
193 193
 	 */
194
-	public function is( $gateway ) {
194
+	public function is($gateway) {
195 195
 		return $gateway == $this->id;
196 196
 	}
197 197
 
@@ -201,23 +201,23 @@  discard block
 block discarded – undo
201 201
 	 * @since 1.0.19
202 202
 	 * @return array
203 203
 	 */
204
-	public function get_tokens( $sandbox = null ) {
204
+	public function get_tokens($sandbox = null) {
205 205
 
206
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
207
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
206
+		if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) {
207
+			$tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true);
208 208
 
209
-			if ( is_array( $tokens ) ) {
209
+			if (is_array($tokens)) {
210 210
 				$this->tokens = $tokens;
211 211
 			}
212 212
 
213 213
 		}
214 214
 
215
-		if ( ! is_bool( $sandbox ) ) {
215
+		if (!is_bool($sandbox)) {
216 216
 			return $this->tokens;
217 217
 		}
218 218
 
219
-		$args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
220
-		return wp_list_filter( $this->tokens, $args );
219
+		$args = array('type' => $sandbox ? 'sandbox' : 'live');
220
+		return wp_list_filter($this->tokens, $args);
221 221
 
222 222
 	}
223 223
 
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @since 1.0.19
228 228
 	 */
229
-	public function save_token( $token ) {
229
+	public function save_token($token) {
230 230
 
231 231
 		$tokens   = $this->get_tokens();
232 232
 		$tokens[] = $token;
233 233
 
234
-		update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
234
+		update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens);
235 235
 
236 236
 		$this->tokens = $tokens;
237 237
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return string
244 244
 	 */
245 245
 	public function get_method_title() {
246
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
246
+		return apply_filters('getpaid_gateway_method_title', $this->method_title, $this);
247 247
 	}
248 248
 
249 249
 	/**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @return string
253 253
 	 */
254 254
 	public function get_method_description() {
255
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
255
+		return apply_filters('getpaid_gateway_method_description', $this->method_description, $this);
256 256
 	}
257 257
 
258 258
 	/**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @param WPInv_Invoice $invoice Invoice object.
262 262
 	 * @return string
263 263
 	 */
264
-	public function get_return_url( $invoice ) {
264
+	public function get_return_url($invoice) {
265 265
 
266 266
 		// Payment success url
267 267
 		$return_url = add_query_arg(
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			wpinv_get_success_page_uri()
274 274
 		);
275 275
 
276
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
276
+		return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this);
277 277
 	}
278 278
 
279 279
 	/**
@@ -282,24 +282,24 @@  discard block
 block discarded – undo
282 282
 	 * @param string $content Success page content.
283 283
 	 * @return string
284 284
 	 */
285
-	public function confirm_payment( $content ) {
285
+	public function confirm_payment($content) {
286 286
 
287 287
 		// Retrieve the invoice.
288 288
 		$invoice_id = getpaid_get_current_invoice_id();
289
-		$invoice    = wpinv_get_invoice( $invoice_id );
289
+		$invoice    = wpinv_get_invoice($invoice_id);
290 290
 
291 291
 		// Ensure that it exists and that it is pending payment.
292
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
292
+		if (empty($invoice_id) || !$invoice->needs_payment()) {
293 293
 			return $content;
294 294
 		}
295 295
 
296 296
 		// Can the user view this invoice??
297
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
297
+		if (!wpinv_user_can_view_invoice($invoice)) {
298 298
 			return $content;
299 299
 		}
300 300
 
301 301
 		// Show payment processing indicator.
302
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
302
+		return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice'));
303 303
 	}
304 304
 
305 305
 	/**
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
 	 * @param WPInv_Invoice $invoice Invoice object.
317 317
 	 * @return string transaction URL, or empty string.
318 318
 	 */
319
-	public function filter_transaction_url( $transaction_url, $invoice ) {
319
+	public function filter_transaction_url($transaction_url, $invoice) {
320 320
 
321
-		$transaction_id  = $invoice->get_transaction_id();
321
+		$transaction_id = $invoice->get_transaction_id();
322 322
 
323
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
324
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
325
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
326
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
323
+		if (!empty($this->view_transaction_url) && !empty($transaction_id)) {
324
+			$transaction_url = sprintf($this->view_transaction_url, $transaction_id);
325
+			$replace         = $this->is_sandbox($invoice) ? 'sandbox' : '';
326
+			$transaction_url = str_replace('{sandbox}', $replace, $transaction_url);
327 327
 		}
328 328
 
329 329
 		return $transaction_url;
@@ -336,15 +336,15 @@  discard block
 block discarded – undo
336 336
 	 * @param WPInv_Invoice $invoice Invoice object.
337 337
 	 * @return string subscription URL, or empty string.
338 338
 	 */
339
-	public function filter_subscription_url( $subscription_url, $invoice ) {
339
+	public function filter_subscription_url($subscription_url, $invoice) {
340 340
 
341
-		$profile_id      = $invoice->get_subscription_id();
341
+		$profile_id = $invoice->get_subscription_id();
342 342
 
343
-		if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
343
+		if (!empty($this->view_subscription_url) && !empty($profile_id)) {
344 344
 
345
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
346
-			$replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
347
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
345
+			$subscription_url = sprintf($this->view_subscription_url, $profile_id);
346
+			$replace          = $this->is_sandbox($invoice) ? 'sandbox' : '';
347
+			$subscription_url = str_replace('{sandbox}', $replace, $subscription_url);
348 348
 
349 349
 		}
350 350
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 * @return bool
358 358
 	 */
359 359
 	public function is_available() {
360
-		return ! empty( $this->enabled );
360
+		return !empty($this->enabled);
361 361
 	}
362 362
 
363 363
 	/**
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @return string
367 367
 	 */
368 368
 	public function get_title() {
369
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
369
+		return apply_filters('getpaid_gateway_title', $this->title, $this);
370 370
 	}
371 371
 
372 372
 	/**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 * @return string
376 376
 	 */
377 377
 	public function get_description() {
378
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
378
+		return apply_filters('getpaid_gateway_description', $this->description, $this);
379 379
 	}
380 380
 
381 381
 	/**
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
388 388
 	 * @return void
389 389
 	 */
390
-	public function process_payment( $invoice, $submission_data, $submission ) {
390
+	public function process_payment($invoice, $submission_data, $submission) {
391 391
 		// Process the payment then either redirect to the success page or the gateway.
392
-		do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
392
+		do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission);
393 393
 	}
394 394
 
395 395
 	/**
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	 * @param  string $reason Refund reason.
404 404
 	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
405 405
 	 */
406
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
407
-		return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
406
+	public function process_refund($invoice, $amount = null, $reason = '') {
407
+		return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason);
408 408
 	}
409 409
 
410 410
 	/**
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 * @param int $invoice_id 0 or invoice id.
414 414
 	 * @param GetPaid_Payment_Form $form Current payment form.
415 415
 	 */
416
-	public function payment_fields( $invoice_id, $form ) {
417
-		do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
416
+	public function payment_fields($invoice_id, $form) {
417
+		do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form);
418 418
 	}
419 419
 
420 420
 	/**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * 
423 423
 	 * @param array $admin_settings
424 424
 	 */
425
-	public function admin_settings( $admin_settings ) {
425
+	public function admin_settings($admin_settings) {
426 426
 		return $admin_settings;
427 427
 	}
428 428
 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * 
432 432
 	 * @param string $option
433 433
 	 */
434
-	public function get_option( $option, $default = false ) {
435
-		return wpinv_get_option( $this->id . '_' . $option, $default );
434
+	public function get_option($option, $default = false) {
435
+		return wpinv_get_option($this->id . '_' . $option, $default);
436 436
 	}
437 437
 
438 438
 	/**
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 * @return bool True if the gateway supports the feature, false otherwise.
446 446
 	 * @since 1.0.19
447 447
 	 */
448
-	public function supports( $feature ) {
449
-		return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
448
+	public function supports($feature) {
449
+		return apply_filters('getpaid_payment_gateway_supports', in_array($feature, $this->supports), $feature, $this);
450 450
 	}
451 451
 
452 452
 	/**
@@ -454,36 +454,36 @@  discard block
 block discarded – undo
454 454
 	 * 
455 455
 	 * @param bool $save whether or not to display the save button.
456 456
 	 */
457
-    public function get_cc_form( $save = false ) {
457
+    public function get_cc_form($save = false) {
458 458
 
459 459
 		ob_start();
460 460
 
461
-        $id_prefix = esc_attr( uniqid( $this->id ) );
461
+        $id_prefix = esc_attr(uniqid($this->id));
462 462
 
463 463
         $months = array(
464
-            '01' => __( 'January', 'invoicing' ),
465
-            '02' => __( 'February', 'invoicing' ),
466
-            '03' => __( 'March', 'invoicing' ),
467
-            '04' => __( 'April', 'invoicing' ),
468
-            '05' => __( 'May', 'invoicing' ),
469
-            '06' => __( 'June', 'invoicing' ),
470
-            '07' => __( 'July', 'invoicing' ),
471
-            '08' => __( 'August', 'invoicing' ),
472
-            '09' => __( 'September', 'invoicing' ),
473
-            '10' => __( 'October', 'invoicing' ),
474
-            '11' => __( 'November', 'invoicing' ),
475
-            '12' => __( 'December', 'invoicing' ),
464
+            '01' => __('January', 'invoicing'),
465
+            '02' => __('February', 'invoicing'),
466
+            '03' => __('March', 'invoicing'),
467
+            '04' => __('April', 'invoicing'),
468
+            '05' => __('May', 'invoicing'),
469
+            '06' => __('June', 'invoicing'),
470
+            '07' => __('July', 'invoicing'),
471
+            '08' => __('August', 'invoicing'),
472
+            '09' => __('September', 'invoicing'),
473
+            '10' => __('October', 'invoicing'),
474
+            '11' => __('November', 'invoicing'),
475
+            '12' => __('December', 'invoicing'),
476 476
         );
477 477
 
478
-        $year  = (int) date( 'Y', current_time( 'timestamp' ) );
478
+        $year  = (int) date('Y', current_time('timestamp'));
479 479
         $years = array();
480 480
 
481
-        for ( $i = 0; $i <= 10; $i++ ) {
482
-            $years[ $year + $i ] = $year + $i;
481
+        for ($i = 0; $i <= 10; $i++) {
482
+            $years[$year + $i] = $year + $i;
483 483
         }
484 484
 
485 485
         ?>
486
-            <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1">
486
+            <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1">
487 487
 
488 488
 
489 489
                 <div class="getpaid-cc-card-inner">
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
                         <div class="col-12">
493 493
 
494 494
 							<div class="form-group">
495
-								<label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label>
495
+								<label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label>
496 496
 								<div class="input-group input-group-sm">
497 497
 									<div class="input-group-prepend ">
498 498
 										<span class="input-group-text">
499 499
 											<i class="fa fa-credit-card"></i>
500 500
 										</span>
501 501
 									</div>
502
-									<input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm">
502
+									<input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm">
503 503
 								</div>
504 504
 							</div>
505 505
 
@@ -507,17 +507,17 @@  discard block
 block discarded – undo
507 507
 
508 508
                         <div class="col-12">
509 509
                             <div class="form-group">
510
-                                <label><?php _e( 'Expiration', 'invoicing' ); ?></label>
510
+                                <label><?php _e('Expiration', 'invoicing'); ?></label>
511 511
                                 <div class="form-row">
512 512
 
513 513
                                     <div class="col">
514
-                                        <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]">
515
-                                            <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option>
514
+                                        <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]">
515
+                                            <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option>
516 516
 
517 517
                                             <?php
518
-                                                foreach ( $months as $key => $month ) {
519
-                                                    $key   = esc_attr( $key );
520
-                                                    $month = wpinv_clean( $month );
518
+                                                foreach ($months as $key => $month) {
519
+                                                    $key   = esc_attr($key);
520
+                                                    $month = wpinv_clean($month);
521 521
                                                     echo "<option value='$key'>$month</option>" . PHP_EOL;
522 522
                                                 }
523 523
                                             ?>
@@ -526,13 +526,13 @@  discard block
 block discarded – undo
526 526
                                     </div>
527 527
 
528 528
                                     <div class="col">
529
-                                        <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]">
530
-                                            <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option>
529
+                                        <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]">
530
+                                            <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option>
531 531
 
532 532
                                             <?php
533
-                                                foreach ( $years as $key => $year ) {
534
-                                                    $key   = esc_attr( $key );
535
-                                                    $year  = wpinv_clean( $year );
533
+                                                foreach ($years as $key => $year) {
534
+                                                    $key   = esc_attr($key);
535
+                                                    $year  = wpinv_clean($year);
536 536
                                                     echo "<option value='$key'>$year</option>" . PHP_EOL;
537 537
                                                 }
538 538
                                             ?>
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
                                     array(
551 551
                                         'name'              => $this->id . '[cc_cvv2]',
552 552
                                         'id'                => "$id_prefix-cc-cvv2",
553
-                                        'label'             => __( 'CCV', 'invoicing' ),
553
+                                        'label'             => __('CCV', 'invoicing'),
554 554
 										'label_type'        => 'vertical',
555 555
 										'class'             => 'form-control-sm',
556 556
                                     )
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 					
563 563
 					<?php
564 564
 
565
-						if ( $save ) {
565
+						if ($save) {
566 566
 							echo $this->save_payment_method_checkbox();
567 567
 						}
568 568
 
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @since 1.0.19
583 583
 	 */
584
-	public function new_payment_method_entry( $form ) {
584
+	public function new_payment_method_entry($form) {
585 585
 		echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>";
586 586
 	}
587 587
 
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 	 * @since 1.0.19
592 592
 	 */
593 593
 	public function saved_payment_methods() {
594
-		$html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
594
+		$html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">';
595 595
 
596
-		foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
597
-			$html .= $this->get_saved_payment_method_option_html( $token );
596
+		foreach ($this->get_tokens($this->is_sandbox()) as $token) {
597
+			$html .= $this->get_saved_payment_method_option_html($token);
598 598
 		}
599 599
 
600 600
 		$html .= $this->get_new_payment_method_option_html();
601 601
 		$html .= '</ul>';
602 602
 
603
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
603
+		echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this);
604 604
 	}
605 605
 
606 606
 	/**
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 * @param  array $token Payment Token.
611 611
 	 * @return string Generated payment method HTML
612 612
 	 */
613
-	public function get_saved_payment_method_option_html( $token ) {
613
+	public function get_saved_payment_method_option_html($token) {
614 614
 
615 615
 		return sprintf(
616 616
 			'<li class="getpaid-payment-method form-group">
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
 					<span>%3$s</span>
620 620
 				</label>
621 621
 			</li>',
622
-			esc_attr( $this->id ),
623
-			esc_attr( $token['id'] ),
624
-			esc_html( $token['name'] ),
625
-			checked( empty( $token['default'] ), false, false )
622
+			esc_attr($this->id),
623
+			esc_attr($token['id']),
624
+			esc_html($token['name']),
625
+			checked(empty($token['default']), false, false)
626 626
 		);
627 627
 
628 628
 	}
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 	 */
635 635
 	public function get_new_payment_method_option_html() {
636 636
 
637
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
637
+		$label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this);
638 638
 
639 639
 		return sprintf(
640 640
 			'<li class="getpaid-new-payment-method">
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
 					<span>%2$s</span>
644 644
 				</label>
645 645
 			</li>',
646
-			esc_attr( $this->id ),
647
-			esc_html( $label )
646
+			esc_attr($this->id),
647
+			esc_html($label)
648 648
 		);
649 649
 
650 650
 	}
@@ -663,8 +663,8 @@  discard block
 block discarded – undo
663 663
 					<span>%2$s</span>
664 664
 				</label>
665 665
 			</p>',
666
-			esc_attr( $this->id ),
667
-			esc_html__( 'Save payment method', 'invoicing' )
666
+			esc_attr($this->id),
667
+			esc_html__('Save payment method', 'invoicing')
668 668
 		);
669 669
 
670 670
 	}
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 	 *
675 675
 	 * @return array
676 676
 	 */
677
-	public function register_gateway( $gateways ) {
677
+	public function register_gateway($gateways) {
678 678
 
679
-		$gateways[ $this->id ] = array(
679
+		$gateways[$this->id] = array(
680 680
 
681 681
 			'admin_label'    => $this->method_title,
682 682
             'checkout_label' => $this->title,
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
695 695
 	 * @return bool
696 696
 	 */
697
-	public function is_sandbox( $invoice = null ) {
697
+	public function is_sandbox($invoice = null) {
698 698
 
699
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
699
+		if (!empty($invoice) && !$invoice->needs_payment()) {
700 700
 			return $invoice->get_mode() == 'test';
701 701
 		}
702 702
 
703
-		return wpinv_is_test_mode( $this->id );
703
+		return wpinv_is_test_mode($this->id);
704 704
 
705 705
 	}
706 706
 
@@ -718,15 +718,15 @@  discard block
 block discarded – undo
718 718
 	 *
719 719
 	 * @return bool
720 720
 	 */
721
-	public function validate_currency( $validation, $currency ) {
721
+	public function validate_currency($validation, $currency) {
722 722
 
723 723
 		// Required currencies.
724
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
724
+		if (!empty($this->currencies) && !in_array($currency, $this->currencies)) {
725 725
 			return false;
726 726
 		}
727 727
 
728 728
 		// Excluded currencies.
729
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
729
+		if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) {
730 730
 			return false;
731 731
 		}
732 732
 
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Please use GetPaid_Notification_Email_Sender
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /*
12 12
 |--------------------------------------------------------------------------
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Generates the email header.
19 19
  */
20
-function wpinv_email_header( $email_heading ) {
21
-    wpinv_get_template( 'emails/wpinv-email-header.php', compact( 'email_heading' ) );
20
+function wpinv_email_header($email_heading) {
21
+    wpinv_get_template('emails/wpinv-email-header.php', compact('email_heading'));
22 22
 }
23
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
23
+add_action('wpinv_email_header', 'wpinv_email_header');
24 24
 
25 25
 
26 26
 /**
27 27
  * Generates the email footer.
28 28
  */
29 29
 function wpinv_email_footer() {
30
-    wpinv_get_template( 'emails/wpinv-email-footer.php' );
30
+    wpinv_get_template('emails/wpinv-email-footer.php');
31 31
 }
32
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
32
+add_action('wpinv_email_footer', 'wpinv_email_footer');
33 33
 
34 34
 
35 35
 /**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
  * @param string $email_type
40 40
  * @param bool $sent_to_admin
41 41
  */
42
-function wpinv_email_invoice_details( $invoice,  $email_type, $sent_to_admin ) {
42
+function wpinv_email_invoice_details($invoice, $email_type, $sent_to_admin) {
43 43
 
44
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
45
-    wpinv_get_template( 'emails/invoice-details.php', $args );
44
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
45
+    wpinv_get_template('emails/invoice-details.php', $args);
46 46
 
47 47
 }
48
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
48
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
49 49
 
50 50
 /**
51 51
  * Display line items in emails.
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
  * @param string $email_type
55 55
  * @param bool $sent_to_admin
56 56
  */
57
-function wpinv_email_invoice_items( $invoice, $email_type, $sent_to_admin ) {
57
+function wpinv_email_invoice_items($invoice, $email_type, $sent_to_admin) {
58 58
 
59 59
     // Prepare line items.
60
-    $columns = getpaid_invoice_item_columns( $invoice );
61
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
60
+    $columns = getpaid_invoice_item_columns($invoice);
61
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
62 62
 
63 63
     // Load the template.
64
-    wpinv_get_template( 'emails/invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) );
64
+    wpinv_get_template('emails/invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin'));
65 65
 
66 66
 }
67
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
67
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
68 68
 
69 69
 
70 70
 /**
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
  * @param string $email_type
75 75
  * @param bool $sent_to_admin
76 76
  */
77
-function wpinv_email_billing_details( $invoice, $email_type, $sent_to_admin ) {
77
+function wpinv_email_billing_details($invoice, $email_type, $sent_to_admin) {
78 78
 
79
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
80
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', $args );
79
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
80
+    wpinv_get_template('emails/wpinv-email-billing-details.php', $args);
81 81
 
82 82
 }
83
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
83
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
84 84
 
85 85
 /**
86 86
  * Returns email css.
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
  */
89 89
 function getpaid_get_email_css() {
90 90
 
91
-    $css = wpinv_get_template_html( 'emails/wpinv-email-styles.php' );
92
-    return apply_filters( 'wpinv_email_styles', $css );
91
+    $css = wpinv_get_template_html('emails/wpinv-email-styles.php');
92
+    return apply_filters('wpinv_email_styles', $css);
93 93
 
94 94
 }
95 95
 
@@ -100,26 +100,26 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  * 
102 102
  */
103
-function wpinv_email_style_body( $content ) {
103
+function wpinv_email_style_body($content) {
104 104
 
105
-    if ( ! class_exists( 'DOMDocument' ) ) {
105
+    if (!class_exists('DOMDocument')) {
106 106
         return $content;
107 107
     }
108 108
 
109 109
     $css = getpaid_get_email_css();
110 110
 
111 111
     // include css inliner
112
-	if ( ! class_exists( 'Emogrifier' ) ) {
113
-		include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
112
+	if (!class_exists('Emogrifier')) {
113
+		include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
114 114
     }
115 115
 
116 116
     // Inline the css.
117 117
     try {
118
-        $emogrifier = new Emogrifier( $content, $css );
118
+        $emogrifier = new Emogrifier($content, $css);
119 119
         $_content   = $emogrifier->emogrify();
120 120
         $content    = $_content;
121
-    } catch ( Exception $e ) {
122
-        wpinv_error_log( $e->getMessage(), 'emogrifier' );
121
+    } catch (Exception $e) {
122
+        wpinv_error_log($e->getMessage(), 'emogrifier');
123 123
     }
124 124
 
125 125
     return $content;
@@ -128,37 +128,37 @@  discard block
 block discarded – undo
128 128
 
129 129
 // Backwards compatibility.
130 130
 function wpinv_init_transactional_emails() {
131
-    foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) {
132
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
131
+    foreach (apply_filters('wpinv_email_actions', array()) as $action) {
132
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
133 133
     }
134 134
 }
135
-add_action( 'init', 'wpinv_init_transactional_emails' );
135
+add_action('init', 'wpinv_init_transactional_emails');
136 136
 
137 137
 function wpinv_send_transactional_email() {
138 138
     $args       = func_get_args();
139 139
     $function   = current_filter() . '_notification';
140
-    do_action_ref_array( $function, $args );
140
+    do_action_ref_array($function, $args);
141 141
 }
142 142
 
143 143
 function wpinv_mail_get_from_address() {
144
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
145
-    return sanitize_email( $from_address );
144
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
145
+    return sanitize_email($from_address);
146 146
 }
147 147
 
148 148
 function wpinv_mail_get_from_name() {
149
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
150
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
149
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
150
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
151 151
 }
152 152
 
153
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
154
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
155
-    return ( $active ? true : false );
153
+function wpinv_mail_admin_bcc_active($mail_type = '') {
154
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
155
+    return ($active ? true : false);
156 156
 }
157 157
     
158
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
159
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
158
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
159
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
160 160
 
161
-    switch ( $email_type ) {
161
+    switch ($email_type) {
162 162
         case 'html' :
163 163
             $content_type = 'text/html';
164 164
             break;
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
  * @param array        $attachments Any files to attach to the email.
184 184
  * @param string|array $cc An email or array of extra emails to send a copy of the email to.
185 185
  */
186
-function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) {
186
+function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) {
187 187
 
188 188
     $mailer  = new GetPaid_Notification_Email_Sender();
189
-    $message = wpinv_email_style_body( $message );
190
-    $to      = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) );
189
+    $message = wpinv_email_style_body($message);
190
+    $to      = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc));
191 191
 
192 192
 	return $mailer->send(
193 193
         $to,
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
  * @return array
205 205
  */
206 206
 function wpinv_get_emails() {
207
-    return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) );
207
+    return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings'));
208 208
 }
209 209
 
210 210
 /**
@@ -213,172 +213,172 @@  discard block
 block discarded – undo
213 213
  * @param array $settings
214 214
  * @return array
215 215
  */
216
-function wpinv_settings_emails( $settings = array() ) {
217
-    $settings = array_merge( $settings, wpinv_get_emails() );
218
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
216
+function wpinv_settings_emails($settings = array()) {
217
+    $settings = array_merge($settings, wpinv_get_emails());
218
+    return apply_filters('wpinv_settings_get_emails', $settings);
219 219
 }
220
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
220
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
221 221
 
222 222
 /**
223 223
  * Filter email section names.
224 224
  * 
225 225
  */
226
-function wpinv_settings_sections_emails( $settings ) {
227
-    foreach  ( wpinv_get_emails() as $key => $email) {
228
-        $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key );
226
+function wpinv_settings_sections_emails($settings) {
227
+    foreach (wpinv_get_emails() as $key => $email) {
228
+        $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key);
229 229
     }
230 230
 
231 231
     return $settings;    
232 232
 }
233
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
233
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
234 234
 
235
-function wpinv_email_is_enabled( $email_type ) {
235
+function wpinv_email_is_enabled($email_type) {
236 236
     $emails = wpinv_get_emails();
237
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
237
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
238 238
 
239
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
239
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
240 240
 }
241 241
 
242
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
243
-    switch ( $email_type ) {
242
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
243
+    switch ($email_type) {
244 244
         case 'new_invoice':
245 245
         case 'cancelled_invoice':
246 246
         case 'failed_invoice':
247 247
             $recipient  = wpinv_get_admin_email();
248 248
         break;
249 249
         default:
250
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
251
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
250
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
251
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
252 252
         break;
253 253
     }
254 254
 
255
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
255
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
256 256
 }
257 257
 
258 258
 /**
259 259
  * Returns invoice CC recipients
260 260
  */
261
-function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) {
262
-    switch ( $email_type ) {
261
+function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) {
262
+    switch ($email_type) {
263 263
         case 'new_invoice':
264 264
         case 'cancelled_invoice':
265 265
         case 'failed_invoice':
266 266
             return array();
267 267
         break;
268 268
         default:
269
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
270
-            $recipient  = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true );
271
-            if ( empty( $recipient ) ) {
269
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
270
+            $recipient  = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true);
271
+            if (empty($recipient)) {
272 272
                 return array();
273 273
             }
274
-            return  array_filter( array_map( 'trim', explode( ',', $recipient ) ) );
274
+            return  array_filter(array_map('trim', explode(',', $recipient)));
275 275
         break;
276 276
     }
277 277
 
278 278
 }
279 279
 
280
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
281
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
282
-    $subject    = __( $subject, 'invoicing' );
280
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
281
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
282
+    $subject    = __($subject, 'invoicing');
283 283
 
284
-    $subject    = wpinv_email_format_text( $subject, $invoice );
284
+    $subject    = wpinv_email_format_text($subject, $invoice);
285 285
 
286
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
286
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
287 287
 }
288 288
 
289
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
290
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
291
-    $email_heading = __( $email_heading, 'invoicing' );
289
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
290
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
291
+    $email_heading = __($email_heading, 'invoicing');
292 292
 
293
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
293
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
294 294
 
295
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
295
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
296 296
 }
297 297
 
298
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
299
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
300
-    $content    = __( $content, 'invoicing' );
298
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
299
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
300
+    $content    = __($content, 'invoicing');
301 301
 
302
-    $content    = wpinv_email_format_text( $content, $invoice );
302
+    $content    = wpinv_email_format_text($content, $invoice);
303 303
 
304
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
304
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
305 305
 }
306 306
 
307
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
307
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
308 308
     $from_name = wpinv_mail_get_from_address();
309 309
     $from_email = wpinv_mail_get_from_address();
310 310
     
311
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
311
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
312 312
     
313
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
314
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
313
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
314
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
315 315
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
316 316
     
317
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
317
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
318 318
 }
319 319
 
320
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
320
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
321 321
     $attachments = array();
322 322
     
323
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
323
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
324 324
 }
325 325
 
326 326
 /**
327 327
  * Searches for and replaces certain placeholders in an email.
328 328
  */
329
-function wpinv_email_format_text( $content, $invoice ) {
329
+function wpinv_email_format_text($content, $invoice) {
330 330
 
331 331
     $replace_array = array(
332 332
         '{site_title}'      => wpinv_get_blogname(),
333
-        '{date}'            => getpaid_format_date( current_time( 'mysql' ) ),
333
+        '{date}'            => getpaid_format_date(current_time('mysql')),
334 334
     );
335 335
 
336
-    $invoice = new WPInv_Invoice( $invoice );
336
+    $invoice = new WPInv_Invoice($invoice);
337 337
 
338
-    if ( $invoice->get_id() ) {
338
+    if ($invoice->get_id()) {
339 339
 
340 340
         $replace_array = array_merge(
341 341
             $replace_array, 
342 342
             array(
343
-                '{name}'            => sanitize_text_field( $invoice->get_user_full_name() ),
344
-                '{full_name}'       => sanitize_text_field( $invoice->get_user_full_name() ),
345
-                '{first_name}'      => sanitize_text_field( $invoice->get_first_name() ),
346
-                '{last_name}'       => sanitize_text_field( $invoice->get_last_name() ),
347
-                '{email}'           => sanitize_email( $invoice->get_email() ),
348
-                '{invoice_number}'  => sanitize_text_field( $invoice->get_number() ),
349
-                '{invoice_total}'   => wpinv_price( wpinv_format_amount( $invoice->get_total( true ) ) ),
350
-                '{invoice_link}'    => esc_url( $invoice->get_view_url() ),
351
-                '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ),
352
-                '{invoice_date}'    => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ),
353
-                '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ),
354
-                '{invoice_quote}'   => sanitize_text_field( $invoice->get_type() ),
355
-                '{invoice_label}'   => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
356
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
343
+                '{name}'            => sanitize_text_field($invoice->get_user_full_name()),
344
+                '{full_name}'       => sanitize_text_field($invoice->get_user_full_name()),
345
+                '{first_name}'      => sanitize_text_field($invoice->get_first_name()),
346
+                '{last_name}'       => sanitize_text_field($invoice->get_last_name()),
347
+                '{email}'           => sanitize_email($invoice->get_email()),
348
+                '{invoice_number}'  => sanitize_text_field($invoice->get_number()),
349
+                '{invoice_total}'   => wpinv_price(wpinv_format_amount($invoice->get_total(true))),
350
+                '{invoice_link}'    => esc_url($invoice->get_view_url()),
351
+                '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()),
352
+                '{invoice_date}'    => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))),
353
+                '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))),
354
+                '{invoice_quote}'   => sanitize_text_field($invoice->get_type()),
355
+                '{invoice_label}'   => sanitize_text_field(ucfirst($invoice->get_type())),
356
+                '{is_was}'          => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
357 357
             )
358 358
         );
359 359
 
360 360
     }
361 361
 
362 362
     // Let third party plugins filter the arra.
363
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
363
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
364 364
 
365
-    foreach ( $replace_array as $key => $value ) {
366
-        $content = str_replace( $key, $value, $content );
365
+    foreach ($replace_array as $key => $value) {
366
+        $content = str_replace($key, $value, $content);
367 367
     }
368 368
 
369
-    return apply_filters( 'wpinv_email_content_replace', $content );
369
+    return apply_filters('wpinv_email_content_replace', $content);
370 370
 }
371 371
 
372 372
 
373
-function wpinv_email_wrap_message( $message ) {
373
+function wpinv_email_wrap_message($message) {
374 374
     // Buffer
375 375
     ob_start();
376 376
 
377
-    do_action( 'wpinv_email_header' );
377
+    do_action('wpinv_email_header');
378 378
 
379
-    echo wpautop( wptexturize( $message ) );
379
+    echo wpautop(wptexturize($message));
380 380
 
381
-    do_action( 'wpinv_email_footer' );
381
+    do_action('wpinv_email_footer');
382 382
 
383 383
     // Get contents
384 384
     $message = ob_get_clean();
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
     return $message;
387 387
 }
388 388
 
389
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) {
390
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
391
-        $date_format = get_option( 'date_format' );
392
-        $time_format = get_option( 'time_format' );
389
+function wpinv_add_notes_to_invoice_email($invoice, $email_type) {
390
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
391
+        $date_format = get_option('date_format');
392
+        $time_format = get_option('time_format');
393 393
         ?>
394 394
         <div id="wpinv-email-notes">
395
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
395
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
396 396
             <ol class="wpinv-notes-lists">
397 397
         <?php
398
-        foreach ( $invoice_notes as $note ) {
399
-            $note_time = strtotime( $note->comment_date );
398
+        foreach ($invoice_notes as $note) {
399
+            $note_time = strtotime($note->comment_date);
400 400
             ?>
401 401
             <li class="comment wpinv-note">
402
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
403
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
402
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
403
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
404 404
             </li>
405 405
             <?php
406 406
         }
@@ -409,4 +409,4 @@  discard block
 block discarded – undo
409 409
         <?php
410 410
     }
411 411
 }
412
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
412
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
Please login to merge, or discard this patch.
includes/deprecated-functions.php 1 patch
Spacing   +91 added lines, -91 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
  * @deprecated
@@ -19,48 +19,48 @@  discard block
 block discarded – undo
19 19
  * @deprecated
20 20
  */
21 21
 function wpinv_get_invoice_cart() {
22
-    return wpinv_get_invoice( getpaid_get_current_invoice_id() );
22
+    return wpinv_get_invoice(getpaid_get_current_invoice_id());
23 23
 }
24 24
 
25 25
 /**
26 26
  * @deprecated
27 27
  */
28
-function wpinv_get_invoice_description( $invoice ) {
29
-    $invoice = new WPInv_Invoice( $invoice );
28
+function wpinv_get_invoice_description($invoice) {
29
+    $invoice = new WPInv_Invoice($invoice);
30 30
     return $invoice->get_description();
31 31
 }
32 32
 
33 33
 /**
34 34
  * @deprecated
35 35
  */
36
-function wpinv_get_invoice_currency_code( $invoice ) {
37
-    $invoice = new WPInv_Invoice( $invoice );
36
+function wpinv_get_invoice_currency_code($invoice) {
37
+    $invoice = new WPInv_Invoice($invoice);
38 38
     return $invoice->get_currency();
39 39
 }
40 40
 
41 41
 /**
42 42
  * @deprecated
43 43
  */
44
-function wpinv_get_payment_user_email( $invoice ) {
45
-    $invoice = new WPInv_Invoice( $invoice );
44
+function wpinv_get_payment_user_email($invoice) {
45
+    $invoice = new WPInv_Invoice($invoice);
46 46
     return $invoice->get_email();
47 47
 }
48 48
 
49 49
 /**
50 50
  * @deprecated
51 51
  */
52
-function wpinv_get_user_id( $invoice ) {
53
-    $invoice = new WPInv_Invoice( $invoice );
52
+function wpinv_get_user_id($invoice) {
53
+    $invoice = new WPInv_Invoice($invoice);
54 54
     return $invoice->get_user_id();
55 55
 }
56 56
 
57 57
 /**
58 58
  * @deprecated
59 59
  */
60
-function wpinv_get_invoice_status( $invoice, $return_label = false ) {
61
-    $invoice = new WPInv_Invoice( $invoice );
60
+function wpinv_get_invoice_status($invoice, $return_label = false) {
61
+    $invoice = new WPInv_Invoice($invoice);
62 62
     
63
-    if ( $return_label ) {
63
+    if ($return_label) {
64 64
         return $invoice->get_status_nicename();
65 65
     }
66 66
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 /**
71 71
  * @deprecated
72 72
  */
73
-function wpinv_get_payment_gateway( $invoice, $return_label = false ) {
74
-    $invoice = new WPInv_Invoice( $invoice );
73
+function wpinv_get_payment_gateway($invoice, $return_label = false) {
74
+    $invoice = new WPInv_Invoice($invoice);
75 75
 
76
-    if ( $return_label ) {
76
+    if ($return_label) {
77 77
         return $invoice->get_gateway_title();
78 78
     }
79 79
 
@@ -83,75 +83,75 @@  discard block
 block discarded – undo
83 83
 /**
84 84
  * @deprecated
85 85
  */
86
-function wpinv_get_payment_gateway_name( $invoice ) {
87
-    return wpinv_get_payment_gateway( $invoice, true );
86
+function wpinv_get_payment_gateway_name($invoice) {
87
+    return wpinv_get_payment_gateway($invoice, true);
88 88
 }
89 89
 
90 90
 /**
91 91
  * @deprecated
92 92
  */
93
-function wpinv_get_payment_transaction_id( $invoice ) {
94
-    $invoice = new WPInv_Invoice( $invoice );
93
+function wpinv_get_payment_transaction_id($invoice) {
94
+    $invoice = new WPInv_Invoice($invoice);
95 95
     return $invoice->get_transaction_id();
96 96
 }
97 97
 
98 98
 /**
99 99
  * @deprecated
100 100
  */
101
-function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) {
102
-    $invoice = new WPInv_Invoice( $invoice_id );
103
-    return $invoice->get_meta( $meta_key, $single );
101
+function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) {
102
+    $invoice = new WPInv_Invoice($invoice_id);
103
+    return $invoice->get_meta($meta_key, $single);
104 104
 }
105 105
 
106 106
 /**
107 107
  * @deprecated
108 108
  */
109
-function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) {
110
-    $invoice = new WPInv_Invoice( $invoice_id );
111
-    return $invoice->update_meta_data( $meta_key, $meta_value );
109
+function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') {
110
+    $invoice = new WPInv_Invoice($invoice_id);
111
+    return $invoice->update_meta_data($meta_key, $meta_value);
112 112
 }
113 113
 
114 114
 /**
115 115
  * @deprecated
116 116
  */
117
-function wpinv_get_items( $invoice = 0 ) {
118
-    $invoice = new WPInv_Invoice( $invoice );
117
+function wpinv_get_items($invoice = 0) {
118
+    $invoice = new WPInv_Invoice($invoice);
119 119
     return $invoice->get_items();
120 120
 }
121 121
 
122 122
 /**
123 123
  * @deprecated
124 124
  */
125
-function wpinv_get_fees( $invoice = 0 ) {
126
-    $invoice = new WPInv_Invoice( $invoice );
125
+function wpinv_get_fees($invoice = 0) {
126
+    $invoice = new WPInv_Invoice($invoice);
127 127
     return $invoice->get_fees();
128 128
 }
129 129
 
130 130
 /**
131 131
  * @deprecated
132 132
  */
133
-function wpinv_get_invoice_ip( $invoice ) {
134
-    $invoice = new WPInv_Invoice( $invoice );
133
+function wpinv_get_invoice_ip($invoice) {
134
+    $invoice = new WPInv_Invoice($invoice);
135 135
     return $invoice->get_ip();
136 136
 }
137 137
 
138 138
 /**
139 139
  * @deprecated
140 140
  */
141
-function wpinv_get_invoice_user_info( $invoice ) {
142
-    $invoice = new WPInv_Invoice( $invoice );
141
+function wpinv_get_invoice_user_info($invoice) {
142
+    $invoice = new WPInv_Invoice($invoice);
143 143
     return $invoice->get_user_info();
144 144
 }
145 145
 
146 146
 /**
147 147
  * @deprecated
148 148
  */
149
-function wpinv_subtotal( $invoice = 0, $currency = false ) {
150
-    $invoice  = new WPInv_Invoice( $invoice );
149
+function wpinv_subtotal($invoice = 0, $currency = false) {
150
+    $invoice  = new WPInv_Invoice($invoice);
151 151
     $subtotal = $invoice->get_subtotal();
152 152
 
153
-    if ( $currency ) {
154
-        return wpinv_price( wpinv_format_amount( $subtotal ), $invoice->get_currency() );
153
+    if ($currency) {
154
+        return wpinv_price(wpinv_format_amount($subtotal), $invoice->get_currency());
155 155
     }
156 156
 
157 157
     return $subtotal;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 /**
161 161
  * @deprecated
162 162
  */
163
-function wpinv_tax( $invoice = 0, $currency = false ) {
164
-    $invoice  = new WPInv_Invoice( $invoice );
163
+function wpinv_tax($invoice = 0, $currency = false) {
164
+    $invoice  = new WPInv_Invoice($invoice);
165 165
     $tax      = $invoice->get_total_tax();
166 166
 
167
-    if ( $currency ) {
168
-        return wpinv_price( wpinv_format_amount( $tax ), $invoice->get_currency() );
167
+    if ($currency) {
168
+        return wpinv_price(wpinv_format_amount($tax), $invoice->get_currency());
169 169
     }
170 170
 
171 171
     return $tax;
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 /**
175 175
  * @deprecated
176 176
  */
177
-function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) {
178
-    $invoice  = new WPInv_Invoice( $invoice );
177
+function wpinv_discount($invoice = 0, $currency = false, $deprecated) {
178
+    $invoice  = new WPInv_Invoice($invoice);
179 179
     $discount = $invoice->get_total_discount();
180 180
 
181
-    if ( $currency ) {
182
-        return wpinv_price( wpinv_format_amount( $discount ), $invoice->get_currency() );
181
+    if ($currency) {
182
+        return wpinv_price(wpinv_format_amount($discount), $invoice->get_currency());
183 183
     }
184 184
 
185 185
     return $discount;
@@ -188,20 +188,20 @@  discard block
 block discarded – undo
188 188
 /**
189 189
  * @deprecated
190 190
  */
191
-function wpinv_discount_code( $invoice = 0 ) {
192
-    $invoice = new WPInv_Invoice( $invoice );
191
+function wpinv_discount_code($invoice = 0) {
192
+    $invoice = new WPInv_Invoice($invoice);
193 193
     return $invoice->get_discount_code();
194 194
 }
195 195
 
196 196
 /**
197 197
  * @deprecated
198 198
  */
199
-function wpinv_payment_total( $invoice = 0, $currency = false ) {
200
-    $invoice  = new WPInv_Invoice( $invoice );
199
+function wpinv_payment_total($invoice = 0, $currency = false) {
200
+    $invoice = new WPInv_Invoice($invoice);
201 201
     $total = $invoice->get_total();
202 202
 
203
-    if ( $currency ) {
204
-        return wpinv_price( wpinv_format_amount( $total ), $invoice->get_currency() );
203
+    if ($currency) {
204
+        return wpinv_price(wpinv_format_amount($total), $invoice->get_currency());
205 205
     }
206 206
 
207 207
     return $total;
@@ -210,51 +210,51 @@  discard block
 block discarded – undo
210 210
 /**
211 211
  * @deprecated
212 212
  */
213
-function wpinv_get_date_created( $invoice = 0, $format = '' ) {
214
-    $invoice = new WPInv_Invoice( $invoice );
213
+function wpinv_get_date_created($invoice = 0, $format = '') {
214
+    $invoice = new WPInv_Invoice($invoice);
215 215
 
216
-    $format         = ! empty( $format ) ? $format : get_option( 'date_format' );
216
+    $format         = !empty($format) ? $format : get_option('date_format');
217 217
     $date_created   = $invoice->get_created_date();
218 218
 
219
-    return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : '';
219
+    return empty($date_created) ? date_i18n($format, strtotime($date_created)) : '';
220 220
 }
221 221
 
222 222
 /**
223 223
  * @deprecated
224 224
  */
225
-function wpinv_get_invoice_date( $invoice = 0, $format = '' ) {
226
-    wpinv_get_date_created( $invoice, $format );
225
+function wpinv_get_invoice_date($invoice = 0, $format = '') {
226
+    wpinv_get_date_created($invoice, $format);
227 227
 }
228 228
 
229 229
 /**
230 230
  * @deprecated
231 231
  */
232
-function wpinv_get_invoice_vat_number( $invoice = 0 ) {
233
-    $invoice = new WPInv_Invoice( $invoice );
232
+function wpinv_get_invoice_vat_number($invoice = 0) {
233
+    $invoice = new WPInv_Invoice($invoice);
234 234
     return $invoice->get_vat_number();
235 235
 }
236 236
 
237 237
 /**
238 238
  * @deprecated
239 239
  */
240
-function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) {
241
-    $invoice = new WPInv_Invoice( $invoice );
242
-    return $invoice->add_note( $note, $user_type, $added_by_user, $system );
240
+function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) {
241
+    $invoice = new WPInv_Invoice($invoice);
242
+    return $invoice->add_note($note, $user_type, $added_by_user, $system);
243 243
 }
244 244
 
245 245
 /**
246 246
  * @deprecated
247 247
  */
248
-function wpinv_get_payment_key( $invoice = 0 ) {
249
-	$invoice = new WPInv_Invoice( $invoice );
248
+function wpinv_get_payment_key($invoice = 0) {
249
+	$invoice = new WPInv_Invoice($invoice);
250 250
     return $invoice->get_key();
251 251
 }
252 252
 
253 253
 /**
254 254
  * @deprecated
255 255
  */
256
-function wpinv_get_invoice_number( $invoice = 0 ) {
257
-    $invoice = new WPInv_Invoice( $invoice );
256
+function wpinv_get_invoice_number($invoice = 0) {
257
+    $invoice = new WPInv_Invoice($invoice);
258 258
     return $invoice->get_number();
259 259
 }
260 260
 
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 /**
402 402
  * @deprecated
403 403
  */
404
-function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) {    
405
-    $invoice = new WPInv_Invoice( $invoice );
406
-    return $invoice->update_status( $new_status );
404
+function wpinv_update_payment_status($invoice, $new_status = 'publish') {    
405
+    $invoice = new WPInv_Invoice($invoice);
406
+    return $invoice->update_status($new_status);
407 407
 }
408 408
 
409 409
 /**
@@ -456,22 +456,22 @@  discard block
 block discarded – undo
456 456
 /**
457 457
  * @deprecated
458 458
  */
459
-function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) {
459
+function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') {
460 460
 
461 461
     // Fetch the invoice.
462
-    $invoice = new WPInv_Invoice( $invoice_id );
462
+    $invoice = new WPInv_Invoice($invoice_id);
463 463
 
464
-    if ( 0 ==  $invoice->get_id() ) {
464
+    if (0 == $invoice->get_id()) {
465 465
         return false;
466 466
     }
467 467
 
468 468
     // Prepare the transaction id.
469
-    if ( empty( $transaction_id ) ) {
469
+    if (empty($transaction_id)) {
470 470
         $transaction_id = $invoice_id;
471 471
     }
472 472
 
473 473
     // Set the transaction id;
474
-    $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) );
474
+    $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice));
475 475
 
476 476
     // Save the invoice.
477 477
     return $invoice->save();
@@ -484,12 +484,12 @@  discard block
 block discarded – undo
484 484
  * @param WPInv_Invoice $invoice
485 485
  * @param string $gateway
486 486
  */
487
-function wpinv_send_to_gateway( $gateway, $invoice ) {
487
+function wpinv_send_to_gateway($gateway, $invoice) {
488 488
 
489 489
     $payment_data = array(
490 490
         'invoice_id'        => $invoice->get_id(),
491 491
         'items'             => $invoice->get_cart_details(),
492
-        'cart_discounts'    => array( $invoice->get_discount_code() ),
492
+        'cart_discounts'    => array($invoice->get_discount_code()),
493 493
         'fees'              => $invoice->get_total_fees(),
494 494
         'subtotal'          => $invoice->get_subtotal(),
495 495
         'discount'          => $invoice->get_total_discount(),
@@ -497,16 +497,16 @@  discard block
 block discarded – undo
497 497
         'price'             => $invoice->get_total(),
498 498
         'invoice_key'       => $invoice->get_key(),
499 499
         'user_email'        => $invoice->get_email(),
500
-        'date'              => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
500
+        'date'              => date('Y-m-d H:i:s', current_time('timestamp')),
501 501
         'user_info'         => $invoice->get_user_info(),
502
-        'post_data'         => stripslashes_deep( $_POST ),
502
+        'post_data'         => stripslashes_deep($_POST),
503 503
         'cart_details'      => $invoice->get_cart_details(),
504 504
         'gateway'           => $gateway,
505 505
         'card_info'         => array(),
506 506
         'gateway_nonce'     => wp_create_nonce('wpi-gateway'),
507 507
     );
508 508
 
509
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
509
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
510 510
 }
511 511
 
512 512
 /**
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
 /**
520 520
  * @deprecated
521 521
  */
522
-function wpinv_die( $message = '', $title = '', $status = 400 ) {
523
-    add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 );
524
-    add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 );
525
-    wp_die( $message, $title, array( 'response' => $status ));
522
+function wpinv_die($message = '', $title = '', $status = 400) {
523
+    add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3);
524
+    add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3);
525
+    wp_die($message, $title, array('response' => $status));
526 526
 }
527 527
 
528 528
 /**
@@ -640,14 +640,14 @@  discard block
 block discarded – undo
640 640
 /**
641 641
  * @deprecated
642 642
  */
643
-function wpinv_invoice_status_label( $status, $status_display = '' ) {
644
-    return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display );
643
+function wpinv_invoice_status_label($status, $status_display = '') {
644
+    return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display);
645 645
 }
646 646
 
647 647
 /**
648 648
  * @deprecated
649 649
  */
650
-function wpinv_clean_invoice_number( $number ) {
650
+function wpinv_clean_invoice_number($number) {
651 651
     return $number;
652 652
 }
653 653
 
@@ -852,12 +852,12 @@  discard block
 block discarded – undo
852 852
 /**
853 853
  * @deprecated
854 854
  */
855
-function wpinv_item_show_price( $item_id = 0, $echo = true ) {
855
+function wpinv_item_show_price($item_id = 0, $echo = true) {
856 856
 
857
-    if ( $echo ) {
858
-        echo wpinv_item_price( $item_id );
857
+    if ($echo) {
858
+        echo wpinv_item_price($item_id);
859 859
     } else {
860
-        return wpinv_item_price( $item_id );
860
+        return wpinv_item_price($item_id);
861 861
     }
862 862
 
863 863
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +464 added lines, -464 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, watermark, 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
-    return 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
+    return 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,56 +170,56 @@  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
 	$templates[] = $slug . '.php';
185 185
 
186 186
 	// Allow template parts to be filtered
187
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
188 188
 
189 189
 	// Return the part that is found
190
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+	return wpinv_locate_tmpl($templates, $load, false);
191 191
 }
192 192
 
193
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
193
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
194 194
 	// No file found yet
195 195
 	$located = false;
196 196
 
197 197
 	// Try to find a template file
198
-	foreach ( (array)$template_names as $template_name ) {
198
+	foreach ((array) $template_names as $template_name) {
199 199
 
200 200
 		// Continue if template is empty
201
-		if ( empty( $template_name ) )
201
+		if (empty($template_name))
202 202
 			continue;
203 203
 
204 204
 		// Trim off any slashes from the template name
205
-		$template_name = ltrim( $template_name, '/' );
205
+		$template_name = ltrim($template_name, '/');
206 206
 
207 207
 		// try locating this template file by looping through the template paths
208
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
208
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
209 209
 
210
-			if( file_exists( $template_path . $template_name ) ) {
210
+			if (file_exists($template_path . $template_name)) {
211 211
 				$located = $template_path . $template_name;
212 212
 				break;
213 213
 			}
214 214
 		}
215 215
 
216
-		if( !empty( $located ) ) {
216
+		if (!empty($located)) {
217 217
 			break;
218 218
 		}
219 219
 	}
220 220
 
221
-	if ( ( true == $load ) && ! empty( $located ) )
222
-		load_template( $located, $require_once );
221
+	if ((true == $load) && !empty($located))
222
+		load_template($located, $require_once);
223 223
 
224 224
 	return $located;
225 225
 }
@@ -228,155 +228,155 @@  discard block
 block discarded – undo
228 228
 	$template_dir = wpinv_get_theme_template_dir_name();
229 229
 
230 230
 	$file_paths = array(
231
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
232
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
231
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
232
+		10 => trailingslashit(get_template_directory()) . $template_dir,
233 233
 		100 => wpinv_get_templates_dir()
234 234
 	);
235 235
 
236
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
236
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
237 237
 
238 238
 	// sort the file paths based on priority
239
-	ksort( $file_paths, SORT_NUMERIC );
239
+	ksort($file_paths, SORT_NUMERIC);
240 240
 
241
-	return array_map( 'trailingslashit', $file_paths );
241
+	return array_map('trailingslashit', $file_paths);
242 242
 }
243 243
 
244 244
 function wpinv_checkout_meta_tags() {
245 245
 
246 246
 	$pages   = array();
247
-	$pages[] = wpinv_get_option( 'success_page' );
248
-	$pages[] = wpinv_get_option( 'failure_page' );
249
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
250
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
247
+	$pages[] = wpinv_get_option('success_page');
248
+	$pages[] = wpinv_get_option('failure_page');
249
+	$pages[] = wpinv_get_option('invoice_history_page');
250
+	$pages[] = wpinv_get_option('invoice_subscription_page');
251 251
 
252
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
252
+	if (!wpinv_is_checkout() && !is_page($pages)) {
253 253
 		return;
254 254
 	}
255 255
 
256 256
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
257 257
 }
258
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
258
+add_action('wp_head', 'wpinv_checkout_meta_tags');
259 259
 
260
-function wpinv_add_body_classes( $class ) {
261
-	$classes = (array)$class;
260
+function wpinv_add_body_classes($class) {
261
+	$classes = (array) $class;
262 262
 
263
-	if( wpinv_is_checkout() ) {
263
+	if (wpinv_is_checkout()) {
264 264
 		$classes[] = 'wpinv-checkout';
265 265
 		$classes[] = 'wpinv-page';
266 266
 	}
267 267
 
268
-	if( wpinv_is_success_page() ) {
268
+	if (wpinv_is_success_page()) {
269 269
 		$classes[] = 'wpinv-success';
270 270
 		$classes[] = 'wpinv-page';
271 271
 	}
272 272
 
273
-	if( wpinv_is_failed_transaction_page() ) {
273
+	if (wpinv_is_failed_transaction_page()) {
274 274
 		$classes[] = 'wpinv-failed-transaction';
275 275
 		$classes[] = 'wpinv-page';
276 276
 	}
277 277
 
278
-	if( wpinv_is_invoice_history_page() ) {
278
+	if (wpinv_is_invoice_history_page()) {
279 279
 		$classes[] = 'wpinv-history';
280 280
 		$classes[] = 'wpinv-page';
281 281
 	}
282 282
 
283
-	if( wpinv_is_subscriptions_history_page() ) {
283
+	if (wpinv_is_subscriptions_history_page()) {
284 284
 		$classes[] = 'wpinv-subscription';
285 285
 		$classes[] = 'wpinv-page';
286 286
 	}
287 287
 
288
-	if( wpinv_is_test_mode() ) {
288
+	if (wpinv_is_test_mode()) {
289 289
 		$classes[] = 'wpinv-test-mode';
290 290
 		$classes[] = 'wpinv-page';
291 291
 	}
292 292
 
293
-	return array_unique( $classes );
293
+	return array_unique($classes);
294 294
 }
295
-add_filter( 'body_class', 'wpinv_add_body_classes' );
295
+add_filter('body_class', 'wpinv_add_body_classes');
296 296
 
297
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
298
-    $args = array( 'nopaging' => true );
297
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
298
+    $args = array('nopaging' => true);
299 299
 
300
-    if ( ! empty( $status ) )
300
+    if (!empty($status))
301 301
         $args['post_status'] = $status;
302 302
 
303
-    $discounts = wpinv_get_discounts( $args );
303
+    $discounts = wpinv_get_discounts($args);
304 304
     $options   = array();
305 305
 
306
-    if ( $discounts ) {
307
-        foreach ( $discounts as $discount ) {
308
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
306
+    if ($discounts) {
307
+        foreach ($discounts as $discount) {
308
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
309 309
         }
310 310
     } else {
311
-        $options[0] = __( 'No discounts found', 'invoicing' );
311
+        $options[0] = __('No discounts found', 'invoicing');
312 312
     }
313 313
 
314
-    $output = wpinv_html_select( array(
314
+    $output = wpinv_html_select(array(
315 315
         'name'             => $name,
316 316
         'selected'         => $selected,
317 317
         'options'          => $options,
318 318
         'show_option_all'  => false,
319 319
         'show_option_none' => false,
320
-    ) );
320
+    ));
321 321
 
322 322
     return $output;
323 323
 }
324 324
 
325
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
326
-    $current     = date( 'Y' );
327
-    $start_year  = $current - absint( $years_before );
328
-    $end_year    = $current + absint( $years_after );
329
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
325
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
326
+    $current     = date('Y');
327
+    $start_year  = $current - absint($years_before);
328
+    $end_year    = $current + absint($years_after);
329
+    $selected    = empty($selected) ? date('Y') : $selected;
330 330
     $options     = array();
331 331
 
332
-    while ( $start_year <= $end_year ) {
333
-        $options[ absint( $start_year ) ] = $start_year;
332
+    while ($start_year <= $end_year) {
333
+        $options[absint($start_year)] = $start_year;
334 334
         $start_year++;
335 335
     }
336 336
 
337
-    $output = wpinv_html_select( array(
337
+    $output = wpinv_html_select(array(
338 338
         'name'             => $name,
339 339
         'selected'         => $selected,
340 340
         'options'          => $options,
341 341
         'show_option_all'  => false,
342 342
         'show_option_none' => false
343
-    ) );
343
+    ));
344 344
 
345 345
     return $output;
346 346
 }
347 347
 
348
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
348
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
349 349
 
350 350
     $options = array(
351
-        '1'  => __( 'January', 'invoicing' ),
352
-        '2'  => __( 'February', 'invoicing' ),
353
-        '3'  => __( 'March', 'invoicing' ),
354
-        '4'  => __( 'April', 'invoicing' ),
355
-        '5'  => __( 'May', 'invoicing' ),
356
-        '6'  => __( 'June', 'invoicing' ),
357
-        '7'  => __( 'July', 'invoicing' ),
358
-        '8'  => __( 'August', 'invoicing' ),
359
-        '9'  => __( 'September', 'invoicing' ),
360
-        '10' => __( 'October', 'invoicing' ),
361
-        '11' => __( 'November', 'invoicing' ),
362
-        '12' => __( 'December', 'invoicing' ),
351
+        '1'  => __('January', 'invoicing'),
352
+        '2'  => __('February', 'invoicing'),
353
+        '3'  => __('March', 'invoicing'),
354
+        '4'  => __('April', 'invoicing'),
355
+        '5'  => __('May', 'invoicing'),
356
+        '6'  => __('June', 'invoicing'),
357
+        '7'  => __('July', 'invoicing'),
358
+        '8'  => __('August', 'invoicing'),
359
+        '9'  => __('September', 'invoicing'),
360
+        '10' => __('October', 'invoicing'),
361
+        '11' => __('November', 'invoicing'),
362
+        '12' => __('December', 'invoicing'),
363 363
     );
364 364
 
365 365
     // If no month is selected, default to the current month
366
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
366
+    $selected = empty($selected) ? date('n') : $selected;
367 367
 
368
-    $output = wpinv_html_select( array(
368
+    $output = wpinv_html_select(array(
369 369
         'name'             => $name,
370 370
         'selected'         => $selected,
371 371
         'options'          => $options,
372 372
         'show_option_all'  => false,
373 373
         'show_option_none' => false
374
-    ) );
374
+    ));
375 375
 
376 376
     return $output;
377 377
 }
378 378
 
379
-function wpinv_html_select( $args = array() ) {
379
+function wpinv_html_select($args = array()) {
380 380
     $defaults = array(
381 381
         'options'          => array(),
382 382
         'name'             => null,
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         'selected'         => 0,
386 386
         'placeholder'      => null,
387 387
         'multiple'         => false,
388
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
389
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
388
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
389
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
390 390
         'data'             => array(),
391 391
         'onchange'         => null,
392 392
         'required'         => false,
@@ -394,74 +394,74 @@  discard block
 block discarded – undo
394 394
         'readonly'         => false,
395 395
     );
396 396
 
397
-    $args = wp_parse_args( $args, $defaults );
397
+    $args = wp_parse_args($args, $defaults);
398 398
 
399 399
     $data_elements = '';
400
-    foreach ( $args['data'] as $key => $value ) {
401
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
400
+    foreach ($args['data'] as $key => $value) {
401
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
402 402
     }
403 403
 
404
-    if( $args['multiple'] ) {
404
+    if ($args['multiple']) {
405 405
         $multiple = ' MULTIPLE';
406 406
     } else {
407 407
         $multiple = '';
408 408
     }
409 409
 
410
-    if( $args['placeholder'] ) {
410
+    if ($args['placeholder']) {
411 411
         $placeholder = $args['placeholder'];
412 412
     } else {
413 413
         $placeholder = '';
414 414
     }
415 415
     
416 416
     $options = '';
417
-    if( !empty( $args['onchange'] ) ) {
418
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
417
+    if (!empty($args['onchange'])) {
418
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
419 419
     }
420 420
     
421
-    if( !empty( $args['required'] ) ) {
421
+    if (!empty($args['required'])) {
422 422
         $options .= ' required="required"';
423 423
     }
424 424
     
425
-    if( !empty( $args['disabled'] ) ) {
425
+    if (!empty($args['disabled'])) {
426 426
         $options .= ' disabled';
427 427
     }
428 428
     
429
-    if( !empty( $args['readonly'] ) ) {
429
+    if (!empty($args['readonly'])) {
430 430
         $options .= ' readonly';
431 431
     }
432 432
 
433
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
434
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
433
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
434
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
435 435
 
436
-    if ( $args['show_option_all'] ) {
437
-        if( $args['multiple'] ) {
438
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
436
+    if ($args['show_option_all']) {
437
+        if ($args['multiple']) {
438
+            $selected = selected(true, in_array(0, $args['selected']), false);
439 439
         } else {
440
-            $selected = selected( $args['selected'], 0, false );
440
+            $selected = selected($args['selected'], 0, false);
441 441
         }
442
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
442
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
443 443
     }
444 444
 
445
-    if ( !empty( $args['options'] ) ) {
445
+    if (!empty($args['options'])) {
446 446
 
447
-        if ( $args['show_option_none'] ) {
448
-            if( $args['multiple'] ) {
449
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
447
+        if ($args['show_option_none']) {
448
+            if ($args['multiple']) {
449
+                $selected = selected(true, in_array("", $args['selected']), false);
450 450
             } else {
451
-                $selected = selected( $args['selected'] === "", true, false );
451
+                $selected = selected($args['selected'] === "", true, false);
452 452
             }
453
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
453
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
454 454
         }
455 455
 
456
-        foreach( $args['options'] as $key => $option ) {
456
+        foreach ($args['options'] as $key => $option) {
457 457
 
458
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
459
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
458
+            if ($args['multiple'] && is_array($args['selected'])) {
459
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
460 460
             } else {
461
-                $selected = selected( $args['selected'], $key, false );
461
+                $selected = selected($args['selected'], $key, false);
462 462
             }
463 463
 
464
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
464
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
465 465
         }
466 466
     }
467 467
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     return $output;
471 471
 }
472 472
 
473
-function wpinv_item_dropdown( $args = array() ) {
473
+function wpinv_item_dropdown($args = array()) {
474 474
     $defaults = array(
475 475
         'name'              => 'wpi_item',
476 476
         'id'                => 'wpi_item',
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
         'multiple'          => false,
479 479
         'selected'          => 0,
480 480
         'number'            => 100,
481
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
482
-        'data'              => array( 'search-type' => 'item' ),
481
+        'placeholder'       => __('Choose a item', 'invoicing'),
482
+        'data'              => array('search-type' => 'item'),
483 483
         'show_option_all'   => false,
484 484
         'show_option_none'  => false,
485 485
         'show_recurring'    => false,
486 486
     );
487 487
 
488
-    $args = wp_parse_args( $args, $defaults );
488
+    $args = wp_parse_args($args, $defaults);
489 489
 
490 490
     $item_args = array(
491 491
         'post_type'      => 'wpi_item',
@@ -494,44 +494,44 @@  discard block
 block discarded – undo
494 494
         'posts_per_page' => $args['number']
495 495
     );
496 496
 
497
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
497
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
498 498
 
499
-    $items      = get_posts( $item_args );
499
+    $items      = get_posts($item_args);
500 500
     $options    = array();
501
-    if ( $items ) {
502
-        foreach ( $items as $item ) {
503
-            $title = esc_html( $item->post_title );
501
+    if ($items) {
502
+        foreach ($items as $item) {
503
+            $title = esc_html($item->post_title);
504 504
             
505
-            if ( !empty( $args['show_recurring'] ) ) {
506
-                $title .= wpinv_get_item_suffix( $item->ID, false );
505
+            if (!empty($args['show_recurring'])) {
506
+                $title .= wpinv_get_item_suffix($item->ID, false);
507 507
             }
508 508
             
509
-            $options[ absint( $item->ID ) ] = $title;
509
+            $options[absint($item->ID)] = $title;
510 510
         }
511 511
     }
512 512
 
513 513
     // This ensures that any selected items are included in the drop down
514
-    if( is_array( $args['selected'] ) ) {
515
-        foreach( $args['selected'] as $item ) {
516
-            if( ! in_array( $item, $options ) ) {
517
-                $title = get_the_title( $item );
518
-                if ( !empty( $args['show_recurring'] ) ) {
519
-                    $title .= wpinv_get_item_suffix( $item, false );
514
+    if (is_array($args['selected'])) {
515
+        foreach ($args['selected'] as $item) {
516
+            if (!in_array($item, $options)) {
517
+                $title = get_the_title($item);
518
+                if (!empty($args['show_recurring'])) {
519
+                    $title .= wpinv_get_item_suffix($item, false);
520 520
                 }
521 521
                 $options[$item] = $title;
522 522
             }
523 523
         }
524
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
525
-        if ( ! in_array( $args['selected'], $options ) ) {
526
-            $title = get_the_title( $args['selected'] );
527
-            if ( !empty( $args['show_recurring'] ) ) {
528
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
524
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
525
+        if (!in_array($args['selected'], $options)) {
526
+            $title = get_the_title($args['selected']);
527
+            if (!empty($args['show_recurring'])) {
528
+                $title .= wpinv_get_item_suffix($args['selected'], false);
529 529
             }
530
-            $options[$args['selected']] = get_the_title( $args['selected'] );
530
+            $options[$args['selected']] = get_the_title($args['selected']);
531 531
         }
532 532
     }
533 533
 
534
-    $output = wpinv_html_select( array(
534
+    $output = wpinv_html_select(array(
535 535
         'name'             => $args['name'],
536 536
         'selected'         => $args['selected'],
537 537
         'id'               => $args['id'],
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         'show_option_all'  => $args['show_option_all'],
543 543
         'show_option_none' => $args['show_option_none'],
544 544
         'data'             => $args['data'],
545
-    ) );
545
+    ));
546 546
 
547 547
     return $output;
548 548
 }
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
     );
563 563
 
564 564
     $options = array();
565
-    if ( $items ) {
566
-        foreach ( $items as $item ) {
567
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
565
+    if ($items) {
566
+        foreach ($items as $item) {
567
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
568 568
         }
569 569
     }
570 570
 
571 571
     return $options;
572 572
 }
573 573
 
574
-function wpinv_html_checkbox( $args = array() ) {
574
+function wpinv_html_checkbox($args = array()) {
575 575
     $defaults = array(
576 576
         'name'     => null,
577 577
         'current'  => null,
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
         )
583 583
     );
584 584
 
585
-    $args = wp_parse_args( $args, $defaults );
585
+    $args = wp_parse_args($args, $defaults);
586 586
 
587
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
587
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
588 588
     $options = '';
589
-    if ( ! empty( $args['options']['disabled'] ) ) {
589
+    if (!empty($args['options']['disabled'])) {
590 590
         $options .= ' disabled="disabled"';
591
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
591
+    } elseif (!empty($args['options']['readonly'])) {
592 592
         $options .= ' readonly';
593 593
     }
594 594
 
595
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
595
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
596 596
 
597 597
     return $output;
598 598
 }
@@ -600,30 +600,30 @@  discard block
 block discarded – undo
600 600
 /**
601 601
  * Displays a hidden field.
602 602
  */
603
-function getpaid_hidden_field( $name, $value ) {
604
-    $name  = sanitize_text_field( $name );
605
-    $value = esc_attr( $value );
603
+function getpaid_hidden_field($name, $value) {
604
+    $name  = sanitize_text_field($name);
605
+    $value = esc_attr($value);
606 606
 
607 607
     echo "<input type='hidden' name='$name' value='$value' />";
608 608
 }
609 609
 
610
-function wpinv_html_text( $args = array() ) {
610
+function wpinv_html_text($args = array()) {
611 611
     // Backwards compatibility
612
-    if ( func_num_args() > 1 ) {
612
+    if (func_num_args() > 1) {
613 613
         $args = func_get_args();
614 614
 
615 615
         $name  = $args[0];
616
-        $value = isset( $args[1] ) ? $args[1] : '';
617
-        $label = isset( $args[2] ) ? $args[2] : '';
618
-        $desc  = isset( $args[3] ) ? $args[3] : '';
616
+        $value = isset($args[1]) ? $args[1] : '';
617
+        $label = isset($args[2]) ? $args[2] : '';
618
+        $desc  = isset($args[3]) ? $args[3] : '';
619 619
     }
620 620
 
621 621
     $defaults = array(
622 622
         'id'           => '',
623
-        'name'         => isset( $name )  ? $name  : 'text',
624
-        'value'        => isset( $value ) ? $value : null,
625
-        'label'        => isset( $label ) ? $label : null,
626
-        'desc'         => isset( $desc )  ? $desc  : null,
623
+        'name'         => isset($name) ? $name : 'text',
624
+        'value'        => isset($value) ? $value : null,
625
+        'label'        => isset($label) ? $label : null,
626
+        'desc'         => isset($desc) ? $desc : null,
627 627
         'placeholder'  => '',
628 628
         'class'        => 'regular-text',
629 629
         'disabled'     => false,
@@ -633,51 +633,51 @@  discard block
 block discarded – undo
633 633
         'data'         => false
634 634
     );
635 635
 
636
-    $args = wp_parse_args( $args, $defaults );
636
+    $args = wp_parse_args($args, $defaults);
637 637
 
638
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
638
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
639 639
     $options = '';
640
-    if( $args['required'] ) {
640
+    if ($args['required']) {
641 641
         $options .= ' required="required"';
642 642
     }
643
-    if( $args['readonly'] ) {
643
+    if ($args['readonly']) {
644 644
         $options .= ' readonly';
645 645
     }
646
-    if( $args['readonly'] ) {
646
+    if ($args['readonly']) {
647 647
         $options .= ' readonly';
648 648
     }
649 649
 
650 650
     $data = '';
651
-    if ( !empty( $args['data'] ) ) {
652
-        foreach ( $args['data'] as $key => $value ) {
653
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
651
+    if (!empty($args['data'])) {
652
+        foreach ($args['data'] as $key => $value) {
653
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
654 654
         }
655 655
     }
656 656
 
657
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
658
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
659
-    if ( ! empty( $args['desc'] ) ) {
660
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
657
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
658
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
659
+    if (!empty($args['desc'])) {
660
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
661 661
     }
662 662
 
663
-    $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 ) . '/>';
663
+    $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) . '/>';
664 664
 
665 665
     $output .= '</span>';
666 666
 
667 667
     return $output;
668 668
 }
669 669
 
670
-function wpinv_html_date_field( $args = array() ) {
671
-    if( empty( $args['class'] ) ) {
670
+function wpinv_html_date_field($args = array()) {
671
+    if (empty($args['class'])) {
672 672
         $args['class'] = 'wpiDatepicker';
673
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
673
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
674 674
         $args['class'] .= ' wpiDatepicker';
675 675
     }
676 676
 
677
-    return wpinv_html_text( $args );
677
+    return wpinv_html_text($args);
678 678
 }
679 679
 
680
-function wpinv_html_textarea( $args = array() ) {
680
+function wpinv_html_textarea($args = array()) {
681 681
     $defaults = array(
682 682
         'name'        => 'textarea',
683 683
         'value'       => null,
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
         'placeholder' => '',
689 689
     );
690 690
 
691
-    $args = wp_parse_args( $args, $defaults );
691
+    $args = wp_parse_args($args, $defaults);
692 692
 
693
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
693
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
694 694
     $disabled = '';
695
-    if( $args['disabled'] ) {
695
+    if ($args['disabled']) {
696 696
         $disabled = ' disabled="disabled"';
697 697
     }
698 698
 
699
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
700
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
701
-    $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>';
699
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
700
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
701
+    $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>';
702 702
 
703
-    if ( ! empty( $args['desc'] ) ) {
704
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
703
+    if (!empty($args['desc'])) {
704
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
705 705
     }
706 706
     $output .= '</span>';
707 707
 
708 708
     return $output;
709 709
 }
710 710
 
711
-function wpinv_html_ajax_user_search( $args = array() ) {
711
+function wpinv_html_ajax_user_search($args = array()) {
712 712
     $defaults = array(
713 713
         'name'        => 'user_id',
714 714
         'value'       => null,
715
-        'placeholder' => __( 'Enter username', 'invoicing' ),
715
+        'placeholder' => __('Enter username', 'invoicing'),
716 716
         'label'       => null,
717 717
         'desc'        => null,
718 718
         'class'       => '',
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
         'data'        => false
722 722
     );
723 723
 
724
-    $args = wp_parse_args( $args, $defaults );
724
+    $args = wp_parse_args($args, $defaults);
725 725
 
726 726
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
727 727
 
728 728
     $output  = '<span class="wpinv_user_search_wrap">';
729
-        $output .= wpinv_html_text( $args );
730
-        $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>';
729
+        $output .= wpinv_html_text($args);
730
+        $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>';
731 731
     $output .= '</span>';
732 732
 
733 733
     return $output;
@@ -743,20 +743,20 @@  discard block
 block discarded – undo
743 743
  * 
744 744
  * @param string $template the template that is currently being used.
745 745
  */
746
-function wpinv_template( $template ) {
746
+function wpinv_template($template) {
747 747
     global $post;
748 748
 
749
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
749
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
750 750
 
751 751
         // If the user can view this invoice, display it.
752
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
752
+        if (wpinv_user_can_view_invoice($post->ID)) {
753 753
 
754
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
754
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
755 755
 
756 756
         // Else display an error message.
757 757
         } else {
758 758
 
759
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
759
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
760 760
 
761 761
         }
762 762
 
@@ -764,46 +764,46 @@  discard block
 block discarded – undo
764 764
 
765 765
     return $template;
766 766
 }
767
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
767
+add_filter('template_include', 'wpinv_template', 10, 1);
768 768
 
769 769
 function wpinv_get_business_address() {
770 770
     $business_address   = wpinv_store_address();
771
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
771
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
772 772
     
773 773
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
774 774
     
775
-    return apply_filters( 'wpinv_get_business_address', $business_address );
775
+    return apply_filters('wpinv_get_business_address', $business_address);
776 776
 }
777 777
 
778 778
 /**
779 779
  * Displays the company address.
780 780
  */
781 781
 function wpinv_display_from_address() {
782
-    wpinv_get_template( 'invoice/company-address.php' );
782
+    wpinv_get_template('invoice/company-address.php');
783 783
 }
784
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
784
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
785 785
 
786
-function wpinv_watermark( $id = 0 ) {
787
-    $output = wpinv_get_watermark( $id );
788
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
786
+function wpinv_watermark($id = 0) {
787
+    $output = wpinv_get_watermark($id);
788
+    return apply_filters('wpinv_get_watermark', $output, $id);
789 789
 }
790 790
 
791
-function wpinv_get_watermark( $id ) {
792
-    if ( !$id > 0 ) {
791
+function wpinv_get_watermark($id) {
792
+    if (!$id > 0) {
793 793
         return NULL;
794 794
     }
795 795
 
796
-    $invoice = wpinv_get_invoice( $id );
796
+    $invoice = wpinv_get_invoice($id);
797 797
     
798
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
799
-        if ( $invoice->is_paid() ) {
800
-            return __( 'Paid', 'invoicing' );
798
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
799
+        if ($invoice->is_paid()) {
800
+            return __('Paid', 'invoicing');
801 801
         }
802
-        if ( $invoice->is_refunded() ) {
803
-            return __( 'Refunded', 'invoicing' );
802
+        if ($invoice->is_refunded()) {
803
+            return __('Refunded', 'invoicing');
804 804
         }
805
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
806
-            return __( 'Cancelled', 'invoicing' );
805
+        if ($invoice->has_status(array('wpi-cancelled'))) {
806
+            return __('Cancelled', 'invoicing');
807 807
         }
808 808
     }
809 809
     
@@ -813,30 +813,30 @@  discard block
 block discarded – undo
813 813
 /**
814 814
  * @deprecated
815 815
  */
816
-function wpinv_display_invoice_details( $invoice ) {
817
-    return getpaid_invoice_meta( $invoice );
816
+function wpinv_display_invoice_details($invoice) {
817
+    return getpaid_invoice_meta($invoice);
818 818
 }
819 819
 
820 820
 /**
821 821
  * Displays invoice meta.
822 822
  */
823
-function getpaid_invoice_meta( $invoice ) {
823
+function getpaid_invoice_meta($invoice) {
824 824
 
825
-    $invoice = new WPInv_Invoice( $invoice );
825
+    $invoice = new WPInv_Invoice($invoice);
826 826
 
827 827
     // Ensure that we have an invoice.
828
-    if ( 0 == $invoice->get_id() ) {
828
+    if (0 == $invoice->get_id()) {
829 829
         return;
830 830
     }
831 831
 
832 832
     // Get the invoice meta.
833
-    $meta = getpaid_get_invoice_meta( $invoice );
833
+    $meta = getpaid_get_invoice_meta($invoice);
834 834
 
835 835
     // Display the meta.
836
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
836
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
837 837
 
838 838
 }
839
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
839
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
840 840
 
841 841
 /**
842 842
  * Retrieves the address markup to use on Invoices.
@@ -848,29 +848,29 @@  discard block
 block discarded – undo
848 848
  * @param  string $separator How to separate address lines.
849 849
  * @return string
850 850
  */
851
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
851
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
852 852
 
853 853
     // Retrieve the address markup...
854
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
855
-    $format = wpinv_get_full_address_format( $country );
854
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
855
+    $format = wpinv_get_full_address_format($country);
856 856
 
857 857
     // ... and the replacements.
858
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
858
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
859 859
 
860
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
860
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
861 861
     
862 862
 	// Remove unavailable tags.
863
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
863
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
864 864
 
865 865
     // Clean up white space.
866
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
867
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
866
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
867
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
868 868
     
869 869
     // Break newlines apart and remove empty lines/trim commas and white space.
870
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
870
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
871 871
 
872 872
     // Add html breaks.
873
-	$formatted_address = implode( $separator, $formatted_address );
873
+	$formatted_address = implode($separator, $formatted_address);
874 874
 
875 875
 	// We're done!
876 876
 	return $formatted_address;
@@ -882,88 +882,88 @@  discard block
 block discarded – undo
882 882
  * 
883 883
  * @param WPInv_Invoice $invoice
884 884
  */
885
-function wpinv_display_to_address( $invoice = 0 ) {
886
-    if ( ! empty( $invoice ) ) {
887
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
885
+function wpinv_display_to_address($invoice = 0) {
886
+    if (!empty($invoice)) {
887
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
888 888
     }
889 889
 }
890
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
890
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
891 891
 
892 892
 
893 893
 /**
894 894
  * Displays invoice line items.
895 895
  */
896
-function wpinv_display_line_items( $invoice_id = 0 ) {
896
+function wpinv_display_line_items($invoice_id = 0) {
897 897
 
898 898
     // Prepare the invoice.
899
-    $invoice = new WPInv_Invoice( $invoice_id );
899
+    $invoice = new WPInv_Invoice($invoice_id);
900 900
 
901 901
     // Abort if there is no invoice.
902
-    if ( 0 == $invoice->get_id() ) {
902
+    if (0 == $invoice->get_id()) {
903 903
         return;
904 904
     }
905 905
 
906 906
     // Line item columns.
907
-    $columns = getpaid_invoice_item_columns( $invoice );
908
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
907
+    $columns = getpaid_invoice_item_columns($invoice);
908
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
909 909
 
910
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
910
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
911 911
 }
912
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
912
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
913 913
 
914 914
 /**
915 915
  * Displays invoice notices on invoices.
916 916
  */
917 917
 function wpinv_display_invoice_notice() {
918 918
 
919
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
920
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
919
+    $label  = wpinv_get_option('vat_invoice_notice_label');
920
+    $notice = wpinv_get_option('vat_invoice_notice');
921 921
 
922
-    if ( empty( $label ) && empty( $notice ) ) {
922
+    if (empty($label) && empty($notice)) {
923 923
         return;
924 924
     }
925 925
 
926 926
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
927 927
 
928
-    if ( ! empty( $label ) ) {
929
-        $label = sanitize_text_field( $label );
928
+    if (!empty($label)) {
929
+        $label = sanitize_text_field($label);
930 930
         echo "<h5>$label</h5>";
931 931
     }
932 932
 
933
-    if ( ! empty( $notice ) ) {
934
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
933
+    if (!empty($notice)) {
934
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
935 935
     }
936 936
 
937 937
     echo '</div>';
938 938
 }
939
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
939
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
940 940
 
941 941
 /**
942 942
  * @param WPInv_Invoice $invoice
943 943
  */
944
-function wpinv_display_invoice_notes( $invoice ) {
944
+function wpinv_display_invoice_notes($invoice) {
945 945
 
946 946
     // Retrieve the notes.
947
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
947
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
948 948
 
949 949
     // Abort if we have non.
950
-    if ( empty( $notes ) ) {
950
+    if (empty($notes)) {
951 951
         return;
952 952
     }
953 953
 
954 954
     // Echo the note.
955 955
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
956
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
956
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
957 957
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
958 958
 
959
-    foreach( $notes as $note ) {
960
-        wpinv_get_invoice_note_line_item( $note );
959
+    foreach ($notes as $note) {
960
+        wpinv_get_invoice_note_line_item($note);
961 961
     }
962 962
 
963 963
     echo '</ul>';
964 964
     echo '</div>';
965 965
 }
966
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
966
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
967 967
 
968 968
 /**
969 969
  * Loads scripts on our invoice templates.
@@ -971,32 +971,32 @@  discard block
 block discarded – undo
971 971
 function wpinv_display_style() {
972 972
 
973 973
     // Make sure that all scripts have been loaded.
974
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
975
-        do_action( 'wp_enqueue_scripts' );
974
+    if (!did_action('wp_enqueue_scripts')) {
975
+        do_action('wp_enqueue_scripts');
976 976
     }
977 977
 
978 978
     // Register the invoices style.
979
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
979
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
980 980
 
981 981
     // Load required styles
982
-    wp_print_styles( 'open-sans' );
983
-    wp_print_styles( 'wpinv-single-style' );
984
-    wp_print_styles( 'ayecode-ui' );
982
+    wp_print_styles('open-sans');
983
+    wp_print_styles('wpinv-single-style');
984
+    wp_print_styles('ayecode-ui');
985 985
 
986 986
     // Maybe load custom css.
987
-    $custom_css = wpinv_get_option( 'template_custom_css' );
987
+    $custom_css = wpinv_get_option('template_custom_css');
988 988
 
989
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
990
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
991
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
989
+    if (isset($custom_css) && !empty($custom_css)) {
990
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
991
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
992 992
         echo '<style type="text/css">';
993 993
         echo $custom_css;
994 994
         echo '</style>';
995 995
     }
996 996
 
997 997
 }
998
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
999
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
998
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
999
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1000 1000
 
1001 1001
 
1002 1002
 /**
@@ -1008,41 +1008,41 @@  discard block
 block discarded – undo
1008 1008
     // Retrieve the current invoice.
1009 1009
     $invoice_id = getpaid_get_current_invoice_id();
1010 1010
 
1011
-    if ( empty( $invoice_id ) ) {
1011
+    if (empty($invoice_id)) {
1012 1012
 
1013 1013
         return aui()->alert(
1014 1014
             array(
1015 1015
                 'type'    => 'warning',
1016
-                'content' => __( 'Invalid invoice', 'invoicing' ),
1016
+                'content' => __('Invalid invoice', 'invoicing'),
1017 1017
             )
1018 1018
         );
1019 1019
 
1020 1020
     }
1021 1021
 
1022 1022
     // Can the user view this invoice?
1023
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
1023
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
1024 1024
 
1025 1025
         return aui()->alert(
1026 1026
             array(
1027 1027
                 'type'    => 'warning',
1028
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1028
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1029 1029
             )
1030 1030
         );
1031 1031
 
1032 1032
     }
1033 1033
 
1034 1034
     // Ensure that it is not yet paid for.
1035
-    $invoice = new WPInv_Invoice( $invoice_id );
1035
+    $invoice = new WPInv_Invoice($invoice_id);
1036 1036
 
1037 1037
     // Maybe mark it as viewed.
1038
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1038
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1039 1039
 
1040
-    if ( $invoice->is_paid() ) {
1040
+    if ($invoice->is_paid()) {
1041 1041
 
1042 1042
         return aui()->alert(
1043 1043
             array(
1044 1044
                 'type'    => 'success',
1045
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1045
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1046 1046
             )
1047 1047
         );
1048 1048
 
@@ -1052,14 +1052,14 @@  discard block
 block discarded – undo
1052 1052
     $wpi_checkout_id = $invoice_id;
1053 1053
 
1054 1054
     // We'll display this invoice via the default form.
1055
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1055
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1056 1056
 
1057
-    if ( 0 == $form->get_id() ) {
1057
+    if (0 == $form->get_id()) {
1058 1058
 
1059 1059
         return aui()->alert(
1060 1060
             array(
1061 1061
                 'type'    => 'warning',
1062
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1062
+                'content' => __('Error loading the payment form', 'invoicing'),
1063 1063
             )
1064 1064
         );
1065 1065
 
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 
1068 1068
     // Set the invoice.
1069 1069
     $form->invoice = $invoice;
1070
-    $form->set_items( $invoice->get_items() );
1070
+    $form->set_items($invoice->get_items());
1071 1071
 
1072 1072
     // Generate the html.
1073 1073
     return $form->get_html();
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 }
1076 1076
 
1077 1077
 function wpinv_empty_cart_message() {
1078
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1078
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1079 1079
 }
1080 1080
 
1081 1081
 /**
@@ -1092,38 +1092,38 @@  discard block
 block discarded – undo
1092 1092
         )
1093 1093
     );
1094 1094
 }
1095
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1095
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1096 1096
 
1097
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1098
-    $invoice = wpinv_get_invoice( $invoice_id );
1097
+function wpinv_receipt_billing_address($invoice_id = 0) {
1098
+    $invoice = wpinv_get_invoice($invoice_id);
1099 1099
 
1100
-    if ( empty( $invoice ) ) {
1100
+    if (empty($invoice)) {
1101 1101
         return NULL;
1102 1102
     }
1103 1103
 
1104 1104
     $billing_details = $invoice->get_user_info();
1105
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1105
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1106 1106
 
1107 1107
     ob_start();
1108 1108
     ?>
1109 1109
     <table class="table table-bordered table-sm wpi-billing-details">
1110 1110
         <tbody>
1111 1111
             <tr class="wpi-receipt-name">
1112
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1113
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1112
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1113
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1114 1114
             </tr>
1115 1115
             <tr class="wpi-receipt-email">
1116
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1117
-                <td><?php echo $billing_details['email'] ;?></td>
1116
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1117
+                <td><?php echo $billing_details['email']; ?></td>
1118 1118
             </tr>
1119 1119
             <tr class="wpi-receipt-address">
1120
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1121
-                <td><?php echo $address_row ;?></td>
1120
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1121
+                <td><?php echo $address_row; ?></td>
1122 1122
             </tr>
1123
-            <?php if ( $billing_details['phone'] ) { ?>
1123
+            <?php if ($billing_details['phone']) { ?>
1124 1124
             <tr class="wpi-receipt-phone">
1125
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1126
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1125
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1126
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1127 1127
             </tr>
1128 1128
             <?php } ?>
1129 1129
         </tbody>
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
     <?php
1132 1132
     $output = ob_get_clean();
1133 1133
     
1134
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1134
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1135 1135
 
1136 1136
     echo $output;
1137 1137
 }
@@ -1139,66 +1139,66 @@  discard block
 block discarded – undo
1139 1139
 /**
1140 1140
  * Filters the receipt page.
1141 1141
  */
1142
-function wpinv_filter_success_page_content( $content ) {
1142
+function wpinv_filter_success_page_content($content) {
1143 1143
 
1144 1144
     // Ensure this is our page.
1145
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1145
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1146 1146
 
1147
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1148
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1147
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1148
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1149 1149
 
1150 1150
     }
1151 1151
 
1152 1152
     return $content;
1153 1153
 }
1154
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1154
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1155 1155
 
1156
-function wpinv_invoice_link( $invoice_id ) {
1157
-    $invoice = wpinv_get_invoice( $invoice_id );
1156
+function wpinv_invoice_link($invoice_id) {
1157
+    $invoice = wpinv_get_invoice($invoice_id);
1158 1158
 
1159
-    if ( empty( $invoice ) ) {
1159
+    if (empty($invoice)) {
1160 1160
         return NULL;
1161 1161
     }
1162 1162
 
1163
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1163
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1164 1164
 
1165
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1165
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1166 1166
 }
1167 1167
 
1168
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1169
-    if ( empty( $note ) ) {
1168
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1169
+    if (empty($note)) {
1170 1170
         return NULL;
1171 1171
     }
1172 1172
 
1173
-    if ( is_int( $note ) ) {
1174
-        $note = get_comment( $note );
1173
+    if (is_int($note)) {
1174
+        $note = get_comment($note);
1175 1175
     }
1176 1176
 
1177
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1177
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1178 1178
         return NULL;
1179 1179
     }
1180 1180
 
1181
-    $note_classes   = array( 'note' );
1182
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1181
+    $note_classes   = array('note');
1182
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1183 1183
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1184
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1185
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1184
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1185
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1186 1186
 
1187 1187
     ob_start();
1188 1188
     ?>
1189
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1189
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1190 1190
         <div class="note_content bg-light border position-relative p-4">
1191 1191
 
1192
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1192
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1193 1193
 
1194
-            <?php if ( ! is_admin() ) : ?>
1194
+            <?php if (!is_admin()) : ?>
1195 1195
                 <em class="meta position-absolute form-text">
1196 1196
                     <?php
1197 1197
                         printf(
1198
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1198
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1199 1199
                             $note->comment_author,
1200
-                            getpaid_format_date_value( $note->comment_date ),
1201
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1200
+                            getpaid_format_date_value($note->comment_date),
1201
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1202 1202
                         );
1203 1203
                     ?>
1204 1204
                 </em>
@@ -1206,21 +1206,21 @@  discard block
 block discarded – undo
1206 1206
 
1207 1207
         </div>
1208 1208
 
1209
-        <?php if ( is_admin() ) : ?>
1209
+        <?php if (is_admin()) : ?>
1210 1210
 
1211 1211
             <p class="meta px-4 py-2">
1212
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1212
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1213 1213
                     <?php
1214 1214
                         printf(
1215
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1215
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1216 1216
                             $note->comment_author,
1217
-                            getpaid_format_date_value( $note->comment_date ),
1218
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1217
+                            getpaid_format_date_value($note->comment_date),
1218
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1219 1219
                         );
1220 1220
                     ?>
1221 1221
                 </abbr>&nbsp;&nbsp;
1222
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1223
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1222
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1223
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1224 1224
                 <?php } ?>
1225 1225
             </p>
1226 1226
 
@@ -1229,9 +1229,9 @@  discard block
 block discarded – undo
1229 1229
     </li>
1230 1230
     <?php
1231 1231
     $note_content = ob_get_clean();
1232
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1232
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1233 1233
 
1234
-    if ( $echo ) {
1234
+    if ($echo) {
1235 1235
         echo $note_content;
1236 1236
     } else {
1237 1237
         return $note_content;
@@ -1241,36 +1241,36 @@  discard block
 block discarded – undo
1241 1241
 function wpinv_invalid_invoice_content() {
1242 1242
     global $post;
1243 1243
 
1244
-    $invoice = wpinv_get_invoice( $post->ID );
1244
+    $invoice = wpinv_get_invoice($post->ID);
1245 1245
 
1246
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1247
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1248
-        if ( is_user_logged_in() ) {
1249
-            if ( wpinv_require_login_to_checkout() ) {
1250
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1251
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1246
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1247
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1248
+        if (is_user_logged_in()) {
1249
+            if (wpinv_require_login_to_checkout()) {
1250
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1251
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1252 1252
                 }
1253 1253
             }
1254 1254
         } else {
1255
-            if ( wpinv_require_login_to_checkout() ) {
1256
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1257
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1255
+            if (wpinv_require_login_to_checkout()) {
1256
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1257
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1258 1258
                 }
1259 1259
             }
1260 1260
         }
1261 1261
     } else {
1262
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1262
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1263 1263
     }
1264 1264
     ?>
1265 1265
     <div class="row wpinv-row-invalid">
1266 1266
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1267
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1267
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1268 1268
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1269 1269
         </div>
1270 1270
     </div>
1271 1271
     <?php
1272 1272
 }
1273
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1273
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1274 1274
 
1275 1275
 /**
1276 1276
  * Function to get privacy policy text.
@@ -1279,21 +1279,21 @@  discard block
 block discarded – undo
1279 1279
  * @return string
1280 1280
  */
1281 1281
 function wpinv_get_policy_text() {
1282
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1282
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1283 1283
 
1284
-    $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]' ));
1284
+    $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]'));
1285 1285
 
1286
-    if(!$privacy_page_id){
1287
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1286
+    if (!$privacy_page_id) {
1287
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1288 1288
     }
1289 1289
 
1290
-    $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' );
1290
+    $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');
1291 1291
 
1292 1292
     $find_replace = array(
1293 1293
         '[wpinv_privacy_policy]' => $privacy_link,
1294 1294
     );
1295 1295
 
1296
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1296
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1297 1297
 
1298 1298
     return wp_kses_post(wpautop($privacy_text));
1299 1299
 }
@@ -1301,21 +1301,21 @@  discard block
 block discarded – undo
1301 1301
 function wpinv_oxygen_fix_conflict() {
1302 1302
     global $ct_ignore_post_types;
1303 1303
 
1304
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1304
+    if (!is_array($ct_ignore_post_types)) {
1305 1305
         $ct_ignore_post_types = array();
1306 1306
     }
1307 1307
 
1308
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1308
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1309 1309
 
1310
-    foreach ( $post_types as $post_type ) {
1310
+    foreach ($post_types as $post_type) {
1311 1311
         $ct_ignore_post_types[] = $post_type;
1312 1312
 
1313 1313
         // Ignore post type
1314
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1314
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1315 1315
     }
1316 1316
 
1317
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1318
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1317
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1318
+    add_filter('template_include', 'wpinv_template', 999, 1);
1319 1319
 }
1320 1320
 
1321 1321
 /**
@@ -1323,10 +1323,10 @@  discard block
 block discarded – undo
1323 1323
  * 
1324 1324
  * @param GetPaid_Payment_Form $form
1325 1325
  */
1326
-function getpaid_display_payment_form( $form ) {
1326
+function getpaid_display_payment_form($form) {
1327 1327
 
1328
-    if ( is_numeric( $form ) ) {
1329
-        $form = new GetPaid_Payment_Form( $form );
1328
+    if (is_numeric($form)) {
1329
+        $form = new GetPaid_Payment_Form($form);
1330 1330
     }
1331 1331
 
1332 1332
     $form->display();
@@ -1336,16 +1336,16 @@  discard block
 block discarded – undo
1336 1336
 /**
1337 1337
  * Helper function to display a item payment form on the frontend.
1338 1338
  */
1339
-function getpaid_display_item_payment_form( $items ) {
1339
+function getpaid_display_item_payment_form($items) {
1340 1340
 
1341
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1342
-    $form->set_items( $items );
1341
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1342
+    $form->set_items($items);
1343 1343
 
1344
-    if ( 0 == count( $form->get_items() ) ) {
1344
+    if (0 == count($form->get_items())) {
1345 1345
         echo aui()->alert(
1346 1346
 			array(
1347 1347
 				'type'    => 'warning',
1348
-				'content' => __( 'No published items found', 'invoicing' ),
1348
+				'content' => __('No published items found', 'invoicing'),
1349 1349
 			)
1350 1350
         );
1351 1351
         return;
@@ -1357,32 +1357,32 @@  discard block
 block discarded – undo
1357 1357
 /**
1358 1358
  * Helper function to display an invoice payment form on the frontend.
1359 1359
  */
1360
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1360
+function getpaid_display_invoice_payment_form($invoice_id) {
1361 1361
 
1362
-    $invoice = wpinv_get_invoice( $invoice_id );
1362
+    $invoice = wpinv_get_invoice($invoice_id);
1363 1363
 
1364
-    if ( empty( $invoice ) ) {
1364
+    if (empty($invoice)) {
1365 1365
 		echo aui()->alert(
1366 1366
 			array(
1367 1367
 				'type'    => 'warning',
1368
-				'content' => __( 'Invoice not found', 'invoicing' ),
1368
+				'content' => __('Invoice not found', 'invoicing'),
1369 1369
 			)
1370 1370
         );
1371 1371
         return;
1372 1372
     }
1373 1373
 
1374
-    if ( $invoice->is_paid() ) {
1374
+    if ($invoice->is_paid()) {
1375 1375
 		echo aui()->alert(
1376 1376
 			array(
1377 1377
 				'type'    => 'warning',
1378
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1378
+				'content' => __('Invoice has already been paid', 'invoicing'),
1379 1379
 			)
1380 1380
         );
1381 1381
         return;
1382 1382
     }
1383 1383
 
1384
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1385
-    $form->set_items( $invoice->get_items() );
1384
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1385
+    $form->set_items($invoice->get_items());
1386 1386
 
1387 1387
     $form->display();
1388 1388
 }
@@ -1390,23 +1390,23 @@  discard block
 block discarded – undo
1390 1390
 /**
1391 1391
  * Helper function to convert item string to array.
1392 1392
  */
1393
-function getpaid_convert_items_to_array( $items ) {
1394
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1393
+function getpaid_convert_items_to_array($items) {
1394
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1395 1395
     $prepared = array();
1396 1396
 
1397
-    foreach ( $items as $item ) {
1398
-        $data = array_map( 'trim', explode( '|', $item ) );
1397
+    foreach ($items as $item) {
1398
+        $data = array_map('trim', explode('|', $item));
1399 1399
 
1400
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1400
+        if (empty($data[0]) || !is_numeric($data[0])) {
1401 1401
             continue;
1402 1402
         }
1403 1403
 
1404 1404
         $quantity = 1;
1405
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1405
+        if (isset($data[1]) && is_numeric($data[1])) {
1406 1406
             $quantity = (int) $data[1];
1407 1407
         }
1408 1408
 
1409
-        $prepared[ $data[0] ] = $quantity;
1409
+        $prepared[$data[0]] = $quantity;
1410 1410
 
1411 1411
     }
1412 1412
 
@@ -1416,13 +1416,13 @@  discard block
 block discarded – undo
1416 1416
 /**
1417 1417
  * Helper function to convert item array to string.
1418 1418
  */
1419
-function getpaid_convert_items_to_string( $items ) {
1419
+function getpaid_convert_items_to_string($items) {
1420 1420
     $prepared = array();
1421 1421
 
1422
-    foreach ( $items as $item => $quantity ) {
1422
+    foreach ($items as $item => $quantity) {
1423 1423
         $prepared[] = "$item|$quantity";
1424 1424
     }
1425
-    return implode( ',', $prepared );
1425
+    return implode(',', $prepared);
1426 1426
 }
1427 1427
 
1428 1428
 /**
@@ -1430,22 +1430,22 @@  discard block
 block discarded – undo
1430 1430
  * 
1431 1431
  * Provide a label and one of $form, $items or $invoice.
1432 1432
  */
1433
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1434
-    $label = sanitize_text_field( $label );
1433
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1434
+    $label = sanitize_text_field($label);
1435 1435
     $nonce = wp_create_nonce('getpaid_ajax_form');
1436 1436
 
1437
-    if ( ! empty( $form ) ) {
1438
-        $form  = esc_attr( $form );
1437
+    if (!empty($form)) {
1438
+        $form = esc_attr($form);
1439 1439
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
1440 1440
     }
1441 1441
 	
1442
-	if ( ! empty( $items ) ) {
1443
-        $items  = esc_attr( $items );
1442
+	if (!empty($items)) {
1443
+        $items = esc_attr($items);
1444 1444
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
1445 1445
     }
1446 1446
     
1447
-    if ( ! empty( $invoice ) ) {
1448
-        $invoice  = esc_attr( $invoice );
1447
+    if (!empty($invoice)) {
1448
+        $invoice = esc_attr($invoice);
1449 1449
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
1450 1450
     }
1451 1451
 
@@ -1456,17 +1456,17 @@  discard block
 block discarded – undo
1456 1456
  *
1457 1457
  * @param WPInv_Invoice $invoice
1458 1458
  */
1459
-function getpaid_the_invoice_description( $invoice ) {
1459
+function getpaid_the_invoice_description($invoice) {
1460 1460
     $description = $invoice->get_description();
1461 1461
 
1462
-    if ( empty( $description ) ) {
1462
+    if (empty($description)) {
1463 1463
         return;
1464 1464
     }
1465 1465
 
1466
-    $description = wp_kses_post( $description );
1466
+    $description = wp_kses_post($description);
1467 1467
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1468 1468
 }
1469
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1469
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1470 1470
 
1471 1471
 /**
1472 1472
  * Render element on a form.
@@ -1474,60 +1474,60 @@  discard block
 block discarded – undo
1474 1474
  * @param array $element
1475 1475
  * @param GetPaid_Payment_Form $form
1476 1476
  */
1477
-function getpaid_payment_form_element( $element, $form ) {
1477
+function getpaid_payment_form_element($element, $form) {
1478 1478
 
1479 1479
     // Set up the args.
1480
-    $element_type    = trim( $element['type'] );
1480
+    $element_type    = trim($element['type']);
1481 1481
     $element['form'] = $form;
1482
-    extract( $element );
1482
+    extract($element);
1483 1483
 
1484 1484
     // Try to locate the appropriate template.
1485
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1485
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1486 1486
     
1487 1487
     // Abort if this is not our element.
1488
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1488
+    if (empty($located) || !file_exists($located)) {
1489 1489
         return;
1490 1490
     }
1491 1491
 
1492 1492
     // Generate the class and id of the element.
1493
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1494
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1493
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1494
+    $id            = isset($id) ? $id : uniqid('gp');
1495 1495
 
1496 1496
     // Echo the opening wrapper.
1497 1497
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1498 1498
 
1499 1499
     // Fires before displaying a given element type's content.
1500
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1500
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1501 1501
 
1502 1502
     // Include the template for the element.
1503 1503
     include $located;
1504 1504
 
1505 1505
     // Fires after displaying a given element type's content.
1506
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1506
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1507 1507
 
1508 1508
     // Echo the closing wrapper.
1509 1509
     echo '</div>';
1510 1510
 }
1511
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1511
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1512 1512
 
1513 1513
 /**
1514 1514
  * Render an element's edit page.
1515 1515
  *
1516 1516
  * @param WP_Post $post
1517 1517
  */
1518
-function getpaid_payment_form_edit_element_template( $post ) {
1518
+function getpaid_payment_form_edit_element_template($post) {
1519 1519
 
1520 1520
     // Retrieve all elements.
1521
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1521
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1522 1522
 
1523
-    foreach ( $all_elements as $element ) {
1523
+    foreach ($all_elements as $element) {
1524 1524
 
1525 1525
         // Try to locate the appropriate template.
1526
-        $element = sanitize_key( $element );
1527
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1526
+        $element = sanitize_key($element);
1527
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1528 1528
 
1529 1529
         // Continue if this is not our element.
1530
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1530
+        if (empty($located) || !file_exists($located)) {
1531 1531
             continue;
1532 1532
         }
1533 1533
 
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
     }
1539 1539
 
1540 1540
 }
1541
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1541
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1542 1542
 
1543 1543
 /**
1544 1544
  * Render an element's preview.
@@ -1547,16 +1547,16 @@  discard block
 block discarded – undo
1547 1547
 function getpaid_payment_form_render_element_preview_template() {
1548 1548
 
1549 1549
     // Retrieve all elements.
1550
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1550
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1551 1551
 
1552
-    foreach ( $all_elements as $element ) {
1552
+    foreach ($all_elements as $element) {
1553 1553
 
1554 1554
         // Try to locate the appropriate template.
1555
-        $element = sanitize_key( $element );
1556
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1555
+        $element = sanitize_key($element);
1556
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1557 1557
 
1558 1558
         // Continue if this is not our element.
1559
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1559
+        if (empty($located) || !file_exists($located)) {
1560 1560
             continue;
1561 1561
         }
1562 1562
 
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
     }
1568 1568
 
1569 1569
 }
1570
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1570
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1571 1571
 
1572 1572
 /**
1573 1573
  * Shows a list of gateways that support recurring payments.
@@ -1575,17 +1575,17 @@  discard block
 block discarded – undo
1575 1575
 function wpinv_get_recurring_gateways_text() {
1576 1576
     $gateways = array();
1577 1577
 
1578
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1579
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1580
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1578
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1579
+        if (wpinv_gateway_support_subscription($key)) {
1580
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1581 1581
         }
1582 1582
     }
1583 1583
 
1584
-    if ( empty( $gateways ) ) {
1585
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1584
+    if (empty($gateways)) {
1585
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1586 1586
     }
1587 1587
 
1588
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1588
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1589 1589
 
1590 1590
 }
1591 1591
 
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
  * @return GetPaid_Template
1596 1596
  */
1597 1597
 function getpaid_template() {
1598
-    return getpaid()->get( 'template' );
1598
+    return getpaid()->get('template');
1599 1599
 }
1600 1600
 
1601 1601
 /**
@@ -1604,23 +1604,23 @@  discard block
 block discarded – undo
1604 1604
  * @param array args
1605 1605
  * @return string
1606 1606
  */
1607
-function getpaid_paginate_links( $args ) {
1607
+function getpaid_paginate_links($args) {
1608 1608
 
1609 1609
     $args['type']     = 'array';
1610 1610
     $args['mid_size'] = 1;
1611
-    $pages        = paginate_links( $args );
1611
+    $pages = paginate_links($args);
1612 1612
 
1613
-    if ( ! is_array( $pages ) ) {
1613
+    if (!is_array($pages)) {
1614 1614
         return '';
1615 1615
     }
1616 1616
 
1617 1617
     $_pages = array();
1618
-    foreach ( $pages as $page ) {
1619
-        $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page );
1618
+    foreach ($pages as $page) {
1619
+        $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page);
1620 1620
     }
1621 1621
 
1622 1622
     $links  = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>";
1623
-    $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages );
1623
+    $links .= join("</li>\n\t\t<li class='page-item'>", $_pages);
1624 1624
     $links .= "</li>\n\t</ul>\n</nav>\n";
1625 1625
 
1626 1626
     return $links;
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_complete.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_expired.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_cancelled.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-renewal_reminder.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print invoice details.
22
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print invoice items.
25
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
26 26
 
27 27
 // Print the billing details.
28
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
28
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
29 29
 
30 30
 // Print the email footer.
31
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
31
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_trial.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.